/// <summary> /// Triggers the Casting event /// </summary> internal SpellFailedReason NotifyCasting(SpellCast cast) { var evt = Casting; if (evt != null) { var err = evt(cast); if (err != SpellFailedReason.Ok) { cast.Cancel(err); return err; } } return SpellFailedReason.Ok; }
/// <summary> /// Triggers the Casting event /// </summary> internal SpellFailedReason NotifyCasting(SpellCast cast) { var evt = Casting; if (evt != null) { var err = evt(cast); if (err != SpellFailedReason.Ok) { cast.Cancel(err); return(err); } } return(SpellFailedReason.Ok); }
/// <summary> /// Somehow seems to be the same as CMSG_CANCEL_CAST /// </summary> //[ClientPacketHandler((RealmServerOpCode.CMSG_CANCEL_CHANNELLING)] public static void HandleCancelChanneling(IRealmClient client, RealmPacketIn packet) { uint spellId = packet.ReadUInt32(); var chr = client.ActiveCharacter; var mover = chr.MoveControl.Mover; //If the player is controlling another unit, ignore this if (mover != chr) { return; } SpellCast cast = chr.SpellCast; if (cast != null /* && cast.Spell.Id == spellId*/) { cast.Cancel(); } }
/// <summary> /// Triggers a new tick /// </summary> protected void Tick(int timeElapsed) { m_ticks++; var cast = m_cast; if (cast == null || !cast.IsCasting) { return; } var spell = cast.Spell; var handlers = m_channelHandlers; // consume power periodically if (spell.PowerPerSecond > 0) { var cost = spell.PowerPerSecond; if (m_amplitude != 1000 && m_amplitude != 0) { cost = (int)(cost * (m_amplitude / 1000f)); } var failReason = cast.ConsumePower(cost); if (failReason != SpellFailedReason.Ok) { m_cast.Cancel(failReason); return; } } // apply effects foreach (var handler in handlers) { handler.OnChannelTick(); if (!m_channeling) { // cancelling a handler might cancel the SpellChannel return; } } // apply all Auras remove those that went inactive in the meantime if (m_auras != null) { m_auras.RemoveAll(aura => { if (aura.IsAdded) { aura.Apply(); // remove if Aura went inactive return(!aura.IsAdded); } return(true); }); } if (m_channeling) { // Ticked event var ticked = Ticked; if (ticked != null) { ticked(this); } // Delay next tick or close if (m_maxTicks <= 0 || m_ticks >= m_maxTicks) { // we are done Close(false); if (cast.IsCasting) { cast.Cleanup(); } } //else //{ // m_timer.Start(m_amplitude); //} } }
/// <summary>Triggers a new tick</summary> protected void Tick(int timeElapsed) { ++m_ticks; SpellCast cast = m_cast; if (cast == null || !cast.IsCasting) { return; } Spell spell = cast.Spell; List <SpellEffectHandler> channelHandlers = m_channelHandlers; if (spell.PowerPerSecond > 0) { int amount = spell.PowerPerSecond; if (m_amplitude != 1000 && m_amplitude != 0) { amount = (int)(amount * (m_amplitude / 1000.0)); } SpellFailedReason reason = cast.ConsumePower(amount); if (reason != SpellFailedReason.Ok) { m_cast.Cancel(reason); return; } } foreach (SpellEffectHandler spellEffectHandler in channelHandlers) { spellEffectHandler.OnChannelTick(); if (!m_channeling) { return; } } if (m_auras != null) { m_auras.RemoveAll(aura => { if (!aura.IsAdded) { return(true); } aura.Apply(); return(!aura.IsAdded); }); } if (!m_channeling) { return; } Action <SpellChannel> ticked = Ticked; if (ticked != null) { ticked(this); } if (m_maxTicks > 0 && m_ticks < m_maxTicks) { return; } Close(false); if (!cast.IsCasting) { return; } cast.Cleanup(); }