Skip to content

Commit 5e10ba2

Browse files
committed
Update V0.1.1
Added "Abandoned Vehcile" callout Improving the others callouts : - Car Crash : - Improved the callout spawn location. - Train Derailment : - Adjusted the minimum spawn distance - Added rocks - Added fire - Ambient trains are now invisible and without collisions
1 parent 03beec3 commit 5e10ba2

6 files changed

Lines changed: 299 additions & 18 deletions

File tree

Callouts/AbandonedVehicle.cs

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Rage;
7+
using LSPD_First_Response.Mod.API;
8+
using LSPD_First_Response.Mod.Callouts;
9+
using System.Windows.Forms.VisualStyles;
10+
11+
namespace SSStuartCallouts.Callouts
12+
{
13+
14+
[CalloutInfo("AbandonedVehicle", CalloutProbability.Low)]
15+
16+
public class AbandonedVehicle: Callout
17+
{
18+
private Ped Driver;
19+
private Vehicle AbandonedCar;
20+
private Blip AbandonedCarBlip;
21+
private Vector3 SpawnPoint;
22+
private LHandle Pursuit;
23+
private bool PursuitCreated;
24+
private bool EventCreated;
25+
private bool VehicleStolen;
26+
private Vehicle PlayerVehicle;
27+
private Vehicle BackupVehicle;
28+
private Blip BackupBlip;
29+
private Ped BackupPed;
30+
31+
public int RandomNumber(int min, int max)
32+
{
33+
int random = new Random().Next(min, max);
34+
return random;
35+
}
36+
37+
38+
public override bool OnBeforeCalloutDisplayed()
39+
{
40+
SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(2000f));
41+
ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 50f);
42+
AddMinimumDistanceCheck(200f, SpawnPoint);
43+
CalloutMessage = "Abandoned Vehicle";
44+
CalloutPosition = SpawnPoint;
45+
Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT_04 IN_OR_ON_POSITION", SpawnPoint);
46+
47+
return base.OnBeforeCalloutDisplayed();
48+
}
49+
50+
public override bool OnCalloutAccepted()
51+
{
52+
List<string> vehicleList = new List<string>
53+
{
54+
"speedo",
55+
"sanchez2",
56+
"faggio",
57+
"granger",
58+
"rebel",
59+
"rebel2",
60+
"dloader",
61+
"voodoo2"
62+
};
63+
64+
AbandonedCar = new Vehicle(vehicleList[RandomNumber(0, vehicleList.Count)], SpawnPoint, RandomNumber(-180, 180));
65+
AbandonedCar.IsPersistent = true;
66+
67+
Driver = new Ped(AbandonedCar.GetOffsetPositionRight(5f));
68+
Driver.IsPersistent = true;
69+
Driver.BlockPermanentEvents = true;
70+
Driver.IsVisible = false;
71+
72+
AbandonedCarBlip = new Blip(AbandonedCar);
73+
AbandonedCarBlip.Color = System.Drawing.Color.Orange;
74+
AbandonedCarBlip.IsRouteEnabled = true;
75+
AbandonedCarBlip.Name = "Abandoned Vehicle";
76+
77+
EventCreated = false;
78+
PursuitCreated = false;
79+
VehicleStolen = false;
80+
81+
return base.OnCalloutAccepted();
82+
}
83+
84+
public override void Process()
85+
{
86+
base.Process();
87+
88+
if (!EventCreated && Game.LocalPlayer.Character.DistanceTo(AbandonedCar) < 300f)
89+
{
90+
Game.DisplayNotification("The abandoned vehicle is a ~o~" + AbandonedCar.Model.Name);
91+
92+
AbandonedCar.IsEngineOn = true;
93+
AbandonedCar.IndicatorLightsStatus = VehicleIndicatorLightsStatus.Both;
94+
if(RandomNumber(0,2) == 1)
95+
AbandonedCar.Doors[0].IsFullyOpen = true;
96+
97+
EventCreated = true;
98+
99+
}
100+
101+
if (EventCreated && !VehicleStolen && Game.LocalPlayer.Character.IsInAnyVehicle(false))
102+
PlayerVehicle = Game.LocalPlayer.Character.LastVehicle;
103+
104+
if (EventCreated && !PursuitCreated && !VehicleStolen && (Game.LocalPlayer.Character.DistanceTo(PlayerVehicle) > 10f) && !Game.LocalPlayer.Character.IsInAnyVehicle(false))
105+
{
106+
AbandonedCarBlip.DisableRoute();
107+
Game.DisplayNotification("Inspect the vehicle");
108+
if (!PlayerVehicle.IsOnScreen && !Game.LocalPlayer.Character.IsInAnyVehicle(false))
109+
{
110+
int counterInvisible = 0;
111+
while (counterInvisible < 10)
112+
{
113+
GameFiber.Wait(100);
114+
if (PlayerVehicle.IsOnScreen)
115+
break;
116+
counterInvisible++;
117+
}
118+
if (counterInvisible == 10)
119+
VehicleStolen = true;
120+
121+
if (VehicleStolen)
122+
{
123+
Driver.Position = PlayerVehicle.GetOffsetPositionRight(-2f);
124+
Driver.IsVisible = true;
125+
Driver.BlockPermanentEvents = true;
126+
127+
Game.LogTrivial("Warping thief into vehicle");
128+
Driver.WarpIntoVehicle(PlayerVehicle, -1);
129+
Game.LogTrivial("Assinging task to drive away");
130+
Driver.Tasks.CruiseWithVehicle(100f);
131+
132+
Pursuit = Functions.CreatePursuit();
133+
Functions.AddPedToPursuit(Pursuit, Driver);
134+
Functions.RequestBackup(World.GetNextPositionOnStreet(Driver.Position.Around(100f)), LSPD_First_Response.EBackupResponseType.Pursuit, LSPD_First_Response.EBackupUnitType.AirUnit);
135+
Functions.SetPursuitIsActiveForPlayer(Pursuit, true);
136+
137+
GameFiber.Wait(1500);
138+
Game.DisplayNotification("dia_police", "dia_police", "Dispatch", "", "Calling for backup to pick you up");
139+
Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_GRAND_THEFT_AUTO OUTRO_03 ASSISTANCE_REQUIRED IN_OR_ON_POSITION", Driver.Position);
140+
141+
BackupVehicle = new Vehicle("police", World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(200f)), Game.LocalPlayer.Character.Heading);
142+
BackupVehicle.IsSirenOn = true;
143+
BackupVehicle.IsPersistent = true;
144+
145+
BackupPed = new Ped("s_m_m_chemsec_01", BackupVehicle.GetOffsetPositionRight(2f), BackupVehicle.Heading);
146+
BackupPed.BlockPermanentEvents = true;
147+
BackupPed.IsPersistent = true;
148+
149+
BackupBlip = new Blip(BackupPed);
150+
BackupBlip.Sprite = BlipSprite.PolicePatrol;
151+
BackupBlip.Color = System.Drawing.Color.LightSkyBlue;
152+
153+
BackupPed.WarpIntoVehicle(BackupVehicle, -1);
154+
Game.LogTrivial("Task : Drive to player");
155+
BackupPed.Tasks.DriveToPosition(Game.LocalPlayer.Character.Position, 100f, VehicleDrivingFlags.Emergency, 20f);
156+
while (BackupVehicle.DistanceTo(Game.LocalPlayer.Character) > 20f)
157+
{
158+
Game.LogTrivial("Distance to player > 20m");
159+
GameFiber.Wait(2000);
160+
BackupPed.Tasks.Clear();
161+
Game.LogTrivial("Task : Drive to player");
162+
BackupPed.Tasks.DriveToPosition(Game.LocalPlayer.Character.Position, 80f, VehicleDrivingFlags.Emergency, 20f);
163+
}
164+
165+
while (BackupVehicle.Speed > 1f)
166+
GameFiber.Wait(500);
167+
Game.LogTrivial("Speed < 1m/s Task : Clear");
168+
BackupPed.Tasks.Clear();
169+
if (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
170+
{
171+
Game.DisplaySubtitle("Hey, get in the car!", 5000);
172+
BackupPed.Tasks.ShuffleToAdjacentSeat();
173+
BackupPed.IsPositionFrozen = true;
174+
BackupPed.StaysInVehiclesWhenJacked = true;
175+
BackupVehicle.IsSirenOn = false;
176+
177+
while (!Game.LocalPlayer.Character.IsInAnyVehicle(false))
178+
GameFiber.Wait(500);
179+
}
180+
181+
BackupBlip.Delete();
182+
BackupPed.Delete();
183+
BackupPed = new Ped("s_m_y_cop_01", BackupVehicle.GetOffsetPositionFront(-20f), 0);
184+
BackupPed.WarpIntoVehicle(BackupVehicle, 0);
185+
BackupPed.BlockPermanentEvents = false;
186+
Functions.AddCopToPursuit(Pursuit, BackupPed);
187+
188+
PursuitCreated = true;
189+
}
190+
}
191+
}
192+
193+
else if (PursuitCreated && !Functions.IsPursuitStillRunning(Pursuit) || !Driver.IsAlive)
194+
{
195+
End();
196+
}
197+
}
198+
199+
public override void End()
200+
{
201+
base.End();
202+
203+
if (AbandonedCarBlip.Exists()) AbandonedCarBlip.Delete();
204+
if (AbandonedCar.Exists()) AbandonedCar.Dismiss();
205+
if (Driver.Exists()) Driver.Dismiss();
206+
if (Driver.Tasks != null) Driver.Tasks.Clear();
207+
if (Game.LocalPlayer.Character.IsInVehicle(BackupVehicle, false))
208+
{
209+
BackupPed.Tasks.PerformDrivingManeuver(VehicleManeuver.Wait).WaitForCompletion();
210+
GameFiber.Wait(1000);
211+
Game.LocalPlayer.Character.Tasks.LeaveVehicle(LeaveVehicleFlags.LeaveDoorOpen).WaitForCompletion();
212+
GameFiber.Wait(1000);
213+
}
214+
if (BackupPed.Tasks != null) BackupPed.Tasks.Clear();
215+
if (BackupBlip.Exists()) BackupBlip.Delete();
216+
if (BackupPed.Exists()) BackupPed.Dismiss();
217+
if (BackupVehicle.Exists()) BackupVehicle.Dismiss();
218+
if (PlayerVehicle.Exists()) PlayerVehicle.Dismiss();
219+
if (Game.LocalPlayer.Character.Tasks != null) Game.LocalPlayer.Character.Tasks.Clear();
220+
221+
Game.DisplayNotification("[CALLOUT 'ABANDONED VEHICLE' ENDED]");
222+
Game.LogTrivial("[SSStuart Callout] 'Abandoned Vehicle' callout has ended.");
223+
}
224+
}
225+
}

Callouts/CarCrash.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace SSStuartCallouts.Callouts
1111
{
1212

13-
[CalloutInfo("CarCrash", CalloutProbability.High)]
13+
[CalloutInfo("CarCrash", CalloutProbability.Medium)]
1414

1515
public class CarCrash: Callout
1616
{
@@ -32,13 +32,9 @@ public int RandomNumber(int min, int max)
3232

3333
public override bool OnBeforeCalloutDisplayed()
3434
{
35-
SpawnPoint = World.GetRandomPositionOnStreet();
36-
while (SpawnPoint.Z < 0)
37-
{
38-
SpawnPoint = World.GetRandomPositionOnStreet();
39-
}
35+
SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(2500f));
4036
ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 30f);
41-
AddMinimumDistanceCheck(5f, SpawnPoint);
37+
AddMinimumDistanceCheck(300f, SpawnPoint);
4238
CalloutMessage = "Car Crash";
4339
CalloutPosition = SpawnPoint;
4440
Functions.PlayScannerAudioUsingPosition("WE_HAVE CRIME_MOTOR_VEHICLE_ACCIDENT_01 IN_OR_ON_POSITION", SpawnPoint);
@@ -196,8 +192,11 @@ public override void End()
196192

197193
if (EventBlip.Exists()) EventBlip.Delete();
198194
if (DriverBlip.Exists()) DriverBlip.Delete();
199-
if (Driver.Exists()) Driver.Dismiss();
200-
if (Driver.Tasks != null) Driver.Tasks.Clear();
195+
if (Driver.Exists())
196+
{
197+
if (Driver.Tasks != null) Driver.Tasks.Clear();
198+
Driver.Dismiss();
199+
}
201200
if (CrashedVehicleBlip.Exists()) CrashedVehicleBlip.Delete();
202201
if (CrashedVehicle.Exists()) CrashedVehicle.Dismiss();
203202

Callouts/TrainDerailment.cs

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
using Rage;
77
using LSPD_First_Response.Mod.API;
88
using LSPD_First_Response.Mod.Callouts;
9+
using Rage.Native;
910

1011
namespace SSStuartCallouts.Callouts
1112
{
1213

13-
[CalloutInfo("TrainDerailment", CalloutProbability.High)]
14+
[CalloutInfo("TrainDerailment", CalloutProbability.VeryLow)]
1415

1516
public class TrainDerailment : Callout
1617
{
@@ -19,6 +20,10 @@ public class TrainDerailment : Callout
1920
private Vehicle TrainCarriage1;
2021
private Vehicle TrainCarriage2;
2122
private Vehicle TrainCarriage3_Tanker;
23+
private Rage.Object Rock1;
24+
private Rage.Object Rock2;
25+
private Rage.Object Rock3;
26+
private Rage.Object Rock4;
2227
private Blip CrashedTrainBlip;
2328
private Blip DriverBlip;
2429
private Vector3 SpawnPoint;
@@ -37,8 +42,8 @@ public override bool OnBeforeCalloutDisplayed()
3742
{
3843
SpawnPoint = new Vector3(2067, 1567, 75.5f);
3944
ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 30f);
40-
AddMinimumDistanceCheck(5f, SpawnPoint);
41-
CalloutMessage = "Train derailment";
45+
AddMinimumDistanceCheck(300f, SpawnPoint);
46+
CalloutMessage = "Train Derailment";
4247
CalloutPosition = SpawnPoint;
4348
Functions.PlayScannerAudioUsingPosition("WE_HAVE VEHICLE_CATEGORY_TRAIN_01 CRIME_MOTOR_VEHICLE_ACCIDENT_01 IN_OR_ON_POSITION", SpawnPoint);
4449

@@ -57,6 +62,23 @@ public override bool OnCalloutAccepted()
5762
TrainCarriage2.IsPersistent = true;
5863
TrainCarriage3_Tanker = new Vehicle("tankercar", new Vector3(2091.4f, 1525.0f, 78.3f), 50f);
5964

65+
Rock1 = new Rage.Object("prop_rock_2_d", new Vector3(2059.2f, 1573.6f, 75f));
66+
Rock1.IsPersistent = true;
67+
Rock1.IsCollisionEnabled = true;
68+
Rock1.IsPositionFrozen = true;
69+
Rock2 = new Rage.Object("prop_rock_2_c", new Vector3(2080.5f, 1559.9f, 76.2f));
70+
Rock2.IsPersistent = true;
71+
Rock2.IsCollisionEnabled = true;
72+
Rock2.IsPositionFrozen = true;
73+
Rock3 = new Rage.Object("prop_rock_2_a", new Vector3(2068.4f, 1577.0f, 76.1f));
74+
Rock3.IsPersistent = true;
75+
Rock3.IsCollisionEnabled = true;
76+
Rock3.IsPositionFrozen = true;
77+
Rock4 = new Rage.Object("prop_rock_2_g", new Vector3(2072.9f, 1551.7f, 76.0f));
78+
Rock4.IsPersistent = true;
79+
Rock4.IsCollisionEnabled = true;
80+
Rock4.IsPositionFrozen = true;
81+
6082
Driver = new Ped("s_m_m_gentransport", SpawnPoint, 0f);
6183
Driver.IsPersistent = true;
6284
Driver.BlockPermanentEvents = true;
@@ -92,10 +114,28 @@ public override void Process()
92114
EventCreated = true;
93115
}
94116

117+
if (EventCreated)
118+
{
119+
var vehicles = World.GetAllVehicles();
120+
foreach (var veh in vehicles)
121+
{
122+
if( (veh.Model.Name == "FREIGHT" || veh.Model.Name == "FREIGHTCONT1" || veh.Model.Name == "FREIGHTCONT2" || veh.Model.Name == "FREIGHTGRAIN" || veh.Model.Name == "TANKERCAR" || veh.Model.Name == "FREIGHTCAR")
123+
&& veh.Speed != 0)
124+
{
125+
veh.IsCollisionEnabled = false;
126+
veh.Opacity = 0f;
127+
if (veh.Model.Name == "FREIGHT")
128+
veh.Driver.Opacity = 0f;
129+
}
130+
}
131+
}
132+
95133
if (EventCreated && !Explosion && Game.LocalPlayer.Character.DistanceTo(CrashedTrain) < 150f)
96134
{
97135
if (RandomNumber(0, 3) == 1)
98136
World.SpawnExplosion(TrainCarriage3_Tanker.Position, 5, RandomNumber(10,20), true, false, 1f);
137+
for (int fireBit = 0; fireBit < 20; fireBit++)
138+
NativeFunction.Natives.StartScriptFire(TrainCarriage3_Tanker.Position.X + RandomNumber(-5, 5), TrainCarriage3_Tanker.Position.Y + RandomNumber(-5, +5), World.GetGroundZ(TrainCarriage3_Tanker.Position, false, false), 25, true);
99139

100140
Explosion = true;
101141
}
@@ -112,7 +152,8 @@ public override void Process()
112152
DriverBlip.Name = "Driver";
113153
DriverBlip.Color = System.Drawing.Color.LightSkyBlue;
114154

115-
Driver.Tasks.LeaveVehicle(LeaveVehicleFlags.BailOut);
155+
if(Driver.IsInAnyVehicle(false))
156+
Driver.Tasks.LeaveVehicle(LeaveVehicleFlags.BailOut);
116157
GameFiber.Wait(5000);
117158
Game.DisplayHelp("Press ~b~End~w~ to end the callout.");
118159

@@ -129,9 +170,11 @@ public override void End()
129170
{
130171
base.End();
131172

173+
NativeFunction.Natives.StopFireInRange(TrainCarriage3_Tanker.Position.X, TrainCarriage3_Tanker.Position.Y, TrainCarriage3_Tanker.Position.Z, 30f);
174+
132175
int counter = 0;
133176
Game.LogTrivial("[SSStuart Callout] 'Train derailment' callout ending in 30 sec.");
134-
while (Game.LocalPlayer.Character.DistanceTo(CrashedTrain) < 300f && counter < 6)
177+
while (Game.LocalPlayer.Character.DistanceTo(CrashedTrain) < 300f && counter <= 6)
135178
{
136179
GameFiber.Wait(5000);
137180
counter++;
@@ -143,6 +186,10 @@ public override void End()
143186
if (TrainCarriage1.Exists()) TrainCarriage1.Delete();
144187
if (TrainCarriage2.Exists()) TrainCarriage2.Delete();
145188
if (TrainCarriage3_Tanker.Exists()) TrainCarriage3_Tanker.Delete();
189+
if (Rock1.Exists()) Rock1.Dismiss();
190+
if (Rock2.Exists()) Rock2.Dismiss();
191+
if (Rock3.Exists()) Rock3.Delete();
192+
if (Rock4.Exists()) Rock4.Delete();
146193

147194
Game.DisplayNotification("[CALLOUT 'TRAIN DERAILMENT' ENDED]");
148195
Game.LogTrivial("[SSStuart Callout] 'Train derailment' callout has ended.");

0 commit comments

Comments
 (0)