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

vcmi: replace school bonuses to unified ones

Except immunity now
This commit is contained in:
Konstantin P 2023-05-05 17:56:04 +03:00
parent 8764765dcf
commit 9e1cdc410f
9 changed files with 106 additions and 64 deletions

View File

@ -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"
}

View File

@ -31,26 +31,6 @@
VCMI_LIB_NAMESPACE_BEGIN
const std::set<std::string> 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;

View File

@ -187,6 +187,4 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>
DLL_LINKAGE std::ostream & operator<<(std::ostream &out, const Bonus &bonus);
extern DLL_LINKAGE const std::set<std::string> deprecatedBonusSet;
VCMI_LIB_NAMESPACE_END

View File

@ -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 */\

View File

@ -17,6 +17,34 @@
VCMI_LIB_NAMESPACE_BEGIN
const std::set<std::string> 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;
}

View File

@ -38,4 +38,6 @@ private:
bool jsonCreated = false;
};
extern DLL_LINKAGE const std::set<std::string> deprecatedBonusSet;
VCMI_LIB_NAMESPACE_END

View File

@ -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<int64_t>(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;
}

View File

@ -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"
}
};

View File

@ -44,11 +44,8 @@ class IBattleCast;
struct SchoolInfo
{
ESpellSchool id; //backlink
BonusType damagePremyBonus;
BonusType immunityBonus;
std::string jsonName;
SecondarySkill::ESecondarySkill skill;
BonusType knoledgeBonus;
};
}