Divergent/mods/iTheon New Tasks/gamedata/scripts/modxml_nta.script

68 lines
2.3 KiB
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
local npcs_requiring_task_dialog = {
character_desc_pripyat = {"trader_pri_a15_mlr"},
character_desc_jupiter = {"jup_a6_stalker_barmen"},
character_desc_bar = {"bar_informator_mlr"},
}
local custom_dialogs = {
character_desc_garbage = {
baraholka_trader = [[
<actor_dialog>baraholka_trader_the_living_fire_1</actor_dialog>
<actor_dialog>baraholka_trader_the_living_fire_2</actor_dialog>
]]
},
character_desc_bar = {
bar_informator_mlr = [[
<actor_dialog>bar_informator_mlr_the_living_fire_2</actor_dialog>
<actor_dialog>bar_informator_mlr_the_living_fire_3</actor_dialog>
<actor_dialog>bar_informator_mlr_the_living_fire_4</actor_dialog>
<actor_dialog>bar_informator_mlr_the_living_fire_5</actor_dialog>
]]
},
character_desc_yantar = {
yan_stalker_sakharov = [[
<actor_dialog>yan_stalker_sakharov_the_living_fire_1</actor_dialog>
<actor_dialog>yan_stalker_sakharov_the_living_fire_2</actor_dialog>
<actor_dialog>yan_stalker_sakharov_the_living_fire_3</actor_dialog>
<actor_dialog>yan_stalker_sakharov_the_living_fire_4</actor_dialog>
<actor_dialog>yan_stalker_sakharov_the_living_fire_5</actor_dialog>
]]
},
character_desc_escape = {
esc_2_12_stalker_trader = [[
<actor_dialog>esc_2_12_stalker_trader_the_living_fire_1</actor_dialog>
]]
}
}
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
for file_name, npcs in pairs(npcs_requiring_task_dialog) do
if xml_file_name:find(file_name .. ".xml") then
for _, npc in ipairs(npcs) do
local query_res = xml_obj:query("specific_character[id=" .. npc .. "]")
if not (type(query_res) == "table" and size_table(query_res) == 1) then return end
local el = query_res[1]
local task_dialog = [[
<actor_dialog>dm_ordered_task_dialog</actor_dialog>
<actor_dialog>dm_ordered_task_completed_dialog</actor_dialog>
]]
xml_obj:insertFromXMLString(task_dialog, el, #el.kids)
end
end
end
for file_name, npcs in pairs(custom_dialogs) do
if xml_file_name:find(file_name .. ".xml") then
for npc, dial in pairs(npcs) do
local query_res = xml_obj:query("specific_character[id=" .. npc .. "]")
if not (type(query_res) == "table" and size_table(query_res) == 1) then return end
local el = query_res[1]
xml_obj:insertFromXMLString(dial, el, #el.kids)
end
end
end
end)
end