- no longer allow killing self or team to update your skill levels

This commit is contained in:
Mark Vejvoda 2011-04-20 16:46:47 +00:00
parent b180581bf8
commit 16ea7881ab
3 changed files with 16 additions and 9 deletions

View File

@ -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

View File

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

View File

@ -1865,7 +1865,7 @@ 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());
attacker->incKills();
attacker->incKills(attacked->getTeam());
switch(this->game->getGameSettings()->getPathFinderType()) {
case pfBasic: