Scripting problem with talking to character.

Started by ddavey1983, Tue 31/01/2017 14:00:02

Previous topic - Next topic

ddavey1983

Hello. I'm having an issue with Sierra-style speech to a character.

I want my player character to say one thing to the sergeant on first speaking to him, something else the second and any subsequent times up until an event happens and then a third thing when speaking to him after that event has happened.

It all sort of works. However, I can't stop him saying the first and second thing together the first time. My code is below. (The event which happens changed the variable sargespoken to 3).


function csarge_Talk()
{
{cEgo.Walk (75, 125, eBlock);
cEgo.FaceCharacter (csarge);
}
if(sargespoken == 0)
{cEgo.Say ("You wanted to see me, sergeant?");
csarge.Say ("Ah, Private Smith. That latrine needs cleaning. Hop to it.");
sargespoken = 1;
}
if (sargespoken == 1)
{csarge.Say ("Have you cleaned that latrine yet?");
}
if (sargespoken == 3)
{csarge.Say ("That explosion came from up the trench!");
}
}

I know its because as soon as the sargespoken value changes to 1 he wants to say the second thing. How can I put a break in so he doesn't?

Thanks

dayowlron

Proper indention would help. but try this: (basically what your missing is an else condition to not check the second if.
Code: ags

function csarge_Talk()
{
  cEgo.Walk (75, 125, eBlock);
  cEgo.FaceCharacter (csarge);
  if(sargespoken == 0)
  {
    cEgo.Say ("You wanted to see me, sergeant?");
    csarge.Say ("Ah, Private Smith. That latrine needs cleaning. Hop to it.");
    sargespoken = 1;
  } else if (sargespoken == 1)
  {
    csarge.Say ("Have you cleaned that latrine yet?");
  }
  if (sargespoken == 3)
  {
    csarge.Say ("That explosion came from up the trench!");
  }
}
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

ddavey1983


SMF spam blocked by CleanTalk