Add special note support in [unit] and [effect].
This commit is contained in:
parent
855734f4c6
commit
7bee8ee157
6 changed files with 61 additions and 0 deletions
|
@ -17,6 +17,10 @@
|
|||
### WML engine
|
||||
* Ranges can now have upper limit "infinity" instead of using a big number like "99" or "99999"
|
||||
* Print a deprecation warning for `[terrain_type]`'s partly-implemented `vision_alias`
|
||||
* Special notes for units now use a new system, with a `[special_note]note=` tag.
|
||||
* This tag is supported both in `[unit]` and in `[unit_type]`. If used in `[unit]`, it will override the type's notes.
|
||||
* Standard special notes should now be added with `{NOTE_*}` instead of `{SPECIAL_NOTES_*}`.
|
||||
* In `[effect]apply_to=profile`, `[add_special_note]` and `[remove_special_note]` are supported.
|
||||
### Miscellaneous and bug fixes
|
||||
* Fixed :droid's arguments not all being optional (Issue#4308)
|
||||
* Chat is now enable in single-player and hotseat multiplayer. (Issue#1111)
|
||||
|
|
|
@ -128,6 +128,16 @@
|
|||
{SIMPLE_KEY portrait string}
|
||||
{SIMPLE_KEY small_portrait string}
|
||||
{SIMPLE_KEY description t_string}
|
||||
[tag]
|
||||
name="add_special_note"
|
||||
max="infinite"
|
||||
{REQUIRED_KEY note t_string}
|
||||
[/tag]
|
||||
[tag]
|
||||
name="remove_special_note"
|
||||
max="infinite"
|
||||
{REQUIRED_KEY note t_string}
|
||||
[/tag]
|
||||
[/case]
|
||||
[case]
|
||||
value=new_ability,remove_ability
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
{SIMPLE_KEY flag_icon string} # Not documented
|
||||
{FILTER_TAG "filter_recall" unit ()}
|
||||
{DATA_TAG variables 0 1}
|
||||
[tag]
|
||||
name="special_note"
|
||||
max="infinite"
|
||||
{REQUIRED_KEY note t_string}
|
||||
[/tag]
|
||||
[tag]
|
||||
name="modifications"
|
||||
{INSERT_TAG}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
[/tag]
|
||||
[tag]
|
||||
name="special_note"
|
||||
max="infinite"
|
||||
{REQUIRED_KEY note t_string}
|
||||
[/tag]
|
||||
{LINK_TAG "units/movetype/resistance"}
|
||||
|
|
|
@ -357,6 +357,7 @@ unit::unit(const unit& o)
|
|||
, abilities_(o.abilities_)
|
||||
, advancements_(o.advancements_)
|
||||
, description_(o.description_)
|
||||
, special_notes_(o.special_notes_)
|
||||
, usage_(copy_or_null(o.usage_))
|
||||
, halo_(copy_or_null(o.halo_))
|
||||
, ellipse_(copy_or_null(o.ellipse_))
|
||||
|
@ -437,6 +438,7 @@ unit::unit()
|
|||
, abilities_()
|
||||
, advancements_()
|
||||
, description_()
|
||||
, special_notes_()
|
||||
, usage_()
|
||||
, halo_()
|
||||
, ellipse_()
|
||||
|
@ -613,6 +615,15 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
|
|||
}
|
||||
}
|
||||
|
||||
// Don't use the unit_type's special notes if this config has its own defined
|
||||
if(config::const_child_itors cfg_range = cfg.child_range("special_note")) {
|
||||
set_attr_changed(UA_NOTES);
|
||||
special_notes_.clear();
|
||||
for(const config& c : cfg_range) {
|
||||
special_notes_.emplace_back(c["note"]);
|
||||
}
|
||||
}
|
||||
|
||||
// If cfg specifies [advancement]s, replace this [advancement]s with them.
|
||||
if(cfg.has_child("advancement")) {
|
||||
set_attr_changed(UA_ADVANCEMENTS);
|
||||
|
@ -964,6 +975,7 @@ void unit::advance_to(const unit_type& u_type, bool use_traits)
|
|||
type_ = &new_type;
|
||||
type_name_ = new_type.type_name();
|
||||
description_ = new_type.unit_description();
|
||||
special_notes_ = new_type.special_notes();
|
||||
undead_variation_ = new_type.undead_variation();
|
||||
max_experience_ = new_type.experience_needed(true);
|
||||
level_ = new_type.level();
|
||||
|
@ -1456,6 +1468,11 @@ void unit::write(config& cfg, bool write_all) const
|
|||
if(description_ != type().unit_description()) {
|
||||
cfg["description"] = description_;
|
||||
}
|
||||
if(write_all || get_attr_changed(UA_NOTES)) {
|
||||
for(const t_string& note : special_notes_) {
|
||||
cfg.add_child("special_note")["note"] = note;
|
||||
}
|
||||
}
|
||||
|
||||
if(halo_.get()) {
|
||||
cfg["halo"] = *halo_;
|
||||
|
@ -1921,6 +1938,22 @@ void unit::apply_builtin_effect(std::string apply_to, const config& effect)
|
|||
if(const config::attribute_value* v = effect.get("description")) {
|
||||
description_ = *v;
|
||||
}
|
||||
|
||||
if(config::const_child_itors cfg_range = effect.child_range("add_special_note")) {
|
||||
for(const config& c : cfg_range) {
|
||||
special_notes_.emplace_back(c["note"]);
|
||||
}
|
||||
}
|
||||
|
||||
if(config::const_child_itors cfg_range = effect.child_range("remove_special_note")) {
|
||||
// TODO: Test that this works properly
|
||||
for(const config& c : cfg_range) {
|
||||
auto iter = std::find(special_notes_.begin(), special_notes_.end(), c["note"].t_str());
|
||||
if(iter != special_notes_.end()) {
|
||||
special_notes_.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(apply_to == "new_attack") {
|
||||
set_attr_changed(UA_ATTACKS);
|
||||
attacks_.emplace_back(new attack_type(effect));
|
||||
|
|
|
@ -133,6 +133,7 @@ private:
|
|||
UA_UNDEAD_VARIATION,
|
||||
//note that UA_ATTACKS only tracks added/deleted attacks, not modified attacks.
|
||||
UA_ATTACKS,
|
||||
UA_NOTES,
|
||||
UA_PROFILE,
|
||||
UA_SMALL_PROFILE,
|
||||
UA_ABILITIES,
|
||||
|
@ -414,6 +415,12 @@ public:
|
|||
{
|
||||
return description_;
|
||||
}
|
||||
|
||||
/** The unit's special notes. */
|
||||
const std::vector<t_string>& unit_special_notes() const
|
||||
{
|
||||
return special_notes_;
|
||||
}
|
||||
|
||||
/** The gender of this unit. */
|
||||
unit_race::GENDER gender() const
|
||||
|
@ -1808,6 +1815,7 @@ private:
|
|||
advancements_list advancements_;
|
||||
|
||||
t_string description_;
|
||||
std::vector<t_string> special_notes_;
|
||||
|
||||
std::unique_ptr<std::string> usage_;
|
||||
std::unique_ptr<std::string> halo_;
|
||||
|
|
Loading…
Add table
Reference in a new issue