diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 879e6740..18f91e90 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -242,6 +242,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, const UnitType animProgress= 0; progress2= 0; kills= 0; + enemyKills = 0; loadCount= 0; ep= 0; deadCount= 0; @@ -1444,9 +1445,9 @@ string Unit::getDesc() const { //kills const Level *nextLevel= getNextLevel(); - if(kills>0 || nextLevel!=NULL){ - str+= "\n" + lang.get("Kills") +": " + intToStr(kills); - if(nextLevel!=NULL){ + if(enemyKills > 0 || nextLevel != NULL) { + str+= "\n" + lang.get("Kills") +": " + intToStr(enemyKills); + if(nextLevel != NULL) { str+= " (" + nextLevel->getName() + ": " + intToStr(nextLevel->getKills()) + ")"; } } @@ -1509,17 +1510,20 @@ void Unit::computeTotalUpgrade(){ faction->getUpgradeManager()->computeTotalUpgrade(this, &totalUpgrade); } -void Unit::incKills(){ +void Unit::incKills(int team) { ++kills; + if(team != this->getTeam()) { + ++enemyKills; + } const Level *nextLevel= getNextLevel(); - if(nextLevel!=NULL && kills>= nextLevel->getKills()){ + if(nextLevel != NULL && enemyKills >= nextLevel->getKills()) { level= nextLevel; int maxHp= totalUpgrade.getMaxHp(); totalUpgrade.incLevel(type); checkItemInVault(&this->hp,this->hp); - hp += totalUpgrade.getMaxHp()-maxHp; + hp += totalUpgrade.getMaxHp() - maxHp; addItemToVault(&this->hp,this->hp); } } @@ -2143,6 +2147,7 @@ std::string Unit::toString() const { result += " highlight = " + floatToStr(this->highlight); result += " progress2 = " + intToStr(this->progress2); result += " kills = " + intToStr(this->kills); + result += " enemyKills = " + intToStr(this->enemyKills); result += "\n"; // WARNING!!! Don't access the Unit pointer in this->targetRef in this method or it causes diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 07ad4f51..951e0176 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -262,6 +262,7 @@ private: float highlight; int progress2; int kills; + int enemyKills; UnitReference targetRef; @@ -376,7 +377,8 @@ public: float getRotation() const {return rotation;} float getVerticalRotation() const; ParticleSystem *getFire() const {return fire;} - int getKills() {return kills;} + int getKills() const {return kills;} + int getEnemyKills() const {return enemyKills;} const Level *getLevel() const {return level;} const Level *getNextLevel() const; string getFullName() const; @@ -459,7 +461,7 @@ public: void tick(); void applyUpgrade(const UpgradeType *upgradeType); void computeTotalUpgrade(); - void incKills(); + void incKills(int team); bool morph(const MorphCommandType *mct); CommandResult checkCommand(Command *command) const; void applyCommand(Command *command); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index b28a5678..ab14310a 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -1865,7 +1865,7 @@ 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()); - attacker->incKills(); + attacker->incKills(attacked->getTeam()); switch(this->game->getGameSettings()->getPathFinderType()) { case pfBasic: