Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using LSPD_First_Response.Engine.Scripting;
- using LSPD_First_Response.Engine.Scripting.Entities;
- using LSPD_First_Response.Mod.Callouts;
- using LSPD_First_Response.Mod.API;
- using LSPD_First_Response.Engine;
- using Rage;
- using System.Diagnostics;
- using Rage.Attributes;
- using Rage.Native;
- using DarkmyreAPI;
- using System.Windows.Forms;
- using RoadIncidentCallouts;
- using RoadIncident_Callouts;
- using ComputerPlus;
- using System.Drawing;
- using System.IO;
- namespace RoadIncident_Callouts.Callouts
- {
- [CalloutInfo("Severe Vehicle Crash", CalloutProbability.High)]
- public class SevereVehicleCrash : Callout
- {
- public Blip PedBlip;
- public Blip SuspectBlip;
- public Blip Trooper1Blip;
- public Blip CopBlip;
- public Blip VehicleBlip;
- public Blip AmboBlip;
- public Vehicle AmboVehicle;
- public Vehicle CopVehicle;
- public Vector3 SpawnPoint;
- public Vector3 AmboPos;
- public Ped AmboPed;
- public Vector3 cone1pos;
- public Vector3 cone2pos;
- public Vector3 cone3pos;
- public Vector3 cone4pos;
- public Vector3 cone5pos;
- public Vehicle SuspectVehicle;
- public EConvostate state1;
- private Vector3 CalloutPositionTrooperCar1;
- private Vector3 CalloutPositionTrooperCar2;
- public Vehicle Victimvehicle;
- public Ped Victimped;
- public Ped CopPed;
- public Ped SuspectPed;
- public Ped Trooper1;
- public Vector3 Victim1pos;
- public Vector3 AmboPedPos;
- public Vector3 CopVehicleSpawn;
- public Vector3 Suspectvehiclepos;
- public Vector3 Suspectpos;
- public Vector3 sp;
- public Rage.Object cone1;
- public Rage.Object cone2;
- public Rage.Object cone3;
- public Rage.Object cone4;
- public Rage.Object cone5;
- public Vector3 CopPos;
- public Persona SuspectPedPersona, VictimPedPersona;
- private int dialog1WithCopIndex;
- private int dialog2WithVicIndex;
- private int dialog3WithSusIndex;
- private SpawnHelper CopPedPos1, VictimPedPos1, SuspectPedPos1, ParaPedPos1, CopVehiclePos1, VictimVehiclePos1, SuspectVehiclePos1, ParaVehiclePos1;
- private ECalloutState calloutState;
- private readonly EDialog dialog;
- private readonly List<SpawnHelper> CopPedPos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(666.14f, -1747.15f, 29.24f), 63.85f)
- };
- private readonly List<SpawnHelper> VictimPedPos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(677.62f, -1750.26f, 29.15f), 221.41f, "Innocence", "Boulevard")
- };
- private readonly List<SpawnHelper> SuspectPedPos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(669.05f, -1751.20f, 29.30f), 333.41f)
- };
- private readonly List<SpawnHelper> ParaPedPos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(685.11f, -1748.25f, 29.28f), 266.08f)
- };
- private readonly List<SpawnHelper> CopVehiclePos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(664.74f, -1748.62f, 28.66f), 266.46f)
- };
- private readonly List<SpawnHelper> VictimVehiclePos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(672.27f, -1748.53f, 28.79f), 250.05f)
- };
- private readonly List<SpawnHelper> SuspectVehiclePos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(676.95f, -1749.16f, 28.85f), 305.59f)
- };
- private readonly List<SpawnHelper> ParaVehiclePos1List = new List<SpawnHelper>
- {
- new SpawnHelper(new Vector3(684.16f, -1750.06f, 28.91f), 264.52f)
- };
- private readonly List<string> dialog1WithCop = new List<string>
- {
- "~b~You:~s~ Hello Officer, what seems to be the problem today? (1/3)",
- "~b~Officer:~s~ Well what I saw was the picador get rammed, almost pitted by the fugitive. They stopped, got out and started spewing shit at each other, be careful with the ~r~suspect~s~, he's quite hostile. (2/3)",
- "~b~You:~s~ Thanks officer, I'll deal with the victim first, and then the suspect. (3/3)",
- };
- private readonly List<string> dialog2WithVic = new List<string>
- {
- "~b~You:~s~ Hello sir, can you tell me what happened. (1/5)",
- "~g~Victim:~s~ Hi there, so what I remember is that I was heading to my friends place for a beer and shit, and BOOM! out of no where, this fugitive hits me and continues to ram my side like he pitted me. (2/5)",
- "~b~You:~s~ Okay thank you sir, are you injured in any way? (3/5)",
- "~g~Victim~s~ No sir, the ambo over there checked me and him out, I'm fine but the fuckhead over there has a sprained wrist. (4/5)",
- "~b~You:~s~ Okay sir, can you please wait here while I have a chat with the ~r~suspect~s~. (5/5)",
- };
- private readonly List<string> dialog3WithSus = new List<string>
- {
- "~b~You:~s~ hello sir, can I talk to you about the accident please? (1/2)",
- "~r~Suspect:~s~ Fuck off you dumbass pig, I'm not saying one fucking word to you, he cut me off so I had all right to hit him, now fuck off and leave me alone! (2/2)",
- };
- private static readonly string SuspectName = "SuspectName";
- private string _SuspectName;
- private readonly List<Entity> SpawnedEntities = new List<Entity>();
- private readonly List<Blip> SpawnedBlips = new List<Blip>();
- private bool computerPlusRunning;
- private Guid callID;
- public override bool OnBeforeCalloutDisplayed()
- {
- computerPlusRunning = Utils.IsLSPDFRPluginRunning("ComputerPlus", new Version("1.3.0.0"));
- CopPedPos1 = Utils.getNearestSpawnHelper(Utils.Player.Position, CopPedPos1List);
- ParaPedPos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, ParaPedPos1List);
- VictimPedPos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, VictimPedPos1List);
- SuspectPedPos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, SuspectPedPos1List);
- CopVehiclePos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, CopVehiclePos1List);
- ParaVehiclePos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, ParaVehiclePos1List);
- VictimVehiclePos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, VictimVehiclePos1List);
- SuspectVehiclePos1 = Utils.getNearestSpawnHelper(CopPedPos1.location, SuspectVehiclePos1List);
- cone1pos = new Vector3(667.31f, -1745.94f, 28.03f);
- cone2pos = new Vector3(670.84f, -1744.64f, 28.33f);
- cone3pos = new Vector3(674.98f, -1745.02f, 28.33f);
- cone4pos = new Vector3(679.13f, -1745.47f, 28.34f);
- cone5pos = new Vector3(681.52f, -1747.75f, 28.28f);
- CalloutMessage = "Severe Vehicle Crash";
- CalloutPosition = VictimPedPos1.location;
- Functions.PlayScannerAudioUsingPosition($"WE_HAVE MVA_01 NEAR_UHM {RoadIncidentCallouts.WorldZone.GetAudioForZoneAtPosition(VictimPedPos1.location)} RESPOND_CODE_2", VictimPedPos1.location);
- ShowCalloutAreaBlipBeforeAccepting(VictimPedPos1.location, 50f);
- //AddMinimumDistanceCheck(50f, VicPos.location);
- if (computerPlusRunning)
- callID = ComputerPlusWrapper.CreateCallout("Motor Vehicle Accident", "Motor Vehicle Accident",
- VictimPedPos1.location, (int)EResponseType.Code_2,
- $"An Officer near ~y~{VictimPedPos1.area}~w~, ~y~{VictimPedPos1.street}~w~ reports a very severe vehicle crash and requires assistance.");
- return base.OnBeforeCalloutDisplayed();
- }
- public override bool OnCalloutAccepted()
- {
- cone5 = new Rage.Object("prop_mp_cone_01", cone5pos, 264.24f);
- cone4 = new Rage.Object("prop_mp_cone_01", cone4pos, 264.24f);
- cone3 = new Rage.Object("prop_mp_cone_01", cone3pos, 264.24f);
- cone2 = new Rage.Object("prop_mp_cone_01", cone2pos, 264.24f);
- cone1 = new Rage.Object("prop_mp_cone_01", cone1pos, 264.24f);
- Game.DisplaySubtitle($"Go to the ~o~Scene~w~ of the ~o~accident~w~ near ~y~{VictimPedPos1.area}~w~, ~y~{VictimPedPos1.street}~w~ and speak with the ~b~Officer", 6500);
- Game.DisplayHelp($"Press ~b~X~w~ to end the callout", 5000);
- Game.DisplayNotification($"~b~Dispatch~w~: An Officer near {VictimPedPos1.area}, {VictimPedPos1.street} reports a very severe vehicle crash and requires assistance.");
- CopPed = CopPedPrep(CopPedPos1.location, CopPedPos1.heading);
- AmboPed = ParaPedPrep(ParaPedPos1.location, ParaPedPos1.heading);
- Victimped = VictimPrep(VictimPedPos1.location, VictimPedPos1.heading);
- SuspectPed = SuspectPedPrep(SuspectPedPos1.location, SuspectPedPos1.heading);
- CopVehicle = CopVehiclePrep(CopVehiclePos1.location, CopVehiclePos1.heading);
- AmboVehicle = ParaVehiclePrep(ParaVehiclePos1.location, ParaVehiclePos1.heading);
- Victimvehicle = VictimVehiclePrep(VictimVehiclePos1.location, VictimVehiclePos1.heading);
- SuspectVehicle = SuspectVehiclePrep(SuspectVehiclePos1.location, SuspectVehiclePos1.heading);
- CopBlip = CopPed.AttachBlip();
- CopBlip.EnableRoute(Color.Blue);
- CopBlip.Scale = 0.8f;
- CopBlip.Name = "Officer";
- SpawnedBlips.Add(CopBlip);
- Trooper1Blip = Victimped.AttachBlip();
- Trooper1Blip.Color = Color.Green;
- Trooper1Blip.Scale = 0.6f;
- Trooper1Blip.Name = "Victim";
- SpawnedBlips.Add(Trooper1Blip);
- SuspectBlip = SuspectPed.AttachBlip();
- SuspectBlip.Color = Color.Red;
- SuspectBlip.Scale = 0.6f;
- SuspectBlip.Name = "Suspect";
- SpawnedBlips.Add(SuspectBlip);
- Victimvehicle.Damage(11f, 1000f);
- SuspectVehicle.Damage(5f, 2500f);
- VictimPedPersona = Functions.GetPersonaForPed(Victimped);
- SuspectPedPersona = Functions.GetPersonaForPed(SuspectPed);
- _SuspectName = SuspectPedPersona.FullName;
- return base.OnCalloutAccepted();
- }
- public override void OnCalloutNotAccepted()
- {
- if (Victimped.Exists()) Victimped.Delete();
- if (Victimvehicle.Exists()) Victimvehicle.Delete();
- if (SuspectBlip.Exists()) SuspectBlip.Delete();
- if (SuspectVehicle.Exists()) SuspectVehicle.Delete();
- if (SuspectPed.Exists()) SuspectPed.Delete();
- if (CopBlip.Exists()) CopBlip.Delete();
- if (PedBlip.Exists()) PedBlip.Delete();
- if (VehicleBlip.Exists()) VehicleBlip.Delete();
- base.OnCalloutNotAccepted();
- }
- public override void Process()
- {
- if (Game.IsKeyDown(Settings.EndCalloutKey))
- {
- try
- {
- const string audioFileName = "CODE_4_RETURN_TO_PATROL.wav";
- "Pressed EndCalloutKey".AddLog();
- Game.DisplayNotification($"~b~{Settings.OfficerName}~w~: Dispatch, I have cleared the last call, show me code 4.");
- if (File.Exists($"lspdfr/Police Scanner/RoadIncidentCallouts_Audio/{audioFileName}"))
- Functions.PlayScannerAudio(audioFileName);
- else $"Failed to locate file '{audioFileName}.wav', verify installation".AddLog();
- End();
- }
- catch (Exception ex)
- {
- $"Error occured trying to end the callout, error is: {ex}".AddLog();
- }
- }
- FinalizeDialog();
- HandleCallout();
- base.Process();
- }
- public override void End()
- {
- if (Victimvehicle)
- if (Victimvehicle.IsAlarmSounding)
- Victimvehicle.AlarmTimeLeft = new TimeSpan(0, 0, 0);
- if (SpawnedBlips.Count > 0)
- {
- foreach (var VARIABLE in SpawnedBlips)
- {
- if (VARIABLE)
- {
- VARIABLE.Delete();
- }
- }
- }
- if (SpawnedEntities.Count > 0)
- {
- foreach (var VARIABLE in SpawnedEntities)
- {
- if (VARIABLE)
- {
- VARIABLE.Dismiss();
- }
- }
- }
- if (computerPlusRunning)
- ComputerPlusWrapper.ConcludeCallout(callID);
- base.End();
- }
- private void HandleCallout()
- {
- if (CopPed)
- {
- if (CopPed.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(CopPed) <= 3.5f)
- {
- VehicleBlip.DisableRoute();
- calloutState = ECalloutState.SpeakWithCopPed;
- }
- }
- }
- if (CopPed)
- {
- if (CopPed.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(CopPed) <= 2.5f)
- {
- if (Game.IsKeyDown(Keys.T))
- {
- if (dialog == EDialog.Dialog1)
- {
- if (dialog1WithCopIndex < dialog1WithCop.Count)
- {
- Game.DisplaySubtitle(dialog1WithCop[dialog1WithCopIndex]);
- dialog1WithCopIndex++;
- }
- }
- if (dialog1WithCopIndex == 3 || dialog2WithVicIndex == 5)
- {
- GameFiber.StartNew(delegate
- {
- GameFiber.Sleep(3000);
- CopPed.Tasks.Clear();
- Game.DisplayNotification("Speak with the ~g~Victim");
- calloutState = ECalloutState.SpokeWithCopPed;
- });
- }
- }
- }
- }
- }
- calloutState = ECalloutState.SpokeWithCopPed;
- if (Victimped)
- {
- if (Victimped.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(Victimped) <= 2.5f)
- {
- Victimped.PlayAmbientSpeech("GENERIC_HI");
- calloutState = ECalloutState.SpeakWithVicPed;
- }
- }
- }
- calloutState = ECalloutState.SpeakWithVicPed;
- if (Victimped)
- {
- if (Victimped.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(Victimped) <= 2.5f)
- {
- if (Game.IsKeyDown(Keys.T))
- {
- if (dialog == EDialog.Dialog1)
- {
- if (dialog2WithVicIndex < dialog2WithVic.Count)
- {
- Game.DisplaySubtitle(dialog2WithVic[dialog2WithVicIndex]);
- dialog2WithVicIndex++;
- }
- }
- if (dialog2WithVicIndex == 5 || dialog3WithSusIndex == 2)
- {
- GameFiber.StartNew(delegate
- {
- GameFiber.Sleep(3500);
- Victimped.Tasks.Clear();
- Game.DisplayNotification("Speak to the ~r~Suspect");
- calloutState = ECalloutState.SpokeWithVicPed;
- });
- }
- }
- }
- }
- }
- calloutState = ECalloutState.SpokeWithVicPed;
- if (SuspectPed)
- {
- if (SuspectPed.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(SuspectPed) <= 2.5f)
- {
- calloutState = ECalloutState.SpeakWithSuspectPed;
- }
- }
- }
- calloutState = ECalloutState.SpeakWithSuspectPed;
- if (SuspectPed)
- {
- if (SuspectPed.IsAlive)
- {
- if (Game.LocalPlayer.Character.Position.DistanceTo2D(SuspectPed) <= 2.5f)
- {
- if (Game.IsKeyDown(Keys.T))
- {
- if (dialog == EDialog.Dialog1)
- {
- if (dialog3WithSusIndex < dialog3WithSus.Count)
- {
- Game.DisplaySubtitle(dialog3WithSus[dialog3WithSusIndex]);
- dialog3WithSusIndex++;
- }
- }
- if (dialog3WithSusIndex == 2)
- {
- GameFiber.Sleep(6500);
- Game.DisplayNotification("Arrest the ~r~suspect~s~, and get the vehicles towed");
- SuspectPed.Tasks.Clear();
- calloutState = ECalloutState.ArrestSuspect;
- }
- }
- }
- }
- }
- calloutState = ECalloutState.ArrestSuspect;
- if (Functions.IsPedArrested(SuspectPed))
- {
- End();
- }
- }
- private void FinalizeDialog()
- {
- dialog1WithCop[3] = dialog1WithCop[3].Replace(SuspectName, _SuspectName);
- dialog2WithVic[5] = dialog2WithVic[5].Replace(SuspectName, _SuspectName);
- }
- private enum EDialog
- {
- Dialog1
- }
- private enum ECalloutState
- {
- SpeakWithCop,
- SpokeWithCop,
- SpeakWithSuspect,
- ArrestSuspect,
- SpeakWithSuspectPed,
- SpokeWithVicPed,
- SpeakWithVicPed,
- SpokeWithCopPed,
- SpeakWithCopPed
- }
- private Ped CopPedPrep(Vector3 position, float heading)
- {
- var ped = new Ped(Utils.GetPolicePedModelForPosition(position), position, heading)
- {
- IsPersistent = true,
- BlockPermanentEvents = true
- };
- return ped;
- }
- private Ped ParaPedPrep(Vector3 position, float heading)
- {
- var ped = new Ped("s_m_m_paramedic_01", position, heading)
- {
- IsPersistent = true,
- BlockPermanentEvents = true
- };
- return ped;
- }
- private Ped VictimPrep(Vector3 position, float heading)
- {
- string[] models = { "a_f_o_soucent_02", "a_m_m_bevhills_02", "a_m_m_eastsa_02", "a_m_m_malibu_01", "a_f_m_tourist_01", "a_m_m_socenlat_01", "a_m_m_skidrow_01", "a_f_y_hipster_04", "a_m_m_stlat_02", "a_m_m_tourist_01" };
- var ped = new Ped(MathHelper.Choose(models), position, heading);
- ped.IsPersistent = true;
- ped.BlockPermanentEvents = true;
- return ped;
- }
- private Ped SuspectPedPrep(Vector3 position, float heading)
- {
- string[] models = { "a_m_o_soucent_02", "a_m_y_beachvesp_01", "a_m_y_beachvesp_02", "a_m_y_bevhills_02", "a_m_y_bevhills_01", "a_m_y_downtown_01", "a_m_y_eastsa_02", "a_m_y_genstreet_02", "a_m_y_latino_01" };
- var ped = new Ped(MathHelper.Choose(models), position, heading)
- {
- IsPersistent = true,
- BlockPermanentEvents = true
- };
- return ped;
- }
- private Vehicle CopVehiclePrep(Vector3 position, float heading)
- {
- var vehicle = new Vehicle(Utils.GetPoliceVehicleModelForPosition(position), position, heading)
- {
- IsPersistent = true
- };
- vehicle.RandomizeLicensePlate();
- vehicle.IsSirenOn = true;
- vehicle.IsSirenSilent = true;
- return vehicle;
- }
- private Vehicle ParaVehiclePrep(Vector3 position, float heading)
- {
- var vehicle = new Vehicle("ambulance", position, heading)
- {
- IsPersistent = true
- };
- vehicle.RandomizeLicensePlate();
- vehicle.IsSirenOn = true;
- vehicle.IsSirenSilent = true;
- return vehicle;
- }
- private Vehicle VictimVehiclePrep(Vector3 position, float heading)
- {
- string[] models = { "asterope", "banshee", "bjxl", "blista", "buccaneer", "bullet", "cogcabrio", "dilettante", "emperor2", "felon" };
- var vehicle = new Vehicle(MathHelper.Choose(models), position, heading)
- {
- IsPersistent = true
- };
- vehicle.RandomizeLicensePlate();
- vehicle.AlarmTimeLeft = new TimeSpan(0, 5, 0);
- return vehicle;
- }
- private Vehicle SuspectVehiclePrep(Vector3 position, float heading)
- {
- string[] models = { "adder", "asea", "baller", "bison", "bobcatxl", "carbonizzare", "cavalcade", "elegy2", "f620", "fq2" };
- var vehicle = new Vehicle(MathHelper.Choose(models), position, heading)
- {
- IsPersistent = true
- };
- vehicle.RandomizeLicensePlate();
- return vehicle;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement