1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

made artillery bonus-based; supports multiple bonus shots

This commit is contained in:
Henning Koehler 2017-08-27 21:05:17 +12:00
parent 8bdb8f01ca
commit 7e5c1ec7f8
3 changed files with 92 additions and 14 deletions

View File

@ -666,5 +666,81 @@
} }
] ]
} }
},
"tactics" : {
"basic" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.tactics",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 3,
"valueType" : "BASE_NUMBER"
}
]
},
"advanced" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.tactics",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 5,
"valueType" : "BASE_NUMBER"
}
]
},
"expert" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.tactics",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 7,
"valueType" : "BASE_NUMBER"
}
]
}
},
"artillery" : {
"basic" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.artillery",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 50,
"valueType" : "BASE_NUMBER"
}
]
},
"advanced" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.artillery",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 75,
"valueType" : "BASE_NUMBER"
},
{
"subtype" : "skill.artillery",
"type" : "SECONDARY_SKILL_VAL2",
"val" : 1,
"valueType" : "BASE_NUMBER"
}
]
},
"expert" : {
"description" : "",
"effects" : [
{
"subtype" : "skill.artillery",
"type" : "SECONDARY_SKILL_PREMY",
"val" : 100,
"valueType" : "BASE_NUMBER"
}
]
}
} }
} }

View File

@ -256,6 +256,10 @@ std::vector<std::shared_ptr<Bonus>> CSkillHandler::defaultBonus(SecondarySkill s
addBonus(1 + level); break; addBonus(1 + level); break;
case SecondarySkill::TACTICS: case SecondarySkill::TACTICS:
addBonus(1 + 2 * level); break; addBonus(1 + 2 * level); break;
case SecondarySkill::ARTILLERY:
addBonus(25 + 25 * level); break;
if(level > 1) // extra attack
addBonus(1, Bonus::SECONDARY_SKILL_VAL2);
case SecondarySkill::LEARNING: case SecondarySkill::LEARNING:
addBonus(5 * level); break; addBonus(5 * level); break;
case SecondarySkill::OFFENCE: case SecondarySkill::OFFENCE:

View File

@ -880,9 +880,8 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
if (att->getCreature()->idNumber == CreatureID::BALLISTA) if (att->getCreature()->idNumber == CreatureID::BALLISTA)
{ {
static const int artilleryLvlToChance[] = {0, 50, 75, 100};
const CGHeroInstance * owner = gs->curB->getHero(att->owner); const CGHeroInstance * owner = gs->curB->getHero(att->owner);
int chance = artilleryLvlToChance[owner->getSecSkillLevel(SecondarySkill::ARTILLERY)]; int chance = owner->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARTILLERY);
if (chance > getRandomGenerator().nextInt(99)) if (chance > getRandomGenerator().nextInt(99))
{ {
bat.flags |= BattleAttack::BALLISTA_DOUBLE_DMG; bat.flags |= BattleAttack::BALLISTA_DOUBLE_DMG;
@ -4007,19 +4006,18 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
handleAfterAttackCasting(bat); handleAfterAttackCasting(bat);
} }
//second shot for ballista, only if hero has advanced artillery //extra shot(s) for ballista, based on artillery skill
if(stack->getCreature()->idNumber == CreatureID::BALLISTA)
const CGHeroInstance * attackingHero = gs->curB->battleGetFightingHero(ba.side);
if(destinationStack->alive()
&& (stack->getCreature()->idNumber == CreatureID::BALLISTA)
&& (attackingHero->getSecSkillLevel(SecondarySkill::ARTILLERY) >= SecSkillLevel::ADVANCED)
)
{ {
BattleAttack bat2; const CGHeroInstance * attackingHero = gs->curB->battleGetFightingHero(ba.side);
bat2.flags |= BattleAttack::SHOT; int ballistaBonusAttacks = attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_VAL2, SecondarySkill::ARTILLERY);
prepareAttack(bat2, stack, destinationStack, 0, ba.destinationTile); while(destinationStack->alive() && ballistaBonusAttacks-- > 0)
sendAndApply(&bat2); {
BattleAttack bat2;
bat2.flags |= BattleAttack::SHOT;
prepareAttack(bat2, stack, destinationStack, 0, ba.destinationTile);
sendAndApply(&bat2);
}
} }
//allow more than one additional attack //allow more than one additional attack