Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 94.08 KB | None | 0 0
  1. #include "Player.h"
  2. #include "ScriptMgr.h"
  3. #include "SpellScript.h"
  4. #include "SpellAuraEffects.h"
  5. #include "Containers.h"
  6.  
  7. enum DruidSpells
  8. {
  9. SPELL_DRUID_NPC_WILD_MUSHROOM = 47649,
  10. SPELL_DRUID_FUNGAL_GROWTH_GRAPHIC = 94339 ,
  11. SPELL_DRUID_FUNGAL_GROWTH_SUMMON = 81291 ,
  12. SPELL_DRUID_SPELL_WILD_MUSHROOM_SUICIDE = 92853,
  13. SPELL_DRUID_SPELL_WILD_MUSHROOM_DAMAGE = 78777,
  14. SPELL_DRUID_MOONFIRE = 8921,
  15. SPELL_DRUID_SUNFIRE = 93402,
  16. SPELL_DRUID_WRATH = 5176,
  17. SPELL_DRUID_STARFIRE = 2912,
  18. SPELL_DRUID_STARSURGE = 78674,
  19. SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE = 89265,
  20. SPELL_DRUID_STARSURGE_ENERGIZE = 86605,
  21. SPELL_DRUID_LUNAR_ECLIPSE_MARKER = 67484, // Will make the yellow arrow on eclipse bar point to the blue side (lunar)
  22. SPELL_DRUID_SOLAR_ECLIPSE_MARKER = 67483, // Will make the yellow arrow on eclipse bar point to the yellow side (solar)
  23. SPELL_DRUID_SOLAR_ECLIPSE = 48517,
  24. SPELL_DRUID_LUNAR_ECLIPSE = 48518,
  25. SPELL_DRUID_ENRAGE_MOD_DAMAGE = 51185,
  26. SPELL_DRUID_GLYPH_OF_TYPHOON = 62135,
  27. SPELL_DRUID_IDOL_OF_FERAL_SHADOWS = 34241,
  28. SPELL_DRUID_IDOL_OF_WORSHIP = 60774,
  29. SPELL_DRUID_INCREASED_MOONFIRE_DURATION = 38414,
  30. SPELL_DRUID_KING_OF_THE_JUNGLE = 48492,
  31. SPELL_DRUID_LIFEBLOOM_ENERGIZE = 64372,
  32. SPELL_DRUID_LIFEBLOOM_FINAL_HEAL = 33778,
  33. SPELL_DRUID_LIVING_SEED_HEAL = 48503,
  34. SPELL_DRUID_LIVING_SEED_PROC = 48504,
  35. SPELL_DRUID_NATURES_SPLENDOR = 57865,
  36. SPELL_DRUID_SURVIVAL_INSTINCTS = 50322,
  37. SPELL_DRUID_SAVAGE_ROAR = 62071,
  38. SPELL_DRUID_TIGER_S_FURY_ENERGIZE = 51178,
  39. SPELL_DRUID_ITEM_T8_BALANCE_RELIC = 64950,
  40. SPELL_DRUID_LIFEBLOOM_HOT = 33763
  41. };
  42.  
  43. // 2912, 5176, 78674 - Starfire, Wrath, and Starsurge
  44. class spell_dru_eclipse_energize : public SpellScriptLoader
  45. {
  46. public:
  47. spell_dru_eclipse_energize() : SpellScriptLoader("spell_dru_eclipse_energize") { }
  48.  
  49. class spell_dru_eclipse_energize_SpellScript : public SpellScript
  50. {
  51. PrepareSpellScript(spell_dru_eclipse_energize_SpellScript);
  52.  
  53. int32 energizeAmount;
  54.  
  55. bool Load()
  56. {
  57. if (GetCaster()->GetTypeId() != TYPEID_PLAYER)
  58. return false;
  59.  
  60. if (GetCaster()->ToPlayer()->getClass() != CLASS_DRUID)
  61. return false;
  62.  
  63. energizeAmount = 0;
  64.  
  65. return true;
  66. }
  67.  
  68. void HandleEnergize(SpellEffIndex effIndex)
  69. {
  70. Player* caster = GetCaster()->ToPlayer();
  71.  
  72. // No boomy, no deal.
  73. if (caster->GetPrimaryTalentTree(caster->GetActiveSpec()) != TALENT_TREE_DRUID_BALANCE)
  74. return;
  75.  
  76. bool lunar = false;
  77. bool solar = false;
  78. bool hasActiveMarker = caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER) || caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER);
  79. switch (GetSpellInfo()->Id)
  80. {
  81. case SPELL_DRUID_SUNFIRE:
  82. case SPELL_DRUID_MOONFIRE:
  83. {
  84. // Lunar shower
  85. if (!caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DRUID, 3698, EFFECT_0))
  86. return;
  87. energizeAmount = 8;
  88. break;
  89. }
  90. case SPELL_DRUID_WRATH:
  91. case SPELL_DRUID_STARFIRE:
  92. {
  93. energizeAmount = GetSpellInfo()->Effects[EFFECT_1].BasePoints;
  94. // Don't add Euphoria beenfit when already in eclipse state
  95. if (caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE) || caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE))
  96. break;
  97. // Euphoria
  98. if (AuraEffect* euphoria = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 4431, EFFECT_0))
  99. if (roll_chance_i(euphoria->GetAmount()))
  100. energizeAmount *= 2;
  101. break;
  102. }
  103. default:
  104. energizeAmount = GetSpellInfo()->Effects[EFFECT_1].BasePoints;
  105. break;
  106. }
  107.  
  108. switch (GetSpellInfo()->Id)
  109. {
  110. case SPELL_DRUID_SUNFIRE:
  111. case SPELL_DRUID_WRATH:
  112. {
  113. energizeAmount = -energizeAmount;
  114. // If we are set to fill the lunar side or we've just logged in with 0 power..
  115. if ((!caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER) && caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER))
  116. || (!hasActiveMarker && caster->GetPower(POWER_ECLIPSE) == 0))
  117. {
  118. caster->CastCustomSpell(caster, SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, &energizeAmount, 0, 0, true);
  119. // If the energize was due to 0 power, cast the eclipse marker aura
  120. if (!caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER))
  121. caster->CastSpell(caster, SPELL_DRUID_LUNAR_ECLIPSE_MARKER, true);
  122.  
  123. lunar = caster->GetPower(POWER_ECLIPSE) == -100;
  124. }
  125. // The energizing effect brought us out of the solar eclipse, remove the aura
  126. if (caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE) && caster->GetPower(POWER_ECLIPSE) <= 0)
  127. {
  128. caster->RemoveAurasDueToSpell(SPELL_DRUID_SOLAR_ECLIPSE);
  129. caster->RemoveAurasDueToSpell(94338);
  130. }
  131. break;
  132. }
  133. case SPELL_DRUID_STARFIRE:
  134. {
  135. // If we are set to fill the solar side or we've just logged in with 0 power..
  136. if ((!caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER) && caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  137. || (!hasActiveMarker && caster->GetPower(POWER_ECLIPSE) == 0))
  138. {
  139. caster->CastCustomSpell(caster, SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, &energizeAmount, 0, 0, true);
  140. // If the energize was due to 0 power, cast the eclipse marker aura
  141. if (!caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  142. caster->CastSpell(caster, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, true);
  143.  
  144. solar = caster->GetPower(POWER_ECLIPSE) == 100;
  145. }
  146. // The energizing effect brought us out of the lunar eclipse, remove the aura
  147. if (caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE) && caster->GetPower(POWER_ECLIPSE) >= 0)
  148. caster->RemoveAura(SPELL_DRUID_LUNAR_ECLIPSE);
  149. break;
  150. }
  151. case SPELL_DRUID_MOONFIRE:
  152. case SPELL_DRUID_STARSURGE:
  153. {
  154. // If we are set to fill the solar side or we've just logged in with 0 power (confirmed with sniffs)
  155. if ((!caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER) && caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  156. || (!hasActiveMarker && caster->GetPower(POWER_ECLIPSE) == 0))
  157. {
  158. if (GetSpellInfo()->Id == SPELL_DRUID_STARSURGE)
  159. caster->CastCustomSpell(caster, SPELL_DRUID_STARSURGE_ENERGIZE, &energizeAmount, 0, 0, true);
  160. else
  161. caster->CastCustomSpell(caster, SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, &energizeAmount, 0, 0, true);
  162. solar = caster->GetPower(POWER_ECLIPSE) == 100;
  163.  
  164. // If the energize was due to 0 power, cast the eclipse marker aura
  165. if (!caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  166. caster->CastSpell(caster, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, true);
  167. }
  168. else if (!caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER) && caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER))
  169. {
  170. energizeAmount = -energizeAmount;
  171. if (GetSpellInfo()->Id == SPELL_DRUID_STARSURGE)
  172. caster->CastCustomSpell(caster, SPELL_DRUID_STARSURGE_ENERGIZE, &energizeAmount, 0, 0, true);
  173. else
  174. caster->CastCustomSpell(caster, SPELL_DRUID_ECLIPSE_GENERAL_ENERGIZE, &energizeAmount, 0, 0, true);
  175. lunar = caster->GetPower(POWER_ECLIPSE) == -100;
  176. }
  177.  
  178. // The energizing effect brought us out of the lunar eclipse, remove the aura
  179. if (caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE) && caster->GetPower(POWER_ECLIPSE) >= 0)
  180. caster->RemoveAura(SPELL_DRUID_LUNAR_ECLIPSE);
  181. // The energizing effect brought us out of the solar eclipse, remove the aura
  182. else if (caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE) && caster->GetPower(POWER_ECLIPSE) <= 0)
  183. {
  184. caster->RemoveAurasDueToSpell(SPELL_DRUID_SOLAR_ECLIPSE);
  185. caster->RemoveAurasDueToSpell(94338);
  186. }
  187. break;
  188. }
  189. }
  190. if (solar || lunar)
  191. {
  192. // Euphoria mana regen
  193. if (AuraEffect* euphoria = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 4431, EFFECT_2))
  194. caster->CastCustomSpell(81070, SPELLVALUE_BASE_POINT0, euphoria->GetAmount(), caster, TRIGGERED_FULL_MASK);
  195.  
  196. // Remove Nature's grace cooldown
  197. caster->RemoveSpellCooldown(16886);
  198.  
  199. if (solar)
  200. // Sunfire
  201. if (AuraEffect* sunfire = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 3262, EFFECT_0))
  202. caster->CastCustomSpell(94338, SPELLVALUE_BASE_POINT0, 93402, caster, TRIGGERED_FULL_MASK);
  203. }
  204. }
  205.  
  206. void Register()
  207. {
  208. OnEffectHitTarget += SpellEffectFn(spell_dru_eclipse_energize_SpellScript::HandleEnergize, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  209. OnEffectHitTarget += SpellEffectFn(spell_dru_eclipse_energize_SpellScript::HandleEnergize, EFFECT_1, SPELL_EFFECT_SCHOOL_DAMAGE);
  210. }
  211. };
  212.  
  213. SpellScript* GetSpellScript() const
  214. {
  215. return new spell_dru_eclipse_energize_SpellScript;
  216. }
  217. };
  218.  
  219. class spell_dru_energize : public SpellScriptLoader
  220. {
  221. public:
  222. spell_dru_energize() : SpellScriptLoader("spell_dru_energize") { }
  223.  
  224. class spell_dru_energize_SpellScript : public SpellScript
  225. {
  226. PrepareSpellScript(spell_dru_energize_SpellScript);
  227.  
  228. bool Load()
  229. {
  230. if (GetCaster()->GetTypeId() != TYPEID_PLAYER)
  231. return false;
  232.  
  233. if (GetCaster()->ToPlayer()->getClass() != CLASS_DRUID)
  234. return false;
  235.  
  236. return true;
  237. }
  238.  
  239. void OnHit()
  240. {
  241. Player* caster = GetCaster()->ToPlayer();
  242.  
  243. // No boomy, no deal.
  244. if (caster->GetPrimaryTalentTree(caster->GetActiveSpec()) != TALENT_TREE_DRUID_BALANCE)
  245. return;
  246.  
  247. bool lunar = caster->GetPower(POWER_ECLIPSE) == -100;
  248. bool solar = caster->GetPower(POWER_ECLIPSE) == 100;
  249. if (caster->GetPower(POWER_ECLIPSE) > 0)
  250. {
  251. if (!caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  252. caster->CastSpell(caster, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, true);
  253. }
  254. else if (caster->GetPower(POWER_ECLIPSE) < 0)
  255. {
  256. if (!caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER))
  257. caster->CastSpell(caster, SPELL_DRUID_LUNAR_ECLIPSE_MARKER, true);
  258. }
  259. if (solar || lunar)
  260. {
  261. // Euphoria mana regen
  262. if (AuraEffect* euphoria = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 4431, EFFECT_2))
  263. caster->CastCustomSpell(81070, SPELLVALUE_BASE_POINT0, euphoria->GetAmount(), caster, TRIGGERED_FULL_MASK);
  264.  
  265. // Remove Nature's grace cooldown
  266. caster->RemoveSpellCooldown(16886);
  267.  
  268. if (solar)
  269. {
  270. // Sunfire
  271. if (AuraEffect* sunfire = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 3262, EFFECT_0))
  272. caster->CastCustomSpell(94338, SPELLVALUE_BASE_POINT0, 93402, caster, TRIGGERED_FULL_MASK);
  273.  
  274. if (caster->HasAura(SPELL_DRUID_SOLAR_ECLIPSE_MARKER))
  275. {
  276. caster->RemoveAurasDueToSpell(SPELL_DRUID_SOLAR_ECLIPSE_MARKER);
  277. caster->CastSpell(caster, SPELL_DRUID_LUNAR_ECLIPSE_MARKER, true);
  278. }
  279.  
  280. caster->CastSpell(caster, 48517, true);
  281. }
  282.  
  283. if (lunar)
  284. {
  285. if (caster->HasAura(SPELL_DRUID_LUNAR_ECLIPSE_MARKER))
  286. {
  287. caster->RemoveAurasDueToSpell(SPELL_DRUID_LUNAR_ECLIPSE_MARKER);
  288. caster->CastSpell(caster, SPELL_DRUID_SOLAR_ECLIPSE_MARKER, true);
  289. }
  290.  
  291. caster->CastSpell(caster, 48518, true);
  292. }
  293. }
  294. }
  295.  
  296. void Register()
  297. {
  298. AfterHit += SpellHitFn(spell_dru_energize_SpellScript::OnHit);
  299. }
  300. };
  301.  
  302. SpellScript* GetSpellScript() const
  303. {
  304. return new spell_dru_energize_SpellScript;
  305. }
  306. };
  307.  
  308. // Starsurege
  309. class spell_dru_starsurge : public SpellScriptLoader
  310. {
  311. public:
  312. spell_dru_starsurge() : SpellScriptLoader("spell_dru_starsurge") { }
  313.  
  314. class spell_dru_starsurge_SpellScript : public SpellScript
  315. {
  316. PrepareSpellScript(spell_dru_starsurge_SpellScript);
  317.  
  318. void HandleProc(SpellEffIndex /*effIndex*/)
  319. {
  320. Unit* caster = GetCaster();
  321. if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
  322. return;
  323.  
  324. if (caster->HasAura(93400))
  325. // Check if starsurge was affected by active starsurge proc
  326. if (Spell* spell = GetSpell())
  327. if (spell->m_appliedAuras.find(93400) == spell->m_appliedAuras.end())
  328. caster->ToPlayer()->RemoveSpellCooldown(78674, true);
  329. }
  330.  
  331. void Register()
  332. {
  333. OnEffectHitTarget += SpellEffectFn(spell_dru_starsurge_SpellScript::HandleProc, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  334. }
  335. };
  336.  
  337. SpellScript* GetSpellScript() const
  338. {
  339. return new spell_dru_starsurge_SpellScript();
  340. }
  341. };
  342.  
  343. // -1850 - Dash
  344. class spell_dru_dash : public SpellScriptLoader
  345. {
  346. public:
  347. spell_dru_dash() : SpellScriptLoader("spell_dru_dash") { }
  348.  
  349. class spell_dru_dash_AuraScript : public AuraScript
  350. {
  351. PrepareAuraScript(spell_dru_dash_AuraScript);
  352.  
  353. void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
  354. {
  355. // do not set speed if not in cat form
  356. if (GetUnitOwner()->GetShapeshiftForm() != FORM_CAT)
  357. amount = 0;
  358. }
  359.  
  360. void Register()
  361. {
  362. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_dash_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_MOD_INCREASE_SPEED);
  363. }
  364. };
  365.  
  366. AuraScript* GetAuraScript() const
  367. {
  368. return new spell_dru_dash_AuraScript();
  369. }
  370. };
  371.  
  372. class spell_dru_innervate : public SpellScriptLoader
  373. {
  374. class script_impl : public AuraScript
  375. {
  376. PrepareAuraScript(script_impl);
  377.  
  378. enum
  379. {
  380. SPELL_INNERVATE_MANA = 54833,
  381. SPELL_GLYPH_OF_INNERVATE = 54832,
  382. SPELL_DREAMSTATE = 33597,
  383. };
  384.  
  385. bool m_self;
  386.  
  387. bool Load()
  388. {
  389. Unit const* const caster = GetCaster();
  390. Unit const* const owner = GetUnitOwner();
  391. m_self = (caster == owner);
  392. return owner && caster && caster->GetTypeId() == TYPEID_PLAYER;
  393. }
  394.  
  395. void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool&)
  396. {
  397. Unit const* const caster = GetCaster();
  398. Unit const* const owner = GetUnitOwner();
  399.  
  400. int32 value = m_self ? amount : amount / 4.0f;
  401. if (m_self)
  402. {
  403. // Dreamstate
  404. if (AuraEffect const* const eff = caster->GetAuraEffectOfRankedSpell(SPELL_DREAMSTATE, EFFECT_0))
  405. value += eff->GetAmount();
  406. }
  407.  
  408. int32 const mana = CalculatePct(caster->GetMaxPower(POWER_MANA), value);
  409. amount = int32(mana / aurEff->GetTotalTicks());
  410. }
  411.  
  412. void OnApply(AuraEffect const*, AuraEffectHandleModes)
  413. {
  414. if (m_self)
  415. return;
  416.  
  417. // Glyph of Innervate
  418. Unit* const caster = GetCaster();
  419. if (caster->HasAura(SPELL_GLYPH_OF_INNERVATE))
  420. caster->CastSpell(caster, SPELL_INNERVATE_MANA, true);
  421. }
  422.  
  423. void Register()
  424. {
  425. DoEffectCalcAmount += AuraEffectCalcAmountFn(script_impl::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_ENERGIZE);
  426. OnEffectApply += AuraEffectApplyFn(script_impl::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_ENERGIZE, AURA_EFFECT_HANDLE_REAL);
  427. }
  428. };
  429.  
  430. public:
  431. spell_dru_innervate()
  432. : SpellScriptLoader("spell_dru_innervate")
  433. {
  434. }
  435.  
  436. AuraScript* GetAuraScript() const
  437. {
  438. return new script_impl();
  439. }
  440. };
  441.  
  442. // Solar Beam
  443. class spell_dru_beam : public SpellScriptLoader
  444. {
  445. public:
  446. spell_dru_beam() : SpellScriptLoader("spell_dru_beam") { }
  447.  
  448. class spell_dru_beam_AuraScript : public AuraScript
  449. {
  450. PrepareAuraScript(spell_dru_beam_AuraScript);
  451.  
  452. bool Validate(SpellInfo const* /*spellInfo*/) { return true; }
  453.  
  454. void HandleEffectPeriodic(AuraEffect const* aurEff)
  455. {
  456. if (DynamicObject* dyn = GetTarget()->GetDynObject(aurEff->GetId()))
  457. GetTarget()->CastSpell(dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ(), 81261, true);
  458. }
  459.  
  460. void Register()
  461. {
  462. OnEffectPeriodic += AuraEffectPeriodicFn(spell_dru_beam_AuraScript::HandleEffectPeriodic, EFFECT_2, SPELL_AURA_PERIODIC_DUMMY);
  463. }
  464. };
  465.  
  466. AuraScript* GetAuraScript() const
  467. {
  468. return new spell_dru_beam_AuraScript();
  469. }
  470. };
  471.  
  472. // Rejuvenation
  473. class spell_dru_rejuv : public SpellScriptLoader
  474. {
  475. public:
  476. spell_dru_rejuv() : SpellScriptLoader("spell_dru_rejuv") { }
  477.  
  478. class spell_dru_rejuv_AuraScript : public AuraScript
  479. {
  480. PrepareAuraScript(spell_dru_rejuv_AuraScript);
  481.  
  482. void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  483. {
  484. if (Unit* caster = GetCaster())
  485. {
  486. if (!caster->ToPlayer())
  487. return;
  488.  
  489. uint32 rejuvCount = 0;
  490. Player::appliedAurasList const& auras = caster->ToPlayer()->appliedAuras;
  491.  
  492. if (auras.empty())
  493. return;
  494.  
  495. for (Player::appliedAurasList::const_iterator itr = auras.begin(); itr != auras.end(); itr++)
  496. {
  497. Aura* aura = (*itr);
  498. if (aura->GetId() == GetSpellInfo()->Id)
  499. rejuvCount++;
  500. }
  501. if (rejuvCount < 3)
  502. caster->RemoveAurasDueToSpell(96206);
  503. }
  504. }
  505.  
  506. void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  507. {
  508. if (Unit* caster = GetCaster())
  509. {
  510. if (AuraEffect* naturesBounty = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, 197, EFFECT_0))
  511. {
  512. uint32 rejuvCount = 0;
  513. Player::appliedAurasList const& auras = caster->ToPlayer()->appliedAuras;
  514. for (Player::appliedAurasList::const_iterator itr = auras.begin(); itr != auras.end(); itr++)
  515. {
  516. Aura* aura = (*itr);
  517. if (aura->GetId() == GetSpellInfo()->Id)
  518. rejuvCount++;
  519. }
  520. if (rejuvCount >= 3)
  521. {
  522. int32 bp0 = -naturesBounty->GetSpellInfo()->Effects[EFFECT_1].BasePoints;
  523. caster->CastCustomSpell(caster, 96206, &bp0, NULL, NULL, true);
  524. }
  525. }
  526.  
  527. // Gift of the earthmother
  528. if (AuraEffect* earthMother = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 3186, EFFECT_0))
  529. {
  530. int32 bp0 = caster->SpellHealingBonusDone(GetUnitOwner(), GetSpellInfo(), aurEff->GetAmount(), DOT);
  531. bp0 = (bp0 * aurEff->GetTotalTicks()) * (earthMother->GetAmount() / 100.0f);
  532. caster->CastCustomSpell(GetUnitOwner(), 64801, &bp0, NULL, NULL, true);
  533. }
  534. }
  535. }
  536.  
  537. void Register()
  538. {
  539. AfterEffectApply += AuraEffectApplyFn(spell_dru_rejuv_AuraScript::AfterApply, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL);
  540. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_rejuv_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL);
  541. }
  542. };
  543.  
  544. AuraScript* GetAuraScript() const
  545. {
  546. return new spell_dru_rejuv_AuraScript();
  547. }
  548. };
  549.  
  550. // 88747 - Wild mushroom
  551. class spell_dru_wild_mushroom : public SpellScriptLoader
  552. {
  553. public:
  554. spell_dru_wild_mushroom() : SpellScriptLoader("spell_dru_wild_mushroom") { }
  555.  
  556. class spell_dru_wild_mushroom_SpellScript : public SpellScript
  557. {
  558. PrepareSpellScript(spell_dru_wild_mushroom_SpellScript)
  559.  
  560. void HandleSummon(SpellEffIndex effIndex)
  561. {
  562. PreventHitDefaultEffect(effIndex);
  563.  
  564. Unit* caster = GetCaster();
  565. WorldLocation const* targetDest = GetExplTargetDest();
  566. SpellInfo const* spellInfo = GetSpellInfo();
  567.  
  568. if(caster && targetDest)
  569. {
  570. if (Player* player = caster->ToPlayer())
  571. {
  572. Position pos;
  573. std::list<Creature*> list;
  574.  
  575. Trinity::AnyUnfriendlyCreatureInUnitRangeCheck check(player, SPELL_DRUID_NPC_WILD_MUSHROOM, 100.0f);
  576. Trinity::CreatureListSearcher<Trinity::AnyUnfriendlyCreatureInUnitRangeCheck> searcher(player, list, check);
  577. player->VisitNearbyGridObject(100.0f, searcher);
  578.  
  579. // Max 3 Wild Mushroom
  580. if ((int32)list.size() >= GetEffectValue())
  581. {
  582. if(list.back())
  583. {
  584. if(TempSummon* temp = list.back()->ToTempSummon())
  585. {
  586. temp->UnSummon();
  587. }
  588. }
  589. }
  590.  
  591. // Summon position
  592. targetDest->GetPosition(&pos);
  593.  
  594. // Summon properties
  595. const SummonPropertiesEntry* properties = sSummonPropertiesStore.LookupEntry(spellInfo->Effects[effIndex].MiscValueB);
  596.  
  597. TempSummon* summon = player->SummonCreature(spellInfo->Effects[0].MiscValue, pos, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, spellInfo->GetDuration());
  598.  
  599. if (!summon)
  600. return;
  601.  
  602. summon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, player->GetGUID());
  603. summon->setFaction(player->getFaction());
  604. summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id);
  605. summon->SetMaxHealth(5);
  606. summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
  607. summon->StopMoving();
  608. summon->SetControlled(true, UNIT_STATE_STUNNED);
  609. }
  610. }
  611. }
  612.  
  613. void Register()
  614. {
  615. OnEffectHit += SpellEffectFn(spell_dru_wild_mushroom_SpellScript::HandleSummon, EFFECT_0, SPELL_EFFECT_SUMMON);
  616. }
  617. };
  618.  
  619. SpellScript* GetSpellScript() const
  620. {
  621. return new spell_dru_wild_mushroom_SpellScript();
  622. }
  623. };
  624.  
  625. // 88751 - Wild mushroom : Detonate
  626. class spell_dru_wild_mushroom_detonation : public SpellScriptLoader
  627. {
  628. public:
  629. spell_dru_wild_mushroom_detonation() : SpellScriptLoader("spell_dru_wild_mushroom_detonation") { }
  630.  
  631. class spell_dru_wild_mushroom_detonation_SpellScript : public SpellScript
  632. {
  633. PrepareSpellScript(spell_dru_wild_mushroom_detonation_SpellScript)
  634.  
  635. bool Load()
  636. {
  637. spellRange = GetSpellInfo()->GetMaxRange();
  638.  
  639. if (!spellRange)
  640. return false;
  641.  
  642. if(Unit* caster = GetCaster())
  643. {
  644. if(Player* player = caster->ToPlayer())
  645. {
  646. std::list<Creature*> list;
  647.  
  648. Trinity::AnyUnfriendlyCreatureInUnitRangeCheck check(player, SPELL_DRUID_NPC_WILD_MUSHROOM, 100.0f);
  649. Trinity::CreatureListSearcher<Trinity::AnyUnfriendlyCreatureInUnitRangeCheck> searcher(player, mushroomList, check);
  650. player->VisitNearbyGridObject(100.0f, searcher);
  651.  
  652. return true;
  653. }
  654. }
  655.  
  656. return false;
  657. }
  658.  
  659. SpellCastResult CheckCast()
  660. {
  661. if(Unit* caster = GetCaster())
  662. {
  663. if(Player* player = caster->ToPlayer())
  664. {
  665. if (mushroomList.empty())
  666. return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
  667.  
  668. bool inRange = false;
  669.  
  670. for (std::list<Creature*>::const_iterator i = mushroomList.begin(); i != mushroomList.end(); i)
  671. {
  672. if((*i))
  673. {
  674. Position pos;
  675. (*i)->GetPosition(&pos);
  676.  
  677. // Must have at least one mushroom within 40 yards
  678. if (player->IsWithinDist3d(&pos, spellRange))
  679. {
  680. return SPELL_CAST_OK;
  681. }
  682. }
  683.  
  684. i++;
  685. }
  686.  
  687. SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_TARGET_TOO_FAR);
  688. return SPELL_FAILED_CUSTOM_ERROR;
  689. }
  690. }
  691. return SPELL_FAILED_CASTER_DEAD;
  692. }
  693.  
  694. void HandleDummy(SpellEffIndex /*effIndex*/)
  695. {
  696. if(Unit* caster = GetCaster())
  697. {
  698. if(Player* player = caster->ToPlayer())
  699. {
  700. int32 fungalGrowthSlowSpellId;
  701.  
  702. for (std::list<Creature*>::const_iterator i = mushroomList.begin(); i != mushroomList.end(); i)
  703. {
  704. Position pos;
  705. Creature* tempMushroom = (*i);
  706.  
  707. if(tempMushroom)
  708. {
  709. tempMushroom->GetPosition(&pos);
  710.  
  711. // Explosion visual and suicide
  712. tempMushroom->CastSpell(tempMushroom, SPELL_DRUID_SPELL_WILD_MUSHROOM_SUICIDE, true);
  713.  
  714. // Explosion damage
  715. player->CastSpell(
  716. pos.GetPositionX(),
  717. pos.GetPositionY(),
  718. pos.GetPositionZ(),
  719. SPELL_DRUID_SPELL_WILD_MUSHROOM_DAMAGE, true);
  720.  
  721. // Fungal Growth
  722. if (AuraEffect* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2681, EFFECT_0))
  723. {
  724. fungalGrowthSlowSpellId = aurEff->GetMiscValue();
  725.  
  726. // Summon fungal
  727. player->CastSpell(
  728. pos.GetPositionX(),
  729. pos.GetPositionY(),
  730. pos.GetPositionZ(),
  731. SPELL_DRUID_FUNGAL_GROWTH_SUMMON, true);
  732. }
  733. }
  734.  
  735. i++;
  736. }
  737.  
  738. // Frees the memory
  739. mushroomList.clear();
  740.  
  741. // Fungal Growth spells
  742. if(fungalGrowthSlowSpellId)
  743. {
  744. if(SpellInfo const* fungalGrowthSpellInfo = sSpellMgr->GetSpellInfo(SPELL_DRUID_FUNGAL_GROWTH_SUMMON))
  745. {
  746. Trinity::AnyUnfriendlyCreatureInUnitRangeCheck check(player, fungalGrowthSpellInfo->Effects[0].MiscValue, 100.0f);
  747. Trinity::CreatureListSearcher<Trinity::AnyUnfriendlyCreatureInUnitRangeCheck> searcher(player, mushroomList, check);
  748. player->VisitNearbyGridObject(100.0f, searcher);
  749.  
  750. for (std::list<Creature*>::const_iterator i = mushroomList.begin(); i != mushroomList.end(); i)
  751. {
  752. Creature* tempFungal = (*i);
  753.  
  754. if(tempFungal)
  755. {
  756. tempFungal->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, player->GetGUID());
  757. tempFungal->SetUInt32Value(UNIT_CREATED_BY_SPELL, SPELL_DRUID_FUNGAL_GROWTH_SUMMON);
  758. tempFungal->SetMaxHealth(5);
  759. tempFungal->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
  760. tempFungal->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  761. tempFungal->StopMoving();
  762. tempFungal->SetControlled(true, UNIT_STATE_STUNNED);
  763.  
  764. // Graphical effect
  765. tempFungal->CastSpell(tempFungal, SPELL_DRUID_FUNGAL_GROWTH_GRAPHIC, true);
  766.  
  767. // Slow effect
  768. tempFungal->CastSpell(tempFungal, fungalGrowthSlowSpellId, true);
  769. }
  770.  
  771. i++;
  772. }
  773. }
  774. }
  775. }
  776. }
  777. }
  778.  
  779. private:
  780. float spellRange;
  781. std::list<Creature*> mushroomList;
  782.  
  783. void Register()
  784. {
  785. OnCheckCast += SpellCheckCastFn(spell_dru_wild_mushroom_detonation_SpellScript::CheckCast);
  786. OnEffectHitTarget += SpellEffectFn(spell_dru_wild_mushroom_detonation_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
  787. }
  788. };
  789.  
  790. SpellScript* GetSpellScript() const
  791. {
  792. return new spell_dru_wild_mushroom_detonation_SpellScript();
  793. }
  794. };
  795.  
  796.  
  797. // -5229 - Enrage
  798. class spell_dru_enrage : public SpellScriptLoader
  799. {
  800. public:
  801. spell_dru_enrage() : SpellScriptLoader("spell_dru_enrage") { }
  802.  
  803. class spell_dru_enrage_SpellScript : public SpellScript
  804. {
  805. PrepareSpellScript(spell_dru_enrage_SpellScript);
  806.  
  807. void OnHit()
  808. {
  809. // King of the jungle
  810. if (AuraEffect const* aurEff = GetHitUnit()->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2850, EFFECT_1))
  811. GetHitUnit()->CastCustomSpell(SPELL_DRUID_ENRAGE_MOD_DAMAGE, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetHitUnit(), true);
  812. }
  813.  
  814. void Register()
  815. {
  816. AfterHit += SpellHitFn(spell_dru_enrage_SpellScript::OnHit);
  817. }
  818. };
  819.  
  820. SpellScript* GetSpellScript() const
  821. {
  822. return new spell_dru_enrage_SpellScript();
  823. }
  824. };
  825.  
  826. // Stampede
  827. class spell_dru_stampede : public SpellScriptLoader
  828. {
  829. public:
  830. spell_dru_stampede() : SpellScriptLoader("spell_dru_stampede") { }
  831.  
  832. class spell_dru_stampede_SpellScript : public SpellScript
  833. {
  834. PrepareSpellScript(spell_dru_stampede_SpellScript);
  835.  
  836. void OnHit()
  837. {
  838. Unit* caster = GetCaster();
  839. uint32 triggeredId = 0;
  840. switch (GetSpellInfo()->Id)
  841. {
  842. case 16979: // Feral charge bear
  843. if (AuraEffect* stampede = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 3930, EFFECT_0))
  844. {
  845. switch (stampede->GetAmount())
  846. {
  847. case 5:
  848. triggeredId = 81016;
  849. break;
  850. case 10:
  851. triggeredId = 81017;
  852. break;
  853. }
  854. }
  855. break;
  856. case 49376: // Feral charge cat
  857. if (AuraEffect* stampede = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 3930, EFFECT_1))
  858. {
  859. switch (stampede->GetAmount())
  860. {
  861. case 3:
  862. triggeredId = 81021;
  863. break;
  864. case 6:
  865. triggeredId = 81022;
  866. break;
  867. }
  868. caster->CastSpell(caster, 109881, true);
  869. }
  870. break;
  871. }
  872. if (triggeredId)
  873. caster->CastSpell(caster, triggeredId, true);
  874. }
  875.  
  876. void Register()
  877. {
  878. AfterHit += SpellHitFn(spell_dru_stampede_SpellScript::OnHit);
  879. }
  880. };
  881.  
  882. SpellScript* GetSpellScript() const
  883. {
  884. return new spell_dru_stampede_SpellScript();
  885. }
  886. };
  887.  
  888. // Feral swiftness
  889. class spell_dru_feral_swiftness : public SpellScriptLoader
  890. {
  891. public:
  892. spell_dru_feral_swiftness() : SpellScriptLoader("spell_dru_feral_swiftness") { }
  893.  
  894. class spell_dru_feral_swiftness_SpellScript : public SpellScript
  895. {
  896. PrepareSpellScript(spell_dru_feral_swiftness_SpellScript);
  897.  
  898. void OnHit()
  899. {
  900. if (AuraEffect const* feralSwiftness = GetCaster()->GetAuraEffect(SPELL_AURA_MOD_DODGE_PERCENT, SPELLFAMILY_DRUID, 67, EFFECT_0))
  901. {
  902. uint32 chance = feralSwiftness->GetId() == 24867 ? 50 : 100;
  903. if (roll_chance_i(chance))
  904. GetCaster()->CastSpell(GetHitUnit(), 97985, true);
  905. }
  906. }
  907.  
  908. void Register()
  909. {
  910. AfterHit += SpellHitFn(spell_dru_feral_swiftness_SpellScript::OnHit);
  911. }
  912. };
  913.  
  914. SpellScript* GetSpellScript() const
  915. {
  916. return new spell_dru_feral_swiftness_SpellScript();
  917. }
  918. };
  919.  
  920. // Skull Bash
  921. class spell_dru_skull_bash : public SpellScriptLoader
  922. {
  923. public:
  924. spell_dru_skull_bash() : SpellScriptLoader("spell_dru_skull_bash") { }
  925.  
  926. class spell_dru_skull_bash_SpellScript : public SpellScript
  927. {
  928. PrepareSpellScript(spell_dru_skull_bash_SpellScript);
  929.  
  930. void HandleDummy(SpellEffIndex /*effIndex*/)
  931. {
  932. Unit* caster = GetCaster();
  933. Unit* victim = GetHitUnit();
  934. caster->CastSpell(victim, 93983, true);
  935. caster->CastSpell(victim, 93985, true);
  936. // Brutal impact
  937. if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, 473, EFFECT_0))
  938. {
  939. uint32 triggeredId = 0;
  940. switch (aurEff->GetId())
  941. {
  942. case 16940:
  943. triggeredId = 82364;
  944. break;
  945. case 16941:
  946. triggeredId = 82365;
  947. break;
  948. }
  949. caster->CastSpell(victim, triggeredId, true);
  950. }
  951. }
  952.  
  953. void Register()
  954. {
  955. OnEffectHitTarget += SpellEffectFn(spell_dru_skull_bash_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
  956. }
  957. };
  958.  
  959. SpellScript* GetSpellScript() const
  960. {
  961. return new spell_dru_skull_bash_SpellScript();
  962. }
  963. };
  964.  
  965. // Primal madness
  966. class spell_dru_primal_madness : public SpellScriptLoader
  967. {
  968. public:
  969. spell_dru_primal_madness() : SpellScriptLoader("spell_dru_primal_madness") { }
  970.  
  971. class spell_dru_primal_madness_AuraScript : public AuraScript
  972. {
  973. PrepareAuraScript(spell_dru_primal_madness_AuraScript);
  974.  
  975. void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  976. {
  977. // Primal Madness
  978. if (AuraEffect const* primalMadness = GetCaster()->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, 1181, EFFECT_1))
  979. {
  980. uint32 triggeredId = 0;
  981. switch (primalMadness->GetId())
  982. {
  983. case 80316:
  984. triggeredId = 80879;
  985. break;
  986. case 80317:
  987. triggeredId = 80886;
  988. break;
  989. }
  990. GetCaster()->CastSpell(GetCaster(), triggeredId, true);
  991. }
  992. }
  993.  
  994. void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  995. {
  996. if (Unit* caster = GetCaster())
  997. {
  998. caster->RemoveAurasDueToSpell(80879);
  999. caster->RemoveAurasDueToSpell(80886);
  1000. }
  1001. }
  1002.  
  1003. void Register()
  1004. {
  1005. AfterEffectApply += AuraEffectApplyFn(spell_dru_primal_madness_AuraScript::OnApply, EFFECT_0, SPELL_AURA_ADD_PCT_MODIFIER, AURA_EFFECT_HANDLE_REAL);
  1006. AfterEffectApply += AuraEffectApplyFn(spell_dru_primal_madness_AuraScript::OnApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
  1007. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_primal_madness_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_ADD_PCT_MODIFIER, AURA_EFFECT_HANDLE_REAL);
  1008. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_primal_madness_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
  1009. }
  1010. };
  1011.  
  1012. AuraScript* GetAuraScript() const
  1013. {
  1014. return new spell_dru_primal_madness_AuraScript();
  1015. }
  1016. };
  1017.  
  1018. // Feral aggression
  1019. class spell_dru_feral_aggression : public SpellScriptLoader
  1020. {
  1021. public:
  1022. spell_dru_feral_aggression() : SpellScriptLoader("spell_dru_feral_aggression") { }
  1023.  
  1024.  
  1025. class spell_dru_feral_aggression_SpellScript : public SpellScript
  1026. {
  1027. PrepareSpellScript(spell_dru_feral_aggression_SpellScript);
  1028.  
  1029. void OnHitTarget(SpellEffIndex effIndex)
  1030. {
  1031. if (Unit* caster = GetCaster())
  1032. if (AuraEffect const* feralSwiftness = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 960, EFFECT_0))
  1033. {
  1034. PreventHitDefaultEffect(effIndex);
  1035. caster->CastCustomSpell(91565, SPELLVALUE_AURA_STACK, feralSwiftness->GetAmount(), GetHitUnit(), true);
  1036. }
  1037. }
  1038.  
  1039. void Register()
  1040. {
  1041. OnEffectHitTarget += SpellEffectFn(spell_dru_feral_aggression_SpellScript::OnHitTarget, EFFECT_0, SPELL_EFFECT_TRIGGER_SPELL);
  1042. }
  1043. };
  1044.  
  1045. SpellScript* GetSpellScript() const
  1046. {
  1047. return new spell_dru_feral_aggression_SpellScript();
  1048. }
  1049. };
  1050.  
  1051. // Barkskin
  1052. class spell_dru_barkskin : public SpellScriptLoader
  1053. {
  1054. public:
  1055. spell_dru_barkskin() : SpellScriptLoader("spell_dru_barkskin") { }
  1056.  
  1057. class spell_dru_barkskin_SpellScript : public SpellScript
  1058. {
  1059. PrepareSpellScript(spell_dru_barkskin_SpellScript);
  1060.  
  1061. void HandleOnHit()
  1062. {
  1063. Unit* caster = GetCaster();
  1064. if (AuraEffect const* glyph = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 689, EFFECT_0))
  1065. caster->CastSpell(caster, 63058, true);
  1066. }
  1067.  
  1068. void Register()
  1069. {
  1070. OnHit += SpellHitFn(spell_dru_barkskin_SpellScript::HandleOnHit);
  1071. }
  1072. };
  1073.  
  1074. SpellScript* GetSpellScript() const
  1075. {
  1076. return new spell_dru_barkskin_SpellScript();
  1077. }
  1078. };
  1079.  
  1080. // Harmony (Mastery)
  1081. class spell_dru_harmony : public SpellScriptLoader
  1082. {
  1083. public:
  1084. spell_dru_harmony() : SpellScriptLoader("spell_dru_harmony") { }
  1085.  
  1086. class spell_dru_harmony_SpellScript : public SpellScript
  1087. {
  1088. PrepareSpellScript(spell_dru_harmony_SpellScript);
  1089.  
  1090. void OnHit()
  1091. {
  1092. if (AuraEffect const* mastery = GetCaster()->GetAuraEffect(77495, EFFECT_0, GetCaster()->GetGUID()))
  1093. {
  1094. int32 bp0 = mastery->GetAmount();
  1095. GetCaster()->CastCustomSpell(GetCaster(), 100977, &bp0, NULL, NULL, true);
  1096. }
  1097. }
  1098.  
  1099. void Register()
  1100. {
  1101. AfterHit += SpellHitFn(spell_dru_harmony_SpellScript::OnHit);
  1102. }
  1103. };
  1104.  
  1105. SpellScript* GetSpellScript() const
  1106. {
  1107. return new spell_dru_harmony_SpellScript();
  1108. }
  1109. };
  1110.  
  1111. // Empowered touch
  1112. class spell_dru_emp_touch : public SpellScriptLoader
  1113. {
  1114. public:
  1115. spell_dru_emp_touch() : SpellScriptLoader("spell_dru_emp_touch") { }
  1116.  
  1117. class spell_dru_emp_touch_SpellScript : public SpellScript
  1118. {
  1119. PrepareSpellScript(spell_dru_emp_touch_SpellScript);
  1120.  
  1121. void OnHit()
  1122. {
  1123. if (AuraEffect const* aurEff = GetCaster()->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2251, EFFECT_1))
  1124. if (roll_chance_i(aurEff->GetAmount()))
  1125. GetCaster()->CastSpell(GetHitUnit(), 88433, true);
  1126. }
  1127.  
  1128. void Register()
  1129. {
  1130. AfterHit += SpellHitFn(spell_dru_emp_touch_SpellScript::OnHit);
  1131. }
  1132. };
  1133.  
  1134. SpellScript* GetSpellScript() const
  1135. {
  1136. return new spell_dru_emp_touch_SpellScript();
  1137. }
  1138. };
  1139.  
  1140. // Empowered touch
  1141. class spell_dru_emp_touch_triggered : public SpellScriptLoader
  1142. {
  1143. public:
  1144. spell_dru_emp_touch_triggered() : SpellScriptLoader("spell_dru_emp_touch_triggered") { }
  1145.  
  1146. class spell_dru_emp_touch_triggered_SpellScript : public SpellScript
  1147. {
  1148. PrepareSpellScript(spell_dru_emp_touch_triggered_SpellScript);
  1149.  
  1150. void OnHit()
  1151. {
  1152. if (GetCaster())
  1153. if (Aura* aura = GetCaster()->GetAura(33763, GetCaster()->GetGUID()))
  1154. aura->RefreshDuration();
  1155. }
  1156.  
  1157. void Register()
  1158. {
  1159. AfterHit += SpellHitFn(spell_dru_emp_touch_triggered_SpellScript::OnHit);
  1160. }
  1161. };
  1162.  
  1163. SpellScript* GetSpellScript() const
  1164. {
  1165. return new spell_dru_emp_touch_triggered_SpellScript();
  1166. }
  1167. };
  1168.  
  1169. // Efflorescence
  1170. class spell_sha_efflorescence : public SpellScriptLoader
  1171. {
  1172. public:
  1173. spell_sha_efflorescence() : SpellScriptLoader("spell_sha_efflorescence") { }
  1174.  
  1175. class spell_sha_efflorescence_AuraScript : public AuraScript
  1176. {
  1177. PrepareAuraScript(spell_sha_efflorescence_AuraScript);
  1178.  
  1179. void HandleEffectPeriodic(AuraEffect const* aurEff)
  1180. {
  1181. if (DynamicObject* dyn = GetTarget()->GetDynObject(aurEff->GetId()))
  1182. GetTarget()->CastSpell(dyn->GetPositionX(), dyn->GetPositionY(), dyn->GetPositionZ(), 81269, true);
  1183. }
  1184.  
  1185. void Register()
  1186. {
  1187. OnEffectPeriodic += AuraEffectPeriodicFn(spell_sha_efflorescence_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
  1188. }
  1189. };
  1190.  
  1191. AuraScript* GetAuraScript() const
  1192. {
  1193. return new spell_sha_efflorescence_AuraScript();
  1194. }
  1195. };
  1196.  
  1197. // Efflorescence heal
  1198. class spell_sha_efflorescence_heal : public SpellScriptLoader
  1199. {
  1200. public:
  1201. spell_sha_efflorescence_heal() : SpellScriptLoader("spell_sha_efflorescence_heal") { }
  1202.  
  1203. class spell_sha_efflorescence_heal_SpellScript : public SpellScript
  1204. {
  1205. PrepareSpellScript(spell_sha_efflorescence_heal_SpellScript);
  1206.  
  1207. void FilterTargets(std::list<WorldObject*>& targets)
  1208. {
  1209. std::list<Unit*> temp;
  1210. for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); itr++)
  1211. if (Unit* unit = (*itr)->ToUnit())
  1212. temp.push_back(unit);
  1213.  
  1214. targets.clear();
  1215. temp.sort(Trinity::HealthPctOrderPred());
  1216. if (temp.size() > 3)
  1217. temp.resize(3);
  1218. for (std::list<Unit*>::iterator itr = temp.begin(); itr != temp.end(); itr++)
  1219. targets.push_back((WorldObject*)(*itr));
  1220. }
  1221.  
  1222. void HandleHeal(SpellEffIndex /*effIndex*/)
  1223. {
  1224. if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(81262, EFFECT_1, GetCaster()->GetGUID()))
  1225. SetHitHeal(aurEff->GetAmount());
  1226. }
  1227.  
  1228. void Register()
  1229. {
  1230. OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sha_efflorescence_heal_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
  1231. OnEffectHitTarget += SpellEffectFn(spell_sha_efflorescence_heal_SpellScript::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
  1232. }
  1233. };
  1234.  
  1235. SpellScript* GetSpellScript() const
  1236. {
  1237. return new spell_sha_efflorescence_heal_SpellScript();
  1238. }
  1239. };
  1240.  
  1241. // Starfire
  1242. class spell_dru_glyph_of_starfire : public SpellScriptLoader
  1243. {
  1244. public:
  1245. spell_dru_glyph_of_starfire() : SpellScriptLoader("spell_dru_glyph_of_starfire") { }
  1246.  
  1247. class spell_dru_glyph_of_starfire_SpellScript : public SpellScript
  1248. {
  1249. PrepareSpellScript(spell_dru_glyph_of_starfire_SpellScript);
  1250.  
  1251. void HandleOnHit()
  1252. {
  1253. Unit* caster = GetCaster();
  1254. if (Unit* unitTarget = GetHitUnit())
  1255. if (AuraEffect* glyph = caster->GetAuraEffect(54845, EFFECT_0, caster->GetGUID()))
  1256. if (Aura* moonfire = unitTarget->GetAura(8921, caster->GetGUID()))
  1257. {
  1258. // Only last applied moonfire can be increased
  1259. if (caster->appliedAuras.back() != moonfire)
  1260. return;
  1261.  
  1262. uint32 countMin = moonfire->GetMaxDuration();
  1263. uint32 countMax = moonfire->GetSpellInfo()->GetMaxDuration() + 9000;
  1264. if (caster->HasAura(SPELL_DRUID_INCREASED_MOONFIRE_DURATION))
  1265. countMax += 3000;
  1266.  
  1267. if (countMin < countMax)
  1268. {
  1269. moonfire->SetDuration(uint32(moonfire->GetDuration() + 3000), false, true);
  1270. moonfire->SetMaxDuration(countMin + 3000);
  1271. }
  1272. }
  1273. }
  1274.  
  1275. void Register()
  1276. {
  1277. OnHit += SpellHitFn(spell_dru_glyph_of_starfire_SpellScript::HandleOnHit);
  1278. }
  1279. };
  1280.  
  1281. SpellScript* GetSpellScript() const
  1282. {
  1283. return new spell_dru_glyph_of_starfire_SpellScript();
  1284. }
  1285. };
  1286.  
  1287. // 34246 - Idol of the Emerald Queen
  1288. // 60779 - Idol of Lush Moss
  1289. class spell_dru_idol_lifebloom : public SpellScriptLoader
  1290. {
  1291. public:
  1292. spell_dru_idol_lifebloom() : SpellScriptLoader("spell_dru_idol_lifebloom") { }
  1293.  
  1294. class spell_dru_idol_lifebloom_AuraScript : public AuraScript
  1295. {
  1296. PrepareAuraScript(spell_dru_idol_lifebloom_AuraScript);
  1297.  
  1298. void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod)
  1299. {
  1300. if (!spellMod)
  1301. {
  1302. spellMod = new SpellModifier(GetAura());
  1303. spellMod->op = SPELLMOD_DOT;
  1304. spellMod->type = SPELLMOD_FLAT;
  1305. spellMod->spellId = GetId();
  1306. spellMod->mask = GetSpellInfo()->Effects[aurEff->GetEffIndex()].SpellClassMask;
  1307. }
  1308. spellMod->value = aurEff->GetAmount() / 7;
  1309. }
  1310.  
  1311. void Register()
  1312. {
  1313. DoEffectCalcSpellMod += AuraEffectCalcSpellModFn(spell_dru_idol_lifebloom_AuraScript::HandleEffectCalcSpellMod, EFFECT_0, SPELL_AURA_DUMMY);
  1314. }
  1315. };
  1316.  
  1317. AuraScript* GetAuraScript() const
  1318. {
  1319. return new spell_dru_idol_lifebloom_AuraScript();
  1320. }
  1321. };
  1322.  
  1323. // -5570 - Insect Swarm
  1324. class spell_dru_insect_swarm : public SpellScriptLoader
  1325. {
  1326. public:
  1327. spell_dru_insect_swarm() : SpellScriptLoader("spell_dru_insect_swarm") { }
  1328.  
  1329. class spell_dru_insect_swarm_AuraScript : public AuraScript
  1330. {
  1331. PrepareAuraScript(spell_dru_insect_swarm_AuraScript);
  1332.  
  1333. void CalculateAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/)
  1334. {
  1335. if (Unit* caster = GetCaster())
  1336. if (AuraEffect const* relicAurEff = caster->GetAuraEffect(SPELL_DRUID_ITEM_T8_BALANCE_RELIC, EFFECT_0))
  1337. amount += relicAurEff->GetAmount() / aurEff->GetTotalTicks();
  1338. }
  1339.  
  1340. void Register()
  1341. {
  1342. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_insect_swarm_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
  1343. }
  1344. };
  1345.  
  1346. AuraScript* GetAuraScript() const
  1347. {
  1348. return new spell_dru_insect_swarm_AuraScript();
  1349. }
  1350. };
  1351.  
  1352. class spell_dru_lifebloom : public SpellScriptLoader
  1353. {
  1354. public:
  1355. spell_dru_lifebloom() : SpellScriptLoader("spell_dru_lifebloom") { }
  1356.  
  1357. class spell_dru_lifebloom_AuraScript : public AuraScript
  1358. {
  1359. PrepareAuraScript(spell_dru_lifebloom_AuraScript);
  1360.  
  1361. bool Validate(SpellInfo const* /*spell*/)
  1362. {
  1363. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_LIFEBLOOM_FINAL_HEAL))
  1364. return false;
  1365. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_LIFEBLOOM_ENERGIZE))
  1366. return false;
  1367. return true;
  1368. }
  1369.  
  1370. void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  1371. {
  1372. // Final heal only on duration end
  1373. if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
  1374. return;
  1375.  
  1376. // final heal
  1377. int32 stack = GetStackAmount();
  1378. int32 healAmount = aurEff->GetAmount();
  1379. if (Unit* caster = GetCaster())
  1380. {
  1381. healAmount = caster->SpellHealingBonusDone(GetTarget(), GetSpellInfo(), healAmount, HEAL, stack);
  1382. healAmount = GetTarget()->SpellHealingBonusTaken(GetSpellInfo(), healAmount, HEAL, stack, GetCasterGUID());
  1383.  
  1384. GetTarget()->CastCustomSpell(GetTarget(), SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
  1385.  
  1386. // restore mana
  1387. int32 returnMana = CalculatePct(caster->GetCreateMana(), GetSpellInfo()->ManaCostPercentage) * stack / 2;
  1388. caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
  1389. return;
  1390. }
  1391.  
  1392. GetTarget()->CastCustomSpell(GetTarget(), SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
  1393. }
  1394.  
  1395. void HandleDispel(DispelInfo* dispelInfo)
  1396. {
  1397. if (Unit* target = GetUnitOwner())
  1398. {
  1399. if (AuraEffect const* aurEff = GetEffect(EFFECT_1))
  1400. {
  1401. // final heal
  1402. int32 healAmount = aurEff->GetAmount();
  1403. if (Unit* caster = GetCaster())
  1404. {
  1405. healAmount = caster->SpellHealingBonusDone(target, GetSpellInfo(), healAmount, HEAL, dispelInfo->GetRemovedCharges());
  1406. healAmount = target->SpellHealingBonusTaken(GetSpellInfo(), healAmount, HEAL, dispelInfo->GetRemovedCharges(), GetCasterGUID());
  1407. target->CastCustomSpell(target, SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, NULL, GetCasterGUID());
  1408.  
  1409. // restore mana
  1410. int32 returnMana = CalculatePct(caster->GetCreateMana(), GetSpellInfo()->ManaCostPercentage) * dispelInfo->GetRemovedCharges() / 2;
  1411. caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, NULL, GetCasterGUID());
  1412. return;
  1413. }
  1414.  
  1415. target->CastCustomSpell(target, SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, NULL, GetCasterGUID());
  1416. }
  1417. }
  1418. }
  1419.  
  1420. void Register()
  1421. {
  1422. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_lifebloom_AuraScript::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  1423. AfterDispel += AuraDispelFn(spell_dru_lifebloom_AuraScript::HandleDispel);
  1424. }
  1425. };
  1426.  
  1427. AuraScript* GetAuraScript() const
  1428. {
  1429. return new spell_dru_lifebloom_AuraScript();
  1430. }
  1431. };
  1432.  
  1433. // Faerie Fire
  1434. class spell_dru_faerie_fire : public SpellScriptLoader
  1435. {
  1436. public:
  1437. spell_dru_faerie_fire() : SpellScriptLoader("spell_dru_faerie_fire") { }
  1438.  
  1439. class spell_dru_faerie_fire_AuraScript : public AuraScript
  1440. {
  1441. PrepareAuraScript(spell_dru_faerie_fire_AuraScript);
  1442.  
  1443. void HandleDispel(DispelInfo* dispelInfo)
  1444. {
  1445. if (Unit* target = GetUnitOwner())
  1446. target->RemoveAura(GetId());
  1447. }
  1448.  
  1449. void Register()
  1450. {
  1451. AfterDispel += AuraDispelFn(spell_dru_faerie_fire_AuraScript::HandleDispel);
  1452. }
  1453. };
  1454.  
  1455. AuraScript* GetAuraScript() const
  1456. {
  1457. return new spell_dru_faerie_fire_AuraScript();
  1458. }
  1459. };
  1460.  
  1461. // -48496 - Living Seed
  1462. class spell_dru_living_seed : public SpellScriptLoader
  1463. {
  1464. public:
  1465. spell_dru_living_seed() : SpellScriptLoader("spell_dru_living_seed") { }
  1466.  
  1467. class spell_dru_living_seed_AuraScript : public AuraScript
  1468. {
  1469. PrepareAuraScript(spell_dru_living_seed_AuraScript);
  1470.  
  1471. bool Validate(SpellInfo const* /*spellInfo*/)
  1472. {
  1473. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_LIVING_SEED_PROC))
  1474. return false;
  1475. return true;
  1476. }
  1477.  
  1478. void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
  1479. {
  1480. PreventDefaultAction();
  1481. int32 amount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount());
  1482. GetTarget()->CastCustomSpell(SPELL_DRUID_LIVING_SEED_PROC, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, NULL, aurEff);
  1483. }
  1484.  
  1485. void Register()
  1486. {
  1487. OnEffectProc += AuraEffectProcFn(spell_dru_living_seed_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
  1488. }
  1489. };
  1490.  
  1491. AuraScript* GetAuraScript() const
  1492. {
  1493. return new spell_dru_living_seed_AuraScript();
  1494. }
  1495. };
  1496.  
  1497. // 48504 - Living Seed (Proc)
  1498. class spell_dru_living_seed_proc : public SpellScriptLoader
  1499. {
  1500. public:
  1501. spell_dru_living_seed_proc() : SpellScriptLoader("spell_dru_living_seed_proc") { }
  1502.  
  1503. class spell_dru_living_seed_proc_AuraScript : public AuraScript
  1504. {
  1505. PrepareAuraScript(spell_dru_living_seed_proc_AuraScript);
  1506.  
  1507. bool Validate(SpellInfo const* /*spellInfo*/)
  1508. {
  1509. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_LIVING_SEED_HEAL))
  1510. return false;
  1511. return true;
  1512. }
  1513.  
  1514. void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
  1515. {
  1516. PreventDefaultAction();
  1517. GetTarget()->CastCustomSpell(SPELL_DRUID_LIVING_SEED_HEAL, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), GetTarget(), true, NULL, aurEff);
  1518. }
  1519.  
  1520. void Register()
  1521. {
  1522. OnEffectProc += AuraEffectProcFn(spell_dru_living_seed_proc_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
  1523. }
  1524. };
  1525.  
  1526. AuraScript* GetAuraScript() const
  1527. {
  1528. return new spell_dru_living_seed_proc_AuraScript();
  1529. }
  1530. };
  1531.  
  1532. // 48391 - Owlkin Frenzy
  1533. class spell_dru_owlkin_frenzy : public SpellScriptLoader
  1534. {
  1535. public:
  1536. spell_dru_owlkin_frenzy() : SpellScriptLoader("spell_dru_owlkin_frenzy") { }
  1537.  
  1538. class spell_dru_owlkin_frenzy_AuraScript : public AuraScript
  1539. {
  1540. PrepareAuraScript(spell_dru_owlkin_frenzy_AuraScript);
  1541.  
  1542. void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
  1543. {
  1544. amount = CalculatePct(GetUnitOwner()->GetCreatePowers(POWER_MANA), amount);
  1545. }
  1546.  
  1547. void Register()
  1548. {
  1549. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_owlkin_frenzy_AuraScript::CalculateAmount, EFFECT_2, SPELL_AURA_PERIODIC_ENERGIZE);
  1550. }
  1551. };
  1552.  
  1553. AuraScript* GetAuraScript() const
  1554. {
  1555. return new spell_dru_owlkin_frenzy_AuraScript();
  1556. }
  1557. };
  1558.  
  1559. /*class spell_druid_frenzied_regeneration : public SpellScriptLoader
  1560. {
  1561. class script_impl : public AuraScript
  1562. {
  1563. PrepareAuraScript(script_impl);
  1564. enum
  1565. {
  1566. SPELL_FRENZIED_REGENERATION_HEAL = 22845,
  1567. SPELL_GLYPH_OF_FRENZIED_REGENERATION = 54810,
  1568. };
  1569. void HandlePeriodic(AuraEffect const* aurEff)
  1570. {
  1571. Unit* const target = GetTarget();
  1572. if (target->getPowerType() != POWER_RAGE)
  1573. return;
  1574. // Glyph of Frenzied Regeneration
  1575. if (target->HasAura(SPELL_GLYPH_OF_FRENZIED_REGENERATION))
  1576. return;
  1577. uint32 const power = target->GetPower(POWER_RAGE);
  1578. if (!power)
  1579. return;
  1580. int32 const rage = std::min<uint32>(power, 100);
  1581. float const pct = rage * aurEff->GetAmount() / 1000;
  1582. int32 const health = CalculatePct(target->GetMaxHealth(), pct);
  1583. target->CastCustomSpell(target, SPELL_FRENZIED_REGENERATION_HEAL, &health, NULL, NULL, true, 0, aurEff);
  1584. target->SetPower(POWER_RAGE, power - rage);
  1585. }
  1586. void Register()
  1587. {
  1588. OnEffectPeriodic += AuraEffectPeriodicFn(script_impl::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
  1589. }
  1590. };
  1591. public:
  1592. spell_druid_frenzied_regeneration()
  1593. : SpellScriptLoader("spell_druid_frenzied_regeneration")
  1594. {
  1595. }
  1596. AuraScript* GetAuraScript() const
  1597. {
  1598. return new script_impl();
  1599. }
  1600. };*/
  1601.  
  1602. // -16972 - Predatory Strikes
  1603. class spell_dru_predatory_strikes : public SpellScriptLoader
  1604. {
  1605. public:
  1606. spell_dru_predatory_strikes() : SpellScriptLoader("spell_dru_predatory_strikes") { }
  1607.  
  1608. class spell_dru_predatory_strikes_AuraScript : public AuraScript
  1609. {
  1610. PrepareAuraScript(spell_dru_predatory_strikes_AuraScript);
  1611.  
  1612. void UpdateAmount(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1613. {
  1614. if (Player* target = GetTarget()->ToPlayer())
  1615. target->UpdateAttackPowerAndDamage();
  1616. }
  1617.  
  1618. void Register()
  1619. {
  1620. AfterEffectApply += AuraEffectApplyFn(spell_dru_predatory_strikes_AuraScript::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
  1621. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_predatory_strikes_AuraScript::UpdateAmount, EFFECT_ALL, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
  1622. }
  1623. };
  1624.  
  1625. AuraScript* GetAuraScript() const
  1626. {
  1627. return new spell_dru_predatory_strikes_AuraScript();
  1628. }
  1629. };
  1630.  
  1631. // -1079 - Rip
  1632. class spell_dru_rip : public SpellScriptLoader
  1633. {
  1634. public:
  1635. spell_dru_rip() : SpellScriptLoader("spell_dru_rip") { }
  1636.  
  1637. class spell_dru_rip_AuraScript : public AuraScript
  1638. {
  1639. PrepareAuraScript(spell_dru_rip_AuraScript);
  1640.  
  1641. bool Load()
  1642. {
  1643. Unit* caster = GetCaster();
  1644. return caster && caster->GetTypeId() == TYPEID_PLAYER;
  1645. }
  1646.  
  1647. void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated)
  1648. {
  1649. canBeRecalculated = false;
  1650.  
  1651. if (Unit* caster = GetCaster())
  1652. {
  1653. // 0.0207 * $AP * cp
  1654. uint8 cp = caster->ToPlayer()->GetComboPoints();
  1655. float coeff = cp * 0.0207f;
  1656. amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * coeff);
  1657. }
  1658. }
  1659.  
  1660. void Register()
  1661. {
  1662. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_rip_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
  1663. }
  1664. };
  1665.  
  1666. AuraScript* GetAuraScript() const
  1667. {
  1668. return new spell_dru_rip_AuraScript();
  1669. }
  1670. };
  1671.  
  1672. // - Rake
  1673. class spell_dru_rake : public SpellScriptLoader
  1674. {
  1675. public:
  1676. spell_dru_rake() : SpellScriptLoader("spell_dru_rake") { }
  1677.  
  1678. class spell_dru_rake_AuraScript : public AuraScript
  1679. {
  1680. PrepareAuraScript(spell_dru_rake_AuraScript);
  1681.  
  1682.  
  1683. void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
  1684. {
  1685. canBeRecalculated = false;
  1686.  
  1687. if (Unit* caster = GetCaster())
  1688. {
  1689. // Ap modifier based on talent - 0.147 per talent point
  1690. float coeff = 0.441f;
  1691. if (AuraEffect* carnage = caster->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DRUID, 2725, EFFECT_0))
  1692. coeff += 0.147f * (carnage->GetAmount() / 3000);
  1693. amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * coeff) / aurEff->GetTotalTicks();
  1694. }
  1695. }
  1696.  
  1697. void Register()
  1698. {
  1699. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_rake_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_PERIODIC_DAMAGE);
  1700. }
  1701. };
  1702.  
  1703. AuraScript* GetAuraScript() const
  1704. {
  1705. return new spell_dru_rake_AuraScript();
  1706. }
  1707. };
  1708.  
  1709. // 52610 - Savage Roar
  1710. class spell_dru_savage_roar : public SpellScriptLoader
  1711. {
  1712. public:
  1713. spell_dru_savage_roar() : SpellScriptLoader("spell_dru_savage_roar") { }
  1714.  
  1715. class spell_dru_savage_roar_SpellScript : public SpellScript
  1716. {
  1717. PrepareSpellScript(spell_dru_savage_roar_SpellScript);
  1718.  
  1719. SpellCastResult CheckCast()
  1720. {
  1721. Unit* caster = GetCaster();
  1722. if (caster->GetShapeshiftForm() != FORM_CAT)
  1723. return SPELL_FAILED_ONLY_SHAPESHIFT;
  1724.  
  1725. return SPELL_CAST_OK;
  1726. }
  1727.  
  1728. void Register()
  1729. {
  1730. OnCheckCast += SpellCheckCastFn(spell_dru_savage_roar_SpellScript::CheckCast);
  1731. }
  1732. };
  1733.  
  1734. class spell_dru_savage_roar_AuraScript : public AuraScript
  1735. {
  1736. PrepareAuraScript(spell_dru_savage_roar_AuraScript);
  1737.  
  1738. bool Validate(SpellInfo const* /*spellInfo*/)
  1739. {
  1740. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_SAVAGE_ROAR))
  1741. return false;
  1742. return true;
  1743. }
  1744.  
  1745. void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  1746. {
  1747. Unit* target = GetTarget();
  1748. target->CastSpell(target, SPELL_DRUID_SAVAGE_ROAR, true, NULL, aurEff, GetCasterGUID());
  1749. }
  1750.  
  1751. void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1752. {
  1753. GetTarget()->RemoveAurasDueToSpell(SPELL_DRUID_SAVAGE_ROAR);
  1754. }
  1755.  
  1756. void Register()
  1757. {
  1758. AfterEffectApply += AuraEffectApplyFn(spell_dru_savage_roar_AuraScript::AfterApply, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  1759. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_savage_roar_AuraScript::AfterRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  1760. }
  1761. };
  1762.  
  1763. SpellScript* GetSpellScript() const
  1764. {
  1765. return new spell_dru_savage_roar_SpellScript();
  1766. }
  1767.  
  1768. AuraScript* GetAuraScript() const
  1769. {
  1770. return new spell_dru_savage_roar_AuraScript();
  1771. }
  1772. };
  1773.  
  1774. // -50286 - Starfall (Dummy)
  1775. class spell_dru_starfall_dummy : public SpellScriptLoader
  1776. {
  1777. class CombatCheck
  1778. {
  1779. Unit* const m_caster;
  1780. public:
  1781. CombatCheck(Unit* caster) : m_caster(caster)
  1782. {
  1783. }
  1784.  
  1785. bool operator() (WorldObject* unit)
  1786. {
  1787. if (unit->GetTypeId() != TYPEID_UNIT && unit->GetTypeId() != TYPEID_PLAYER)
  1788. return true;
  1789.  
  1790. return unit->ToUnit()->HasBreakableByDamageCrowdControlAura(m_caster);
  1791. }
  1792. };
  1793.  
  1794. class script_impl : public SpellScript
  1795. {
  1796. PrepareSpellScript(script_impl);
  1797.  
  1798. enum { MAX_SHARDS = 20 };
  1799.  
  1800. bool Load()
  1801. {
  1802. return GetTriggeringSpell();
  1803. }
  1804.  
  1805. void FilterTargets(std::list<WorldObject*>& targets)
  1806. {
  1807. targets.remove_if(CombatCheck(GetCaster()));
  1808. }
  1809.  
  1810. void HandleDummy(SpellEffIndex)
  1811. {
  1812. Unit* const caster = GetCaster();
  1813. uint32 const triggeringSpellId = GetTriggeringSpell()->Id;
  1814. AuraEffect* const aurEff = caster->GetAuraEffect(triggeringSpellId, EFFECT_0);
  1815. if (!aurEff)
  1816. return;
  1817.  
  1818. // Shapeshifting into an animal form or mounting cancels the effect
  1819. // Or if 20 Shards were fired
  1820. if (caster->GetCreatureType() == CREATURE_TYPE_BEAST || caster->IsMounted() || aurEff->userData() >= MAX_SHARDS)
  1821. {
  1822. caster->RemoveAurasDueToSpell(triggeringSpellId);
  1823. return;
  1824. }
  1825.  
  1826.  
  1827. // Any effect which causes you to lose control of your character will supress the starfall effect.
  1828. if (caster->HasUnitState(UNIT_STATE_CONTROLLED))
  1829. return;
  1830.  
  1831. caster->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true);
  1832. aurEff->setUserData(aurEff->userData() + 1);
  1833. }
  1834.  
  1835. void Register()
  1836. {
  1837. OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(script_impl::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
  1838. OnEffectHitTarget += SpellEffectFn(script_impl::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
  1839. }
  1840. };
  1841.  
  1842. public:
  1843. spell_dru_starfall_dummy()
  1844. : SpellScriptLoader("spell_dru_starfall_dummy")
  1845. {
  1846. }
  1847.  
  1848. SpellScript* GetSpellScript() const
  1849. {
  1850. return new script_impl();
  1851. }
  1852. };
  1853.  
  1854. // 61336 - Survival Instincts
  1855. class spell_dru_survival_instincts : public SpellScriptLoader
  1856. {
  1857. public:
  1858. spell_dru_survival_instincts() : SpellScriptLoader("spell_dru_survival_instincts") { }
  1859.  
  1860. class spell_dru_survival_instincts_SpellScript : public SpellScript
  1861. {
  1862. PrepareSpellScript(spell_dru_survival_instincts_SpellScript);
  1863.  
  1864. SpellCastResult CheckCast()
  1865. {
  1866. Unit* caster = GetCaster();
  1867. if (!caster->IsInFeralForm())
  1868. return SPELL_FAILED_ONLY_SHAPESHIFT;
  1869.  
  1870. return SPELL_CAST_OK;
  1871. }
  1872.  
  1873. void Register()
  1874. {
  1875. OnCheckCast += SpellCheckCastFn(spell_dru_survival_instincts_SpellScript::CheckCast);
  1876. }
  1877. };
  1878.  
  1879. class spell_dru_survival_instincts_AuraScript : public AuraScript
  1880. {
  1881. PrepareAuraScript(spell_dru_survival_instincts_AuraScript);
  1882.  
  1883. bool Validate(SpellInfo const* /*spell*/)
  1884. {
  1885. if (!sSpellMgr->GetSpellInfo(SPELL_DRUID_SURVIVAL_INSTINCTS))
  1886. return false;
  1887. return true;
  1888. }
  1889.  
  1890. void AfterApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  1891. {
  1892. Unit* target = GetTarget();
  1893. target->CastSpell(target, SPELL_DRUID_SURVIVAL_INSTINCTS, true);
  1894. }
  1895.  
  1896. void Register()
  1897. {
  1898. AfterEffectApply += AuraEffectApplyFn(spell_dru_survival_instincts_AuraScript::AfterApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
  1899. }
  1900. };
  1901.  
  1902. SpellScript* GetSpellScript() const
  1903. {
  1904. return new spell_dru_survival_instincts_SpellScript();
  1905. }
  1906.  
  1907. AuraScript* GetAuraScript() const
  1908. {
  1909. return new spell_dru_survival_instincts_AuraScript();
  1910. }
  1911. };
  1912.  
  1913. // 40121 - Swift Flight Form (Passive)
  1914. class spell_dru_swift_flight_passive : public SpellScriptLoader
  1915. {
  1916. public:
  1917. spell_dru_swift_flight_passive() : SpellScriptLoader("spell_dru_swift_flight_passive") { }
  1918.  
  1919. class spell_dru_swift_flight_passive_AuraScript : public AuraScript
  1920. {
  1921. PrepareAuraScript(spell_dru_swift_flight_passive_AuraScript);
  1922.  
  1923. bool Load()
  1924. {
  1925. return GetCaster()->GetTypeId() == TYPEID_PLAYER;
  1926. }
  1927.  
  1928. void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
  1929. {
  1930. if (Player* caster = GetCaster()->ToPlayer())
  1931. if (caster->GetSkillValue(SKILL_RIDING) >= 375)
  1932. amount = 310;
  1933. }
  1934.  
  1935. void Register()
  1936. {
  1937. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_swift_flight_passive_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED);
  1938. }
  1939. };
  1940.  
  1941. AuraScript* GetAuraScript() const
  1942. {
  1943. return new spell_dru_swift_flight_passive_AuraScript();
  1944. }
  1945. };
  1946.  
  1947. // -5217 - Tiger's Fury
  1948. class spell_dru_tiger_s_fury : public SpellScriptLoader
  1949. {
  1950. public:
  1951. spell_dru_tiger_s_fury() : SpellScriptLoader("spell_dru_tiger_s_fury") { }
  1952.  
  1953. class spell_dru_tiger_s_fury_AuraScript : public AuraScript
  1954. {
  1955. PrepareAuraScript(spell_dru_tiger_s_fury_AuraScript);
  1956.  
  1957. bool Validate(SpellInfo const* /*spell*/)
  1958. {
  1959. if (!sSpellMgr->GetSpellInfo(5217))
  1960. return false;
  1961. return true;
  1962. }
  1963.  
  1964. void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1965. {
  1966. if (Unit* caster = GetCaster())
  1967. {
  1968. if (AuraEffect* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2850, 1))
  1969. {
  1970. int32 bp0 = aurEff->GetAmount();
  1971. caster->CastCustomSpell(caster, 51178, &bp0, 0, 0, true); // King of the Jungle
  1972. }
  1973. if (caster->HasAura(80316)) // Primal Madness (rank 1)
  1974. caster->CastSpell(caster, 80879, true);
  1975.  
  1976. if (caster->HasAura(80317)) // Primal Madness (rank 1)
  1977. caster->CastSpell(caster, 80886, true);
  1978. }
  1979. }
  1980.  
  1981. void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1982. {
  1983. if (Unit* caster = GetCaster())
  1984. {
  1985. if (caster->HasAura(80316))
  1986. caster->RemoveAura(80879);
  1987.  
  1988. if (caster->HasAura(80317))
  1989. caster->RemoveAura(80886);
  1990. }
  1991. }
  1992.  
  1993. void Register()
  1994. {
  1995. AfterEffectApply += AuraEffectApplyFn(spell_dru_tiger_s_fury_AuraScript::AfterApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
  1996. AfterEffectRemove += AuraEffectRemoveFn(spell_dru_tiger_s_fury_AuraScript::AfterRemove, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
  1997. }
  1998. };
  1999.  
  2000. AuraScript* GetAuraScript() const
  2001. {
  2002. return new spell_dru_tiger_s_fury_AuraScript();
  2003. }
  2004. };
  2005.  
  2006. // -61391 - Typhoon
  2007. class spell_dru_typhoon : public SpellScriptLoader
  2008. {
  2009. public:
  2010. spell_dru_typhoon() : SpellScriptLoader("spell_dru_typhoon") { }
  2011.  
  2012. class spell_dru_typhoon_SpellScript : public SpellScript
  2013. {
  2014. PrepareSpellScript(spell_dru_typhoon_SpellScript);
  2015.  
  2016. void HandleKnockBack(SpellEffIndex effIndex)
  2017. {
  2018. // Glyph of Typhoon
  2019. if (GetCaster()->HasAura(SPELL_DRUID_GLYPH_OF_TYPHOON))
  2020. PreventHitDefaultEffect(effIndex);
  2021. }
  2022.  
  2023. void Register()
  2024. {
  2025. OnEffectHitTarget += SpellEffectFn(spell_dru_typhoon_SpellScript::HandleKnockBack, EFFECT_0, SPELL_EFFECT_KNOCK_BACK);
  2026. }
  2027. };
  2028.  
  2029. SpellScript* GetSpellScript() const
  2030. {
  2031. return new spell_dru_typhoon_SpellScript();
  2032. }
  2033. };
  2034.  
  2035. // 70691 - Item T10 Restoration 4P Bonus
  2036. class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader
  2037. {
  2038. public:
  2039. spell_dru_t10_restoration_4p_bonus() : SpellScriptLoader("spell_dru_t10_restoration_4p_bonus") { }
  2040.  
  2041. class spell_dru_t10_restoration_4p_bonus_SpellScript : public SpellScript
  2042. {
  2043. PrepareSpellScript(spell_dru_t10_restoration_4p_bonus_SpellScript);
  2044.  
  2045. bool Load()
  2046. {
  2047. return GetCaster()->GetTypeId() == TYPEID_PLAYER;
  2048. }
  2049.  
  2050. void FilterTargets(std::list<WorldObject*>& targets)
  2051. {
  2052. if (!GetCaster()->ToPlayer()->GetGroup())
  2053. {
  2054. targets.clear();
  2055. targets.push_back(GetCaster());
  2056. }
  2057. else
  2058. {
  2059. targets.remove(GetExplTargetUnit());
  2060. std::list<Unit*> tempTargets;
  2061. for (std::list<WorldObject*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr)
  2062. if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith((*itr)->ToUnit()))
  2063. tempTargets.push_back((*itr)->ToUnit());
  2064.  
  2065. if (tempTargets.empty())
  2066. {
  2067. targets.clear();
  2068. FinishCast(SPELL_FAILED_DONT_REPORT);
  2069. return;
  2070. }
  2071.  
  2072. Unit* target = Trinity::Containers::SelectRandomContainerElement(tempTargets);
  2073. targets.clear();
  2074. targets.push_back(target);
  2075. }
  2076. }
  2077.  
  2078. void Register()
  2079. {
  2080. OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_t10_restoration_4p_bonus_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
  2081. }
  2082. };
  2083.  
  2084. SpellScript* GetSpellScript() const
  2085. {
  2086. return new spell_dru_t10_restoration_4p_bonus_SpellScript();
  2087. }
  2088. };
  2089.  
  2090. // Thorns
  2091. class spell_dru_thorns : public SpellScriptLoader
  2092. {
  2093. public:
  2094. spell_dru_thorns() : SpellScriptLoader("spell_dru_thorns") { }
  2095.  
  2096. class spell_dru_thorns_AuraScript : public AuraScript
  2097. {
  2098. PrepareAuraScript(spell_dru_thorns_AuraScript);
  2099.  
  2100. void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
  2101. {
  2102. if (Unit* caster = GetCaster())
  2103. {
  2104. float coeff = 0.168f;
  2105. if (caster->HasSpell(33876))
  2106. amount = caster->GetTotalAttackPowerValue(BASE_ATTACK) * coeff;
  2107. else
  2108. amount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * coeff;
  2109. }
  2110. }
  2111.  
  2112. void Register()
  2113. {
  2114. DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_dru_thorns_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_DAMAGE_SHIELD);
  2115. }
  2116. };
  2117.  
  2118. AuraScript* GetAuraScript() const
  2119. {
  2120. return new spell_dru_thorns_AuraScript();
  2121. }
  2122. };
  2123.  
  2124. class spell_druid_t12_4p_restoration_item_bonus : public SpellScriptLoader
  2125. {
  2126. class script_impl : public AuraScript
  2127. {
  2128. PrepareAuraScript(script_impl);
  2129.  
  2130. enum { SPELL_RUNIC_ENERGIZE = 61258 };
  2131.  
  2132. bool CheckProc(ProcEventInfo& procInfo)
  2133. {
  2134. SpellInfo const* const spellInfo = procInfo.GetSpellInfo();
  2135. if (!spellInfo)
  2136. return false;
  2137.  
  2138. HealInfo* const healInfo = procInfo.GetHealInfo();
  2139. if (!healInfo || !healInfo->GetHeal())
  2140. return false;
  2141.  
  2142. return SelectFriendlyTarget();
  2143. }
  2144.  
  2145.  
  2146. void HandleProc(AuraEffect const*, ProcEventInfo& procInfo)
  2147. {
  2148. Unit* const target = SelectFriendlyTarget();
  2149.  
  2150. int32 const value = int32(procInfo.GetHealInfo()->GetHeal());
  2151. GetTarget()->CastCustomSpell(target, procInfo.GetSpellInfo()->Id, &value, NULL, NULL, true);
  2152. }
  2153.  
  2154.  
  2155. Unit* SelectFriendlyTarget() const
  2156. {
  2157. Unit* unit = NULL;
  2158. Unit* const target = GetTarget();
  2159.  
  2160. Trinity::MostHPMissingInRange check(target, 15.0f, 1);
  2161. Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(target, unit, check);
  2162. target->VisitNearbyObject(15.0f, searcher);
  2163.  
  2164. return unit;
  2165. }
  2166.  
  2167.  
  2168. void Register()
  2169. {
  2170. DoCheckProc += AuraCheckProcFn(script_impl::CheckProc);
  2171. OnEffectProc += AuraEffectProcFn(script_impl::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
  2172. }
  2173. };
  2174.  
  2175. public:
  2176. spell_druid_t12_4p_restoration_item_bonus()
  2177. : SpellScriptLoader("spell_druid_t12_4p_restoration_item_bonus")
  2178. {
  2179. }
  2180.  
  2181. AuraScript* GetAuraScript() const
  2182. {
  2183. return new script_impl();
  2184. }
  2185. };
  2186.  
  2187. class spell_druid_ferocious_bite : public SpellScriptLoader
  2188. {
  2189. class script_impl : public SpellScript
  2190. {
  2191. PrepareSpellScript(script_impl);
  2192.  
  2193. enum { SPELL_BLOOD_IN_THE_WATER = 80318 };
  2194.  
  2195. void HandleScript(SpellEffIndex)
  2196. {
  2197. Unit* const caster = GetCaster();
  2198. Unit* const target = GetHitUnit();
  2199. if (caster->GetTypeId() != TYPEID_PLAYER || !target)
  2200. return;
  2201.  
  2202. // Blood in the Water
  2203. if (AuraEffect const* const aurEff = caster->GetAuraEffectOfRankedSpell(SPELL_BLOOD_IN_THE_WATER, EFFECT_0))
  2204. {
  2205. uint8 const rank = sSpellMgr->GetSpellRank(aurEff->GetId());
  2206. uint32 const spellId = aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].TriggerSpell;
  2207.  
  2208. if (target->HealthBelowPct(aurEff->GetAmount() + 1) && roll_chance_i(50 * rank))
  2209. caster->CastSpell(caster, spellId, true);
  2210. }
  2211. }
  2212.  
  2213.  
  2214. void Register()
  2215. {
  2216. OnEffectHitTarget += SpellEffectFn(script_impl::HandleScript, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  2217. }
  2218. };
  2219.  
  2220. public:
  2221. spell_druid_ferocious_bite()
  2222. : SpellScriptLoader("spell_druid_ferocious_bite")
  2223. {
  2224. }
  2225.  
  2226. SpellScript* GetSpellScript() const
  2227. {
  2228. return new script_impl();
  2229. }
  2230. };
  2231.  
  2232. class spell_druid_blood_in_the_water : public SpellScriptLoader
  2233. {
  2234. class script_impl : public SpellScript
  2235. {
  2236. PrepareSpellScript(script_impl);
  2237.  
  2238. enum { SPELL_RIP = 1079 };
  2239.  
  2240. void HandleScript(SpellEffIndex effIndex)
  2241. {
  2242. Unit* const target = GetHitUnit();
  2243. if (!target)
  2244. return;
  2245.  
  2246. // Rip
  2247. if (Aura* const aura = target->GetAura(SPELL_RIP, GetCaster()->GetGUID()))
  2248. aura->RefreshDuration();
  2249. }
  2250.  
  2251. void Register()
  2252. {
  2253. OnEffectHitTarget += SpellEffectFn(script_impl::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
  2254. }
  2255. };
  2256.  
  2257. public:
  2258. spell_druid_blood_in_the_water()
  2259. : SpellScriptLoader("spell_druid_blood_in_the_water")
  2260. {
  2261. }
  2262.  
  2263. SpellScript* GetSpellScript() const
  2264. {
  2265. return new script_impl();
  2266. }
  2267. };
  2268.  
  2269. class spell_druid_shred_maul : public SpellScriptLoader
  2270. {
  2271. class script_impl : public SpellScript
  2272. {
  2273. PrepareSpellScript(script_impl);
  2274.  
  2275. enum { SPELL_REND_AND_TEAR = 48432 };
  2276.  
  2277. void HandleOnHit()
  2278. {
  2279. if (AuraEffect const* const aurEff = GetCaster()->GetAuraEffectOfRankedSpell(SPELL_REND_AND_TEAR, EFFECT_0))
  2280. {
  2281. Unit* const target = GetHitUnit();
  2282. if (!target || !target->HasAuraState(AURA_STATE_BLEEDING))
  2283. return;
  2284.  
  2285. int32 value = GetHitDamage();
  2286. AddPct(value, aurEff->GetAmount());
  2287. SetHitDamage(value);
  2288. }
  2289. }
  2290.  
  2291.  
  2292. void Register()
  2293. {
  2294. OnHit += SpellHitFn(script_impl::HandleOnHit);
  2295. }
  2296. };
  2297.  
  2298. public:
  2299. spell_druid_shred_maul()
  2300. : SpellScriptLoader("spell_druid_shred_maul")
  2301. {
  2302. }
  2303.  
  2304. SpellScript* GetSpellScript() const
  2305. {
  2306. return new script_impl();
  2307. }
  2308. };
  2309.  
  2310. class spell_druid_regrowth : public SpellScriptLoader
  2311. {
  2312. class script_impl : public AuraScript
  2313. {
  2314. PrepareAuraScript(script_impl);
  2315.  
  2316. enum { SPELL_GLYPH_OF_REGROWTH = 54743 };
  2317.  
  2318. bool Load()
  2319. {
  2320. Unit const* const caster = GetCaster();
  2321. return caster && caster->GetTypeId() == TYPEID_PLAYER;
  2322. }
  2323.  
  2324.  
  2325. void OnPeriodic(AuraEffect const* aurEff)
  2326. {
  2327. Unit const* const caster = GetCaster();
  2328. if (caster)
  2329. if(AuraEffect const* const regrowth = caster->GetAuraEffect(SPELL_GLYPH_OF_REGROWTH, EFFECT_0))
  2330. if (!GetTarget()->HealthAbovePct(regrowth->GetAmount()))
  2331. aurEff->GetBase()->RefreshDuration();
  2332. }
  2333.  
  2334. void Register()
  2335. {
  2336. OnEffectPeriodic += AuraEffectPeriodicFn(script_impl::OnPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_HEAL);
  2337. }
  2338. };
  2339.  
  2340. public:
  2341. spell_druid_regrowth()
  2342. : SpellScriptLoader("spell_druid_regrowth")
  2343. {
  2344. }
  2345.  
  2346. AuraScript* GetAuraScript() const
  2347. {
  2348. return new script_impl();
  2349. }
  2350. };
  2351.  
  2352. // pulverize
  2353. class spell_dru_pulverize : public SpellScriptLoader
  2354. {
  2355. public:
  2356. spell_dru_pulverize() : SpellScriptLoader("spell_dru_pulverize") { }
  2357.  
  2358. class spell_dru_pulverize_SpellScript : public SpellScript
  2359. {
  2360. PrepareSpellScript(spell_dru_pulverize_SpellScript);
  2361.  
  2362. void OnHit()
  2363. {
  2364. if (Unit* caster=GetCaster())
  2365. {
  2366. if (Unit* target=GetHitUnit())
  2367. {
  2368. if (AuraEffect const* lacerate = target->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_DRUID,0x00000000,0x00000100,0x00000000,caster->GetGUID()))
  2369. {
  2370. int32 bp0 = 3*lacerate->GetBase()->GetStackAmount();
  2371. caster->CastCustomSpell(caster,80951,&bp0,0,0,true);
  2372. target->RemoveAura(lacerate->GetBase());
  2373. }
  2374. }
  2375. }
  2376. }
  2377.  
  2378. void Register()
  2379. {
  2380.  
  2381. AfterHit += SpellHitFn(spell_dru_pulverize_SpellScript::OnHit);
  2382. }
  2383. };
  2384.  
  2385. SpellScript* GetSpellScript() const
  2386. {
  2387. return new spell_dru_pulverize_SpellScript();
  2388. }
  2389. };
  2390.  
  2391. // lacerate
  2392. class spell_dru_lacerate : public SpellScriptLoader
  2393. {
  2394. public:
  2395. spell_dru_lacerate() : SpellScriptLoader("spell_dru_lacerate") { }
  2396.  
  2397. class spell_dru_lacerate_AuraScript : public AuraScript
  2398. {
  2399. PrepareAuraScript(spell_dru_lacerate_AuraScript);
  2400.  
  2401. bool Validate(SpellInfo const* /*spell*/)
  2402. {
  2403. if (!sSpellMgr->GetSpellInfo(50334))
  2404. return false;
  2405. return true;
  2406. }
  2407.  
  2408. void OnPeriodic(AuraEffect const* aurEff)
  2409. {
  2410. if(Unit* caster = GetCaster())
  2411. {
  2412. if (Player* player = caster->ToPlayer())
  2413. {
  2414. // Berserk
  2415. if(player->HasTalent(50334, player->GetActiveSpec()))
  2416. {
  2417. if(roll_chance_i(50))
  2418. {
  2419. player->RemoveSpellCooldown(33878, true);
  2420. player->CastSpell(player, 93622, true);
  2421. }
  2422. }
  2423. }
  2424. }
  2425. }
  2426.  
  2427. void Register()
  2428. {
  2429. OnEffectPeriodic += AuraEffectPeriodicFn(spell_dru_lacerate_AuraScript::OnPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
  2430. }
  2431. };
  2432.  
  2433. AuraScript* GetAuraScript() const
  2434. {
  2435. return new spell_dru_lacerate_AuraScript();
  2436. }
  2437. };
  2438.  
  2439. class RaidCheck
  2440. {
  2441. public:
  2442. explicit RaidCheck(Unit const* caster) : _caster(caster) { }
  2443.  
  2444. bool operator()(WorldObject* obj) const
  2445. {
  2446. if (Unit* target = obj->ToUnit())
  2447. return !_caster->IsInRaidWith(target);
  2448.  
  2449. return true;
  2450. }
  2451.  
  2452. private:
  2453. Unit const* _caster;
  2454. };
  2455.  
  2456. // 48438 - Wild Growth
  2457. class spell_dru_wild_growth : public SpellScriptLoader
  2458. {
  2459. public:
  2460. spell_dru_wild_growth() : SpellScriptLoader("spell_dru_wild_growth") { }
  2461.  
  2462. class spell_dru_wild_growth_SpellScript : public SpellScript
  2463. {
  2464. PrepareSpellScript(spell_dru_wild_growth_SpellScript);
  2465.  
  2466. bool Validate(SpellInfo const* spellInfo)
  2467. {
  2468. if (spellInfo->Effects[EFFECT_2].IsEffect() || spellInfo->Effects[EFFECT_2].CalcValue() <= 0)
  2469. return false;
  2470. return true;
  2471. }
  2472.  
  2473. void FilterTargets(std::list<WorldObject*>& targets)
  2474. {
  2475. targets.remove_if(RaidCheck(GetCaster()));
  2476.  
  2477. uint32 const maxTargets = uint32(GetSpellInfo()->Effects[EFFECT_2].CalcValue(GetCaster()));
  2478.  
  2479. if (targets.size() > maxTargets)
  2480. {
  2481. targets.sort(Trinity::HealthPctOrderPred());
  2482. targets.resize(maxTargets);
  2483. }
  2484.  
  2485. _targets = targets;
  2486. }
  2487.  
  2488. void SetTargets(std::list<WorldObject*>& targets)
  2489. {
  2490. targets = _targets;
  2491. }
  2492.  
  2493. void Register()
  2494. {
  2495. OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_wild_growth_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
  2496. OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_dru_wild_growth_SpellScript::SetTargets, EFFECT_1, TARGET_UNIT_DEST_AREA_ALLY);
  2497. }
  2498.  
  2499. private:
  2500. std::list<WorldObject*> _targets;
  2501. };
  2502.  
  2503. SpellScript* GetSpellScript() const
  2504. {
  2505. return new spell_dru_wild_growth_SpellScript();
  2506. }
  2507. };
  2508.  
  2509. void AddSC_druid_spell_scripts()
  2510. {
  2511. new spell_dru_dash();
  2512. new spell_dru_eclipse_energize();
  2513. new spell_dru_enrage();
  2514. new spell_dru_glyph_of_starfire();
  2515. new spell_dru_idol_lifebloom();
  2516. new spell_dru_insect_swarm();
  2517. new spell_dru_lifebloom();
  2518. new spell_dru_living_seed();
  2519. new spell_dru_living_seed_proc();
  2520. new spell_dru_owlkin_frenzy();
  2521. new spell_dru_predatory_strikes();
  2522. new spell_dru_rip();
  2523. new spell_dru_savage_roar();
  2524. new spell_dru_starfall_dummy();
  2525. new spell_dru_survival_instincts();
  2526. new spell_dru_swift_flight_passive();
  2527. new spell_dru_tiger_s_fury();
  2528. new spell_dru_typhoon();
  2529. new spell_dru_t10_restoration_4p_bonus();
  2530. new spell_dru_rejuv();
  2531. new spell_dru_emp_touch();
  2532. new spell_dru_emp_touch_triggered();
  2533. new spell_sha_efflorescence();
  2534. new spell_sha_efflorescence_heal();
  2535. new spell_dru_harmony();
  2536. new spell_dru_feral_swiftness();
  2537. new spell_dru_feral_aggression();
  2538. new spell_dru_stampede();
  2539. new spell_dru_skull_bash();
  2540. new spell_dru_primal_madness();
  2541. new spell_dru_pulverize();
  2542. new spell_dru_innervate();
  2543. new spell_dru_beam();
  2544. new spell_dru_wild_mushroom();
  2545. new spell_dru_wild_mushroom_detonation();
  2546. new spell_dru_rake();
  2547. //new spell_druid_frenzied_regeneration();
  2548. new spell_dru_barkskin();
  2549. new spell_dru_energize();
  2550. new spell_dru_starsurge();
  2551. new spell_dru_faerie_fire();
  2552. new spell_dru_thorns();
  2553. new spell_druid_ferocious_bite();
  2554. new spell_druid_blood_in_the_water();
  2555. new spell_druid_shred_maul();
  2556. new spell_druid_regrowth();
  2557. new spell_dru_lacerate();
  2558. new spell_dru_wild_growth();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement