From 48123469bc35dcb27e3263593aa9983da1bdd408 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 16 Apr 2018 00:00:51 -0400 Subject: [PATCH] Support location_id in [recall] and [unstore_unit] (cherry-picked from commit ecc8785edbbcaa814502ccee6b2946da4242f53e) --- changelog.md | 2 +- data/lua/wml-tags.lua | 3 +++ src/game_events/action_wml.cpp | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 1f0a7befb1d4..a2893080a810 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/data/lua/wml-tags.lua b/data/lua/wml-tags.lua index aa2455649fc7..dca55b1a6e88 100644 --- a/data/lua/wml-tags.lua +++ b/data/lua/wml-tags.lua @@ -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 diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index efceb0b00f6f..32f9c08fc2b4 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -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) {