mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 23:51:28 +00:00
Refactor getting resist value out to a function
This commit is contained in:
parent
8af4730ddf
commit
0356c0a891
@ -281,6 +281,7 @@ public:
|
|||||||
float ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use_resist_override = false,
|
float ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use_resist_override = false,
|
||||||
int resist_override = 0, bool CharismaCheck = false, bool CharmTick = false, bool IsRoot = false,
|
int resist_override = 0, bool CharismaCheck = false, bool CharmTick = false, bool IsRoot = false,
|
||||||
int level_override = -1);
|
int level_override = -1);
|
||||||
|
int GetResist(uint8 resist_type);
|
||||||
int ResistPhysical(int level_diff, uint8 caster_level);
|
int ResistPhysical(int level_diff, uint8 caster_level);
|
||||||
int ResistElementalWeaponDmg(const EQEmu::ItemInstance *item);
|
int ResistElementalWeaponDmg(const EQEmu::ItemInstance *item);
|
||||||
int CheckBaneDamage(const EQEmu::ItemInstance *item);
|
int CheckBaneDamage(const EQEmu::ItemInstance *item);
|
||||||
|
|||||||
@ -4437,6 +4437,36 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Mob::GetResist(uint8 resist_type)
|
||||||
|
{
|
||||||
|
switch(resist_type)
|
||||||
|
{
|
||||||
|
case RESIST_FIRE:
|
||||||
|
return GetFR();
|
||||||
|
case RESIST_COLD:
|
||||||
|
return GetCR();
|
||||||
|
case RESIST_MAGIC:
|
||||||
|
return GetMR();
|
||||||
|
case RESIST_DISEASE:
|
||||||
|
return GetDR();
|
||||||
|
case RESIST_POISON:
|
||||||
|
return GetPR();
|
||||||
|
case RESIST_CORRUPTION:
|
||||||
|
return GetCorrup();
|
||||||
|
case RESIST_PRISMATIC:
|
||||||
|
return (GetFR() + GetCR() + GetMR() + GetDR() + GetPR()) / 5;
|
||||||
|
case RESIST_CHROMATIC:
|
||||||
|
return std::min({GetFR(), GetCR(), GetMR(), GetDR(), GetPR()});
|
||||||
|
case RESIST_PHYSICAL:
|
||||||
|
if (IsNPC())
|
||||||
|
return GetPhR();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Spell resists:
|
// Spell resists:
|
||||||
// returns an effectiveness index from 0 to 100. for most spells, 100 means
|
// returns an effectiveness index from 0 to 100. for most spells, 100 means
|
||||||
@ -4520,69 +4550,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int target_resist;
|
int target_resist = GetResist(resist_type);
|
||||||
switch(resist_type)
|
|
||||||
{
|
|
||||||
case RESIST_FIRE:
|
|
||||||
target_resist = GetFR();
|
|
||||||
break;
|
|
||||||
case RESIST_COLD:
|
|
||||||
target_resist = GetCR();
|
|
||||||
break;
|
|
||||||
case RESIST_MAGIC:
|
|
||||||
target_resist = GetMR();
|
|
||||||
break;
|
|
||||||
case RESIST_DISEASE:
|
|
||||||
target_resist = GetDR();
|
|
||||||
break;
|
|
||||||
case RESIST_POISON:
|
|
||||||
target_resist = GetPR();
|
|
||||||
break;
|
|
||||||
case RESIST_CORRUPTION:
|
|
||||||
target_resist = GetCorrup();
|
|
||||||
break;
|
|
||||||
case RESIST_PRISMATIC:
|
|
||||||
target_resist = (GetFR() + GetCR() + GetMR() + GetDR() + GetPR()) / 5;
|
|
||||||
break;
|
|
||||||
case RESIST_CHROMATIC:
|
|
||||||
{
|
|
||||||
target_resist = GetFR();
|
|
||||||
int temp = GetCR();
|
|
||||||
if(temp < target_resist)
|
|
||||||
{
|
|
||||||
target_resist = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = GetMR();
|
|
||||||
if(temp < target_resist)
|
|
||||||
{
|
|
||||||
target_resist = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = GetDR();
|
|
||||||
if(temp < target_resist)
|
|
||||||
{
|
|
||||||
target_resist = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = GetPR();
|
|
||||||
if(temp < target_resist)
|
|
||||||
{
|
|
||||||
target_resist = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RESIST_PHYSICAL:
|
|
||||||
{
|
|
||||||
if (IsNPC())
|
|
||||||
target_resist = GetPhR();
|
|
||||||
else
|
|
||||||
target_resist = 0;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
|
|
||||||
target_resist = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Setup our base resist chance.
|
//Setup our base resist chance.
|
||||||
int resist_chance = 0;
|
int resist_chance = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user