private static void SwimHeartbeat(CLRScriptBase script, uint Creature)
 {
     uint Trigger = AppearanceTypes.currentSwimTrigger[Creature];
     foreach(uint contents in script.GetObjectsInPersistentObject(Trigger, CLRScriptBase.OBJECT_TYPE_CREATURE, CLRScriptBase.PERSISTENT_ZONE_ACTIVE))
     {
         if(contents == Creature)
         {
             if (script.GetSubRace(Creature) != CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI &&
                 script.GetLocalInt(Creature, ACR_CREATURE_AQUATIC) == 0)
             {
                 int SwimDC = script.GetLocalInt(Trigger, ACR_SWIM_DC);
                 int SinkDC = SwimDC - 5;
                 int NoAir = script.GetLocalInt(Trigger, ACR_NO_AIR);
                 int Roll = script.d20(1);
                 int Bonus = script.GetSkillRank(CLRScriptBase.SKILL_SWIM, Creature, CLRScriptBase.FALSE);
                 ProcessWaterEffects(script, Creature, Trigger);
                 if (10 + Bonus >= SwimDC)
                 {
                     // Can take 10 here.
                     Roll = 10;
                 }
                 if (Roll + Bonus >= SwimDC)
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(50)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Success!*", Roll, Bonus, Roll+Bonus, SwimDC));
                     if(NoAir == CLRScriptBase.FALSE)
                     {
                         CurrentDrownStatus.Remove(Creature);
                         CurrentDrownDC.Remove(Creature);
                     }
                     else
                     {
                         ProcessNoAir(script, Creature);
                     }
                 }
                 else if (Roll + Bonus >= SinkDC)
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC));
                     script.SendMessageToPC(Creature, String.Format("You struggle to move through the water."));
                     if (NoAir == CLRScriptBase.FALSE)
                     {
                         CurrentDrownStatus.Remove(Creature);
                         CurrentDrownDC.Remove(Creature);
                     }
                     else
                     {
                         ProcessNoAir(script, Creature);
                     }
                 }
                 else
                 {
                     script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectMovementSpeedDecrease(75)), Creature, 6.0f);
                     // TODO: Find a way to apply this penalty without completely screwing the PC's AC.
                     //script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_TEMPORARY, script.ExtraordinaryEffect(script.EffectACDecrease(2, CLRScriptBase.AC_DODGE_BONUS, CLRScriptBase.DAMAGE_TYPE_ALL)), Creature, 6.0f);
                     script.SendMessageToPC(Creature, String.Format("*Swim: {0} + {1} = {2} v. DC {3} :: Failure!*", Roll, Bonus, Roll + Bonus, SwimDC));
                     script.SendMessageToPC(Creature, String.Format("You're completely overwhelmed by the pull of the water!"));
                     ProcessNoAir(script, Creature);
                 }
             }
             else
             {
                 script.SendMessageToPC(Creature, "Your swim speed and capacity to breathe water allows you to move easily through the water.");
                 return;
             }
             script.DelayCommand(6.0f, delegate { SwimHeartbeat(script, Creature); });
             return;
         }
     }
     AppearanceTypes.currentSwimTrigger[Creature] = CLRScriptBase.OBJECT_INVALID;
     AppearanceTypes.characterMovement[Creature] = AppearanceTypes.MovementType.Walking;
     if (Swimming.CurrentDrownStatus.ContainsKey(Creature)) Swimming.CurrentDrownStatus.Remove(Creature);
     AppearanceTypes.RecalculateMovement(script, Creature);
 }
 public static int GetBaseAppearance(CLRScriptBase script, uint Character)
 {
     int race = script.GetRacialType(Character);
     if (race == CLRScriptBase.RACIAL_TYPE_ABERRATION ||
        race == CLRScriptBase.RACIAL_TYPE_ANIMAL ||
        race == CLRScriptBase.RACIAL_TYPE_BEAST ||
        race == CLRScriptBase.RACIAL_TYPE_CONSTRUCT ||
        race == CLRScriptBase.RACIAL_TYPE_DRAGON ||
        race == CLRScriptBase.RACIAL_TYPE_ELEMENTAL ||
        race == CLRScriptBase.RACIAL_TYPE_FEY ||
        race == CLRScriptBase.RACIAL_TYPE_GIANT ||
        race == CLRScriptBase.RACIAL_TYPE_HUMANOID_GOBLINOID ||
        race == CLRScriptBase.RACIAL_TYPE_HUMANOID_MONSTROUS ||
        race == CLRScriptBase.RACIAL_TYPE_HUMANOID_ORC ||
        race == CLRScriptBase.RACIAL_TYPE_HUMANOID_REPTILIAN ||
        race == CLRScriptBase.RACIAL_TYPE_INCORPOREAL ||
        race == CLRScriptBase.RACIAL_TYPE_INVALID ||
        race == CLRScriptBase.RACIAL_TYPE_MAGICAL_BEAST ||
        race == CLRScriptBase.RACIAL_TYPE_OOZE ||
        race == CLRScriptBase.RACIAL_TYPE_OUTSIDER ||
        race == CLRScriptBase.RACIAL_TYPE_SHAPECHANGER ||
        race == CLRScriptBase.RACIAL_TYPE_UNDEAD ||
        race == CLRScriptBase.RACIAL_TYPE_VERMIN ||
        race == CLRScriptBase.RACIAL_TYPE_YUANTI)
     {
         return -1;
     }
     else if (race == CLRScriptBase.RACIAL_TYPE_DWARF)
     {
         int subrace = script.GetSubRace(Character);
         if(subrace == CLRScriptBase.RACIAL_SUBTYPE_GOLD_DWARF)
         {
             return DwarfGoldBase;
         }
         else if(subrace == CLRScriptBase.RACIAL_SUBTYPE_GRAY_DWARF)
         {
             return DuergarBase;
         }
         return DwarfBase;
     }
     else if (race == CLRScriptBase.RACIAL_TYPE_ELF)
     {
         int subrace = script.GetSubRace(Character);
         if(subrace == CLRScriptBase.RACIAL_SUBTYPE_DROW)
         {
             return ElfDrowBase;
         }
         else if(subrace == CLRScriptBase.RACIAL_SUBTYPE_SUN_ELF)
         {
             return ElfSunBase;
         }
         else if(subrace == CLRScriptBase.RACIAL_SUBTYPE_WILD_ELF)
         {
             return ElfWildBase;
         }
         else if(subrace == CLRScriptBase.RACIAL_SUBTYPE_WOOD_ELF)
         {
             return ElfWoodBase;
         }
         return ElfBase;
     }
     else if(race == CLRScriptBase.RACIAL_TYPE_GNOME)
     {
         int subrace = script.GetSubRace(Character);
         if(subrace == CLRScriptBase.RACIAL_SUBTYPE_SVIRFNEBLIN)
         {
             return SvirfBase;
         }
         return GnomeBase;
     }
     else if (race == CLRScriptBase.RACIAL_TYPE_GRAYORC)
     {
         return HalfOrcBase;
     }
     else if (race == CLRScriptBase.RACIAL_TYPE_HALFELF)
     {
         int subrace = script.GetSubRace(Character);
         if(subrace == CLRScriptBase.RACIAL_SUBTYPE_HALFDROW)
         {
             return HalfDrowBase;
         }
         return HalfElfBase;
     }
     else if (race == CLRScriptBase.RACIAL_TYPE_HALFLING)
     {
         int subrace = script.GetSubRace(Character);
         if(subrace == CLRScriptBase.RACIAL_SUBTYPE_STRONGHEART_HALF)
         {
             return HalfStrongBase;
         }
         return HalflingBase;
     }
     else if(race == CLRScriptBase.RACIAL_TYPE_HALFORC)
     {
         return HalfOrcBase;
     }
     else if(race == CLRScriptBase.RACIAL_TYPE_HUMAN)
     {
         int subrace = script.GetSubRace(Character);
         if (subrace == CLRScriptBase.RACIAL_SUBTYPE_AASIMAR)
         {
             return AasimarBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_AIR_GENASI)
         {
             return AirGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_EARTH_GENASI)
         {
             return EarthGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_FIRE_GENASI)
         {
             return FireGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_TIEFLING)
         {
             return TieflingBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI)
         {
             return WaterGenasiBase;
         }
         return HumanBase;
     }
     else if(race == CLRScriptBase.RACIAL_TYPE_PLANETOUCHED)
     {
         int subrace = script.GetSubRace(Character);
         if (subrace == CLRScriptBase.RACIAL_SUBTYPE_AASIMAR)
         {
             return AasimarBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_AIR_GENASI)
         {
             return AirGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_EARTH_GENASI)
         {
             return EarthGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_FIRE_GENASI)
         {
             return FireGenasiBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_TIEFLING)
         {
             return TieflingBase;
         }
         else if (subrace == CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI)
         {
             return WaterGenasiBase;
         }
     }
     return -1;
 }
        private static bool GetNeedsToBreathe(CLRScriptBase script, uint Creature)
        {
            if(script.GetSubRace(Creature) == CLRScriptBase.RACIAL_SUBTYPE_AIR_GENASI ||
               script.GetSubRace(Creature) == CLRScriptBase.RACIAL_SUBTYPE_WATER_GENASI)
            {
                return false;
            }

            foreach(NWEffect effect in script.GetEffects(Creature))
            {
                int spellId = script.GetEffectSpellId(effect);
                if(spellId == CLRScriptBase.SPELL_WATER_BREATHING ||
                   spellId == CLRScriptBase.SPELL_STONE_BODY ||
                   spellId == CLRScriptBase.SPELL_LIVING_UNDEATH ||
                   spellId == CLRScriptBase.SPELL_IRON_BODY ||
                   script.GetEffectType(effect) == CLRScriptBase.EFFECT_TYPE_PETRIFY)
                {
                    return false;
                }
            }
            return true;
        }