Dialogs

From Mod Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 23:31, 18 July 2008 (edit)
Drengor (Talk | contribs)

← Previous diff
Revision as of 01:52, 19 July 2008 (edit) (undo)
Don Reba (Talk | contribs)
m (formatting)
Next diff →
Line 1: Line 1:
-{{Potential article}}+===Dialog Introduction===
-'''S.T.A.L.K.E.R.''''' Dialogs'' 
- 
-__TOC__ 
- 
-===Dialog Introduction=== 
Firstly, there are two methods for creating dialogs. As the [[Quest]] page has briefly documented, there is a 'static' dialog tree which allows for a fairly simple conversation to be defined. Additionally, you can create 'dynamic' or script controlled dialogs. Firstly, there are two methods for creating dialogs. As the [[Quest]] page has briefly documented, there is a 'static' dialog tree which allows for a fairly simple conversation to be defined. Additionally, you can create 'dynamic' or script controlled dialogs.
===Static vs Dynamic - which to use.=== ===Static vs Dynamic - which to use.===
 +
For most dialogs, the static dialog will be simpler and sufficient. It will define a pre-planned conversation tree that can branch either by user selection, or the use of 'preconditions'. For most dialogs, the static dialog will be simpler and sufficient. It will define a pre-planned conversation tree that can branch either by user selection, or the use of 'preconditions'.
Line 17: Line 13:
A simple static dialog might be as follows. A simple static dialog might be as follows.
-:.Hey, man, what's up?+:Hey, man, what's up?
-:..Not much, how are things with you?+:Not much, how are things with you?
-:...Pretty good, thanks.+:Pretty good, thanks.
-:....Good to hear, keep it up.+:Good to hear, keep it up.
-:...I've been better.+:I've been better.
-:....Well, tomorrow's a new day, here's hoping for better luck.+:Well, tomorrow's a new day, here's hoping for better luck.
-:...I'm scraping bottom here, man.+:I'm scraping bottom here, man.
-:....That sucks, mate. Sorry to hear it.+:That sucks, mate. Sorry to hear it.
So a simple conversation with one opening line, one response, and three branches for the third response. We may choose to let the user choose one of the three branches, or limit which are available with preconditions. So a simple conversation with one opening line, one response, and three branches for the third response. We may choose to let the user choose one of the three branches, or limit which are available with preconditions.
Line 32: Line 28:
<source lang="xml"> <source lang="xml">
<dialog id="our_casual_conversation"> <dialog id="our_casual_conversation">
- <phrase_list>+ <phrase_list>
- <phrase id="0">+ <phrase id="0">
- <text>our_casual_dialog_0</text>+ <text>our_casual_dialog_0</text>
- <next>1</next>+ <next>1</next>
- </phrase>+ </phrase>
- <phrase id="1">+ <phrase id="1">
- <text>our_casual_dialog_1</text>+ <text>our_casual_dialog_1</text>
- <next>11</next>+ <next>11</next>
- <next>12</next>+ <next>12</next>
- <next>13</next>+ <next>13</next>
- </phrase>+ </phrase>
- <phrase id="11">+ <phrase id="11">
- <text>our_casual_dialog_11</text>+ <text>our_casual_dialog_11</text>
- <next>111</next>+ <next>111</next>
- </phrase>+ </phrase>
- <phrase id="12">+ <phrase id="12">
- <text>our_casual_dialog_12</text>+ <text>our_casual_dialog_12</text>
- <next>121</next>+ <next>121</next>
- </phrase>+ </phrase>
- <phrase id="13">+ <phrase id="13">
- <text>our_casual_dialog_13</text>+ <text>our_casual_dialog_13</text>
- <next>131</next>+ <next>131</next>
- </phrase>+ </phrase>
- <phrase id="111">+ <phrase id="111">
- <text>our_casual_dialog_111</text>+ <text>our_casual_dialog_111</text>
- </phrase>+ </phrase>
- <phrase id="121">+ <phrase id="121">
- <text>our_casual_dialog_121</text>+ <text>our_casual_dialog_121</text>
- </phrase>+ </phrase>
- <phrase id="131">+ <phrase id="131">
- <text>our_casual_dialog_131</text>+ <text>our_casual_dialog_131</text>
- </phrase>+ </phrase>
- </phrase_list>+ </phrase_list>
</dialog> </dialog>
</source> </source>
- 
=== Dynamic Dialogs === === Dynamic Dialogs ===
 +
Dynamic dialogs do not define the whole tree, but rather define an initialization script that will be able to determine what phrases to add. Dynamic dialogs do not define the whole tree, but rather define an initialization script that will be able to determine what phrases to add.
<source lang="xml"> <source lang="xml">
- <dialog id="dm_hello_dialog">+<dialog id="dm_hello_dialog">
- <init_func>dialog_manager.init_intro_dialog</init_func>+ <init_func>dialog_manager.init_intro_dialog</init_func>
- </dialog>+</dialog>
</source> </source>
- 
=== Preconditions === === Preconditions ===
Line 84: Line 79:
It is important to note any errors in dialog_manager.script will prevent the dialog_manager global from being assigned and will crash the game immediately with the message It is important to note any errors in dialog_manager.script will prevent the dialog_manager global from being assigned and will crash the game immediately with the message
-<source lang="lua">+:[error]Arguments : LUA error: e:\games\stalker\gamedata\scripts\_g.script:1255: attempt to index global 'dialog_manager' (a nil value)
-[error]Arguments : LUA error: e:\games\stalker\gamedata\scripts\_g.script:1255: attempt to index global 'dialog_manager' (a nil value)+
-</source>+
Preconditions are called with five parameters - the original speaker, the other speaker, and P1,P2,and P3 (which I've yet to see used, and have no idea what they really are) Preconditions are called with five parameters - the original speaker, the other speaker, and P1,P2,and P3 (which I've yet to see used, and have no idea what they really are)
Line 93: Line 86:
<source lang="lua"> <source lang="lua">
function precondition_is_stalker(speaker1,speaker2,P1,P2,P3) function precondition_is_stalker(speaker1,speaker2,P1,P2,P3)
- if IsStalker(speaker2) then+ if IsStalker(speaker2) then
- return true+ return true
- end+ end
- return false+ return false
end end
</source> </source>

Revision as of 01:52, 19 July 2008

Contents

Dialog Introduction

Firstly, there are two methods for creating dialogs. As the Quest page has briefly documented, there is a 'static' dialog tree which allows for a fairly simple conversation to be defined. Additionally, you can create 'dynamic' or script controlled dialogs.

Static vs Dynamic - which to use.

For most dialogs, the static dialog will be simpler and sufficient. It will define a pre-planned conversation tree that can branch either by user selection, or the use of 'preconditions'.

Dynamic dialogs will use script to determine how the conversation progresses instead of a pre-planned tree. In the standard game, nearly every stalker has the option of having 'cool info' that more or less randomly gives a response when you ask if they know anything interesting. This uses a 'dynamic' dialog with script 'randomly' deciding which response the stalker will give.

Static Dialogs

A simple static dialog might be as follows.

— Hey, man, what's up?
— Not much, how are things with you?
— Pretty good, thanks.
— Good to hear, keep it up.
— I've been better.
— Well, tomorrow's a new day, here's hoping for better luck.
— I'm scraping bottom here, man.
— That sucks, mate. Sorry to hear it.

So a simple conversation with one opening line, one response, and three branches for the third response. We may choose to let the user choose one of the three branches, or limit which are available with preconditions.

To define this dialog statically, we would make a dialog xml structure, and insert it into one of the dialog*.xml files in the config\gameplay folder.

<dialog id="our_casual_conversation">
	<phrase_list>
		<phrase id="0">
			<text>our_casual_dialog_0</text>
			<next>1</next>
		</phrase>
		<phrase id="1">
			<text>our_casual_dialog_1</text>
			<next>11</next>
			<next>12</next>
			<next>13</next>
		</phrase>
		<phrase id="11">
			<text>our_casual_dialog_11</text>
			<next>111</next>
		</phrase>
		<phrase id="12">
			<text>our_casual_dialog_12</text>
			<next>121</next>
		</phrase>
		<phrase id="13">
			<text>our_casual_dialog_13</text>
			<next>131</next>
		</phrase>
		<phrase id="111">
			<text>our_casual_dialog_111</text>
		</phrase>
		<phrase id="121">
			<text>our_casual_dialog_121</text>
		</phrase>
		<phrase id="131">
			<text>our_casual_dialog_131</text>
		</phrase>
	</phrase_list>
</dialog>

Dynamic Dialogs

Dynamic dialogs do not define the whole tree, but rather define an initialization script that will be able to determine what phrases to add.

<dialog id="dm_hello_dialog">
	<init_func>dialog_manager.init_intro_dialog</init_func>
</dialog>

Preconditions

Both Dynamic and Static dialogs allow the use of the <precondition> tag. Preconditions are script functions that must return 'true' for the dialog to be enabled. The precondition functions are defined in dialog_manager.script.

It is important to note any errors in dialog_manager.script will prevent the dialog_manager global from being assigned and will crash the game immediately with the message

[error]Arguments : LUA error: e:\games\stalker\gamedata\scripts\_g.script:1255: attempt to index global 'dialog_manager' (a nil value)

Preconditions are called with five parameters - the original speaker, the other speaker, and P1,P2,and P3 (which I've yet to see used, and have no idea what they really are)

A simple precondition might look like

function precondition_is_stalker(speaker1,speaker2,P1,P2,P3)
	if IsStalker(speaker2) then
		return true
	end
 
	return false
end

and there are many predefined preconditions, like

function has_2000_money(first_speaker, second_speaker)
	return first_speaker:money() >= 2000
end

Which dialog*.xml to use

You will have noticed there are several dialog*.xml files in the config/gameplay folder. One is generically named dialog.xml, and the rest have a zone name in them (IE. dialog_escape.xml) Very basically, all zones will include the dialog.xml and the zone specific xml... so if your new dialog will only show up in one zone, add it to the zone specific (to keep resource usage down), but if it will be used in multiple zones (all zones), you may add it to the dialog.xml.

Text Strings

In all of the dialogs, you have put an identifier, not the actual text you want to appear. This is to allow multiple language versions of the game. You must add entries to the appropriate stable_dialog*.xml file(s) for the languages you will support.

How to add dialogs to characters

Dialogs are added to characters via <start_dialog> or <actor_dialog> tags in the character definition. These determine who is speaker1 and who is speaker2. <start_dialog> tags indicate the npc is starting the conversation and is speaker1.

If your dialog is for a specific character, you simply add it to that character's definition. If your dialog should be available to all characters, you may add it to character_dialogs.xml, and it will show up for everyone EXCEPT special characters (unless preconditions limit it further).

So, if we wanted our static dialog to show up for all random characters, we would add

<start_dialog>our_casual_conversation</start_dialog>

to character_dialogs.xml.

Personal tools