diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 36910246d1..37742e5c67 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -561,3 +561,8 @@ bool StringToBool(std::string const& str) std::string lowerStr = boost::algorithm::to_lower_copy(str); return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes"; } + +float DegToRad(float degrees) +{ + return degrees * (2.f * float(M_PI) / 360.f); +} diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index 59db3c8eb7..17e934e34a 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -323,6 +323,7 @@ TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, b TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false); TC_COMMON_API bool StringToBool(std::string const& str); +TC_COMMON_API float DegToRad(float degrees); // simple class for not-modifyable list template diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index 37f51aae52..ccb4245c54 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -2193,10 +2193,11 @@ struct SpellShapeshiftEntry struct SpellTargetRestrictionsEntry { uint32 Id; // 0 m_ID - uint32 MaxAffectedTargets; // 1 m_maxTargets - uint32 MaxTargetLevel; // 2 m_maxTargetLevel - uint32 TargetCreatureType; // 3 m_targetCreatureType - uint32 Targets; // 4 m_targets + float ConeAngle; // 1 m_coneAngel + uint32 MaxAffectedTargets; // 2 m_maxTargets + uint32 MaxTargetLevel; // 3 m_maxTargetLevel + uint32 TargetCreatureType; // 4 m_targetCreatureType + uint32 Targets; // 5 m_targets }; // SpellReagents.dbc diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 0ecc414c8d..b82380b5d4 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -154,7 +154,7 @@ char const SpellRangefmt[] = "nffffixx"; char const SpellReagentsEntryfmt[] = "diiiiiiiiiiiiiiii"; char const SpellScalingEntryfmt[] = "diiiiffffffffffi"; char const SpellTotemsEntryfmt[] = "niiii"; -char const SpellTargetRestrictionsEntryfmt[] = "nxiiii"; +char const SpellTargetRestrictionsEntryfmt[] = "nfiiii"; char const SpellPowerEntryfmt[] = "diiiixxx"; char const SpellInterruptsEntryfmt[] = "dixixi"; char const SpellEquippedItemsEntryfmt[] = "diii"; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cb986cab13..87ea61cf63 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1267,7 +1267,7 @@ void Player::Update(uint32 p_time) } } //120 degrees of radiant range - else if (!HasInArc(2 * float(M_PI) / 3, victim)) + 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) @@ -1295,8 +1295,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 diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e2de3b0ac3..f5c29b7470 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -574,6 +574,16 @@ float Unit::GetMeleeRange(Unit const* target) const return std::max(range, NOMINAL_MELEE_RANGE); } +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(); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 3a12518067..ff2743c689 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1335,8 +1335,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; float GetMeleeRange(Unit const* target) const; void GetRandomContactPoint(const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const; uint32 m_extraAttacks; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 811ad705a6..98a093a4e5 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1145,7 +1145,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge if (uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList)) { - Trinity::WorldObjectSpellConeTargetCheck check(coneAngle, radius, m_caster, m_spellInfo, selectionType, condList); + Trinity::WorldObjectSpellConeTargetCheck check(DegToRad(m_spellInfo->ConeAngle), radius, m_caster, m_spellInfo, selectionType, condList); Trinity::WorldObjectListSearcher searcher(m_caster, targets, check, containerTypeMask); SearchTargets >(searcher, containerTypeMask, m_caster, m_caster, radius); @@ -6145,7 +6145,8 @@ SpellCastResult Spell::CheckRange(bool strict) const return SPELL_FAILED_OUT_OF_RANGE; if (m_caster->GetTypeId() == TYPEID_PLAYER && - (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast(M_PI), target)) + (((m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc(static_cast(M_PI), target)) + && !m_caster->IsWithinBoundaryRadius(target))) return SPELL_FAILED_UNIT_NOT_INFRONT; } @@ -7873,8 +7874,11 @@ bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target) } else { - if (!_caster->isInFront(target, _coneAngle)) - return false; + if (!_caster->IsWithinBoundaryRadius(target->ToUnit())) + // ConeAngle > 0 -> select targets in front + // ConeAngle < 0 -> select targets in back + if (_caster->HasInArc(_coneAngle, target) != G3D::fuzzyGe(_coneAngle, 0.f)) + return false; } return WorldObjectSpellAreaTargetCheck::operator ()(target); } diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 10c032f2ab..02a9f76944 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1012,6 +1012,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effe // SpellTargetRestrictionsEntry SpellTargetRestrictionsEntry const* _target = GetSpellTargetRestrictions(); + ConeAngle = _target ? _target->ConeAngle : 0.f; Targets = _target ? _target->Targets : 0; TargetCreatureType = _target ? _target->TargetCreatureType : 0; MaxAffectedTargets = _target ? _target->MaxAffectedTargets : 0; diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 0af75d3643..67524782fd 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -392,6 +392,7 @@ class TC_GAME_API SpellInfo uint32 ActiveIconID; char* SpellName; char* Rank; + float ConeAngle; uint32 MaxTargetLevel; uint32 MaxAffectedTargets; uint32 SpellFamilyName; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 2397fff43a..b8588bb5d0 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -28,6 +28,7 @@ #include "BattlefieldWG.h" #include "BattlefieldMgr.h" #include "Player.h" +#include bool IsPrimaryProfessionSkill(uint32 skill) { @@ -2769,9 +2770,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes() if (!spellInfo->_IsPositiveEffect(EFFECT_2, false)) spellInfo->AttributesCu |= SPELL_ATTR0_CU_NEGATIVE_EFF2; - if (spellInfo->SpellVisual[0] == 3879) - spellInfo->AttributesCu |= SPELL_ATTR0_CU_CONE_BACK; - spellInfo->_InitializeExplicitTargetMask(); } @@ -3671,6 +3669,13 @@ void SpellMgr::LoadSpellInfoCorrections() break; } + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; i++) + { + if (spellInfo->Effects[i].TargetA.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE || spellInfo->Effects[i].TargetB.GetSelectionCategory() == TARGET_SELECT_CATEGORY_CONE) + if (G3D::fuzzyEq(spellInfo->ConeAngle, 0.f)) + spellInfo->ConeAngle = 90.f; + } + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_PALADIN: