Skip to content

Dialogs

PRXPHET edited this page May 27, 2025 · 1 revision

Dialog extensions

  • Force reload mode, will call init_func every time a dialog window is opened. Allows to rebuild the whole graph. Only works if c init_func (and therefore no phrase_list) in xml:

XML: force_reload=“1”.

LUA: dlg.SetForceReload(true)

  • For phrases set text via scripts:

XML: <script_text>dialog_manager.create_bye_phrase</script_text>

LUA: phrase_script:SetScriptText(“travel_manager.squad_action_description”)

Parameters are the same as for action\predicate.

  • New script methods for building dialogs via init_func:
dlg.SetPriority(123) -- change dialog priority
dlg.SetCaption(“test”) -- change title
dlg.SetForceReload(false) -- change the force_reload flag (stop updating the dialog after some condition)
dlg.GetPhrase(“PhraseId”) -- get phrase by id
dlg.GetPhraseScript() -- access to CPhraseScript of the dialog itself. (only AddPrecondition/AddHasInfo/AddDontHasInfo methods work)

phrase.GetText() -- get the text of the phrase
phrase.SetText(str) -- change the text of the phrase
  • Support for passing arguments to functions called from dialogs, such as:
<precondition>my_script.test_func(123, true, nil, ...)</precondition>
<action>my_script.test_func(123, true, nil, ...)</action>

If you specify a variable number of arguments ... at the end, standard arguments like pSpeakerGO1->lua_game_object(), pSpeakerGO2->lua_game_object(), dialog_id, phrase_id will be passed there.

Accelerators for response dialogs

  • **Accelerator from 1 to 0 is assigned to each phrase, i.e. if you press the corresponding button, the corresponding phrase will be selected. To show these numbers before phrases, you need to enable the show_dialog_numbers option in the features section, because this requires an additional statik “num_text” in talk.xml, as in CoP. Here is a working example:
<question_item x="0" y="0" width="527" height="20" min_height="13">
	<num_text x="0" y="0" width="8" height="20">
		<text font="letterica18" r="255" g="232" b="208" align="l" />
	</num_text>
	<content_text x="15" y="0" width="512" height="20">
	<text font="letterica18" r="255" g="232" b="208" align="l" complex_mode="1"/>
	<text_color>
		<t r="231" g="168" b="12"/> <e r="255" g="232" b="208"/> <h r="255" g="255" b="255"/>
	</text_color>
	
	</content_text>
</question_item>
  • Added the SetAccelerator( dik, idx ) method to script buttons, which allows you to assign a key to a button from the script, when you press it, it should be triggered. Same as the “accel” attribute in the xml config.

Ability to reload changed tasks

Given tasks are saved in the save file and saved completely: text, infoportions, functions, etc. Therefore, changing <game_task/> will not affect an already issued task. In order to affect it, I added two attributes. They are version and objectives_version. By default, both are 0. When version is incremented, e.g.

<game_task id=“shax_plennik” prio=“0” version=“1”>
</game_task>

parameters of the task from the save file will be ignored, except for issue time, etc., as well as <objective/> states. I.e. those sub-jobs that have already been completed will remain completed. If you increase objectives_version in addition to version, for example

<game_task id="shax_plennik" prio="0" version="1" objectives_version="1">
</game_task>

then the saved state of subtasks will not be used. This makes sense if the number of subtasks or their meaning is changed in the config.

Please note. These are not flags. These are version numbers and they should increase monotonically.

Support for canceling tasks

  • For xml tasks added : infoportion_skipped, infoportion_set_skipped, function_skipped, function_call_skipped.
  • For xml ui tasks, added color task_sub_item:description:text_colors:skipped and texture ui_icons_PDA_subtask_skipped.
  • For scripts, added methods for the SGameTaskObjective: class add_skipped_info, add_on_skipped_info, add_skipped_info, add_skipped_func, add_on_skipped_func and a new ETaskState: skipped.

To add a canceled tasks tab to the PDA, add a new button in pda_events.xml. Example:

<button x="155" y="0" width="50" height="18"hint="pda_btn_skipped_hint">
    <text align="c" x="0" y="0" font="letterica18" r="255" g="255" b="255" complex_mode="0">pda_btn_skipped</text>
    <text_color>
		<t r="231" g="168" b="12"/> <d r="181" g="170" b="148"/> <e r="127" g="127" b="127"/> <h r="255" g="255" b="255"/>
    </text_color>
</button>
Clone this wiki locally