Exemplo n.º 1
0
 private void InitMemory()
 {
     if (_initMemory)
     {
         return;
     }
     HandlingFile.Init();
     //CTimeScale.Init();
     _initMemory = true;
 }
Exemplo n.º 2
0
        private void LiftThrowVehicle(Vehicle vehicle)
        {
            // We have our vehicle.
            if (vehicle == null || !vehicle.Exists() || !Profile.LocalUser.IsTouching(vehicle))
            {
                return;
            }

            // The direction to the vehicle.
            var directionToVehicle = vehicle.Position - Profile.LocalUser.Position;

            directionToVehicle.Normalize();

            // Make sure we're not on top of this vehicle.
            var dot = Vector3.Dot(directionToVehicle, Vector3.WorldUp);

            if (dot < -0.4f)
            {
                return;
            }

            // Get the mass of the vehicle.
            var weight = HandlingFile.GetHandlingValue(vehicle, 0x000C);

            // The maximum weight spidey can lift,
            // about 10 tons.
            const float maxWeight = 9071.85f;

            // If the weight is over the max then we can't lift it.
            if (weight > maxWeight)
            {
                if (Profile.LocalUser.IsPlayer)
                {
                    UI.Notify("This vehicle is FAR to heavy for spidey to lift.");
                }
                return;
            }

            // Lifting:
            // amb@world_human_yoga@male@base => base_b

            // Pickup:
            // anim@mp_snowball => pickup_snowball

            // Set the current pickup vehicle.
            _currentPickupVehicle = vehicle;

            // Clear the player tasks and make him play
            // the pickup animation.
            Profile.LocalUser.ClearTasksImmediately();
            Profile.LocalUser.Heading = directionToVehicle.ToHeading();
            Profile.LocalUser.Task.PlayAnimation("anim@mp_snowball", "pickup_snowball", 8.0f, -8.0f,
                                                 500, AnimationFlags.StayInEndFrame, 0.0f);

            // Let's us keep track of whether or not we played the animation.
            var hasPlayedAnimation = false;

            // Set the vehicle alpha to transparent so the
            // player can see where he's going to throw.
            vehicle.Alpha = 100;

            GameWaiter.Wait(100);

            while (true)
            {
                Profile.DisableControls();

                if (Profile.LocalUser.IsPlayer)
                {
                    Game.EnableControlThisFrame(2, Control.ReplayStartStopRecording);
                    Game.EnableControlThisFrame(2, Control.MoveLeftRight);
                    Game.EnableControlThisFrame(2, Control.MoveUpDown);
                    Game.EnableControlThisFrame(2, Control.LookLeftRight);
                    Game.EnableControlThisFrame(2, Control.LookUpDown);
                    Game.EnableControlThisFrame(2, Control.NextCamera);
                }

                if (weight < maxWeight / 2)
                {
                    if (Profile.LocalUser.IsPlayer)
                    {
                        Game.EnableControlThisFrame(2, Control.Jump);
                        Game.EnableControlThisFrame(2, Control.Sprint);
                    }
                }

                if (Profile.LocalUser.IsRagdoll || Profile.LocalUser.IsBeingStunned ||
                    Profile.LocalUser.IsDead || Profile.LocalUser.IsInVehicle() ||
                    Profile.LocalUser.IsGettingUp)
                {
                    break;
                }

                // Play our pickup animation sequence.
                if (Profile.LocalUser.IsPlayingAnimation("anim@mp_snowball", "pickup_snowball"))
                {
                    hasPlayedAnimation = true;
                    vehicle.Velocity   = Vector3.Zero;
                }
                // Now that we've played that animation let's continue.
                else if (hasPlayedAnimation)
                {
                    Profile.LocalUser.ClearTasksImmediately();
                    Profile.LocalUser.Task.PlayAnimation("random@arrests", "kneeling_arrest_get_up", 8.0f,
                                                         -8.0f, -1,
                                                         AnimationFlags.Loop |
                                                         AnimationFlags.AllowRotation |
                                                         AnimationFlags.UpperBodyOnly, 0.06f);

                    var model = vehicle.Model;
                    var d     = model.GetDimensions();
                    d.X = Math.Max(1.25f, d.X);
                    var height = d.X * 0.8f;

                    // Attack the vehicle to the player.
                    vehicle.AttachToEntity(Profile.LocalUser, -1,
                                           Profile.LocalUser.UpVector * height,
                                           new Vector3(0, 90, 90), false, false, false, 0, true);

                    // Make sure to only do this once.
                    hasPlayedAnimation = false;
                }

                if (Profile.LocalUser.GetConfigFlag(60))
                {
                    Profile.LocalUser.Velocity +=
                        Vector3.WorldDown * (weight * .002f * Time.UnscaledDeltaTime);
                }

                // Set the animation speed to 0 so it loops in that pose.
                Profile.LocalUser.SetAnimationSpeed("random@arrests", "kneeling_arrest_get_up", 0.0f);

                // If we press vehicle enter again, then let's set down the vehicle.
                if (Profile.LocalUser.IsPlayer && Game.IsDisabledControlJustPressed(2, Control.Enter))
                {
                    Profile.LocalUser.Task.ClearAll();
                    Profile.LocalUser.Task.PlayAnimation("anim@mp_snowball", "pickup_snowball", 8.0f, -4.0f,
                                                         500, AnimationFlags.AllowRotation, 0.0f);
                    GameWaiter.Wait(250);
                    vehicle.Detach();
                    vehicle.SetCoordsSafely(Profile.LocalUser.Position + Profile.LocalUser.ForwardVector * 2.5f);
                    break;
                }

                if (GetCanThrow())
                {
                    Profile.LocalUser.Task.ClearAll();
                    Profile.LocalUser.Task.PlayAnimation("weapons@projectile@", "throw_m_fb_stand", 8.0f,
                                                         -4.0f, 500, AnimationFlags.AllowRotation, 0.1f);
                    vehicle.Detach();
                    vehicle.Velocity          += Profile.LocalUser.Velocity;
                    vehicle.Velocity           = Profile.GetCameraDirection() * 25000 / weight;
                    Profile.LocalUser.Velocity = Vector3.Zero;
                    ThrowVehicle = false;
                    break;
                }

                Script.Yield();
            }

            // Detach the vehicle if needed.
            if (vehicle.IsAttached())
            {
                vehicle.Detach();
            }
            vehicle.ResetAlpha();

            // Clear this animation from the player if it's still playing.
            Profile.LocalUser.Task.ClearAnimation("random@arrests", "kneeling_arrest_get_up");

            // Make sure to clear the current pickup vehicle.
            _currentPickupVehicle = null;

            var timer = DateTime.Now + new TimeSpan(0, 0, 0, 0, 600);

            while (DateTime.Now < timer)
            {
                vehicle.SetNoCollision(Profile.LocalUser, true);
                Script.Yield();
            }
            vehicle.SetNoCollision(Profile.LocalUser, false);
        }