more modifiable attributes to lua units
This commit is contained in:
parent
d940697987
commit
783dc0767b
3 changed files with 37 additions and 5 deletions
|
@ -397,8 +397,11 @@ static int impl_unit_set(lua_State *L)
|
|||
modify_int_attrib("side", u.set_side(value));
|
||||
modify_int_attrib("moves", u.set_movement(value));
|
||||
modify_int_attrib("max_moves", u.set_total_movement(value));
|
||||
modify_int_attrib("max_attacks", u.set_max_attacks(value));
|
||||
modify_int_attrib("hitpoints", u.set_hitpoints(value));
|
||||
modify_int_attrib("max_hitpoints", u.set_max_hitpoints(value));
|
||||
modify_int_attrib("experience", u.set_experience(value));
|
||||
modify_int_attrib("max_experience", u.set_max_experience(value));
|
||||
modify_int_attrib("recall_cost", u.set_recall_cost(value));
|
||||
modify_int_attrib("attacks_left", u.set_attacks(value));
|
||||
modify_int_attrib("level", u.set_level(value));
|
||||
|
@ -407,6 +410,7 @@ static int impl_unit_set(lua_State *L)
|
|||
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_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));
|
||||
|
|
|
@ -529,17 +529,17 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
level_ = cfg["level"].to_int(level_);
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("undead_variation")) {
|
||||
undead_variation_ = v->str();
|
||||
set_undead_variation(v->str());
|
||||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("max_attacks")) {
|
||||
max_attacks_ = std::max(0, v->to_int(1));
|
||||
set_max_attacks(std::max(0, v->to_int(1)));
|
||||
}
|
||||
|
||||
attacks_left_ = std::max(0, cfg["attacks_left"].to_int(max_attacks_));
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("zoc")) {
|
||||
emit_zoc_ = v->to_bool(level_ > 0);
|
||||
set_emit_zoc(v->to_bool(level_ > 0));
|
||||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("description")) {
|
||||
|
@ -563,13 +563,13 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("profile")) {
|
||||
std::string profile = (*v).str();
|
||||
set_big_profile((*v).str());
|
||||
adjust_profile(profile);
|
||||
profile_ = profile;
|
||||
}
|
||||
|
||||
if(const config::attribute_value* v = cfg.get("small_profile")) {
|
||||
small_profile_ = (*v).str();
|
||||
set_small_profile((*v).str());
|
||||
}
|
||||
|
||||
max_hit_points_ = std::max(1, cfg["max_hitpoints"].to_int(max_hit_points_));
|
||||
|
|
|
@ -427,6 +427,11 @@ public:
|
|||
return max_hit_points_;
|
||||
}
|
||||
|
||||
void set_max_hitpoints(int value)
|
||||
{
|
||||
max_hit_points_ = value;
|
||||
}
|
||||
|
||||
/** Sets the current hitpoint amount. */
|
||||
void set_hitpoints(int hp)
|
||||
{
|
||||
|
@ -445,6 +450,11 @@ public:
|
|||
return max_experience_;
|
||||
}
|
||||
|
||||
void set_max_experience(int value)
|
||||
{
|
||||
max_experience_ = value;
|
||||
}
|
||||
|
||||
/** The number of experience points this unit needs to level up, or 0 if current XP > max XP. */
|
||||
unsigned int experience_to_advance() const
|
||||
{
|
||||
|
@ -482,6 +492,10 @@ public:
|
|||
}
|
||||
|
||||
/** The ID of the undead variation (ie, dwarf, swimmer) of this unit. */
|
||||
void set_undead_variation(const std::string& value)
|
||||
{
|
||||
undead_variation_ = value;
|
||||
}
|
||||
const std::string& undead_variation() const
|
||||
{
|
||||
return undead_variation_;
|
||||
|
@ -495,6 +509,10 @@ public:
|
|||
*/
|
||||
std::string small_profile() const;
|
||||
|
||||
void set_small_profile(const std::string& value)
|
||||
{
|
||||
small_profile_ = value;
|
||||
}
|
||||
/**
|
||||
* An optional profile image displays when this unit is 'speaking' via [message].
|
||||
*
|
||||
|
@ -503,6 +521,11 @@ public:
|
|||
*/
|
||||
std::string big_profile() const;
|
||||
|
||||
void set_big_profile(const std::string& value)
|
||||
{
|
||||
profile_ = value;
|
||||
adjust_profile(profile_);
|
||||
}
|
||||
/** Whether this unit can recruit other units - ie, are they a leader unit. */
|
||||
bool can_recruit() const
|
||||
{
|
||||
|
@ -862,6 +885,11 @@ public:
|
|||
return max_attacks_;
|
||||
}
|
||||
|
||||
void set_max_attacks(int value)
|
||||
{
|
||||
max_attacks_ = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remaining number of attacks this unit can perform this turn.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue