Ejemplo n.º 1
0
        public bool CanProcBeTriggeredBy(Unit owner, IUnitAction action, bool active)
        {
            //if (CheckCasterConstraints(owner) != SpellFailedReason.Ok)
            //{
            //    return false;
            //}

            if (action.Spell != null)
            {
                if (active)
                {
                    // owner == attacker
                    if (CasterProcSpells != null)
                    {
                        return(CasterProcSpells.Contains(action.Spell));
                    }
                }
                else if (TargetProcSpells != null)
                {
                    // owner == victim
                    return(TargetProcSpells.Contains(action.Spell));
                }
                if (action.Spell == this)
                {
                    // Proc spell can't trigger itself
                    return(false);
                }
            }

            if (RequiredItemClass != ItemClass.None)
            {
                // check for weapon
                if (!(action is DamageAction))
                {
                    return(false);
                }

                var aAction = (DamageAction)action;
                if (aAction.Weapon == null || !(aAction.Weapon is Item))
                {
                    return(false);
                }

                var weapon = ((Item)aAction.Weapon).Template;

                return(weapon.Class == RequiredItemClass &&
                       (RequiredItemSubClassMask == 0 || weapon.SubClassMask.HasAnyFlag(RequiredItemSubClassMask)));
            }
            return(true);
        }