Skip to content

Commit

Permalink
Game/Entities: Players can attack targets when they are not facing th…
Browse files Browse the repository at this point in the history
…em as long as they are in boundaryradius, this also applies for cone effect spells

Signed-off-by: Shauren <shauren.trinity@gmail.com>
  • Loading branch information
P-Kito authored and Shauren committed Jul 16, 2016
1 parent 64f0691 commit 86275a3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -1107,8 +1107,8 @@ void Player::Update(uint32 p_time)
m_swingErrorMsg = 1;
}
}
//120 degrees of radiant range
else if (!HasInArc(2 * float(M_PI) / 3, victim))
//120 degrees of radiant range, if player is not in boundary radius
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
{
setAttackTimer(BASE_ATTACK, 100);
if (m_swingErrorMsg != 2) // send single time (client auto repeat)
Expand Down Expand Up @@ -1136,8 +1136,10 @@ void Player::Update(uint32 p_time)
{
if (!IsWithinMeleeRange(victim))
setAttackTimer(OFF_ATTACK, 100);
else if (!HasInArc(2 * float(M_PI) / 3, victim))
setAttackTimer(OFF_ATTACK, 100);
else if (!IsWithinBoundaryRadius(victim) && !HasInArc(2 * float(M_PI) / 3, victim))
{
setAttackTimer(BASE_ATTACK, 100);
}
else
{
// prevent base and off attack in same time, delay attack at 0.2 sec
Expand Down
10 changes: 10 additions & 0 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -514,6 +514,16 @@ bool Unit::IsWithinMeleeRange(Unit const* obj) const
return distsq <= maxdist * maxdist;
}

bool Unit::IsWithinBoundaryRadius(const Unit* obj) const
{
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
return false;

float objBoundaryRadius = std::max(obj->GetBoundaryRadius(), MIN_MELEE_REACH);

return IsInDist(obj, objBoundaryRadius);
}

void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const
{
float combat_reach = GetCombatReach();
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/Entities/Unit/Unit.h
Expand Up @@ -1365,8 +1365,10 @@ class TC_GAME_API Unit : public WorldObject
bool CanDualWield() const { return m_canDualWield; }
virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
float GetCombatReach() const { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
float GetBoundaryRadius() const { return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; }
bool IsWithinCombatRange(const Unit* obj, float dist2compare) const;
bool IsWithinMeleeRange(Unit const* obj) const;
bool IsWithinBoundaryRadius(const Unit* obj) const;
void GetRandomContactPoint(const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const;
uint32 m_extraAttacks;
bool m_canDualWield;
Expand Down
8 changes: 5 additions & 3 deletions src/server/game/Spells/Spell.cpp
Expand Up @@ -5995,7 +5995,8 @@ SpellCastResult Spell::CheckRange(bool strict)
return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_OUT_OF_RANGE : SPELL_FAILED_DONT_REPORT;

if (m_caster->GetTypeId() == TYPEID_PLAYER &&
(m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target))
(((m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast<float>(M_PI), target))
&& !m_caster->IsWithinBoundaryRadius(target)))
return !(_triggeredCastFlags & TRIGGERED_DONT_REPORT_CAST_ERROR) ? SPELL_FAILED_UNIT_NOT_INFRONT : SPELL_FAILED_DONT_REPORT;
}

Expand Down Expand Up @@ -7650,8 +7651,9 @@ bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target)
}
else
{
if (!_caster->isInFront(target, _coneAngle))
return false;
if (!_caster->IsWithinBoundaryRadius(target->ToUnit()))
if (!_caster->isInFront(target, _coneAngle))
return false;
}
return WorldObjectSpellAreaTargetCheck::operator ()(target);
}
Expand Down

5 comments on commit 86275a3

@bachda90
Copy link

@bachda90 bachda90 commented on 86275a3 Jul 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is 100% False for 6.x and single target melee spells (not sure about range spells), very easy to see on Archimond in HFC as a melee DPS if your standing inside him you still have to face his center. the only time you can hit him no matter of orientation is standing directly in the center of him. but his BoundaryRadius still requires you to face his center point.

But for cone spells like Shockwave this is true as long as you stand inside a NPC youll hit it no matter of your orientation

@Shauren
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, I tested it on retail myself. Also you seem to be mistaking something - UNIT_FIELD_BOUNDINGRADIUS is NOT the size of target selection circle, it is much smaller and matches the range where any facing was allowed.

@bachda90
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it must be fucking tiny for Archimonde^^, that was so annoying on Mythic progress when you have to dodge those beams and standing in the middle of the fucking boss and still having to face twards his center

@Shauren
Copy link
Member

@Shauren Shauren commented on 86275a3 Jul 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is tiny! These are sniffed values for Archimonde:

[8] UNIT_FIELD_BOUNDINGRADIUS: 1067030938/1.2
[8] UNIT_FIELD_COMBATREACH: 1094713344/12

COMBATREACH is the more or less the autoattack range with normal facing
1.2 vs 12

@Ovahlord
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same goes for the elementium monstrosity. big hitbox, small combat reach

Please sign in to comment.