Appearance sets
This commit is contained in:
@@ -22,7 +22,7 @@ func create_proposal(attacker: DeployedUnit, defender: DeployedUnit, distance: i
|
||||
func _filter_tactics(deployed: DeployedUnit, distance: int) -> Array[CombatTactic]:
|
||||
var valid: Array[CombatTactic] = []
|
||||
for tactic in deployed.tactics:
|
||||
if tactic.tactic_range and tactic.tactic_range.is_valid_range(distance, deployed.unit):
|
||||
if tactic.tactic_range and tactic.tactic_range.is_valid_range(distance, deployed.current_stats):
|
||||
valid.append(tactic)
|
||||
return valid
|
||||
|
||||
@@ -35,27 +35,29 @@ func _find_default_attack(tactics: Array[CombatTactic]) -> CombatTactic:
|
||||
|
||||
|
||||
func _snapshot(deployed: DeployedUnit, opponent: DeployedUnit, available: Array[CombatTactic], selected: CombatTactic, opponent_selected: CombatTactic) -> CombatProposal.CombatantStats:
|
||||
var current := deployed.current_stats
|
||||
var opp_current := opponent.current_stats
|
||||
var stats := CombatProposal.CombatantStats.new()
|
||||
stats.deployed = deployed
|
||||
stats.max_hp = deployed.unit.stats.max_hp
|
||||
stats.hp = deployed.current_stats.current_hp
|
||||
stats.sp = deployed.current_stats.current_sp
|
||||
stats.spd = deployed.unit.stats.spd
|
||||
stats.max_hp = current.max_hp
|
||||
stats.hp = current.current_hp
|
||||
stats.sp = current.current_sp
|
||||
stats.spd = current.spd
|
||||
stats.available_tactics = available
|
||||
stats.selected_tactic = selected
|
||||
|
||||
if selected and selected.deals_damage():
|
||||
var offensive: Dictionary = selected.get_offensive_stats(deployed.unit)
|
||||
var offensive: Dictionary = selected.get_offensive_stats(current)
|
||||
stats.atk = offensive["atk"]
|
||||
stats.hit = offensive["hit"] - opponent.unit.stats.eva
|
||||
stats.hit = offensive["hit"] - opp_current.eva
|
||||
else:
|
||||
stats.atk = 0
|
||||
stats.hit = 0
|
||||
|
||||
if opponent_selected and opponent_selected.deals_damage():
|
||||
stats.def = opponent_selected.get_relevant_defense(deployed.unit)
|
||||
stats.def = opponent_selected.get_relevant_defense(current)
|
||||
else:
|
||||
stats.def = deployed.unit.stats.phys_def
|
||||
stats.def = current.phys_def
|
||||
|
||||
return stats
|
||||
|
||||
@@ -74,18 +76,18 @@ func update_tactic(proposal: CombatProposal, is_attacker: bool, tactic: CombatTa
|
||||
|
||||
# Recalculate this side's offensive stats
|
||||
if tactic and tactic.deals_damage():
|
||||
var offensive: Dictionary = tactic.get_offensive_stats(self_stats.deployed.unit)
|
||||
var offensive: Dictionary = tactic.get_offensive_stats(self_stats.deployed.current_stats)
|
||||
self_stats.atk = offensive["atk"]
|
||||
self_stats.hit = offensive["hit"] - opp_stats.deployed.unit.stats.eva
|
||||
self_stats.hit = offensive["hit"] - opp_stats.deployed.current_stats.eva
|
||||
else:
|
||||
self_stats.atk = 0
|
||||
self_stats.hit = 0
|
||||
|
||||
# Recalculate opponent's def based on this side's new tactic
|
||||
if tactic and tactic.deals_damage():
|
||||
opp_stats.def = tactic.get_relevant_defense(opp_stats.deployed.unit)
|
||||
opp_stats.def = tactic.get_relevant_defense(opp_stats.deployed.current_stats)
|
||||
else:
|
||||
opp_stats.def = opp_stats.deployed.unit.stats.phys_def
|
||||
opp_stats.def = opp_stats.deployed.current_stats.phys_def
|
||||
|
||||
|
||||
func select_ai_tactic(deployed: DeployedUnit, opponent: DeployedUnit, available_tactics: Array[CombatTactic]) -> CombatTactic:
|
||||
@@ -95,8 +97,8 @@ func select_ai_tactic(deployed: DeployedUnit, opponent: DeployedUnit, available_
|
||||
for tactic in available_tactics:
|
||||
if not tactic.deals_damage():
|
||||
continue
|
||||
var offensive: Dictionary = tactic.get_offensive_stats(deployed.unit)
|
||||
var defense: int = tactic.get_relevant_defense(opponent.unit)
|
||||
var offensive: Dictionary = tactic.get_offensive_stats(deployed.current_stats)
|
||||
var defense: int = tactic.get_relevant_defense(opponent.current_stats)
|
||||
var damage := maxi(offensive["atk"] - defense, 0)
|
||||
if damage > best_damage:
|
||||
best_damage = damage
|
||||
|
||||
Reference in New Issue
Block a user