TrinityCore
Loading...
Searching...
No Matches
zone_tirisfal_glades.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/* ScriptData
19SDName: Tirisfal_Glades
20SD%Complete: 100
21SDComment: Quest support: 590, 1819
22SDCategory: Tirisfal Glades
23EndScriptData */
24
25/* ContentData
26npc_calvin_montague
27go_mausoleum_door
28go_mausoleum_trigger
29EndContentData */
30
31#include "ScriptMgr.h"
32#include "GameObject.h"
33#include "GameObjectAI.h"
34#include "ObjectAccessor.h"
35#include "Player.h"
36#include "ScriptedCreature.h"
37
38/*######
39## npc_calvin_montague
40######*/
41
43{
45 SPELL_DRINK = 7737, // Possibly incorrect spell, but both duration and icon are correct
46 QUEST_590 = 590,
47
52 EVENT_STAND = 5
53};
54
56{
57public:
58 npc_calvin_montague() : CreatureScript("npc_calvin_montague") { }
59
61 {
62 npc_calvin_montagueAI(Creature* creature) : ScriptedAI(creature) { }
63
64 void Reset() override
65 {
67 if (!me->IsImmuneToPC())
68 me->SetImmuneToPC(true);
69 }
70
71 void JustEngagedWith(Unit* /*who*/) override { }
72
73 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
74 {
75 if (damage > me->GetHealth() || me->HealthBelowPctDamaged(15, damage))
76 {
77 damage = 0;
78 me->CombatStop(true);
81 }
82 }
83
84 void UpdateAI(uint32 diff) override
85 {
86 _events.Update(diff);
87
88 if (uint32 eventId = _events.ExecuteEvent())
89 {
90 switch (eventId)
91 {
95 break;
96 case EVENT_TALK:
99 break;
100 case EVENT_DRINK:
102 player->AreaExploredOrEventHappens(QUEST_590);
106 break;
110 break;
111 case EVENT_STAND:
113 break;
114 }
115 }
116
117 if (!UpdateVictim())
118 return;
119
121 }
122
123 void OnQuestAccept(Player* player, Quest const* quest) override
124 {
125 if (quest->GetQuestId() == QUEST_590)
126 {
127 _playerGUID = player->GetGUID();
129 me->SetImmuneToPC(false);
130 AttackStart(player);
132 }
133 }
134
135 private:
138 };
139
140 CreatureAI* GetAI(Creature* creature) const override
141 {
142 return new npc_calvin_montagueAI(creature);
143 }
144};
145
147{
149}
uint32_t uint32
Definition Define.h:133
@ EMOTE_ONESHOT_RUDE
@ FACTION_ENEMY
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_NPC_FLAG_QUESTGIVER
DamageEffectType
Definition Unit.h:352
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void SetImmuneToPC(bool apply) override
Definition Creature.h:129
bool IsImmuneToPC() const
Definition Unit.h:1137
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Clear()
Definition ObjectGuid.h:150
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetQuestId() const
Definition QuestDef.h:229
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
Definition Unit.h:769
void RestoreFaction()
Definition Unit.cpp:11776
void SetFaction(uint32 faction) override
Definition Unit.h:974
void RemoveNpcFlag(NPCFlags flags)
Definition Unit.h:1098
uint32 GetHealth() const
Definition Unit.h:913
void SetNpcFlag(NPCFlags flags)
Definition Unit.h:1097
void HandleEmoteCommand(Emote emoteId)
Definition Unit.cpp:1568
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition Unit.cpp:5691
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
void AttackStart(Unit *) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnQuestAccept(Player *player, Quest const *quest) override
void AddSC_tirisfal_glades()
@ EVENT_SET_QUESTGIVER_FLAG
@ EVENT_EMOTE_RUDE