- bugfix for attack-boosts on morphed units
This commit is contained in:
parent
68d8ef11d8
commit
63e3313e6b
|
@ -2679,6 +2679,25 @@ void Unit::checkUnitLevel() {
|
|||
}
|
||||
}
|
||||
|
||||
void Unit::morphAttackBoosts(Unit *unit) {
|
||||
// Remove any units that were previously in range
|
||||
if(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.empty() == false && currentAttackBoostOriginatorEffect.skillType != NULL) {
|
||||
for(int i = currentAttackBoostOriginatorEffect.currentAttackBoostUnits.size() - 1; i >= 0; --i) {
|
||||
// Remove attack boost upgrades from unit
|
||||
|
||||
int findUnitId = currentAttackBoostOriginatorEffect.currentAttackBoostUnits[i];
|
||||
Unit *affectedUnit = game->getWorld()->findUnitById(findUnitId);
|
||||
if(affectedUnit != NULL && affectedUnit->getId() == unit->getId()) {
|
||||
affectedUnit->deapplyAttackBoost(currentAttackBoostOriginatorEffect.skillType->getAttackBoost(), this);
|
||||
|
||||
currentAttackBoostOriginatorEffect.currentAttackBoostUnits.erase(currentAttackBoostOriginatorEffect.currentAttackBoostUnits.begin() + i);
|
||||
}
|
||||
|
||||
//printf("- #1 DE-APPLY ATTACK BOOST from unit [%s - %d]\n",affectedUnit->getType()->getName().c_str(),affectedUnit->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::morph(const MorphCommandType *mct){
|
||||
|
||||
if(mct == NULL) {
|
||||
|
@ -2703,6 +2722,17 @@ bool Unit::morph(const MorphCommandType *mct){
|
|||
map->clearUnitCells(this, pos, true);
|
||||
faction->deApplyStaticCosts(type,mct);
|
||||
|
||||
//printf("Now unapply attack-boost for unit [%d - %s]\n",this->getId(),this->getType()->getName().c_str());
|
||||
// De apply attack boosts for morphed unit
|
||||
for(int i = currentAttackBoostEffects.size() - 1; i >= 0; --i) {
|
||||
UnitAttackBoostEffect *effect = currentAttackBoostEffects[i];
|
||||
if(effect != NULL) {
|
||||
Unit *sourceUnit = game->getWorld()->findUnitById(effect->source->getId());
|
||||
sourceUnit->morphAttackBoosts(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkItemInVault(&this->hp,this->hp);
|
||||
hp += morphUnitType->getMaxHp() - type->getMaxHp();
|
||||
addItemToVault(&this->hp,this->hp);
|
||||
|
|
|
@ -741,6 +741,8 @@ private:
|
|||
void checkCustomizedParticleTriggers(bool force);
|
||||
bool checkModelStateInfoForNewHpValue();
|
||||
void checkUnitLevel();
|
||||
|
||||
void morphAttackBoosts(Unit *unit);
|
||||
};
|
||||
|
||||
}}// end namespace
|
||||
|
|
Loading…
Reference in New Issue