Skip to main content
gamedev.net
🔒 Locked

Speech Tree

Started by Greg K 4 replies 550+ views
Original Post
Greg K
Greg K
Does anyone have a gracefull way to handle a speech tree as with a standard npc? What methods are out there and what are your favourites? Any suggestions would be great. -Greg Reverie Entertainment
krez
krez
i designed and partially implemented this once, for an RPG that i never seem to actually finish.

there is a PC_CHOICE class, and an NPC_RESPONSE class. both have an index member, the actually text which is "said", a list of indices to "unlock" (i.e. when the player selects the "tell me about that evil cave" response, the NPC says "what would you like to know about it", and unlocks a few more choices for the player to ask about, such as "do you know the way through?", "what creatures live there?", etc). they also have a script member, in case that part of the conversation requires it (to give an item, begin combat, end conversation, alter the NPCs state (i.e. made him angry), etc).

the PC_CHOICE objects are in a list, and the "available" (unlocked, through previous conversation or at the beginning for the "hello, villager" message) ones are displayed to the player to pick. when one is picked, the appropriate NPC_RESPONSE is displayed, the script (if it exists) is run, and the choices are redisplayed.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Kylotan
Kylotan
Mine is similar to the above. Each speech node has some text, a list of other nodes it hides, and a list of other nodes it reveals. You have a default node which is used at the start of the conversation and that typically reveals 3 or 4 other nodes. Those nodes in turn may reveal others, and so on. The final action was to add a script hook to the nodes so that choosing certain options could result in actions being taken.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.