/// <summary>Checks that the mob is not in a state that disallows spell casting (silenced, feared, etc.)</summary> internal virtual bool TrySpellCasting(ushort spellId) { if (_castingSpell != null || _delayTimer || _spellEndTimer.Enabled || _stunned || _feared || _mezzed || _silenced) { _log.WarnFormat("Spell casting canceled: unable to cast due to Casting:{0}, Waiting: {1} Recast Timer Enabled:{2}, Stunned:{3}, Feared:{4}, Mez'd:{5}, Silenced:{6}", _castingSpell.SpellID, _delayTimer, _spellEndTimer.Enabled, _stunned, _feared, _mezzed, _silenced); return false; } // TODO: check for divine aura (can't cast if using) // Raise event so that zone can run its checks (no-combat, blocked spells, etc.) TryCastEventArgs tce = new TryCastEventArgs() { SpellId = spellId, Allowed = true }; OnTryingToCast(tce); return tce.Allowed; }
protected void OnTryingToCast(TryCastEventArgs e) { EventHandler<TryCastEventArgs> handler = TryingToCast; if (handler != null) handler(this, e); }
// Fired when mob is running checks for if it can cast a spell / use an ability, etc. void Mob_TryingToCast(object sender, TryCastEventArgs e) { // No combat zone == no detrimental spells if (!_zoneSvr.Zone.CanCombat && (sender as Mob).GetSpell(e.SpellId).IsDetrimental) { e.Allowed = false; if (sender is ZonePlayer) (sender as ZonePlayer).MsgMgr.SendMessageID((uint)MessageType.Common13, MessageStrings.SPELL_WOULDNT_HOLD); } // TODO: check for blocked spells in zone, can levitate, outdoor/indoor, gate prevention (GMs ignore) }