mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
Support for creature damage bonus.
TODO: display it in a creature window
This commit is contained in:
parent
26fe6b3f04
commit
695c862638
@ -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<int, int>(id, st->type->damageMax * st->count));
|
||||
m_statMinDamage.push_back(std::pair<int, int>(id, st->type->damageMin * st->count));
|
||||
m_statMaxDamage.push_back(std::pair<int, int>(id, st->getMaxDamage() * st->count));
|
||||
m_statMinDamage.push_back(std::pair<int, int>(id, st->getMinDamage() * st->count));
|
||||
m_statHitPoints.push_back(std::pair<int, int>(id, hitPoints));
|
||||
m_statMaxSpeed.push_back(std::pair<int, int>(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;
|
||||
}
|
||||
}
|
||||
|
@ -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<CCreature*>::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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -2495,8 +2495,8 @@ bool CGameState::checkForVisitableDir( const int3 & src, const TerrainTile *pom,
|
||||
std::pair<ui32, ui32> 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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user