Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
        {
            int  Command = (int)ScriptParameters[0]; // ScriptParameterTypes[0] is typeof(int)
            uint Target  = (uint)ScriptParameters[1];

            if (!AppearanceTypes.characterMovement.ContainsKey(Target))
            {
                AppearanceTypes.characterMovement.Add(Target, AppearanceTypes.MovementType.Walking);
            }
            if (!AppearanceTypes.overlandMap.ContainsKey(Target))
            {
                AppearanceTypes.overlandMap.Add(Target, false);
            }
            if (!AppearanceTypes.currentSwimTrigger.ContainsKey(Target))
            {
                AppearanceTypes.currentSwimTrigger.Add(Target, OBJECT_INVALID);
            }

            switch ((MovementCommand)Command)
            {
            case MovementCommand.EnterWater:
                AppearanceTypes.characterMovement[Target] = AppearanceTypes.MovementType.Swimming;
                AppearanceTypes.RecalculateMovement(this, Target);
                if (GetIsObjectValid(AppearanceTypes.currentSwimTrigger[Target]) == CLRScriptBase.TRUE)
                {
                    AppearanceTypes.currentSwimTrigger[Target] = OBJECT_SELF;
                }
                else
                {
                    AppearanceTypes.currentSwimTrigger[Target] = OBJECT_SELF;
                    Swimming.SwimTriggerEnter(this, Target);
                }
                break;

            case MovementCommand.ExitWater:
                break;

            case MovementCommand.MountHorse:
                AppearanceTypes.characterMovement[Target] = AppearanceTypes.MovementType.Riding;
                Riding.MountHorse(this, Target, OBJECT_SELF);
                AppearanceTypes.RecalculateMovement(this, Target);
                break;

            case MovementCommand.CloakRemoved:
                if (Riding.isWarhorse.ContainsKey(Target))
                {
                    AppearanceTypes.characterMovement[Target] = AppearanceTypes.MovementType.Walking;
                    Riding.Dismount(this, Target, GetPCItemLastUnequipped(), GetLocation(Target));
                    AppearanceTypes.RecalculateMovement(this, Target);
                }
                break;

            case MovementCommand.ToOverlandMap:
                AppearanceTypes.overlandMap[Target] = true;
                AppearanceTypes.RecalculateMovement(this, Target);
                break;

            case MovementCommand.FromOverlandMap:
                AppearanceTypes.overlandMap[Target] = false;
                AppearanceTypes.RecalculateMovement(this, Target);
                break;

            case MovementCommand.Dismount:
                if (Riding.isWarhorse.ContainsKey(Target))
                {
                    AppearanceTypes.characterMovement[Target] = AppearanceTypes.MovementType.Walking;
                    AppearanceTypes.RecalculateMovement(this, Target);
                    Riding.Dismount(this, Target, GetItemInSlot(INVENTORY_SLOT_CLOAK, Target), GetLocation(OBJECT_SELF));
                }
                break;

            case MovementCommand.ForceRecalculate:
                AppearanceTypes.RecalculateMovement(this, Target);
                break;

            case MovementCommand.RestoreHorse:
                AppearanceTypes.characterMovement[Target] = AppearanceTypes.MovementType.Riding;
                AppearanceTypes.RecalculateMovement(this, Target);
                if (!Riding.isWarhorse.ContainsKey(Target))
                {
                    Riding.isWarhorse.Add(Target, true);
                }
                break;
            }

            return(0);
        }