Skip to content

Commit

Permalink
Ghosts avoid peds
Browse files Browse the repository at this point in the history
Put ghost back on bike if knocked off
Ghost bike can't be damaged
Add blip at ghosts start
  • Loading branch information
oldnapalm committed Apr 19, 2021
1 parent 10cdb28 commit e152218
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ActivityGhosts/ActivityGhosts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace ActivityGhosts
public class ActivityGhosts : Script
{
private List<Ghost> ghosts;
private Blip start;
private System.DateTime lastTime;
private Keys menuKey;
public static PointF initialGPSPoint;
Expand Down Expand Up @@ -51,6 +52,7 @@ private void DeleteGhosts()
foreach (Ghost g in ghosts)
g.Delete();
ghosts.Clear();
start?.Delete();
}

private void RegroupGhosts()
Expand Down Expand Up @@ -123,6 +125,8 @@ private void CreateMenu()
LoadGhosts();
if (ghosts.Count > 0)
{
start = World.CreateBlip(Game.Player.Character.Position);
start.Sprite = BlipSprite.RaceBike;
loadMenuItem.Enabled = false;
regroupMenuItem.Enabled = true;
deleteMenuItem.Enabled = true;
Expand Down Expand Up @@ -161,6 +165,7 @@ public class Ghost
VehicleDrivingFlags.AllowMedianCrossing |
VehicleDrivingFlags.AvoidEmptyVehicles |
VehicleDrivingFlags.AvoidObjects |
VehicleDrivingFlags.AvoidPeds |
VehicleDrivingFlags.AvoidVehicles |
VehicleDrivingFlags.IgnorePathFinding;

Expand All @@ -183,6 +188,7 @@ public Ghost(List<GeoPoint> pointList)
Vector3 start = GetPoint(index);
vehicle = World.CreateVehicle(vModel, start);
vModel.MarkAsNoLongerNeeded();
vehicle.IsInvincible = true;
vehicle.Mods.CustomPrimaryColor = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));
Model pModel;
pModel = new Model(availableCyclists[random.Next(availableCyclists.Length)]);
Expand All @@ -193,6 +199,7 @@ public Ghost(List<GeoPoint> pointList)
Script.Wait(10);
ped = World.CreatePed(pModel, start);
pModel.MarkAsNoLongerNeeded();
ped.IsInvincible = true;
ped.SetIntoVehicle(vehicle, VehicleSeat.Driver);
vehicle.Heading = GetHeading(index);
blip = vehicle.AddBlip();
Expand All @@ -206,6 +213,8 @@ public void Update()
{
if (points.Count > index + 1)
{
if (!ped.IsOnBike)
ped.SetIntoVehicle(vehicle, VehicleSeat.Driver);
float speed = points[index].Speed;
float distance = vehicle.Position.DistanceTo2D(GetPoint(index));
if (distance > 20f)
Expand All @@ -219,8 +228,6 @@ public void Update()
ped.Task.ClearAll();
ped.Task.DriveTo(vehicle, GetPoint(index), 0f, speed, (DrivingStyle)customDrivingStyle);
vehicle.Speed = speed;
ped.IsInvincible = true;
ped.CanBeKnockedOffBike = true;
}
else if (ped.IsOnBike)
{
Expand Down

0 comments on commit e152218

Please sign in to comment.