"""Complete dialogue system with NPC interaction."""
def__init__(self):
self.scene=mcrfpy.Scene("dialogue_system")
self.ui=self.scene.children
# Create NPC
self.npc=NPC("Elder Sage")
# Dialogue tree
self.dialogue_tree=self._create_dialogue_tree()
self.setup()
def_create_dialogue_tree(self):
"""Create the dialogue tree structure."""
return{
"greeting":{
"text":"Greetings, traveler. I am the Elder Sage of this village. What brings you to these remote lands?",
"choices":[
("I seek wisdom and knowledge.","wise_response"),
("I'm looking for treasure!","treasure_response"),
("None of your business.","rude_response"),
("I'm lost. Can you help me?","help_response"),
]
},
"wise_response":{
"text":"Ah, a seeker of truth! That is admirable. Knowledge is the greatest treasure one can possess. Tell me, what specific wisdom do you seek?",
"mood":"happy",
"trust_change":10,
"choices":[
("I want to learn about the ancient prophecy.","prophecy"),
("Teach me about magic.","magic"),
("I wish to know the history of this land.","history"),
]
},
"treasure_response":{
"text":"Treasure? Bah! Material wealth corrupts the soul. But... perhaps you could prove yourself worthy of learning where such things might be found.",
"mood":"suspicious",
"trust_change":-5,
"choices":[
("I apologize. I spoke hastily.","apologize"),
("I don't need your approval!","defiant"),
("What must I do to prove myself?","prove_worthy"),
]
},
"rude_response":{
"text":"How dare you speak to me with such disrespect! Leave my presence at once!",
"mood":"angry",
"trust_change":-30,
"choices":[
("I'm sorry, I didn't mean that.","apologize_angry"),
("Make me!","defiant"),
("*Leave quietly*","leave"),
]
},
"help_response":{
"text":"Lost? Poor soul. These mountains can be treacherous. I will help you find your way, but first, tell me where you wish to go.",
"mood":"neutral",
"trust_change":5,
"choices":[
("To the nearest town.","directions"),
("Anywhere but here.","sad_path"),
("Actually, maybe I'll stay a while.","stay"),
]
},
"prophecy":{
"text":"The ancient prophecy speaks of a chosen one who will restore balance when darkness falls. Many believe that time is now approaching...",
"mood":"neutral",
"choices":[
("Am I the chosen one?","chosen"),
("How can I help prevent this darkness?","help_prevent"),
("That sounds like nonsense.","skeptic"),
]
},
"magic":{
"text":"Magic is not learned from books alone. It flows from within, from understanding the natural world. Your journey has only begun.",
"mood":"happy",
"choices":[
("Will you teach me?","teach"),
("I understand. Thank you.","thanks"),
]
},
"history":{
"text":"This land was once a great kingdom, until the Shadow Wars tore it asunder. Now only ruins remain of its former glory.",
"mood":"sad",
"choices":[
("What caused the Shadow Wars?","shadow_wars"),
("Can the kingdom be restored?","restore"),
("Thank you for sharing.","thanks"),
]
},
"apologize":{
"text":"Hmm... perhaps I misjudged you. True wisdom includes recognizing one's mistakes. Let us start again.",
"mood":"neutral",
"trust_change":5,
"choices":[
("Thank you for understanding.","wise_response"),
]
},
"apologize_angry":{
"text":"*sighs* Very well. I accept your apology. But mind your tongue in the future.",
"mood":"neutral",
"trust_change":-10,
"choices":[
("I will. Now, I seek wisdom.","wise_response"),
("Thank you, Elder.","thanks"),
]
},
"defiant":{
"text":"GUARDS! Remove this insolent fool from my sight!",
"mood":"angry",
"trust_change":-50,
"choices":[
("*Run away!*","escape"),
("*Fight the guards*","fight"),
]
},
"prove_worthy":{
"text":"There is a sacred trial in the mountains. Complete it, and I may reconsider my opinion of you.",
"mood":"neutral",
"trust_change":5,
"choices":[
("I accept the challenge!","accept_trial"),
("What kind of trial?","trial_info"),
("Perhaps another time.","decline"),
]
},
"thanks":{
"text":"You are welcome, traveler. May your journey be blessed with wisdom and good fortune. Return if you need guidance.",
"mood":"happy",
"choices":[
("Farewell, Elder.","end_good"),
("I have more questions.","greeting"),
]
},
"end_good":{
"text":"Farewell. May the ancient spirits watch over you.",
"mood":"happy",
"choices":[
("*Restart conversation*","greeting"),
]
},
"leave":{
"text":"Perhaps it is for the best. Safe travels... if you can find your way.",
"mood":"neutral",
"choices":[
("*Restart conversation*","greeting"),
]
},
"escape":{
"text":"*You flee into the wilderness, the guards' shouts fading behind you...*",
"mood":"neutral",
"choices":[
("*Restart conversation*","greeting"),
]
},
"fight":{
"text":"*The guards overwhelm you. You wake up in a cell...*",
"mood":"angry",
"choices":[
("*Restart conversation*","greeting"),
]
},
# Default responses for missing states
"chosen":{"text":"That remains to be seen. Only time will tell.","mood":"neutral","choices":[("I understand.","thanks")]},
"help_prevent":{"text":"Prepare yourself. Train hard. The darkness comes for us all.","mood":"neutral","choices":[("I will.","thanks")]},
"skeptic":{"text":"Believe what you will. But when darkness comes, remember my words.","mood":"sad","choices":[("Perhaps you're right.","apologize")]},
"teach":{"text":"In time, perhaps. First, prove your dedication.","mood":"neutral","choices":[("How?","prove_worthy")]},
"shadow_wars":{"text":"Ancient evils that should have remained buried. Let us speak no more of it.","mood":"sad","choices":[("I understand.","thanks")]},
"restore":{"text":"Perhaps... if the chosen one rises. Perhaps.","mood":"neutral","choices":[("I hope so.","thanks")]},
"directions":{"text":"Head east through the mountain pass. The town of Millbrook lies two days' journey.","mood":"neutral","choices":[("Thank you!","thanks")]},
"sad_path":{"text":"I sense great pain in you. Perhaps you should stay and heal.","mood":"sad","choices":[("You're right.","stay")]},
"stay":{"text":"You are welcome here. Rest, and we shall talk more.","mood":"happy","choices":[("Thank you, Elder.","thanks")]},
"accept_trial":{"text":"Brave soul! Seek the Cave of Trials to the north. Return victorious!","mood":"happy","choices":[("I will return!","thanks")]},
"trial_info":{"text":"It tests courage, wisdom, and heart. Few have succeeded.","mood":"neutral","choices":[("I'll try anyway!","accept_trial"),("Maybe not...","decline")]},
"decline":{"text":"Perhaps another time then. The offer stands.","mood":"neutral","choices":[("Thank you.","thanks")]},