Example #1
0
        public override void End()
        {
            CalloutRunning = false;
            Rage.Native.NativeFunction.Natives.RESET_AI_MELEE_WEAPON_DAMAGE_MODIFIER();
            if (Game.LocalPlayer.Character.Exists())
            {
                if (Game.LocalPlayer.Character.IsDead)
                {
                    GameFiber.Wait(1500);
                    Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE");
                    GameFiber.Wait(3000);
                }
            }
            else
            {
                GameFiber.Wait(1500);
                Functions.PlayScannerAudio("OFFICER HAS_BEEN_FATALLY_SHOT NOISE_SHORT OFFICER_NEEDS_IMMEDIATE_ASSISTANCE");
                GameFiber.Wait(3000);
            }
            base.End();

            if (PoliceOfficerBlip.Exists())
            {
                PoliceOfficerBlip.Delete();
            }

            if (CalloutFinished)
            {
                if (PoliceOfficer.Exists())
                {
                    PoliceOfficer.Dismiss();
                }
                if (PoliceCar.Exists())
                {
                    PoliceCar.Dismiss();
                }
                if (Suspect.Exists())
                {
                    if (!Suspect.IsInAnyVehicle(false))
                    {
                        Suspect.Dismiss();
                    }
                    else
                    {
                        if (Suspect.CurrentVehicle.Driver == Suspect)
                        {
                            Suspect.Dismiss();
                        }
                        else
                        {
                            Suspect.Delete();
                        }
                    }
                }
                if (SuspectCar.Exists())
                {
                    SuspectCar.Dismiss();
                }
            }
            else
            {
                if (PoliceCar.Exists())
                {
                    PoliceCar.Delete();
                }


                if (PoliceOfficer.Exists())
                {
                    PoliceOfficer.Delete();
                }
                if (Suspect.Exists())
                {
                    Suspect.Delete();
                }
                if (SuspectCar.Exists())
                {
                    SuspectCar.Delete();
                }
            }
        }
        private void CalloutHandler()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    Suspect.Tasks.CruiseWithVehicle(SuspectCar, 20f, VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds);
                    GameFiber.Wait(3000);
                    Game.DisplayNotification("Suspicious truck~s~ is a ~b~" + CarModelName + ".");
                    Game.DisplayNotification("The plate is ~b~" + SuspectCar.LicensePlate + ". ~s~Added to ~o~ANPR system.");
                    GameFiber.Wait(3000);
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Added " + CarModelName + " with licence plate " + SuspectCar.LicensePlate + " to fixed ANPR system.");
                        API.ComputerPlusFuncs.AddVehicleToCallout(CalloutID, SuspectCar);
                    }
                    HandleSearchForVehicleWithANPR();
                    if (ComputerPlusRunning)
                    {
                        API.ComputerPlusFuncs.SetCalloutStatusToAtScene(CalloutID);

                        API.ComputerPlusFuncs.AddUpdateToCallout(CalloutID, "Suspicious truck located. Engaging traffic stop.");
                    }
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (!CalloutRunning)
                        {
                            break;
                        }
                        if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            break;
                        }
                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) == Suspect)

                            {
                                break;
                            }
                        }
                    }
                    if (Functions.IsPlayerPerformingPullover() && CalloutRunning)
                    {
                        GameFiber.Wait(3000);
                    }
                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if (AssortedCalloutsHandler.rnd.Next(11) < 2 || !Game.LocalPlayer.Character.IsInAnyVehicle(false) || Functions.GetActivePursuit() != null)
                    {
                        if (CalloutRunning)
                        {
                            if (Functions.GetActivePursuit() != null)
                            {
                                Functions.ForceEndPursuit(Functions.GetActivePursuit());
                            }
                            Pursuit = Functions.CreatePursuit();
                            Functions.AddPedToPursuit(Pursuit, Suspect);
                            foreach (Ped migrant in IllegalImmigrants)
                            {
                                Functions.AddPedToPursuit(Pursuit, migrant);
                            }
                            Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                            if (Functions.IsPlayerPerformingPullover())
                            {
                                Functions.ForceEndCurrentPullover();
                            }
                            Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                            if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                            }
                            else
                            {
                                Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                            }

                            while (Functions.IsPursuitStillRunning(Pursuit))
                            {
                                GameFiber.Yield();
                                if (!CalloutRunning)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        while (CalloutRunning)
                        {
                            GameFiber.Yield();

                            if (!Game.LocalPlayer.Character.IsInAnyVehicle(false) || Functions.GetActivePursuit() != null)
                            {
                                GameFiber.Wait(1000);
                                if (AssortedCalloutsHandler.rnd.Next(6) < 2 || Functions.GetActivePursuit() != null)
                                {
                                    if (Functions.GetActivePursuit() != null)
                                    {
                                        Functions.ForceEndPursuit(Functions.GetActivePursuit());
                                    }
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        Functions.AddPedToPursuit(Pursuit, migrant);
                                    }
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }

                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                                    if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~making off.~b~ Giving chase.");
                                    }
                                    else
                                    {
                                        Game.DisplayNotification("Control, the vehicle is ~r~fleeing,~b~ In pursuit.");
                                    }
                                }
                                break;
                            }
                        }

                        if (Pursuit == null)
                        {
                            while (CalloutRunning)
                            {
                                GameFiber.Yield();
                                if (Functions.GetActivePursuit() != null)
                                {
                                    Functions.ForceEndPursuit(Functions.GetActivePursuit());
                                }
                                if (Vector3.Distance(Game.LocalPlayer.Character.Position, SuspectCar.RearPosition) < 3f)
                                {
                                    //Game.LogTrivial("Illegalimmigrant length: " + IllegalImmigrants.Count.ToString());
                                    if (IllegalImmigrants[0].Exists())
                                    {
                                        if (!IllegalImmigrants[0].IsAnySpeechPlaying)
                                        {
                                            IllegalImmigrants[0].PlayAmbientSpeech("GENERIC_CURSE_MED");
                                        }
                                    }
                                    Game.DisplayHelp("You can open the back of the truck by pressing ~b~F.");
                                    if (Game.IsKeyDown(System.Windows.Forms.Keys.F))
                                    {
                                        Game.LocalPlayer.Character.Tasks.ClearImmediately();
                                        Game.LocalPlayer.Character.Tasks.GoStraightToPosition(SuspectCar.RearPosition, 1.3f, SuspectCar.Heading, 1f, 3000).WaitForCompletion(2000);

                                        int wait = 0;

                                        while (CalloutRunning)
                                        {
                                            GameFiber.Yield();
                                            wait++;
                                            if (wait > 200)
                                            {
                                                break;
                                            }
                                            if (!SuspectCar.Doors[2].IsOpen)
                                            {
                                                SuspectCar.Doors[2].Open(true);
                                            }
                                            if (!SuspectCar.Doors[3].IsOpen)
                                            {
                                                SuspectCar.Doors[3].Open(true);
                                            }
                                        }

                                        foreach (Ped immigrant in IllegalImmigrants)
                                        {
                                            immigrant.PlayAmbientSpeech("GENERIC_CURSE_MED");
                                            if (immigrant.IsInAnyVehicle(false))
                                            {
                                                immigrant.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(1000);
                                            }
                                        }
                                        SuspectCar.Doors[2].Open(true);
                                        SuspectCar.Doors[3].Open(true);
                                        GameFiber.Wait(3000);
                                        break;
                                    }
                                }
                                else
                                {
                                    Game.DisplaySubtitle("Move to the back of the truck to investigate it.", 50);
                                }
                            }

                            if (CalloutRunning)
                            {
                                int roll = AssortedCalloutsHandler.rnd.Next(8);
                                if (roll < 3)
                                {
                                    foreach (Ped immigrant in IllegalImmigrants)
                                    {
                                        immigrant.Inventory.GiveNewWeapon(MeleeWeapons[AssortedCalloutsHandler.rnd.Next(MeleeWeapons.Length)], -1, true);
                                        immigrant.RelationshipGroup = "ROBBERS";
                                        Game.SetRelationshipBetweenRelationshipGroups("COP", "ROBBERS", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("ROBBERS", "COP", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("ROBBERS", "PLAYER", Relationship.Hate);
                                        Game.SetRelationshipBetweenRelationshipGroups("PLAYER", "ROBBERS", Relationship.Hate);
                                        GameFiber.Yield();
                                        immigrant.Tasks.FightAgainstClosestHatedTarget(60f);
                                    }
                                    if (Suspect.IsInAnyVehicle(false))
                                    {
                                        Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000);
                                    }
                                    Suspect.RelationshipGroup = "ROBBERS";
                                    Suspect.Tasks.FightAgainstClosestHatedTarget(60f);
                                }
                                else if (roll < 6)
                                {
                                    Pursuit = Functions.CreatePursuit();
                                    Functions.AddPedToPursuit(Pursuit, Suspect);
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        Functions.AddPedToPursuit(Pursuit, migrant);
                                    }
                                    Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
                                    if (Functions.IsPlayerPerformingPullover())
                                    {
                                        Functions.ForceEndCurrentPullover();
                                    }
                                    Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESIST_ARREST IN_OR_ON_POSITION", Game.LocalPlayer.Character.Position);
                                    if (AssortedCalloutsHandler.English == AssortedCalloutsHandler.EnglishTypes.BritishEnglish)
                                    {
                                        Game.DisplayNotification("Control, the suspects are ~r~making off. ~b~Giving chase.");
                                    }
                                    else
                                    {
                                        Game.DisplayNotification("Control, the suspects are ~r~fleeing,~b~ In pursuit.");
                                    }
                                }
                                else if (roll < 8)
                                {
                                    foreach (Ped migrant in IllegalImmigrants)
                                    {
                                        migrant.Tasks.PutHandsUp(-1, Game.LocalPlayer.Character);
                                    }
                                    if (Suspect.IsInAnyVehicle(false))
                                    {
                                        Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(5000);
                                    }
                                    Suspect.Tasks.PutHandsUp(-1, Game.LocalPlayer.Character);
                                }
                                List <Ped> Suspects = IllegalImmigrants;
                                Suspects.Add(Suspect);

                                while (CalloutRunning)
                                {
                                    GameFiber.Yield();
                                    if (Pursuit == null)
                                    {
                                        if (Suspects.Count == 0)
                                        {
                                            break;
                                        }
                                        foreach (Ped suspect in Suspects.ToArray())
                                        {
                                            if (!suspect.Exists())
                                            {
                                                EscapeCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (Functions.IsPedArrested(suspect))
                                            {
                                                ArrestCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (suspect.IsDead)
                                            {
                                                DeadCount++;
                                                Suspects.Remove(suspect);
                                            }
                                            else if (Vector3.Distance(suspect.Position, Game.LocalPlayer.Character.Position) > 1000f)
                                            {
                                                EscapeCount++;
                                                Suspects.Remove(suspect);
                                                if (suspect.CurrentVehicle.Exists())
                                                {
                                                    suspect.CurrentVehicle.Delete();
                                                }
                                                suspect.Delete();
                                                Game.DisplayNotification("A suspect has escaped.");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!Functions.IsPursuitStillRunning(Pursuit))
                                        {
                                            break;
                                        }
                                    }
                                }

                                while (CalloutRunning)
                                {
                                    GameFiber.Yield();
                                    Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.EndCallKey) + " ~s~to end the callout.");
                                    if (Game.IsKeyDown(AssortedCalloutsHandler.EndCallKey))
                                    {
                                        Game.HideHelp();

                                        //foreach (Ped suspect in Suspects)
                                        //{
                                        //    EscapeCount++;
                                        //}
                                        msg = "Control,";
                                        if (ArrestCount > 0)
                                        {
                                            msg += " ~g~" + ArrestCount.ToString() + " suspects in custody.";
                                        }
                                        if (DeadCount > 0)
                                        {
                                            msg += " ~o~" + DeadCount.ToString() + " suspects dead.";
                                        }
                                        if (EscapeCount > 0)
                                        {
                                            msg += " ~r~" + EscapeCount.ToString() + " suspects escaped.";
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            while (CalloutRunning)
                            {
                                GameFiber.Yield();
                                if (!Functions.IsPursuitStillRunning(Pursuit))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Assorted Callouts handled the exception successfully.");
                        Game.DisplayNotification("~O~IllegalImmigrantsInTruck~s~ callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }
Example #3
0
        private void MainLogic()
        {
            CalloutRunning = true;
            GameFiber.StartNew(delegate
            {
                try
                {
                    DispatchResponse();
                    WaitForGetClose();
                    WaitForParkAndGetNearby();
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        PoliceCar.ShouldVehiclesYieldToThisVehicle = false;
                        if (Vector3.Distance(Game.LocalPlayer.Character.Position, PoliceOfficer.Position) < 4f)
                        {
                            Game.DisplayHelp("Press ~b~" + AssortedCalloutsHandler.kc.ConvertToString(AssortedCalloutsHandler.TalkKey) + " ~s~to talk.");
                            if (Albo1125.Common.CommonLibrary.ExtensionMethods.IsKeyDownComputerCheck(AssortedCalloutsHandler.TalkKey))
                            {
                                SpeechHandler.HandleSpeech("Officer", ArrestWarrantSpeeches[AssortedCalloutsHandler.rnd.Next(ArrestWarrantSpeeches.Count)]);
                                PoliceOfficer.Tasks.EnterVehicle(PoliceCar, 5000, -1);
                                break;
                            }
                        }
                    }
                    if (CalloutRunning)
                    {
                        if (Suspect.IsInAnyVehicle(false))
                        {
                            Suspect.Tasks.LeaveVehicle(LeaveVehicleFlags.None).WaitForCompletion(3000);
                        }
                    }
                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        Suspect.Tasks.FollowNavigationMeshToPosition(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeBack * 1.5f), Game.LocalPlayer.Character.Heading, 1.4f).WaitForCompletion(500);
                        if (Game.LocalPlayer.Character.LastVehicle.Exists())
                        {
                            if (Game.LocalPlayer.Character.LastVehicle.DistanceTo(Suspect) < 3f)
                            {
                                Suspect.Tasks.Clear();
                                Suspect.Tasks.EnterVehicle(Game.LocalPlayer.Character.LastVehicle, 6000, Game.LocalPlayer.Character.LastVehicle.PassengerCapacity - 1).WaitForCompletion(6100);
                            }
                        }
                        if (Suspect.IsInAnyVehicle(false))
                        {
                            break;
                        }
                    }
                    if (SuspectBlip.Exists())
                    {
                        SuspectBlip.Delete();
                    }
                    if (PoliceOfficerBlip.Exists())
                    {
                        PoliceOfficerBlip.Delete();
                    }

                    while (CalloutRunning)
                    {
                        GameFiber.Yield();
                        if (Suspect.Exists())
                        {
                            if (Functions.IsPedInPrison(Suspect))
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    DisplayCodeFourMessage();
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    End();
                }
                catch (Exception e)
                {
                    if (CalloutRunning)
                    {
                        Game.LogTrivial(e.ToString());
                        Game.LogTrivial("Assorted Callouts handled the exception successfully.");
                        Game.DisplayNotification("~O~Traffic Stop Backup~s~callout crashed, sorry. Please send me your log file.");
                        Game.DisplayNotification("Full LSPDFR crash prevented ~g~successfully.");
                        End();
                    }
                }
            });
        }