TrinityCore
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
141{
143}
uint32_t uint32
Definition: Define.h:142
@ EMOTE_ONESHOT_CUSTOM_SPELL_01
@ EMOTE_STATE_FLYGRABCLOSED
Says_VBM
Definition: chapter1.cpp:538
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
Creature *const me
Definition: CreatureAI.h:61
void SetTarget(ObjectGuid const &guid) override
Definition: Creature.cpp:3419
void DisappearAndDie()
Definition: Creature.h:83
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
static Player * ToPlayer(Object *o)
Definition: Object.h:213
bool IsResurrectRequested() const
Definition: Player.h:1933
Unit * GetSummonerUnit() const
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetVisible(bool x)
Definition: Unit.cpp:8351
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
float GetCombatReach() const override
Definition: Unit.h:694
TempSummon * ToTempSummon()
Definition: Unit.h:1756
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:12392
bool SetCanFly(bool enable)
Definition: Unit.cpp:12820
bool IsSummon() const
Definition: Unit.h:738
bool SetWalk(bool enable)
Definition: Unit.cpp:12707
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition: Object.cpp:3403
void setActive(bool isActiveObject)
Definition: Object.cpp:922
void SetFarVisible(bool on)
Definition: Object.cpp:973
CreatureAI * GetAI(Creature *creature) const override
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
void AddSC_the_scarlet_enclave()