diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-07-12 20:30:52 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-16 00:10:25 +0100 |
commit | 8c35206bb5a6d4f98e941f7140f597433345bd4c (patch) | |
tree | 8bef22117eb204d96658ca45ac0671b0be94a98e | |
parent | ef6a5d3c3c010f9ad63a71015a533a3894ab38b9 (diff) |
Scripts/ScarletEnclave: 4ee84bb followup
(cherry picked from commit fa9a4ee20d6a63f2e99e9feb45cd0ecf83ccc7f5)
-rw-r--r-- | src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index c7839057c3b..348d3f31e6c 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -18,6 +18,7 @@ #include "ScriptMgr.h" #include "CombatAI.h" #include "CreatureTextMgr.h" +#include "G3DPosition.hpp" #include "GameObject.h" #include "GameObjectAI.h" #include "Log.h" @@ -33,7 +34,6 @@ #include "SpellInfo.h" #include "TemporarySummon.h" #include "Vehicle.h" -#include <G3D/Vector3.h> /*###### ##Quest 12848 @@ -404,31 +404,31 @@ class spell_death_knight_initiate_visual : public SpellScript ## npc_eye_of_acherus ######*/ -enum EyeOfAcherus +enum EyeOfAcherusMisc { - SPELL_EYE_VISUAL = 51892, - SPELL_EYE_FLIGHT_BOOST = 51923, - SPELL_EYE_FLIGHT = 51890, + SPELL_EYE_VISUAL = 51892, + SPELL_EYE_FLIGHT_BOOST = 51923, + SPELL_EYE_FLIGHT = 51890, - EVENT_MOVE_START = 1, + EVENT_MOVE_START = 1, - TALK_MOVE_START = 0, - TALK_CONTROL = 1, + TALK_MOVE_START = 0, + TALK_CONTROL = 1, - POINT_EYE_FALL = 1, - POINT_EYE_MOVE_END = 3 + POINT_EYE_FALL = 1, + POINT_EYE_MOVE_END = 3 }; Position const EyeOFAcherusFallPoint = { 2361.21f, -5660.45f, 496.7444f, 0.0f }; -Position const EyeOfAcherusPath[] = +G3D::Vector3 const EyeOfAcherusPath[] = { { 2361.21f, -5660.45f, 496.744f }, { 2341.57f, -5672.8f, 538.394f }, { 1957.4f, -5844.1f, 273.867f }, { 1758.01f, -5876.79f, 166.867f } }; -std::size_t const EyeOfAcherusPathSize = std::extent<decltype(EyeOfAcherusPath)>::value; +std::size_t constexpr EyeOfAcherusPathSize = std::extent<decltype(EyeOfAcherusPath)>::value; class npc_eye_of_acherus : public CreatureScript { @@ -439,21 +439,25 @@ class npc_eye_of_acherus : public CreatureScript { npc_eye_of_acherusAI(Creature* creature) : ScriptedAI(creature) { - me->SetDisplayFromModel(0); - if (me->GetCharmInfo()) - me->GetCharmInfo()->InitPossessCreateSpells(); + creature->SetDisplayFromModel(0); + creature->SetReactState(REACT_PASSIVE); + creature->SetDisableGravity(true); + creature->SetControlled(true, UNIT_STATE_ROOT); + + if (creature->GetCharmInfo()) + creature->GetCharmInfo()->InitPossessCreateSpells(); + } + + void JustAppeared() override + { + ScriptedAI::JustAppeared(); DoCastSelf(SPELL_EYE_VISUAL); - me->SetReactState(REACT_PASSIVE); - me->SetDisableGravity(true); - me->SetControlled(true, UNIT_STATE_ROOT); Movement::MoveSplineInit init(me); - init.MoveTo(EyeOFAcherusFallPoint.GetPositionX(), EyeOFAcherusFallPoint.GetPositionY(), EyeOFAcherusFallPoint.GetPositionZ(), false); + init.MoveTo(PositionToVector3(EyeOFAcherusFallPoint), false); init.SetFall(); me->GetMotionMaster()->LaunchMoveSpline(std::move(init), POINT_EYE_FALL, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE); - - _events.ScheduleEvent(EVENT_MOVE_START, 7s); } void OnCharmed(bool /*isNew*/) override { } @@ -470,21 +474,14 @@ class npc_eye_of_acherus : public CreatureScript { DoCastSelf(SPELL_EYE_FLIGHT_BOOST); me->SetControlled(false, UNIT_STATE_ROOT); - - if (Player* owner = me->GetCharmerOrOwner()->ToPlayer()) + if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself()) { - for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) - me->SetSpeedRate(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i))); + for (uint8 itr = 0; itr < MAX_MOVE_TYPE; ++itr) + me->SetSpeedRate(UnitMoveType(itr), owner->GetSpeedRate(UnitMoveType(itr))); Talk(TALK_MOVE_START, owner); } - Movement::PointsArray path; - path.reserve(EyeOfAcherusPathSize); - std::transform(std::begin(EyeOfAcherusPath), std::end(EyeOfAcherusPath), std::back_inserter(path), [](Position const& pos) - { - return G3D::Vector3(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); - }); - + Movement::PointsArray path(EyeOfAcherusPath, EyeOfAcherusPath + EyeOfAcherusPathSize); Movement::MoveSplineInit init(me); init.MovebyPath(path); me->GetMotionMaster()->LaunchMoveSpline(std::move(init), POINT_EYE_MOVE_END, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE); @@ -498,20 +495,30 @@ class npc_eye_of_acherus : public CreatureScript void MovementInform(uint32 movementType, uint32 pointId) override { - if (movementType == POINT_MOTION_TYPE && pointId == POINT_EYE_MOVE_END) + if (movementType != POINT_MOTION_TYPE) + return; + + switch (pointId) { - me->RemoveAllAuras(); + case POINT_EYE_FALL: + _events.ScheduleEvent(EVENT_MOVE_START, 2s); + break; + case POINT_EYE_MOVE_END: + me->RemoveAurasDueToSpell(SPELL_EYE_FLIGHT_BOOST); + if (Player* owner = me->GetCharmerOrOwnerPlayerOrPlayerItself()) + { + owner->RemoveAurasDueToSpell(SPELL_EYE_FLIGHT_BOOST); + for (uint8 itr = 0; itr < MAX_MOVE_TYPE; ++itr) + me->SetSpeedRate(UnitMoveType(itr), owner->GetSpeedRate(UnitMoveType(itr))); + Talk(TALK_CONTROL, owner); - if (Player* owner = me->GetCharmerOrOwner()->ToPlayer()) - { - owner->RemoveAura(SPELL_EYE_FLIGHT_BOOST); - for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) - me->SetSpeedRate(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i))); - Talk(TALK_CONTROL, owner); - } - me->SetDisableGravity(false); - DoCastSelf(SPELL_EYE_FLIGHT); + owner->PossessSpellInitialize(); + } + DoCastSelf(SPELL_EYE_FLIGHT); + break; + default: + break; } } |