From 3204e4eb5687a7881541972251bbf166d49972f2 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sat, 19 Jul 2014 02:19:26 +0200 Subject: [PATCH] add healthy and fearless [effect]s so we don't have to these these traits specialy. --- data/core/macros/traits.cfg | 9 +++++++++ src/unit.cpp | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/data/core/macros/traits.cfg b/data/core/macros/traits.cfg index d4fa8c991e7e..f829830d611c 100644 --- a/data/core/macros/traits.cfg +++ b/data/core/macros/traits.cfg @@ -170,6 +170,9 @@ male_name= _ "healthy" female_name= _ "female^healthy" description= _ "Always rest heals" + [effect] + apply_to = "healthy" + [/effect] [effect] apply_to=hitpoints increase_total=1 @@ -189,6 +192,9 @@ male_name= _ "fearless" female_name= _ "female^fearless" description= _ "Fights normally during unfavorable times of day/night" + [effect] + apply_to = "fearless" + [/effect] [/trait] #enddef @@ -202,6 +208,9 @@ male_name= _ "fearless" female_name= _ "female^fearless" description= _ "Fights normally during unfavorable times of day/night" + [effect] + apply_to = "fearless" + [/effect] [/trait] #enddef diff --git a/src/unit.cpp b/src/unit.cpp index aba181d0366c..99bd202f827a 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -1560,9 +1560,6 @@ void unit::add_modification(const std::string& mod_type, const config& mod, bool //some trait activate specific flags if ( mod_type == "trait" ) { - const std::string& id = mod["id"]; - is_fearless_ = is_fearless_ || id == "fearless"; - is_healthy_ = is_healthy_ || id == "healthy"; if (!mod["generate_description"].empty()) { generate_description = mod["generate_description"].to_bool(); } @@ -1596,7 +1593,16 @@ void unit::add_modification(const std::string& mod_type, const config& mod, bool if ((apply_to == "variation" || apply_to == "type") && no_add == false) { set_poisoned = false; last_effect = effect; - } else if(apply_to == "profile") { + } + else if(apply_to == "fearless") + { + is_fearless_ = effect["set"].to_bool(true); + } + else if(apply_to == "healthy") + { + is_healthy_ = effect["set"].to_bool(true); + } + else if(apply_to == "profile") { if (const config::attribute_value *v = effect.get("portrait")) { std::string big = *v, small = effect["small_portrait"]; adjust_profile(small, big, "");