Skip to content

Commit

Permalink
battle_calcs: provide default value for resistance modifiers
Browse files Browse the repository at this point in the history
This is done for cases when the value cannot be read from the unit_info
table, which might happen in some UMC.  This fixes a rare bug affecting
the Fast Micro AI attack evaluation
  • Loading branch information
mattsc committed Jun 16, 2014
1 parent ac262a1 commit 9e8ee00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions data/ai/lua/battle_calcs.lua
Expand Up @@ -115,7 +115,7 @@ function battle_calcs.strike_damage(attacker, defender, att_weapon, def_weapon,
local att_damage = attacker_info.attacks[att_weapon].damage

-- Opponent resistance modifier
local att_multiplier = defender_info.resist_mod[attacker_info.attacks[att_weapon].type]
local att_multiplier = defender_info.resist_mod[attacker_info.attacks[att_weapon].type] or 1

-- TOD modifier
att_multiplier = att_multiplier * AH.get_unit_time_of_day_bonus(attacker_info.alignment, att_lawful_bonus)
Expand All @@ -127,7 +127,7 @@ function battle_calcs.strike_damage(attacker, defender, att_weapon, def_weapon,
def_damage = defender_info.attacks[def_weapon].damage

-- Opponent resistance modifier
def_multiplier = attacker_info.resist_mod[defender_info.attacks[def_weapon].type]
def_multiplier = attacker_info.resist_mod[defender_info.attacks[def_weapon].type] or 1

-- TOD modifier
def_multiplier = def_multiplier * AH.get_unit_time_of_day_bonus(defender_info.alignment, def_lawful_bonus)
Expand Down

0 comments on commit 9e8ee00

Please sign in to comment.