TrinityCore
Loading...
Searching...
No Matches
boss_mal_ganis.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
19#include "InstanceScript.h"
20#include "Map.h"
21#include "MotionMaster.h"
22#include "ObjectAccessor.h"
23#include "PassiveAI.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "ScriptMgr.h"
27#include "SpellMgr.h"
28
36
45
53
55{
56 public:
57 boss_mal_ganis() : CreatureScript("boss_mal_ganis") { }
58
59 CreatureAI* GetAI(Creature* creature) const override
60 {
61 if (!InstanceHasScript(creature, CoSScriptName))
62 return nullptr;
63
65 return new NullCreatureAI(creature);
66 else
67 return new boss_mal_ganisAI(creature);
68 }
69
70 struct boss_mal_ganisAI : public BossAI
71 {
72 boss_mal_ganisAI(Creature* creature) : BossAI(creature, DATA_MAL_GANIS), _defeated(false), _hadYell30(false), _hadYell15(false) { }
73
74 void Reset() override
75 {
76 if (!_defeated)
78 }
79
80 void DamageTaken(Unit* /*source*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
81 {
82 if (damage >= me->GetHealth())
83 {
84 damage = me->GetHealth() - 1;
85 if (_defeated)
86 return;
87 _defeated = true;
88
89 // @todo hack most likely
92 map->PermBindAllPlayers();
93 }
94 }
95
106
107 void JustReachedHome() override
108 {
109 if (!_defeated)
111 }
112
113 void UpdateAI(uint32 diff) override
114 {
115 if (_defeated)
116 {
117 if (me->IsInCombat())
118 {
120 me->SetImmuneToAll(true);
121 }
122 return;
123 }
124
125 if (!UpdateVictim())
126 return;
127
128 if (!_hadYell30 && HealthBelowPct(30))
129 {
131 _hadYell30 = true;
132 }
133
134 if (!_hadYell15 && HealthBelowPct(15))
135 {
137 _hadYell15 = true;
138 }
139
140 events.Update(diff);
141
143 return;
144
145 while (uint32 eventId = events.ExecuteEvent())
146 {
147 switch (eventId)
148 {
152 break;
153 case EVENT_MIND_BLAST:
154 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, -int32(sSpellMgr->GetSpellIdForDifficulty(SPELL_SLEEP, me))))
155 DoCast(target, SPELL_MIND_BLAST);
156 else
158 events.Repeat(Seconds(8), Seconds(12));
159 break;
162 events.Repeat(Seconds(30));
163 break;
164 case EVENT_SLEEP:
165 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f))
166 DoCast(target, SPELL_SLEEP);
167 else
169 events.Repeat(Seconds(10), Seconds(15));
170 break;
171 default:
172 break;
173 }
174
176 return;
177 }
178
180 }
181
182 void KilledUnit(Unit* victim) override
183 {
184 if (!_defeated && victim->GetTypeId() == TYPEID_PLAYER)
185 Talk(SAY_SLAY);
186 }
187
188 private:
192 };
193};
194
196{
197 new boss_mal_ganis();
198}
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:27
@ NOT_STARTED
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
Spells
Definition PlayerAI.cpp:32
#define sSpellMgr
Definition SpellMgr.h:738
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ SAY_30HEALTH
@ SAY_SLEEP
@ SAY_KILL
@ SAY_SLAY
@ SAY_15HEALTH
void AddSC_boss_mal_ganis()
@ SPELL_SLEEP
@ SPELL_VAMPIRIC_TOUCH
@ SPELL_MIND_BLAST
@ SPELL_CARRION_SWARM
@ EVENT_CARRION_SWARM
@ EVENT_MIND_BLAST
@ EVENT_SLEEP
@ EVENT_VAMPIRIC_TOUCH
Yells
InstanceScript *const instance
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetImmuneToAll(bool apply) override
Definition Creature.h:126
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
virtual bool SetBossState(uint32 id, EncounterState state)
InstanceMap * instance
InstanceMap * ToInstanceMap()
Definition Map.h:520
bool IsHeroic() const
Definition Map.cpp:4256
TypeID GetTypeId() const
Definition Object.h:93
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
uint32 GetHealth() const
Definition Unit.h:913
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool IsInCombat() const
Definition Unit.h:1144
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:55
CreatureAI * GetAI(Creature *creature) const override
@ DATA_INSTANCE_PROGRESS
#define CoSScriptName
@ MALGANIS_IN_PROGRESS
bool HealthBelowPct(uint32 pct) const
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *victim) override
void JustEngagedWith(Unit *) override