Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_rogue.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/*
7 * Scripts for spells with SPELLFAMILY_ROGUE and SPELLFAMILY_GENERIC spells used by rogue players.
8 * Ordered alphabetically using scriptname.
9 * Scriptnames of files in this file should be prefixed with "spell_rog_".
10 */
11
12#include "Player.h"
13#include "ScriptMgr.h"
14#include "SpellScript.h"
15#include "SpellAuraEffects.h"
16
30
35
36// 13877, 33735, (check 51211, 65956) - Blade Flurry
38{
39public:
40 spell_rog_blade_flurry() : SpellScriptLoader("spell_rog_blade_flurry") { }
41
43 {
45
46 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
47 {
49 return false;
50 return true;
51 }
52
54 {
55 _procTarget = NULL;
56 return true;
57 }
58
59 bool CheckProc(ProcEventInfo& eventInfo)
60 {
62 return _procTarget && eventInfo.GetDamageInfo();
63 }
64
65 void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
66 {
68
69 SF_LOG_ERROR("misc", "damage: %u procSpell: %u",
70 eventInfo.GetDamageInfo()->GetDamage(), eventInfo.GetDamageInfo()->GetSpellInfo() ? eventInfo.GetDamageInfo()->GetSpellInfo()->Id : 0);
71
73 }
74
83
84 private:
86 };
87
92};
93
94// 31228 - Cheat Death
96{
97public:
98 spell_rog_cheat_death() : SpellScriptLoader("spell_rog_cheat_death") { }
99
101 {
103
105
106 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
107 {
109 return false;
110 return true;
111 }
112
114 {
116 return GetUnitOwner()->ToPlayer();
117 }
118
119 void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
120 {
121 // Set absorbtion amount to unlimited
122 amount = -1;
123 }
124
125 void Absorb(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount)
126 {
127 Player* target = GetTarget()->ToPlayer();
129 return;
130
131 target->CastSpell(target, SPELL_ROGUE_CHEAT_DEATH_COOLDOWN, true);
132 target->AddSpellCooldown(SPELL_ROGUE_CHEAT_DEATH_COOLDOWN, 0, time(NULL) + 60);
133
134 uint32 health10 = target->CountPctFromMaxHealth(10);
135
136 // hp > 10% - absorb hp till 10%
137 if (target->GetHealth() > health10)
138 absorbAmount = dmgInfo.GetDamage() - target->GetHealth() + health10;
139 // hp lower than 10% - absorb everything
140 else
141 absorbAmount = dmgInfo.GetDamage();
142 }
143
149 };
150
155};
156
157// -51625 - Deadly Brew
159{
160public:
161 spell_rog_crippling_poison() : SpellScriptLoader("spell_rog_crippling_poison") { }
162
164 {
166
167 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
168 {
169 if (!sSpellMgr->GetSpellInfo(SPELL_ROGUE_CRIPPLING_POISON))
170 return false;
171 return true;
172 }
173
174 void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
175 {
177 GetTarget()->CastSpell(eventInfo.GetProcTarget(), SPELL_ROGUE_CRIPPLING_POISON, true, NULL, aurEff);
178 }
179
184 };
185
190};
191
192// -51664 - Cut to the Chase
194{
195public:
196 spell_rog_cut_to_the_chase() : SpellScriptLoader("spell_rog_cut_to_the_chase") { }
197
199 {
201
202 void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
203 {
206 aur->SetDuration(aur->GetSpellInfo()->GetMaxDuration(), true);
207 }
208
213 };
214
219};
220
221// 2818 - Deadly Poison
223{
224public:
225 spell_rog_deadly_poison() : SpellScriptLoader("spell_rog_deadly_poison") { }
226
228 {
230
232 {
233 _stackAmount = 0;
234 // at this point CastItem must already be initialized
236 }
237
239 {
240 if (Unit* target = GetHitUnit())
241 // Deadly Poison
242 if (AuraEffect const* aurEff = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x10000, 0x80000, 0, GetCaster()->GetGUID()))
243 _stackAmount = aurEff->GetBase()->GetStackAmount();
244 }
245
247 {
248 if (_stackAmount < 5)
249 return;
250
251 Player* player = GetCaster()->ToPlayer();
252
253 if (Unit* target = GetHitUnit())
254 {
256
257 if (item == GetCastItem())
259
260 if (!item)
261 return;
262
263 // item combat enchantments
264 for (uint8 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot)
265 {
266 if (slot > PRISMATIC_ENCHANTMENT_SLOT&& slot < PROP_ENCHANTMENT_SLOT_0) // not holding enchantment id
267 continue;
268
270 if (!enchant)
271 continue;
272
273 for (uint8 s = 0; s < 3; ++s)
274 {
275 if (enchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
276 continue;
277
278 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchant->spellid[s]);
279 if (!spellInfo)
280 {
281 SF_LOG_ERROR("spells", "Player::CastItemCombatSpell Enchant %i, player (Name: %s, GUID: %u) cast unknown spell %i", enchant->ID, player->GetName().c_str(), player->GetGUIDLow(), enchant->spellid[s]);
282 continue;
283 }
284
285 // Proc only rogue poisons
286 if (spellInfo->SpellFamilyName != SPELLFAMILY_ROGUE || spellInfo->Dispel != DISPEL_POISON)
287 continue;
288
289 // Do not reproc deadly
290 if (spellInfo->SpellFamilyFlags.IsEqual(0x10000, 0x80000, 0))
291 continue;
292
293 if (spellInfo->IsPositive())
294 player->CastSpell(player, enchant->spellid[s], true, item);
295 else
296 player->CastSpell(target, enchant->spellid[s], true, item);
297 }
298 }
299 }
300 }
301
307
309 };
310
315};
316
317// 31666 - Master of Subtlety
353
354// 73651 - Recuperate
356{
357public:
358 spell_rog_recuperate() : SpellScriptLoader("spell_rog_recuperate") { }
359
361 {
363
365 {
367 }
368
369 void OnPeriodic(AuraEffect const* /*aurEff*/)
370 {
371 if (Unit* caster = GetCaster())
372 if (AuraEffect* effect = GetAura()->GetEffect(EFFECT_0))
373 effect->RecalculateAmount(caster);
374 }
375
376 void CalculateBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
377 {
378 canBeRecalculated = false;
379 if (Unit* caster = GetCaster())
380 {
381 int32 baseAmount = GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster) * 1000;
382 // Improved Recuperate
383 if (AuraEffect const* auraEffect = caster->GetDummyAuraEffect(SPELLFAMILY_ROGUE, ICON_ROGUE_IMPROVED_RECUPERATE, EFFECT_0))
384 baseAmount += auraEffect->GetAmount();
385
386 amount = CalculatePct(caster->GetMaxHealth(), float(baseAmount) / 1000.0f);
387 }
388 }
389
395 };
396
398 {
400 }
401};
402
403// 1943 - Rupture
405{
406public:
407 spell_rog_rupture() : SpellScriptLoader("spell_rog_rupture") { }
408
410 {
412
414 {
415 Unit* caster = GetCaster();
416 return caster && caster->GetTypeId() == TypeID::TYPEID_PLAYER;
417 }
418
419 void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
420 {
421 if (Unit* caster = GetCaster())
422 {
423 canBeRecalculated = false;
424
425 float const attackpowerPerCombo[6] =
426 {
427 0.0f,
428 0.015f, // 1 point: ${($m1 + $b1*1 + 0.015 * $AP) * 4} damage over 8 secs
429 0.024f, // 2 points: ${($m1 + $b1*2 + 0.024 * $AP) * 5} damage over 10 secs
430 0.03f, // 3 points: ${($m1 + $b1*3 + 0.03 * $AP) * 6} damage over 12 secs
431 0.03428571f, // 4 points: ${($m1 + $b1*4 + 0.03428571 * $AP) * 7} damage over 14 secs
432 0.0375f // 5 points: ${($m1 + $b1*5 + 0.0375 * $AP) * 8} damage over 16 secs
433 };
434
435 uint8 cp = caster->ToPlayer()->GetComboPoints();
436 if (cp > 5)
437 cp = 5;
438
439 amount += int32(caster->GetTotalAttackPowerValue(WeaponAttackType::BASE_ATTACK) * attackpowerPerCombo[cp]);
440 }
441 }
442
447 };
448
450 {
451 return new spell_rog_rupture_AuraScript();
452 }
453};
454
455// 1784 - Stealth
457{
458public:
459 spell_rog_stealth() : SpellScriptLoader("spell_rog_stealth") { }
460
462 {
464
465 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
466 {
470 return false;
471 return true;
472 }
473
474 void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
475 {
476 Unit* target = GetTarget();
477
478 // Master of Subtlety
480 {
481 int32 basepoints0 = aurEff->GetAmount();
482 target->CastCustomSpell(target, SPELL_ROGUE_MASTER_OF_SUBTLETY_DAMAGE_PERCENT, &basepoints0, NULL, NULL, true);
483 }
484 }
485
486 void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
487 {
488 Unit* target = GetTarget();
489
490 // Master of subtlety
493 }
494
500 };
501
503 {
504 return new spell_rog_stealth_AuraScript();
505 }
506};
507
508// 57934 - Tricks of the Trade
510{
511public:
512 spell_rog_tricks_of_the_trade() : SpellScriptLoader("spell_rog_tricks_of_the_trade") { }
513
515 {
517
518 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
519 {
521 return false;
523 return false;
524 return true;
525 }
526
528 {
529 _redirectTarget = NULL;
530 return true;
531 }
532
533 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
534 {
535 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT)
537 }
538
539 bool CheckProc(ProcEventInfo& /*eventInfo*/)
540 {
542 return _redirectTarget;
543 }
544
545 void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
546 {
548
549 Unit* target = GetTarget();
551 target->CastSpell(target, SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC, true);
552 Remove(AURA_REMOVE_BY_DEFAULT); // maybe handle by proc charges
553 }
554
561
562 private:
564 };
565
570};
571
572// 59628 - Tricks of the Trade (Proc)
598
@ ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL
Definition DBCEnums.h:410
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
EnchantmentSlot
Definition Item.h:149
@ PROP_ENCHANTMENT_SLOT_0
Definition Item.h:160
@ MAX_ENCHANTMENT_SLOT
Definition Item.h:165
@ PRISMATIC_ENCHANTMENT_SLOT
Definition Item.h:156
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
@ TYPEID_PLAYER
Definition Object.h:55
@ EQUIPMENT_SLOT_MAINHAND
Definition Player.h:704
@ EQUIPMENT_SLOT_OFFHAND
Definition Player.h:705
#define INVENTORY_SLOT_BAG_0
Definition Player.h:684
@ EFFECT_1
@ EFFECT_0
@ SPELLFAMILY_ROGUE
@ DISPEL_POISON
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_MOD_SHAPESHIFT
@ SPELL_AURA_MOD_MELEE_HASTE
@ SPELL_AURA_PERIODIC_HEAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_SCHOOL_ABSORB
@ SPELL_AURA_MOD_POWER_REGEN_PERCENT
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_MOD_STEALTH
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define AuraEffectProcFn(F, I, N)
#define AuraEffectCalcAmountFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectAbsorbFn(F, I)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraCheckProcFn(F)
#define SpellHitFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
@ SPELLVALUE_BASE_POINT0
Definition Unit.h:114
@ AURA_REMOVE_BY_DEFAULT
Definition Unit.h:407
bool roll_chance_i(int chance)
Definition Util.h:89
T CalculatePct(T base, U pct)
Definition Util.h:103
uint32 m_scriptSpellId
Definition SpellScript.h:95
void PreventDefaultAction()
void Remove(uint32 removeMode=0)
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
SpellInfo const * GetSpellInfo() const
HookList< EffectApplyHandler > AfterEffectApply
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Unit * GetCaster() const
AuraEffect * GetEffect(uint8 effIndex) const
HookList< EffectAbsorbHandler > OnEffectAbsorb
Aura * GetAura() const
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
HookList< EffectProcHandler > OnEffectProc
Unit * GetUnitOwner() const
SpellInfo const * GetSpellInfo() const
Definition Unit.h:907
uint32 GetDamage() const
Definition Unit.h:923
Definition Item.h:202
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition Item.h:287
Player * ToPlayer()
Definition Object.h:204
uint32 GetGUIDLow() const
Definition Object.h:120
TypeID GetTypeId() const
Definition Object.h:131
bool HasSpellCooldown(uint32 spell_id) const
Definition Player.cpp:17498
Item * GetItemByPos(uint16 pos) const
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time)
Definition Player.cpp:17633
DamageInfo * GetDamageInfo() const
Definition Unit.h:985
Unit * GetProcTarget() const
Definition Unit.h:974
int32 CalcValue(Unit const *caster=NULL, int32 const *basePoints=NULL, Unit const *target=NULL) const
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
uint32 Id
Definition SpellInfo.h:160
uint32 Dispel
Definition SpellInfo.h:162
flag128 SpellFamilyFlags
Definition SpellInfo.h:227
bool IsPositive() const
uint32 SpellFamilyName
Definition SpellInfo.h:226
HookList< HitHandler > AfterHit
Item * GetCastItem()
Unit * GetHitUnit()
Unit * GetCaster()
HookList< HitHandler > BeforeHit
SpellScriptLoader(const char *name)
Definition Unit.h:1367
Unit * SelectNearbyTarget(Unit *exclude=NULL, float dist=NOMINAL_MELEE_RANGE) const
Definition Unit.cpp:6043
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
Unit * GetRedirectThreatTarget()
Definition Unit.cpp:7158
uint32 GetHealth() const
Definition Unit.h:1600
bool HasAuraType(AuraType auraType) const
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 casterGUID=0) const
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void ResetRedirectThreat()
Definition Unit.h:2720
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:1633
std::string const & GetName() const
Definition Object.h:664
bool IsEqual(uint32 p1=0, uint32 p2=0, uint32 p3=0, uint32 p4=0) const
Definition Util.h:421
void HandleProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
PrepareAuraScript(spell_rog_blade_flurry_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
PrepareAuraScript(spell_rog_cheat_death_AuraScript)
void CalculateAmount(AuraEffect const *, int32 &amount, bool &)
void Absorb(AuraEffect *, DamageInfo &dmgInfo, uint32 &absorbAmount)
AuraScript * GetAuraScript() const OVERRIDE
void OnProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
PrepareAuraScript(spell_rog_crippling_poison_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
PrepareAuraScript(spell_rog_cut_to_the_chase_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_rog_deadly_poison_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const
void CalculateBonus(AuraEffect const *, int32 &amount, bool &canBeRecalculated)
PrepareAuraScript(spell_rog_recuperate_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
PrepareAuraScript(spell_rog_rupture_AuraScript)
void CalculateAmount(AuraEffect const *, int32 &amount, bool &canBeRecalculated)
AuraScript * GetAuraScript() const OVERRIDE
PrepareAuraScript(spell_rog_stealth_AuraScript)
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
void HandleEffectRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
AuraScript * GetAuraScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
void AddSC_rogue_spell_scripts()
@ SPELL_ROGUE_TRICKS_OF_THE_TRADE_PROC
@ SPELL_ROGUE_SLICE_AND_DICE
@ SPELL_ROGUE_TRICKS_OF_THE_TRADE_DMG_BOOST
@ SPELL_ROGUE_BLADE_FLURRY
@ SPELL_ROGUE_MASTER_OF_SUBTLETY_PASSIVE
@ SPELL_ROGUE_CRIPPLING_POISON
@ SPELL_ROGUE_MASTER_OF_SUBTLETY_PERIODIC
@ SPELL_ROGUE_CHEAT_DEATH_COOLDOWN
@ SPELL_ROGUE_MASTER_OF_SUBTLETY_DAMAGE_PERCENT
@ SPELL_ROGUE_BLADE_FLURRY_EXTRA_ATTACK
RogueSpellIcons
@ ICON_ROGUE_IMPROVED_RECUPERATE
uint32 type[MAX_ITEM_ENCHANTMENT_EFFECTS]
uint32 ID
uint32 spellid[MAX_ITEM_ENCHANTMENT_EFFECTS]