1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Configurable ferocity bonus

This commit is contained in:
Dydzio 2024-01-01 21:16:38 +01:00
parent 898b8f3c71
commit 7cf7543747
4 changed files with 19 additions and 6 deletions

View File

@ -380,7 +380,7 @@
"core.bonus.FEARLESS.name": "Fearless",
"core.bonus.FEARLESS.description": "Immune to Fear ability",
"core.bonus.FEROCITY.name": "Ferocity",
"core.bonus.FEROCITY.description": "DESCRIPTION TO BE ADDED",
"core.bonus.FEROCITY.description": "Attacks ${val} additional times if killed anybody",
"core.bonus.FLYING.name": "Fly",
"core.bonus.FLYING.description": "Flies when moving (ignores obstacles)",
"core.bonus.FREE_SHOOTING.name": "Shoot Close",

View File

@ -608,6 +608,13 @@ Affected unit can use ranged attacks only within specified range
- val: max shooting range in hexes
- addInfo: optional, range at which ranged penalty will trigger (default is 10)
### FEROCITY
Affected unit will attack additional times if killed creatures during attacking (including ADDITIONAL_ATTACK bonus attacks)
- val: amount of additional attacks (negative number will reduce number of unperformed attacks if any left)
- addInfo: optional, amount of creatures needed to kill (default is 1)
## Special abilities
### CATAPULT

View File

@ -173,7 +173,7 @@ class JsonNode;
BONUS_NAME(UNLIMITED_MOVEMENT) /*cheat bonus*/ \
BONUS_NAME(MAX_MORALE) /*cheat bonus*/ \
BONUS_NAME(MAX_LUCK) /*cheat bonus*/ \
BONUS_NAME(FEROCITY) /*extra attack, only if at least 1 creature killed in opponent target unit*/ \
BONUS_NAME(FEROCITY) /*extra attacks, only if at least some creatures killed in opponent target unit, val = amount of additional attacks, additional info = amount of creatures killed to trigger (default 1)*/ \
/* end of list */

View File

@ -271,7 +271,7 @@ bool BattleActionProcessor::doAttackAction(const CBattleInfoCallback & battle, c
const bool firstStrike = destinationStack->hasBonusOfType(BonusType::FIRST_STRIKE);
const bool retaliation = destinationStack->ableToRetaliate();
bool ferocityApplied = false;
int32_t defenderCreatureQuantity = destinationStack->getCount();
int32_t defenderInitialQuantity = destinationStack->getCount();
for (int i = 0; i < totalAttacks; ++i)
{
@ -286,10 +286,16 @@ bool BattleActionProcessor::doAttackAction(const CBattleInfoCallback & battle, c
{
makeAttack(battle, stack, destinationStack, (i ? 0 : distance), destinationTile, i==0, false, false);//no distance travelled on second attack
if(!ferocityApplied && stack->hasBonusOfType(BonusType::FEROCITY) && destinationStack->getCount() < defenderCreatureQuantity)
if(!ferocityApplied && stack->hasBonusOfType(BonusType::FEROCITY))
{
auto ferocityBonus = stack->getBonus(Selector::type()(BonusType::FEROCITY));
int32_t requiredCreaturesToKill = ferocityBonus->additionalInfo != CAddInfo::NONE ? ferocityBonus->additionalInfo[0] : 1;
if(defenderInitialQuantity - destinationStack->getCount() >= requiredCreaturesToKill)
{
ferocityApplied = true;
++totalAttacks;
int additionalAttacksCount = stack->valOfBonuses(BonusType::FEROCITY);
totalAttacks += additionalAttacksCount;
}
}
}