ACR_Movement.AppearanceTypes.RecalculateMovement C# (CSharp) Method

RecalculateMovement() public static method

public static RecalculateMovement ( CLRScriptBase script, uint Creature ) : void
script CLRScriptFramework.CLRScriptBase
Creature uint
return void
        public static void RecalculateMovement(CLRScriptBase script, uint Creature)
        {
            int appType = GetBaseAppearance(script, Creature);
            if (appType < 0)
            {
                return;
            }
            if(overlandMap[Creature])
            {
                if(characterMovement[Creature] == MovementType.Riding)
                {
                    appType += Ride_02;
                    script.SetCreatureAppearanceType(Creature, appType);
                    return;
                }
                else
                {
                    appType += Walk_01;
                    script.SetCreatureAppearanceType(Creature, appType);
                    return;
                }
            }
            else if(characterMovement[Creature] == MovementType.Riding)
            {
                appType += Ride_12;
                script.SetCreatureAppearanceType(Creature, appType);
                return;
            }
            else if (characterMovement[Creature] == MovementType.Swimming)
            {
                appType += Swim;
                script.SetCreatureAppearanceType(Creature, appType);
                return;
            }
            else
            {
                int moveRate = 10;
                if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_BARBARIAN, Creature) >= 1)
                {
                    // Barbarians get +0.4m/s when not wearing heavy armor and not carrying a heavy load.
                    if (script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_OVERLOADED &&
                        script.GetArmorRank(script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, Creature)) != CLRScriptBase.ARMOR_RANK_HEAVY)
                    {
                        moveRate += 1;
                    }
                }
                if(script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 3)
                {
                    // Unarmored monks get +0.4m/s of movement for every 3 levels, up to level 18.
                    if(script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_HEAVY &&
                       script.GetEncumbranceState(Creature) != CLRScriptBase.ENCUMBRANCE_STATE_OVERLOADED &&
                       script.GetArmorRank(script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CHEST, Creature)) == CLRScriptBase.ARMOR_RANK_NONE)
                    {
                        if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 18) moveRate++;
                        if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 15) moveRate++;
                        if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 12) moveRate++;
                        if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 9) moveRate++;
                        if (script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_MONK, Creature) >= 6) moveRate++;
                        moveRate++;
                    }
                }
                if(script.GetHasFeat(CLRScriptBase.FEAT_NW9_FRANTIC_REACTIONS, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE)
                {
                    // Level 3+ knight protectors have frantic reactions, and thus +0.4m/s
                    moveRate++;
                }
                switch (moveRate)
                {
                    case 10:
                        appType += Walk_10;
                        break;
                    case 11:
                        appType += Walk_11;
                        break;
                    case 12:
                        appType += Walk_12;
                        break;
                    case 13:
                        appType += Walk_13;
                        break;
                    case 14:
                        appType += Walk_14;
                        break;
                    case 15:
                        appType += Walk_15;
                        break;
                    case 16:
                        appType += Walk_16;
                        break;
                    case 17:
                        appType += Walk_17;
                        break;
                    case 18:
                        appType += Walk_18;
                        break;
                    case 19:
                        appType += Walk_19;
                        break;
                    case 20:
                        appType += Walk_20;
                        break;
                    case 21:
                        appType += Walk_21;
                        break;
                    case 22:
                        appType += Walk_22;
                        break;
                }

                if(script.GetHasFeat(CLRScriptBase.FEAT_MONK_ENDURANCE, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE)
                {
                    script.FeatRemove(Creature, CLRScriptBase.FEAT_MONK_ENDURANCE);
                    script.FeatAdd(Creature, 3742, CLRScriptBase.FALSE, CLRScriptBase.FALSE, CLRScriptBase.FALSE);
                }
                if(script.GetHasFeat(CLRScriptBase.FEAT_BARBARIAN_ENDURANCE, Creature, CLRScriptBase.TRUE) == CLRScriptBase.TRUE)
                {
                    script.FeatRemove(Creature, CLRScriptBase.FEAT_BARBARIAN_ENDURANCE);
                    script.FeatAdd(Creature, 3743, CLRScriptBase.FALSE, CLRScriptBase.FALSE, CLRScriptBase.FALSE);
                }

                script.SetCreatureAppearanceType(Creature, appType);
                return;
            }
        }
    }

Usage Example

        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);
        }
All Usage Examples Of ACR_Movement.AppearanceTypes::RecalculateMovement