Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MuwuM

Pages: 1 ... 14 15 16 17 [18]
426
Feature requests / [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 ;-) ...

Pages: 1 ... 14 15 16 17 [18]
anything