Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GameMaker_95 on Sat 21/11/2015 10:36:58

Title: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Sat 21/11/2015 10:36:58
Hi all,

Okay, so it's not a problem that I have, I just want to ask a question. I've searched the manual and forum and cannot find what I'm looking for,
I'm beginning to think I imagined it. Is there a function or such that if I talked to one character say, Cop that will give me a different response
from Vet because I've talked to Cop (Without using the HasInventoryItem function) . I feel like I saw something like HasPlayerTalkedToSomeone somewhere on the forum but I could be wrong. Also,
regarding this, is there any way to get a different response from Vet if I chose a specific option in the Dialog with the Cop?

Thanks in advance.
GameMaker95
Title: Re: Different dialog responses from certain dialog options.
Post by: Gurok on Sat 21/11/2015 11:04:24
I think the method you're thinking of is HasOptionBeenChosen. It's a method of Dialog objects. You call it like this:

if(dCop.HasOptionBeenChosen(3)) // Has the third option in the cop's dialogue been chosen?
{
   ...
Title: Re: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Sat 21/11/2015 11:54:30
Hi Gurok,

No I already knew that one but I was looking for something more like hasplayerbeeninroom but with has player spoken to
an NPC. If that is what I'm looking for then how would I reference that in regards to changing the dialog of another character?

Thanks,
GameMaker95
Title: Re: Different dialog responses from certain dialog options.
Post by: Slasher on Sat 21/11/2015 12:22:36
you could use booleans

for example:

global booleans
if_talk_cop=false
if_talk_vet=false

just change to true when talk to npc // cop or vet  before dialog opens
in the dialogs change to if whichever are true npc say this...

you could then use other booleans afterwards in the dialog
global booleans
talked_to_cop
talked_to_vet

something along these lines..



Title: Re: Different dialog responses from certain dialog options.
Post by: Gurok on Sat 21/11/2015 12:32:27
Expanding on what Slasher said, I don't think there's any function like that specifically for talk interactions. You'd have to use a global variable like so:

bool talked_to_cop;

function cCop_Talk()
{
    talked_to_cop = true;
    cCop.Say("Stay safe.");
}

function cVet_Talk()
{
    if(talked_to_cop)
        cVet.Say("Ayyy lmao");
    else
        cVet.Say("I love animals.");
}


Regarding referencing things in regards to changing the dialogue of another character, it depends on how your dialogue is structured. If it's just straight .Say() statements, you can do it as above. If you've got these statements embedded within a dialogue script, you can reference global variables there too, but you'll need to export them from the global script:

In GlobalScript.asc
bool talked_to_cop;

export talked_to_cop;


In GlobalScript.ash
import bool talked_to_cop;

If you're still looking to get a different response from vet if you chose a specific option in the dialogue with the cop, HasOptionBeenChosen will cover that.
Title: Re: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Sun 22/11/2015 00:18:00
Thank you everyone. I will try everything you said and get back to you if I managed to
get it to work.
Title: Re: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Sun 22/11/2015 01:46:30
Hi,

Awesome, I did what both of you said and I've got it working. Gurok, I do want to choose a specific option with the
cop to change what dialog i use with the vet, so would I be able to turn the bool on from within the dialog like that? If I had the
bool for if i talked to the cop but only after i selected that option?

GameMaker95
Title: Re: Different dialog responses from certain dialog options.
Post by: Slasher on Sun 22/11/2015 05:44:26
yes, you can use booleans within the dialogs options to enable/disable options. Either at the startup point or within options with if/else conditions.


examples:

Code (ags) Select

// Dialog script file
@S  // Dialog startup entry point
aWaves.Play();
cCharles.Walk(1210, 493, eBlock, eWalkableAreas);
cCharles.Loop=3;

if(Beach_whore==false && Find_Polly==true)
option-on 4  // turns option 4 on
if(Height==true && Jez_Height==false)
option-on 2 // turns option 2 on


within option:

Code (ags) Select

@1
object[2].SetView(52);
object[2].Animate(0, 4, eRepeat, eNoBlock);
cJack.Say("&1 Horrible he was! Face all screwed-up and he had mad eyes");
cJack.Say("&12 He also had a limp.");
object[2].SetView(52, 0, 0);
cCharles.Say("&15 Mmm.");
cCharles.Say("&16 It could have been the Ripper about to strike again!");
object[2].SetView(52);
object[2].Animate(0, 4, eRepeat, eNoBlock);
cJack.Say("&2 It were the Ripper that done in my best friend: Annie Chapman!");
object[2].SetView(52, 0, 0);
cCharles.Say("&17 I'm sorry to hear that.");

if(Game.DoOnceOnly("Mad eyes")){
LNotes.Text=LNotes.Text.Append("  Jeezebel said her attacker had 'Mad eyes' and had a limp.");
LIdentity.Text=LIdentity.Text.Append(" [* Has a limp.");
}
option-off 1 // turns option 1 off


Title: Re: Different dialog responses from certain dialog options.
Post by: Cassiebsg on Sun 22/11/2015 10:48:41
Like Gurok said: HasOptionBeenChosen can save you a bool. ;)
Title: Re: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Sun 22/11/2015 10:57:14
Thanks everyone.

I've managed to do the basic stuff like if I talked to one character I can change which dialog
runs with the other but I'll be honest, getting the next part to work is probably too complicated for me
and hard to understand exactly. Thanks for your help.

GameMaker95
Title: Re: Different dialog responses from certain dialog options.
Post by: Khris on Sun 22/11/2015 13:16:52
First of all, there's a Global Variables pane where you can easily create booleans (flags) without having to bother with export and import lines.
Just create a new variable, and fill out the form like this:

got_warned_about_vet
bool
false

In your dialog with the cop, use something like
@3 // ask about vet
  if (got_warned_about_vet) cCop.Say("Like I said, he's dangerous.");
  else {
    cCop.Say("Stay away from him, he's dangerous.");
    got_warned_about_vet = true;
  }
return


Regular script can be used if the lines are indented by at least one blank space.
I'm also already using the variable to make the cop's response a little more varied.

You can now do arbitrary things in your other scripts, based on whether the variable is true or not.
Like this:
function cVet_Talkto() {
  if (got_warned_about_vet) dVet1.SetOptionState(5, eOptionOn);
  dVet1.Start();
}


Here, an option with "Show" being unchecked is turned on in the script, IF the player was warned about the vet by the cop.
You can of course also run a different dialog altogether, if getting warned changes your attitude towards the vet completely.
Title: Re: Different dialog responses from certain dialog options.
Post by: GameMaker_95 on Mon 23/11/2015 01:30:33
Hi Khris,

Thank you very much, you've explained that so I can make sense of it and It's exactly what I want,
less messier than what I was thinking.

Thanks for your help.
GameMaker95