TrinityCore
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
28{
29 // Pilgrims Bounty Buff Food
35};
36
38{
40
41public:
42 spell_pilgrims_bounty_buff_food(uint32 triggeredSpellId) : AuraScript(), _triggeredSpellId(triggeredSpellId)
43 {
44 _handled = false;
45 }
46
47 void HandleTriggerSpell(AuraEffect const* /*aurEff*/)
48 {
50 if (_handled)
51 return;
52
53 _handled = true;
55 }
56
57 void Register() override
58 {
60 }
61
63};
64
66{
70 FEAST_ON_PIE = 61787,
78};
79
80/* 61784 - Feast On Turkey
81 61785 - Feast On Cranberries
82 61786 - Feast On Sweet Potatoes
83 61787 - Feast On Pie
84 61788 - Feast On Stuffing */
86{
87 bool Validate(SpellInfo const* spellInfo) override
88 {
89 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } })
91 }
92
93 void HandleDummy(SpellEffIndex /*effIndex*/)
94 {
95 Unit* caster = GetCaster();
96
97 uint32 _spellId = 0;
98 switch (GetSpellInfo()->Id)
99 {
100 case FEAST_ON_TURKEY:
101 _spellId = SPELL_TURKEY_HELPINS;
102 break;
104 _spellId = SPELL_CRANBERRY_HELPINS;
105 break;
108 break;
109 case FEAST_ON_PIE:
110 _spellId = SPELL_PIE_HELPINS;
111 break;
113 _spellId = SPELL_STUFFING_HELPINS;
114 break;
115 default:
116 return;
117 }
118
119 if (Vehicle* vehicle = caster->GetVehicleKit())
120 if (Unit* target = vehicle->GetPassenger(0))
121 if (Player* player = target->ToPlayer())
122 {
123 player->CastSpell(player, SPELL_ON_PLATE_EAT_VISUAL, true);
124 caster->CastSpell(player, _spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK)
125 .SetOriginalCaster(player->GetGUID()));
126 }
127
128 if (Aura* aura = caster->GetAura(GetEffectValue()))
129 {
130 if (aura->GetStackAmount() == 1)
131 caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue());
132 aura->ModStackAmount(-1);
133 }
134 }
135
136 void Register() override
137 {
139 }
140};
141
143{
151
152// 62014 - Turkey Tracker
154{
155 bool Validate(SpellInfo const* /*spell*/) override
156 {
158 }
159
160 void HandleScript(SpellEffIndex /*effIndex*/)
161 {
162 Creature* caster = GetCaster()->ToCreature();
163 Unit* target = GetHitUnit();
164
165 if (!target || !caster)
166 return;
167
169 return;
170
171 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
172 {
173 switch (aura->GetStackAmount())
174 {
175 case 10:
176 caster->AI()->Talk(EMOTE_TURKEY_HUNTER, target);
177 break;
178 case 20:
179 caster->AI()->Talk(EMOTE_TURKEY_DOMINATION, target);
180 break;
181 case 30:
182 caster->AI()->Talk(EMOTE_TURKEY_SLAUGHTER, target);
183 break;
184 case 40:
185 caster->AI()->Talk(EMOTE_TURKEY_TRIUMPH, target);
186 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL_MAX, true);
187 target->RemoveAurasDueToSpell(GetSpellInfo()->Id);
188 break;
189 default:
190 return;
191 }
192 target->CastSpell(target, SPELL_KILL_COUNTER_VISUAL, true);
193 }
194 }
195
196 void Register() override
197 {
199 }
200};
201
203{
206
208{
210
211public:
212 spell_pilgrims_bounty_well_fed(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { }
213
214private:
215 bool Validate(SpellInfo const* /*spell*/) override
216 {
218 }
219
221 {
222 PreventHitDefaultEffect(effIndex);
223 Player* target = GetHitPlayer();
224 if (!target)
225 return;
226
227 if (Aura const* aura = target->GetAura(GetSpellInfo()->Id))
228 {
229 if (aura->GetStackAmount() == 5)
230 target->CastSpell(target, _triggeredSpellId, true);
231 }
232
233 Aura const* turkey = target->GetAura(SPELL_TURKEY_HELPINS);
234 Aura const* cranberies = target->GetAura(SPELL_CRANBERRY_HELPINS);
235 Aura const* stuffing = target->GetAura(SPELL_STUFFING_HELPINS);
236 Aura const* sweetPotatoes = target->GetAura(SPELL_SWEET_POTATO_HELPINS);
237 Aura const* pie = target->GetAura(SPELL_PIE_HELPINS);
238
239 if ((turkey && turkey->GetStackAmount() == 5) && (cranberies && cranberies->GetStackAmount() == 5) && (stuffing && stuffing->GetStackAmount() == 5)
240 && (sweetPotatoes && sweetPotatoes->GetStackAmount() == 5) && (pie && pie->GetStackAmount() == 5))
241 {
242 target->CastSpell(target, SPELL_THE_SPIRIT_OF_SHARING, true);
248 }
249 }
250
251 void Register() override
252 {
254 }
255};
256
258{
288
289/* 66250 - Pass The Turkey
290 66259 - Pass The Stuffing
291 66260 - Pass The Pie
292 66261 - Pass The Cranberries
293 66262 - Pass The Sweet Potatoes */
295{
300
301public:
302 spell_pilgrims_bounty_on_plate(uint32 triggeredSpellId1, uint32 triggeredSpellId2, uint32 triggeredSpellId3, uint32 triggeredSpellId4) : SpellScript(),
303 _triggeredSpellId1(triggeredSpellId1), _triggeredSpellId2(triggeredSpellId2), _triggeredSpellId3(triggeredSpellId3), _triggeredSpellId4(triggeredSpellId4) { }
304
305private:
306 bool Validate(SpellInfo const* /*spell*/) override
307 {
308 return ValidateSpellInfo(
309 {
314 });
315 }
316
318 {
319 if (target->GetTypeId() == TYPEID_PLAYER)
320 {
321 if (Unit* vehBase = target->GetVehicleBase())
322 if (Vehicle* table = vehBase->GetVehicle())
323 if (table->GetCreatureEntry() == NPC_BOUNTIFUL_TABLE)
324 return table;
325 }
326 else if (Vehicle* veh = target->GetVehicle())
327 if (veh->GetCreatureEntry() == NPC_BOUNTIFUL_TABLE)
328 return veh;
329
330 return nullptr;
331 }
332
334 {
335 if (Unit* holderUnit = table->GetPassenger(SEAT_PLATE_HOLDER))
336 if (Vehicle* holder = holderUnit->GetVehicleKit())
337 if (Unit* plate = holder->GetPassenger(seat))
338 return plate;
339
340 return nullptr;
341 }
342
343 void HandleDummy(SpellEffIndex /*effIndex*/)
344 {
345 Unit* caster = GetCaster();
346 Unit* target = GetHitUnit();
347 if (!target || caster == target)
348 return;
349
350 Vehicle* table = GetTable(caster);
351 if (!table || table != GetTable(target))
352 return;
353
354 if (Vehicle* casterChair = caster->GetVehicleKit())
355 if (Unit* casterPlr = casterChair->GetPassenger(SEAT_PLAYER))
356 {
357 if (casterPlr == target)
358 return;
359
360 casterPlr->CastSpell(casterPlr, _triggeredSpellId2, true); //Credit for Sharing is Caring(always)
361
362 uint8 seat = target->GetTransSeat();
363 if (target->GetTypeId() == TYPEID_PLAYER && target->GetVehicleBase())
364 seat = target->GetVehicleBase()->GetTransSeat();
365
366 if (Unit* plate = GetPlateInSeat(table, seat))
367 {
368 if (target->GetTypeId() == TYPEID_PLAYER) //Food Fight case
369 {
370 casterPlr->CastSpell(target, _triggeredSpellId1, true);
371 caster->CastSpell(target->GetVehicleBase(), _triggeredSpellId4, true); //CanEat-chair(always)
372 }
373 else
374 {
375 casterPlr->CastSpell(plate, _triggeredSpellId3, true); //Food Visual on plate
376 caster->CastSpell(target, _triggeredSpellId4, true); //CanEat-chair(always)
377 }
378 }
379 }
380 }
381
382 void Register() override
383 {
385 }
386};
387
388/* 61804 - A Serving of Cranberries
389 61805 - A Serving of Pie
390 61806 - A Serving of Stuffing
391 61807 - A Serving of Turkey
392 61808 - A Serving of Sweet Potatoes
393 61793 - Cranberry Server
394 61794 - Pie Server
395 61795 - Stuffing Server
396 61796 - Turkey Server
397 61797 - Sweet Potatoes Server */
399{
401
402public:
403 spell_pilgrims_bounty_a_serving_of(uint32 triggeredSpellId) : AuraScript(), _triggeredSpellId(triggeredSpellId) { }
404
405private:
406 bool Validate(SpellInfo const* /*spell*/) override
407 {
409 }
410
411 void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
412 {
413 Unit* target = GetTarget();
414 target->CastSpell(target, uint32(aurEff->GetAmount()), true);
415 HandlePlate(target, true);
416 }
417
418 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
419 {
420 Unit* target = GetTarget();
421 target->RemoveAurasDueToSpell(aurEff->GetAmount());
422 HandlePlate(target, false);
423 }
424
425 void HandlePlate(Unit* target, bool apply)
426 {
427 if (Vehicle* table = target->GetVehicle())
428 if (Unit* holderUnit = table->GetPassenger(SEAT_PLATE_HOLDER))
429 if (Vehicle* holder = holderUnit->GetVehicleKit())
430 if (Unit* plate = holder->GetPassenger(target->GetTransSeat()))
431 {
432 if (apply)
433 target->CastSpell(plate, _triggeredSpellId, true);
434 else
435 plate->RemoveAurasDueToSpell(_triggeredSpellId);
436 }
437 }
438
439 void Register() override
440 {
443 }
444};
445
447{
457 RegisterSpellScriptWithArgs(spell_pilgrims_bounty_well_fed, "spell_pilgrims_bounty_well_fed_sweet_potatoes", SPELL_WELL_FED_HASTE_TRIGGER);
470}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition: ScriptMgr.h:1368
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ EFFECT_2
Definition: SharedDefines.h:32
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
Definition: SpellScript.h:2035
uint8 GetStackAmount() const
Definition: SpellAuras.h:189
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
CreatureAI * AI() const
Definition: Creature.h:214
static Creature * ToCreature(Object *o)
Definition: Object.h:219
TypeID GetTypeId() const
Definition: Object.h:173
static Player * ToPlayer(Object *o)
Definition: Object.h:213
int32 CalcValue(WorldObject const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:495
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
Player * GetHitPlayer() const
Unit * GetCaster() const
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellInfo const * GetSpellInfo() const
Definition: Unit.h:627
Vehicle * GetVehicle() const
Definition: Unit.h:1713
Unit * GetVehicleBase() const
Definition: Unit.cpp:11480
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4560
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
Vehicle * GetVehicleKit() const
Definition: Unit.h:1711
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition: Vehicle.cpp:291
int8 GetTransSeat() const
Definition: Object.h:757
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
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)
spell_pilgrims_bounty_buff_food(uint32 triggeredSpellId)
void HandleTriggerSpell(AuraEffect const *)
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)
void apply(T *val)
Definition: ByteConverter.h:41
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()