|
15 | 15 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | */ |
17 | 17 |
|
18 | | -/* ScriptData |
19 | | -Name: Boss_Shirrak_the_dead_watcher |
20 | | -%Complete: 80 |
21 | | -Comment: InhibitMagic should stack slower far from the boss, proper Visual for Focus Fire, heroic implemented |
22 | | -Category: Auchindoun, Auchenai Crypts |
23 | | -EndScriptData */ |
| 18 | +/* Old comment: "Inhibit Magic should stack slower far from the boss" - really? */ |
24 | 19 |
|
| 20 | +#include "ScriptedCreature.h" |
25 | 21 | #include "ScriptMgr.h" |
| 22 | +#include "Spell.h" |
| 23 | +#include "SpellScript.h" |
| 24 | +#include "SpellInfo.h" |
26 | 25 | #include "auchenai_crypts.h" |
27 | | -#include "Map.h" |
28 | | -#include "ObjectAccessor.h" |
29 | | -#include "Player.h" |
30 | | -#include "ScriptedCreature.h" |
31 | 26 |
|
32 | | -enum Spells |
| 27 | +enum ShirrakTexts |
33 | 28 | { |
34 | | - SPELL_INHIBITMAGIC = 32264, |
35 | | - SPELL_ATTRACTMAGIC = 32265, |
36 | | - SPELL_CARNIVOROUSBITE = 36383, |
37 | | - |
38 | | - SPELL_FIERY_BLAST = 32302, |
39 | | - |
40 | | - SPELL_FOCUS_FIRE_VISUAL = 42075 //need to find better visual |
| 29 | + EMOTE_FOCUSED = 0 |
41 | 30 | }; |
42 | 31 |
|
43 | | -enum Say |
| 32 | +enum ShirrakSpells |
44 | 33 | { |
45 | | - EMOTE_FOCUSED = 0 |
| 34 | + SPELL_INHIBIT_MAGIC_PERIODIC = 33460, |
| 35 | + SPELL_INHIBIT_MAGIC = 32264, |
| 36 | + |
| 37 | + SPELL_ATTRACT_MAGIC = 32265, |
| 38 | + SPELL_CARNIVOROUS_BITE = 36383, |
| 39 | + SPELL_FOCUS_FIRE_AURA = 32291, |
| 40 | + |
| 41 | + SPELL_BIRTH = 26262, |
| 42 | + SPELL_FOCUS_TARGET_VISUAL = 32286, |
| 43 | + SPELL_FIERY_BLAST = 32302, |
| 44 | + |
| 45 | + SPELL_FOCUS_FIRE_DUMMY = 32300, |
| 46 | + SPELL_PING_SHIRRAK = 32301 |
46 | 47 | }; |
47 | 48 |
|
48 | | -enum Creatures |
| 49 | +enum ShirrakEvents |
49 | 50 | { |
50 | | - NPC_FOCUS_FIRE = 18374 |
| 51 | + EVENT_ATTRACT_MAGIC = 1, |
| 52 | + EVENT_CARNIVOROUS_BITE, |
| 53 | + EVENT_FOCUS_FIRE |
51 | 54 | }; |
52 | 55 |
|
| 56 | +// 18371 - Shirrak the Dead Watcher |
53 | 57 | struct boss_shirrak_the_dead_watcher : public BossAI |
54 | 58 | { |
55 | | - boss_shirrak_the_dead_watcher(Creature* creature) : BossAI(creature, DATA_SHIRRAK_THE_DEAD_WATCHER) |
56 | | - { |
57 | | - Initialize(); |
58 | | - } |
59 | | - |
60 | | - void Initialize() |
61 | | - { |
62 | | - Inhibitmagic_Timer = 0; |
63 | | - Attractmagic_Timer = 28000; |
64 | | - Carnivorousbite_Timer = 10000; |
65 | | - FocusFire_Timer = 17000; |
66 | | - FocusedTargetGUID.Clear(); |
67 | | - } |
68 | | - |
69 | | - uint32 Inhibitmagic_Timer; |
70 | | - uint32 Attractmagic_Timer; |
71 | | - uint32 Carnivorousbite_Timer; |
72 | | - uint32 FocusFire_Timer; |
73 | | - |
74 | | - ObjectGuid FocusedTargetGUID; |
| 59 | + boss_shirrak_the_dead_watcher(Creature* creature) : BossAI(creature, DATA_SHIRRAK_THE_DEAD_WATCHER) { } |
75 | 60 |
|
76 | 61 | void Reset() override |
77 | 62 | { |
78 | | - Initialize(); |
| 63 | + DoCastSelf(SPELL_INHIBIT_MAGIC_PERIODIC); |
79 | 64 | _Reset(); |
80 | 65 | } |
81 | 66 |
|
82 | | - void JustSummoned(Creature* summoned) override |
| 67 | + void JustEngagedWith(Unit* who) override |
83 | 68 | { |
84 | | - if (summoned && summoned->GetEntry() == NPC_FOCUS_FIRE) |
85 | | - { |
86 | | - summoned->CastSpell(summoned, SPELL_FOCUS_FIRE_VISUAL, false); |
87 | | - summoned->SetFaction(me->GetFaction()); |
88 | | - summoned->SetLevel(me->GetLevel()); |
89 | | - summoned->AddUnitState(UNIT_STATE_ROOT); |
90 | | - |
91 | | - if (Unit* pFocusedTarget = ObjectAccessor::GetUnit(*me, FocusedTargetGUID)) |
92 | | - summoned->AI()->AttackStart(pFocusedTarget); |
93 | | - } |
94 | | - BossAI::JustSummoned(summoned); |
| 69 | + BossAI::JustEngagedWith(who); |
| 70 | + events.ScheduleEvent(EVENT_ATTRACT_MAGIC, 30s); |
| 71 | + events.ScheduleEvent(EVENT_CARNIVOROUS_BITE, 5s, 10s); |
| 72 | + events.ScheduleEvent(EVENT_FOCUS_FIRE, 20s, 30s); |
95 | 73 | } |
96 | 74 |
|
97 | 75 | void UpdateAI(uint32 diff) override |
98 | 76 | { |
99 | | - //Inhibitmagic_Timer |
100 | | - if (Inhibitmagic_Timer <= diff) |
101 | | - { |
102 | | - float dist; |
103 | | - Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers(); |
104 | | - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) |
105 | | - if (Player* i_pl = i->GetSource()) |
106 | | - if (i_pl->IsAlive() && (dist = i_pl->GetDistance(me)) < 45) |
107 | | - { |
108 | | - i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC); |
109 | | - me->AddAura(SPELL_INHIBITMAGIC, i_pl); |
110 | | - if (dist < 35) |
111 | | - me->AddAura(SPELL_INHIBITMAGIC, i_pl); |
112 | | - if (dist < 25) |
113 | | - me->AddAura(SPELL_INHIBITMAGIC, i_pl); |
114 | | - if (dist < 15) |
115 | | - me->AddAura(SPELL_INHIBITMAGIC, i_pl); |
116 | | - } |
117 | | - Inhibitmagic_Timer = 3000 + (rand32() % 1000); |
118 | | - } else Inhibitmagic_Timer -= diff; |
119 | | - |
120 | | - //Return since we have no target |
121 | 77 | if (!UpdateVictim()) |
122 | 78 | return; |
123 | 79 |
|
124 | | - //Attractmagic_Timer |
125 | | - if (Attractmagic_Timer <= diff) |
126 | | - { |
127 | | - DoCast(me, SPELL_ATTRACTMAGIC); |
128 | | - Attractmagic_Timer = 30000; |
129 | | - Carnivorousbite_Timer = 1500; |
130 | | - } else Attractmagic_Timer -= diff; |
| 80 | + events.Update(diff); |
131 | 81 |
|
132 | | - //Carnivorousbite_Timer |
133 | | - if (Carnivorousbite_Timer <= diff) |
134 | | - { |
135 | | - DoCast(me, SPELL_CARNIVOROUSBITE); |
136 | | - Carnivorousbite_Timer = 10000; |
137 | | - } else Carnivorousbite_Timer -= diff; |
| 82 | + if (me->HasUnitState(UNIT_STATE_CASTING)) |
| 83 | + return; |
138 | 84 |
|
139 | | - //FocusFire_Timer |
140 | | - if (FocusFire_Timer <= diff) |
| 85 | + while (uint32 eventId = events.ExecuteEvent()) |
141 | 86 | { |
142 | | - // Summon Focus Fire & Emote |
143 | | - Unit* target = SelectTarget(SelectTargetMethod::Random, 1); |
144 | | - if (target && target->GetTypeId() == TYPEID_PLAYER && target->IsAlive()) |
| 87 | + switch (eventId) |
145 | 88 | { |
146 | | - FocusedTargetGUID = target->GetGUID(); |
147 | | - me->SummonCreature(NPC_FOCUS_FIRE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 5500ms); |
148 | | - Talk(EMOTE_FOCUSED, target); |
| 89 | + case EVENT_ATTRACT_MAGIC: |
| 90 | + DoCastSelf(SPELL_ATTRACT_MAGIC); |
| 91 | + events.Repeat(30s); |
| 92 | + break; |
| 93 | + case EVENT_CARNIVOROUS_BITE: |
| 94 | + DoCastSelf(SPELL_CARNIVOROUS_BITE); |
| 95 | + events.Repeat(5s, 10s); |
| 96 | + break; |
| 97 | + case EVENT_FOCUS_FIRE: |
| 98 | + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 50, true)) |
| 99 | + { |
| 100 | + DoCast(target, SPELL_FOCUS_FIRE_AURA); |
| 101 | + Talk(EMOTE_FOCUSED, target); |
| 102 | + } |
| 103 | + events.Repeat(15s, 25s); |
| 104 | + break; |
| 105 | + default: |
| 106 | + break; |
149 | 107 | } |
150 | | - FocusFire_Timer = 15000 + (rand32() % 5000); |
151 | | - } else FocusFire_Timer -= diff; |
| 108 | + |
| 109 | + if (me->HasUnitState(UNIT_STATE_CASTING)) |
| 110 | + return; |
| 111 | + } |
152 | 112 |
|
153 | 113 | DoMeleeAttackIfReady(); |
154 | 114 | } |
155 | 115 | }; |
156 | 116 |
|
| 117 | +// 18374 - Focus Fire |
157 | 118 | struct npc_focus_fire : public ScriptedAI |
158 | 119 | { |
159 | | - npc_focus_fire(Creature* creature) : ScriptedAI(creature) |
| 120 | + npc_focus_fire(Creature* creature) : ScriptedAI(creature) { } |
| 121 | + |
| 122 | + void InitializeAI() override |
| 123 | + { |
| 124 | + me->SetReactState(REACT_PASSIVE); |
| 125 | + } |
| 126 | + |
| 127 | + void JustAppeared() override |
| 128 | + { |
| 129 | + // Should be in this sniffed order but makes it ignore other spell casts, so disabled |
| 130 | + // DoCastSelf(SPELL_BIRTH); |
| 131 | + DoCastSelf(SPELL_FOCUS_TARGET_VISUAL); |
| 132 | + DoCastSelf(SPELL_PING_SHIRRAK); |
| 133 | + |
| 134 | + _scheduler.Schedule(5s, [this](TaskContext /*task*/) |
| 135 | + { |
| 136 | + DoCastSelf(SPELL_FIERY_BLAST); |
| 137 | + }); |
| 138 | + } |
| 139 | + |
| 140 | + void UpdateAI(uint32 diff) override |
| 141 | + { |
| 142 | + _scheduler.Update(diff); |
| 143 | + } |
| 144 | + |
| 145 | +private: |
| 146 | + TaskScheduler _scheduler; |
| 147 | +}; |
| 148 | + |
| 149 | +// 32301 - Ping Shirrak |
| 150 | +class spell_shirrak_ping_shirrak : public SpellScript |
| 151 | +{ |
| 152 | + PrepareSpellScript(spell_shirrak_ping_shirrak); |
| 153 | + |
| 154 | + bool Validate(SpellInfo const* /*spellInfo*/) override |
160 | 155 | { |
161 | | - Initialize(); |
| 156 | + return ValidateSpellInfo({ SPELL_FOCUS_FIRE_DUMMY }); |
162 | 157 | } |
163 | 158 |
|
164 | | - void Initialize() |
| 159 | + void HandleScript(SpellEffIndex /*effIndex*/) |
165 | 160 | { |
166 | | - FieryBlast_Timer = 3000 + (rand32() % 1000); |
167 | | - fiery1 = fiery2 = true; |
| 161 | + GetHitUnit()->CastSpell(GetCaster(), SPELL_FOCUS_FIRE_DUMMY); |
168 | 162 | } |
169 | 163 |
|
170 | | - uint32 FieryBlast_Timer; |
171 | | - bool fiery1, fiery2; |
| 164 | + void Register() override |
| 165 | + { |
| 166 | + OnEffectHitTarget += SpellEffectFn(spell_shirrak_ping_shirrak::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT); |
| 167 | + } |
| 168 | +}; |
172 | 169 |
|
173 | | - void Reset() override |
| 170 | +// 32264 - Inhibit Magic |
| 171 | +class spell_shirrak_inhibit_magic : public SpellScript |
| 172 | +{ |
| 173 | + PrepareSpellScript(spell_shirrak_inhibit_magic); |
| 174 | + |
| 175 | + void RemoveOldAura(SpellEffIndex /*effIndex*/) |
174 | 176 | { |
175 | | - Initialize(); |
| 177 | + GetHitUnit()->RemoveAurasDueToSpell(GetSpellInfo()->Id); |
176 | 178 | } |
177 | 179 |
|
178 | | - void UpdateAI(uint32 diff) override |
| 180 | + void TriggerNext() |
179 | 181 | { |
180 | | - //Return since we have no target |
181 | | - if (!UpdateVictim()) |
| 182 | + int32 castIndex = GetCastIndex(); |
| 183 | + if (castIndex >= 3) |
182 | 184 | return; |
183 | 185 |
|
184 | | - //FieryBlast_Timer |
185 | | - if (fiery2 && FieryBlast_Timer <= diff) |
186 | | - { |
187 | | - DoCast(me, SPELL_FIERY_BLAST); |
| 186 | + float radiusMod = GetSpellValue()->RadiusMod * 0.66f; |
188 | 187 |
|
189 | | - if (fiery1) fiery1 = false; |
190 | | - else if (fiery2) fiery2 = false; |
| 188 | + GetCaster()->CastSpell(nullptr, GetSpellInfo()->Id, CastSpellExtraArgs() |
| 189 | + .SetTriggerFlags(TRIGGERED_FULL_MASK) |
| 190 | + .AddSpellMod(SPELLVALUE_BASE_POINT1, castIndex + 1) |
| 191 | + .AddSpellMod(SPELLVALUE_RADIUS_MOD, int32(radiusMod * 10000))); |
| 192 | + } |
191 | 193 |
|
192 | | - FieryBlast_Timer = 1000; |
193 | | - } else FieryBlast_Timer -= diff; |
| 194 | + int32 GetCastIndex() const |
| 195 | + { |
| 196 | + // we are storing number of casts in a non-effect SPELLVALUE_BASE_POINT1 |
| 197 | + return GetSpellValue()->EffectBasePoints[EFFECT_1]; |
| 198 | + } |
194 | 199 |
|
195 | | - DoMeleeAttackIfReady(); |
| 200 | + void Register() override |
| 201 | + { |
| 202 | + if (!GetSpell() || GetCastIndex() == 0) |
| 203 | + OnEffectLaunchTarget += SpellEffectFn(spell_shirrak_inhibit_magic::RemoveOldAura, EFFECT_0, SPELL_EFFECT_APPLY_AURA); |
| 204 | + |
| 205 | + AfterCast += SpellCastFn(spell_shirrak_inhibit_magic::TriggerNext); |
196 | 206 | } |
197 | 207 | }; |
198 | 208 |
|
199 | 209 | void AddSC_boss_shirrak_the_dead_watcher() |
200 | 210 | { |
201 | 211 | RegisterAuchenaiCryptsCreatureAI(boss_shirrak_the_dead_watcher); |
202 | 212 | RegisterAuchenaiCryptsCreatureAI(npc_focus_fire); |
| 213 | + RegisterSpellScript(spell_shirrak_ping_shirrak); |
| 214 | + RegisterSpellScript(spell_shirrak_inhibit_magic); |
203 | 215 | } |
0 commit comments