Simplest way of implementing an "interrogation" system?

Started by Akril15, Fri 12/04/2013 05:31:56

Previous topic - Next topic

Akril15

Hello,

I'm creating a game which involves interrogating characters to learn information about various topics (similar to the notebook mechanic in Laura Bow 2). Since this would mean asking the same questions repeatedly, I was considering creating a single dialog tree displaying the 4-5 different topics, with different responses depending on which character is being interrogated.

However, this is turning out to be more challenging than it first appeared. I can't figure out a way to tell the dialog tree which character is being spoken to (and thus, exactly what to say when responding to the protagonist) other than assigning a boolean variable to every character that is set to "true" when the conversation starts, then "false" once the conversation ends. Is there a simpler way to go about this that I may have overlooked, or should I go ahead and start implementing the true/false variables?

As always, thanks in advance!

Slasher

Sounds a poser for you.

You obviously need a way to check which character the player is talking to in the dialog if you intend to do it this way.

This may involve if / else if functions and possibly variables etc etc to check which player the dialog refers to.

How you check which NPC could be done in various ways. Do you really want to go this route?

With just a few dialog options (you say 3 or 4) and they are the same for each NPC and you only have a few NPC's you might be better off letting each character have their own dialog. It would save the additional scripting.

You can copy and paste dialogs and just amend each dialogs NPC to show what it is 'they' will say in response.

It does save time and frustration.

Of course, if you want to go the other route then do so by all means and perhaps one of the super scripter's here will show you the best way to go about it.




Andail

I have a system where the player can ask various NPCs about notes in the journal. Every dialogue has an option "can I ask you about..." which will open the journal GUI, and set a string variable to the character's name. When I close the GUI, the dialog stops and the string is set to null.
I first check which character is being spoken to, and then which note is being talked about. I handle everything in the global script, and only use the dialogue editor for topics that are special for each character.
The benefit is that I have everything gathered in one place, and can quickly add responses if I add a journal entry.
The drawback is that I have to use the Say command instead of the slightly easier dialog editor.

Khris

I would do this:

Create a global variable called topic. You can make it a string, but a better way is to make it an int and use an enum for the topics.
Code: ags
// header
enum Topic {
  eTopicVictim = 1,
  eTopicCrimeScene = 2,
  eTopicMurderWeapon = 3
};

import int topic;
import void AskAbout(Topic t);

// top of global script
int topic;
export topic;
Character* interrogated;

void AskAbout(Topic t) {
  topic = t;
  interrogated.RunInteraction(eModeTalkto);
}


In a person's "talk to" event:

Code: ags
function cSuspect1_Talkto() {

  /*  method 1
  if (topic == 0) {
    interrogated = cSuspect1;
    dTopics.Start();
  }
  */

  if (topic == eTopicVictim) {
    cSuspect1.Say("I knew him only in passing.");
  }

  ...
}


In your dialog script:

Code: ags
@1
  AskAbout(1);
return;
@2
  AskAbout(2);
return;
...


Method 2:

In on_mouse_click
Code: ags
  // eMouseLeft
    if (mouse.mode == eModeTalkto && GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
      interrogated == Character.GetAtScreenXY(mouse.x, mouse.y);
      topic = 0;
      dTopics.Start();
    }
    else ProcessClick(mouse.x, mouse.y, mouse.Mode);


Method 1 will initialize the interrogation on a per-character basis.
Method 2 assumes that every NPC is going to be interrogated.

Not tested in any way!

Akril15

Khris, I couldn't get Method 1 to work, but I think I might be able to make do with the "Character* interrogated;" variable you included in that first block of code. It's been a while since I've done any serious scripting in AGS, and I think that might be all I need (at least for the time being). Thank you!

SMF spam blocked by CleanTalk