Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
zone_mulgore.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6 /* ScriptData
7 SDName: Mulgore
8 SD%Complete: 100
9 SDComment: Support for quest: 14491
10 SDCategory: Mulgore
11 EndScriptData */
12
13 /* ContentData
14 npc_agitated_earth_spirit
15 EndContentData */
16
17#include "ScriptMgr.h"
18#include "ScriptedCreature.h"
19#include "ScriptedGossip.h"
20#include "Player.h"
21#include "SpellInfo.h"
22
32
33// 36845 - Agitated Earth Spirit
35{
36public:
37 npc_agitated_earth_spirit() : CreatureScript("npc_agitated_earth_spirit") { }
38
40 {
42
44 {
45 events.Reset();
46 playerGUID = 0;
47 me->setFaction(190);
48 }
49
50 void SpellHit(Unit* caster, SpellInfo const* spell) OVERRIDE
51 {
52 if (spell->Id == SPELL_SOOTHE_EARTH_SPIRIT && me->getFaction() == 190)
53 {
54 Position pos;
55 caster->GetNearPoint(caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ, 0.0f, MIN_MELEE_REACH, caster->GetAngle(me));
56 me->GetMotionMaster()->MovePoint(1, pos);
57 playerGUID = caster->GetGUID();
58 }
59 }
60
62 {
63 if (type == POINT_MOTION_TYPE && pointId == 1)
64 {
65 switch (std::rand() % 1)
66 {
67 case 0:
68 {
69 me->setFaction(35);
71 player->KilledMonsterCredit(NPC_EARTH_SPIRIT_CREDIT_BUNNY);
72
73 me->DespawnOrUnsummon(1000);
74 break;
75 }
76 case 1:
77 me->setFaction(14);
79 {
80 Talk(0, player);
81 AttackStart(player);
82 }
83 break;
84 }
85 }
86 }
87
88 void EnterCombat(Unit* /*victim*/) OVERRIDE
89 {
90 events.ScheduleEvent(EVENT_ROCK_BARRAGE, std::rand() % 5000 + 4000);
91 }
92
94 {
95 if (!UpdateVictim())
96 return;
97
98 events.Update(diff);
99
100 while (uint32 eventId = events.ExecuteEvent())
101 {
102 switch (eventId)
103 {
105 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
106 DoCast(target, SPELL_ROCK_BARRAGE);
107 events.ScheduleEvent(EVENT_ROCK_BARRAGE, std::rand() % 21000 + 18000);
108 break;
109 }
110 }
111
113 }
114
115 private:
118 };
119
121 {
122 return new npc_agitated_earth_spiritAI(creature);
123 }
124};
125
127{
129}
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ POINT_MOTION_TYPE
#define MIN_MELEE_REACH
Definition Object.h:31
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
static Player * GetPlayer(WorldObject const &, uint64 guid)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
Definition Unit.h:1367
CreatureAI * GetAI(Creature *creature) const OVERRIDE
float m_positionZ
Definition Object.h:289
float m_positionX
Definition Object.h:287
float m_positionY
Definition Object.h:288
Creature * me
ScriptedAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
void MovementInform(uint32 type, uint32 pointId) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void SpellHit(Unit *caster, SpellInfo const *spell) OVERRIDE
void AddSC_mulgore()
eAgitatedEarthSpirit
@ NPC_EARTH_SPIRIT_CREDIT_BUNNY
@ EVENT_ROCK_BARRAGE
@ SPELL_ROCK_BARRAGE
@ SPELL_SOOTHE_EARTH_SPIRIT