mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Grant advanced catapult proficiency with CATAPULT_EXTRA_SHOTS
This commit is contained in:
parent
44d653b835
commit
b55d506e22
@ -4271,13 +4271,20 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
|
||||
const CGHeroInstance * attackingHero = gs->curB->battleGetFightingHero(ba.side);
|
||||
|
||||
CHeroHandler::SBallisticsLevelInfo sbi;
|
||||
CHeroHandler::SBallisticsLevelInfo stackBallisticsParameters;
|
||||
if(stack->getCreature()->idNumber == CreatureID::CATAPULT)
|
||||
sbi = VLC->heroh->ballistics.at(attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::BALLISTICS));
|
||||
else //may need to use higher ballistics level for creatures in future for some cases to match original H3 (upgraded cyclops etc)
|
||||
stackBallisticsParameters = VLC->heroh->ballistics.at(attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::BALLISTICS));
|
||||
else
|
||||
{
|
||||
sbi = VLC->heroh->ballistics.at(1);
|
||||
sbi.shots += std::max(stack->valOfBonuses(Bonus::CATAPULT_EXTRA_SHOTS), 0);
|
||||
if(stack->hasBonusOfType(Bonus::CATAPULT_EXTRA_SHOTS)) //by design use advanced ballistics parameters with this bonus present, upg. cyclops use advanced ballistics, nonupg. use basic in OH3
|
||||
{
|
||||
stackBallisticsParameters = VLC->heroh->ballistics.at(2);
|
||||
stackBallisticsParameters.shots = 1; //skip default "2 shots" from adv. ballistics
|
||||
}
|
||||
else
|
||||
stackBallisticsParameters = VLC->heroh->ballistics.at(1);
|
||||
|
||||
stackBallisticsParameters.shots += std::max(stack->valOfBonuses(Bonus::CATAPULT_EXTRA_SHOTS), 0); //0 is allowed minimum to let modders force advanced ballistics for "oneshotting creatures"
|
||||
}
|
||||
|
||||
auto wallPart = gs->curB->battleHexToWallPart(destination);
|
||||
@ -4296,7 +4303,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
break;
|
||||
}
|
||||
|
||||
for (int g=0; g<sbi.shots; ++g)
|
||||
for (int g=0; g<stackBallisticsParameters.shots; ++g)
|
||||
{
|
||||
bool hitSuccessfull = false;
|
||||
auto attackedPart = wallPart;
|
||||
@ -4305,7 +4312,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
{
|
||||
if (currentHP.at(attackedPart) != EWallState::DESTROYED && // this part can be hit
|
||||
currentHP.at(attackedPart) != EWallState::NONE &&
|
||||
getRandomGenerator().nextInt(99) < getCatapultHitChance(attackedPart, sbi))//hit is successful
|
||||
getRandomGenerator().nextInt(99) < getCatapultHitChance(attackedPart, stackBallisticsParameters))//hit is successful
|
||||
{
|
||||
hitSuccessfull = true;
|
||||
}
|
||||
@ -4334,7 +4341,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
attack.destinationTile = destination;
|
||||
attack.damageDealt = 0;
|
||||
|
||||
int dmgChance[] = { sbi.noDmg, sbi.oneDmg, sbi.twoDmg }; //dmgChance[i] - chance for doing i dmg when hit is successful
|
||||
int dmgChance[] = { stackBallisticsParameters.noDmg, stackBallisticsParameters.oneDmg, stackBallisticsParameters.twoDmg }; //dmgChance[i] - chance for doing i dmg when hit is successful
|
||||
|
||||
int dmgRand = getRandomGenerator().nextInt(99);
|
||||
//accumulating dmgChance
|
||||
|
Loading…
x
Reference in New Issue
Block a user