diff --git a/config/artifacts.json b/config/artifacts.json index 001f41b4b..316ed5346 100644 --- a/config/artifacts.json +++ b/config/artifacts.json @@ -1184,7 +1184,8 @@ { "bonuses" : [ { - "type" : "AIR_SPELL_DMG_PREMY", + "type" : "SPELL_DAMAGE", + "subtype" : 0, "val" : 50, "valueType" : "BASE_NUMBER" } @@ -1196,7 +1197,8 @@ { "bonuses" : [ { - "type" : "EARTH_SPELL_DMG_PREMY", + "type" : "SPELL_DAMAGE", + "subtype" : 3, "val" : 50, "valueType" : "BASE_NUMBER" } @@ -1208,7 +1210,8 @@ { "bonuses" : [ { - "type" : "FIRE_SPELL_DMG_PREMY", + "type" : "SPELL_DAMAGE", + "subtype" : 1, "val" : 50, "valueType" : "BASE_NUMBER" } @@ -1220,7 +1223,8 @@ { "bonuses" : [ { - "type" : "WATER_SPELL_DMG_PREMY", + "type" : "SPELL_DAMAGE", + "subtype" : 2, "val" : 50, "valueType" : "BASE_NUMBER" } @@ -1271,7 +1275,8 @@ { "bonuses" : [ { - "type" : "FIRE_SPELLS", + "type" : "SPELLS_OF_SCHOOL", + "subtype" : 1, "val" : 0, "valueType" : "BASE_NUMBER" } @@ -1283,7 +1288,8 @@ { "bonuses" : [ { - "type" : "AIR_SPELLS", + "type" : "SPELLS_OF_SCHOOL", + "subtype" : 0, "val" : 0, "valueType" : "BASE_NUMBER" } @@ -1295,7 +1301,8 @@ { "bonuses" : [ { - "type" : "WATER_SPELLS", + "type" : "SPELLS_OF_SCHOOL", + "subtype" : 2, "val" : 0, "valueType" : "BASE_NUMBER" } @@ -1307,7 +1314,8 @@ { "bonuses" : [ { - "type" : "EARTH_SPELLS", + "type" : "SPELLS_OF_SCHOOL", + "subtype" : 3, "val" : 0, "valueType" : "BASE_NUMBER" } diff --git a/lib/bonuses/Bonus.cpp b/lib/bonuses/Bonus.cpp index da6f08362..8bdd67cc3 100644 --- a/lib/bonuses/Bonus.cpp +++ b/lib/bonuses/Bonus.cpp @@ -31,26 +31,6 @@ VCMI_LIB_NAMESPACE_BEGIN -const std::set deprecatedBonusSet = { - "SECONDARY_SKILL_PREMY", - "SECONDARY_SKILL_VAL2", - "MAXED_SPELL", - "LAND_MOVEMENT", - "SEA_MOVEMENT", - "SIGHT_RADIOUS", - "NO_TYPE", - "SPECIAL_SECONDARY_SKILL", - "FULL_HP_REGENERATION", - "KING1", - "KING2", - "KING3", - "BLOCK_MORALE", - "BLOCK_LUCK", - "SELF_MORALE", - "SELF_LUCK", - "DIRECT_DAMAGE_IMMUNITY" -}; - //This constructor should be placed here to avoid side effects CAddInfo::CAddInfo() = default; diff --git a/lib/bonuses/Bonus.h b/lib/bonuses/Bonus.h index 58837c910..8644f1e54 100644 --- a/lib/bonuses/Bonus.h +++ b/lib/bonuses/Bonus.h @@ -187,6 +187,4 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus); -extern DLL_LINKAGE const std::set deprecatedBonusSet; - VCMI_LIB_NAMESPACE_END diff --git a/lib/bonuses/BonusEnum.h b/lib/bonuses/BonusEnum.h index 8ab5d9f72..fb144b867 100644 --- a/lib/bonuses/BonusEnum.h +++ b/lib/bonuses/BonusEnum.h @@ -10,10 +10,10 @@ #pragma once -VCMI_LIB_NAMESPACE_BEGIN - #include "../JsonNode.h" +VCMI_LIB_NAMESPACE_BEGIN + #define BONUS_LIST \ BONUS_NAME(NONE) \ BONUS_NAME(LEVEL_COUNTER) /* for commander artifacts*/ \ @@ -22,29 +22,22 @@ VCMI_LIB_NAMESPACE_BEGIN BONUS_NAME(LUCK) \ BONUS_NAME(PRIMARY_SKILL) /*uses subtype to pick skill; additional info if set: 1 - only melee, 2 - only distance*/ \ BONUS_NAME(SIGHT_RADIUS) \ - BONUS_NAME(MANA_REGENERATION) /*points per turn apart from normal (1 + mysticism)*/ \ + BONUS_NAME(MANA_REGENERATION) /*points per turn*/ \ BONUS_NAME(FULL_MANA_REGENERATION) /*all mana points are replenished every day*/ \ BONUS_NAME(NONEVIL_ALIGNMENT_MIX) /*good and neutral creatures can be mixed without morale penalty*/ \ BONUS_NAME(SURRENDER_DISCOUNT) /*%*/ \ BONUS_NAME(STACKS_SPEED) /*additional info - percent of speed bonus applied after direct bonuses; >0 - added, <0 - subtracted to this part*/ \ BONUS_NAME(FLYING_MOVEMENT) /*value - penalty percentage*/ \ BONUS_NAME(SPELL_DURATION) \ - BONUS_NAME(AIR_SPELL_DMG_PREMY) \ - BONUS_NAME(EARTH_SPELL_DMG_PREMY) \ - BONUS_NAME(FIRE_SPELL_DMG_PREMY) \ - BONUS_NAME(WATER_SPELL_DMG_PREMY) \ BONUS_NAME(WATER_WALKING) /*value - penalty percentage*/ \ BONUS_NAME(NEGATE_ALL_NATURAL_IMMUNITIES) \ BONUS_NAME(STACK_HEALTH) \ - BONUS_NAME(FIRE_SPELLS) \ - BONUS_NAME(AIR_SPELLS) \ - BONUS_NAME(WATER_SPELLS) \ - BONUS_NAME(EARTH_SPELLS) \ BONUS_NAME(GENERATE_RESOURCE) /*daily value, uses subtype (resource type)*/ \ BONUS_NAME(CREATURE_GROWTH) /*for legion artifacts: value - week growth bonus, subtype - monster level if aplicable*/ \ BONUS_NAME(WHIRLPOOL_PROTECTION) /*hero won't lose army when teleporting through whirlpool*/ \ BONUS_NAME(SPELL) /*hero knows spell, val - skill level (0 - 3), subtype - spell id*/ \ BONUS_NAME(SPELLS_OF_LEVEL) /*hero knows all spells of given level, val - skill level; subtype - level*/ \ + BONUS_NAME(SPELLS_OF_SCHOOL) /*hero knows all spells of given school, subtype - spell school; 0 - air, 1 - fire, 2 - water, 3 - earth*/ \ BONUS_NAME(BATTLE_NO_FLEEING) /*for shackles of war*/ \ BONUS_NAME(MAGIC_SCHOOL_SKILL) /* //eg. for magic plains terrain, subtype: school of magic (0 - all, 1 - fire, 2 - air, 4 - water, 8 - earth), value - level*/ \ BONUS_NAME(FREE_SHOOTING) /*stacks can shoot even if otherwise blocked (sharpshooter's bow effect)*/ \ @@ -81,7 +74,7 @@ VCMI_LIB_NAMESPACE_BEGIN BONUS_NAME(SPELL_LIKE_ATTACK) /*subtype - spell, value - spell level; range is taken from spell, but damage from creature; eg. magog*/ \ BONUS_NAME(THREE_HEADED_ATTACK) /*eg. cerberus*/ \ BONUS_NAME(GENERAL_DAMAGE_PREMY) \ - BONUS_NAME(FIRE_IMMUNITY) /*subtype 0 - all, 1 - all except positive, 2 - only damage spells*/ \ + BONUS_NAME(FIRE_IMMUNITY) /*subtype 0 - all, 1 - all except positive*/ \ BONUS_NAME(WATER_IMMUNITY) \ BONUS_NAME(EARTH_IMMUNITY) \ BONUS_NAME(AIR_IMMUNITY) \ @@ -122,7 +115,7 @@ VCMI_LIB_NAMESPACE_BEGIN BONUS_NAME(NO_MORALE) /*eg. when fighting on cursed ground*/ \ BONUS_NAME(DARKNESS) /*val = radius */ \ BONUS_NAME(SPECIAL_SPELL_LEV) /*subtype = id, val = value per level in percent*/\ - BONUS_NAME(SPELL_DAMAGE) /*val = value, now works for sorcery*/\ + BONUS_NAME(SPELL_DAMAGE) /*val = value, now works for sorcery, subtype - spell school; -1 - all, 0 - air, 1 - fire, 2 - water, 3 - earth*/\ BONUS_NAME(SPECIFIC_SPELL_DAMAGE) /*subtype = id of spell, val = value*/\ BONUS_NAME(SPECIAL_PECULIAR_ENCHANT) /*blesses and curses with id = val dependent on unit's level, subtype = 0 or 1 for Coronius*/\ BONUS_NAME(SPECIAL_UPGRADE) /*subtype = base, additionalInfo = target */\ diff --git a/lib/bonuses/BonusParams.cpp b/lib/bonuses/BonusParams.cpp index c947dc1f1..f358bddbf 100644 --- a/lib/bonuses/BonusParams.cpp +++ b/lib/bonuses/BonusParams.cpp @@ -17,6 +17,34 @@ VCMI_LIB_NAMESPACE_BEGIN +const std::set deprecatedBonusSet = { + "SECONDARY_SKILL_PREMY", + "SECONDARY_SKILL_VAL2", + "MAXED_SPELL", + "LAND_MOVEMENT", + "SEA_MOVEMENT", + "SIGHT_RADIOUS", + "NO_TYPE", + "SPECIAL_SECONDARY_SKILL", + "FULL_HP_REGENERATION", + "KING1", + "KING2", + "KING3", + "BLOCK_MORALE", + "BLOCK_LUCK", + "SELF_MORALE", + "SELF_LUCK", + "DIRECT_DAMAGE_IMMUNITY", + "AIR_SPELL_DMG_PREMY", + "EARTH_SPELL_DMG_PREMY" + "FIRE_SPELL_DMG_PREMY" + "WATER_SPELL_DMG_PREMY", + "FIRE_SPELLS", + "AIR_SPELLS", + "WATER_SPELLS", + "EARTH_SPELLS" +}; + BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSubtypeStr, int deprecatedSubtype): isConverted(true) { @@ -222,6 +250,54 @@ BonusParams::BonusParams(std::string deprecatedTypeStr, std::string deprecatedSu val = 100; valRelevant = true; } + else if (deprecatedTypeStr == "AIR_SPELL_DMG_PREMY") + { + type = BonusType::SPELL_DAMAGE; + subtypeRelevant = true; + subtype = 0; + } + else if (deprecatedTypeStr == "FIRE_SPELL_DMG_PREMY") + { + type = BonusType::SPELL_DAMAGE; + subtypeRelevant = true; + subtype = 1; + } + else if (deprecatedTypeStr == "WATER_SPELL_DMG_PREMY") + { + type = BonusType::SPELL_DAMAGE; + subtypeRelevant = true; + subtype = 2; + } + else if (deprecatedTypeStr == "EARTH_SPELL_DMG_PREMY") + { + type = BonusType::SPELL_DAMAGE; + subtypeRelevant = true; + subtype = 3; + } + else if (deprecatedTypeStr == "AIR_SPELLS") + { + type = BonusType::SPELLS_OF_SCHOOL; + subtypeRelevant = true; + subtype = 0; + } + else if (deprecatedTypeStr == "FIRE_SPELLS") + { + type = BonusType::SPELLS_OF_SCHOOL; + subtypeRelevant = true; + subtype = 1; + } + else if (deprecatedTypeStr == "WATER_SPELLS") + { + type = BonusType::SPELLS_OF_SCHOOL; + subtypeRelevant = true; + subtype = 2; + } + else if (deprecatedTypeStr == "EARTH_SPELLS") + { + type = BonusType::SPELLS_OF_SCHOOL; + subtypeRelevant = true; + subtype = 3; + } else isConverted = false; } diff --git a/lib/bonuses/BonusParams.h b/lib/bonuses/BonusParams.h index baf86eb1e..ef58d605e 100644 --- a/lib/bonuses/BonusParams.h +++ b/lib/bonuses/BonusParams.h @@ -38,4 +38,6 @@ private: bool jsonCreated = false; }; +extern DLL_LINKAGE const std::set deprecatedBonusSet; + VCMI_LIB_NAMESPACE_END \ No newline at end of file diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index a484aa242..423f5bcc0 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -619,7 +619,7 @@ int64_t CGHeroInstance::getSpellBonus(const spells::Spell * spell, int64_t base, spell->forEachSchool([&maxSchoolBonus, this](const spells::SchoolInfo & cnf, bool & stop) { - vstd::amax(maxSchoolBonus, valOfBonuses(cnf.damagePremyBonus)); + vstd::amax(maxSchoolBonus, valOfBonuses(BonusType::SPELL_DAMAGE, vstd::to_underlying(cnf.id))); }); base = static_cast(base * (100 + maxSchoolBonus) / 100.0); @@ -708,7 +708,7 @@ bool CGHeroInstance::canCastThisSpell(const spells::Spell * spell) const spell->forEachSchool([this, &schoolBonus](const spells::SchoolInfo & cnf, bool & stop) { - if(hasBonusOfType(cnf.knoledgeBonus)) + if(hasBonusOfType(BonusType::SPELLS_OF_SCHOOL, vstd::to_underlying(cnf.id))) { schoolBonus = stop = true; } diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index 14ee15429..15ec74200 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -42,35 +42,23 @@ static const spells::SchoolInfo SCHOOL[4] = { { ESpellSchool::AIR, - BonusType::AIR_SPELL_DMG_PREMY, BonusType::AIR_IMMUNITY, - "air", - SecondarySkill::AIR_MAGIC, - BonusType::AIR_SPELLS + "air" }, { ESpellSchool::FIRE, - BonusType::FIRE_SPELL_DMG_PREMY, BonusType::FIRE_IMMUNITY, - "fire", - SecondarySkill::FIRE_MAGIC, - BonusType::FIRE_SPELLS + "fire" }, { ESpellSchool::WATER, - BonusType::WATER_SPELL_DMG_PREMY, BonusType::WATER_IMMUNITY, - "water", - SecondarySkill::WATER_MAGIC, - BonusType::WATER_SPELLS + "water" }, { ESpellSchool::EARTH, - BonusType::EARTH_SPELL_DMG_PREMY, BonusType::EARTH_IMMUNITY, - "earth", - SecondarySkill::EARTH_MAGIC, - BonusType::EARTH_SPELLS + "earth" } }; diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index e7e6c118a..3653950ab 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -44,11 +44,8 @@ class IBattleCast; struct SchoolInfo { ESpellSchool id; //backlink - BonusType damagePremyBonus; BonusType immunityBonus; std::string jsonName; - SecondarySkill::ESecondarySkill skill; - BonusType knoledgeBonus; }; }