- updated hp regeneration method to look for negative hp regen values and if health ticks below 0 the unit dies
This commit is contained in:
parent
8d8afe78b5
commit
335749a15e
|
@ -25,6 +25,7 @@
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
|
#include "sound_renderer.h"
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
@ -1112,14 +1113,30 @@ void Unit::tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//regenerate hp
|
//regenerate hp
|
||||||
|
if(type->getHpRegeneration() >= 0) {
|
||||||
hp+= type->getHpRegeneration();
|
hp+= type->getHpRegeneration();
|
||||||
if(hp>type->getTotalMaxHp(&totalUpgrade)){
|
if(hp>type->getTotalMaxHp(&totalUpgrade)){
|
||||||
hp= type->getTotalMaxHp(&totalUpgrade);
|
hp= type->getTotalMaxHp(&totalUpgrade);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// If we have negative regeneration then check if the unit should die
|
||||||
|
else {
|
||||||
|
bool decHpResult = decHp(-type->getHpRegeneration());
|
||||||
|
if(decHpResult) {
|
||||||
|
Unit::game->getWorld()->getStats()->die(getFactionIndex());
|
||||||
|
game->getScriptManager()->onUnitDied(this);
|
||||||
|
}
|
||||||
|
StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound();
|
||||||
|
if(sound != NULL && this->getFactionIndex() == Unit::game->getWorld()->getThisFactionIndex()) {
|
||||||
|
SoundRenderer::getInstance().playFx(sound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//stop DamageParticles
|
//stop DamageParticles
|
||||||
if(hp > type->getTotalMaxHp(&totalUpgrade) / 2) {
|
if(hp > type->getTotalMaxHp(&totalUpgrade) / 2) {
|
||||||
stopDamageParticles();
|
stopDamageParticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
//regenerate ep
|
//regenerate ep
|
||||||
ep += type->getEpRegeneration();
|
ep += type->getEpRegeneration();
|
||||||
if(ep>type->getTotalMaxEp(&totalUpgrade)){
|
if(ep>type->getTotalMaxEp(&totalUpgrade)){
|
||||||
|
|
Loading…
Reference in New Issue