mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
vcmi: 100% damage reduction is damage immunity
This commit is contained in:
parent
0cbc2e458c
commit
5841c716fd
@ -1178,8 +1178,9 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
b.subtype = 1; //not positive
|
||||
break;
|
||||
case 'O':
|
||||
b.type = BonusType::FIRE_IMMUNITY;
|
||||
b.subtype = 2; //only direct damage
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = 1; //Fire school
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'f':
|
||||
b.type = BonusType::FIRE_IMMUNITY;
|
||||
@ -1190,31 +1191,36 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
|
||||
b.subtype = 1; //not positive
|
||||
break;
|
||||
case 'W':
|
||||
b.type = BonusType::WATER_IMMUNITY;
|
||||
b.subtype = 2; //only direct damage
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = 2; //Water school
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'w':
|
||||
b.type = BonusType::WATER_IMMUNITY;
|
||||
b.subtype = 0; //all
|
||||
break;
|
||||
case 'E':
|
||||
b.type = BonusType::EARTH_IMMUNITY;
|
||||
b.subtype = 2; //only direct damage
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = 3; //Earth school
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'e':
|
||||
b.type = BonusType::EARTH_IMMUNITY;
|
||||
b.subtype = 0; //all
|
||||
break;
|
||||
case 'A':
|
||||
b.type = BonusType::AIR_IMMUNITY;
|
||||
b.subtype = 2; //only direct damage
|
||||
b.type = BonusType::SPELL_DAMAGE_REDUCTION;
|
||||
b.subtype = 0; //Air school
|
||||
b.val = 100; //Full damage immunity
|
||||
break;
|
||||
case 'a':
|
||||
b.type = BonusType::AIR_IMMUNITY;
|
||||
b.subtype = 0; //all
|
||||
break;
|
||||
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;
|
||||
case '0':
|
||||
b.type = BonusType::RECEPTIVE;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "Damage.h"
|
||||
#include "Registry.h"
|
||||
#include "../CSpellHandler.h"
|
||||
#include "../ISpellMechanics.h"
|
||||
|
||||
#include "../../NetPacks.h"
|
||||
@ -20,6 +21,8 @@
|
||||
#include "../../CGeneralTextHandler.h"
|
||||
#include "../../serializer/JsonSerializeFormat.h"
|
||||
|
||||
#include <vcmi/spells/Spell.h>
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
namespace spells
|
||||
@ -82,16 +85,14 @@ bool Damage::isReceptive(const Mechanics * m, const battle::Unit * unit) const
|
||||
if(!UnitEffect::isReceptive(m, unit))
|
||||
return false;
|
||||
|
||||
bool isImmune = m->getSpell()->isMagical() && (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, -1) >= 100); //General spell damage immunity
|
||||
//elemental immunity for damage
|
||||
auto filter = m->getElementalImmunity();
|
||||
|
||||
for(auto element : filter)
|
||||
m->getSpell()->forEachSchool([&](const SchoolInfo & cnf, bool & stop)
|
||||
{
|
||||
if(!m->isPositiveSpell() && unit->hasBonusOfType(element, 2))
|
||||
return false;
|
||||
}
|
||||
isImmune |= (unit->getBonusBearer()->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, static_cast<ui8>(cnf.id)) >= 100); //100% reduction is immunity
|
||||
});
|
||||
|
||||
return true;
|
||||
return !isImmune;
|
||||
}
|
||||
|
||||
void Damage::serializeJsonUnitEffect(JsonSerializeFormat & handler)
|
||||
|
Loading…
Reference in New Issue
Block a user