From 45ff24dbd7879581dc6243591d0be847eb3fd41a Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sat, 31 Mar 2012 10:14:42 +0000 Subject: [PATCH] new switch "count-kill-for-unit-upgrade" if a unit has set this switch to false , killing it does not count up the number of kills of the attacking unit. --- source/glest_game/types/unit_type.cpp | 13 +++++++++++++ source/glest_game/types/unit_type.h | 3 ++- source/glest_game/world/unit_updater.cpp | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index e2e24916..a35371e7 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -524,6 +524,19 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const countUnitKillInStats=true; } + //countKillForUnitUpgrade + if(parametersNode->hasChild("count-kill-for-unit-upgrade")){ + const XmlNode *countKillForUnitUpgradeNode= parametersNode->getChild("count-kill-for-unit-upgrade"); + countKillForUnitUpgrade= countKillForUnitUpgradeNode->getAttribute("value")->getBoolValue(); + } else { + countKillForUnitUpgrade=true; + } + + if(countKillForUnitUpgrade == false){ + // it makes no sense if we count it in stats but not for upgrades + countUnitKillInStats=false; + } + //selection sounds const XmlNode *selectionSoundNode= parametersNode->getChild("selection-sounds"); if(selectionSoundNode->getAttribute("enabled")->getBoolValue()){ diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 54b9ef1c..d94e7f4a 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -137,6 +137,7 @@ private: bool countUnitDeathInStats; bool countUnitProductionInStats; bool countUnitKillInStats; + bool countKillForUnitUpgrade; //OPTIMIZATION: store first command type and skill type of each class const CommandType *firstCommandTypeOfClass[ccCount]; @@ -184,7 +185,7 @@ public: bool getCountUnitDeathInStats() const {return countUnitDeathInStats;} bool getCountUnitProductionInStats() const {return countUnitProductionInStats;} bool getCountUnitKillInStats() const {return countUnitKillInStats;} - + bool getCountKillForUnitUpgrade() const {return countKillForUnitUpgrade;} bool isMobile() const {return (firstSkillTypeOfClass[scMove] != NULL);} Texture2D *getMeetingPointImage() const {return meetingPointImage;} StaticSound *getSelectionSound() const {return selectionSounds.getRandSound();} diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 44b23cb9..ab74067d 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2063,7 +2063,9 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac //damage the unit if(attacked->decHp(static_cast(damage))) { world->getStats()->kill(attacker->getFactionIndex(), attacked->getFactionIndex(), attacker->getTeam() != attacked->getTeam(),attacked->getType()->getCountUnitDeathInStats(),attacked->getType()->getCountUnitKillInStats()); - attacker->incKills(attacked->getTeam()); + if(attacked->getType()->getCountKillForUnitUpgrade()){ + attacker->incKills(attacked->getTeam()); + } switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: