Added a lua implementation for FULL_HEAL and PUT_TO_RECALL_LIST
This commit is contained in:
parent
7bb7c8aa84
commit
db028708c4
2 changed files with 39 additions and 40 deletions
|
@ -365,26 +365,9 @@
|
|||
#enddef
|
||||
|
||||
#define FULL_HEAL FILTER
|
||||
# This heals the specified unit(s) to full health.
|
||||
[store_unit]
|
||||
[filter]
|
||||
{FILTER}
|
||||
[/filter]
|
||||
variable=FULL_HEAL_temp
|
||||
[/store_unit]
|
||||
|
||||
{FOREACH FULL_HEAL_temp FULL_HEAL_i}
|
||||
[set_variable]
|
||||
name=FULL_HEAL_temp[$FULL_HEAL_i].hitpoints
|
||||
value=$FULL_HEAL_temp[$FULL_HEAL_i].max_hitpoints
|
||||
[/set_variable]
|
||||
[unstore_unit]
|
||||
find_vacant=no
|
||||
variable=FULL_HEAL_temp[$FULL_HEAL_i]
|
||||
[/unstore_unit]
|
||||
{NEXT FULL_HEAL_i}
|
||||
|
||||
{CLEAR_VARIABLE FULL_HEAL_temp,FULL_HEAL_i}
|
||||
[full_heal]
|
||||
{FILTER}
|
||||
[/full_heal]
|
||||
#enddef
|
||||
|
||||
#define PUT_TO_RECALL_LIST FILTER
|
||||
|
@ -405,26 +388,9 @@
|
|||
#!
|
||||
#! {PUT_TO_RECALL_LIST x,y=20,38}
|
||||
#! [/event]
|
||||
[store_unit]
|
||||
[filter]
|
||||
{FILTER}
|
||||
[/filter]
|
||||
|
||||
variable=PUT_TO_RECALL_LIST_temp
|
||||
kill=yes
|
||||
[/store_unit]
|
||||
|
||||
{FOREACH PUT_TO_RECALL_LIST_temp PUT_TO_RECALL_LIST_i}
|
||||
{VARIABLE PUT_TO_RECALL_LIST_temp[$PUT_TO_RECALL_LIST_i].x "recall"}
|
||||
{VARIABLE PUT_TO_RECALL_LIST_temp[$PUT_TO_RECALL_LIST_i].y "recall"}
|
||||
|
||||
[unstore_unit]
|
||||
variable=PUT_TO_RECALL_LIST_temp[$PUT_TO_RECALL_LIST_i]
|
||||
find_vacant=no
|
||||
[/unstore_unit]
|
||||
{NEXT PUT_TO_RECALL_LIST_i}
|
||||
|
||||
{CLEAR_VARIABLE PUT_TO_RECALL_LIST_temp,PUT_TO_RECALL_LIST_i}
|
||||
[put_to_recall_list]
|
||||
{FILTER}
|
||||
[/put_to_recall_list]
|
||||
#enddef
|
||||
|
||||
# FIXME: Documentation for these is needed.
|
||||
|
|
|
@ -1275,3 +1275,36 @@ function wml_actions.store_villages( cfg )
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
function wml_actions.put_to_recall_list(cfg)
|
||||
local units = wesnoth.get_units(cfg)
|
||||
|
||||
for i, unit in ipairs(units) do
|
||||
if cfg.heal then
|
||||
unit.hitpoints = unit.max_hitpoints
|
||||
unit.moves = unit.max_moves
|
||||
unit.attacks_left = unit.max_attacks
|
||||
unit.status.poisoned = false
|
||||
unit.status.slowed = false
|
||||
end
|
||||
wesnoth.put_recall_unit(unit, unit.side)
|
||||
wesnoth.put_unit(unit.x, unit.y)
|
||||
end
|
||||
end
|
||||
|
||||
function wml_actions.full_heal(cfg)
|
||||
local units = wesnoth.get_units(cfg)
|
||||
|
||||
for i, unit in ipairs(units) do
|
||||
if (not unit.status.unhealable) or cfg.ignore_status then
|
||||
unit.hitpoints = unit.max_hitpoints
|
||||
if cfg.cures then
|
||||
unit.status.poisoned = false
|
||||
unit.status.slowed = false
|
||||
end
|
||||
if cfg.animate then
|
||||
wesnoth.fire( "animate_unit", { flag = "healed" , with_bars = "yes" , { "filter" , { id = unit.id } } })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue