Делаем разные action в диалогах: 1. Создаём обычный диалог:
<dialog id="test_dialog"> <dont_has_info>test_pogovoril</dont_has_info> <phrase_list> <phrase id="0"> <text>test_dialog_0</text> <next>1</next> </phrase> <phrase id="1"> <text>test_dialog_1</text> <next>2</next> <next>3</next> <next>4</next> </phrase> <phrase id="2"> <text>test_dialog_2</text> </phrase> <phrase id="3"> <text>test_dialog_3</text> </phrase> <phrase id="4"> <text>test_dialog_4</text> </phrase> </phrase_list> </dialog>
C такими текстами:
<string id="test_dialog_0"> <text>Я тестю функции.</text> </string> <string id="test_dialog_1"> <text>Ок, какую?</text> </string> <string id="test_dialog_2"> <text>Дать деньги</text> </string> <string id="test_dialog_3"> <text>Дать ПМ</text> </string> <string id="test_dialog_4"> <text>Заспавнить ПМ</text> </string>
2.Создаём свой скрипт в папке gamedata/script например test.script и пишем в него 3 функции:
function dat_dengi(first_speaker, second_speaker) dialogs.relocate_money(second_speaker, 3000, "in") end
Это функция отдачи денег ГГ. На месте 3000 любое число. На месте dat_dengi любое название.
function dat_item(first_speaker, second_speaker) dialogs.relocate_item_section(second_speaker, "wpn_pm", "in") end
Это функция отдачи предмета ГГ. На месте wpn_pm любой предмет. На месте dat_item любое название.
function spawn_item_or_monster_or_stalker() alife():create("wpn_pm",vector():set(pos),lvid,gvid) end
Это функция спавна чего либо. На месте wpn_pm любой предмет,монстр или сталкер. На месте (pos),lvid,gvid) любые координаты. На месте spawn_item_or_monster_or_stalker любое название. Так же функция может быть одна, но с несколькими действиями. Например:
function all(first_speaker, second_speaker) dialogs.relocate_money(second_speaker, 3000, "in") dialogs.relocate_item_section(second_speaker, "wpn_pm", "in") alife():create("wpn_pm",vector():set(pos),lvid,gvid) end
Значит что одновременно ГГ дадут 3000 рублей, ПМ и по заданным координатам заспавнится ПМ.
3. Впишем функции в диалог:
<dialog id="test_dialog"> <phrase_list> <phrase id="0"> <text>test_dialog_0</text> <next>1</next> </phrase> <phrase id="1"> <text>test_dialog_1</text> <next>2</next> <next>3</next> <next>4</next> </phrase> <phrase id="2"> <text>test_dialog_2</text> <action>test.dat_dengi</action> </phrase> <phrase id="3"> <text>test_dialog_3</text> <action>test.dat_item</action> </phrase> <phrase id="4"> <text>test_dialog_4</text> <action>test.spawn_item_or_monster_or_stalker</action> </phrase> </phrase_list> </dialog>
Это значит что после после фразы <text>test_dialog_2</text> ГГ дадут 3000руб.
А после после фразы <text>test_dialog_3</text>, ГГ дадут ПМ.
И после после фразы <text>test_dialog_3</text>, заспавнится ПМ.
|