Log in

View Full Version : Dialogues



zamp
12-22-2012, 04:03 PM
I think dialogues could be done server side so the client only gets the message (what the npc says) and options (what you can say as a reply) for any given dialogue. When they choose one option they get the next.

Could be done like so:


foo = new Dialog("dialog_file.xml");
OnPlayerUse(player,object)
{
if (object.type == MyOwnGeckObjectTypeThatIsAComputerOrSomething)
player.dialog = foo;
}


Having a dialogue in a file would make scripting more difficult so the dialogs could be hard-coded too which would give you much more control over what happens (dialogue exits with a timer or whatever you want)

I've made a dialogue system like this for my own game that uses xml files and the scripting is done with lua.


<?xml version="1.0" encoding="utf-8"?>
<dialogue name="Some healer guy">
<segment name="default">
<script>
if (player.health < player.maxHealth) then
dialog.addOption("heal","Heal me please!"))
end
</script>

<message>...</message>
<option goto="exit">Nevermind..</option>
</segment>

<segment name="heal">
<script>
player.health = player.maxHealth
</script>
<message>There you go. Good as new!</message>
<option goto="exit">Thanks!</option>
</segment>
</dialogue>

Edit: Removed cdata from scripts since it derped out and came out like this <=!=C=D=A=T=A=[

There's also a <forward> element that you have in place of options which will append the message to the beginning of what it forwards to.


<segment name="foo">
<message>Hello </message>
<forward>bar</forward>
</segment>
<segment name="bar">
<message>world</message>
<option goto="exit">Ok</option>
</segment>

This would print out "Hello world"

foxtacles
12-22-2012, 04:47 PM
Sounds good. We'll have to deal with more important features like NPC synchronization first though, but I will get back to this!

roby65
12-23-2012, 09:22 AM
I think dialogues should be handled like sa-mp handles custom menus, it's very flexible ;-)