Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: godofredo on Mon 24/09/2012 19:38:38

Title: Disable walk before dialog
Post by: godofredo on Mon 24/09/2012 19:38:38
Hi,

whenever I start a dialog with an NPC,my main character walks close to the NPC before
starting the dialog. I wan't to disable this as the main character is placed in the
top left corner of the NPC area. How do I do this?

Many thanks.
Title: Re: Disable walk before dialog
Post by: Andail on Tue 25/09/2012 08:47:13
Can you provide the code please? What command are you using to have the character walk to begin with? The coordinates are yours to set anywhere you want.
Title: Re: Disable walk before dialog
Post by: Khris on Tue 25/09/2012 10:49:26
godofredo uses the 9-verb template (godofredo: you should mention that in every relevant thread) which has a special set of functions (Go(), GoToCharacter(), etc.) that get called automatically.

This is hardcoded into on_mouse_click, for instance here:
Code (ags) Select
      // talkto
      else if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) {
        ActionLine.TextColor=ActionLabelColorHighlighted;
        if (GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player, 1)) character[GSlocid].RunInteraction(GSagsusedmode);
        SetAction(eMA_Default);
      }


To fix this, add a custom property to characters.
Let's call it "approach", any description, type Boolean, default value "true". (Or false of course, if that's going to happen more often.)
Open guiscript.asc, go to line 1475 and change it to this:

Code (ags) Select
        if (!character[GSlocid].GetProperty("approach") || GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player, 1))
          character[GSlocid].RunInteraction(GSagsusedmode);


Also, line 1521 (right click).
That should fix it.
Title: Re: Disable walk before dialog
Post by: godofredo on Tue 25/09/2012 16:14:36
WOW! What can I say, many thanks!!!

Pretty elegant solution that worked just perfect, and also gave me the opportunity
to play with custom properties.

Also sorry for not having mentioned my ASG and GUI versions, I gave it for granted as I had
posted another thread a couple of days ago.

Thanks again.
Title: Re: Disable walk before dialog
Post by: Khris on Tue 25/09/2012 17:37:09
Yes, I vaguely remembered that and checked your other posts.

Small correction for future readers of this: when setting up a bool in the custom properties editor, the default value has to be either 0 or 1, not "true" or "false".
Title: Re: Disable walk before dialog
Post by: rmonic79 on Sun 16/11/2014 18:30:32
hello, can you specify what lines i must change?