Show auto attack forecasts in battle HUD
This commit is contained in:
@@ -6152,6 +6152,12 @@ func _update_forecast() -> void:
|
||||
forecast_label.text = "전황: 병장 봉인\n무기로 공격할 수 없습니다."
|
||||
return
|
||||
|
||||
if not bool(preview.get("in_range", false)):
|
||||
var auto_attack_text := _format_auto_attack_forecast_text(selected, target)
|
||||
if not auto_attack_text.is_empty():
|
||||
forecast_label.text = auto_attack_text
|
||||
return
|
||||
|
||||
var range_text := "사거리 안" if preview["in_range"] else "사거리 밖"
|
||||
var defeat_text := " 퇴각" if preview["would_defeat"] else ""
|
||||
var effective_text := _format_effective_forecast_text(preview, "effective_bonus", "effective_target_type")
|
||||
@@ -6182,6 +6188,45 @@ func _update_forecast() -> void:
|
||||
]
|
||||
|
||||
|
||||
func _format_auto_attack_forecast_text(selected: Dictionary, target: Dictionary) -> String:
|
||||
if selected.is_empty() or target.is_empty():
|
||||
return ""
|
||||
if basic_attack_targeting or _has_pending_move() or bool(selected.get("moved", false)) or bool(selected.get("acted", false)):
|
||||
return ""
|
||||
var origin := _best_auto_attack_origin(selected, target)
|
||||
if origin == Vector2i(-1, -1):
|
||||
return ""
|
||||
var current_cell: Vector2i = selected.get("pos", Vector2i(-1, -1))
|
||||
if origin == current_cell:
|
||||
return ""
|
||||
var preview := _auto_attack_preview_for_origin(selected, target, origin)
|
||||
if preview.is_empty():
|
||||
return ""
|
||||
var move_distance := _manhattan(current_cell, origin)
|
||||
var defeat_text := " 퇴각" if bool(preview.get("would_defeat", false)) else ""
|
||||
var directional_text := _format_directional_forecast_text(preview, "directional_bonus", "directional_label")
|
||||
var counter_text := ""
|
||||
if bool(preview.get("counter_in_range", false)):
|
||||
var counter_defeat := " 퇴각" if bool(preview.get("counter_would_defeat", false)) else ""
|
||||
counter_text = "\n반격 %d, 명중 %d%%.%s" % [
|
||||
int(preview.get("counter_damage", 0)),
|
||||
int(preview.get("counter_hit_chance", 0)),
|
||||
counter_defeat
|
||||
]
|
||||
return "전황: 행공 진 %d,%d 이동 %d칸\n피해 %d%s, 명중 %d%%, 적 병력 %d/%d.%s%s" % [
|
||||
origin.x + 1,
|
||||
origin.y + 1,
|
||||
move_distance,
|
||||
int(preview.get("damage", 0)),
|
||||
directional_text,
|
||||
int(preview.get("hit_chance", 0)),
|
||||
int(preview.get("target_hp_after", 0)),
|
||||
int(target.get("max_hp", 1)),
|
||||
defeat_text,
|
||||
counter_text
|
||||
]
|
||||
|
||||
|
||||
func _format_effective_forecast_text(preview: Dictionary, bonus_key: String, type_key: String) -> String:
|
||||
var bonus := int(preview.get(bonus_key, 0))
|
||||
if bonus <= 0:
|
||||
|
||||
Reference in New Issue
Block a user