Ejemplo n.º 1
0
        public void IssueTicket(bool SeizeVehicle)
        {
            GameFiber.StartNew(delegate
            {
                Game.LocalPlayer.Character.Tasks.AchieveHeading(Game.LocalPlayer.Character.CalculateHeadingTowardsEntity(Suspect));
                Functions.GetPersonaForPed(Suspect).Citations++;
                GameFiber.Wait(1500);
                Game.LocalPlayer.Character.Tasks.Clear();
                NativeFunction.Natives.TASK_START_SCENARIO_IN_PLACE(Game.LocalPlayer.Character, "CODE_HUMAN_MEDIC_TIME_OF_DEATH", 0, true);

                //Do animation
                while (!NativeFunction.Natives.IS_PED_ACTIVE_IN_SCENARIO <bool>(Game.LocalPlayer.Character))
                {
                    GameFiber.Yield();
                }
                int Waitcount = 0;
                while (NativeFunction.Natives.IS_PED_ACTIVE_IN_SCENARIO <bool>(Game.LocalPlayer.Character))
                {
                    GameFiber.Yield();
                    Waitcount++;
                    if (Waitcount >= 300)
                    {
                        Game.LocalPlayer.Character.Tasks.Clear();
                    }
                }
                GameFiber.Wait(4000);

                if (SeizeVehicle && SuspectVehicle.Exists())
                {
                    //Game.LogTrivial("Debug 4");
                    foreach (Ped occupant in SuspectVehicle.Occupants)
                    {
                        occupant.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(6000);
                        if (occupant.IsInAnyVehicle(false))
                        {
                            occupant.Tasks.LeaveVehicle(LeaveVehicleFlags.WarpOut).WaitForCompletion(100);
                        }
                        occupant.Tasks.Wander();
                    }

                    GameFiber.Wait(1000);
                    Game.LocalPlayer.Character.Tasks.ClearImmediately();
                    if (LSPDFRPlusHandler.ArrestManagerRunning)
                    {
                        API.ArrestManagerFuncs.RequestTowForVeh(SuspectVehicle);
                    }
                }
                else
                {
                    GameFiber.Wait(2500);
                    Functions.ForceEndCurrentPullover();
                }

                StatisticsCounter.AddCountToStatistic("Traffic Stop - Tickets Issued", "LSPDFR+");
            });
        }
Ejemplo n.º 2
0
 public void IssueWarning()
 {
     GameFiber.StartNew(delegate
     {
         PlaySpecificSpeech("Warn");
         GameFiber.Wait(2500);
         Functions.ForceEndCurrentPullover();
         StatisticsCounter.AddCountToStatistic("Traffic Stop - Warnings Issued", "LSPDFR+");
     });
 }
Ejemplo n.º 3
0
        public static void MainLoop()
        {
            GameFiber.StartNew(delegate
            {
                while (true)
                {
                    try
                    {
                        GameFiber.Yield();

                        if (Functions.GetActivePursuit() != null)
                        {
                            if (!AutoPursuitBackupEnabled)
                            {
                                Functions.SetPursuitCopsCanJoin(Functions.GetActivePursuit(), false);
                            }

                            if (!InPursuit)
                            {
                                StatisticsCounter.AddCountToStatistic("Pursuits", "LSPDFR+");
                                InPursuit = true;
                                API.Functions.OnPlayerJoinedActivePursuit();
                                if (EnhancedPursuitAIEnabled)
                                {
                                    Game.DisplayHelp("Press ~b~" + ExtensionMethods.GetKeyString(OpenPursuitTacticsMenuKey, OpenPursuitTacticsMenuModifierKey) + " ~s~to open the pursuit tactics menu.");
                                    //Menus.AutomaticTacticsCheckboxItem.Checked = true;
                                }
                            }


                            if (EnhancedPursuitAIEnabled)
                            {
                                if (Functions.GetPursuitPeds(Functions.GetActivePursuit()).Length <= 0)
                                {
                                    Functions.ForceEndPursuit(Functions.GetActivePursuit()); continue;
                                }
                                Ped[] pursuitpeds = (from x in Functions.GetPursuitPeds(Functions.GetActivePursuit()) where x.Exists() orderby Game.LocalPlayer.Character.DistanceTo(x) select x).ToArray();
                                if (pursuitpeds.Length > 0)
                                {
                                    EnhancedPursuitAI.AutomaticAI        = Menus.AutomaticTacticsCheckboxItem.Checked;
                                    Menus.PursuitTacticsListItem.Enabled = !Menus.AutomaticTacticsCheckboxItem.Checked;
                                    if (AutomaticAI)
                                    {
                                        if (Game.LocalPlayer.Character.IsInAnyVehicle(false) && pursuitpeds[0].IsInAnyVehicle(false))
                                        {
                                            if (Game.LocalPlayer.Character.DistanceTo(pursuitpeds[0].GetOffsetPosition(Vector3.RelativeFront * 4f)) < Game.LocalPlayer.Character.DistanceTo(pursuitpeds[0].GetOffsetPosition(Vector3.RelativeBack * 4f)) && Game.LocalPlayer.Character.DistanceTo(pursuitpeds[0]) < 40f)
                                            {
                                                CurrentPursuitTactic = PursuitTactics.SlightlyAggressive;
                                            }
                                            else if (Game.LocalPlayer.Character.DistanceTo(pursuitpeds[0].Position) > 130f)
                                            {
                                                CurrentPursuitTactic = PursuitTactics.FulloutAggressive;
                                            }
                                            else
                                            {
                                                CurrentPursuitTactic = PursuitTactics.Safe;
                                            }
                                        }
                                        else
                                        {
                                            CurrentPursuitTactic = PursuitTactics.FulloutAggressive;
                                        }
                                        Menus.PursuitTacticsListItem.Index = (int)CurrentPursuitTactic;
                                    }
                                    else
                                    {
                                        CurrentPursuitTactic = (PursuitTactics)Menus.PursuitTacticsListItem.Index;
                                    }

                                    foreach (Ped ped in Game.LocalPlayer.Character.GetNearbyPeds(16))
                                    {
                                        if (ped.Exists() && !CopsInPursuit.Contains(ped))
                                        {
                                            if (ped.IsInAnyPoliceVehicle && ped.IsPolicePed())
                                            {
                                                if (!ped.CurrentVehicle.IsInAir && !ped.CurrentVehicle.IsHelicopter && !ped.CurrentVehicle.IsBoat)
                                                {
                                                    CopsInPursuit.Add(ped);
                                                }
                                            }
                                            else if (!Functions.GetPursuitPeds(Functions.GetActivePursuit()).Contains(ped) && ped.IsInAnyVehicle(false))
                                            {
                                                Rage.Native.NativeFunction.Natives.SET_DRIVE_TASK_DRIVING_STYLE(ped, 786603);
                                            }
                                        }
                                    }
                                    //Game.LogTrivial("Pursuittactic: " + CurrentPursuitTactic);
                                    float distance = Vector3.Distance(pursuitpeds[0].Position, Game.LocalPlayer.Character.Position) + 10f;

                                    Ped[] CopsInPursuitOrdered = (from x in CopsInPursuit where x.Exists() orderby x.DistanceTo(pursuitpeds[0].Position) select x).ToArray();
                                    //Ped[] CopsInPursuitOrdered = (from x in (from y in CopsInPursuit where y.Exists() select y) orderby x.DistanceTo(pursuitpeds[0].Position) select x).ToArray();
                                    //Ped[] NearbyPedsInOrder = (from x in (from y in NearbyPeds where y.Exists() select y) orderby x.DistanceTo(Game.LocalPlayer.Character.Position) select x).ToArray();
                                    foreach (Ped ped in CopsInPursuitOrdered)
                                    {
                                        GameFiber.Yield();
                                        if (ped.Exists())
                                        {
                                            if (ped.IsInAnyVehicle(false) && !ped.CurrentVehicle.IsInAir)
                                            {
                                                NativeFunction.Natives.SET_DRIVER_ABILITY(ped, 1.0f);
                                                int flag = 1;

                                                //8: Medium-aggressive boxing tactic with a bit of PIT
                                                //1: Aggressive ramming of suspect
                                                //2: Ram attempts
                                                //32: Stay back from suspect, no tactical contact. Convoy-like.
                                                //16: Ramming, seems to be slightly less aggressive than 1-2.

                                                distance += 15;



                                                if (Game.LocalPlayer.Character.IsInAnyVehicle(false) && pursuitpeds[0].IsInAnyVehicle(false))
                                                {
                                                    if (CurrentPursuitTactic == PursuitTactics.Safe)
                                                    {
                                                        Rage.Native.NativeFunction.Natives.SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE(ped, distance);
                                                        flag = 32;
                                                        //Game.LogTrivial("Setting pursuit distance " + distance.ToString());
                                                        Rage.Native.NativeFunction.Natives.SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG(ped, flag, true);
                                                        //Game.LogTrivial("Setting behaviour flag to " + flag.ToString());
                                                        NativeFunction.Natives.SET_DRIVER_AGGRESSIVENESS(ped, 0.1f);
                                                    }
                                                    else if (CurrentPursuitTactic == PursuitTactics.SlightlyAggressive)
                                                    {
                                                        Rage.Native.NativeFunction.Natives.SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE(ped, 0f);
                                                        //Game.LogTrivial("Setting pursuit distance 0");
                                                        flag = 8;
                                                        Rage.Native.NativeFunction.Natives.SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG(ped, flag, true);
                                                        //Game.LogTrivial("Setting behaviour flag to " + flag.ToString());
                                                        NativeFunction.Natives.SET_DRIVER_AGGRESSIVENESS(ped, 0.5f);
                                                    }
                                                    else
                                                    {
                                                        ped.Tasks.Clear();
                                                        ped.Tasks.ChaseWithGroundVehicle(pursuitpeds[0]);
                                                        NativeFunction.Natives.SET_DRIVER_AGGRESSIVENESS(ped, 1.0f);
                                                    }
                                                }
                                                else
                                                {
                                                    ped.Tasks.Clear();
                                                    ped.Tasks.ChaseWithGroundVehicle(pursuitpeds[0]);
                                                    NativeFunction.Natives.SET_DRIVER_AGGRESSIVENESS(ped, 1.0f);
                                                }
                                                //else
                                                //{
                                                //    Rage.Native.NativeFunction.Natives.SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE(ped, 0f);
                                                //    Game.LogTrivial("Setting pursuit distance 0");
                                                //    flag = 8;
                                                //}



                                                //Works with: 32, 16, 8,
                                            }
                                        }
                                    }
                                    if (CurrentPursuitTactic == PursuitTactics.FulloutAggressive)
                                    {
                                        GameFiber.Wait(600);
                                    }
                                }
                            }
                        }
                        else
                        {
                            InPursuit = false;
                            if (CopsInPursuit.Count > 0)
                            {
                                CopsInPursuit.Clear();
                            }
                        }
                    }
                    catch (System.Threading.ThreadAbortException e) { break; }
                    catch (Exception e)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Handled");
                    }
                }
            });
        }
Ejemplo n.º 4
0
        private static void MainLogic()
        {
            GameFiber.StartNew(delegate
            {
                try
                {
                    while (true)
                    {
                        GameFiber.Yield();
                        if (EnhancedPursuitAI.InPursuit && Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            if (ExtensionMethods.IsKeyCombinationDownComputerCheck(EnhancedPursuitAI.OpenPursuitTacticsMenuKey, EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey))
                            {
                                PursuitTacticsMenu.Visible = !PursuitTacticsMenu.Visible;
                            }
                        }
                        else
                        {
                            PursuitTacticsMenu.Visible = false;
                        }

                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != CurrentEnhancedTrafficStop.Suspect)
                            {
                                CurrentEnhancedTrafficStop = new EnhancedTrafficStop();

                                StatisticsCounter.AddCountToStatistic("Traffic Stops", "LSPDFR+");
                                Game.LogTrivial("Adding traffic stop count - LSPDFR+");
                                API.Functions.OnTrafficStopInitiated(Functions.GetPulloverSuspect(Functions.GetCurrentPullover()));
                            }
                        }
                        //Shift Q ticket menu handler.
                        else if (!_MenuPool.IsAnyMenuOpen() && !Game.LocalPlayer.Character.IsInAnyVehicle(false) && ExtensionMethods.IsKeyCombinationDownComputerCheck(Offence.OpenTicketMenuKey, Offence.OpenTicketMenuModifierKey) &&
                                 Game.LocalPlayer.Character.GetNearbyPeds(1)[0].Exists() && Game.LocalPlayer.Character.DistanceTo(Game.LocalPlayer.Character.GetNearbyPeds(1)[0]) < 5f)
                        {
                            Game.LocalPlayer.Character.Tasks.ClearImmediately();
                            _MenuPool.ResetMenus(true, true);
                            CurrentEnhancedTrafficStop.SelectedOffences.Clear();
                            SeizeVehicleTicketCheckboxItem.Enabled = false;
                            TicketMenu.ParentMenu = null;
                            foreach (UIMenu m in OffenceCategoryMenus)
                            {
                                m.Visible = false;
                            }
                            TicketMenu.Visible = true;
                        }

                        if (!LSPDFRPlusHandler.BritishPolicingScriptRunning && ExtensionMethods.IsKeyDownComputerCheck(CourtSystem.OpenCourtMenuKey) && (ExtensionMethods.IsKeyDownRightNowComputerCheck(CourtSystem.OpenCourtMenuModifierKey) || CourtSystem.OpenCourtMenuModifierKey == Keys.None))
                        {
                            if (!CourtsMenu.Visible)
                            {
                                CourtsMenu.Visible = true;
                            }
                        }

                        if (_MenuPool.IsAnyMenuOpen())
                        {
                            NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0);
                        }

                        //Prevent the traffic stop menu from being used when it shouldn't be.
                        if (TrafficStopMenu.Visible)
                        {
                            if (!Functions.IsPlayerPerformingPullover())
                            {
                                if (TrafficStopMenuEnabled)
                                {
                                    ToggleUIMenuEnabled(TrafficStopMenu, false);
                                    TrafficStopMenuEnabled = false;
                                }
                            }
                            else if (Vector3.Distance2D(Game.LocalPlayer.Character.Position, Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).Position) > TrafficStopMenuDistance)
                            {
                                if (TrafficStopMenuEnabled)
                                {
                                    ToggleUIMenuEnabled(TrafficStopMenu, false);
                                    TrafficStopMenuEnabled = false;
                                }
                            }
                            else if (!TrafficStopMenuEnabled)
                            {
                                ToggleUIMenuEnabled(TrafficStopMenu, true);
                                TrafficStopMenuEnabled = true;
                            }
                        }

                        if (CourtsMenu.Visible)
                        {
                            if (!CourtsMenuPaused)
                            {
                                CourtsMenuPaused = true;
                                Game.IsPaused    = true;
                            }
                            if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Delete))
                            {
                                if (PendingResultsList.Active)
                                {
                                    if (CourtCase.PendingResultsMenuCleared)
                                    {
                                        CourtSystem.DeleteCourtCase(CourtSystem.PendingCourtCases[PendingResultsList.Index]);
                                        PendingResultsList.Index = 0;
                                    }
                                }
                                else if (PublishedResultsList.Active)
                                {
                                    if (CourtCase.ResultsMenuCleared)
                                    {
                                        CourtSystem.DeleteCourtCase(CourtSystem.PublishedCourtCases[PublishedResultsList.Index]);

                                        PublishedResultsList.Index = 0;
                                    }
                                }
                            }

                            if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Insert))
                            {
                                if (PendingResultsList.Active)
                                {
                                    if (CourtCase.PendingResultsMenuCleared)
                                    {
                                        CourtSystem.PendingCourtCases[PendingResultsList.Index].ResultsPublishTime = DateTime.Now;
                                        PendingResultsList.Index = 0;
                                    }
                                }
                            }
                        }
                        else if (CourtsMenuPaused)
                        {
                            CourtsMenuPaused = false;
                            Game.IsPaused    = false;
                        }
                    }
                }
                catch (System.Threading.ThreadAbortException e) { }
                catch (Exception e) { Game.LogTrivial(e.ToString()); }
            });
        }
Ejemplo n.º 5
0
        private static void MainLoop()
        {
            GameFiber.StartNew(delegate
            {
                Game.LogTrivial("LSPDFR+ has been initialised successfully and is now loading INI, XML and dependencies. Standby...");
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LSPDFRResolveEventHandler);
                GameFiber.Sleep(5000);
                BritishPolicingScriptRunning = IsLSPDFRPluginRunning("British Policing Script", new Version("0.9.0.0"));
                ArrestManagerRunning         = IsLSPDFRPluginRunning("Arrest Manager", new Version("7.6.8.0"));
                TrafficPolicerRunning        = IsLSPDFRPluginRunning("Traffic Policer", new Version("6.13.6.0"));
                if (BritishPolicingScriptRunning)
                {
                    API.BritishPolicingScriptFunctions.RegisterBPSOutOfVehicleEvent();
                    Offence.currency = "£";
                }
                if (ArrestManagerRunning)
                {
                    API.ArrestManagerFuncs.PlayerArrestedPedHandler();
                }
                else
                {
                    Game.DisplayNotification("To optimally use LSPDFR+, you are advised to install Arrest Manager by Albo1125.");
                }

                if (!TrafficPolicerRunning)
                {
                    Game.DisplayNotification("To optimally use LSPDFR+, you are advised to install Traffic Policer by Albo1125.");
                }

                Offence.DeserializeOffences();
                Game.LogTrivial("TrafficOffences:");
                Offence.CategorizedTrafficOffences.Values.ToList().ForEach(x => x.ForEach(y => Game.LogTrivial(y.ToString())));
                Menus.InitialiseMenus();

                CourtSystem.CourtSystemMainLogic();

                EnhancedPursuitAI.MainLoop();
                StatisticsCounter.AddCountToStatistic("Times gone on duty", "LSPDFR+");

                Game.LogTrivial("LSPDFR+ has been fully initialised successfully and is now working.");

                TimeOnDutyStopWatch.Start();
                while (true)
                {
                    GameFiber.Yield();

                    if (Functions.IsPlayerPerformingPullover() && NativeFunction.Natives.UPDATE_ONSCREEN_KEYBOARD <int>() == 0)
                    {
                        Game.DisplaySubtitle("~h~Stopped Vehicle: " + Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).CurrentVehicle.LicensePlate, 50);
                    }

                    if (Game.IsPaused && TimeOnDutyStopWatch.IsRunning)
                    {
                        TimeOnDutyStopWatch.Stop();
                    }
                    else if (!Game.IsPaused && !TimeOnDutyStopWatch.IsRunning)
                    {
                        TimeOnDutyStopWatch.Start();
                    }

                    if (TimeOnDutyStopWatch.ElapsedMilliseconds > 60000)
                    {
                        StatisticsCounter.AddCountToStatistic("Minutes spent on duty", "LSPDFR+");

                        TimeOnDutyStopWatch.Restart();
                    }
                }
            });
        }