Add six more known attributes to the [modify_unit] optimized path
This commit is contained in:
parent
fc04268aa4
commit
8374306009
4 changed files with 32 additions and 5 deletions
|
@ -40,6 +40,7 @@
|
|||
### Lua API
|
||||
* unit:transform() now takes an optional variation parameter
|
||||
* Support side.variables for access to side variables, similar to unit.variables
|
||||
* New read-write keys in unit userdata: ellipse, halo, description, renamable
|
||||
### WML engine
|
||||
* Support upkeep in StandardUnitFilter
|
||||
* [effect]apply_to=variation now supports heal_full
|
||||
|
|
|
@ -47,6 +47,12 @@ local known_attributes = make_set {
|
|||
"canrecruit",
|
||||
"type",
|
||||
"variation",
|
||||
"ellipse",
|
||||
"halo",
|
||||
"recall_cost",
|
||||
"description",
|
||||
"hidden",
|
||||
"unrenamable",
|
||||
}
|
||||
|
||||
local known_tags = make_set {
|
||||
|
@ -89,11 +95,14 @@ end
|
|||
|
||||
local function simple_modify_unit(cfg)
|
||||
local filter = wml.get_child(cfg, "filter") or helper.wml_error "[modify_unit] missing required [filter] tag"
|
||||
-- todo: investigate the follwoing attrtibutes:
|
||||
-- id, ellipse, recall_cost, alpha, flying,
|
||||
-- hidden, halo, description, overlays, unrenamable
|
||||
-- and tags: [variables]
|
||||
-- todo: investigate the following attrtibutes:
|
||||
-- id, alpha, flying, overlays
|
||||
local simple_attributes = {
|
||||
"ellipse",
|
||||
"halo",
|
||||
"recall_cost",
|
||||
"description",
|
||||
"hidden",
|
||||
"side",
|
||||
"name",
|
||||
"role",
|
||||
|
@ -106,7 +115,7 @@ local function simple_modify_unit(cfg)
|
|||
"experience",
|
||||
"max_experience",
|
||||
"resting",
|
||||
"canrecruit"
|
||||
"canrecruit",
|
||||
}
|
||||
|
||||
local function handle_unit(u)
|
||||
|
@ -123,6 +132,9 @@ local function simple_modify_unit(cfg)
|
|||
if cfg.ai_special == "guardian" then
|
||||
u.status.guardian = true
|
||||
end
|
||||
if cfg.unrenamable then
|
||||
u.renamable = not cfg.unrenamable
|
||||
end
|
||||
---------- SIMPLE ATTRIBUTES ----------
|
||||
for i, name in ipairs(simple_attributes) do
|
||||
if cfg[name] ~= nil then
|
||||
|
|
|
@ -315,6 +315,8 @@ static int impl_unit_get(lua_State *L)
|
|||
return_string_attrib("type", u.type_id());
|
||||
return_string_attrib("image_mods", u.effect_image_mods());
|
||||
return_string_attrib("usage", u.usage());
|
||||
return_string_attrib("ellipse", u.image_ellipse());
|
||||
return_string_attrib("halo", u.image_halo());
|
||||
return_int_attrib("hitpoints", u.hitpoints());
|
||||
return_int_attrib("max_hitpoints", u.max_hitpoints());
|
||||
return_int_attrib("experience", u.experience());
|
||||
|
@ -325,7 +327,9 @@ static int impl_unit_get(lua_State *L)
|
|||
return_int_attrib("max_attacks", u.max_attacks());
|
||||
return_int_attrib("attacks_left", u.attacks_left());
|
||||
return_tstring_attrib("name", u.name());
|
||||
return_tstring_attrib("description", u.unit_description());
|
||||
return_bool_attrib("canrecruit", u.can_recruit());
|
||||
return_bool_attrib("renamable", !u.unrenamable());
|
||||
return_int_attrib("level", u.level());
|
||||
return_int_attrib("cost", u.cost());
|
||||
|
||||
|
@ -435,13 +439,17 @@ static int impl_unit_set(lua_State *L)
|
|||
modify_int_attrib("level", u.set_level(value));
|
||||
modify_bool_attrib("resting", u.set_resting(value));
|
||||
modify_tstring_attrib("name", u.set_name(value));
|
||||
modify_tstring_attrib("description", u.set_unit_description(value));
|
||||
modify_string_attrib("role", u.set_role(value));
|
||||
modify_string_attrib("facing", u.set_facing(map_location::parse_direction(value)));
|
||||
modify_string_attrib("usage", u.set_usage(value));
|
||||
modify_string_attrib("undead_variation", u.set_undead_variation(value));
|
||||
modify_string_attrib("ellipse", u.set_image_ellipse(value));
|
||||
modify_string_attrib("halo", u.set_image_halo(value));
|
||||
modify_bool_attrib("hidden", u.set_hidden(value));
|
||||
modify_bool_attrib("zoc", u.set_emit_zoc(value));
|
||||
modify_bool_attrib("canrecruit", u.set_can_recruit(value));
|
||||
modify_bool_attrib("renamable", u.set_unrenamable(!value));
|
||||
|
||||
modify_vector_string_attrib("extra_recruit", u.set_recruits(value));
|
||||
modify_vector_string_attrib("advances_to", u.set_advances_to(value));
|
||||
|
|
|
@ -415,6 +415,12 @@ public:
|
|||
{
|
||||
return description_;
|
||||
}
|
||||
|
||||
/** A detailed description of this unit. */
|
||||
void set_unit_description(const t_string& new_desc)
|
||||
{
|
||||
description_ = new_desc;
|
||||
}
|
||||
|
||||
/** The unit's special notes. */
|
||||
const std::vector<t_string>& unit_special_notes() const
|
||||
|
|
Loading…
Add table
Reference in a new issue