The Daily Click ::. Forums ::. Klik Coding Help ::. Dialogue system Implementing Choices?
 

Post Reply  Post Oekaki 
 

Posted By Message

J.C



Registered
  22/03/2013 05:18:14
Points
  118
3rd April, 2014 at 03/04/2014 18:26:11 -

Hey there, J.C. here again.

Has anyone ever tried to create a dialogue tree game mechanic similar to some point and click games?

Here's the setup:

One character finishes speaking, then four active objects along with string texts appear as dialogue choices that the player can select.

Here's the twist, there is a relationship mechanic that affects the events in the game and even the outcome of the story depending on the player's choice. If he says rude or hurtful comments, the relationship deteriorates, and vice versa.

What I'm wondering is, would a global alterable value be the best method to track the player's choices in game?


Edited by J.C

 
n/a

LordHannu

Crazy?

Registered
  22/04/2007
Points
  7910

VIP MemberStarTeddy BearRibbonGame of the Week Winner2021 Halloween Competition Winner2022 Hi-Score Mash-up Competition (Bronze)2023 Halloween Competition (Bronze)2023 Halloween Competition Entrant
5th April, 2014 at 05/04/2014 23:21:52 -

Hi! You can make objects global per person that play chat with. and each object has the values you can change. So im thinking it might be easier to have each object as a person and its values depending on responses?

 
n/a

tetsuya_shino



Registered
  12/08/2004
Points
  491
14th April, 2014 at 14/04/2014 03:57:11 -

Yes, it's possible in TGF with some effort, and simple in MMF2. Basicly you should have a master global counter to control the plot of the game. Then create counters for each character. For NPCs that aren't important to the story, you can use the master counter to check against.

For relationships make a counter with a min value of 1 and a max value of 100. Then set the counter to 50 by default. You could set it so when you say something nice you could add to the counter. When you piss that person off subtract from the counter. You could change the text depending on what the current value is. If the reply is neutral leave the counter unchanged. If you want to make things really complex combine the master and relationship counter in a single even;

-- The hero is on a quest to slay the dragon and he tries to recruit a female to his party. --

if master = 1
and girl A relationship = 50

''Ok! Let's go and kill that dragon.''

if master = 1
and girl A relationship = 97

''It sounds dangerous! What if you get hurt?''

if master = 1
and girl A relationship = 5

''Me? Go on a quest together with you? Not a chance!''

-- The dragon has been defeated. --

if master = 2
and girl A relationship = 50

''We did it! Good job.''

if master = 2
and girl A relationship = 97

''I had feared the worst, but somehow we were victorious.''

if master = 2
and girl A relationship = 5

''So you killed the dragon without my help? Who cares! Piss off!''
------------------

Another way to do a relationship counter is to have it start at 0 and max out at 100. Doing it this way everyone hates the hero at the start of the game, but slowly warms up to him as the game progresses. This is a good way to go if you don't want to deal with having a counter that goes up, neutral, or down. With this it's just neutral or up only.

Hope that helps. Good luck.







 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
7th May, 2014 at 07/05/2014 01:16:38 -

So, each dialog has 2-4 options. Each option has an associated active object the user clicks on which needs to modify a global value. Pretty straight-forward. You could set a global value to 50 and each of the four active objects could have two alterable values; positiveopt and negativeopt. At the beginning of each dialog, test the global value to determine how an NPC responds to the character's alignment (optional, but it might be neat to make the NPCs respond differently if the player's alignment is too good or too evil), set BOTH positiveopt and negativeopt for all actives to 0 THEN set either positiveopt or negativeopt for each dialog option accordingly. Lastly, when the player clicks one of the active objects associated with a dialog option, have the global value = global value +positiveopt -negativeopt of the clicked active.

Example:
NPC: Please look after my son.
Active1(positiveopt=2|negativeopt=0) String1: Sure thing!
Active2(positiveopt=1|negativeopt=0) String2: Only if you pay me.
Active3(positiveopt=0|negativeopt=1) String3: I have better things to do.
Active4(positiveopt=0|negativeopt=2) String4: Nope. Your kid seems like a real brat.

If the player begins with an alignment of 50 (neutral), chosing the fourth option would set the global value to 48. Choosing the second option would set the global value to 51.



 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
7th May, 2014 at 07/05/2014 01:46:51 -

Oh, and I'd add you could set this whole thing up to be an external script the game parses.

The easiest method would be using String Parser 2 and INI++.
In the INI, each group could be an NPC name.
The first string could look something like this:
"40|60|NPCresponse|2|0|option1|1|0|option2|0|1|option3|0|2|option4"
The second string could look like this:
"60|80|NPCresponse|2|0|option1|1|0|option2|0|1|option3|0|2|option4"

So, here's the breakdown.
The first two numbers are for testing character alignment. In the first string, the game will test if character alignment is more than 40 but less than 60. In the second string, it tests to see if alignment is more than 60 but less than 80. Once the game finds a range the alignment falls into, the NPCresponse is what the NPC says.

The fourth position is positiveopt and the fifth position is negativeopt. These values can be loaded into the active objects positiveopt and negativeopt alterable values. The option1, option2, option3, and option4 are the responses the player can chose from.

Add "|" as a delimiter to the StringParser2 object then when spawning the dialog, select the INI group by NPC name, then use StringParser2 to read the first string. Test the first and second elements to compare the range against the global character alignment value. If the alignment isn't within range, load the next string from the INI into StringParser2 and test ranges again. This time, if the alignment DOES fall within the set range, have the dialog display the NPCresponse and set the first active dialog object's positiveopt and negativeopt alterable values to the 4th and 5th elements... and the first string to the sixth element. You'll need to do the same for the second, third, and fourth active objects and string objects respectively. You might be able to use a fastloop to take care of most of this.

Keep in mind that you might need to use the Val$ function to convert the 'values' in each string of the INI to actual numerical values, since they're stored in the INI as a delimitable string.

After most of the dialog is complete for your game, you can encrypt the INI file so players can't change alignment modification values, but then you'll need to go back and have your game unencrypt the INI file at the start of each frame.


 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
   

Post Reply



 



Advertisement

Worth A Click