/// <summary> /// Checks whether the world event can start at the position depending on available peds. /// </summary> /// <param name="position"> /// The position. /// </param> /// <returns> /// True if yes, otherwise false. /// </returns> public override bool CanStart(Vector3 position) { // Look for peds meeting our requirements. Note that it is also completely fine to just always return true here and create the peds yourself. // But since we don't want to stress the game too much I'm using this approach for all world events, so they can only occur if the game has // created ambient peds anyway. foreach (Ped ped in World.GetAllPeds()) { if (ped != null && ped.Exists()) { if (ped.Position.DistanceTo(position) < 30f) { LPed tempPed = LPed.FromGTAPed(ped); if (!Functions.DoesPedHaveAnOwner(tempPed) && !tempPed.IsPlayer && tempPed.IsAliveAndWell && !tempPed.IsOnStreet && !ped.isInVehicle()) { if (this.firstGuy == null) { this.firstGuy = tempPed; } else { this.secondGuy = tempPed; return(true); } } } } } return(false); }
public void Questioning() { pCar = LPlayer.LocalPlayer.Ped.IsInVehicle() ? LPlayer.LocalPlayer.Ped.CurrentVehicle : LPlayer.LocalPlayer.LastVehicle; //sCar = m.pulloverCar;//LVehicle.FromGTAVehicle(World.GetClosestVehicle(LPlayer.LocalPlayer.LastVehicle.GetOffsetPosition(new Vector3(0, pCar.Model.GetDimensions().Y / 2 + 4, 0)), 5f)); //sCar.AttachBlip(); suspect = LPlayer.LocalPlayer.LastVehicle.GetPedOnSeat(LPlayer.LocalPlayer.LastVehicle.IsSeatFree(VehicleSeat.LeftRear) ? VehicleSeat.RightRear : VehicleSeat.LeftRear); if (suspect.Exists()) // If the suspect does exist we can go ahead and question them { if (sCar != null && sCar.Exists()) // Check for the suspect's vehicle, if it doesn't exist then this isn't a traffic stop. { IsTrafficStop = true; Functions.PrintHelp("~KEY_DIALOG_1~ Conduct Breathtest~n~~KEY_DIALOG_2~ Seize Car~n~~KEY_DIALOG_3~ Release Ped~n~~KEY_DIALOG_4~ Cancel"); qTimer = new GTA.Timer(10); qTimer.Start(); qTimer.Tick += qTimer_Tick; } else { IsTrafficStop = false; Functions.PrintHelp("You can only question a suspect from a pullover at this time."); m.HasQuestioningFired = false; //Functions.PrintHelp("~KEY_DIALOG_1~ Option 2~n~~KEY_DIALOG_2~ Option 2~n~~KEY_DIALOG_3~ Release Ped~n~~KEY_DIALOG_4~ Cancel"); } } else { m.HasQuestioningFired = false; } }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); this.blip = Functions.CreateBlipForArea(this.spawnPosition, 20f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; this.vehicle1 = new LVehicle(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.vehicleModels)); if (this.vehicle1.Exists()) { // Ensure vehicle is freed on end Functions.AddToScriptDeletionList(this.vehicle1, this); this.vehicle1.PlaceOnNextStreetProperly(); this.vehicle1.AttachBlip(); this.vehicle1.EngineHealth = 50; driver = this.vehicle1.CreatePedOnSeat(VehicleSeat.Driver); Functions.SetPedIsOwnedByScript(driver, this, true); DelayedCaller.Call(delegate { driver.Task.CruiseWithVehicle(vehicle1, 20, true); }, this, 1000); DelayedCaller.Call(delegate { this.vehicle1.HazardLightsOn = true; this.vehicle1.EngineHealth = 0; }, this, 4000); Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); } return(true); }
//Fired when callout is accepted public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.blip = Functions.CreateBlipForArea(this.spawnPosition, 20f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; this.criminal = new LPed(this.spawnPosition.Around(5f), Common.GetRandomCollectionValue <string>(this.criminalModels)); if (this.criminal.Exists()) { this.criminal.CurrentRoom = Room.FromString(roomName); //criminal.Task.RunTo(this.spawnPosition); if (!Functions.DoesPedHaveAnOwner(this.criminal)) { Functions.SetPedIsOwnedByScript(this.criminal, this, true); } IsGunman = Common.GetRandomBool(0, 5, 1); HasPedBeenDesignated = false; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); return(true); } else { Functions.AddTextToTextwall("Disregard, situation code 4.", "CONTROL"); return(false);//this.End(); } }
public override bool OnCalloutAccepted() { target = new LPed(spawnPoint.Position, "M_Y_STREET_01", LPed.EPedGroup.Criminal); target.Weapons.AssaultRifle_M4.Ammo = 99999; target.Weapons.Select(Weapon.Rifle_M4); target.RelationshipGroup = RelationshipGroup.Criminal; target.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate); target.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate); target.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Hate); target.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); target.Task.FightAgainstHatedTargets(-1); Functions.SetPedIsOwnedByScript(target, this, true); Functions.AddToScriptDeletionList(target, this); Functions.AddTextToTextwall("Dispatch 4 units from " + Functions.GetAreaStringFromPosition(LPlayer.LocalPlayer.Ped.Position), Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); Functions.PlaySoundUsingPosition("ATTENTION_ALL_UNITS DFROM_DISPATCH_4_UNITS_FROM POSITION", this.spawnPoint.Position); Functions.RequestPoliceBackupAtPosition(spawnPoint.Position); Functions.RequestPoliceBackupAtPosition(spawnPoint.Position); Functions.RequestPoliceBackupAtPosition(spawnPoint.Position); Functions.RequestPoliceBackupAtPosition(spawnPoint.Position); Functions.PrintHelp("You may call NOOSE team if required."); return(base.OnCalloutAccepted()); }
//Delete peds if they leave script public override void PedLeftScript(LPed ped) { base.PedLeftScript(ped); Functions.RemoveFromDeletionList(ped, this); Functions.SetPedIsOwnedByScript(ped, this, false); }
public override bool CanStart(Vector3 position) { // Select the ped foreach (Ped ped in World.GetAllPeds()) { if (ped != null && ped.Exists()) { if (ped.Position.DistanceTo(position) < 30f) { LPed tempPed = LPed.FromGTAPed(ped); if (!Functions.DoesPedHaveAnOwner(tempPed) && !tempPed.IsPlayer && tempPed.IsAliveAndWell && !tempPed.IsOnStreet && !ped.isInVehicle()) { if (this.Guy == null) { this.Guy = tempPed; } else { this.Victim = tempPed; return(true); } } } } } return(false); }
/// <summary> /// Checks whether the world event can start at the position depending on available peds. /// </summary> /// <param name="position"> /// The position. /// </param> /// <returns> /// True if yes, otherwise false. /// </returns> public override bool CanStart(Vector3 position) { // Look for peds meeting our requirements. Note that it is also completely fine to just always return true here and create the peds yourself. // But since we don't want to stress the game too much I'm using this approach for all world events, so they can only occur if the game has // created ambient peds anyway. foreach (Ped ped in World.GetAllPeds()) { if (ped != null && ped.Exists()) { if (ped.Position.DistanceTo(position) < 30f) { LPed tempPed = LPed.FromGTAPed(ped); if (!Functions.DoesPedHaveAnOwner(tempPed) && !tempPed.IsPlayer && tempPed.IsAliveAndWell && !tempPed.IsOnStreet && !ped.isInVehicle()) { if (this.firstGuy == null) { this.firstGuy = tempPed; } else { this.secondGuy = tempPed; return true; } } } } } return false; }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 20f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; this.victim = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.MissionPed); if (victim.Exists()) { if (victim.EnsurePedIsNotInBuilding(victim.Position)) { Functions.AddToScriptDeletionList(victim, this); Functions.SetPedIsOwnedByScript(victim, this, true); Functions.AddPedToPursuit(this.pursuit, victim); //this.victim.Die(); this.victim.AttachBlip(); int random = Common.GetRandomValue(0, 100); if (random <= 14) { this.victim.Health = 10; //victim.FreezePosition = true; //victim.ForceRagdoll(-1, false); victim.Die(); victim.Task.AlwaysKeepTask = true; this.victim.HasBeenDamagedBy(Weapon.Melee_Knife); alive = true; } else { //this.victim.Health = 0; this.victim.HasBeenDamagedBy(Weapon.Melee_Knife); this.victim.Die(); alive = false; } } else { Log.Debug("OnCalloutAccepted: Failed to place ped properly outside of building", this); victim.Delete(); } } this.RegisterStateCallback(EPedState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EPedState.PlayerIsClose, this.PlayerIsClose); this.RegisterStateCallback(EPedState.PlayerOnScene, this.PlayerOnScene); this.RegisterStateCallback(EPedState.None, this.CalloutOver); this.State = EPedState.WaitingForPlayer; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); return(true); }
public override void PedLeftScript(LPed ped) { base.PedLeftScript(victim); // Free ped Functions.RemoveFromDeletionList(victim, this); Functions.SetPedIsOwnedByScript(victim, this, false); this.End(); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); copCar = new LVehicle(World.GetNextPositionOnStreet(spawnPosition), "POLICE"); officer = new LPed(spawnPosition.Around(2f), "M_Y_COP"); if (copCar != null && copCar.Exists()) { copCar.PlaceOnNextStreetProperly(); copCar.SirenActive = true; } suspect = new LPed(spawnPosition, Common.GetRandomCollectionValue <string>(criminalModels)); getawayCar = new LVehicle(World.GetNextPositionOnStreet(spawnPosition), Common.GetRandomCollectionValue <string>(vehicleModels)); if (getawayCar != null && getawayCar.Exists()) { getawayCar.PlaceOnNextStreetProperly(); if (suspect.Exists()) { suspect.WarpIntoVehicle(getawayCar, VehicleSeat.Driver); officer.Task.Die(); suspect.Task.CruiseWithVehicle(getawayCar, 15, true); blip = Functions.CreateBlipForArea(spawnPosition, 20f); blip.Display = BlipDisplay.ArrowAndMap; blip.RouteActive = true; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); RegisterStateCallback(EPedState.WaitingForPlayer, WaitingForPlayer); RegisterStateCallback(EPedState.PlayerOnScene, PlayerOnScene); RegisterStateCallback(EPedState.Over, CalloutOver); RegisterStateCallback(EPedState.PlayerSearching, PlayerSearching); State = EPedState.WaitingForPlayer; } else { Functions.AddTextToTextwall("Disregard previous, situation is code 4.", "CONTROL"); End(); } } else { Functions.AddTextToTextwall("Disregard previous, situation is code 4.", "CONTROL"); End(); } return(true); }
/// <summary> /// Called when a ped assigned to the current script has left the script due to a more important action, such as being arrested by the player. /// This is invoked right before control is granted to the new script, so perform all necessary freeing actions right here. /// </summary> /// <param name="ped">The ped</param> public override void PedLeftScript(LPed ped) { base.PedLeftScript(ped); if (ped == this.firstGuy) { this.firstGuy.Task.ClearAll(); } if (ped == this.secondGuy) { this.secondGuy.Task.ClearAll(); } }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); //create the vehicle and then check to make sure it exists, if so begin creating the criminal vehicle = new LVehicle(World.GetNextPositionOnStreet(spawnPosition), Common.GetRandomCollectionValue <string>(vehicleModels)); if (vehicle != null && vehicle.Exists()) { Functions.AddToScriptDeletionList(vehicle, this); vehicle.PlaceOnNextStreetProperly(); criminal = new LPed(World.GetNextPositionOnStreet(vehicle.Position), Common.GetRandomCollectionValue <string>(criminalModels)); if (criminal.Exists()) { //if criminal exists, warp into vehicle and begin driving criminal.WarpIntoVehicle(vehicle, VehicleSeat.Driver); criminal.Task.CruiseWithVehicle(vehicle, 20f, true); //add him to the deletion list and set him owned by the script Functions.AddToScriptDeletionList(criminal, this); if (!Functions.DoesPedHaveAnOwner(criminal)) { Functions.SetPedIsOwnedByScript(criminal, this, true); } blip = Functions.CreateBlipForArea(spawnPosition, 20f); blip.Display = BlipDisplay.ArrowAndMap; blip.RouteActive = true; //Functions.PrintText("Get to the reported location and find the stolen vehicle", 4000); Functions.AddTextToTextwall("Dispatch I'll head that up, enabling tracker now. Do we know the vehicle make?", LPlayer.LocalPlayer.Username); Functions.AddTextToTextwall("Details show the vehicle to be a " + vehicle.Name, "CONTROL"); timer = new GTA.Timer(1000); timer.Tick += timer_Tick; timer.Start(); } else { Functions.AddTextToTextwall("Disregard, situation is code 4", "CONTROL"); //end } } else { Functions.AddTextToTextwall("Disregard, situation is code 4", "CONTROL"); //end } return(true); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); this.suspect = new LPed(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.Criminal); this.suspect.BlockPermanentEvents = true; this.suspect.Task.AlwaysKeepTask = true; Functions.AddToScriptDeletionList(this.suspect, this); Functions.AddPedToPursuit(this.pursuit, this.suspect); if (!Functions.DoesPedHaveAnOwner(this.suspect)) { Functions.SetPedIsOwnedByScript(this.suspect, this, true); } if (this.calloutType == ECalloutType.FootChase) { Functions.SetPursuitCalledIn(this.pursuit, true); Functions.SetPursuitIsActiveForPlayer(this.pursuit, true); Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_ROBBERY_CATCH_UP"), 25000); this.suspect.WantedByPolice = true; LPed cop = new LPed(this.spawnPosition, "M_Y_COP"); Functions.AddToScriptDeletionList(cop, this); if (cop.Exists()) { cop.Task.AimAt(suspect, 4000); cop.Task.AlwaysKeepTask = true; } //Functions.RequestPoliceBackupAtPosition(this.suspect.Position); } else { Functions.SetPursuitCalledIn(this.pursuit, true); Functions.SetPursuitIsActiveForPlayer(this.pursuit, true); Functions.RequestPoliceBackupAtPosition(this.spawnPosition); this.suspect.DeleteBlip(); this.suspect.WantedByPolice = true; this.suspect.RangeToDetectEnemies = 10f; this.suspect.EquipWeapon(); } return(true); }
public override void PedLeftScript(LPed ped) { Log.Info("PedLeftScript received", "HotCallouts] [hMugging"); if (ped == this.guy) { this.guy.Task.ClearAll(); Functions.SetPedIsOwnedByScript(ped, this, false); } else { Log.Warning("A ped that should not be owned by Man With a Weapon World Event is reported LeftScript.", "HotCallouts"); Log.Warning("The mod will still try to make a left script, but the mod may crash.", "HotCallouts"); Functions.SetPedIsOwnedByScript(ped, this, false); } }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); car = new LVehicle(World.GetNextPositionOnStreet(spawnPoint.Position), "PSTOCKADE"); car.IsRequiredForMission = true; suspect = new LPed(spawnPoint.Position.Around(10f), "M_Y_GALB_LO_02"); passenger = new LPed(spawnPoint.Position.Around(11f), "M_Y_GALB_LO_02"); prisoner = new LPed(spawnPoint.Position.Around(11.5f), "M_Y_PRISON"); // To avoid NullReferenceException if (passenger == null || suspect == null || car == null) { Functions.AddTextToTextwall("The suspect has escaped.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); Functions.AddTextToTextwall("Notifying DOC.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); return(false); } if (!passenger.Exists() || !suspect.Exists() || !car.Exists()) { Functions.AddTextToTextwall("The real-time GPS has been disabled. Notifying DOC.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); return(false); } suspect.WarpIntoVehicle(car, VehicleSeat.Driver); passenger.WarpIntoVehicle(car, VehicleSeat.RightFront); prisoner.WarpIntoVehicle(car, VehicleSeat.RightRear); suspect.Task.CruiseWithVehicle(car.GVehicle, 30f, false); suspect.EquipWeapon(); passenger.EquipWeapon(); suspect.WillDoDrivebys = true; passenger.WillDoDrivebys = true; prisoner.CanResistArrest = false; prisoner.AlwaysSurrender = true; car.DisablePullover = true; Blip carBlip = car.AttachBlip(); carBlip.Icon = BlipIcon.Misc_Waypoint; carBlip.RouteActive = true; carBlip.Name = "Hijacked Transport Truck"; Functions.PrintHelp("When you sighted the truck, order the driver out of the truck. The prisoner will not resist."); return(true); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); driver = new LPed(spawnPoint.Position, "M_Y_STREET_01"); Vehicle temp = World.CreateVehicle(spawnPoint.Position.Around(5.0f)); car = LVehicle.FromGTAVehicle(temp); driver.IsRequiredForMission = true; car.IsRequiredForMission = true; try { // Fix NullReferenceException if (driver == null) { return(false); } if (driver.Exists() || car.Exists()) { driver.CanResistArrest = true; driver.Task.WarpIntoVehicle(car.GVehicle, VehicleSeat.Driver); driver.Task.CruiseWithVehicle(car.GVehicle, 20f, false); blip = driver.AttachBlip(); Functions.AddToScriptDeletionList(driver, this); Functions.SetPedIsOwnedByScript(driver, this, true); Functions.AddToScriptDeletionList(car, this); } else { return(false); } } catch (Exception ex) { Log.Error("Exception caught while callout is being accepted", "HotCallots] [DangerousDriver"); Log.Error(ex.GetType().Name + ": " + ex.Message + "\r\n" + ex.StackTrace, "HotCallots] [DangerousDriver"); return(false); } return(true); }
public override bool OnCalloutAccepted() { target = new LPed(spawnPoint.Position, "M_Y_STREET_01", LPed.EPedGroup.Criminal); // target.DefaultWeapon = Weapon.Shotgun_Basic; // This Line May Leads to a LCPDFR mod crash target.EquipWeapon(); target.RelationshipGroup = RelationshipGroup.Criminal; target.ChangeRelationship(RelationshipGroup.Civillian_Male, Relationship.Hate); target.ChangeRelationship(RelationshipGroup.Civillian_Female, Relationship.Hate); target.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Companion); target.ChangeRelationship(RelationshipGroup.Cop, Relationship.Neutral); target.Task.FightAgainstHatedTargets(-1); Functions.SetPedIsOwnedByScript(target, this, true); Functions.AddToScriptDeletionList(target, this); return(base.OnCalloutAccepted()); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); car = LVehicle.FromGTAVehicle(World.CreateVehicle(spawnPoint.Position.Around(10f))); car.IsRequiredForMission = true; suspect = new LPed(spawnPoint.Position.Around(10f), "M_Y_GALB_LO_02"); passenger = new LPed(spawnPoint.Position.Around(11f), "M_Y_GALB_LO_02"); // To avoid NullReferenceException if (passenger == null || suspect == null || car == null) { Functions.AddTextToTextwall("Unable to locate suspect through given location by caller.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); Functions.AddTextToTextwall("Looking out for alert calls.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); return(false); } if (!passenger.Exists() || !suspect.Exists() || !car.Exists()) { Functions.AddTextToTextwall("Caller only heard alarms, notifying nearby patrol officers.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); return(false); } suspect.WarpIntoVehicle(car, VehicleSeat.Driver); passenger.WarpIntoVehicle(car, VehicleSeat.RightFront); suspect.Task.CruiseWithVehicle(car.GVehicle, 30f, true); car.BurstTire(VehicleWheel.FrontLeft); car.Door(VehicleDoor.LeftFront).Break(); car.Door(VehicleDoor.RightFront).Break(); Blip carBlip = car.AttachBlip(); carBlip.Icon = BlipIcon.Misc_Waypoint; carBlip.RouteActive = true; carBlip.Name = "Stolen Vehicle"; return(true); }
/// <summary> /// Called when a ped assigned to the current script has left the script due to a more important action, such as being arrested by the player. /// This is invoked right before control is granted to the new script, so perform all necessary freeing actions right here. /// </summary> /// <param name="ped">The ped</param> public override void PedLeftScript(LPed ped) { base.PedLeftScript(ped); // Since they are law enforcers, they can only be left when died try { for (int i = 0; i <= SWATMembers.Length; i++) { if (ped == SWATMembers[i]) { SWATMembers[i].Task.ClearAll(); SWATMembers[i].NoLongerNeeded(); } //NooseVeh.NoLongerNeeded(); } } catch (Exception ex) { // Script continues to play even though the error is logged Log.Error("CRITICAL ERROR: Error accessing array list or trouble with peds in list: " + ex, this); } }
/// <summary> /// Called when a ped assigned to the current script has left the script due to a more important action, such as being arrested by the player. /// This is invoked right before control is granted to the new script, so perform all necessary freeing actions right here. /// </summary> /// <param name="ped">The ped</param> public override void PedLeftScript(LPed ped) { base.PedLeftScript(ped); // Free ped Functions.RemoveFromDeletionList(ped, this); Functions.SetPedIsOwnedByScript(ped, this, false); }
//Function for requesting a tow truck public void RequestTowTruck() { Functions.AddTextToTextwall("Can I get a removal truck at my location please", "OFFICER " + LPlayer.LocalPlayer.Username); towedCar = World.GetClosestVehicle(LPlayer.LocalPlayer.Ped.Position, 3f); if (towedCar != null && towedCar.Exists()) { if (CalloutsPlusMain.QuickSpawnMethod == true) // if quick spawn method is set to true, the vehicle will spawn much closer { truck = new LVehicle(LPlayer.LocalPlayer.Ped.Position.Around(Common.GetRandomValue(30, 60)), "PACKER"); } else { truck = new LVehicle(LPlayer.LocalPlayer.Ped.Position.Around(Common.GetRandomValue(100, 150)), "PACKER"); } if (truck != null && truck.Exists()) { truckDriver = new LPed(truck.Position.Around(2f), "m_y_mechanic_02"); } if (towedCar.Model.isBoat) { Functions.PrintText("[TOW TRUCK] We can't tow a boat!", 4000); truck.NoLongerNeeded(); truckDriver.NoLongerNeeded(); towTruckCalledOut = false; } else if (towedCar.Model.isHelicopter) { Functions.PrintText("[TOW TRUCK] We can't tow a helicopter!", 4000); truck.NoLongerNeeded(); truckDriver.NoLongerNeeded(); towTruckCalledOut = false; } else if (towedCar.Model.Hash == 2053223216 || towedCar.Model.Hash == 850991848 || towedCar.Model.Hash == 2307837162 || towedCar.Model.Hash == 3581397346 || towedCar.Model.Hash == 1938952078 || towedCar.Model.Hash == 1353720154 || towedCar.Model.Hash == 904750859 || towedCar.Model.Hash == 569305213) { Functions.PrintText( "[TOW TRUCK] We can't tow that, it's too big. Send an impound cop instead.", 4000); truck.NoLongerNeeded(); truckDriver.NoLongerNeeded(); towTruckCalledOut = false; } else { if (truck != null && truck.Exists()) { if (truckDriver != null && truckDriver.Exists()) { truck.PlaceOnNextStreetProperly(); if (World.GetClosestVehicle(truck.Position, 5f).Exists() && World.GetClosestVehicle(truck.Position, 5f) != truck) { truck.Heading = World.GetClosestVehicle(truck.Position, 5f).Heading; } truck.Extras(1).Enabled = false; truck.Extras(2).Enabled = false; truck.Extras(3).Enabled = false; truck.Extras(4).Enabled = false; truckDriver.WarpIntoVehicle(truck, VehicleSeat.Driver); truck.AttachBlip().Color = BlipColor.Yellow; DelayedCaller.Call(delegate { Functions.AddTextToTextwall("Affirmative, a removal truck has been dispatched", "CONTROL"); towTruckCanCancel = true; truckDriver.Task.DriveTo(LPlayer.LocalPlayer.Ped.Position, 20f, true, false); GTA.Native.Function.Call("ADD_STUCK_CAR_CHECK", new GTA.Native.Parameter[] { (Vehicle)truck, 2f, 12000 }); truckDriver.MakeProofTo(false, true, true, true, false); TTStatus = State.Responding; towTruckTimer = new GTA.Timer(1000); towTruckTimer.Tick += TowTruck_Tick; towTruckTimer.Start(); }, this, 100); } else { Functions.AddTextToTextwall("Negative we have no drivers available right now.", "CONTROL"); truck.Delete(); towTruckCalledOut = false; } } else { Functions.AddTextToTextwall("Negative at this time, we have no available trucks.", "CONTROL"); driver.Delete(); towTruckCalledOut = false; } } } else { Functions.PrintText("There is no vehicle here, tow truck will not be sent", 4000); towTruckCalledOut = false; } }
// Big regards to LtFlash for extension tricks (consider leaving him some cookies soon...) /// <summary> /// Checks if the specific object still exists in the world /// </summary> /// <param name="ped">GTA Ped</param> /// <returns>True if exist, otherwise false</returns> internal static bool isObjectValid(this LPed ped) { return(ped != null && ped.Exists()); }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { bool isReady = base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); // Add blip this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 30f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; // Decide whether prank call or not if (Common.GetRandomBool(0, 5, 1) && !isOfficerCalledIn) { Log.Debug("OnCalloutAccepted: Is prank", this); this.SetAsPrankCall(); } else { try { this.criminals = new List <LPed>(); // Create Niko with an RPG LPed criminal1 = new LPed(this.spawnPoint.Position, "IG_NIKO", LPed.EPedGroup.Criminal); criminal1.Weapons.RemoveAll(); criminal1.Weapons.RocketLauncher.Ammo = 100; criminal1.Weapons.DesertEagle.Ammo = 999; criminal1.Weapons.BaseballBat.Ammo = 1; criminal1.DefaultWeapon = Weapon.Heavy_RocketLauncher; criminal1.Weapons.RocketLauncher.Select(); criminal1.MaxHealth = 400; criminal1.Health = 400; criminal1.PersonaData = new PersonaData(new DateTime(1978, 6, 15), 10, "Niko", "Bellic", false, 8, true); criminal1.ComplianceChance = Common.GetRandomValue(0, 60); // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { criminal1.GPed }); // Create Little Jacob with an AK LPed criminal2 = new LPed(this.spawnPoint.Position, "IG_LILJACOB", LPed.EPedGroup.Criminal); criminal2.Weapons.RemoveAll(); criminal2.Weapons.AssaultRifle_AK47.Ammo = 999; criminal2.Weapons.Glock.Ammo = 999; criminal2.Weapons.Knife.Ammo = 1; criminal2.DefaultWeapon = Weapon.Rifle_AK47; criminal2.Weapons.AssaultRifle_AK47.Select(); criminal2.MaxHealth = 300; criminal2.Health = 300; criminal2.PersonaData = new PersonaData(new DateTime(1981, 4, 22), 4, "\"Little\" Jacob", "Hughes", true, 3, true); criminal2.ComplianceChance = Common.GetRandomValue(50, 100); // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { criminal2.GPed }); // Create Packie with a bolt-action sniper LPed criminal3 = new LPed(this.spawnPoint.Position, "IG_PACKIE_MC", LPed.EPedGroup.Criminal); criminal3.Weapons.RemoveAll(); criminal3.Weapons.SniperRifle_M40A1.Ammo = 999; criminal3.Weapons.Glock.Ammo = 999; criminal3.Weapons.Knife.Ammo = 1; //criminal3.DefaultWeapon = Weapon.Handgun_Glock; criminal3.DefaultWeapon = Weapon.SniperRifle_M40A1; criminal3.Weapons.SniperRifle_M40A1.Select(); criminal3.MaxHealth = 300; criminal3.Health = 300; criminal3.Armor = 50; criminal3.PersonaData = new PersonaData(new DateTime(1979, 8, 13), 10, "Patrick \"Packie\"", "McReary", true, 5, true); criminal3.ComplianceChance = Common.GetRandomValue(75, 100); // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { criminal3.GPed }); criminals.Add(criminal1); criminals.Add(criminal2); criminals.Add(criminal3); foreach (LPed criminal in criminals) { if (criminal.isObjectValid()) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); criminal.BecomeMissionCharacter(); criminal.RelationshipGroup = RelationshipGroup.Criminal; criminal.ChangeRelationship(RelationshipGroup.Criminal, Relationship.Companion); criminal.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.CantBeDamagedByRelationshipGroup(RelationshipGroup.Criminal, base.OnCalloutAccepted()); Functions.AddPedToPursuit(this.pursuit, criminal); // Place near any street if a criminal is in a building if (!criminal.EnsurePedIsNotInBuilding(criminal.Position)) { criminal.Position = World.GetNextPositionOnStreet(this.spawnPoint.Position).ToGround(); } } } // Start fighting immediately if the officers on the field are calling the callout in if (isOfficerCalledIn) { Vector3 temp1 = World.GetNextPositionOnPavement(this.spawnPoint.Position); Vector3 temp2 = (temp1 + new Vector3(0.3f, 0.3f, 0)).ToGround(); Vector3 temp3 = World.GetNextPositionOnStreet(this.spawnPoint.Position).Around((float)Common.GetRandomValue(5, 15)); Vector3 temp4 = (temp1 + new Vector3(0.9f, 0.9f, 0)).ToGround(); LPed[] cops = new LPed[] { new LPed(temp1, "M_M_FATCOP_01", LPed.EPedGroup.Cop), new LPed(temp2, "M_M_FATCOP_01", LPed.EPedGroup.Cop), new LPed(temp3, "M_M_FATCOP_01", LPed.EPedGroup.Cop), new LPed(temp4, "M_M_FATCOP_01", LPed.EPedGroup.Cop) }; foreach (LPed cop in cops) { Functions.AddToScriptDeletionList(cop, this); cop.Weapons.RemoveAll(); cop.Weapons.DesertEagle.Ammo = 999; cop.Weapons.BarettaShotgun.Ammo = 999; cop.DefaultWeapon = Weapon.Shotgun_Baretta; cop.Weapons.BarettaShotgun.Select(); Function.Call("SET_CHAR_RANDOM_COMPONENT_VARIATION", new Parameter[] { cop.GPed }); } // Create cop cars Vehicle copcar1 = World.CreateVehicle(new Model("POLICE"), World.GetNextPositionOnStreet(temp4).ToGround()); Vehicle copcar2 = World.CreateVehicle(new Model("POLICE"), copcar1.Position.Around(3.3f).ToGround()); // Don't place it REALLY close to the terrorists if ((copcar1.Position - criminal1.Position).Length() < 10f) { copcar1.Position = World.GetNextPositionOnStreet(copcar1.Position + new Vector3(13, 15, 0)).ToGround(); } if ((copcar2.Position - criminal1.Position).Length() < 10f) { copcar2.Position = World.GetNextPositionOnStreet(copcar2.Position.Around(4f) + new Vector3(13, 15, 0)).ToGround(); } // Release them as an ambient vehicle copcar1.NoLongerNeeded(); copcar2.NoLongerNeeded(); this.State = EShootoutState.Fighting; this.Engage(); // Request one backup unit automatically Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); Functions.PlaySoundUsingPosition("DFROM_DISPATCH_2_UNITS_FROM POSITION", LPlayer.LocalPlayer.Ped.Position); } isReady = true; } catch (Exception ex) { Log.Error("OnCalloutAccepted: Cannot create Pursuit instance: " + ex, this); isReady = false; } } // Add states if (isReady) { this.RegisterStateCallback(EShootoutState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EShootoutState.PlayerIsClose, this.PlayerIsClose); this.RegisterStateCallback(EShootoutState.InCombat, this.InCombat); this.RegisterStateCallback(EShootoutState.Fighting, this.InCombat); this.RegisterStateCallback(EShootoutState.Prank, this.Prank); this.State = EShootoutState.WaitingForPlayer; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); } return(isReady); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); this.vehicle1 = new LVehicle(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.vehicleModels)); if (vehicle1 != null && vehicle1.Exists()) { vehicle1.PlaceOnNextStreetProperly(); Vector3 dimensions = vehicle1.Model.GetDimensions(); float width = dimensions.X; float length = dimensions.Y; this.vehicle2 = new LVehicle(vehicle1.GetOffsetPosition(new Vector3(0, length / 2 + 8, 0)), Common.GetRandomCollectionValue <string>(this.vehicleModels)); if (vehicle2 != null && vehicle2.Exists()) { //vehicle2.PlaceOnNextStreetProperly(); DelayedCaller.Call(delegate { vehicle1.ApplyForceRelative(new Vector3(0, 60, 0)); DelayedCaller.Call(delegate { vehicle1.Speed = 0; vehicle2.Speed = 0; this.blip = Functions.CreateBlipForArea(vehicle1.Position, 20f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; vic1 = new LPed(vehicle1.Position.Around(2f), Common.GetRandomCollectionValue <string>(this.victimModels)); vic2 = new LPed(vehicle2.Position.Around(2f), Common.GetRandomCollectionValue <string>(this.victimModels)); vic1.WarpIntoVehicle(vehicle1, VehicleSeat.Driver); vic2.WarpIntoVehicle(vehicle2, VehicleSeat.Driver); vic1.Health = 50; vic2.Health = 20; vic1.LeaveVehicle(); vic2.LeaveVehicle(); DelayedCaller.Call(delegate { vic1.Task.FightAgainst(vic2); vic2.Task.FightAgainst(vic1); }, this, 1000); }, this, 500); }, this, 1000); Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); this.RegisterStateCallback(EPedState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EPedState.PlayerOnScene, this.PlayerOnScene); this.RegisterStateCallback(EPedState.None, this.CalloutOver); this.State = EPedState.WaitingForPlayer; } else { Functions.AddTextToTextwall("Disregard previous, situation is code 4", "CONTROL"); // vehicle 2 didn't spawn this.End(); } } else { Functions.AddTextToTextwall("Disregard previous, situation is code 4", "CONTROL"); // vehicle 1 didn't spawn this.End(); } return(true); }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); // Add blip this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 30f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; // Decide whether prank call or not if (Common.GetRandomBool(0, 5, 1)) { Log.Debug("OnCalloutAccepted: Is prank", this); this.SetAsPrankCall(); } else { this.criminals = new List <LPed>(); int random = Common.GetRandomValue(2, 10); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.MissionPed); if (criminal.Exists()) { // Ensure ped is not in a building if (criminal.EnsurePedIsNotInBuilding(criminal.Position)) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.DefaultWeapon = 0; Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } else { Log.Debug("OnCalloutAccepted: Failed to place ped properly outside of building", this); criminal.Delete(); } } } if (this.criminals.Count == 0) { return(false); } // Chance to spawn another bunch of suspects fighting each other if (Common.GetRandomBool(0, 2, 1)) { random = Common.GetRandomValue(2, 10); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.Criminal); if (criminal.Exists()) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.DefaultWeapon = 0; Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } } // Chance to start fighting immediately if (Common.GetRandomBool(0, 2, 1)) { this.State = EShootoutState.Fighting; this.Engage(); // Request one backup unit automatically Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); } } } // Add states this.RegisterStateCallback(EShootoutState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EShootoutState.PlayerIsClose, this.PlayerIsClose); this.RegisterStateCallback(EShootoutState.InCombat, this.InCombat); this.RegisterStateCallback(EShootoutState.Fighting, this.InCombat); this.RegisterStateCallback(EShootoutState.Prank, this.Prank); this.State = EShootoutState.WaitingForPlayer; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); return(true); }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { bool isReady = base.OnCalloutAccepted(); // Create pursuit instance this.pursuit = Functions.CreatePursuit(); // Create vehicle try { this.vehicle = new LVehicle(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.vehicleModels)); if (ValidityCheck.isObjectValid(this.vehicle)) { // Ensure vehicle is freed on end Functions.AddToScriptDeletionList(this.vehicle, this); this.vehicle.PlaceOnNextStreetProperly(); // Create Luis luis = vehicle.CreatePedOnSeat(VehicleSeat.Driver, new CModel(new Model("IG_LUIS")), RelationshipGroup.Criminal); luis.PersonaData = new PersonaData(new DateTime(1983, 8, 17, 0, 25, 0, DateTimeKind.Utc), 13, "Luis Fernando", "Lopez", true, 8, true); luis.Money = 500; // Make ignore all events luis.BlockPermanentEvents = true; luis.Task.AlwaysKeepTask = true; // Give specified weapons luis.Weapons.RemoveAll(); luis.Weapons.DesertEagle.Ammo = 999; luis.DefaultWeapon = Weapon.Handgun_DesertEagle; luis.Weapons.AssaultRifle_M4.Ammo = 300; luis.Weapons.AssaultRifle_M4.Select(); luis.ComplianceChance = Common.GetRandomValue(40, 80); // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { luis.GPed }); // Add to deletion list and to pursuit Functions.AddToScriptDeletionList(luis, this); Functions.AddPedToPursuit(this.pursuit, luis); } // Create FIB Squad LVehicle fibCar = new LVehicle(World.GetNextPositionOnStreet(this.vehicle.Position), "FBI"); LPed[] fibPersonnel = new LPed[4] { fibCar.CreatePedOnSeat(VehicleSeat.Driver, new CModel((UInt32)3295460374), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.RightFront, new CModel((UInt32)3295460374), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.LeftRear, new CModel((UInt32)3295460374), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.RightRear, new CModel((UInt32)3295460374), RelationshipGroup.Cop), }; if (ValidityCheck.isObjectValid(fibCar)) { Functions.AddToScriptDeletionList(fibCar, this); fibCar.PlaceOnNextStreetProperly(); fibCar.SirenActive = true; foreach (LPed fib in fibPersonnel) { if (fib.isObjectValid()) // derived from ValidityCheck - greetings to LtFlash { Functions.AddToScriptDeletionList(fib, this); fib.Weapons.RemoveAll(); fib.Weapons.FromType(Weapon.Handgun_Glock).Ammo = 999; fib.Weapons.FromType(Weapon.SMG_MP5).Ammo = 999; fib.Weapons.FromType(Weapon.Rifle_M4).Ammo = 999; fib.Weapons.Select(Weapon.Rifle_M4); fib.DefaultWeapon = Weapon.Rifle_M4; } } } // Since we want other cops to join, set as called in already and also active it for player Functions.SetPursuitCalledIn(this.pursuit, true); Functions.SetPursuitIsActiveForPlayer(this.pursuit, true); // Add a chance that the suspect forced to fight back Functions.SetPursuitForceSuspectsToFight(this.pursuit, Common.GetRandomBool(0, 2, 1)); // Show message to the player Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_ROBBERY_CATCH_UP"), 25000); isReady = true; } catch (Exception ex) { Log.Error("OnCalloutAccepted: Cannot create Pursuit instance: " + ex, this); isReady = false; } return(isReady); }
public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); // Create pursuit instance this.pursuit = Functions.CreatePursuit(); // Create this.vehicle = new LVehicle(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.vehicleModels)); if (this.vehicle.Exists()) { // Ensure vehicle is freed on end Functions.AddToScriptDeletionList(this.vehicle, this); this.vehicle.PlaceOnNextStreetProperly(); int peds = Common.GetRandomValue(1, 3); // Create suspects this.robbers = new LPed[peds]; for (int i = 0; i < this.robbers.Length; i++) { // Spawn ped this.robbers[i] = new LPed(World.GetNextPositionOnStreet(this.vehicle.Position), Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.Criminal); if (this.robbers[i].Exists()) { // If vehicle doesn't have a driver yet, warp robber as driver if (!this.vehicle.HasDriver) { this.robbers[i].WarpIntoVehicle(this.vehicle, VehicleSeat.Driver); } else { this.robbers[i].WarpIntoVehicle(this.vehicle, VehicleSeat.AnyPassengerSeat); } // Make ignore all events and give default weapon this.robbers[i].BlockPermanentEvents = true; this.robbers[i].Task.AlwaysKeepTask = true; if (this.calloutType == ECalloutType.StolenCruiser) { this.robbers[i].EquipWeapon(); } else { // When not a robbery, 1/6 chance of weapons allowed only bool allowWeapons = Common.GetRandomBool(0, 7, 1); Functions.SetPursuitAllowWeaponsForSuspects(this.pursuit, allowWeapons); } // Add to deletion list and to pursuit Functions.AddToScriptDeletionList(this.robbers[i], this); Functions.AddPedToPursuit(this.pursuit, this.robbers[i]); // Parity check, just to show how to normally use this API. No need if you just created the ped, // since no other script could own it already if (!Functions.DoesPedHaveAnOwner(this.robbers[i])) { // Bind ped to script so it can't be used by other scripts, such as random scenarios // Because we now own this script, we also have to define behavior what we want to do when another script // takes over control, e.g. when being arrested. That's why we implement PedLeftScript below Functions.SetPedIsOwnedByScript(this.robbers[i], this, true); } } } // Create Police LVehicle copCar = new LVehicle(World.GetNextPositionOnStreet(this.vehicle.Position), "POLICE"); if (copCar.Exists()) { Functions.AddToScriptDeletionList(copCar, this); copCar.PlaceOnNextStreetProperly(); LPed copDriver = copCar.CreatePedOnSeat(VehicleSeat.Driver); if (copDriver != null && copDriver.Exists()) { Functions.AddToScriptDeletionList(copDriver, this); copCar.SirenActive = true; copDriver.SayAmbientSpeech("PULL_OVER_WARNING"); } } // Since we want other cops to join, set as called in already and also active it for player Functions.SetPursuitCalledIn(this.pursuit, true); Functions.SetPursuitIsActiveForPlayer(this.pursuit, true); // Show message to the player Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_ROBBERY_CATCH_UP"), 25000); } return(true); }
/// <summary> /// Called every tick to process all plugin logic. /// </summary> public override void Process() { // If on duty and Z is down if (LPlayer.LocalPlayer.IsOnDuty && (Functions.IsKeyDown(Keys.Z) || (Functions.IsControllerInUse() && Functions.IsControllerKeyDown(GamepadButtonFlags.DPadRight)))) { DelayedCaller.Call( delegate { LPlayer.LocalPlayer.Ped.DrawTextAboveHead("Test", 500); }, this, 500); if (this.lcpdfrPed == null || this.lcpdfrPed.Exists() || this.lcpdfrPed.IsAliveAndWell) { // Create a ped this.lcpdfrPed = new LPed(LPlayer.LocalPlayer.Ped.Position, "F_Y_HOOKER_01"); this.lcpdfrPed.NoLongerNeeded(); this.lcpdfrPed.AttachBlip(); this.lcpdfrPed.ItemsCarried = LPed.EPedItem.Drugs; LPed.EPedItem item = this.lcpdfrPed.ItemsCarried; this.lcpdfrPed.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", false, 1337, true); } } // If our ped exists and has been arrested, kill it if (this.lcpdfrPed != null && this.lcpdfrPed.Exists()) { if (this.lcpdfrPed.HasBeenArrested && this.lcpdfrPed.IsAliveAndWell) { this.lcpdfrPed.Die(); } } if (Functions.IsKeyDown(Keys.B)) { if (Functions.IsPlayerPerformingPullover()) { LHandle pullover = Functions.GetCurrentPullover(); if (pullover != null) { LVehicle vehicle = Functions.GetPulloverVehicle(pullover); if (vehicle != null && vehicle.Exists()) { vehicle.AttachBlip().Color = BlipColor.Cyan; if (vehicle.HasDriver) { // Change name of driver to Sam T. LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver); if (driver != null && driver.Exists()) { // Modify name. driver.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", true, 0, false); string name = driver.PersonaData.FullName; Functions.PrintText("--- Pulling over: " + name + " ---", 10000); // Looking up the driver will make the vehicle explode. Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data) { if (data.FullName == name) { DelayedCaller.Call(delegate { if (vehicle.Exists()) { vehicle.Explode(); } }, this, Common.GetRandomValue(5000, 10000)); } }; } } } } } else { // Disable pullovers for vehicle in front. GTA.Vehicle vehicle = World.GetClosestVehicle(LPlayer.LocalPlayer.Ped.GetOffsetPosition(new Vector3(0, 10, 0)), 5f); if (vehicle != null && vehicle.Exists()) { LVehicle veh = LVehicle.FromGTAVehicle(vehicle); if (veh != null) { veh.DisablePullover = true; veh.AttachBlip(); } } } } // Kill all partners. if (Functions.IsKeyDown(Keys.N)) { LHandle partnerManger = Functions.GetCurrentPartner(); LPed[] peds = Functions.GetPartnerPeds(partnerManger); if (peds != null) { foreach (LPed partner in peds) { if (partner.Exists()) { partner.Die(); } } } } // Send RequestBackup message in network game. if (Functions.IsKeyDown(Keys.X)) { if (Networking.IsInSession && Networking.IsConnected) { if (Networking.IsHost) { Vector3 position = LPlayer.LocalPlayer.Ped.Position; // Tell client we need backup. DynamicData dynamicData = new DynamicData(Networking.GetServerInstance()); dynamicData.Write(position); Networking.GetServerInstance().Send("API_Example", ENetworkMessages.RequestBackup, dynamicData); } } } }
public override bool OnCalloutAccepted() { target = new LPed(spawnPoint.Position, "M_Y_GBIK_LO_01"); officer = new LPed(target.Position.Around(10.0f), "M_Y_COP"); switch (CallType) { case EFirearmAttackType.Attack: officer.EquipWeapon(); target.EquipWeapon(); officerBlip = officer.AttachBlip(); targetBlip = target.AttachBlip(); officerBlip.Friendly = true; targetBlip.Icon = BlipIcon.Misc_CopHeli; targetBlip.Scale = 0.5f; targetBlip.Color = BlipColor.Red; targetBlip.RouteActive = true; targetBlip.Name = "Suspect"; target.Task.FightAgainst(officer); officer.Task.FightAgainst(target); Functions.PrintText("Get to the ~y~crime scene~w~ ASAP!", 7000); Functions.AddTextToTextwall("Be advised, we have another unit responding.", Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); Functions.RequestPoliceBackupAtPosition(spawnPoint.Position); break; case EFirearmAttackType.TakingAim: officer.EquipWeapon(); target.EquipWeapon(); officerBlip = officer.AttachBlip(); targetBlip = target.AttachBlip(); officerBlip.Friendly = true; targetBlip.Icon = BlipIcon.Misc_CopHeli; targetBlip.Scale = 0.5f; targetBlip.Color = BlipColor.Red; targetBlip.RouteActive = true; targetBlip.Name = "Suspect"; officer.Task.AimAt(target.GPed, -1); target.Task.AimAt(officer.GPed, -1); Functions.PrintText("Get to the ~crime scene~w~.", 7000); break; case EFirearmAttackType.DrawGun: officer.EquipWeapon(); target.EquipWeapon(); officerBlip = officer.AttachBlip(); targetBlip = target.AttachBlip(); officerBlip.Friendly = true; targetBlip.Icon = BlipIcon.Misc_CopHeli; targetBlip.Scale = 0.5f; targetBlip.Color = BlipColor.Red; targetBlip.RouteActive = true; targetBlip.Name = "Suspect"; officer.Task.AimAt(target, -1); Functions.PrintText("Get to the ~crime scene~w~.", 7000); break; } Functions.AddToScriptDeletionList(target, this); Functions.SetPedIsOwnedByScript(target, this, true); Functions.AddToScriptDeletionList(target, this); Functions.SetPedIsOwnedByScript(target, this, true); return(base.OnCalloutAccepted()); }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); // Add blip this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 30f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; // Decide whether prank call or not if (Common.GetRandomBool(0, 5, 1)) { Log.Debug("OnCalloutAccepted: Is prank", this); this.SetAsPrankCall(); } else { this.criminals = new List<LPed>(); int random = Common.GetRandomValue(2, 10); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue<string>(this.criminalModels), LPed.EPedGroup.Criminal); if (criminal.Exists()) { // Ensure ped is not in a building if (criminal.EnsurePedIsNotInBuilding(criminal.Position)) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); criminal.RelationshipGroup = RelationshipGroup.Special; criminal.ChangeRelationship(RelationshipGroup.Special, Relationship.Companion); criminal.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Hate); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.EquipWeapon(); Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } else { Log.Debug("OnCalloutAccepted: Failed to place ped properly outside of building", this); criminal.Delete(); } } } if (this.criminals.Count == 0) { return false; } // Chance to spawn another bunch of suspects fighting each other if (Common.GetRandomBool(0, 2, 1)) { random = Common.GetRandomValue(2, 10); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue<string>(this.criminalModels), LPed.EPedGroup.Criminal); if (criminal.Exists()) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); criminal.RelationshipGroup = RelationshipGroup.Gang_Albanian; criminal.ChangeRelationship(RelationshipGroup.Gang_Albanian, Relationship.Companion); criminal.ChangeRelationship(RelationshipGroup.Special, Relationship.Hate); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.EquipWeapon(); Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } } // Chance to start fighting immediately if (Common.GetRandomBool(0, 2, 1)) { this.State = EShootoutState.Fighting; this.Engage(); // Request one backup unit automatically Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); } } } // Add states this.RegisterStateCallback(EShootoutState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EShootoutState.PlayerIsClose, this.PlayerIsClose); this.RegisterStateCallback(EShootoutState.InCombat, this.InCombat); this.RegisterStateCallback(EShootoutState.Fighting, this.InCombat); this.RegisterStateCallback(EShootoutState.Prank, this.Prank); this.State = EShootoutState.WaitingForPlayer; Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); return true; }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { bool isReady = base.OnCalloutAccepted(); bool isLuisCarryingDrugs = new Boolean(); // Create pursuit instance this.pursuit = Functions.CreatePursuit(); // Create vehicle try { this.vehicle = new LVehicle(World.GetNextPositionOnStreet(this.spawnPosition), Common.GetRandomCollectionValue <string>(this.vehicleModels)); /*try * { * if (vehicle.Model.ModelInfo.ModelFlags.HasFlag(EModelFlags.IsEmergencyServicesVehicle) || vehicle.Model.ModelInfo.ModelFlags.HasFlag(EModelFlags.IsCopCar)) vehicle.SirenActive = true; * } * catch (ArgumentException ex) * { * Log.Warning("Unknown model flag contained on model: " + vehicle.ToString() + ", treated it as a civilian vehicle", this); * Log.Warning(ex.ToString(), this); * }*/ if (this.vehicle.isObjectValid()) { // Ensure vehicle is freed on end Functions.AddToScriptDeletionList(this.vehicle, this); this.vehicle.PlaceOnNextStreetProperly(); // Create suspects this.criminals = new LPed[4] { vehicle.CreatePedOnSeat(VehicleSeat.Driver, new CModel(new Model("IG_LUIS2")), RelationshipGroup.Special), vehicle.CreatePedOnSeat(VehicleSeat.LeftRear, new CModel(new Model("IG_ARMANDO")), RelationshipGroup.Special), vehicle.CreatePedOnSeat(VehicleSeat.RightRear, new CModel(new Model("IG_HENRIQUE")), RelationshipGroup.Special), vehicle.CreatePedOnSeat(VehicleSeat.RightFront, CModel.GetRandomModel(EModelFlags.IsWealthUpperClass), RelationshipGroup.Criminal), }; // Allow suspects to use custom Persona Data specific to protagonist characters criminals[0].PersonaData = new PersonaData(new DateTime(1983, 8, 17, 0, 25, 0, DateTimeKind.Utc), 13, "Luis Fernando", "Lopez", true, 8, true); criminals[0].BecomeMissionCharacter(); if (Common.GetRandomBool(0, 3, 1)) { criminals[0].Money = 5000; criminals[0].ItemsCarried = LPed.EPedItem.Drugs; isLuisCarryingDrugs = true; } else { criminals[0].Money = 0; } criminals[1].PersonaData = new PersonaData(new DateTime(1981, 6, 20), 4, "Armando", "", true, 0, true); criminals[1].BecomeMissionCharacter(); criminals[2].PersonaData = new PersonaData(new DateTime(1982, 9, 29), 4, "Henrique", "", true, 3, true); criminals[2].BecomeMissionCharacter(); if (isLuisCarryingDrugs == false) { criminals[3].Money = 1000; if (Common.GetRandomBool(0, 3, 1)) { criminals[3].ItemsCarried = LPed.EPedItem.Drugs; } else { criminals[3].ItemsCarried = LPed.EPedItem.StolenCards; } } for (int i = 0; i < this.criminals.Length; i++) { // Make ignore all events this.criminals[i].WillDoDrivebys = true; this.criminals[i].Task.FightAgainstHatedTargets(criminals[i].RangeToDetectEnemies); this.criminals[i].BlockPermanentEvents = true; this.criminals[i].Task.AlwaysKeepTask = true; // Give specified weapons //criminals[i].ItemsCarried = LPed.EPedItem.Weapons; criminals[i].Weapons.RemoveAll(); criminals[i].Weapons.FromType(Weapon.Melee_Knife).Ammo = 999; criminals[i].Weapons.FromType(Weapon.TBOGT_Pistol44).Ammo = 9999; criminals[i].DefaultWeapon = Weapon.TBOGT_Pistol44; criminals[i].Weapons.FromType(Weapon.TBOGT_GoldenSMG).Ammo = 320; criminals[i].Weapons.FromType(Weapon.TBOGT_AdvancedMG).Ammo = 400; criminals[i].Weapons.Select(Weapon.TBOGT_AdvancedMG); criminals[i].ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); criminals[i].ChangeRelationship(RelationshipGroup.Special, Relationship.Companion); criminals[i].ChangeRelationship(RelationshipGroup.Criminal, Relationship.Companion); criminals[i].CantBeDamagedByRelationshipGroup(RelationshipGroup.Criminal, base.OnCalloutAccepted()); criminals[i].CantBeDamagedByRelationshipGroup(RelationshipGroup.Special, base.OnCalloutAccepted()); criminals[i].ComplianceChance = Common.GetRandomValue(0, 75); criminals[i].AlwaysDiesOnLowHealth = true; // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { criminals[i].GPed }); // Add to deletion list and to pursuit Functions.AddToScriptDeletionList(this.criminals[i], this); Functions.AddPedToPursuit(this.pursuit, this.criminals[i]); } } // Create FIB Squad (x2) LVehicle fibCar = new LVehicle(World.GetNextPositionOnStreet(this.vehicle.Position), "FBI"); LVehicle fibCar2 = new LVehicle(World.GetNextPositionOnStreet(fibCar.Position.Around((float)10)), "FBI"); LPed[] fibPersonnel = new LPed[4] { fibCar.CreatePedOnSeat(VehicleSeat.Driver, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.RightFront, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.LeftRear, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar.CreatePedOnSeat(VehicleSeat.RightRear, new CModel(fib_model_int), RelationshipGroup.Cop), }; LPed[] fibPersonnel2 = new LPed[4] { fibCar2.CreatePedOnSeat(VehicleSeat.Driver, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar2.CreatePedOnSeat(VehicleSeat.RightFront, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar2.CreatePedOnSeat(VehicleSeat.LeftRear, new CModel(fib_model_int), RelationshipGroup.Cop), fibCar2.CreatePedOnSeat(VehicleSeat.RightRear, new CModel(fib_model_int), RelationshipGroup.Cop), }; if (fibCar.isObjectValid() && fibCar2.isObjectValid()) { Functions.AddToScriptDeletionList(fibCar, this); Functions.AddToScriptDeletionList(fibCar2, this); fibCar.PlaceOnNextStreetProperly(); fibCar2.PlaceOnNextStreetProperly(); fibCar.SirenActive = true; fibCar2.SirenActive = true; foreach (LPed fib in fibPersonnel) { if (ValidityCheck.isObjectValid(fib)) { Functions.AddToScriptDeletionList(fib, this); fib.Weapons.RemoveAll(); fib.Weapons.FromType(Weapon.Handgun_Glock).Ammo = 999; fib.Weapons.FromType(Weapon.TBOGT_AssaultSMG).Ammo = 999; fib.Weapons.FromType(Weapon.Rifle_M4).Ammo = 999; fib.Weapons.Select(Weapon.Rifle_M4); fib.DefaultWeapon = Weapon.Rifle_M4; fib.WillDoDrivebys = true; } } foreach (LPed fib in fibPersonnel2) { if (ValidityCheck.isObjectValid(fib)) { Functions.AddToScriptDeletionList(fib, this); fib.Weapons.RemoveAll(); fib.Weapons.FromType(Weapon.TBOGT_Pistol44).Ammo = 999; fib.Weapons.FromType(Weapon.SMG_MP5).Ammo = 999; fib.Weapons.FromType(Weapon.Shotgun_Basic).Ammo = 999; fib.Weapons.Select(Weapon.SMG_MP5); fib.DefaultWeapon = Weapon.SMG_MP5; fib.WillDoDrivebys = true; } } } // Since we want other cops to join, set as called in already and also active it for player Functions.SetPursuitCalledIn(this.pursuit, true); Functions.SetPursuitIsActiveForPlayer(this.pursuit, true); Functions.SetPursuitAllowWeaponsForSuspects(this.pursuit, true); Functions.SetPursuitForceSuspectsToFight(this.pursuit, true); Functions.SetPursuitTactics(this.pursuit, true); // Show message to the player Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_ROBBERY_CATCH_UP"), 25000); Functions.AddTextToTextwall(string.Format(Resources.TEXT_INFO_RELAY_SV_LUIS, criminals[0].PersonaData.FullName, criminals[0].PersonaData.BirthDay), Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); isReady = true; } catch (Exception ex) { Log.Error("OnCalloutAccepted: Cannot create Pursuit instance: " + ex, this); isReady = false; } return(isReady); }
/// <summary> /// Called when the callout has been accepted. Call base to set state to Running. /// </summary> /// <returns> /// True if callout was setup properly, false if it failed. Calls <see cref="End"/> when failed. /// </returns> public override bool OnCalloutAccepted() { bool isReady = base.OnCalloutAccepted(); this.pursuit = Functions.CreatePursuit(); Functions.SetPursuitCopsCanJoin(this.pursuit, false); Functions.SetPursuitDontEnableCopBlips(this.pursuit, true); // Add blip this.blip = Functions.CreateBlipForArea(this.spawnPoint.Position, 30f); this.blip.Display = BlipDisplay.ArrowAndMap; this.blip.RouteActive = true; // Decide whether prank call or not if (Common.GetRandomBool(0, 5, 1)) { Log.Debug("OnCalloutAccepted: Is prank", this); this.SetAsPrankCall(); } else { try { this.criminals = new List <LPed>(); int random = Common.GetRandomValue(6, 13); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue <string>(this.criminalModels), LPed.EPedGroup.Criminal); if (ValidityCheck.isObjectValid(criminal)) { // Ensure ped is not in a building if (criminal.EnsurePedIsNotInBuilding(criminal.Position)) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); criminal.RelationshipGroup = RelationshipGroup.Gang_Biker2; criminal.ChangeRelationship(RelationshipGroup.Gang_Biker2, Relationship.Companion); criminal.ChangeRelationship(RelationshipGroup.Gang_Italian, Relationship.Hate); criminal.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); criminal.CantBeDamagedByRelationshipGroup(RelationshipGroup.Gang_Biker2, true); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; // Set up weapons criminal.Weapons.RemoveAll(); criminal.Weapons.FromType(Weapon.Handgun_Glock).Ammo = 999; criminal.Weapons.FromType(Weapon.Shotgun_Basic).Ammo = 120; criminal.Weapons.FromType(Weapon.Melee_Knife); criminal.Weapons.FromType(Weapon.Thrown_Molotov).Ammo = 2; criminal.Weapons.Select(Weapon.Thrown_Molotov); criminal.DefaultWeapon = Weapon.Shotgun_Basic; criminal.ComplianceChance = Common.GetRandomValue(25, 75); Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } else { Log.Debug("OnCalloutAccepted: Failed to place ped properly outside of building", this); criminal.Delete(); } } } if (this.criminals.Count == 0) { isReady = false; } else { // Create Johnny johnny = new LPed(this.spawnPoint.Position.Around((float)10), "IG_JOHNNYBIKER", LPed.EPedGroup.MissionPed); johnny.PersonaData = new PersonaData(new DateTime(1974, 3, 17, 8, 30, 0, DateTimeKind.Utc), 13, "Johnny", "Klebitz", true, 9, true); johnny.RelationshipGroup = RelationshipGroup.Special; johnny.ChangeRelationship(RelationshipGroup.Special, Relationship.Companion); johnny.ChangeRelationship(RelationshipGroup.Gang_Biker2, Relationship.Companion); johnny.ChangeRelationship(RelationshipGroup.Gang_Italian, Relationship.Hate); johnny.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); johnny.CantBeDamagedByRelationshipGroup(RelationshipGroup.Gang_Biker2, true); johnny.CantBeDamagedByRelationshipGroup(RelationshipGroup.Special, true); johnny.BecomeMissionCharacter(); // Place near any criminal ped if he's in a building if (!johnny.EnsurePedIsNotInBuilding(johnny.Position)) { johnny.Position = criminals[Common.GetRandomValue(0, criminals.Count - 1)].Position + new Vector3(1.0f, 1.5f, 0); } // We don't want the criminal to flee yet johnny.DisablePursuitAI = true; // Set up weapons johnny.Weapons.RemoveAll(); johnny.Weapons.DesertEagle.Ammo = 999; johnny.Weapons.AssaultRifle_AK47.Ammo = 300; johnny.Weapons.Knife.Ammo = 1; johnny.Weapons.AssaultRifle_AK47.Select(); johnny.DefaultWeapon = Weapon.Rifle_AK47; johnny.ComplianceChance = Common.GetRandomValue(0, 30); // Make default of the ped's component variation Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", new Parameter[] { johnny.GPed }); Functions.AddPedToPursuit(this.pursuit, johnny); this.criminals.Add(johnny); } // Chance to spawn another bunch of suspects fighting each other if (Common.GetRandomBool(0, 2, 1)) { random = Common.GetRandomValue(7, 15); for (int i = 0; i < random; i++) { LPed criminal = new LPed(this.spawnPoint.Position, Common.GetRandomCollectionValue <string>(this.mafiaModels), LPed.EPedGroup.Criminal); if (ValidityCheck.isObjectValid(criminal)) { Functions.AddToScriptDeletionList(criminal, this); Functions.SetPedIsOwnedByScript(criminal, this, true); criminal.RelationshipGroup = RelationshipGroup.Gang_Italian; criminal.ChangeRelationship(RelationshipGroup.Gang_Italian, Relationship.Companion); criminal.ChangeRelationship(RelationshipGroup.Cop, Relationship.Hate); criminal.ChangeRelationship(RelationshipGroup.Gang_Biker2, Relationship.Hate); criminal.CantBeDamagedByRelationshipGroup(RelationshipGroup.Gang_Italian, true); // We don't want the criminal to flee yet criminal.DisablePursuitAI = true; criminal.Weapons.RemoveAll(); criminal.Weapons.Glock.Ammo = 999; criminal.Weapons.Uzi.Ammo = 999; criminal.Weapons.Knife.Ammo = 1; if (Common.GetRandomBool(0, 50, 1)) { criminal.Weapons.Uzi.Select(); criminal.DefaultWeapon = Weapon.SMG_Uzi; } else { criminal.Weapons.AssaultRifle_M4.Ammo = 999; criminal.Weapons.AssaultRifle_M4.Select(); criminal.DefaultWeapon = Weapon.Rifle_M4; } Functions.AddPedToPursuit(this.pursuit, criminal); this.criminals.Add(criminal); } } // Chance to start fighting immediately if (Common.GetRandomBool(0, 2, 1)) { this.State = EShootoutState.Fighting; this.Engage(); // Request one backup unit automatically Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); Functions.PlaySoundUsingPosition("DFROM_DISPATCH_3_UNITS_FROM POSITION FOR CRIM_A_DOMESTIC_DISTURBANCE", LPlayer.LocalPlayer.Ped.Position); } } isReady = true; } catch (Exception ex) { Log.Error("OnCalloutAccepted: Cannot create Pursuit instance: " + ex, this); isReady = false; } } // Add states if (isReady) { this.RegisterStateCallback(EShootoutState.WaitingForPlayer, this.WaitingForPlayer); this.RegisterStateCallback(EShootoutState.PlayerIsClose, this.PlayerIsClose); this.RegisterStateCallback(EShootoutState.InCombat, this.InCombat); this.RegisterStateCallback(EShootoutState.Fighting, this.InCombat); this.RegisterStateCallback(EShootoutState.Prank, this.Prank); this.State = EShootoutState.WaitingForPlayer; if (!this.IsPrankCall) { Functions.AddTextToTextwall(string.Format(Resources.TEXT_INFO_RELAY_SV_JOHNNY, johnny.PersonaData.FullName, johnny.PersonaData.BirthDay), Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); } else { DelayedCaller.Call(delegate { Functions.AddTextToTextwall(Resources.TEXT_INFO_RELAY_SV_JOHNNY_PRANK, Functions.GetStringFromLanguageFile("POLICE_SCANNER_CONTROL")); // Request one backup unit automatically Functions.RequestPoliceBackupAtPosition(LPlayer.LocalPlayer.Ped.Position); Functions.PlaySoundUsingPosition("DFROM_DISPATCH_2_UNITS_FROM POSITION", LPlayer.LocalPlayer.Ped.Position); }, this, Common.GetRandomValue(3000, 6001)); } Functions.PrintText(Functions.GetStringFromLanguageFile("CALLOUT_GET_TO_CRIME_SCENE"), 8000); } return(isReady); }