コード例 #1
0
        public override void Abort()
        {
            //Ped.FreezePosition = false;

            if (GrappleHook != null)
            {
                GrappleHook.Delete();
            }

            if (GrappleTaskSequence != null)
            {
                GrappleTaskSequence.Dispose();
                Ped.Task.ClearAll();
            }

            if (IsPlayingGlideAnim)
            {
                ClearGlideAnimation();
            }

            if (IsDoingGlideKick)
            {
                ClearGlideKickAnimation();
            }

            if (IsDoingCombatRoll || IsAttackingAnything)
            {
                ClearAttackAnimation();
            }

            if (IsThrowingBatarang)
            {
                ClearBatarangAnimation();
            }

            if (IsPlayingGrappleAnimation)
            {
                ClearGrappleAnimation();
            }

            if (IsPlayingGrappleReelAnimation)
            {
                ClearGrappleReelAnimation();
            }

            if (BatGrappleInstance != null)
            {
                BatGrappleInstance.Delete();
            }
        }
コード例 #2
0
        private void HandleGrapple()
        {
            if (IsGrappling)
            {
                if (!Exists(BatGrappleInstance))
                {
                    var prop = World.CreateProp(BatGrappleModel, Ped.Position + Vector3.RelativeTop * 100, false, false);

                    prop.FreezePosition = true;

                    prop.AttachTo(Ped, Ped.GetBoneIndex(Bone.SKEL_R_Hand), new Vector3(0.1f, 0f, 0), new Vector3(-90, 0, 0));

                    BatGrappleInstance = prop;
                }
            }
            else
            {
                if (Exists(BatGrappleInstance))
                {
                    BatGrappleInstance.Delete();
                }
            }

            if (!IsGrappling || Ped.IsRagdoll || IsGliding)
            {
                if (IsPlayingGrappleAnimation)
                {
                    ClearGrappleAnimation();
                }

                if (IsPlayingGrappleReelAnimation)
                {
                    ClearGrappleReelAnimation();
                }

                if (GrappleHook != null)
                {
                    GrappleHook.Delete();
                }

                if (IsGrappling)
                {
                    IsGrappling = false;
                }

                GrappleSpeed = 0f;

                return;
            }

            if (Exists(BatGrappleInstance) && BatGrappleInstance.IsAttachedTo(Ped))
            {
                Function.Call(Hash.PROCESS_ENTITY_ATTACHMENTS, Ped.Handle);
            }

            if (!IsPlayingGrappleAnimation)
            {
                Ped.Heading = (LastGrapplePoint - Ped.Position).ToHeading();

                StartGrappleTaskSequence();

                Ped.SetConfigFlag(60, true);

                IsPlayingGrappleAnimation = true;

                GrappleHook = new GrappleHook(LastGrapplePoint, this, BatGrappleInstance);
            }
            else
            {
                if (!GrappleHook.IsHooked)
                {
                    Ped.SetConfigFlag(60, true);

                    GrappleHook.Update();
                }
                else
                {
                    if (!IsPlayingGrappleReelAnimation)
                    {
                        var vel = Ped.Velocity;

                        Ped.Task.ClearAll();

                        Ped.Velocity = Vector3.Zero;

                        Ped.PlayAnimation("skydive@parachute@", "chute_idle", 8.0f, -8.0f, -1, AnimationFlags.Loop, 0.0f);

                        Ped.PlayAnimation("weapons@pistol_1h@", "aim_high_loop", 8.0f, -8.0f, -1, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation | AnimationFlags.StayInEndFrame, 0f);

                        Ped.SetAnimationSpeed("skydive@parachute@", "chute_idle", 0f);

                        Ped.SetAnimationSpeed("weapons@pistol_1h@", "aim_high_loop", 0f);

                        Ped.Velocity = vel;

                        Ped.SetConfigFlag(60, true);

                        IsPlayingGrappleReelAnimation = true;
                    }
                    else
                    {
                        var dirNormalized = (LastGrapplePoint - Ped.Position).Normalized;

                        Ped.SetConfigFlag(60, true);

                        if (Ped.HasCollidedWithAnything && Ped.Velocity.Length() > 5f)
                        {
                            var ray = World.Raycast(Ped.Position + (-LastGrappleWallNormal * 1.15f) + (Vector3.RelativeTop * 2f), Vector3.RelativeBottom, 5f, IntersectOptions.Map, Ped);

                            if (!ray.DitHitAnything)
                            {
                                var dir = Vector3.Reflect(dirNormalized, LastGrappleWallNormal);

                                Ped.Heading = dir.ToHeading();

                                Ped.Velocity = Ped.ForwardVector * 50;

                                IsGliding = true;

                                GlideHorizontalAdditive = new Vector3(0, -90, 0f);
                            }
                            else
                            {
                                Ped.Heading = (-LastGrappleWallNormal).ToHeading();

                                Ped.Task.ClearAll();

                                Ped.Velocity = Vector3.Zero;

                                Ped.Task.Climb();
                            }

                            IsGrappling = false;
                        }
                        else
                        {
                            Ped.Quaternion = Quaternion.FromToRotation(Ped.UpVector, dirNormalized) * Ped.Quaternion;

                            GrappleHook.Update();

                            GrappleSpeed = Mathf.Lerp(GrappleSpeed, 90f, Game.LastFrameTime * 2.5f);

                            Ped.Velocity = dirNormalized * GrappleSpeed;
                        }
                    }
                }
            }
        }