Add scripted event withdrawals
This commit is contained in:
@@ -3648,6 +3648,15 @@ func _execute_event_action(action: Dictionary, trigger_unit: Dictionary = {}) ->
|
||||
return
|
||||
for deployment in deployments:
|
||||
_spawn_event_deployment(deployment)
|
||||
elif action_type == "withdraw_unit":
|
||||
_withdraw_event_unit(str(action.get("unit_id", action.get("id", ""))))
|
||||
elif action_type == "withdraw_units":
|
||||
var unit_ids = action.get("unit_ids", [])
|
||||
if typeof(unit_ids) != TYPE_ARRAY:
|
||||
push_error("Skipping malformed withdrawal list in %s." % battle_id)
|
||||
return
|
||||
for unit_id in unit_ids:
|
||||
_withdraw_event_unit(str(unit_id))
|
||||
|
||||
|
||||
func _grant_event_items(item_entries, trigger_unit: Dictionary = {}) -> void:
|
||||
@@ -3781,6 +3790,25 @@ func _spawn_event_deployment(deployment) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _withdraw_event_unit(unit_id: String) -> bool:
|
||||
var normalized_id := unit_id.strip_edges()
|
||||
if normalized_id.is_empty():
|
||||
push_error("Skipping event withdrawal with no unit_id in %s." % battle_id)
|
||||
return false
|
||||
var unit := get_unit(normalized_id)
|
||||
if unit.is_empty() or not unit.get("deployed", true) or not unit.get("alive", false):
|
||||
return false
|
||||
if selected_unit_id == normalized_id:
|
||||
selected_unit_id = ""
|
||||
_emit_combat_feedback(unit, "WITHDRAW", "fade")
|
||||
unit["deployed"] = false
|
||||
unit["acted"] = true
|
||||
unit["moved"] = true
|
||||
_emit_log("%s withdraws from the battlefield." % unit.get("name", normalized_id))
|
||||
_notify_changed()
|
||||
return true
|
||||
|
||||
|
||||
func _reset_team_actions(team: String) -> void:
|
||||
_apply_phase_status_effects_for_team(team)
|
||||
_check_battle_status()
|
||||
|
||||
Reference in New Issue
Block a user