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
This commit is contained in:
RidingKeys 2018-06-01 03:07:28 -05:00 committed by H0zen
parent 5aa68fa21d
commit 77d285010d
2 changed files with 26 additions and 25 deletions

View File

@ -1767,7 +1767,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, 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 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) && 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)) GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this))
{ {
// -probability is between 0% and 40% // -probability is between 0% and 40%
@ -1776,7 +1776,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// there is a newbie protection, at level 10 just 7% base chance; assuming linear function // there is a newbie protection, at level 10 just 7% base chance; assuming linear function
if (pVictim->getLevel() < 30) if (pVictim->getLevel() < 30)
{ Probability = 0.65f * pVictim->getLevel() + 0.5f; } {
Probability = 0.65f * pVictim->getLevel() + 0.5f;
}
uint32 VictimDefense = pVictim->GetDefenseSkillValue(); uint32 VictimDefense = pVictim->GetDefenseSkillValue();
uint32 AttackerMeleeSkill = GetUnitMeleeSkill(); uint32 AttackerMeleeSkill = GetUnitMeleeSkill();
@ -1784,10 +1786,15 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
Probability *= AttackerMeleeSkill / (float)VictimDefense; Probability *= AttackerMeleeSkill / (float)VictimDefense;
if (Probability > 40.0f) if (Probability > 40.0f)
{ Probability = 40.0f; } {
Probability = 40.0f;
}
if (roll_chance_f(Probability)) if (roll_chance_f(Probability))
{ CastSpell(pVictim, 1604, true); } {
CastSpell(pVictim, 1604, true);
}
} }
// update at damage Judgement aura duration that applied by attacker at victim // update at damage Judgement aura duration that applied by attacker at victim

View File

@ -1575,6 +1575,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
Cell::VisitAllObjects(m_caster, searcher, max_range); Cell::VisitAllObjects(m_caster, searcher, max_range);
break; 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: case TARGET_RANDOM_FRIEND_CHAIN_IN_AREA:
{ {
MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(m_caster, max_range); 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); Cell::VisitAllObjects(m_caster, searcher, max_range);
break; break;
} }
case TARGET_RANDOM_UNIT_CHAIN_IN_AREA:
{
MaNGOS::AnyUnitInObjectRangeCheck u_check(m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(tempTargetUnitMap, u_check);
Cell::VisitAllObjects(m_caster, searcher, max_range);
break;
}
} }
if (tempTargetUnitMap.empty()) if (tempTargetUnitMap.empty())
@ -4980,7 +4974,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{ return SPELL_FAILED_ALREADY_OPEN; } { return SPELL_FAILED_ALREADY_OPEN; }
// Is the lock within the spell max range? // 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; } { return SPELL_FAILED_OUT_OF_RANGE; }
} }
else if (Item* item = m_targets.getItemTarget()) else if (Item* item = m_targets.getItemTarget())