Author Topic: [DONE] Units die from negative life regeneration  (Read 820 times)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
[DONE] Units die from negative life regeneration
« on: 16 January 2011, 21:06:48 »
Units doesn't die with 0 or less life caused by a negative value in life regeneration, but die when get damaged.

I tried to fix this:

Easily change in unit.cpp:
Code: [Select]
void Unit::tick() {

if(isAlive()) {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
}

//regenerate hp
hp+= type->getHpRegeneration();
if(hp>type->getTotalMaxHp(&totalUpgrade)){
hp= type->getTotalMaxHp(&totalUpgrade);

}
//stop DamageParticles
if(hp>type->getTotalMaxHp(&totalUpgrade)/2 ){
stopDamageParticles();
}
//regenerate ep
ep+= type->getEpRegeneration();
if(ep>type->getTotalMaxEp(&totalUpgrade)){
ep= type->getTotalMaxEp(&totalUpgrade);
}
}
}
to:
Code: [Select]
void Unit::tick() {

if(isAlive()) {
if(type == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
}

//regenerate hp
hp+= type->getHpRegeneration();
if(hp>type->getTotalMaxHp(&totalUpgrade)){
hp= type->getTotalMaxHp(&totalUpgrade);
//kill when life below 0
if(hp <= 0){
alive = false;
kill();
}
}
//stop DamageParticles
if(hp>type->getTotalMaxHp(&totalUpgrade)/2 ){
stopDamageParticles();
}
//regenerate ep
ep+= type->getEpRegeneration();
if(ep>type->getTotalMaxEp(&totalUpgrade)){
ep= type->getTotalMaxEp(&totalUpgrade);
}
}
}

Sry for my bad english. I try to improve ;-) ...
« Last Edit: 9 June 2011, 11:01:45 by tomreyn »

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Units die from negative life regeneration
« Reply #1 on: 19 January 2011, 17:04:31 »
this is in svn now ( maybe made in a different way )
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios