From 9f8587f810c550b124fc3b3f69517b50fc66ccd6 Mon Sep 17 00:00:00 2001 From: Supopur Date: Wed, 7 Jun 2023 20:43:51 +0200 Subject: [PATCH] Made a new class for storing house stuff like the suspects, victims etc.. --- Callouts/DomesticViolence.cs | 141 +++++++++++++++++++++++++++++++---- Callouts/Test.cs | 79 -------------------- Code Blue Calls.csproj | 8 +- Main.cs | 7 +- 4 files changed, 138 insertions(+), 97 deletions(-) delete mode 100644 Callouts/Test.cs diff --git a/Callouts/DomesticViolence.cs b/Callouts/DomesticViolence.cs index 6c23a1a..0663640 100644 --- a/Callouts/DomesticViolence.cs +++ b/Callouts/DomesticViolence.cs @@ -3,31 +3,146 @@ using System.Linq; using Rage; using LSPD_First_Response.Mod.API; using LSPD_First_Response.Mod.Callouts; +using CalloutInterfaceAPI; +using System.Collections.Generic; +using DialogueSystem; +using CalloutInterface; +using LSPD_First_Response.Engine; namespace Code_Blue_Calls.Callouts { - [CalloutInfo("Domestic Violence", CalloutProbability.High)] + + [CalloutInterface("Domestic Violence", CalloutProbability.Medium, "Code 3", "LSPD")] public class DomesticViolence : Callout { private Ped victim, suspect; - private Blip blip_suspect; - private Blip blip_victim; - private Vector3 location_suspect; - private Vector3 location_victim; - private bool Victimfleeing; - private bool SuspectKillingPlayer; - private bool ShotAtVictim; + private Blip blip_suspect, blip_victim; + private Vector3 location_suspect, location_victim; + + private Vector3 GetClosestHouse(List houses) + { + Vector3 playerPosition = Game.LocalPlayer.Character.Position; + Vector3 closestHouse = Vector3.Zero; + float closestDistance = float.MaxValue; + + foreach (Vector3 house in houses) + { + float distance = Vector3.Distance(playerPosition, house); + if (distance < closestDistance) + { + closestHouse = house; + closestDistance = distance; + } + } + return closestHouse; + } + // I don't know what im doing + private class House + { + public Vector3 Position; + public List Victims { get; set; } + public List Suspects { get; set; } + public string Name; + } public override bool OnBeforeCalloutDisplayed() { - location_suspect = new Vector3(-111.19f, -8.28f, 70.52f); - location_victim = new Vector3(-111.19f, -11f, 70.52f); + // This is stupid and will get replaced with a list containing a list with the suspect and the victim and its gonna be per house + List location_suspect = new List { + new Vector3() + }; + + - ShowCalloutAreaBlipBeforeAccepting(location_suspect, 30f); + //This is a list of all the houses/interiors + //This is used for getting the closest house to the player so its not random and he/she doesn't have to go to the other side of the map + + List houses = new List + { + new Vector3(1276.979f, -1725.641f, 54.65f), //Lester's place + new Vector3(249.1075f, -1720.578f, 29.16469f), //Generic house + new Vector3(-775.9423f, 291.741f, 85.38015f), //West eclips towers + new Vector3(-131.3567f, -32.02588f, 57.84212f), //Janitors house + new Vector3(-66.24619f, -574.7697f, 36.95814f), //4 integrity way (players apt.) + new Vector3(-13.93472f, -1455.081f, 30.4537f), //Franklin + new Vector3(-616.9177f, 22.83247f, 41.47743f), //Strangeways + new Vector3(-178.65f, 507.2562f, 136.0046f), //Wild oats + new Vector3(-553.8226f, 666.5585f, 144.6216f), //Normandy + new Vector3(1122.733f, 2647.359f, 37.99636f), //Vespuci aka sandy motel + }; + + List houses1 = new List + { + new House + { + Name = "Lesterhouse", + Victims = new List + { + new Vector3(1273.748f, -1709.831f, 54.77149f) + }, + Suspects = new List + { + new Vector3(1274.567f, -1713.383f, 54.77149f) + }, + Position = new Vector3(1276.979f, -1725.641f, 54.65f) + }, + new House + { + Name = "Generic House", + Victims = new List + { + new Vector3(264.6913f, -997.2188f, -99.00867f) + }, + Suspects = new List + { + new Vector3(261.1124f, -998.8026f, -99.00865f) + }, + Position = new Vector3(249.1075f, -1720.578f, 29.16469f) + }, + new House + { + Name = "Frankiln house old", + Victims = new List + { + new Vector3(-11.18673f, -1429.365f, 31.10147f) + }, + Suspects = new List + { + new Vector3(-10.82392f, -1438.442f, 31.10153f) + }, + Position = new Vector3(-13.93472f, -1455.081f, 30.4537f) + }, + new House + { + Name = "Med rich apt.", + + + } + }; + + // Choose the closest house to the player. This isn't really optimal as if the player isn't patrolling and doing radar or some other thing wich involves being in one place + // Then the player will get the same house again and again + Vector3 SpawnPoint = GetClosestHouse(houses); + + + + + + + // Not needed as My code isn't goofy and doesn't set the callout position to the other side of the map + //AddMaximumDistanceCheck(600f, SpawnPoint); //Player must be 600m or closer + + + ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 30f); CalloutMessage = "Domestic Violence"; - CalloutPosition = location_suspect; - Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESISTING_ARREST_02 IN_OR_ON_POSITION", location_suspect); + CalloutPosition = SpawnPoint; + LSPD_First_Response.Mod.API.Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESISTING_ARREST_02 IN_OR_ON_POSITION", SpawnPoint); + + + + + return base.OnBeforeCalloutDisplayed(); } diff --git a/Callouts/Test.cs b/Callouts/Test.cs deleted file mode 100644 index 3ae1907..0000000 --- a/Callouts/Test.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Rage; -using LSPD_First_Response.Mod.API; -using LSPD_First_Response.Mod.Callouts; -using System.Drawing; - -namespace Code_Blue_Calls.Callouts -{ - [CalloutInfo("Test", CalloutProbability.High)] - public class Test : Callout - { - private Ped suspect; - private Vehicle vehicle; - private Blip blip; - private LHandle Pursuit; - private Vector3 spawn; - private bool created; - public override bool OnBeforeCalloutDisplayed() - { - spawn = World.GetRandomPositionOnStreet(); - ShowCalloutAreaBlipBeforeAccepting(spawn, 30f); - //AddMaximumDistanceCheck(40, spawn); - CalloutMessage = "Test"; - CalloutPosition = spawn; - Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_RESISTING_ARREST_02 IN_OR_ON_POSITION", spawn); - return base.OnBeforeCalloutDisplayed(); - } - - public override bool OnCalloutAccepted() - { - vehicle = new Vehicle("BLISTA", spawn); - vehicle.IsPersistent = true; - suspect = new Ped(vehicle.GetOffsetPositionFront(5f)); - suspect.IsPersistent = true; - suspect.BlockPermanentEvents = true; - suspect.WarpIntoVehicle(vehicle, -1); - - blip = suspect.AttachBlip(); - blip.Color = System.Drawing.Color.Yellow; - blip.IsRouteEnabled = true; - - created = false; - - return base.OnCalloutAccepted(); - } - - public override void Process() - { - base.Process(); - - if (!created && Game.LocalPlayer.Character.DistanceTo(vehicle) <= 20f) - { - Pursuit = Functions.CreatePursuit(); - Functions.AddPedToPursuit(Pursuit, suspect); - Functions.SetPursuitIsActiveForPlayer(Pursuit, true); - - created = true; - } - if (created && !Functions.IsPursuitStillRunning(Pursuit)) - { - End(); - } - - } - public override void End() - { - base.End(); - - if (suspect.Exists()) - { - suspect.Dismiss(); - } - } - } -} diff --git a/Code Blue Calls.csproj b/Code Blue Calls.csproj index 31dfa7b..72a80c4 100644 --- a/Code Blue Calls.csproj +++ b/Code Blue Calls.csproj @@ -56,6 +56,12 @@ ..\..\..\Documents\References\CalloutInterfaceAPI.dll + + ..\..\..\Documents\References\DialogueSystem.dll + + + ..\..\..\..\..\Program Files\Epic Games\GTAV\IPT.Common.dll + ..\..\..\Documents\References\LSPD First Response.dll @@ -82,7 +88,7 @@ - + diff --git a/Main.cs b/Main.cs index f262491..e38a924 100644 --- a/Main.cs +++ b/Main.cs @@ -34,14 +34,13 @@ namespace Code_Blue_Calls { if (OnDuty) { -<<<<<<< HEAD // If the player goes on duty, register the callouts RegisterCallouts(); // Display a notification to indicate that the callouts have been loaded -======= + RegisterCallouts(); ->>>>>>> parent of ccc531b (Added domestic violence calout) + Game.DisplayNotification("Code Blue Callouts loaded."); } } @@ -49,7 +48,7 @@ namespace Code_Blue_Calls // Register the callouts private static void RegisterCallouts() { - Functions.RegisterCallout(typeof(Callouts.Test)); + Functions.RegisterCallout(typeof(Callouts.DomesticViolence)); } // Event handler for resolving LSPDFR-related assemblies