From 77d285010dedc89615b5bfd58f6f651fec92d2af Mon Sep 17 00:00:00 2001 From: RidingKeys Date: Fri, 1 Jun 2018 03:07:28 -0500 Subject: [PATCH] Fixes daze absorb and duplicate target flags (#67) - Fixes daze absorb and duplicate target flags - Fix chests showing out of range even when in range --- src/game/Object/Unit.cpp | 51 ++++++++++++++++++-------------- src/game/WorldHandlers/Spell.cpp | 10 ++----- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 0e85d81358556..528e104d25a63 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -1767,28 +1767,35 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, durabilityLoss); // If this is a creature and it attacks from behind it has a probability to daze it's victim - if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this)) - { - // -probability is between 0% and 40% - // 20% base chance - float Probability = 20.0f; - - // there is a newbie protection, at level 10 just 7% base chance; assuming linear function - if (pVictim->getLevel() < 30) - { Probability = 0.65f * pVictim->getLevel() + 0.5f; } - - uint32 VictimDefense = pVictim->GetDefenseSkillValue(); - uint32 AttackerMeleeSkill = GetUnitMeleeSkill(); - - Probability *= AttackerMeleeSkill / (float)VictimDefense; - - if (Probability > 40.0f) - { Probability = 40.0f; } - - if (roll_chance_f(Probability)) - { CastSpell(pVictim, 1604, true); } - } + if ((!damageInfo->absorb) && (damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && + GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this)) + { + // -probability is between 0% and 40% + // 20% base chance + float Probability = 20.0f; + + // there is a newbie protection, at level 10 just 7% base chance; assuming linear function + if (pVictim->getLevel() < 30) + { + Probability = 0.65f * pVictim->getLevel() + 0.5f; + } + + uint32 VictimDefense = pVictim->GetDefenseSkillValue(); + uint32 AttackerMeleeSkill = GetUnitMeleeSkill(); + + Probability *= AttackerMeleeSkill / (float)VictimDefense; + + if (Probability > 40.0f) + { + Probability = 40.0f; + } + + if (roll_chance_f(Probability)) + { + CastSpell(pVictim, 1604, true); + } + + } // update at damage Judgement aura duration that applied by attacker at victim if (damageInfo->damage) diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index f39f8116c3629..a61335d1228f7 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -1575,6 +1575,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& Cell::VisitAllObjects(m_caster, searcher, max_range); break; } + case TARGET_RANDOM_UNIT_CHAIN_IN_AREA: // This works the same as Target_random_friend_chain_in_area but is named differently for some reason case TARGET_RANDOM_FRIEND_CHAIN_IN_AREA: { MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(m_caster, max_range); @@ -1582,13 +1583,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& Cell::VisitAllObjects(m_caster, searcher, max_range); break; } - case TARGET_RANDOM_UNIT_CHAIN_IN_AREA: - { - MaNGOS::AnyUnitInObjectRangeCheck u_check(m_caster, max_range); - MaNGOS::UnitListSearcher searcher(tempTargetUnitMap, u_check); - Cell::VisitAllObjects(m_caster, searcher, max_range); - break; - } } if (tempTargetUnitMap.empty()) @@ -4980,7 +4974,7 @@ SpellCastResult Spell::CheckCast(bool strict) { return SPELL_FAILED_ALREADY_OPEN; } // Is the lock within the spell max range? - if (!IsLockInRange(go)) + if (!IsLockInRange(go) && go->GetGoType() == GAMEOBJECT_TYPE_TRAP) { return SPELL_FAILED_OUT_OF_RANGE; } } else if (Item* item = m_targets.getItemTarget())