allow d_got_item and d_trade to be used as target dialogs and as target for failed actions

This commit is contained in:
Sokomine 2024-12-15 13:50:58 +01:00
parent a54c395e91
commit bfeed37767

View File

@ -177,9 +177,10 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam
yl_speak_up.speak_to[pname].d_id = this_action.a_on_failure yl_speak_up.speak_to[pname].d_id = this_action.a_on_failure
yl_speak_up.speak_to[pname].o_id = nil yl_speak_up.speak_to[pname].o_id = nil
yl_speak_up.speak_to[pname].a_id = nil yl_speak_up.speak_to[pname].a_id = nil
yl_speak_up.show_fs(player, "talk", {n_id = n_id, -- allow d_end, d_trade, d_got_item etc. to work as a_on_failure
d_id = this_action.a_on_failure, yl_speak_up.show_next_talk_fs_after_action(player, pname,
alternate_text = this_action.alternate_text}) this_action.a_on_failure, formname,
dialog, d_id, n_id, this_action.alternate_text)
return return
else else
local this_action = actions[ sorted_key_list[ nr ]] local this_action = actions[ sorted_key_list[ nr ]]
@ -220,6 +221,26 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam
local target_dialog = res.next_dialog local target_dialog = res.next_dialog
yl_speak_up.speak_to[pname].o_id = nil yl_speak_up.speak_to[pname].o_id = nil
yl_speak_up.speak_to[pname].a_id = nil yl_speak_up.speak_to[pname].a_id = nil
-- the function above returns a target dialog; show that to the player
yl_speak_up.show_next_talk_fs_after_action(player, pname, target_dialog, formname,
dialog, target_dialog, n_id, res.alternate_text)
end
-- after completing the action - either successfully or if it failed:
yl_speak_up.show_next_talk_fs_after_action = function(player, pname, target_dialog, formname,
dialog, d_id, n_id, alternate_text)
-- allow to switch to d_trade from any dialog
if(target_dialog and target_dialog == "d_trade") then
yl_speak_up.show_fs(player, "trade_list")
return
end
-- allow to switch to d_got_item from any dialog
if(target_dialog and target_dialog == "d_got_item") then
yl_speak_up.show_fs(player, "player_offers_item")
return
end
-- end conversation -- end conversation
if(target_dialog and target_dialog == "d_end") then if(target_dialog and target_dialog == "d_end") then
yl_speak_up.stop_talking(pname) yl_speak_up.stop_talking(pname)
@ -229,18 +250,16 @@ yl_speak_up.execute_next_action = function(player, a_id, result_of_a_id, formnam
end end
return return
end end
-- the special dialogs d_trade and d_got_item have no actions or effects - thus
-- d_id cannot become d_trade or d_got_item
if(not(target_dialog) if(not(target_dialog)
or target_dialog == "" or target_dialog == ""
or not(dialog.n_dialogs[target_dialog])) then or not(dialog.n_dialogs[target_dialog])) then
target_dialog = d_id target_dialog = d_id
end end
if(target_dialog and target_dialog == "d_trade") then -- actually show the next dialog to the player
yl_speak_up.show_fs(player, "trade_list")
return
end
-- the function above returns a target dialog; show that to the player
yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog, yl_speak_up.show_fs(player, "talk", {n_id = n_id, d_id = target_dialog,
alternate_text = res.alternate_text}) alternate_text = alternate_text})
end end