mirror of
https://github.com/glest/glest-source.git
synced 2025-08-26 01:23:35 +02:00
- more bugfixes for attack-boost
This commit is contained in:
@@ -1490,13 +1490,46 @@ bool Unit::applyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
|||||||
effect.boost = boost;
|
effect.boost = boost;
|
||||||
effect.source = source;
|
effect.source = source;
|
||||||
|
|
||||||
//if(boost->isAffected(source, this)) {
|
bool wasAlive = alive;
|
||||||
totalUpgrade.apply(&boost->boostUpgrade, this);
|
int prevMaxHp = totalUpgrade.getMaxHp();
|
||||||
|
//printf("#1 wasAlive = %d hp = %d boosthp = %d\n",wasAlive,hp,boost->boostUpgrade.getMaxHp());
|
||||||
|
|
||||||
checkItemInVault(&this->hp,this->hp);
|
totalUpgrade.apply(&boost->boostUpgrade, this);
|
||||||
hp += boost->boostUpgrade.getMaxHp();
|
|
||||||
addItemToVault(&this->hp,this->hp);
|
checkItemInVault(&this->hp,this->hp);
|
||||||
//}
|
//hp += boost->boostUpgrade.getMaxHp();
|
||||||
|
hp += (totalUpgrade.getMaxHp() - prevMaxHp);
|
||||||
|
addItemToVault(&this->hp,this->hp);
|
||||||
|
|
||||||
|
//printf("#2 wasAlive = %d hp = %d boosthp = %d\n",wasAlive,hp,boost->boostUpgrade.getMaxHp());
|
||||||
|
|
||||||
|
if(wasAlive == true) {
|
||||||
|
//startDamageParticles
|
||||||
|
startDamageParticles();
|
||||||
|
|
||||||
|
//stop DamageParticles on death
|
||||||
|
if(hp <= 0) {
|
||||||
|
alive= false;
|
||||||
|
hp=0;
|
||||||
|
addItemToVault(&this->hp,this->hp);
|
||||||
|
|
||||||
|
stopDamageParticles(true);
|
||||||
|
|
||||||
|
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() ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer))) {
|
||||||
|
SoundRenderer::getInstance().playFx(sound);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->isDead() && this->getCurrSkill()->getClass() != scDie) {
|
||||||
|
this->kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(showUnitParticles == true) {
|
if(showUnitParticles == true) {
|
||||||
effect.upst = new UnitParticleSystemType();
|
effect.upst = new UnitParticleSystemType();
|
||||||
@@ -1523,13 +1556,43 @@ void Unit::deapplyAttackBoost(const AttackBoost *boost, const Unit *source) {
|
|||||||
|
|
||||||
//printf("DE-APPLYING ATTACK BOOST to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
|
//printf("DE-APPLYING ATTACK BOOST to unit [%s - %d] from unit [%s - %d]\n",this->getType()->getName().c_str(),this->getId(),source->getType()->getName().c_str(),source->getId());
|
||||||
|
|
||||||
//if(boost->isAffected(source, this)) {
|
bool wasAlive = alive;
|
||||||
totalUpgrade.deapply(&boost->boostUpgrade, this);
|
int prevMaxHp = totalUpgrade.getMaxHp();
|
||||||
|
totalUpgrade.deapply(&boost->boostUpgrade, this);
|
||||||
|
|
||||||
|
checkItemInVault(&this->hp,this->hp);
|
||||||
|
//hp -= boost->boostUpgrade.getMaxHp();
|
||||||
|
hp -= (prevMaxHp - totalUpgrade.getMaxHp());
|
||||||
|
addItemToVault(&this->hp,this->hp);
|
||||||
|
|
||||||
|
if(wasAlive == true) {
|
||||||
|
//startDamageParticles
|
||||||
|
startDamageParticles();
|
||||||
|
|
||||||
|
//stop DamageParticles on death
|
||||||
|
if(hp <= 0) {
|
||||||
|
alive= false;
|
||||||
|
hp=0;
|
||||||
|
addItemToVault(&this->hp,this->hp);
|
||||||
|
|
||||||
|
stopDamageParticles(true);
|
||||||
|
|
||||||
|
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() ||
|
||||||
|
(game->getWorld()->getThisTeamIndex() == GameConstants::maxPlayers -1 + fpt_Observer))) {
|
||||||
|
SoundRenderer::getInstance().playFx(sound);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->isDead() && this->getCurrSkill()->getClass() != scDie) {
|
||||||
|
this->kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkItemInVault(&this->hp,this->hp);
|
|
||||||
hp -= boost->boostUpgrade.getMaxHp();
|
|
||||||
addItemToVault(&this->hp,this->hp);
|
|
||||||
//}
|
|
||||||
|
|
||||||
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
for(unsigned int i = 0; i < currentAttackBoostEffects.size(); ++i) {
|
||||||
UnitAttackBoostEffect &effect = currentAttackBoostEffects[i];
|
UnitAttackBoostEffect &effect = currentAttackBoostEffects[i];
|
||||||
|
@@ -37,68 +37,70 @@ namespace Glest{ namespace Game{
|
|||||||
|
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
|
||||||
|
const string VALUE_PERCENT_MULTIPLIER_KEY_NAME = "value-percent-multiplier";
|
||||||
|
|
||||||
void UpgradeTypeBase::load(const XmlNode *upgradeNode) {
|
void UpgradeTypeBase::load(const XmlNode *upgradeNode) {
|
||||||
//values
|
//values
|
||||||
maxHpIsMultiplier = false;
|
maxHpIsMultiplier = false;
|
||||||
maxHp= upgradeNode->getChild("max-hp")->getAttribute("value")->getIntValue();
|
maxHp= upgradeNode->getChild("max-hp")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("max-hp")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("max-hp")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
maxHpIsMultiplier = upgradeNode->getChild("max-hp")->getAttribute("value-percent-multipler")->getBoolValue();
|
maxHpIsMultiplier = upgradeNode->getChild("max-hp")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found maxHpIsMultiplier = %d\n",maxHpIsMultiplier);
|
//printf("Found maxHpIsMultiplier = %d\n",maxHpIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxEpIsMultiplier = false;
|
maxEpIsMultiplier = false;
|
||||||
maxEp= upgradeNode->getChild("max-ep")->getAttribute("value")->getIntValue();
|
maxEp= upgradeNode->getChild("max-ep")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("max-ep")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("max-ep")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
maxEpIsMultiplier = upgradeNode->getChild("max-ep")->getAttribute("value-percent-multipler")->getBoolValue();
|
maxEpIsMultiplier = upgradeNode->getChild("max-ep")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found maxEpIsMultiplier = %d\n",maxEpIsMultiplier);
|
//printf("Found maxEpIsMultiplier = %d\n",maxEpIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
sightIsMultiplier = false;
|
sightIsMultiplier = false;
|
||||||
sight= upgradeNode->getChild("sight")->getAttribute("value")->getIntValue();
|
sight= upgradeNode->getChild("sight")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("sight")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("sight")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
sightIsMultiplier = upgradeNode->getChild("sight")->getAttribute("value-percent-multipler")->getBoolValue();
|
sightIsMultiplier = upgradeNode->getChild("sight")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found sightIsMultiplier = %d\n",sightIsMultiplier);
|
//printf("Found sightIsMultiplier = %d\n",sightIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
attackStrengthIsMultiplier = false;
|
attackStrengthIsMultiplier = false;
|
||||||
attackStrength= upgradeNode->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
attackStrength= upgradeNode->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("attack-strenght")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
attackStrengthIsMultiplier = upgradeNode->getChild("attack-strenght")->getAttribute("value-percent-multipler")->getBoolValue();
|
attackStrengthIsMultiplier = upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found attackStrengthIsMultiplier = %d\n",attackStrengthIsMultiplier);
|
//printf("Found attackStrengthIsMultiplier = %d\n",attackStrengthIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
attackRangeIsMultiplier = false;
|
attackRangeIsMultiplier = false;
|
||||||
attackRange= upgradeNode->getChild("attack-range")->getAttribute("value")->getIntValue();
|
attackRange= upgradeNode->getChild("attack-range")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("attack-range")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("attack-range")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
attackRangeIsMultiplier = upgradeNode->getChild("attack-range")->getAttribute("value-percent-multipler")->getBoolValue();
|
attackRangeIsMultiplier = upgradeNode->getChild("attack-range")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found attackRangeIsMultiplier = %d\n",attackRangeIsMultiplier);
|
//printf("Found attackRangeIsMultiplier = %d\n",attackRangeIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
armorIsMultiplier = false;
|
armorIsMultiplier = false;
|
||||||
armor= upgradeNode->getChild("armor")->getAttribute("value")->getIntValue();
|
armor= upgradeNode->getChild("armor")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("armor")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("armor")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
armorIsMultiplier = upgradeNode->getChild("armor")->getAttribute("value-percent-multipler")->getBoolValue();
|
armorIsMultiplier = upgradeNode->getChild("armor")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found armorIsMultiplier = %d\n",armorIsMultiplier);
|
//printf("Found armorIsMultiplier = %d\n",armorIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveSpeedIsMultiplier = false;
|
moveSpeedIsMultiplier = false;
|
||||||
moveSpeed= upgradeNode->getChild("move-speed")->getAttribute("value")->getIntValue();
|
moveSpeed= upgradeNode->getChild("move-speed")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("move-speed")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("move-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
moveSpeedIsMultiplier = upgradeNode->getChild("move-speed")->getAttribute("value-percent-multipler")->getBoolValue();
|
moveSpeedIsMultiplier = upgradeNode->getChild("move-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found moveSpeedIsMultiplier = %d\n",moveSpeedIsMultiplier);
|
//printf("Found moveSpeedIsMultiplier = %d\n",moveSpeedIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
prodSpeedIsMultiplier = false;
|
prodSpeedIsMultiplier = false;
|
||||||
prodSpeed= upgradeNode->getChild("production-speed")->getAttribute("value")->getIntValue();
|
prodSpeed= upgradeNode->getChild("production-speed")->getAttribute("value")->getIntValue();
|
||||||
if(upgradeNode->getChild("production-speed")->getAttribute("value-percent-multipler",false) != NULL) {
|
if(upgradeNode->getChild("production-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||||
prodSpeedIsMultiplier = upgradeNode->getChild("production-speed")->getAttribute("value-percent-multipler")->getBoolValue();
|
prodSpeedIsMultiplier = upgradeNode->getChild("production-speed")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||||
|
|
||||||
//printf("Found prodSpeedIsMultiplier = %d\n",prodSpeedIsMultiplier);
|
//printf("Found prodSpeedIsMultiplier = %d\n",prodSpeedIsMultiplier);
|
||||||
}
|
}
|
||||||
@@ -375,9 +377,12 @@ void TotalUpgrade::sum(const UpgradeTypeBase *ut, const Unit *unit) {
|
|||||||
prodSpeedIsMultiplier = ut->getProdSpeedIsMultiplier();
|
prodSpeedIsMultiplier = ut->getProdSpeedIsMultiplier();
|
||||||
|
|
||||||
if(ut->getMaxHpIsMultiplier() == true) {
|
if(ut->getMaxHpIsMultiplier() == true) {
|
||||||
|
//printf("#1 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
||||||
maxHp += (unit->getHp() * (ut->getMaxHp() / 100));
|
maxHp += (unit->getHp() * (ut->getMaxHp() / 100));
|
||||||
|
//printf("#1.1 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//printf("#2 Maxhp maxHp = %d, unit->getHp() = %d ut->getMaxHp() = %d\n",maxHp,unit->getHp(),ut->getMaxHp());
|
||||||
maxHp += ut->getMaxHp();
|
maxHp += ut->getMaxHp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,6 +479,15 @@ void TotalUpgrade::apply(const UpgradeTypeBase *ut, const Unit *unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TotalUpgrade::deapply(const UpgradeTypeBase *ut,const Unit *unit) {
|
void TotalUpgrade::deapply(const UpgradeTypeBase *ut,const Unit *unit) {
|
||||||
|
maxHpIsMultiplier = ut->getMaxHpIsMultiplier();
|
||||||
|
sightIsMultiplier = ut->getSightIsMultiplier();
|
||||||
|
maxEpIsMultiplier = ut->getMaxEpIsMultiplier();
|
||||||
|
armorIsMultiplier = ut->getArmorIsMultiplier();
|
||||||
|
attackStrengthIsMultiplier = ut->getAttackStrengthIsMultiplier();
|
||||||
|
attackRangeIsMultiplier = ut->getAttackRangeIsMultiplier();
|
||||||
|
moveSpeedIsMultiplier = ut->getMoveSpeedIsMultiplier();
|
||||||
|
prodSpeedIsMultiplier = ut->getProdSpeedIsMultiplier();
|
||||||
|
|
||||||
if(ut->getMaxHpIsMultiplier() == true) {
|
if(ut->getMaxHpIsMultiplier() == true) {
|
||||||
maxHp -= (unit->getHp() * (ut->getMaxHp() / 100));
|
maxHp -= (unit->getHp() * (ut->getMaxHp() / 100));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user