public static bool FitsTrapTargetRestriction(CLRScriptBase s, ALFA.Shared.ActiveTrap trap, uint target)
 {
     if (s.GetIsDead(target, FALSE) == TRUE)
     {
         return(false);
     }
     if (trap.TargetAlignment != ALIGNMENT_ALL)
     {
         if ((trap.TargetAlignment == ALIGNMENT_CHAOTIC ||
              trap.TargetAlignment == ALIGNMENT_LAWFUL ||
              trap.TargetAlignment == ALIGNMENT_NEUTRAL) &&
             s.GetAlignmentLawChaos(target) != trap.TargetAlignment)
         {
             return(false);
         }
         if ((trap.TargetAlignment == ALIGNMENT_GOOD ||
              trap.TargetAlignment == ALIGNMENT_EVIL ||
              trap.TargetAlignment == ALIGNMENT_NEUTRAL) &&
             s.GetAlignmentGoodEvil(target) != trap.TargetAlignment)
         {
             return(false);
         }
     }
     if (trap.TargetRace != RACIAL_TYPE_ALL)
     {
         if (trap.TargetRace != s.GetRacialType(target))
         {
             return(false);
         }
     }
     return(true);
 }
        public static void ActivateLongTermBuffs(uint oCaster, CLRScriptBase s)
        {
            // Cast protection from good/evil based on alignment.
            if (s.GetAlignmentGoodEvil(oCaster) == CLRScriptBase.ALIGNMENT_EVIL)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_GOOD, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_EVIL, s);
            }

            // Buff armor, if the creature has any.
            uint oItem = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, s.OBJECT_SELF);

            if (oItem != CLRScriptBase.OBJECT_INVALID)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_VESTMENT, s, oItem);
            }

            // Buff the shield, if the creature has one.
            uint oLeftHandItem  = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_LEFTHAND, oCaster);
            uint oRightHandItem = s.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_RIGHTHAND, oCaster);
            int  nLeftItemType  = s.GetBaseItemType(oLeftHandItem);
            int  nRightItemType = s.GetBaseItemType(oRightHandItem);

            if (GetIsItemShield(oLeftHandItem, s) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_VESTMENT, s, oLeftHandItem);
            }

            // FIX ME!! Weapon-buffing should be more intelligent. But we need to be
            // able to tell what a weapon is.
            _QuickBuff(oCaster, CLRScriptBase.SPELL_KEEN_EDGE, s);
            if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_MAGIC_WEAPON, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_MAGIC_WEAPON, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGIC_WEAPON, s);
            }
            _QuickBuff(oCaster, CLRScriptBase.SPELL_WEAPON_OF_IMPACT, s);

            _QuickBuff(oCaster, CLRScriptBase.SPELL_BARKSKIN, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_SPIDERSKIN, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_CONVICTION, s);

            if (s.GetHasSpell(CLRScriptBase.SPELL_PROTECTION_FROM_ENERGY, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_ENERGY, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_ENDURE_ELEMENTS, s);
            }

            _QuickBuff(oCaster, CLRScriptBase.SPELL_FREEDOM_OF_MOVEMENT, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_HEROISM, s);

            if (s.GetHasSpell(CLRScriptBase.SPELL_IMPROVED_MAGE_ARMOR, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_IMPROVED_MAGE_ARMOR, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_MAGE_ARMOR, s);
            }

            if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_PLANAR_BINDING, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_PLANAR_BINDING, s);
            }
            else if (s.GetHasSpell(CLRScriptBase.SPELL_PLANAR_BINDING, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PLANAR_BINDING, s);
            }
            else if (s.GetHasSpell(CLRScriptBase.SPELL_PLANAR_ALLY, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PLANAR_ALLY, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_LESSER_PLANAR_BINDING, s);
            }

            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_RESISTANCE, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_MIND_BLANK, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_ONE_WITH_THE_LAND, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_PREMONITION, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_SPELLS, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_PROTECTION_FROM_ARROWS, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_BULLS_STRENGTH, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_CATS_GRACE, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_EAGLE_SPLENDOR, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_BEARS_ENDURANCE, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_FOXS_CUNNING, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_OWLS_WISDOM, s);
            _QuickBuff(oCaster, CLRScriptBase.SPELL_SEE_INVISIBILITY, s);

            if (s.GetHasSpell(CLRScriptBase.SPELL_PREMONITION, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_PREMONITION, s);
            }
            else if (s.GetHasSpell(CLRScriptBase.SPELL_GREATER_STONESKIN, oCaster) != CLRScriptBase.FALSE)
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_GREATER_STONESKIN, s);
            }
            else
            {
                _QuickBuff(oCaster, CLRScriptBase.SPELL_STONESKIN, s);
            }

            // Delay party buffs a bit in case this guy has buddies spawning in next to him.
            s.DelayCommand(6.0f, delegate { _QuickBuff(oCaster, CLRScriptBase.SPELL_MASS_CAMOFLAGE, s); });
        }