Пример #1
0
        /// <summary>
        ///     Draw's the background image while the weapon wheel is open.
        /// </summary>
        private void DrawBackground()
        {
            var screenRes = GTAGraphics.GetScreenResolution();
            var hudbgSize = new Size(512, 512);

            //UI.DrawTexture(MainPath + "hudbg.png", 0, 1, 60, GetCenterPointForImage(screenRes, hudbgSize), hudbgSize);
            UI.DrawTexture(MainPath + "spideyhud.png", 28, 0, 60, Point.Empty, screenRes);
        }
Пример #2
0
        /// <summary>
        ///     If you call this as soon as the player
        ///     hit's the ground, it will recover him with a roll (or
        ///     if not moving just a plain landing animation).
        /// </summary>
        private void CatchLanding()
        {
            // Clear the player's tasks.
            Profile.LocalUser.ClearTasksImmediately();

            // Check our movement vector.
            var moveVector = Profile.GetInputDirection();

            // Play the movement dependant animations.
            if (moveVector.Length() > 0)
            {
                // Add a little bit of dust.
                GTAGraphics.StartParticle("core", "ent_dst_dust", Profile.LocalUser.Position - Vector3.WorldUp,
                                          Vector3.Zero, 2f);

                // Play the rolling animation.
                Profile.LocalUser.Task.PlayAnimation("move_fall", "land_roll",
                                                     8.0f, -4.0f, 750, AnimationFlags.AllowRotation, 0.0f);
            }
            else
            {
                // Add a little bit of dust.
                GTAGraphics.StartParticle("core", "ent_dst_dust", Profile.LocalUser.Position - Vector3.WorldUp,
                                          Vector3.Zero, 2f);

                // Play our super hero landing animation.
                Profile.LocalUser.Velocity = Vector3.Zero;
                Profile.LocalUser.Task.PlayAnimation("move_crouch_proto", "idle_intro", 6.0f, -4.0f, 450,
                                                     AnimationFlags.Loop, 0.0f);
                Profile.LocalUser.Task.PlayAnimation("skydive@base", "ragdoll_to_free_idle", 6.0f, -4.0f, 450,
                                                     AnimationFlags.AllowRotation |
                                                     AnimationFlags.UpperBodyOnly,
                                                     0.0f);
                var timer = 0.5f;
                while (!Profile.LocalUser.IsPlayingAnimation("skydive@base", "ragdoll_to_free_idle") &&
                       timer > 0f)
                {
                    timer -= Time.DeltaTime;
                    Script.Yield();
                }
                Profile.LocalUser.SetAnimationSpeed("skydive@base", "ragdoll_to_free_idle", 0f);
            }

            // Clear the falling animation.
            Profile.LocalUser.Task.ClearAnimation("move_fall", "fall_high");
            GameWaiter.Wait(500);
        }
Пример #3
0
        public void Explode()
        {
            if (Exploded)
            {
                return;
            }
            Exploded = true;
            var entities = World.GetNearbyEntities(Prop.Position, 20f);

            Prop.Position       = new Vector3(Prop.Position.X, Prop.Position.Y, World.GetGroundHeight(Prop.Position));
            Prop.FreezePosition = true;
            foreach (var ent in entities)
            {
                if (ent.GetEntityType() == EntityType.Object)
                {
                    continue;
                }
                if (ent.Handle == Game.Player.Character.Handle)
                {
                    continue;
                }
                if (ent.IsDead)
                {
                    continue;
                }
                //Utilities.CreateParticleChain(Prop.Position, ent.Position, Vector3.Zero, 0.1f, particleScale: 0.2f);
                if (ent is Ped ped)
                {
                    if (ped.IsInVehicle())
                    {
                        continue;
                    }
                    Utilities.ShockPed(ped, 100);
                }
                var length = Vector3.Distance(ent.Position, Prop.Position);
                var rope   = Rope.AddRope(Prop.Position, length, GTARopeType.ThickRope, length / 2, 0.1f, true, false);
                rope.AttachEntities(Prop, Vector3.Zero, ent, Vector3.Zero, length / 2);
                rope.ActivatePhysics();
                _attachments.Add(new AttachmentInfo(ent, Prop, rope));
                WebAttachments.AddAttachment(ent, Prop, rope, true);
            }
            GTAGraphics.StartParticle("core", "ent_ray_prologue_elec_crackle_sp", Prop.Position, Vector3.Zero, 5.0f);
            World.DrawLightWithRange(Prop.Position, Color.White, 25f, 100f);
            World.AddOwnedExplosion(Game.Player.Character, Prop.Position, ExplosionType.Grenade, 0f, 0.1f, true, false);
        }
Пример #4
0
        private void ApplyDamage(Vector3 direction, Entity entity, EntityType type, Vector3 hitCoords)
        {
            switch (type)
            {
            case EntityType.Vehicle:
                var veh    = new Vehicle(entity.Handle);
                var offset = veh.GetOffsetFromWorldCoords(hitCoords);
                veh.SetDamage(offset, 5000f, 7000f);
                veh.Health -= (int)(45 * Profile.PunchDamageMultiplier);
                veh.ApplyForce(ForceFlags.StrongForce, Profile.LocalUser.ForwardVector * 30000f * Profile.PunchForceMultiplier, direction, 0, false, false, false);
                GTAGraphics.StartParticle("core", "bul_carmetal", hitCoords, Vector3.Zero, 1.0f);
                Audio.ReleaseSound(Audio.PlaySoundFromEntity(entity, "KNUCKLE_DUSTER_COMBAT_PED_HIT_BODY"));
                break;

            case EntityType.Ped:
                var ped = new Ped(entity.Handle);
                ped.SetToRagdoll(0);
                ped.Velocity = direction * 35 * Profile.PunchForceMultiplier;
                ped.ApplyDamage((int)(50 * Profile.PunchDamageMultiplier));
                Audio.ReleaseSound(Audio.PlaySoundFromEntity(entity, "FLASHLIGHT_HIT_BODY"));
                break;
            }
            DamagedEntity?.Invoke(this, null, entity, hitCoords);
        }
Пример #5
0
        /// <summary>
        ///     Create's a particle chain from point a to point b.
        /// </summary>
        /// <param name="pointA">The starting position.</param>
        /// <param name="pointB">The ending position.</param>
        /// <param name="rotationOffset">The offset of the particles rotation.</param>
        /// <param name="nodeSize">The node size (the distance*2 between each particle)</param>
        /// <param name="noiseMultiplier">The amount of noise to apply to the chain (0-1)</param>
        /// <param name="particleAsset">The asset name of the particle.</param>
        /// <param name="particleName">The name of the particle.</param>
        public static void CreateParticleChain(Vector3 pointA, Vector3 pointB, Vector3 rotationOffset,
                                               float nodeSize       = 1f, float noiseMultiplier   = 0.5f,
                                               string particleAsset = "core", string particleName = "ent_ray_prologue_elec_crackle_sp",
                                               float particleScale  = 0.5f)
        {
            // Clamp the noise.
            noiseMultiplier = Maths.Clamp01(noiseMultiplier);

            // Get the direction to point b.
            var pointBDirection = pointB - pointA;

            pointBDirection.Normalize();

            // Get the distance between points.
            var totalDistance = Vector3.Distance(pointA, pointB);

            // Estimate the amount of nodes we need to use.
            var count = (int)(totalDistance / nodeSize);

            // Initialize variables.
            var currentPosition = pointA;
            var currentRotation =
                Quaternion.FromToRotation(Vector3.WorldUp, pointBDirection); // Calculate the initial rotation.
            var random = new Random();

            // Now we need to loop through each particle.
            for (var i = 0; i < count; i++)
            {
                // Calculate random direction...
                var randomDirection = new Vector2(
                    (float)random.RandomNumberBetween(-1, 1) * noiseMultiplier,
                    (float)random.RandomNumberBetween(-1, 1) * noiseMultiplier);
                randomDirection.Normalize();

                // Get the actual direction we need to move in.
                pointBDirection = currentPosition - pointB;
                pointBDirection.Normalize(); // Normalize this vector.

                // Calculate the rotation to point b.
                var newRotation = Quaternion.FromToRotation(Vector3.RelativeTop, pointBDirection);

                // Calculate the distance.
                var currentDistance    = Vector3.Distance(currentPosition, pointB);
                var distancePercentage = currentDistance / totalDistance;

                // Calculate the amount of deviation from the regular direction.
                var dX        = randomDirection.X * distancePercentage;
                var dY        = randomDirection.Y * distancePercentage;
                var deviation = new Vector3(dX, dY, 1);

                // Get the direction to travel.
                var directionDelta = newRotation * -deviation;
                directionDelta.Normalize();

                // Add that to the current position.
                var nextPosition           = currentPosition + directionDelta * nodeSize;
                var currentToNextDirection = nextPosition - currentPosition;
                currentToNextDirection.Normalize();

                // Get the desired rotation from current to next position.
                var desiredRotation = Quaternion.FromToRotation(Vector3.RelativeFront, currentToNextDirection) *
                                      Quaternion.Euler(rotationOffset);

                // Spawn the particle.
                GTAGraphics.StartParticle(particleAsset, particleName, currentPosition,
                                          Vector3.Zero, particleScale, true, true, true);

                // Set the current position to the new position.
                currentPosition = nextPosition;
            }
        }