Yizzard
Member
Hey, so I've been working on a branching dialogue system for a while now, and I just can't seem to figure some stuff out. It currently works basically by having an invisible object spawn in the room that in it's creation code sets all of the NPCs in the room's text, then the NPC creates a dialogue box when interacted with and the box itself prints out the text using custom fonts and whatnot until reaching the end of the message then let's you choose an option and responds. The problem I'm having is that I don't know how to standardize it to where no matter how many branches I have it still works, for example, this is the creation code for a few test NPCs:
myText shows what the NPC says, optionTxt is what pops up that you can click on (Is usually a shortened version of response) and response is what John actually says back to the NPC. The above code all works perfectly correctly as you would expect, choosing option 0 makes John say response 0 and then triggers the next myText. The problem is, I don't know how to make the myText change depending on what John said and change the options depending on that, in other words, I can't figure out how to make the previous choices affect the current choices. I would really like to make it work similarly to this:
Obviously that doesn't work because I'm making the same arrays be a string, an array, a 2D array, a 3D array, ...(etc.) all at the same time, which as far as I'm aware, isn't possible. Any info you could give me on how I could go about with the logic on this would be greatly appreciated. And if you have any further questions, please ask! (I could record a little video demonstrating how it works if that would help at all or show you some more of the code from the text box/NPC's if you need, etc.)
Thanks for the help!
Code:
obj_GenericNPC_John.myText[0] = "Hello! We're outside now! I'm not a vampire, so I can survive the sun! Btw, I hate your dog.";
obj_GenericNPC_John.optionTxt[0, 0] = "Well I hate your dog!";
obj_GenericNPC_John.optionTxt[0, 1] = "I'm sorry to hear that";
obj_GenericNPC_John.optionTxt[0, 2] = "Sadface";
obj_GenericNPC_John.response[0, 0] = "Oh yeah? Well... I hate your dog! Your dog sucks just as much, if not more than mine!";
obj_GenericNPC_John.response[0, 1] = "Well I truly am very sorry to hear that, sir.";
obj_GenericNPC_John.response[0, 2] = "Why would you say that to me? That makes me truly sad. :(";
obj_GenericNPC_John.canChoose = 1;
obj_Naldi.myText[0] = "Hello John! Your dog sucks. Please get rid of it. I do not enjoy its presence";
obj_Naldi.optionTxt[0, 0] = "I will";
obj_Naldi.optionTxt[0, 1] = "No";
obj_Naldi.response[0, 0] = "You're right... My dogo really does suck... I will get rid of it at once!";
obj_Naldi.response[0, 1] = "No, it's my dog, I can keep it if I want to!";
obj_Naldi.myText[1] = "Well whether or not you get rid of this dog doesn't really matter, all that matters is that you like my dog. Youd do like my dog, right?";
obj_Naldi.optionTxt[1, 0] = "Well...";
obj_Naldi.optionTxt[1, 1] = "I do";
obj_Naldi.response[1, 0] = "Well... I actually really hate your dog and think it is more of a monstrosity than my dog.";
obj_Naldi.response[1, 1] = "Don't worry, I love your dog.";
obj_Naldi.myText[2] = "Alright. I understand";
obj_Naldi.canChoose = 2;
obj_GenericNPC_John2.myText[0] = "John... Hey... John... Sabrina is secretly...";
obj_GenericNPC_John2.optionTxt[0, 0] = "Secretly...?";
obj_GenericNPC_John2.optionTxt[0, 1] = "Shut up, clone.";
obj_GenericNPC_John2.response[0, 0] = "Secretly... What exactly?";
obj_GenericNPC_John2.response[0, 1] = "I don't have time for your tricks, clone!";
obj_GenericNPC_John2.myText[1] = "She's an eveil Watch!?!?!!!";
obj_GenericNPC_John2.optionTxt[1, 0] = "Oh no!";
obj_GenericNPC_John2.optionTxt[1, 1] = "Why do I talk to you?";
obj_GenericNPC_John2.response[1, 0] = "This is horrible news! What should we do?!?";
obj_GenericNPC_John2.response[1, 1] = "Why do I even talk to you...";
obj_GenericNPC_John2.myText[2] = "WE MUST BURN HER!";
obj_GenericNPC_John2.optionTxt[2, 0] = "Yes! We definately must!";
obj_GenericNPC_John2.optionTxt[2, 1] = "We must burn you!";
obj_GenericNPC_John2.response[2, 0] = "Yes! We will set the burning for tomorrow evening at 5:30 P.M. Eastern Standard Time.";
obj_GenericNPC_John2.response[2, 1] = "No... We must burn you instead! Muhahahaha!";
obj_GenericNPC_John2.canChoose = 3;
Code:
test.myText = "First line";
test.optionTxt[0] = "Opt 0";
test.optionTxt[1] = "Opt 1";
test.response[0] = "Opt 0 Text";
test.response[1] = "Opt 1 Text";
test.myText[0] = "Opt 0 Line";
test.optionTxt[0, 0] = "Opt 0 0";
test.optionTxt[0, 1] = "Opt 0 1";
test.response[0, 0] = "Opt 0 0 Text";
test.response[0, 1] = "Opt 0 1 Text";
test.myText[1] = "Opt 1 Line";
test.optionTxt[1, 0] = "Opt 1 0";
test.optionTxt[1, 1] = "Opt 1 1";
test.response[1, 0] = "Opt 1 0 Text";
test.response[1, 1] = "Opt 1 1 Text";
text.myText[0, 0] = "Opt 0 0 Line";
test.optionTxt[0, 0, 0] = "Opt 0 0 0";
test.optionTxt[0, 0, 1] = "Opt 0 0 1";
test.response[0, 0, 0] = "Opt 0 0 0 Text";
test.response[0, 0, 1] = "Opt 0 0 1 Text";
test.myText[0, 1] = "Opt 0 1 Line";
test.optionTxt[0, 1, 0] = "Opt 0 1 0";
test.optionTxt[0, 1, 1] = "Opt 0 1 1";
test.response[0, 1, 0] = "Opt 0 1 0 Text";
test.response[0, 1, 1] = "Opt 0 1 1 Text";
text.myText[1, 0] = "Opt 1 0 Line";
test.optionTxt[1, 0, 0] = "Opt 0 0 0";
test.optionTxt[1, 0, 1] = "Opt 0 0 1";
test.response[1, 0, 0] = "Opt 0 0 0 Text";
test.response[1, 0, 1] = "Opt 0 0 1 Text";
test.myText[1, 1] = "Opt 1 1 Line";
test.optionTxt[1, 1, 0] = "Opt 0 1 0";
test.optionTxt[1, 1, 1] = "Opt 0 1 1";
test.response[1, 1, 0] = "Opt 0 1 0 Text";
test.response[1, 1, 1] = "Opt 0 1 1 Text";
text.myText[0, 0, 0] = "Opt 0 0 0 Line";
... (etc.)
Thanks for the help!