diff --git a/AI/GeniusAI/BattleLogic.cpp b/AI/GeniusAI/BattleLogic.cpp index 998fceb92..2b4583ad5 100644 --- a/AI/GeniusAI/BattleLogic.cpp +++ b/AI/GeniusAI/BattleLogic.cpp @@ -133,8 +133,8 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) // make stats int hitPoints = st->count * stackHP - (stackHP - st->firstHPleft); - m_statMaxDamage.push_back(std::pair(id, st->type->damageMax * st->count)); - m_statMinDamage.push_back(std::pair(id, st->type->damageMin * st->count)); + m_statMaxDamage.push_back(std::pair(id, st->getMaxDamage() * st->count)); + m_statMinDamage.push_back(std::pair(id, st->getMinDamage() * st->count)); m_statHitPoints.push_back(std::pair(id, hitPoints)); m_statMaxSpeed.push_back(std::pair(id, stackHP)); @@ -175,13 +175,13 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) } } - cs.damage_max = (int)(currentStack->type->damageMax * currentStack->count * damageFactor); + cs.damage_max = (int)(currentStack->getMaxDamage() * currentStack->count * damageFactor); if (cs.damage_max > hitPoints) { cs.damage_max = hitPoints; } - cs.damage_min = (int)(currentStack->type->damageMin * currentStack->count * damageFactor); + cs.damage_min = (int)(currentStack->getMinDamage() * currentStack->count * damageFactor); if (cs.damage_min > hitPoints) { cs.damage_min = hitPoints; @@ -217,7 +217,7 @@ void CBattleLogic::MakeStatistics(int currentCreatureId) } int hitPoints = st->count * stackHP - (stackHP - st->firstHPleft); - totalDamage += (st->type->damageMax + st->type->damageMin) * st->count / 2; + totalDamage += (st->getMaxDamage() + st->getMinDamage()) * st->count / 2; totalHitPoints += hitPoints; } } diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 5e55682c7..a12a86108 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -1109,13 +1109,20 @@ void CGHeroInstance::initObj() case 13://Dragon bonuses (Mutare) bonus.type = Bonus::PRIMARY_SKILL; bonus.valType = Bonus::ADDITIVE_VALUE; - bonus.additionalInfo = it->additionalinfo; //id - bonus.subtype = it->subtype; //which stat it is + switch (it->subtype) + { + case 1: + bonus.subtype = PrimarySkill::ATTACK; + break; + case 2: + bonus.subtype = PrimarySkill::DEFENSE; + break; + } for (std::vector::iterator i = VLC->creh->creatures.begin(); i != VLC->creh->creatures.end(); i++) { //TODO: what if creature changes type during the game (Dragon Eye Ring?) if ((*i)->hasBonusOfType(Bonus::DRAGON_NATURE)) //TODO: implement it! { - bonus.additionalInfo = (*i)->idNumber; //for each Dragon separately + bonus.limiter = new CCreatureTypeLimiter (**i, false); speciality.bonuses.push_back (bonus); } } diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 66d42fc67..fcd8a2c98 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -276,4 +276,13 @@ void CStackInstance::getParents(TCNodes &out, const CBonusSystemNode *source /*= out.insert(armyObj); else out.insert(&IObjectInterface::cb->gameState()->globalEffects); +} + +ui32 CStackInstance::getMinDamage() const +{ + return type->damageMin + valOfBonuses(Bonus::CREATURE_DAMAGE, 0) + valOfBonuses(Bonus::CREATURE_DAMAGE, 1); +} +ui32 CStackInstance::getMaxDamage() const +{ + return type->damageMax + valOfBonuses(Bonus::CREATURE_DAMAGE, 0) + valOfBonuses(Bonus::CREATURE_DAMAGE, 2); } \ No newline at end of file diff --git a/lib/CCreatureSet.h b/lib/CCreatureSet.h index 31a312201..e90353695 100644 --- a/lib/CCreatureSet.h +++ b/lib/CCreatureSet.h @@ -25,6 +25,8 @@ public: const CArmedInstance *armyObj; //stack must be part of some army, army must be part of some object const CCreature *type; TQuantity count; + ui32 getMinDamage() const; + ui32 getMaxDamage() const; ui32 experience; //TODO: handle //TODO: stack artifacts diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 0d1301580..c1f2f2547 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -2495,8 +2495,8 @@ bool CGameState::checkForVisitableDir( const int3 & src, const TerrainTile *pom, std::pair BattleInfo::calculateDmgRange( const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky ) { float additiveBonus=1.0f, multBonus=1.0f, - minDmg = attacker->type->damageMin * attacker->count, - maxDmg = attacker->type->damageMax * attacker->count; + minDmg = attacker->getMinDamage() * attacker->count, + maxDmg = attacker->getMaxDamage() * attacker->count; if(attacker->type->idNumber == 149) //arrow turret {