1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

vcmi: 100% damage reduction is damage immunity

This commit is contained in:
Konstantin P 2023-05-03 16:35:32 +03:00
parent 0cbc2e458c
commit 5841c716fd
2 changed files with 23 additions and 16 deletions

View File

@ -1178,8 +1178,9 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.subtype = 1; //not positive b.subtype = 1; //not positive
break; break;
case 'O': case 'O':
b.type = BonusType::FIRE_IMMUNITY; b.type = BonusType::SPELL_DAMAGE_REDUCTION;
b.subtype = 2; //only direct damage b.subtype = 1; //Fire school
b.val = 100; //Full damage immunity
break; break;
case 'f': case 'f':
b.type = BonusType::FIRE_IMMUNITY; b.type = BonusType::FIRE_IMMUNITY;
@ -1190,31 +1191,36 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
b.subtype = 1; //not positive b.subtype = 1; //not positive
break; break;
case 'W': case 'W':
b.type = BonusType::WATER_IMMUNITY; b.type = BonusType::SPELL_DAMAGE_REDUCTION;
b.subtype = 2; //only direct damage b.subtype = 2; //Water school
b.val = 100; //Full damage immunity
break; break;
case 'w': case 'w':
b.type = BonusType::WATER_IMMUNITY; b.type = BonusType::WATER_IMMUNITY;
b.subtype = 0; //all b.subtype = 0; //all
break; break;
case 'E': case 'E':
b.type = BonusType::EARTH_IMMUNITY; b.type = BonusType::SPELL_DAMAGE_REDUCTION;
b.subtype = 2; //only direct damage b.subtype = 3; //Earth school
b.val = 100; //Full damage immunity
break; break;
case 'e': case 'e':
b.type = BonusType::EARTH_IMMUNITY; b.type = BonusType::EARTH_IMMUNITY;
b.subtype = 0; //all b.subtype = 0; //all
break; break;
case 'A': case 'A':
b.type = BonusType::AIR_IMMUNITY; b.type = BonusType::SPELL_DAMAGE_REDUCTION;
b.subtype = 2; //only direct damage b.subtype = 0; //Air school
b.val = 100; //Full damage immunity
break; break;
case 'a': case 'a':
b.type = BonusType::AIR_IMMUNITY; b.type = BonusType::AIR_IMMUNITY;
b.subtype = 0; //all b.subtype = 0; //all
break; break;
case 'D': case 'D':
b.type = BonusType::DIRECT_DAMAGE_IMMUNITY; b.type = BonusType::SPELL_DAMAGE_REDUCTION;
b.subtype = -1; //all
b.val = 100; //Full damage immunity
break; break;
case '0': case '0':
b.type = BonusType::RECEPTIVE; b.type = BonusType::RECEPTIVE;

View File

@ -11,6 +11,7 @@
#include "Damage.h" #include "Damage.h"
#include "Registry.h" #include "Registry.h"
#include "../CSpellHandler.h"
#include "../ISpellMechanics.h" #include "../ISpellMechanics.h"
#include "../../NetPacks.h" #include "../../NetPacks.h"
@ -20,6 +21,8 @@
#include "../../CGeneralTextHandler.h" #include "../../CGeneralTextHandler.h"
#include "../../serializer/JsonSerializeFormat.h" #include "../../serializer/JsonSerializeFormat.h"
#include <vcmi/spells/Spell.h>
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
namespace spells namespace spells
@ -82,16 +85,14 @@ bool Damage::isReceptive(const Mechanics * m, const battle::Unit * unit) const
if(!UnitEffect::isReceptive(m, unit)) if(!UnitEffect::isReceptive(m, unit))
return false; return false;
bool isImmune = m->getSpell()->isMagical() && (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, -1) >= 100); //General spell damage immunity
//elemental immunity for damage //elemental immunity for damage
auto filter = m->getElementalImmunity(); m->getSpell()->forEachSchool([&](const SchoolInfo & cnf, bool & stop)
for(auto element : filter)
{ {
if(!m->isPositiveSpell() && unit->hasBonusOfType(element, 2)) isImmune |= (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, static_cast<ui8>(cnf.id)) >= 100); //100% reduction is immunity
return false; });
}
return true; return !isImmune;
} }
void Damage::serializeJsonUnitEffect(JsonSerializeFormat & handler) void Damage::serializeJsonUnitEffect(JsonSerializeFormat & handler)