Different dialog responses from certain dialog options.

Started by GameMaker_95, Sat 21/11/2015 10:36:58

Previous topic - Next topic

GameMaker_95

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

Gurok

I think the method you're thinking of is HasOptionBeenChosen. It's a method of Dialog objects. You call it like this:

Code: ags
if(dCop.HasOptionBeenChosen(3)) // Has the third option in the cop's dialogue been chosen?
{
   ...
[img]http://7d4iqnx.gif;rWRLUuw.gi

GameMaker_95

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

Slasher

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




Gurok

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:

Code: ags
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
Code: ags
bool talked_to_cop;

export talked_to_cop;


In GlobalScript.ash
Code: ags
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.
[img]http://7d4iqnx.gif;rWRLUuw.gi

GameMaker_95

Thank you everyone. I will try everything you said and get back to you if I managed to
get it to work.

GameMaker_95

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

Slasher

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

// 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

@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



Cassiebsg

Like Gurok said: HasOptionBeenChosen can save you a bool. ;)
There are those who believe that life here began out there...

GameMaker_95

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

Khris

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
Code: ags
@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:
Code: ags
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.

GameMaker_95

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

SMF spam blocked by CleanTalk