TrinityCore
Loading...
Searching...
No Matches
pilgrims_bounty.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#include "ScriptMgr.h"
19#include "CreatureAIImpl.h"
20#include "Player.h"
21#include "ScriptedCreature.h"
22#include "SpellAuraEffects.h"
23#include "SpellScript.h"
24#include "Vehicle.h"
25
35
50
51/* 61784 - Feast On Turkey
52 61785 - Feast On Cranberries
53 61786 - Feast On Sweet Potatoes
54 61787 - Feast On Pie
55 61788 - Feast On Stuffing */
57{
59
60 void HandleDummy(SpellEffIndex /*effIndex*/)
61 {
62 Unit* caster = GetCaster();
63
64 uint32 _spellId = 0;
65 switch (GetSpellInfo()->Id)
66 {
67 case FEAST_ON_TURKEY:
68 _spellId = SPELL_TURKEY_HELPINS;
69 break;
71 _spellId = SPELL_CRANBERRY_HELPINS;
72 break;
75 break;
76 case FEAST_ON_PIE:
77 _spellId = SPELL_PIE_HELPINS;
78 break;
80 _spellId = SPELL_STUFFING_HELPINS;
81 break;
82 default:
83 return;
84 }
85
86 if (Vehicle* vehicle = caster->GetVehicleKit())
87 if (Unit* target = vehicle->GetPassenger(0))
88 if (Player* player = target->ToPlayer())
89 {
90 player->CastSpell(player, SPELL_ON_PLATE_EAT_VISUAL, true);
91 caster->CastSpell(player, _spellId, player->GetGUID());
92 }
93
94 if (Aura* aura = caster->GetAura(GetEffectValue()))
95 {
96 if (aura->GetStackAmount() == 1)
97 caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue());
98 aura->ModStackAmount(-1);
99 }
100 }
101
106};
107
117
118// 62014 - Turkey Tracker
120{
122
123 bool Validate(SpellInfo const* /*spell*/) override
124 {
126 }
127
128 void HandleScript(SpellEffIndex /*effIndex*/)
129 {
130 Creature* caster = GetCaster()->ToCreature();
131 Unit* target = GetHitUnit();
132
133 if (!target || !caster)
134 return;
135
137 return;
138
139 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
140 {
141 switch (aura->GetStackAmount())
142 {
143 case 10:
144 caster->AI()->Talk(EMOTE_TURKEY_HUNTER, target);
145 break;
146 case 20:
147 caster->AI()->Talk(EMOTE_TURKEY_DOMINATION, target);
148 break;
149 case 30:
150 caster->AI()->Talk(EMOTE_TURKEY_SLAUGHTER, target);
151 break;
152 case 40:
153 caster->AI()->Talk(EMOTE_TURKEY_TRIUMPH, target);
154 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL_MAX, true);
155 target->RemoveAurasDueToSpell(GetSpellInfo()->Id);
156 break;
157 default:
158 return;
159 }
160 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL, true);
161 }
162 }
163
168};
169
174
176{
178
180
181public:
182 spell_pilgrims_bounty_well_fed(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { }
183
184private:
185 bool Validate(SpellInfo const* /*spell*/) override
186 {
188 }
189
191 {
192 PreventHitDefaultEffect(effIndex);
193 Player* target = GetHitPlayer();
194 if (!target)
195 return;
196
197 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
198 {
199 if (aura->GetStackAmount() == 5)
200 target->CastSpell(target, _triggeredSpellId, true);
201 }
202
203 Aura const* turkey = target->GetAura(SPELL_TURKEY_HELPINS);
204 Aura const* cranberies = target->GetAura(SPELL_CRANBERRY_HELPINS);
205 Aura const* stuffing = target->GetAura(SPELL_STUFFING_HELPINS);
206 Aura const* sweetPotatoes = target->GetAura(SPELL_SWEET_POTATO_HELPINS);
207 Aura const* pie = target->GetAura(SPELL_PIE_HELPINS);
208
209 if ((turkey && turkey->GetStackAmount() == 5) && (cranberies && cranberies->GetStackAmount() == 5) && (stuffing && stuffing->GetStackAmount() == 5)
210 && (sweetPotatoes && sweetPotatoes->GetStackAmount() == 5) && (pie && pie->GetStackAmount() == 5))
211 {
212 target->CastSpell(target, SPELL_THE_SPIRIT_OF_SHARING, true);
218 }
219 }
220
225};
226
258
259/* 66250 - Pass The Turkey
260 66259 - Pass The Stuffing
261 66260 - Pass The Pie
262 66261 - Pass The Cranberries
263 66262 - Pass The Sweet Potatoes */
265{
267
272
273public:
274 spell_pilgrims_bounty_on_plate(uint32 triggeredSpellId1, uint32 triggeredSpellId2, uint32 triggeredSpellId3, uint32 triggeredSpellId4) : SpellScript(),
275 _triggeredSpellId1(triggeredSpellId1), _triggeredSpellId2(triggeredSpellId2), _triggeredSpellId3(triggeredSpellId3), _triggeredSpellId4(triggeredSpellId4) { }
276
277private:
278 bool Validate(SpellInfo const* /*spell*/) override
279 {
280 return ValidateSpellInfo(
281 {
286 });
287 }
288
290 {
291 if (target->GetTypeId() == TYPEID_PLAYER)
292 {
293 if (Unit* vehBase = target->GetVehicleBase())
294 if (Vehicle* table = vehBase->GetVehicle())
295 if (table->GetCreatureEntry() == NPC_BOUNTIFUL_TABLE)
296 return table;
297 }
298 else if (Vehicle* veh = target->GetVehicle())
299 if (veh->GetCreatureEntry() == NPC_BOUNTIFUL_TABLE)
300 return veh;
301
302 return nullptr;
303 }
304
306 {
307 if (Unit* holderUnit = table->GetPassenger(SEAT_PLATE_HOLDER))
308 if (Vehicle* holder = holderUnit->GetVehicleKit())
309 if (Unit* plate = holder->GetPassenger(seat))
310 return plate;
311
312 return nullptr;
313 }
314
315 void HandleDummy(SpellEffIndex /*effIndex*/)
316 {
317 Unit* caster = GetCaster();
318 Unit* target = GetHitUnit();
319 if (!target || caster == target)
320 return;
321
322 Vehicle* table = GetTable(caster);
323 if (!table || table != GetTable(target))
324 return;
325
326 if (Vehicle* casterChair = caster->GetVehicleKit())
327 if (Unit* casterPlr = casterChair->GetPassenger(SEAT_PLAYER))
328 {
329 if (casterPlr == target)
330 return;
331
332 casterPlr->CastSpell(casterPlr, _triggeredSpellId2, true); //Credit for Sharing is Caring(always)
333
334 uint8 seat = target->GetTransSeat();
335 if (target->GetTypeId() == TYPEID_PLAYER && target->GetVehicleBase())
336 seat = target->GetVehicleBase()->GetTransSeat();
337
338 if (Unit* plate = GetPlateInSeat(table, seat))
339 {
340 if (target->GetTypeId() == TYPEID_PLAYER) //Food Fight case
341 {
342 casterPlr->CastSpell(target, _triggeredSpellId1, true);
343 caster->CastSpell(target->GetVehicleBase(), _triggeredSpellId4, true); //CanEat-chair(always)
344 }
345 else
346 {
347 casterPlr->CastSpell(plate, _triggeredSpellId3, true); //Food Visual on plate
348 caster->CastSpell(target, _triggeredSpellId4, true); //CanEat-chair(always)
349 }
350 }
351 }
352 }
353
358};
359
360/* 61804 - A Serving of Cranberries
361 61805 - A Serving of Pie
362 61806 - A Serving of Stuffing
363 61807 - A Serving of Turkey
364 61808 - A Serving of Sweet Potatoes
365 61793 - Cranberry Server
366 61794 - Pie Server
367 61795 - Stuffing Server
368 61796 - Turkey Server
369 61797 - Sweet Potatoes Server */
371{
373
375
376public:
377 spell_pilgrims_bounty_a_serving_of(uint32 triggeredSpellId) : AuraScript(), _triggeredSpellId(triggeredSpellId) { }
378
379private:
380 bool Validate(SpellInfo const* /*spell*/) override
381 {
383 }
384
385 void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
386 {
387 Unit* target = GetTarget();
388 target->CastSpell(target, uint32(aurEff->GetAmount()), true);
389 HandlePlate(target, true);
390 }
391
392 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
393 {
394 Unit* target = GetTarget();
395 target->RemoveAurasDueToSpell(aurEff->GetAmount());
396 HandlePlate(target, false);
397 }
398
399 void HandlePlate(Unit* target, bool apply)
400 {
401 if (Vehicle* table = target->GetVehicle())
402 if (Unit* holderUnit = table->GetPassenger(SEAT_PLATE_HOLDER))
403 if (Vehicle* holder = holderUnit->GetVehicleKit())
404 if (Unit* plate = holder->GetPassenger(target->GetTransSeat()))
405 {
406 if (apply)
407 target->CastSpell(plate, _triggeredSpellId, true);
408 else
409 plate->RemoveAurasDueToSpell(_triggeredSpellId);
410 }
411 }
412
418};
419
421{
426 RegisterSpellScriptWithArgs(spell_pilgrims_bounty_well_fed, "spell_pilgrims_bounty_well_fed_sweet_potatoes", SPELL_WELL_FED_HASTE_TRIGGER);
439}
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1127
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
#define SpellEffectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
int32 GetAmount() const
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
uint8 GetStackAmount() const
Definition SpellAuras.h:164
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
CreatureAI * AI() const
Definition Creature.h:154
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
static Player * ToPlayer(Object *o)
Definition Object.h:180
Player * GetHitPlayer() const
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
SpellInfo const * GetSpellInfo() const
Definition Unit.h:769
Vehicle * GetVehicle() const
Definition Unit.h:1737
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4439
Unit * GetVehicleBase() const
Definition Unit.cpp:11826
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Vehicle * GetVehicleKit() const
Definition Unit.h:1735
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition Vehicle.cpp:296
int8 GetTransSeat() const
Definition Object.h:571
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *aurEff, AuraEffectHandleModes)
spell_pilgrims_bounty_a_serving_of(uint32 triggeredSpellId)
void HandlePlate(Unit *target, bool apply)
PrepareAuraScript(spell_pilgrims_bounty_a_serving_of)
void OnApply(AuraEffect const *aurEff, AuraEffectHandleModes)
PrepareSpellScript(spell_pilgrims_bounty_feast_on)
bool Validate(SpellInfo const *) override
spell_pilgrims_bounty_on_plate(uint32 triggeredSpellId1, uint32 triggeredSpellId2, uint32 triggeredSpellId3, uint32 triggeredSpellId4)
PrepareSpellScript(spell_pilgrims_bounty_on_plate)
Unit * GetPlateInSeat(Vehicle *table, uint8 seat)
Vehicle * GetTable(Unit *target)
PrepareSpellScript(spell_pilgrims_bounty_turkey_tracker)
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex effIndex)
PrepareSpellScript(spell_pilgrims_bounty_well_fed)
bool Validate(SpellInfo const *) override
spell_pilgrims_bounty_well_fed(uint32 triggeredSpellId)
PilgrimsBountyBuffFood
@ SPELL_WELL_FED_SPIRIT_TRIGGER
@ SPELL_WELL_FED_HIT_TRIGGER
@ SPELL_WELL_FED_ZM_TRIGGER
@ SPELL_WELL_FED_AP_TRIGGER
@ SPELL_WELL_FED_HASTE_TRIGGER
TheTurkinator
@ EMOTE_TURKEY_DOMINATION
@ SPELL_KILL_COUNTER_VISUAL_MAX
@ EMOTE_TURKEY_HUNTER
@ EMOTE_TURKEY_TRIUMPH
@ EMOTE_TURKEY_SLAUGHTER
@ SPELL_KILL_COUNTER_VISUAL
BountifulTableMisc
@ SPELL_A_SERVING_OF_PIE_PLATE
@ SEAT_PLAYER
@ SPELL_ON_PLATE_VISUAL_POTATOES
@ SPELL_A_SERVING_OF_STUFFING_CHAIR
@ SPELL_ON_PLATE_VISUAL_STUFFING
@ SPELL_PASS_THE_SWEET_POTATOES
@ SPELL_ON_PLATE_VISUAL_TURKEY
@ SPELL_ON_PLATE_SWEET_POTATOES
@ SPELL_PASS_THE_CRANBERRIES
@ SPELL_A_SERVING_OF_STUFFING_PLATE
@ SPELL_PASS_THE_TURKEY
@ SPELL_A_SERVING_OF_SWEET_POTATOES_CHAIR
@ SPELL_ON_PLATE_TURKEY
@ SPELL_A_SERVING_OF_CRANBERRIES_CHAIR
@ SPELL_A_SERVING_OF_TURKEY_CHAIR
@ SPELL_ON_PLATE_VISUAL_PIE
@ SPELL_A_SERVING_OF_SWEET_POTATOES_PLATE
@ SPELL_ON_PLATE_CRANBERRIES
@ SPELL_A_SERVING_OF_TURKEY_PLATE
@ SPELL_ON_PLATE_PIE
@ SPELL_PASS_THE_PIE
@ SEAT_PLATE_HOLDER
@ SPELL_PASS_THE_STUFFING
@ SPELL_A_SERVING_OF_CRANBERRIES_PLATE
@ NPC_BOUNTIFUL_TABLE
@ SPELL_ON_PLATE_STUFFING
@ SPELL_A_SERVING_OF_PIE_CHAIR
@ SPELL_ON_PLATE_VISUAL_CRANBERRIES
FeastOnSpells
@ FEAST_ON_TURKEY
@ SPELL_TURKEY_HELPINS
@ SPELL_ON_PLATE_EAT_VISUAL
@ FEAST_ON_CRANBERRIES
@ SPELL_SWEET_POTATO_HELPINS
@ SPELL_STUFFING_HELPINS
@ SPELL_CRANBERRY_HELPINS
@ FEAST_ON_SWEET_POTATOES
@ FEAST_ON_STUFFING
@ FEAST_ON_PIE
@ SPELL_PIE_HELPINS
SpiritOfSharing
@ SPELL_THE_SPIRIT_OF_SHARING
void AddSC_event_pilgrims_bounty()