Different Character Response Options for Action (eg trying to leave a room)

Started by PightyMirate, Wed 16/06/2021 09:31:13

Previous topic - Next topic

PightyMirate

Hi All,

I'm sure this is a super easy and I DID see some info on this yesterday but I cannot find it again  :embarrassed:

I want the player to say different responses each time he tries to leave a room (or walk on to a hotspot). Is this a string command? The dialogue options will be similar to:

1: I cant go that way.
2: Seriously, I cant go that way.
3: I have told you already, I cant go that way

Then loop response 3 once the first 2 have been shown.

I dont know the term for this particular script so having difficulty searching for info and it's not in the tutorial!

Many thanks  (nod)

Vincent

You should check how many times the player has entered the region with an int, so on your 'Walks onto region' function you should write something simple like this:

Code: ags

int step = 0;

function region0_WalksOnto()
{
  if (step != 3) step ++;
  if (step == 1) player.say("I cant go that way.");
  else if (step == 2) player.say("Seriously, I cant go that way.");
  else player.say("I have told you already, I cant go that way");
}

Khris


Hobbes

Just wondering Vincent (with my limited experience) if your final "else" statement also needs a step = 1 to repeat the cycle?

So:

Code: ags

int step = 0;
 
function region0_WalksOnto()
{
  if (step != 3) step ++;
  if (step == 1) player.say("I cant go that way.");
  else if (step == 2) player.say("Seriously, I cant go that way.");
  else {
    player.say("I have told you already, I cant go that way");
    step = 1;
    }
}


Not 100% sure, since my scripting skills aren't that strong.

PightyMirate

Quote from: Vincent on Wed 16/06/2021 10:15:55
You should check how many times the player has entered the region with an int, so on your 'Walks onto region' function you should write something simple like this:

Code: ags

int step = 0;

function region0_WalksOnto()
{
  if (step != 3) step ++;
  if (step == 1) player.say("I cant go that way.");
  else if (step == 2) player.say("Seriously, I cant go that way.");
  else player.say("I have told you already, I cant go that way");
}


Thanks Vincent   8-)

PightyMirate

Quote from: Khris on Wed 16/06/2021 10:17:57
There's no built-in mechanism for this, however there's a really old module called MultiResponse:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=27947.0

This is awesome! Thank you so much (again) Khris  :-*

It's really fun and easy to add the different responses, so cool.

Vincent

@Hobbes If you want to repeat that cycle with this script the int step should be reset to 0 and not 1

Code: ags

int step = 0;

function region0_WalksOnto()
{
  if (step != 3) step ++;
  if (step == 1) player.Say("I cant go that way.");
  else if (step == 2) player.Say("Seriously, I cant go that way.");
  else 
  {
    player.Say("I have told you already, I cant go that way");
    step = 0;
  }
}


If you reset step to 1 when player enter the region step will become 2 and it will start saying "Seriously, I cant go that way." so it should be reset to step 0 if you want it to start from the beginning saying "I cant go that way."

SMF spam blocked by CleanTalk