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:
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:
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 ;-) ...