*Update miss chance calculation.
--HG-- branch : trunk
This commit is contained in:
+24
-11
@@ -2792,7 +2792,8 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackT
|
|||||||
// This is only wrapper
|
// This is only wrapper
|
||||||
|
|
||||||
// Miss chance based on melee
|
// Miss chance based on melee
|
||||||
float miss_chance = MeleeMissChanceCalc(pVictim, attType);
|
//float miss_chance = MeleeMissChanceCalc(pVictim, attType);
|
||||||
|
float miss_chance = MeleeSpellMissChance(pVictim, attType, int32(GetWeaponSkillValue(attType,pVictim)) - int32(pVictim->GetDefenseSkillValue(this)), 0);
|
||||||
|
|
||||||
// Critical hit chance
|
// Critical hit chance
|
||||||
float crit_chance = GetUnitCriticalChance(attType, pVictim);
|
float crit_chance = GetUnitCriticalChance(attType, pVictim);
|
||||||
@@ -3070,18 +3071,22 @@ bool Unit::isSpellBlocked(Unit *pVictim, SpellEntry const *spellProto, WeaponAtt
|
|||||||
|
|
||||||
// Melee based spells can be miss, parry or dodge on this step
|
// Melee based spells can be miss, parry or dodge on this step
|
||||||
// Crit or block - determined on damage calculation phase! (and can be both in some time)
|
// Crit or block - determined on damage calculation phase! (and can be both in some time)
|
||||||
float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell)
|
float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
|
||||||
{
|
{
|
||||||
// Calculate hit chance (more correct for chance mod)
|
// Calculate hit chance (more correct for chance mod)
|
||||||
int32 HitChance;
|
int32 HitChance;
|
||||||
|
|
||||||
// PvP - PvE melee chances
|
// PvP - PvE melee chances
|
||||||
int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
|
/*int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7;
|
||||||
int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
|
int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim);
|
||||||
if(leveldif < 3)
|
if(leveldif < 3)
|
||||||
HitChance = 95 - leveldif;
|
HitChance = 95 - leveldif;
|
||||||
else
|
else
|
||||||
HitChance = 93 - (leveldif - 2) * lchance;
|
HitChance = 93 - (leveldif - 2) * lchance;*/
|
||||||
|
if (spellId || attType == RANGED_ATTACK || !haveOffhandWeapon())
|
||||||
|
HitChance = 95.0f;
|
||||||
|
else
|
||||||
|
HitChance = 76.0f;
|
||||||
|
|
||||||
// Hit chance depends from victim auras
|
// Hit chance depends from victim auras
|
||||||
if(attType == RANGED_ATTACK)
|
if(attType == RANGED_ATTACK)
|
||||||
@@ -3090,8 +3095,11 @@ float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32
|
|||||||
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
|
HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE);
|
||||||
|
|
||||||
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
|
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
|
||||||
if(Player *modOwner = GetSpellModOwner())
|
if(spellId)
|
||||||
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
|
{
|
||||||
|
if(Player *modOwner = GetSpellModOwner())
|
||||||
|
modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, HitChance);
|
||||||
|
}
|
||||||
|
|
||||||
// Miss = 100 - hit
|
// Miss = 100 - hit
|
||||||
float miss_chance= 100.0f - HitChance;
|
float miss_chance= 100.0f - HitChance;
|
||||||
@@ -3103,7 +3111,12 @@ float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32
|
|||||||
miss_chance -= m_modMeleeHitChance;
|
miss_chance -= m_modMeleeHitChance;
|
||||||
|
|
||||||
// bonus from skills is 0.04%
|
// bonus from skills is 0.04%
|
||||||
miss_chance -= skillDiff * 0.04f;
|
//miss_chance -= skillDiff * 0.04f;
|
||||||
|
int32 diff = -skillDiff;
|
||||||
|
if(pVictim->GetTypeId()==TYPEID_PLAYER)
|
||||||
|
miss_chance += diff > 0 ? diff * 0.04 : diff * 0.02;
|
||||||
|
else
|
||||||
|
miss_chance += diff > 10 ? 2 + (diff - 10) * 0.4 : diff * 0.1;
|
||||||
|
|
||||||
// Limit miss chance from 0 to 60%
|
// Limit miss chance from 0 to 60%
|
||||||
if (miss_chance < 0.0f)
|
if (miss_chance < 0.0f)
|
||||||
@@ -3127,7 +3140,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell)
|
|||||||
int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this));
|
int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this));
|
||||||
|
|
||||||
uint32 roll = urand (0, 10000);
|
uint32 roll = urand (0, 10000);
|
||||||
uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f);
|
uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell->Id)*100.0f);
|
||||||
|
|
||||||
// Roll miss
|
// Roll miss
|
||||||
uint32 tmp = missChance;
|
uint32 tmp = missChance;
|
||||||
@@ -3325,7 +3338,7 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
|
|||||||
return SPELL_MISS_NONE;
|
return SPELL_MISS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const
|
/*float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const
|
||||||
{
|
{
|
||||||
if(!pVictim)
|
if(!pVictim)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
@@ -3400,7 +3413,7 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c
|
|||||||
return 60.0f;
|
return 60.0f;
|
||||||
|
|
||||||
return misschance;
|
return misschance;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
uint32 Unit::GetDefenseSkillValue(Unit const* target) const
|
uint32 Unit::GetDefenseSkillValue(Unit const* target) const
|
||||||
{
|
{
|
||||||
@@ -11780,7 +11793,7 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const
|
|||||||
return SPELL_SCHOOL_MASK_NORMAL;
|
return SPELL_SCHOOL_MASK_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Unit::GetSpellModOwner()
|
Player* Unit::GetSpellModOwner() const
|
||||||
{
|
{
|
||||||
if(GetTypeId()==TYPEID_PLAYER)
|
if(GetTypeId()==TYPEID_PLAYER)
|
||||||
return (Player*)this;
|
return (Player*)this;
|
||||||
|
|||||||
+3
-3
@@ -912,7 +912,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
void HandleEmoteCommand(uint32 anim_id);
|
void HandleEmoteCommand(uint32 anim_id);
|
||||||
void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false );
|
void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false );
|
||||||
|
|
||||||
float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const;
|
//float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const;
|
||||||
|
|
||||||
void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
|
void CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *damageInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||||
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
|
void DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss);
|
||||||
@@ -920,7 +920,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
|
void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||||
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
||||||
|
|
||||||
float MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell);
|
float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
|
||||||
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||||
SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||||
SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false);
|
SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false);
|
||||||
@@ -1048,7 +1048,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
}
|
}
|
||||||
bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
|
bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
|
||||||
|
|
||||||
Player* GetSpellModOwner();
|
Player* GetSpellModOwner() const;
|
||||||
|
|
||||||
Unit* GetOwner() const;
|
Unit* GetOwner() const;
|
||||||
Pet* GetPet() const;
|
Pet* GetPet() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user