[harm_unit]: added resistance_multiplier key, as per fendrin's request

This commit is contained in:
Elvish_Hunter 2012-02-15 09:53:18 +00:00
parent e1c05a1edb
commit 84beb9ced7
2 changed files with 7 additions and 3 deletions

View file

@ -82,6 +82,7 @@ Version 1.11.0-svn:
backwards compatibility for inline owner_side= at the cost of
confusing syntax (due to (possible) duplicate side information).
This also adds SSF support in [store_villages].
* Added support for resistance_multiplier= key in [harm_unit]
* Miscellaneous and bug fixes:
* Fix wrong preferences path suffix (1.1 instead of 1.10) on Linux and other
platforms using XDG layout (no compiled-in preferences path override,

View file

@ -746,6 +746,7 @@ function wml_actions.harm_unit(cfg)
local secondary_attack = helper.get_child(cfg, "secondary_attack")
local harmer_filter = helper.get_child(cfg, "filter_second")
local experience = cfg.experience
local resistance_multiplier = tonumber(cfg.resistance_multiplier) or 1
if harmer_filter then harmer = wesnoth.get_units(harmer_filter)[1] end
-- end of block to support $this_unit
@ -775,7 +776,7 @@ function wml_actions.harm_unit(cfg)
end
end
local function calculate_damage( base_damage, alignment, tod_bonus, resistance )
local function calculate_damage( base_damage, alignment, tod_bonus, resistance, modifier )
local damage_multiplier = 100
if alignment == "lawful" then
damage_multiplier = damage_multiplier + tod_bonus
@ -785,7 +786,8 @@ function wml_actions.harm_unit(cfg)
damage_multiplier = damage_multiplier - math.abs( tod_bonus )
else -- neutral, do nothing
end
damage_multiplier = damage_multiplier * resistance -- at this point, a resistance_modifier can be added, as asked by fendrin
local resistance_modified = resistance * modifier
damage_multiplier = damage_multiplier * resistance_modified
local damage = round_damage( base_damage, damage_multiplier, 10000 ) -- if harmer.status.slowed, this may be 20000 ?
return damage
end
@ -793,7 +795,8 @@ function wml_actions.harm_unit(cfg)
local damage = calculate_damage( amount,
( cfg.alignment or "neutral" ),
wesnoth.get_time_of_day( { unit_to_harm.x, unit_to_harm.y, true } ).lawful_bonus,
wesnoth.unit_resistance( unit_to_harm, cfg.damage_type or "dummy" )
wesnoth.unit_resistance( unit_to_harm, cfg.damage_type or "dummy" ),
resistance_multiplier
)
if unit_to_harm.hitpoints <= damage then