TrinityCore
Loading...
Searching...
No Matches
zone_the_scarlet_enclave.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "MotionMaster.h"
20#include "PassiveAI.h"
21#include "Player.h"
22#include "TemporarySummon.h"
23
24/*####
25## npc_valkyr_battle_maiden
26####*/
27
29{
30 SPELL_REVIVE = 51918
31};
32
34{
36};
37
39{
40public:
41 npc_valkyr_battle_maiden() : CreatureScript("npc_valkyr_battle_maiden") { }
42
43 CreatureAI* GetAI(Creature* creature) const override
44 {
45 return new npc_valkyr_battle_maidenAI(creature);
46 }
47
49 {
51 {
52 Initialize();
53 }
54
56 {
57 FlyBackTimer = 500;
58 phase = 0;
59 x = 0.f;
60 y = 0.f;
61 z = 0.f;
62 }
63
65 float x, y, z;
67
68 void Reset() override
69 {
70 me->setActive(true);
71 me->SetFarVisible(true);
72 me->SetVisible(false);
73 me->SetCanFly(true);
74
75 me->GetPosition(x, y, z);
76 z += 4.0f;
77 x -= 3.5f;
78 y -= 5.0f;
80 me->UpdatePosition(x, y, z, 0.0f);
81 }
82
83 void UpdateAI(uint32 diff) override
84 {
85 if (FlyBackTimer <= diff)
86 {
87 Player* player = nullptr;
88 if (me->IsSummon())
89 if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
90 player = summoner->ToPlayer();
91
92 if (!player)
93 phase = 3;
94
95 switch (phase)
96 {
97 case 0:
98 me->SetWalk(false);
100 FlyBackTimer = 500;
101 break;
102 case 1:
103 player->GetClosePoint(x, y, z, me->GetCombatReach());
104 z += 2.5f;
105 x -= 2.0f;
106 y -= 1.5f;
107 me->GetMotionMaster()->MovePoint(0, x, y, z);
108 me->SetTarget(player->GetGUID());
109 me->SetVisible(true);
110 FlyBackTimer = 4500;
111 break;
112 case 2:
113 if (!player->IsResurrectRequested())
114 {
116 DoCast(player, SPELL_REVIVE, true);
117 Talk(WHISPER_REVIVE, player);
118 }
119 FlyBackTimer = 5000;
120 break;
121 case 3:
122 me->SetVisible(false);
123 FlyBackTimer = 3000;
124 break;
125 case 4:
127 break;
128 default:
129 //Nothing To DO
130 break;
131 }
132 ++phase;
133 }
134 else
135 FlyBackTimer -= diff;
136 }
137 };
138};
139
uint32_t uint32
Definition Define.h:154
@ EMOTE_ONESHOT_CUSTOM_SPELL_01
@ EMOTE_STATE_FLYGRABCLOSED
Says_VBM
Definition chapter1.cpp:544
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Creature *const me
Definition CreatureAI.h:63
void SetTarget(ObjectGuid const &guid) override
void DisappearAndDie()
Definition Creature.h:95
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Player * ToPlayer()
Definition Object.h:126
bool IsResurrectRequested() const
Definition Player.h:2104
Unit * GetSummonerUnit() const
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetVisible(bool x)
Definition Unit.cpp:8768
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
float GetCombatReach() const override
Definition Unit.h:705
TempSummon * ToTempSummon()
Definition Unit.h:1828
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition Unit.cpp:13027
bool SetCanFly(bool enable)
Definition Unit.cpp:13459
bool IsSummon() const
Definition Unit.h:749
bool SetWalk(bool enable)
Definition Unit.cpp:13343
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition Unit.cpp:1657
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition Object.cpp:2749
void setActive(bool isActiveObject)
Definition Object.cpp:276
void SetFarVisible(bool on)
Definition Object.cpp:327
CreatureAI * GetAI(Creature *creature) const override
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
void AddSC_the_scarlet_enclave()