Exemplo n.º 1
0
        private async void FB_Explode(float x, float y, float z, int stunTime, int afterTime, float radius)
        {
            int     stunRefTime  = stunTime * 1000;
            int     afterRefTime = afterTime * 1000;
            int     finishTime   = 0;
            Ped     ped          = Game.Player.Character;
            Vector3 pos          = new Vector3(x, y, z);

            PlayParticles(pos);

            float distance = World.GetDistance(ped.Position, pos);

            if (distance <= radius)
            {
                Screen.Effects.Start(ScreenEffect.DontTazemeBro, 0, true);
                GameplayCamera.Shake(CameraShake.Hand, 15f);
                await ped.Task.PlayAnimation(Animation[0], Animation[1], -8f, -8f, -1, AnimationFlags.StayInEndFrame | AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 8f);

                finishTime = Game.GameTime + stunRefTime;
                while (Game.GameTime < finishTime)
                {
                    Game.Player.DisableFiringThisFrame();
                    await Delay(0);
                }
                ped.Task.ClearAnimation(Animation[0], Animation[1]);
                GameplayCamera.ShakeAmplitude = 10f;
                finishTime = Game.GameTime + afterRefTime;
                while (Game.GameTime < finishTime)
                {
                    await Delay(0);
                }
                GameplayCamera.StopShaking();
                Screen.Effects.Stop(ScreenEffect.DontTazemeBro);
            }
        }
Exemplo n.º 2
0
        public void Handle(Chaos mod, String from, IEnumerable <String> rest)
        {
            var player = Game.Player.Character;

            if (player == null)
            {
                return;
            }

            float  amplitude    = 1f;
            string animationSet = "move_m@drunk@moderatedrunk";
            string what         = "drunk";

            if (veryDrunk)
            {
                amplitude    = 5f;
                animationSet = "move_m@drunk@verydrunk";
                what         = "VERY drunk";
                Function.Call(Hash._START_SCREEN_EFFECT, "DrugsDrivingOut", 0, 0);
            }

            var timer        = mod.Timer(what, 20f);
            var stumbleTimer = mod.RandomTimer(2f, 5f);

            if (!WorldExtension.HasAnimationSetLoaded(animationSet))
            {
                WorldExtension.RequestAnimationSet(animationSet);
            }

            GameplayCamera.Shake(CameraShake.Drunk, amplitude);
            player.SetPedIsDrunk(true);
            player.SetConfigFlag(100, true);
            player.SetPedMovementClipset(animationSet);
            mod.AddUniqueTicker(TickerId.Drunk, new DrunkTicker(mod.Rnd, timer, stumbleTimer, player));
            mod.ShowText($"{from} made you {what}!");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Grapple the player towards the specified vehicle.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="twoHandedAnim"></param>
        /// <param name="elapsedTime"></param>
        /// <param name="initialTargetDirection"></param>
        /// <param name="ropes"></param>
        /// <param name="ropeDeleteDelay"></param>
        /// <returns></returns>
        private bool GrappleToVehicle(Vehicle vehicle, bool twoHandedAnim, float elapsedTime,
                                      Vector3 initialTargetDirection, List <Rope> ropes, ref float ropeDeleteDelay)
        {
            // Two handed web logic...
            ropeDeleteDelay = twoHandedAnim
                ? UpdateRopes1(vehicle, ropes, ropeDeleteDelay)
                : UpdateRopes2(vehicle, ropes, ropeDeleteDelay);

            // Get the target direction direction.
            var targetDirection = vehicle.Position - Profile.LocalUser.Position;

            targetDirection.Normalize();

            // Get the distance while we're at it.
            var targetDistance = Vector3.Distance(Profile.LocalUser.Position, vehicle.Position);

            // The angle of the arc.
            const float angle = 37f;

            // A degree to radians conversion.
            const float degToRad = 0.0174533f;

            // The amount of gravity for the jump.
            const float gravity = 50;

            // Set the player rotation.
            var targetRotation =
                Quaternion.FromToRotation(_helperObj.Quaternion * Vector3.RelativeFront, targetDirection) *
                _helperObj.Quaternion;

            _helperObj.Quaternion = targetRotation;

            // Calculate the speed needed to go from A to B.
            var targetVelocityMag = targetDistance / ((float)Math.Sin(2f * angle * degToRad) / gravity);

            // Extract the x and z of the velocity.
            var acceleration = GetAcceleration(elapsedTime, angle, degToRad, gravity, targetVelocityMag);

            // Set the players velocity and heading.
            Profile.LocalUser.Heading  = (initialTargetDirection * 5).ToHeading();
            Profile.LocalUser.Velocity = acceleration * 25f + vehicle.Velocity;

            // reverse the grapple animation.
            if (Profile.LocalUser.IsPlayingAnimation("weapons@projectile@", "throw_m_fb_stand"))
            {
                Profile.LocalUser.SetAnimationSpeed("weapons@projectile@",
                                                    "throw_m_fb_stand", -1.0f); // set it to -1x the speed.
            }
            // Check if the player has collided with anything,
            // and if so, then break the loop.
            if (Profile.LocalUser.HasCollidedWithAnything)
            {
                // Stop the grapple.
                StopGrapple();

                // If the player is touching the vehicle...
                if (!Profile.LocalUser.IsTouching(vehicle))
                {
                    return(false);
                }

                // Get the collision normal and check to see
                // if we're on a flat surface.
                var collisionNormal = vehicle.GetLastCollisionNormal();
                if (!(Vector3.Dot(collisionNormal, Vector3.WorldUp) > 0.5f))
                {
                    return(false);
                }

                // Now we're going to artificially attach the player
                // to the roof, with a nice little animation.
                Profile.LocalUser.Velocity = vehicle.Velocity;
                vehicle.SetDamage(Profile.LocalUser.Position - vehicle.Position, 3000f, 200f);
                Profile.LocalUser.Task.PlayAnimation("move_fall", "clamber_land_stand",
                                                     8.0f, -4.0f, 750, AnimationFlags.None, 0.0f);
                GameplayCamera.Shake(CameraShake.Jolt, 0.1f);
                OverrideFallHeight(0f);
                return(false);
            }

            // Make sure the player doesn't think he's falling while we update.
            Profile.LocalUser.SetConfigFlag(60, true);
            return(true);
        }