Skip to content

Commit e152218

Browse files
committed
Ghosts avoid peds
Put ghost back on bike if knocked off Ghost bike can't be damaged Add blip at ghosts start
1 parent 10cdb28 commit e152218

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ActivityGhosts/ActivityGhosts.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace ActivityGhosts
1616
public class ActivityGhosts : Script
1717
{
1818
private List<Ghost> ghosts;
19+
private Blip start;
1920
private System.DateTime lastTime;
2021
private Keys menuKey;
2122
public static PointF initialGPSPoint;
@@ -51,6 +52,7 @@ private void DeleteGhosts()
5152
foreach (Ghost g in ghosts)
5253
g.Delete();
5354
ghosts.Clear();
55+
start?.Delete();
5456
}
5557

5658
private void RegroupGhosts()
@@ -123,6 +125,8 @@ private void CreateMenu()
123125
LoadGhosts();
124126
if (ghosts.Count > 0)
125127
{
128+
start = World.CreateBlip(Game.Player.Character.Position);
129+
start.Sprite = BlipSprite.RaceBike;
126130
loadMenuItem.Enabled = false;
127131
regroupMenuItem.Enabled = true;
128132
deleteMenuItem.Enabled = true;
@@ -161,6 +165,7 @@ public class Ghost
161165
VehicleDrivingFlags.AllowMedianCrossing |
162166
VehicleDrivingFlags.AvoidEmptyVehicles |
163167
VehicleDrivingFlags.AvoidObjects |
168+
VehicleDrivingFlags.AvoidPeds |
164169
VehicleDrivingFlags.AvoidVehicles |
165170
VehicleDrivingFlags.IgnorePathFinding;
166171

@@ -183,6 +188,7 @@ public Ghost(List<GeoPoint> pointList)
183188
Vector3 start = GetPoint(index);
184189
vehicle = World.CreateVehicle(vModel, start);
185190
vModel.MarkAsNoLongerNeeded();
191+
vehicle.IsInvincible = true;
186192
vehicle.Mods.CustomPrimaryColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));
187193
Model pModel;
188194
pModel = new Model(availableCyclists[random.Next(availableCyclists.Length)]);
@@ -193,6 +199,7 @@ public Ghost(List<GeoPoint> pointList)
193199
Script.Wait(10);
194200
ped = World.CreatePed(pModel, start);
195201
pModel.MarkAsNoLongerNeeded();
202+
ped.IsInvincible = true;
196203
ped.SetIntoVehicle(vehicle, VehicleSeat.Driver);
197204
vehicle.Heading = GetHeading(index);
198205
blip = vehicle.AddBlip();
@@ -206,6 +213,8 @@ public void Update()
206213
{
207214
if (points.Count > index + 1)
208215
{
216+
if (!ped.IsOnBike)
217+
ped.SetIntoVehicle(vehicle, VehicleSeat.Driver);
209218
float speed = points[index].Speed;
210219
float distance = vehicle.Position.DistanceTo2D(GetPoint(index));
211220
if (distance > 20f)
@@ -219,8 +228,6 @@ public void Update()
219228
ped.Task.ClearAll();
220229
ped.Task.DriveTo(vehicle, GetPoint(index), 0f, speed, (DrivingStyle)customDrivingStyle);
221230
vehicle.Speed = speed;
222-
ped.IsInvincible = true;
223-
ped.CanBeKnockedOffBike = true;
224231
}
225232
else if (ped.IsOnBike)
226233
{

0 commit comments

Comments
 (0)