remove variable substitution from leadership and backstab abilities

This commit is contained in:
gfgtdf 2017-06-13 23:22:06 +02:00
parent 80d27b4584
commit 70a23cdf83
2 changed files with 49 additions and 12 deletions

View file

@ -112,7 +112,7 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
affect_self=no
[affect_adjacent]
[filter]
level=$($other_unit.level - 5)
lua_function="leadership_receiver_filter_5"
[/filter]
[/affect_adjacent]
[/leadership]
@ -123,7 +123,7 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
affect_self=no
[affect_adjacent]
[filter]
level=$($other_unit.level - 4)
lua_function="leadership_receiver_filter_4"
[/filter]
[/affect_adjacent]
[/leadership]
@ -134,7 +134,7 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
affect_self=no
[affect_adjacent]
[filter]
level=$($other_unit.level - 3)
lua_function="leadership_receiver_filter_3"
[/filter]
[/affect_adjacent]
[/leadership]
@ -145,7 +145,7 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
affect_self=no
[affect_adjacent]
[filter]
level=$($other_unit.level - 2)
lua_function="leadership_receiver_filter_2"
[/filter]
[/affect_adjacent]
[/leadership]
@ -156,7 +156,7 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
affect_self=no
[affect_adjacent]
[filter]
level=$($other_unit.level - 1)
lua_function="leadership_receiver_filter_1"
[/filter]
[/affect_adjacent]
[/leadership]
@ -349,13 +349,7 @@ Enemy units cannot see this unit while it is in deep water, except if they have
multiply=2
active_on=offense
[filter_opponent]
[filter_adjacent]
adjacent=$other_unit.facing
is_enemy=yes
[not]
status=petrified
[/not]
[/filter_adjacent]
lua_function="backstab_defender_filter"
[/filter_opponent]
[/damage]
#enddef

View file

@ -13,3 +13,46 @@ function teleport_target_filter(x, y)
local blocking_unit = wesnoth.get_unit(x, y)
return not blocking_unit
end
function backstab_defender_filter(defender)
local attacker_x = wesnoth.get_variable("other_unit.x")
local attacker_y = wesnoth.get_variable("other_unit.y")
local defender_x = defender.x
local defender_y = defender.y
local adjacent = {wesnoth.map.get_adjacent_tiles(x, y)}
local attacker_pos_index = nil
for i,v in ipairs(adjacent) do
if v[1] == attacker_x and v[2] == attacker_y then
attacker_pos_index = i
end
end
if attacker_pos_index == nil then
-- Attack not from adjacent location
return false
end
local opposite_pos_index = (((attacker_pos_index + 3) - 1) % 6) + 1
local opposite_unit = wesnoth.get_unit(adjacent[opposite_pos_index][1], adjacent[opposite_pos_index][2])
if not opposite_unit then
-- No opposite unit
return false
end
if opposite_unit.status.petrified then
return false
end
return wesnoth.is_enemy(opposite_unit.side, defender.side)
end
for i = 1, 5 do
_G["leadership_receiver_filter_" .. i] = function(receiver)
return receiver.level == wesnoth.get_variable("other_unit.level") - i
end
end