diff --git a/changelog.md b/changelog.md index b77e36e5363..b4868ab2c2e 100644 --- a/changelog.md +++ b/changelog.md @@ -48,6 +48,7 @@ * [effect]apply_to=variation now supports heal_full * Support [set/clear_variable] inside [modify_unit/side] * Support [variables] in [modify_side], as in [modify_unit] + * [modify_unit] now accepts rebuild=no which will avoid a rebuild of the unit if possible (not guaranteed) ### Packaging * The Wesnoth client now looks for the data/dist file when logging into the multiplayer server. This file should contain one of the following values based on where the package is for: diff --git a/data/lua/wml/modify_unit.lua b/data/lua/wml/modify_unit.lua index c704445922c..e1bfc6fb356 100644 --- a/data/lua/wml/modify_unit.lua +++ b/data/lua/wml/modify_unit.lua @@ -53,6 +53,7 @@ local known_attributes = make_set { "description", "hidden", "unrenamable", + "rebuild", } local known_tags = make_set { @@ -179,9 +180,11 @@ local function simple_modify_unit(cfg) u:transform(cfg.type or u.type, cfg.variation) end - -- always do an advancement here (not only when experience/max_experience/type was modified) - -- for compatability with old code. - u:advance() + -- by default always do an advancement here (not only when experience/max_experience/type was modified) + -- for compatibility with old code. + if cfg.experience or cfg.max_experience or cfg.rebuild ~= false then + u:advance() + end end local this_unit = utils.start_var_scope("this_unit")