public static Ped ClonePed(this Ped oldped, bool ClonePersona)
        {
            Persona oldpers = Functions.GetPersonaForPed(oldped);
            Ped     NewPed  = oldped.ClonePed();

            if (ClonePersona)
            {
                Functions.SetPersonaForPed(NewPed, oldpers);
            }
            return(NewPed);
        }
Example #2
0
 public static void RequestTransportToHospitalForNearestPed()
 {
     GameFiber.StartNew(delegate
     {
         Ped pedtotransport = GetNearestValidPed(3.5f);
         if (pedtotransport.Exists())
         {
             if (Functions.IsPedArrested(pedtotransport))
             {
                 pedtotransport = pedtotransport.ClonePed(true);
                 pedtotransport.Tasks.PlayAnimation("mp_arresting", "idle", 8f, AnimationFlags.UpperBodyOnly | AnimationFlags.SecondaryTask | AnimationFlags.Loop);
             }
             Functions.SetPedCantBeArrestedByPlayer(pedtotransport, true);
             API.BetterEMSFuncs.RequestTransportToHospitalForNearestValidPed(pedtotransport);
         }
     });
 }
Example #3
0
        protected override void MainLogic()
        {
            if (!drvPed1.Exists())
            {
                return;
            }
            if (!drvPed2.Exists())
            {
                return;
            }
            if (!vehRacer1.Exists())
            {
                return;
            }
            if (!vehRacer2.Exists())
            {
                return;
            }



            TrafficPolicerHandler.driversConsidered.Add(drvPed1);
            TrafficPolicerHandler.driversConsidered.Add(drvPed2);
            //Make some kind of cleanup function to be called


            drvPed1.WarpIntoVehicle(vehRacer1, -1);
            drvPed2.WarpIntoVehicle(vehRacer2, -1); //-1 is driverseat, 0 is passengerseat



            AmbientEventMainFiber = GameFiber.StartNew(delegate

            { //A multitasking fiber.
                try
                {
                    bool pursuitCreated = false;
                    bool teleported     = false;
                    int closeCount      = 0;
                    int waitingCount    = 0;
                    drvPed1.Tasks.CruiseWithVehicle(vehRacer1, 80f, VehicleDrivingFlags.Emergency); //Make the ped drive
                    Rage.Native.NativeFunction.Natives.TASK_VEHICLE_CHASE(drvPed2, drvPed1);
                    while (eventRunning)
                    {//main loop, runs until broken with break;
                        GameFiber.Wait(10);
                        waitingCount++;



                        if (!pursuitCreated)
                        {
                            if (!teleported)
                            {
                                if ((waitingCount > 100) && waitingCount < 130)
                                {
                                    if (Vector3.Distance(drvPed1.Position, drvPed2.Position) > 40f)
                                    {
                                        vehRacer2.Position = vehRacer1.GetOffsetPosition(Vector3.RelativeBack * 5f);
                                        vehRacer2.Heading  = vehRacer1.Heading;
                                        teleported         = true;
                                    }
                                }
                            }

                            if ((Vector3.Distance(Game.LocalPlayer.Character.Position, vehRacer1.Position) < 20f) || (Vector3.Distance(Game.LocalPlayer.Character.Position, vehRacer2.Position) < 20f))
                            {
                                if (Functions.IsPlayerPerformingPullover() && Game.LocalPlayer.Character.IsInAnyVehicle(false))
                                {
                                    if ((Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == drvPed1) || (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == drvPed2))
                                    {
                                        Game.LogTrivial("Initiating Street Race Pursuit");
                                        if (!drvPed1.Exists())
                                        {
                                            End(); return;
                                        }
                                        if (!drvPed2.Exists())
                                        {
                                            End(); return;
                                        }
                                        if (!vehRacer1.Exists())
                                        {
                                            End(); return;
                                        }
                                        if (!vehRacer2.Exists())
                                        {
                                            End(); return;
                                        }
                                        if (drvPed1.IsInVehicle(vehRacer1, false))
                                        {
                                            drvPed1.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait);
                                        }
                                        if (drvPed2.IsInVehicle(vehRacer2, false))
                                        {
                                            drvPed2.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait);
                                        }
                                        GameFiber.Wait(200);
                                        if (drvPed1.IsInVehicle(vehRacer1, false))
                                        {
                                            drvPed1.Tasks.PerformDrivingManeuver(VehicleManeuver.BurnOut);
                                        }
                                        if (drvPed2.IsInVehicle(vehRacer2, false))
                                        {
                                            drvPed2.Tasks.PerformDrivingManeuver(VehicleManeuver.BurnOut);
                                        }
                                        GameFiber.Wait(2000);

                                        if (drvBlip1.Exists())
                                        {
                                            drvBlip1.Delete();
                                        }
                                        if (drvBlip2.Exists())
                                        {
                                            drvBlip2.Delete();
                                        }
                                        drvPed1 = drvPed1.ClonePed();
                                        TrafficPolicerHandler.driversConsidered.Add(drvPed1);
                                        drvPed2 = drvPed2.ClonePed();
                                        TrafficPolicerHandler.driversConsidered.Add(drvPed2);
                                        pursuit = Functions.CreatePursuit();
                                        Functions.AddPedToPursuit(pursuit, drvPed1);
                                        Functions.AddPedToPursuit(pursuit, drvPed2);
                                        Functions.SetPursuitIsActiveForPlayer(pursuit, true);

                                        if (Game.LocalPlayer.Character.IsInAnyVehicle(false))
                                        {
                                            Game.LocalPlayer.Character.CurrentVehicle.IsSirenOn     = true;
                                            Game.LocalPlayer.Character.CurrentVehicle.IsSirenSilent = false;
                                        }
                                        GameFiber.Wait(300);
                                        drvPed1.PlayAmbientSpeech("GENERIC_CURSE_HIGH", true);
                                        drvPed2.PlayAmbientSpeech("GENERIC_CURSE_HIGH", true);
                                        GameFiber.Wait(800);
                                        Functions.PlayScannerAudioUsingPosition("WE_HAVE VEHICLES_RACING IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);

                                        pursuitCreated = true;
                                        Game.LogTrivial("Street race pursuit created.");

                                        break;
                                    }
                                }
                            }
                            else if (Vector3.Distance(Game.LocalPlayer.Character.Position, drvPed1.Position) > 350f)
                            {
                                End();
                                return;
                            }
                        }
                    }

                    if (pursuit == null)
                    {
                        End();
                    }
                    while (eventRunning && Functions.IsPursuitStillRunning(pursuit))
                    {
                        GameFiber.Yield();
                        if (drvPed1.Exists())
                        {
                            if (Vector3.Distance(drvPed1.Position, Game.LocalPlayer.Character.Position) > 2000f)
                            {
                                if (!Functions.IsPedArrested(drvPed1))
                                {
                                    Game.DisplayNotification("A street racer has ~r~escaped");
                                }

                                drvPed1.Delete();
                            }
                        }
                        if (drvPed2.Exists())
                        {
                            if (Vector3.Distance(drvPed2.Position, Game.LocalPlayer.Character.Position) > 2000f)
                            {
                                if (!Functions.IsPedArrested(drvPed2))
                                {
                                    Game.DisplayNotification("A street racer has ~r~escaped");
                                }

                                drvPed2.Delete();
                            }
                        }
                    }
                    base.End();
                }
                catch (Exception e)
                {
                    End();
                }
            });
        }