New menu-based conversation system update
Posted: Sat Jan 28, 2012 3:03 am
For a long time, I've been trying to update Christopher Tate's conversation system to make it a bit more robust. It's a long ways off from it being pretty enough to upload as an official library contribution (actually, I'm not sure that day will ever come), but I think I've fixed some of its worst problems (that is, the problems introduced by my changes) and that it's ready to be shared. I'm sure I have lots of inefficient and redundant code in there and I probably broke some of the original functionality, but hopefully some of the new features are worth it.
Like the original, you can have top-screen conversation menus that allow you to interact with objects in the room normally as you talk to the NPC, but you can also do bottom-screen "Photopia-style" menus. Instead of using a bunch of arrays to keep track of characters, questions, and responses, this uses an object-based container system (one conversation object holds topic objects which, in turn, hold assertation objects). The current topic determines which assertations are available at any given moment.
Download it here.
In this zip file, there is a chat.hug file which is a working example, but I'll go over all of the main points here:
1. Besides including newconverse.g and newconverse.h, call InitConverse in the init routine, after the player global variable has been defined (" player = you" or whatever).
2. Rearrange the main routine so PrintStatusLine is run after events and other possibly game-changing calls, like so:
3. Characters use the "npc" object class.
4. Set the game's chat options by replacing the "talkoptions" object and changing to your heart's content:
Of course, certain option combinations work better than others.
5. So, topic objects go in the conversation object, and Assertion objects go in topic objects.
Assertion objects have a bunch of optional (and non-optional) properties-
only_npc - the assertion is only available for this character
menu_choice - how the choice is listed in the menu
menu_response - the character's response text
show_assert - (defaults to true) when this Assert is chosen, it is printed again with quotes around it, like the player just said it... before going on to print the response. You can set it to false when you want to change the line completely and just throw the entire thing into the menu_response field
pretext - text to go before the assertion is printed (example: "You say, ")
posttext - text to go after the assertion (example: " you ask sheepishly.")
needscomma - if true, takes the last character from menu_choice and turns it into a comma (so a "This menu is cool." choice could be turned into '"This menu is cool," you say.'
6. If you want an Assertion initially hidden (but 'unlocked' later), define it with the visited attribute but take it away when you want the option to show up.
7. Non-forced conversations can be exited by typing >END CONVERSATION, >STOP TALKING, or >SHUT UP. On the other side of things, if you want to stop a conversation in-progress, call DoStopTalk(1) (The 1 means it is called silently).
Well, that's it for now. If you have more questions, ask me or take a look at the Christopher Tate's original conversation library; it probably describes some things better.
Anyhow, like I said, it ain't pretty, and I don't expect people to have no problems with it but I think it could be just the thing for some people trying to get menu-based conversations into their games.
Like the original, you can have top-screen conversation menus that allow you to interact with objects in the room normally as you talk to the NPC, but you can also do bottom-screen "Photopia-style" menus. Instead of using a bunch of arrays to keep track of characters, questions, and responses, this uses an object-based container system (one conversation object holds topic objects which, in turn, hold assertation objects). The current topic determines which assertations are available at any given moment.
Download it here.
In this zip file, there is a chat.hug file which is a working example, but I'll go over all of the main points here:
1. Besides including newconverse.g and newconverse.h, call InitConverse in the init routine, after the player global variable has been defined (" player = you" or whatever).
2. Rearrange the main routine so PrintStatusLine is run after events and other possibly game-changing calls, like so:
Code: Select all
routine main
{
if speaking not in location : speaking = 0
counter++
run location.each_turn
runevents
RunScripts
PrintStatusLine
}
4. Set the game's chat options by replacing the "talkoptions" object and changing to your heart's content:
Code: Select all
replace talkoptions
{
gNumAvailableAssertions 0 ! not to be changed
gDidSpeak 0 ! not to be changed
top 1 ! true if conversation menu on top of screen
show_topics 1 ! show available convo topics?
topic_change 1 ! allow topic changing?
conv_force 0 ! force convo commands?
auto 1 ! automatically switch topics when 1 is depleted?
stop_undo 0 ! disallow undo-ing in a conversation?
can_quit 1 ! disallow leaving a conversation?
}
5. So, topic objects go in the conversation object, and Assertion objects go in topic objects.
Assertion objects have a bunch of optional (and non-optional) properties-
only_npc - the assertion is only available for this character
menu_choice - how the choice is listed in the menu
menu_response - the character's response text
show_assert - (defaults to true) when this Assert is chosen, it is printed again with quotes around it, like the player just said it... before going on to print the response. You can set it to false when you want to change the line completely and just throw the entire thing into the menu_response field
pretext - text to go before the assertion is printed (example: "You say, ")
posttext - text to go after the assertion (example: " you ask sheepishly.")
needscomma - if true, takes the last character from menu_choice and turns it into a comma (so a "This menu is cool." choice could be turned into '"This menu is cool," you say.'
6. If you want an Assertion initially hidden (but 'unlocked' later), define it with the visited attribute but take it away when you want the option to show up.
7. Non-forced conversations can be exited by typing >END CONVERSATION, >STOP TALKING, or >SHUT UP. On the other side of things, if you want to stop a conversation in-progress, call DoStopTalk(1) (The 1 means it is called silently).
Well, that's it for now. If you have more questions, ask me or take a look at the Christopher Tate's original conversation library; it probably describes some things better.
Anyhow, like I said, it ain't pretty, and I don't expect people to have no problems with it but I think it could be just the thing for some people trying to get menu-based conversations into their games.