From 546f9ee53c7b08207805c5a1c431ce2df0f365e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Timbert?= Date: Fri, 4 Aug 2006 17:41:56 +0000 Subject: [PATCH] gave every ability/special a specific id (some were missing) new remove_special= key to remove attack specials in [effect] (Trunk only) --- changelog | 1 + data/abilities.cfg | 12 +++++++++++- src/unit_types.cpp | 21 ++++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/changelog b/changelog index 023dfe09626..9038b261701 100644 --- a/changelog +++ b/changelog @@ -15,6 +15,7 @@ Version 1.3-svn: * allow_new_game key (default=yes) to prevent [multiplayer] scenarios to show up in the multiplayer game creation interface (FR #6397) * new [set_specials] tag to allow custom special in effect tags + * new remove_specials= key to allow to remove specials in effect tags * obsolete set_special= in [effect] tags Version 1.1.7: diff --git a/data/abilities.cfg b/data/abilities.cfg index e75b5c532eb..9b4c5171191 100644 --- a/data/abilities.cfg +++ b/data/abilities.cfg @@ -53,7 +53,7 @@ A curer can cure a unit of poison, although that unit will receive no additional #define ABILITY_REGENERATES [regenerate] value=8 - id=healing + id=regenerates name= _ "regenerates" description= _ "Regenerates: The unit will heal itself 8 hp per turn. If it is poisoned, it will remove the poison instead of healing." @@ -301,6 +301,7 @@ Adjacent friendly units of lower level will do more damage in battle. When a uni #define ABILITY_SKIRMISHER [skirmisher] + id=skirmisher name= _ "skirmisher" description= _ "Skirmisher: This unit is skilled in moving past enemies quickly, and ignores all enemy Zones of Control." @@ -325,6 +326,7 @@ Any units adjacent to this unit will fight as if it were dusk when it is night, #define ABILITY_TELEPORT [teleport] + id=teleport name= _ "teleport" description= _ "Teleport: This unit may teleport between any two friendly villages using one of its moves." @@ -333,6 +335,7 @@ This unit may teleport between any two friendly villages using one of its moves. #define ABILITY_AMBUSH [hides] + id=ambush name= _ "ambush" name_inactive= _ "ambush" description= _ "Ambush: @@ -354,6 +357,7 @@ Enemy units cannot see or attack this unit when it is in forest, except for any #define ABILITY_NIGHTSTALK [hides] + id=nightstalk name= _ "nightstalk" description= _ "Nightstalk: The unit becomes invisible during night. @@ -375,6 +379,7 @@ Enemy units cannot see or attack this unit at night, except for any turn immedia #define ABILITY_SUBMERGE [hides] + id=submerge name= _ "submerge" description= _ "Submerge: This unit can hide in deep water, and remain undetected by its enemies. @@ -423,6 +428,7 @@ This attack deals double damage if there is an enemy of the target on the opposi #define WEAPON_SPECIAL_PLAGUE_TYPE TYPE [plague] + id=plague({TYPE}) name= _ "plague" description= _ "Plague: When a unit is killed by a Plague attack, that unit is replaced with a unit identical to and on the same side as the unit with the Plague attack. (This doesn't work on Undead or units in villages.)" @@ -431,6 +437,7 @@ When a unit is killed by a Plague attack, that unit is replaced with a unit iden #enddef #define WEAPON_SPECIAL_PLAGUE [plague] + id=plague name= _ "plague" description= _ "Plague: When a unit is killed by a Plague attack, that unit is replaced with a unit identical to and on the same side as the unit with the Plague attack. (This doesn't work on Undead or units in villages.)" @@ -448,6 +455,7 @@ This attack slows the target until it ends a turn. Slow halves the damage caused #define WEAPON_SPECIAL_STONE [stones] + id=stones name= _ "stones" description= _ "Stone: This attack turns the target to stone. Units that have been turned to stone may not move or attack." @@ -479,6 +487,7 @@ This attack always has a 70% chance to hit." #define WEAPON_SPECIAL_SWARM [attacks] + id=swarm name= _ "swarm" description= _ "Swarm: The number of strikes of this attack decreases when the unit is wounded. The number of strikes is proportional to the % of HP/maximum HP the unit has. For example a unit with 3/4 of its maximum HP will get 3/4 of the number of strikes." @@ -508,6 +517,7 @@ This unit drains health from living units, healing itself for half the amount of #define WEAPON_SPECIAL_FIRSTSTRIKE [firststrike] + id=firststrike name= _ "firststrike" description= _ "First Strike: This unit always strikes first with this attack, even if they are defending." diff --git a/src/unit_types.cpp b/src/unit_types.cpp index 930d9021c68..4131e5413e0 100644 --- a/src/unit_types.cpp +++ b/src/unit_types.cpp @@ -242,6 +242,7 @@ bool attack_type::apply_modification(const config& cfg,std::string* description) const t_string& set_name = cfg["set_name"]; const std::string& set_type = cfg["set_type"]; const config* set_specials = cfg.child("set_specials"); + const std::string& del_specials = cfg["remove_specials"]; const std::string& set_special = cfg["set_special"]; const std::string& increase_damage = cfg["increase_damage"]; const std::string& increase_attacks = cfg["increase_attacks"]; @@ -271,10 +272,28 @@ bool attack_type::apply_modification(const config& cfg,std::string* description) } for(config::all_children_iterator s = set_specials->ordered_begin(); s != set_specials->ordered_end(); ++s) { const std::pair& value = *s; - new_specials->add_child(*value.first,*value.second); // new_specials==NULL :/ + new_specials->add_child(*value.first,*value.second); } } + if(del_specials.empty() == false) { + const std::vector& dsl = utils::split(del_specials); + config* specials = cfg_.child("specials"); + if (specials != NULL) { + config new_specials; + for(config::all_children_iterator s = specials->ordered_begin(); s != specials->ordered_end(); ++s) { + const std::pair& vp = *s; + std::vector::const_iterator found_id = + std::find(dsl.begin(),dsl.end(),vp.second->get_attribute("id")); + if (found_id == dsl.end()) { + new_specials.add_child(*vp.first,*vp.second); + } + } + cfg_.clear_children("specials"); + cfg_.add_child("specials",new_specials); + } + } + if(set_special.empty() == false) { LOG_STREAM(err, config) << "[effect] uses set_special=" << set_special <<", which is now deprecated. Use [set_specials] instead.\n"; cfg_.clear_children("specials");