diff --git a/src/game/Entities/Object/Object.cpp b/src/game/Entities/Object/Object.cpp index 10773c872..6f36d9943 100644 --- a/src/game/Entities/Object/Object.cpp +++ b/src/game/Entities/Object/Object.cpp @@ -1128,7 +1128,7 @@ Position WorldObject::GetHitSpherePointFor(Position const& dest) const { G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ()); G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); - G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * std::min(dest.GetExactDist(GetPosition()), GetObjectSize()); + G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * GetObjectSize(); return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y)); } diff --git a/src/game/Entities/Object/Object.h b/src/game/Entities/Object/Object.h index 78234cb40..68b8bda28 100644 --- a/src/game/Entities/Object/Object.h +++ b/src/game/Entities/Object/Object.h @@ -365,6 +365,17 @@ class Object struct Position { + Position(float x = 0, float y = 0, float z = 0, float o = 0) + : m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientation(o)) { } + + Position(Position const& loc) { Relocate(loc); } + + struct PositionXYStreamer + { + explicit PositionXYStreamer(Position& pos) : Pos(&pos) { } + Position* Pos; + }; + struct PositionXYZStreamer { explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) {} @@ -382,19 +393,38 @@ struct Position float m_positionZ; float m_orientation; + bool operator==(Position const &a); + + inline bool operator!=(Position const &a) + { + return !(operator==(a)); + } + void Relocate(float x, float y) - { m_positionX = x; m_positionY = y;} + { + m_positionX = x; m_positionY = y; + } void Relocate(float x, float y, float z) - { m_positionX = x; m_positionY = y; m_positionZ = z; } + { + m_positionX = x; m_positionY = y; m_positionZ = z; + } void Relocate(float x, float y, float z, float orientation) - { m_positionX = x; m_positionY = y; m_positionZ = z; m_orientation = orientation; } + { + m_positionX = x; m_positionY = y; m_positionZ = z; m_orientation = orientation; + } void Relocate(const Position &pos) - { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; m_orientation = pos.m_orientation; } + { + m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; m_orientation = pos.m_orientation; + } void Relocate(const Position* pos) - { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; m_orientation = pos->m_orientation; } + { + m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; m_orientation = pos->m_orientation; + } void RelocateOffset(const Position &offset); void SetOrientation(float orientation) - { m_orientation = orientation; } + { + m_orientation = orientation; + } float GetPositionX() const { return m_positionX; } float GetPositionY() const { return m_positionY; } @@ -402,17 +432,26 @@ struct Position float GetOrientation() const { return m_orientation; } void GetPosition(float &x, float &y) const - { x = m_positionX; y = m_positionY; } + { + x = m_positionX; y = m_positionY; + } void GetPosition(float &x, float &y, float &z) const - { x = m_positionX; y = m_positionY; z = m_positionZ; } + { + x = m_positionX; y = m_positionY; z = m_positionZ; + } void GetPosition(float &x, float &y, float &z, float &o) const - { x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; } + { + x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; + } void GetPosition(Position* pos) const { if (pos) pos->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation); } + Position GetPosition() const { return *this; } + + Position::PositionXYZStreamer PositionXYZStream() { return PositionXYZStreamer(*this); @@ -425,39 +464,65 @@ struct Position bool IsPositionValid() const; float GetExactDist2dSq(float x, float y) const - { float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; } + { + float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; + } float GetExactDist2d(const float x, const float y) const - { return sqrt(GetExactDist2dSq(x, y)); } + { + return sqrt(GetExactDist2dSq(x, y)); + } float GetExactDist2dSq(const Position* pos) const - { float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; } + { + float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; + } float GetExactDist2d(const Position* pos) const - { return sqrt(GetExactDist2dSq(pos)); } + { + return sqrt(GetExactDist2dSq(pos)); + } float GetExactDistSq(float x, float y, float z) const - { float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; } + { + float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; + } float GetExactDist(float x, float y, float z) const - { return sqrt(GetExactDistSq(x, y, z)); } + { + return sqrt(GetExactDistSq(x, y, z)); + } float GetExactDistSq(const Position* pos) const - { float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; } + { + float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; + } float GetExactDist(const Position* pos) const - { return sqrt(GetExactDistSq(pos)); } + { + return sqrt(GetExactDistSq(pos)); + } void GetPositionOffsetTo(const Position & endPos, Position & retOffset) const; float GetAngle(const Position* pos) const; float GetAngle(float x, float y) const; float GetRelativeAngle(const Position* pos) const - { return GetAngle(pos) - m_orientation; } + { + return GetAngle(pos) - m_orientation; + } float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; } void GetSinCos(float x, float y, float &vsin, float &vcos) const; bool IsInDist2d(float x, float y, float dist) const - { return GetExactDist2dSq(x, y) < dist * dist; } + { + return GetExactDist2dSq(x, y) < dist * dist; + } bool IsInDist2d(const Position* pos, float dist) const - { return GetExactDist2dSq(pos) < dist * dist; } + { + return GetExactDist2dSq(pos) < dist * dist; + } bool IsInDist(float x, float y, float z, float dist) const - { return GetExactDistSq(x, y, z) < dist * dist; } + { + return GetExactDistSq(x, y, z) < dist * dist; + } bool IsInDist(const Position* pos, float dist) const - { return GetExactDistSq(pos) < dist * dist; } + { + return GetExactDistSq(pos) < dist * dist; + } bool IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const; bool HasInArc(float arcangle, const Position* pos, float targetRadius = 0.0f) const; @@ -479,10 +544,13 @@ struct Position return fmod(o, 2.0f * static_cast(M_PI)); } }; -ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); +ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYStreamer const& streamer); +ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYStreamer const& streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); -ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); +ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); +ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer); + struct MovementInfo { diff --git a/src/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp index 55c745a8a..3278c123f 100644 --- a/src/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp +++ b/src/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp @@ -196,11 +196,13 @@ class boss_ayamiss : public CreatureScript events.ScheduleEvent(EVENT_SWARMER_ATTACK, 60000); break; case EVENT_SUMMON_SWARMER: + { Position Pos; me->GetRandomPoint(SwarmerPos, 80.0f, Pos); me->SummonCreature(NPC_SWARMER, Pos); events.ScheduleEvent(EVENT_SUMMON_SWARMER, 5000); break; + } case EVENT_TRASH: DoCastVictim(SPELL_TRASH); events.ScheduleEvent(EVENT_TRASH, urand(5000, 7000)); diff --git a/src/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp index 1b8f6de3e..1a076a666 100644 --- a/src/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp +++ b/src/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp @@ -179,12 +179,14 @@ public: events.RepeatEvent(20000); break; case EVENT_SPELL_LOCUST_SWARM: + { me->CastSpell(me, RAID_MODE(SPELL_LOCUST_SWARM_10, SPELL_LOCUST_SWARM_25), false); Position pos; - me->GetNearPosition(pos, 10.0f, rand_norm()*2*M_PI); + me->GetNearPosition(pos, 10.0f, rand_norm() * 2 * M_PI); me->SummonCreature(NPC_CRYPT_GUARD, pos); events.RepeatEvent(90000); break; + } case EVENT_SPELL_BERSERK: me->CastSpell(me, SPELL_BERSERK, true); events.PopEvent(); diff --git a/src/scripts/Northrend/zone_dalaran.cpp b/src/scripts/Northrend/zone_dalaran.cpp index 367b5231f..140029352 100644 --- a/src/scripts/Northrend/zone_dalaran.cpp +++ b/src/scripts/Northrend/zone_dalaran.cpp @@ -576,13 +576,15 @@ class npc_minigob_manabonk : public CreatureScript events.ScheduleEvent(EVENT_BLINK, 3*IN_MILLISECONDS); break; case EVENT_BLINK: + { DoCast(me, SPELL_IMPROVED_BLINK); Position pos; me->GetRandomNearPosition(pos, (urand(15, 40))); me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ); - events.ScheduleEvent(EVENT_DESPAWN, 3*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DESPAWN, 3 * IN_MILLISECONDS); events.ScheduleEvent(EVENT_DESPAWN_VISUAL, 2.5*IN_MILLISECONDS); break; + } case EVENT_DESPAWN_VISUAL: DoCast(me, SPELL_TELEPORT_VISUAL); break; diff --git a/src/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp b/src/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp index 0a9b09531..5297bbc4c 100644 --- a/src/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp +++ b/src/scripts/Outland/TempestKeep/Mechanar/boss_mechano_lord_capacitus.cpp @@ -104,11 +104,13 @@ class boss_mechano_lord_capacitus : public CreatureScript events.ScheduleEvent(EVENT_REFLECTIVE_DAMAGE_SHIELD, 20000); break; case EVENT_SUMMON_NETHER_CHARGE: + { Position pos; me->GetRandomNearPosition(pos, 8.0f); me->SummonCreature(NPC_NETHER_CHARGE, pos, TEMPSUMMON_TIMED_DESPAWN, 18000); events.ScheduleEvent(EVENT_SUMMON_NETHER_CHARGE, 5000); break; + } case EVENT_POSITIVE_SHIFT: me->CastSpell(me, SPELL_POLARITY_SHIFT, true); events.ScheduleEvent(EVENT_POSITIVE_SHIFT, 30000);