Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
kezan.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#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "ScriptedGossip.h"
9#include "Player.h"
10
11/*####
12## npc_defiant_troll (http://www.wowhead.com/quest=14069)
13####*/
14
24
26{
27public:
28 npc_defiant_troll() : CreatureScript("npc_defiant_troll") { }
29
31 {
32 return new npc_defiant_trollAI(creature);
33 }
34
36 {
37 npc_defiant_trollAI(Creature* creature) : ScriptedAI(creature) { }
38
40 bool work;
41
43 {
44 rebuffTimer = 0;
45 work = false;
46 me->CastSpell(me, SPELL_ENRAGE, true);
47 }
48
50 {
51 if (id == 1)
52 work = true;
53 }
54
55 bool IsWorking() const { return work; }
56
58 {
59 if (IsWorking())
60 me->HandleEmoteCommand(EMOTE_ONESHOT_WORK_MINING);
61
62 if (rebuffTimer <= diff)
63 {
64 Reset();
65
66 switch (std::rand() % 2)
67 {
68 case 0:
69 me->HandleEmoteCommand(EMOTE_STATE_EXCLAIM);
70 break;
71 case 1:
72 me->HandleEmoteCommand(EMOTE_STATE_DANCE);
73 break;
74 case 2:
75 me->HandleEmoteCommand(EMOTE_ONESHOT_NONE);
76 break;
77 }
78 rebuffTimer = 120000; // Rebuff again in 2 minutes
79 }
80 else
81 rebuffTimer -= diff;
82
83 if (!UpdateVictim())
84 return;
85
86 //DoMeleeAttackIfReady();
87 }
88 };
89
90 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
91 {
92 if (player->GetQuestStatus(QUEST_GOOD_HELP_IS_HARD_TO_FIND) == QUEST_STATUS_INCOMPLETE && !CAST_AI(npc_defiant_troll::npc_defiant_trollAI, creature->AI())->IsWorking())
93 {
94 player->CastSpell(creature, SPELL_LIGHTNING_VISUAL, true);
95 player->KilledMonsterCredit(DEFFIANT_KILL_CREDIT, creature->GetGUID());
96 creature->AI()->Talk(SAY_WORK);
97 creature->RemoveAllAuras();
98
99 if (GameObject* deposit = creature->FindNearestGameObject(GO_DEPOSIT, 20))
100 creature->GetMotionMaster()->MovePoint(1, deposit->GetPositionX() - 1.0f, deposit->GetPositionY(), deposit->GetPositionZ());
101
102 if (player->GetQuestStatus(QUEST_GOOD_HELP_IS_HARD_TO_FIND) == QUEST_STATUS_COMPLETE)
103 player->RemoveAura(SPELL_LIGHTNING_VISUAL);
104
105 player->CLOSE_GOSSIP_MENU();
106
107 return true;
108 }
109
110 player->CLOSE_GOSSIP_MENU();
111
112 return false;
113 }
114};
115
117{
118 new npc_defiant_troll();
119}
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:89
@ QUEST_STATUS_COMPLETE
Definition QuestDef.h:87
#define CAST_AI(a, b)
@ EMOTE_ONESHOT_WORK_MINING
@ EMOTE_STATE_DANCE
@ EMOTE_ONESHOT_NONE
@ EMOTE_STATE_EXCLAIM
@ SPELL_ENRAGE
bool UpdateVictim()
CreatureScript(const char *name)
GameObject * FindNearestGameObject(uint32 entry, float range) const
Definition Object.cpp:2810
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition kezan.cpp:30
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
Definition kezan.cpp:90
DefiantTrollEnum
Definition kezan.cpp:16
@ SAY_WORK
Definition kezan.cpp:22
@ SPELL_ENRAGE
Definition kezan.cpp:19
@ SPELL_LIGHTNING_VISUAL
Definition kezan.cpp:18
@ DEFFIANT_KILL_CREDIT
Definition kezan.cpp:17
@ QUEST_GOOD_HELP_IS_HARD_TO_FIND
Definition kezan.cpp:20
@ GO_DEPOSIT
Definition kezan.cpp:21
void AddSC_kezan()
Definition kezan.cpp:116
Creature * me
ScriptedAI(Creature *creature)
void MovementInform(uint32, uint32 id) OVERRIDE
Definition kezan.cpp:49
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition kezan.cpp:57
npc_defiant_trollAI(Creature *creature)
Definition kezan.cpp:37