ExpAI: make recruiting work with all keys of [damage] special
Previously there would be an error, and subsequently no recruiting, if the multiply= key was not set.
This commit is contained in:
parent
81aac64fc2
commit
bf3517d1e4
1 changed files with 22 additions and 5 deletions
|
@ -113,7 +113,7 @@ return {
|
|||
for attack in H.child_range(wesnoth.unit_types[attacker.type].__cfg, "attack") do
|
||||
local defense = defender_defense
|
||||
local poison = false
|
||||
local damage_multiplier = 1
|
||||
local damage_multiplier,damage_add,damage_value = 1, 0
|
||||
|
||||
for special in H.child_range(attack, 'specials') do
|
||||
local mod
|
||||
|
@ -146,12 +146,28 @@ return {
|
|||
-- Handle backstab, charge
|
||||
mod = H.get_child(special, 'damage')
|
||||
if mod and mod.active_on ~= "defense" then
|
||||
if mod.value then
|
||||
if mod.cumulative then
|
||||
if mod.value > attack.damage then
|
||||
damage_value = mod.value
|
||||
end
|
||||
else
|
||||
damage_value = mod.value
|
||||
end
|
||||
elseif mod.add then
|
||||
damage_add = mod.add
|
||||
elseif mod.sub then
|
||||
damage_add = - mod.sub
|
||||
elseif mod.multiply then
|
||||
damage_multiplier = mod.multiply
|
||||
elseif mod.divide then
|
||||
damage_multiplier = 1. / mod.divide
|
||||
end
|
||||
if mod.backstab then
|
||||
-- Assume backstab happens on only 1/2 of attacks
|
||||
-- TODO: find out what actual probability of getting to backstab is
|
||||
damage_multiplier = damage_multiplier*(mod.multiply*0.5 + 0.5)
|
||||
else
|
||||
damage_multiplier = damage_multiplier*mod.multiply
|
||||
damage_multiplier = damage_multiplier * 0.5 + 0.5
|
||||
damage_add = damage_add * 0.5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -179,7 +195,8 @@ return {
|
|||
resistance = 50
|
||||
end
|
||||
end
|
||||
local base_damage = attack.damage*resistance*damage_multiplier
|
||||
local base_damage = (attack.damage * damage_multiplier + damage_add) * resistance
|
||||
if damage_value then base_damage = damage_value * resistance end
|
||||
if (resistance > 100) then
|
||||
base_damage = base_damage-1
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue