rendered paste bodyIndex: src/framework/Utilities/EventProcessor.h
===================================================================
--- src/framework/Utilities/EventProcessor.h (revision 5258)
+++ src/framework/Utilities/EventProcessor.h (working copy)
@@ -60,6 +60,15 @@
void KillAllEvents();
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
uint64 CalculateTime(uint64 t_offset);
+
+ template<class Check>
+ bool check(Check& check) const
+ {
+ for(EventList::const_iterator itr = m_events.begin(); itr != m_events.end(); ++itr)
+ if(check(itr->second))
+ return true;
+ return false;
+ }
protected:
uint64 m_time;
EventList m_events;
Index: src/game/Spell.cpp
===================================================================
--- src/game/Spell.cpp (revision 5264)
+++ src/game/Spell.cpp (working copy)
@@ -59,6 +59,27 @@
&& spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
}
+struct SpellCastItemCheck
+{
+ explicit SpellCastItemCheck(Spell* spell) : i_spell(spell), i_count(spell->m_CastItem ? spell->m_CastItem->GetCount() : 0) {}
+
+ Spell const* i_spell;
+ uint32 i_count;
+
+ bool operator() (BasicEvent const* event)
+ {
+ if(SpellEvent const* spellEvent = dynamic_cast<SpellEvent const*>(event))
+ {
+ if(spellEvent->GetSpell() != i_spell && spellEvent->GetSpell()->m_CastItem==i_spell->m_CastItem)
+ --i_count;
+
+ return !i_count;
+ }
+ else
+ return false;
+ }
+};
+
SpellCastTargets::SpellCastTargets()
{
m_unitTarget = NULL;
@@ -3618,6 +3639,11 @@
if(!proto)
return SPELL_FAILED_ITEM_NOT_READY;
+ SpellCastItemCheck check(this);
+
+ if(p_caster->m_Events.check(check)) // fail if item already used in delayed spell
+ return SPELL_FAILED_ITEM_NOT_READY;
+
for (int i = 0; i<5; i++)
{
if (proto->Spells[i].SpellCharges)
Index: src/game/Spell.h
===================================================================
--- src/game/Spell.h (revision 5258)
+++ src/game/Spell.h (working copy)
@@ -832,6 +832,8 @@
virtual bool Execute(uint64 e_time, uint32 p_time);
virtual void Abort(uint64 e_time);
+
+ Spell* GetSpell() const { return m_Spell; }
protected:
Spell* m_Spell;
};