Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. From d68964ad0ab614fb8069833a64c85cbb83995519 Mon Sep 17 00:00:00 2001
  2. From: trickerer <onlysuffering@gmail.com>
  3. Date: Sat, 19 Oct 2013 18:33:47 +0700
  4. Subject: [PATCH] Multiple spell reflection
  5.  
  6. ---
  7. src/server/game/Entities/Unit/Unit.cpp | 38 ++++++++++++++++++++++++++-
  8. src/server/game/Spells/Auras/SpellAuras.cpp | 6 +++-
  9. src/server/game/Spells/Auras/SpellAuras.h | 2 +-
  10. 3 files changed, 43 insertions(+), 3 deletions(-)
  11.  
  12. diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
  13. index 74c5014..289de71 100644
  14. --- a/src/server/game/Entities/Unit/Unit.cpp
  15. +++ b/src/server/game/Entities/Unit/Unit.cpp
  16. @@ -100,6 +100,26 @@ static bool isAlwaysTriggeredAura[TOTAL_AURAS];
  17. // Prepare lists
  18. static bool procPrepared = InitTriggerAuraData();
  19.  
  20. +class DropChargeEvent : public BasicEvent
  21. +{
  22. + public:
  23. + DropChargeEvent(Unit* target, uint32 spellId, uint64 caster = 0) : _target(target), _spellId(spellId), _caster(caster)
  24. + {
  25. + }
  26. +
  27. + bool Execute(uint64 /*time*/, uint32 /*diff*/)
  28. + {
  29. + if (Aura* aura = _target->GetAura(_spellId, _caster))
  30. + aura->DropCharge();
  31. + return true;
  32. + }
  33. +
  34. + private:
  35. + Unit* _target;
  36. + uint32 _spellId;
  37. + uint64 _caster;
  38. +};
  39. +
  40. DamageInfo::DamageInfo(Unit* _attacker, Unit* _victim, uint32 _damage, SpellInfo const* _spellInfo, SpellSchoolMask _schoolMask, DamageEffectType _damageType)
  41. : m_attacker(_attacker), m_victim(_victim), m_damage(_damage), m_spellInfo(_spellInfo), m_schoolMask(_schoolMask),
  42. m_damageType(_damageType), m_attackType(BASE_ATTACK)
  43. @@ -14259,7 +14279,23 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
  44.  
  45. // Remove charge (aura can be removed by triggers)
  46. if (prepare && useCharges && takeCharges)
  47. - i->aura->DropCharge();
  48. + {
  49. + // Set charge drop delay (only for missiles)
  50. + if ((procExtra & PROC_EX_REFLECT) && procSpell && procSpell->Speed > 0.0f)
  51. + {
  52. + // Set up missile speed based delay (from Spell.cpp: Spell::AddUnitTarget()::L2237)
  53. + int32 delay = target ? int32(floor(std::max<float>(target->GetDistance(this), 5.0f) / procSpell->Speed * 1000.0f)) : (1 * IN_MILLISECONDS) / 2;
  54. +
  55. + // Do not allow aura to be removed too soon (do not update clientside timer)
  56. + i->aura->SetDuration(std::max<int32>(i->aura->GetDuration(), delay), false, false);
  57. +
  58. + // Schedule charge drop
  59. + DropChargeEvent* dropEvent = new DropChargeEvent(this, i->aura->GetId(), i->aura->GetCasterGUID());
  60. + m_Events.AddEvent(dropEvent, m_Events.CalculateTime(delay));
  61. + }
  62. + else
  63. + i->aura->DropCharge();
  64. + }
  65.  
  66. i->aura->CallScriptAfterProcHandlers(aurApp, eventInfo);
  67.  
  68. diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
  69. index d7b8003..7b2ab01 100644
  70. --- a/src/server/game/Spells/Auras/SpellAuras.cpp
  71. +++ b/src/server/game/Spells/Auras/SpellAuras.cpp
  72. @@ -733,7 +733,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const
  73. return maxDuration;
  74. }
  75.  
  76. -void Aura::SetDuration(int32 duration, bool withMods)
  77. +void Aura::SetDuration(int32 duration, bool withMods, bool update)
  78. {
  79. if (withMods)
  80. {
  81. @@ -742,6 +742,10 @@ void Aura::SetDuration(int32 duration, bool withMods)
  82. modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, duration);
  83. }
  84. m_duration = duration;
  85. +
  86. + if (!update)
  87. + return;
  88. +
  89. SetNeedClientUpdateForTargets();
  90. }
  91.  
  92. diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
  93. index 9e7d0cc..19b8209 100644
  94. --- a/src/server/game/Spells/Auras/SpellAuras.h
  95. +++ b/src/server/game/Spells/Auras/SpellAuras.h
  96. @@ -128,7 +128,7 @@ class Aura
  97. int32 CalcMaxDuration() const { return CalcMaxDuration(GetCaster()); }
  98. int32 CalcMaxDuration(Unit* caster) const;
  99. int32 GetDuration() const { return m_duration; }
  100. - void SetDuration(int32 duration, bool withMods = false);
  101. + void SetDuration(int32 duration, bool withMods = false, bool update = true);
  102. void RefreshDuration();
  103. void RefreshTimers();
  104. bool IsExpired() const { return !GetDuration();}
  105. --
  106. 1.7.6.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement