Ver Fonte

Added subtype for SPELL_DURATION

Ivan Savenko há 2 anos atrás
pai
commit
4ba8014573

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

@@ -256,6 +256,7 @@ Allows creature upgrade for affected armies
 Changes duration of timed spells casted by affected hero
 
 - val: additional duration, turns
+- subtype: optional, identifier of affected spells, or all if not set
 
 ### SPELL
 

+ 1 - 0
lib/JsonNode.cpp

@@ -486,6 +486,7 @@ static void loadBonusSubtype(BonusSubtypeID & subtype, BonusType type, const Jso
 			break;
 		}
 		case BonusType::SPELL_IMMUNITY:
+		case BonusType::SPELL_DURATION:
 		case BonusType::SPECIAL_ADD_VALUE_ENCHANT:
 		case BonusType::SPECIAL_FIXED_VALUE_ENCHANT:
 		case BonusType::SPECIAL_PECULIAR_ENCHANT:

+ 5 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -697,7 +697,11 @@ int32_t CGHeroInstance::getEffectPower(const spells::Spell * spell) const
 
 int32_t CGHeroInstance::getEnchantPower(const spells::Spell * spell) const
 {
-	return getPrimSkillLevel(PrimarySkill::SPELL_POWER) + valOfBonuses(BonusType::SPELL_DURATION);
+	int32_t spellpower = getPrimSkillLevel(PrimarySkill::SPELL_POWER);
+	int32_t durationCommon = valOfBonuses(BonusType::SPELL_DURATION, BonusSubtypeID());
+	int32_t durationSpecific = valOfBonuses(BonusType::SPELL_DURATION, BonusSubtypeID(spell->getId()));
+
+	return spellpower + durationCommon + durationSpecific;
 }
 
 int64_t CGHeroInstance::getEffectValue(const spells::Spell * spell) const