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 "Creature.h"
20#include "CreatureAI.h"
21#include "Player.h"
22#include "SpellAuraEffects.h"
23#include "SpellMgr.h"
24#include "SpellScript.h"
25#include "Vehicle.h"
26
36
51
52/* 61784 - Feast On Turkey
53 61785 - Feast On Cranberries
54 61786 - Feast On Sweet Potatoes
55 61787 - Feast On Pie
56 61788 - Feast On Stuffing */
58{
59 bool Validate(SpellInfo const* spellInfo) override
60 {
61 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } })
63 }
64
65 void HandleDummy(SpellEffIndex /*effIndex*/)
66 {
67 Unit* caster = GetCaster();
68
69 uint32 _spellId = 0;
70 switch (GetSpellInfo()->Id)
71 {
72 case FEAST_ON_TURKEY:
73 _spellId = SPELL_TURKEY_HELPINS;
74 break;
76 _spellId = SPELL_CRANBERRY_HELPINS;
77 break;
80 break;
81 case FEAST_ON_PIE:
82 _spellId = SPELL_PIE_HELPINS;
83 break;
85 _spellId = SPELL_STUFFING_HELPINS;
86 break;
87 default:
88 return;
89 }
90
91 if (Vehicle* vehicle = caster->GetVehicleKit())
92 if (Unit* target = vehicle->GetPassenger(0))
93 if (Player* player = target->ToPlayer())
94 {
95 player->CastSpell(player, SPELL_ON_PLATE_EAT_VISUAL, true);
96 caster->CastSpell(player, _spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
97 .SetOriginalCaster(player->GetGUID()));
98 }
99
100 if (Aura* aura = caster->GetAura(GetEffectValueAsInt()))
101 {
102 if (aura->GetStackAmount() == 1)
103 caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt());
104 aura->ModStackAmount(-1);
105 }
106 }
107
112};
113
123
124// 62014 - Turkey Tracker
126{
127 bool Validate(SpellInfo const* /*spell*/) override
128 {
130 }
131
132 void HandleScript(SpellEffIndex /*effIndex*/)
133 {
134 Creature* caster = GetCaster()->ToCreature();
135 Unit* target = GetHitUnit();
136
137 if (!target || !caster)
138 return;
139
141 return;
142
143 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
144 {
145 switch (aura->GetStackAmount())
146 {
147 case 10:
148 caster->AI()->Talk(EMOTE_TURKEY_HUNTER, target);
149 break;
150 case 20:
151 caster->AI()->Talk(EMOTE_TURKEY_DOMINATION, target);
152 break;
153 case 30:
154 caster->AI()->Talk(EMOTE_TURKEY_SLAUGHTER, target);
155 break;
156 case 40:
157 caster->AI()->Talk(EMOTE_TURKEY_TRIUMPH, target);
158 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL_MAX, true);
159 target->RemoveAurasDueToSpell(GetSpellInfo()->Id);
160 break;
161 default:
162 return;
163 }
164 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL, true);
165 }
166 }
167
172};
173
178
180{
182
183public:
184 spell_pilgrims_bounty_well_fed(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { }
185
186private:
187 bool Validate(SpellInfo const* /*spell*/) override
188 {
190 }
191
193 {
194 PreventHitDefaultEffect(effIndex);
195 Player* target = GetHitPlayer();
196 if (!target)
197 return;
198
199 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
200 {
201 if (aura->GetStackAmount() == 5)
202 target->CastSpell(target, _triggeredSpellId, true);
203 }
204
205 Aura const* turkey = target->GetAura(SPELL_TURKEY_HELPINS);
206 Aura const* cranberies = target->GetAura(SPELL_CRANBERRY_HELPINS);
207 Aura const* stuffing = target->GetAura(SPELL_STUFFING_HELPINS);
208 Aura const* sweetPotatoes = target->GetAura(SPELL_SWEET_POTATO_HELPINS);
209 Aura const* pie = target->GetAura(SPELL_PIE_HELPINS);
210
211 if ((turkey && turkey->GetStackAmount() == 5) && (cranberies && cranberies->GetStackAmount() == 5) && (stuffing && stuffing->GetStackAmount() == 5)
212 && (sweetPotatoes && sweetPotatoes->GetStackAmount() == 5) && (pie && pie->GetStackAmount() == 5))
213 {
214 target->CastSpell(target, SPELL_THE_SPIRIT_OF_SHARING, true);
220 }
221 }
222
227};
228
260
261/* 66250 - Pass The Turkey
262 66259 - Pass The Stuffing
263 66260 - Pass The Pie
264 66261 - Pass The Cranberries
265 66262 - Pass The Sweet Potatoes */
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
374public:
375 spell_pilgrims_bounty_a_serving_of(uint32 triggeredSpellId) : AuraScript(), _triggeredSpellId(triggeredSpellId) { }
376
377private:
378 bool Validate(SpellInfo const* /*spell*/) override
379 {
381 }
382
383 void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
384 {
385 Unit* target = GetTarget();
386 target->CastSpell(target, uint32(aurEff->GetAmountAsInt()), true);
387 HandlePlate(target, true);
388 }
389
390 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
391 {
392 Unit* target = GetTarget();
393 target->RemoveAurasDueToSpell(aurEff->GetAmountAsInt());
394 HandlePlate(target, false);
395 }
396
397 void HandlePlate(Unit* target, bool apply)
398 {
399 if (Vehicle* table = target->GetVehicle())
400 if (Unit* holderUnit = table->GetPassenger(SEAT_PLATE_HOLDER))
401 if (Vehicle* holder = holderUnit->GetVehicleKit())
402 if (Unit* plate = holder->GetPassenger(target->GetTransSeat()))
403 {
404 if (apply)
405 target->CastSpell(plate, _triggeredSpellId, true);
406 else
407 plate->RemoveAurasDueToSpell(_triggeredSpellId);
408 }
409 }
410
416};
417
419{
424 RegisterSpellScriptWithArgs(spell_pilgrims_bounty_well_fed, "spell_pilgrims_bounty_well_fed_sweet_potatoes", SPELL_WELL_FED_HASTE_TRIGGER);
437}
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1382
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
#define SpellEffectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
int32 GetAmountAsInt() const
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
uint8 GetStackAmount() const
Definition SpellAuras.h:238
TypeID GetTypeId() const
Definition BaseEntity.h:166
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
CreatureAI * AI() const
Definition Creature.h:235
Player * ToPlayer()
Definition Object.h:126
Creature * ToCreature()
Definition Object.h:121
int32 CalcValueAsInt(WorldObject const *caster=nullptr, SpellEffectValue const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:590
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Player * GetHitPlayer() const
Unit * GetCaster() const
int32 GetEffectValueAsInt() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellInfo const * GetSpellInfo() const
Definition Unit.h:647
Vehicle * GetVehicle() const
Definition Unit.h:1800
Unit * GetVehicleBase() const
Definition Unit.cpp:12206
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4718
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4822
Vehicle * GetVehicleKit() const
Definition Unit.h:1798
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition Vehicle.cpp:303
int8 GetTransSeat() const
Definition Object.h:544
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
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)
void OnApply(AuraEffect const *aurEff, AuraEffectHandleModes)
bool Validate(SpellInfo const *spellInfo) override
bool Validate(SpellInfo const *) override
spell_pilgrims_bounty_on_plate(uint32 triggeredSpellId1, uint32 triggeredSpellId2, uint32 triggeredSpellId3, uint32 triggeredSpellId4)
Unit * GetPlateInSeat(Vehicle *table, uint8 seat)
Vehicle * GetTable(Unit *target)
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex effIndex)
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()