TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "ScriptedCreature.h"
23#include "TemporarySummon.h"
24
25/*####
26## npc_valkyr_battle_maiden
27####*/
28
30{
31 SPELL_REVIVE = 51918
32};
33
35{
37};
38
40{
41public:
42 npc_valkyr_battle_maiden() : CreatureScript("npc_valkyr_battle_maiden") { }
43
44 CreatureAI* GetAI(Creature* creature) const override
45 {
46 return new npc_valkyr_battle_maidenAI(creature);
47 }
48
50 {
52 {
53 Initialize();
54 }
55
57 {
58 FlyBackTimer = 500;
59 phase = 0;
60 x = 0.f;
61 y = 0.f;
62 z = 0.f;
63 }
64
66 float x, y, z;
68
69 void Reset() override
70 {
71 me->setActive(true);
72 me->SetFarVisible(true);
73 me->SetVisible(false);
74 me->SetCanFly(true);
75
76 me->GetPosition(x, y, z);
77 z += 4.0f;
78 x -= 3.5f;
79 y -= 5.0f;
81 me->UpdatePosition(x, y, z, 0.0f);
82 }
83
84 void UpdateAI(uint32 diff) override
85 {
86 if (FlyBackTimer <= diff)
87 {
88 Player* player = nullptr;
89 if (me->IsSummon())
90 if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
91 player = summoner->ToPlayer();
92
93 if (!player)
94 phase = 3;
95
96 switch (phase)
97 {
98 case 0:
99 me->SetWalk(false);
101 FlyBackTimer = 500;
102 break;
103 case 1:
104 player->GetClosePoint(x, y, z, me->GetCombatReach());
105 z += 2.5f;
106 x -= 2.0f;
107 y -= 1.5f;
108 me->GetMotionMaster()->MovePoint(0, x, y, z);
109 me->SetTarget(player->GetGUID());
110 me->SetVisible(true);
111 FlyBackTimer = 4500;
112 break;
113 case 2:
114 if (!player->IsResurrectRequested())
115 {
117 DoCast(player, SPELL_REVIVE, true);
118 Talk(WHISPER_REVIVE, player);
119 }
120 FlyBackTimer = 5000;
121 break;
122 case 3:
123 me->SetVisible(false);
124 FlyBackTimer = 3000;
125 break;
126 case 4:
128 break;
129 default:
130 //Nothing To DO
131 break;
132 }
133 ++phase;
134 }
135 else
136 FlyBackTimer -= diff;
137 }
138 };
139};
140
142{
144}
uint32_t uint32
Definition: Define.h:133
@ EMOTE_ONESHOT_CUSTOM_SPELL_01
@ EMOTE_STATE_FLYGRABCLOSED
Says_VBM
Definition: chapter1.cpp:534
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:48
Creature *const me
Definition: CreatureAI.h:81
void SetTarget(ObjectGuid guid) override
Definition: Creature.cpp:3150
bool SetCanFly(bool enable, bool packetOnly=false) override
Definition: Creature.cpp:2992
bool SetWalk(bool enable) override
Definition: Creature.cpp:2941
void DisappearAndDie()
Definition: Creature.h:73
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:77
static Player * ToPlayer(Object *o)
Definition: Object.h:179
Definition: Player.h:915
bool IsResurrectRequested() const
Definition: Player.h:1558
Unit * GetSummonerUnit() const
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:114
Definition: Unit.h:769
void SetVisible(bool x)
Definition: Unit.cpp:8509
MotionMaster * GetMotionMaster()
Definition: Unit.h:1667
float GetCombatReach() const override
Definition: Unit.h:837
TempSummon * ToTempSummon()
Definition: Unit.h:1794
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:12924
bool IsSummon() const
Definition: Unit.h:880
void HandleEmoteCommand(Emote emoteId)
Definition: Unit.cpp:1565
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0) const
Definition: Object.cpp:3243
void setActive(bool isActiveObject)
Definition: Object.cpp:980
void SetFarVisible(bool on)
Definition: Object.cpp:1003
CreatureAI * GetAI(Creature *creature) const override
void GetPosition(float &x, float &y) const
Definition: Position.h:84
void AddSC_the_scarlet_enclave()