Aller au contenu

Photo

Troubles with starting conversations from an On Enter script.


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
My scripts work fine as long as I am posessing my owned character when I transition areas.  If I am posessing one of my companions, they do not. 


Here is one of the scripts:

///////////////////////
void main()
{
FloatingTextStringOnCreature("worked",GetFirstPC());
object oCreature = GetEnteringObject(); 
object oLeader = GetOwnedCharacter(GetFactionLeader(oCreature));
object oSelf = OBJECT_SELF;
object oFirstPC = GetFirstPC();
object oArea = GetObjectByTag("area_2023");
///////////////////////////////////////////////////////////////////
//THIS CODE HANDLES THE CONVERSATIONS THAT START WHEN YOU ENTER THE AREA
//code for the grand finale battle when you enter after taking the courtyard
//try to make the PC posess the owned character so the conversations work.

if (GetIsOwnedByPlayer(oLeader))
{

int nJournal = GetJournalEntry("the_final_assault",oLeader);
effect eResurrection = EffectResurrection();
if (nJournal==20)
 {
  if (GetIsDead(oLeader))
  {
  ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrection,oLeader);
  }
// RemoveAllEffects(oLeader,TRUE);
 AssignCommand(oLeader,ClearAllActions(TRUE));
 DelayCommand(1.5,AssignCommand(oLeader,ActionStartConversation(oLeader,"2023_finale_entry_convo")));
 }
 

//integer for final escape from the tower.
int nPrepareFinalBattle = GetLocalInt(GetObjectByTag("area_2023"),"nPrepareFinalBattle");
//first time entering convo.
if (nPrepareFinalBattle == 1)
 
 {
 SetLocalInt(oArea,"nActivate202OnEnterConvo",1);
// AssignCommand(oCreature,ActionStartConversation(oCreature,"204_sentry_first_entrance",FALSE,FALSE,TRUE));
  AssignCommand(oLeader,ActionStartConversation(oCreature,"2023_before_final_escape",FALSE,FALSE,TRUE));
 }

}
}

Modifié par M. Rieder, 02 janvier 2012 - 11:56 .


#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Okay, I think I got it. I added

SetOwnersControlledCompanion(oCreature,oLeader);

And tested it and it seemed to work. But if anyone wants to comment, I welcome the remarks.


Below is the working copy:

////////////////////////
#include "ginc_cutscene"


// PART OF THE ALTHEA MAPPING SYSTEM

#include "alb_functions"

void main()
{
FloatingTextStringOnCreature("worked",GetFirstPC());
object oCreature = GetEnteringObject();
object oLeader = GetOwnedCharacter(GetFactionLeader(oCreature));
object oSelf = OBJECT_SELF;
object oFirstPC = GetFirstPC();
object oArea = GetObjectByTag("area_2023");
///////////////////////////////////////////////////////////////////
//THIS CODE HANDLES THE CONVERSATIONS THAT START WHEN YOU ENTER THE AREA
//code for the grand finale battle when you enter after taking the courtyard

//try to make the PC posess the owned character so the conversations work.
SetOwnersControlledCompanion(oCreature,oLeader);

if (GetIsOwnedByPlayer(oLeader))
{


int nJournal = GetJournalEntry("the_final_assault",oLeader);
effect eResurrection = EffectResurrection();
if (nJournal==20)

{
if (GetIsDead(oLeader))
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrection,oLeader);
}
// RemoveAllEffects(oLeader,TRUE);
AssignCommand(oLeader,ClearAllActions(TRUE));
DelayCommand(1.5,AssignCommand(oLeader,ActionStartConversation(oLeader,"2023_finale_entry_convo")));
}




//integer for final escape from the tower.
int nPrepareFinalBattle = GetLocalInt(GetObjectByTag("area_2023"),"nPrepareFinalBattle");

//first time entering convo.
if (nPrepareFinalBattle == 1)

{
SetLocalInt(oArea,"nActivate202OnEnterConvo",1);
// AssignCommand(oCreature,ActionStartConversation(oCreature,"204_sentry_first_entrance",FALSE,FALSE,TRUE));
AssignCommand(oLeader,ActionStartConversation(oCreature,"2023_before_final_escape",FALSE,FALSE,TRUE));
}


}



}

#3
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Generally, you should start conversations from the on-client-enter script, not the regular on-enter. I'm sure what exactly transpires between the two events, but basically the game isn't absolutely ready for player action until the on-client-enter, and setting up the newly-transitioned party might be part of those intervening preparations.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Well isn't that an important bit of information! Thank you very much. I'll implement that.

Just to clarify:
When does on-client-enter fire? Is it only with PCs, as the name suggests?

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
also... do you think I should change it now, even though it seems to work? I guess there is a possibility some other bugs could arise... maybe I should. I shudder at changing and re-testing all of my on-enter conversations... *shudder*

#6
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
As I understand it, on-enter fires every time a creature enters an area, and on-client-enter fires when the player actually sees the new area. Depending on the area and your computer, there can be a few seconds difference between when the PC first enters a new area (area loaded on the loadscreen) and when the loadscreen is done and the player can actually do anything.

This issue was notorious a few years ago, as builders were jumping PCs into areas directly into speak triggers, and the triggers fired before the client was ready.

Even if it works now, later, when the area is busier and the engine stressed, you could start to see issues.

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

Lugaid of the Red Stripes wrote...

Even if it works now, later, when the area is busier and the engine stressed, you could start to see issues.



This is exactly what happens.  I originally had PC's jumping into speak triggers and it worked fine until I got a few more areas into my mod, then it quit working all of a sudden.  So I switched to On Enter scripts, sadly I didn't know to use the client-on enter. 

Thanks again for your help, that is very useful to know.

My only question now is whether Lance Botelle's Fog of War scripts need to go in the On Enter or On Client enter.  If they work on the On Client Enter event, then I can just switch my entire on enter script with no modification.  If not... well... toolset time!

#8
Dann-J

Dann-J
  • Members
  • 3 161 messages
Indeed - OnClientEnter fires once the area is fully loaded and the player is fully in the area (and ready to receive script instructions).

Even then, I like to put a very brief delay on my OnClientEnter conversation scripts (like 0.2 seconds) just to make sure everything is ready for action.

#9
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
So If I put a script in the On Client Enter event, will it only fire once - that is, when the owned character enters the area? The on enter event fires anytime anything enters the area.

#10
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Would someone mind posting an example of their on client enter convo start scripts? I just want to see how others are doing it.

#11
Dann-J

Dann-J
  • Members
  • 3 161 messages
OnClientEnter will fire every time the player enters the area, so if you want a once-only conversation then you'll have to set a local variable on the area and have the script check it before running.

This is my very simple OnClientEnter conversation script. By changing the local variables on the area, you can have a different conversation fire at another point in the game:

// OnClientEnter script to start conversation when entering an area for the first time
// Set local variables Conversation and Talker (both strings) on the area

void TalkOnEnter()
{
object oArea = GetArea(GetFirstPC());
string sConv = GetLocalString(oArea, "Conversation");
string sTalker = GetLocalString(oArea, "Talker");
int iDone = GetLocalInt(oArea, "TalkDone");
if (iDone == 1)// Once marked done, never run again
return;
SetLocalInt(oArea, "TalkDone", 1);
AssignCommand(GetFirstPC(), ActionStartConversation(GetObjectByTag(sTalker),sConv, FALSE, FALSE, TRUE, FALSE));
}

void main()
{
DelayCommand(0.2, TalkOnEnter());// delay slightly before firing conversation
}