Support location_id in [recall] and [unstore_unit]

(cherry-picked from commit ecc8785edb)
This commit is contained in:
Celtic Minstrel 2018-04-16 00:00:51 -04:00
parent b3b3a3c53d
commit 48123469bc
3 changed files with 8 additions and 2 deletions

View file

@ -50,8 +50,8 @@
### WML engine
* Support formula= key in [variable] ConditionalWML
* Support to_location in [move_unit], taking a location ID
* Support location_id in [teleport] for the target location
* Suppor dir in [move_unit] to perform relative movements
* Support location_id in [teleport], [recall], [unstore_unit] for the target location
* Support [filter_weapon] in leadership and resistance abilities,
which activates the ability only when the affected unit is using
a matching weapon.

View file

@ -831,6 +831,9 @@ wml_actions.unstore_unit = function(cfg)
local check_passability = cfg.check_passability ~= false or nil
local x = cfg.x or unit.x or -1
local y = cfg.y or unit.y or -1
if cfg.location_id then
x, y = wesnoth.special_locations[cfg.location_id]
end
wesnoth.add_known_unit(unit.type)
if on_board(x, y) then
if cfg.find_vacant then

View file

@ -468,6 +468,7 @@ WML_HANDLER_FUNCTION(recall,, cfg)
*/
temp_config["x"] = "recall";
temp_config["y"] = "recall";
temp_config.remove_attribute("location_id");
vconfig unit_filter_cfg(temp_config);
const vconfig & leader_filter = cfg.child("secondary_unit");
@ -494,7 +495,9 @@ WML_HANDLER_FUNCTION(recall,, cfg)
const unit_ptr to_recruit = *u;
const unit* pass_check = to_recruit.get();
if(!cfg["check_passability"].to_bool(true)) pass_check = nullptr;
const map_location cfg_loc = cfg_to_loc(cfg);
const map_location cfg_loc = cfg.has_attribute("location_id")
? resources::gameboard->map().special_locations().left[cfg["location_id"]]
: cfg_to_loc(cfg);
/// @todo fendrin: comment this monster
for (unit_map::const_unit_iterator leader : leaders) {