Example #1
0
        private IEnumerable <object> YogaCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }

                if (random.Next(100) < 100)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.Position, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                if (core.PlayerPed.IsInVehicle())
                {
                    var targetPos      = (core.PlayerPed.ForwardVector).Normalized();
                    var targetPosition = core.PlayerPed.Position + targetPos * 15;
                    var tar            = targetPosition - ped.Position;

                    SetAnimRate(ped, 5.0f);
                    ped.ApplyForce(new Vector3(tar.X * 3.0f, tar.Y * 3.0f, tar.Z * 3.0f));

                    Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                                  0, 0);
                    Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                    var hp = core.PlayerPed.Position;
                    Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, hp.X, hp.Y, hp.Z, 1, false,
                                  true, true, true, true);

                    Function.Call(Hash.TASK_PLAY_ANIM, ped, "missfam5_yoga", "a2_pose", 0, 0, 0, 2, 0
                                  , 0, 0, 0);
                    break;
                }
                else
                {
                    var targetPos      = (core.PlayerPed.ForwardVector).Normalized();
                    var targetPosition = core.PlayerPed.Position + targetPos * 0;
                    var tar            = targetPosition - ped.Position;
                    SetAnimRate(ped, 5.0f);

                    ped.ApplyForce(new Vector3(tar.X, tar.Y, tar.Z));

                    Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                                  0, 0);
                    Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                    var hp = core.PlayerPed.Position;
                    Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, hp.X, hp.Y, hp.Z, 1, false,
                                  true, true, true, true);

                    Function.Call(Hash.TASK_PLAY_ANIM, ped, "missfam5_yoga", "a2_pose", 0, 0, 0, 2, 0
                                  , 0, 0, 0);
                }

                yield return(null);
            }
        }
Example #2
0
        private void BomBatAction(Ped ped)
        {
            if (ped.HasBeenDamagedBy(Weapon.BAT))
            {
                GTA.World.AddExplosion(ped.Position + Vector3.WorldUp * 0.5f, GTA.ExplosionType.Grenade, 40.0f,
                                       0.5f);


                var randomVector = InfernoUtilities.CreateRandomVector();
                ped.ApplyForce(randomVector * Random.Next(10, 20));
                ped.Kill();
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
            else if (ped.HasBeenDamagedBy(Weapon.KNIFE))
            {
                GTA.World.AddExplosion(ped.Position, GTA.ExplosionType.Molotov1, 0.1f, 0.0f);
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
            else if (ped.HasBeenDamagedBy(Weapon.GOLFCLUB))
            {
                var randomVector = InfernoUtilities.CreateRandomVector();
                ped.SetToRagdoll(100);
                ped.Velocity = randomVector * 1000;
                ped.ApplyForce(randomVector * Random.Next(2000, 4000));
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
            else if (ped.HasBeenDamagedBy(Weapon.UNARMED) /*&& !ped.HasBeenDamagedByPed(PlayerPed)*/)
            {
                NativeFunctions.ShootSingleBulletBetweenCoords(
                    ped.Position + new Vector3(0, 0, 1),
                    ped.GetBoneCoord(Bone.IK_Head), 1, WeaponHash.StunGun, null, 1.0f);
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
            else if (ped.HasBeenDamagedBy(Weapon.HAMMER))
            {
                if (!ped.IsInRangeOf(PlayerPed.Position, 10))
                {
                    return;
                }
                Shock(ped);
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
            else if (ped.HasBeenDamagedBy(Weapon.Poolcue))
            {
                var blowVector = -ped.ForwardVector;
                ped.SetToRagdoll(1);
                ped.Velocity = blowVector * 10;
                ped.ApplyForce(blowVector * Random.Next(20, 40));
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, ped);
            }
        }
Example #3
0
        private IEnumerable <object> YogaCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }

                if (random.Next(100) < 100)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.Position, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                var tar = (core.PlayerPed.Position - ped.Position) * 1.0f;


                SetAnimRate(ped, 5.0f);

                Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                              0, 0);
                Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                var hp = core.PlayerPed.Position;
                Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, hp.X, hp.Y, hp.Z, 1, false,
                              true, true, true, true);
                Function.Call(Hash.TASK_PLAY_ANIM, ped, "creatures@boar@move", "gallop", 2.5, 2.5, -1, 9, 0
                              , 0, 0, 0);
                ped.ApplyForce(new Vector3(tar.X, tar.Y, tar.Z) * 5.0f);

                yield return(null);
            }
        }
        private IEnumerable <object> HidroCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }

                if (random.Next(100) < 10)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.UpVector, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                var tar = (core.PlayerPed.Position - ped.Position) * 1.5f;

                SetAnimRate(ped, 5.0f);
                Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                              0, 0);
                Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                var hp = core.PlayerPed.ForwardVector;
                Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, 0, 0, 0, 1, false,
                              true, true, true, true);
                Function.Call(Hash.TASK_PLAY_ANIM, ped, "move_f@generic", "idle_turn_l_-180", 9.0, -9.0, -1, 0, 0,
                              0, 0, 0);
                ped.ApplyForce(new Vector3(tar.X, tar.Y, tar.Z) * 1.0f);
                StartWater(ped);

                yield return(null);
            }
        }
Example #5
0
        private bool checkPedTouch()
        {
            Ped testPed = Function.Call <Ped>(Hash.GET_MELEE_TARGET_FOR_PED, Game.Player.Character);

            if (testPed != null)
            {
                if (testPed.Health <= 0)
                {
                    testPed.Health = 1;
                }
                if (GetWeaponHitDirection(weaponEntity, Game.Player.Character) != Vector3.Zero || IsTouching(weaponEntity, testPed))
                {
                    if (testPed.IsInMeleeCombat)
                    {
                        Wait(20);
                    }
                    Function.Call((Hash)0xAE99FB955581844A, testPed, 10, 10, 0, true, true, false);                     // small Ragdoll mode
                    testPed.ApplyForce(((curDirection == Vector3.Zero) ? Game.Player.Character.ForwardVector : curDirection) * currentStrength);
                    Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, testPed);
                    Function.Call(Hash.CLEAR_ENTITY_LAST_WEAPON_DAMAGE, testPed);
                    Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, testPed);
                    return(true);
                }
            }
            return(false);
        }
Example #6
0
        private IEnumerable <object> PlayCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }

                if (random.Next(100) < 10)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.UpVector, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                var tar = core.PlayerPed.Position - ped.Position;

                SetAnimRate(ped, 5.0f);
                Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                              0, 0);
                Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                var hp = core.PlayerPed.ForwardVector;
                Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, 0, 0, 0, 1, false,
                              true, true, true, true);
                Function.Call(Hash.TASK_PLAY_ANIM, ped, "missbigscore1switch_trevor_piss", "piss_loop", 8.0, 0, -1, 1, 0
                              , 0, 0, 0);
                ped.ApplyForce(new Vector3(tar.X * 2.0f, tar.Y * 2.0f, tar.Z * 2.0f));
                StartFire(ped);

                yield return(null);
            }
        }
Example #7
0
            public override bool Tick()
            {
                if (!player.IsAlive)
                {
                    return(true);
                }

                switch (player.ParachuteState)
                {
                case ParachuteState.Deploying:
                case ParachuteState.Gliding:
                    if (putAwayParachute)
                    {
                        return(true);
                    }
                    break;

                case ParachuteState.None:
                    player.Task.ClearAll();
                    player.Task.Skydive();
                    break;

                default:
                    putAwayParachute = true;
                    break;
                }

                var factor = timer.Remaining / timer.Duration;
                var facing = player.ForwardVector * 10_000f * (1 - factor);
                var up     = GTA.Math.Vector3.WorldUp * 1_000f * factor;

                player.ApplyForce(up + facing);
                return(timer.Tick());
            }
Example #8
0
        private async Task DelayParachute(Ped ped)
        {
            ped.SetNotChaosPed(true);
            ped.ClearTasksImmediately();
            ped.Position += new Vector3(0, 0, 0.5f);
            ped.SetToRagdoll();

            await Task.Delay(TimeSpan.FromSeconds(0.1f));

            ped.ApplyForce(new Vector3(0, 0, 40.0f));
            ped.IsInvincible = true;

            await Task.Delay(TimeSpan.FromSeconds(1.5f));

            if (!ped.IsSafeExist())
            {
                return;
            }
            ped.IsInvincible = false;
            ped.ParachuteTo(PlayerPed.Position);

            await Task.Delay(TimeSpan.FromSeconds(15));

            if (!ped.IsSafeExist())
            {
                return;
            }
            ped.SetNotChaosPed(false);
        }
Example #9
0
        private IEnumerable <object> DelayParachute(Ped ped)
        {
            ped.SetNotChaosPed(true);
            ped.ClearTasksImmediately();
            ped.Position += new Vector3(0, 0, 0.5f);
            ped.SetToRagdoll();
            yield return(null);

            ped.ApplyForce(new Vector3(0, 0, 40.0f));

            ped.IsInvincible = true;
            yield return(WaitForSeconds(1.5f));

            if (!ped.IsSafeExist())
            {
                yield break;
            }
            ped.IsInvincible = false;
            ped.ParachuteTo(core.PlayerPed.Position);
            yield return(WaitForSeconds(10));

            if (!ped.IsSafeExist())
            {
                yield break;
            }
            ped.SetNotChaosPed(false);
        }
Example #10
0
        IEnumerable <object> FartCoroutine(Ped ped)
        {
            core.DrawParupunteText("3", 1.0f);

            yield return(WaitForSeconds(1));

            core.DrawParupunteText("2", 1.0f);
            yield return(WaitForSeconds(1));

            core.DrawParupunteText("1", 1.0f);
            yield return(WaitForSeconds(1));

            core.DrawParupunteText("発射!", 3.0f);
            GasExplosion(ped);
            CreateEffect(ped, "ent_sht_steam");

            if (ped.IsInVehicle())
            {
                ped.CurrentVehicle.Speed = 300;
            }

            ped.SetToRagdoll(10);


            random = new Random();
            switch (random.Next(0, 2) % 4)
            {
            case 0:
                ped.ApplyForce(Vector3.WorldUp * 10.0f);
                break;

            case 1:
                ped.ApplyForce(Vector3.WorldUp * 100.0f);
                core.PlayerPed.IsInvincible = true;
                while (core.PlayerPed.IsInVehicle() ? core.PlayerPed.CurrentVehicle.IsInAir : core.PlayerPed.IsInAir)
                {
                    yield return(null);
                }
                break;

            case 2:
                ped.ApplyForce(Vector3.WorldUp * 2.0f);
                break;
            }

            ParupunteEnd();
        }
Example #11
0
        private void ThrowAPed(GTA.Script sender, GTA.ObjectCollection Parameter)
        {
            Ped ped = Parameter.Convert <Ped>(0);

            if (!Exists(ped) || ped.isInAir)
            {
                return;
            }
            ped.ApplyForce(new Vector3(0.0F, 0.0F, 5.0F), new Vector3(0.0F, 5.0F, 0.0F));
        }
Example #12
0
        public static void DamagePed(Ped attacker, Ped victim, int damage, RagdollType type, int ragdollMS, Vector3 forceDirection = default(Vector3), float forceDirectionMultiplier = 1f, Vector3 forceRotation = default(Vector3), float forceRotationMultiplier = 1f)
        {
            PlayPedPainSound(victim);
            SetPedRagdoll(victim, ragdollMS, type);

            victim.ApplyDamage(damage);
            victim.ApplyForce(forceDirection * forceDirectionMultiplier, forceRotation * forceRotationMultiplier);

            Function.Call(Hash.APPLY_PED_DAMAGE_PACK, victim, "BigRunOverByVehicle", 1.0, 1.0);
        }
Example #13
0
        private IEnumerable <object> HidroCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                ped.SetToRagdoll();
                core.PlayerPed.SetToRagdoll();

                var tar = (ped.Position + new Vector3(0, 0, 5)).Normalized();

                ped.ApplyForce(tar * 0.05f);
                core.PlayerPed.ApplyForce((core.PlayerPed.Position + new Vector3(0, 0, 5)).Normalized() * 0.05f);

                yield return(null);
            }
        }
Example #14
0
        private void Input(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.K)
            {
                Ped newPed = World.CreateRandomPed(Game.Player.Character.Position.Around(1.0f));
                newPed.CanRagdoll = true;
                newPed.Kill();
                newPed.ApplyForce(Vector3.WorldUp * 1.0f);

                bodyCount++;
                UI.Notify(bodyCount.ToString());
            }
            if (e.KeyCode == Keys.C)
            {
                UI.Notify(World.GetAllPeds().Count().ToString());
            }
        }
Example #15
0
        private IEnumerable <object> PlayCoroutine(Ped ped)
        {
            var animDict = "melee@knife@streamed_core";
            var animPlay = "counter_attack_r";

            Function.Call(Hash.REQUEST_ANIM_DICT, animDict);

            Inferno.InfernoCore.Publish(new ChangeWeaponEvent(Weapon.KNIFE));

            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }

                if (random.Next(100) < 100)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.Position, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                var tar = core.PlayerPed.Position - ped.Position;

                SetAnimRate(ped, 5.0f);

                Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                              0, 0);
                Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                var hp = core.PlayerPed.Position;
                Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, hp.X, hp.Y, hp.Z, 1, false,
                              true, true, true, true);
                Function.Call(Hash.TASK_PLAY_ANIM, ped, animDict, animPlay, 8.0, -8.0, -1, 0, 0
                              , 0, 0, 0);
                ped.ApplyForce(new Vector3(tar.X * 2.0f, tar.Y * 2.0f, tar.Z * 2.0f));

                yield return(null);
            }
        }
Example #16
0
        private IEnumerable <object> FlyCoroutine(Ped ped)
        {
            while (!ReduceCounter.IsCompleted)
            {
                if (!ped.IsSafeExist())
                {
                    yield break;
                }
                if (ped.IsDead)
                {
                    GTA.World.AddExplosion(ped.Position, GTA.ExplosionType.Rocket, 1.0f, 1.0f);
                    yield break;
                }

                if (random.Next(100) < 100)
                {
                    ped.Quaternion = Quaternion.RotationAxis(ped.Position, (float)(random.NextDouble() - 0.5)) * ped.Quaternion;
                }

                var pos = ped.Position;

                SetAnimRate(ped, 5.0f);
                Function.Call(Hash.SET_OBJECT_PHYSICS_PARAMS, ped, 200000000.0, 1, 1000, 1, 0, 0, 0, 0, 0,
                              0, 0);
                Function.Call(Hash.SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN, ped, true);
                var hp = core.PlayerPed.Position;
                Function.Call(Hash.APPLY_FORCE_TO_ENTITY, ped, hp.X * 1, hp.Y * 1, hp.Z * 1, hp.X, hp.Y, hp.Z, 1, false,
                              true, true, true, true);
                Function.Call(Hash.TASK_PLAY_ANIM_ADVANCED, ped, "ped", "handsup_exit", pos.X, pos.Y, pos.Z, 0, 0, 0, 2.0, -2.0, -1, 1, 0, 0, 0);

                ped.ApplyForce(new Vector3(0, 0, 2.8f));
                StartFire(ped);

                yield return(null);
            }
        }
Example #17
0
        /// <summary>
        /// くっつけるコルーチン
        /// </summary>
        IEnumerable <object> PedAttachCoroutine(Ped ped, Vehicle veh)
        {
            var handleId = ped.Handle;

            ped.SetToRagdoll(1, 2);
            SetPedProof(ped, true);

            //ターゲットが車に触るまでforceを加える
            foreach (var s in WaitForSeconds(3))
            {
                if (!IsEnableStatus(ped, veh))
                {
                    processingPedIdSet.Remove(ped.Handle);
                    yield break;
                }

                //触ったら終わり
                if (ped.IsTouching(veh))
                {
                    break;
                }

                //車に向かって引っ張る
                var dir = (veh.Position + Vector3.WorldUp * 2.0f - ped.Position).Normalized;
                ped.ApplyForce(dir * 3.0f, Vector3.Zero, ForceType.MaxForceRot2);
                yield return(null);
            }

            //オブジェクトが消失した、または車に触っていなかったら終了
            if (!IsEnableStatus(ped, veh) || !ped.IsTouching(veh))
            {
                if (ped.IsSafeExist())
                {
                    SetPedProof(ped, false);
                }
                processingPedIdSet.Remove(ped.Handle);
                yield break;
            }

            var rHandCoord     = ped.GetBoneCoord(Bone.SKEL_R_Hand);
            var offsetPosition = Function.Call <Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS,
                                                         veh,
                                                         rHandCoord.X,
                                                         rHandCoord.Y,
                                                         rHandCoord.Z);

            //掴み始めたら追加
            processingPedList.Add(ped);

            //掴みループ
            while (IsEnableStatus(ped, veh))
            {
                GripVehicle(ped, veh, offsetPosition);
                yield return(null);
            }

            if (ped.IsSafeExist())
            {
                ReleaseVehicle(ped);
            }
            processingPedIdSet.Remove(handleId);
        }
Example #18
0
        private void HandleGlide()
        {
            if (!IsGliding)
            {
                if (IsPlayingGlideAnim)
                {
                    ClearGlideAnimation();

                    StartFallHeight = float.MaxValue;

                    StartedFalling = true;
                }

                if (IsPlayingGlideKickAnim)
                {
                    ClearGlideKickAnimation();
                }

                if (IsPlayingDiveAnim)
                {
                    ClearDiveAnim();

                    StartFallHeight = float.MaxValue;

                    StartedFalling = true;

                    SpecialLanding = true;
                }
                return;
            }

            if (IsDoingGlideKick)
            {
                SubGlide_HandleGlideKick();

                return;
            }
            else
            {
                if (IsPlayingGlideKickAnim)
                {
                    ClearGlideKickAnimation();
                }
            }


            if (IsDiving)
            {
                if (!IsPlayingDiveAnim)
                {
                    if (IsPlayingGlideAnim)
                    {
                        ClearGlideAnimation();
                    }

                    var initialVelocity = Ped.Velocity;

                    if (Ped.IsVaulting)
                    {
                        Ped.Task.ClearAllImmediately();
                    }
                    else
                    {
                        Ped.Task.ClearAll();
                    }

                    Ped.Velocity = Vector3.Zero;

                    Ped.PlayAnimation("skydive@freefall", "free_forward", 4.0f, -4.0f, -1, AnimationFlags.Loop, 0f);

                    Ped.SetConfigFlag(60, true);

                    Ped.Velocity = initialVelocity;

                    IsPlayingDiveAnim = true;
                }
                else
                {
                    GlideVerticalAdditive = Vector3.Lerp(GlideVerticalAdditive, new Vector3(22.5f * GlidingMovement.X, 0f, 0f), Game.LastFrameTime * 2f);

                    var pedUpQuaternion = Quaternion.Euler(0, 0, Ped.Rotation.Z) * Quaternion.Euler(new Vector3(0, -60f, 0)) * Quaternion.Euler(GlideVerticalAdditive);

                    Ped.SetConfigFlag(60, true);

                    Ped.ApplyForce((Vector3.RelativeBottom * (float)Math.Pow(9.81f, 2)) * 0.5f * Game.LastFrameTime);

                    Ped.Quaternion = pedUpQuaternion;
                }
            }
            else
            {
                if (!IsPlayingGlideAnim)
                {
                    InitialGlideVelocity = Vector3.RelativeFront * Math.Min(new Vector3(Ped.Velocity.X, Ped.Velocity.Y, 0f).Length(), 30f) + new Vector3(0, 0, Math.Min(Ped.Velocity.Z, 30f));

                    GlideDrag = 3f;

                    GlideDownSpeed = -0.6f;

                    var wasDiving = false;

                    if (IsPlayingDiveAnim)
                    {
                        ClearDiveAnim();

                        GlideDrag = 4f;

                        wasDiving = true;
                    }

                    var initialVelocity = Ped.Velocity;

                    Ped.Task.ClearAll();

                    Ped.Velocity = Vector3.Zero;

                    Ped.PlayAnimation("swimming@first_person@", "walk_fwd_0_up_loop", 4.0f, -4.0f, -1, AnimationFlags.Loop, 0.5f);

                    Ped.PlayAnimation("misslamar1leadinout", "magenta_idle", 4.0f, -4.0f, -1, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 0f);

                    Ped.SetAnimationSpeed("swimming@first_person@", "walk_fwd_0_up_loop", 0f);

                    Ped.SetAnimationSpeed("misslamar1leadinout", "magenta_idle", 0f);

                    if (wasDiving)
                    {
                        GlideHorizontalAdditive = new Vector3(0f, -10f, 0f);
                    }

                    Ped.SetConfigFlag(60, true);

                    Ped.Velocity = initialVelocity;

                    IsPlayingGlideAnim = true;
                }
                else
                {
                    Ped.SetConfigFlag(60, true);

                    GlideHorizontalAdditive = Vector3.Lerp(GlideHorizontalAdditive, new Vector3(0, (32f * GlidingMovement.Y), 0), Game.LastFrameTime * 5f);

                    GlideVerticalAdditive = Vector3.Lerp(GlideVerticalAdditive, new Vector3(6.5f * GlidingMovement.X, 0f, 0f), Game.LastFrameTime * 5f);

                    var pedUpQuaternion = Quaternion.Euler(0, 0, Ped.Rotation.Z) * Quaternion.Euler(new Vector3(0, -85f, 0) - GlideHorizontalAdditive) * Quaternion.Euler(GlideVerticalAdditive);

                    Ped.Quaternion = pedUpQuaternion;

                    GlideDrag = Mathf.Lerp(GlideDrag, 0.1f, Game.LastFrameTime * 0.15f);

                    GlideDownSpeed = Mathf.Lerp(GlideDownSpeed, 0.6f, Game.LastFrameTime * 0.8f);

                    Ped.Velocity = (Ped.ForwardVector + ((Ped.UpVector + Vector3.WorldUp * GlideDownSpeed) * GlideDrag)) * 0.25f * Math.Min(InitialGlideVelocity.Length(), 50) + new Vector3(0, 0, -9.81f);
                }
            }

            if (Ped.HeightAboveGround < MinGlideHeight)
            {
                IsGliding = false;
            }
        }