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.

This commit is contained in:
Titus Tscharntke 2012-03-31 10:14:42 +00:00
parent 31f0c18653
commit 45ff24dbd7
3 changed files with 18 additions and 2 deletions

View File

@ -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()){

View File

@ -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();}

View File

@ -2063,7 +2063,9 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
//damage the unit
if(attacked->decHp(static_cast<int>(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: