Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PightyMirate on Wed 16/06/2021 09:31:13

Title: Different Character Response Options for Action (eg trying to leave a room)
Post by: PightyMirate on Wed 16/06/2021 09:31:13
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)
Title: Re: Different Character Response Options for Action (eg trying to leave a room)
Post by: 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) Select

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");
}
Title: Re: Different Character Response Options for Action (eg trying to leave a room)
Post by: 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
Title: Different Character Response Options for Action (eg trying to leave a room)
Post by: Hobbes on Wed 16/06/2021 12:16:13
Just wondering Vincent (with my limited experience) if your final "else" statement also needs a step = 1 to repeat the cycle?

So:

Code (ags) Select

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.
Title: Re: Different Character Response Options for Action (eg trying to leave a room)
Post by: PightyMirate on Wed 16/06/2021 13:20:50
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) Select

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-)
Title: Re: Different Character Response Options for Action (eg trying to leave a room)
Post by: PightyMirate on Wed 16/06/2021 13:21:43
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.
Title: Re: Different Character Response Options for Action (eg trying to leave a room)
Post by: Vincent on Wed 16/06/2021 14:03:46
@Hobbes If you want to repeat that cycle with this script the int step should be reset to 0 and not 1

Code (ags) Select

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."