Browse Source

Added VULNERABLE_FROM_BACK bonus

Ivan Savenko 4 months ago
parent
commit
527885de21

+ 3 - 1
client/battle/BattleStacksController.cpp

@@ -442,7 +442,9 @@ void BattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> at
 
 
 		// FIXME: this check is better, however not usable since stacksAreAttacked is called after net pack is applied - petrification is already removed
 		// FIXME: this check is better, however not usable since stacksAreAttacked is called after net pack is applied - petrification is already removed
 		// if (needsReverse && !attackedInfo.defender->isFrozen())
 		// if (needsReverse && !attackedInfo.defender->isFrozen())
-		if (needsReverse && stackAnimation[attackedInfo.defender->unitId()]->getType() != ECreatureAnimType::FROZEN)
+		if (needsReverse &&
+		   stackAnimation[attackedInfo.defender->unitId()]->getType() != ECreatureAnimType::FROZEN &&
+		   !attackedInfo.defender->hasBonusOfType(BonusType::VULNERABLE_FROM_BACK))
 		{
 		{
 			owner.addToAnimationStage(EAnimationEvents::MOVEMENT, [this, attackedInfo]()
 			owner.addToAnimationStage(EAnimationEvents::MOVEMENT, [this, attackedInfo]()
 			{
 			{

+ 12 - 0
docs/modders/Bonus/Bonus_Types.md

@@ -413,6 +413,12 @@ Increases starting amount of shots that unit has in battle
 
 
 ## Static abilities and immunities
 ## Static abilities and immunities
 
 
+### LIVING
+
+Affected unit is considered to be alive. Automatically granted to any unit that is not UNDEAD, NON_LIVING, MECHANICAL, GARGOYLE, or SIEGE_WEAPON.
+
+Living units can be affected by TRANSMUTATION, LIFE_DRAIN, and SOUL_STEAL bonuses
+
 ### NON_LIVING
 ### NON_LIVING
 
 
 Affected unit is considered to not be alive and not affected by morale and certain spells
 Affected unit is considered to not be alive and not affected by morale and certain spells
@@ -495,6 +501,12 @@ Affected unit will deal more damage based on movement distance (Champions)
 
 
 - val: additional damage per passed tile, percentage
 - val: additional damage per passed tile, percentage
 
 
+### VULNERABLE_FROM_BACK
+
+Affected unit will receive more damage when attacked from behind. Attacked unit will not turn around to face the attacker
+
+- val: additional damage for attacks from behind, percentage (0-100)
+
 ### HATE
 ### HATE
 
 
 Affected unit will deal more damage when attacking specific creature
 Affected unit will deal more damage when attacking specific creature

+ 10 - 0
lib/battle/DamageCalculator.cpp

@@ -275,6 +275,15 @@ double DamageCalculator::getAttackJoustingFactor() const
 	return 0.0;
 	return 0.0;
 }
 }
 
 
+double DamageCalculator::getAttackFromBackFactor() const
+{
+	int value = info.defender->valOfBonuses(BonusType::VULNERABLE_FROM_BACK);
+
+	if (value != 0 && callback.isToReverse(info.attacker, info.defender, info.attackerPos, info.defenderPos))
+		return value / 100.0;
+	return 0;
+}
+
 double DamageCalculator::getAttackHateFactor() const
 double DamageCalculator::getAttackHateFactor() const
 {
 {
 	//assume that unit have only few HATE features and cache them all
 	//assume that unit have only few HATE features and cache them all
@@ -462,6 +471,7 @@ std::vector<double> DamageCalculator::getAttackFactors() const
 		getAttackBlessFactor(),
 		getAttackBlessFactor(),
 		getAttackLuckFactor(),
 		getAttackLuckFactor(),
 		getAttackJoustingFactor(),
 		getAttackJoustingFactor(),
+		getAttackFromBackFactor(),
 		getAttackDeathBlowFactor(),
 		getAttackDeathBlowFactor(),
 		getAttackDoubleDamageFactor(),
 		getAttackDoubleDamageFactor(),
 		getAttackHateFactor(),
 		getAttackHateFactor(),

+ 1 - 0
lib/battle/DamageCalculator.h

@@ -52,6 +52,7 @@ class DLL_LINKAGE DamageCalculator
 	double getAttackDoubleDamageFactor() const;
 	double getAttackDoubleDamageFactor() const;
 	double getAttackHateFactor() const;
 	double getAttackHateFactor() const;
 	double getAttackRevengeFactor() const;
 	double getAttackRevengeFactor() const;
+	double getAttackFromBackFactor() const;
 
 
 	double getDefenseSkillFactor() const;
 	double getDefenseSkillFactor() const;
 	double getDefenseArmorerFactor() const;
 	double getDefenseArmorerFactor() const;

+ 1 - 0
lib/bonuses/BonusEnum.h

@@ -189,6 +189,7 @@ class JsonNode;
 	BONUS_NAME(MULTIHEX_ENEMY_ATTACK) /*eg. dragons*/	\
 	BONUS_NAME(MULTIHEX_ENEMY_ATTACK) /*eg. dragons*/	\
 	BONUS_NAME(MULTIHEX_ANIMATION) /*eg. dragons*/	\
 	BONUS_NAME(MULTIHEX_ANIMATION) /*eg. dragons*/	\
 	BONUS_NAME(STACK_EXPERIENCE_GAIN_PERCENT) /*modifies all stack experience gains*/\
 	BONUS_NAME(STACK_EXPERIENCE_GAIN_PERCENT) /*modifies all stack experience gains*/\
+	BONUS_NAME(VULNERABLE_FROM_BACK) /*bonus damage for attacks from behind*/\
 	/* end of list */
 	/* end of list */