Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
New scene finished, bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cannonb4ll committed Jul 2, 2020
1 parent 7345076 commit bd79883
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 49 deletions.
5 changes: 4 additions & 1 deletion VehicleCollisions/Scenes/CarPetrolLeak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public CarPetrolLeak()
public string[] Notifications()
{
return new string[]
{ };
{
"We've received a call a cars petrol tank is leaking.",
"Deal with the leaking tank, tow away the car and cleanup the scene.s"
};
}

public Vector3 Coordinates => new Vector3(RandomCoordinates.X, RandomCoordinates.Y, RandomCoordinates.Z);
Expand Down
8 changes: 4 additions & 4 deletions VehicleCollisions/Scenes/MilitaryTransportEngineFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public async Task RunAdditionalTasks()
}
}

public async void TheTruckCouldNotBeFixedAndCaughtOnFire()
private async void TheTruckCouldNotBeFixedAndCaughtOnFire()
{
ShowSubtitle("[Military officer] SHIT! Wrong cable! Put out the fire or run!", 10000);

Expand All @@ -219,7 +219,7 @@ public async void TheTruckCouldNotBeFixedAndCaughtOnFire()
SpawnedCivilianPeds[0].Task.FleeFrom(SpawnedCrashedCars[0].Driver);
}

public async void MechanicGetsOverWhelmedByFumes()
private async void MechanicGetsOverWhelmedByFumes()
{
ShowSubtitle("[Military officer] Ooof... These fumes are not good, I do not feel well..", 10000);

Expand All @@ -228,7 +228,7 @@ public async void MechanicGetsOverWhelmedByFumes()
SetEntityHealth(SpawnedCivilianPeds[0].Handle, 0);
}

public async void MilitaryGetsAttacked()
private async void MilitaryGetsAttacked()
{
ShowNotification("[Dispatch] We've received a call a suspicious vehicle is heading towards your location.");
ShowNotification("[Dispatch] We marked the vehicle on your map, check out the vehicle.");
Expand Down Expand Up @@ -268,7 +268,7 @@ await _vehicleCollisions._SpawnVehicle(BadGuyVehicles[Utilities.Between(0, BadGu
SpawnedCivilianPeds[0].AlwaysKeepTask = true;
}

public async void TheTruckIsFixedAndCanDriveAway()
private async void TheTruckIsFixedAndCanDriveAway()
{
ShowSubtitle("[Military officer] Alright, all good! Thanks for guarding us.", 10000);

Expand Down
3 changes: 1 addition & 2 deletions VehicleCollisions/Scenes/SceneFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public class SceneFactory

public SceneFactory()
{
_sceneNumber = 14;
//_sceneNumber = Utilities.Between(1, 14);
_sceneNumber = Utilities.Between(1, 14);
}

public IScene GetScene(VehicleCollisions vehicleCollisions)
Expand Down
15 changes: 3 additions & 12 deletions VehicleCollisions/Scenes/SevereCrashWithMilitaryConvoy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace VehicleCollisions.Scenes
{
internal class SevereCrashWithMilitaryConvoy : IScene
{
private Ped[] SpawnedCivilianPeds;
private Vehicle[] SpawnedCrashedCars;
public bool HasAdditionalTasks => false;
public string Title => "Severe crash with military convoy";

Expand All @@ -29,7 +27,7 @@ public string[] Notifications()
}

// Define the coordinates of the main accident
public Vector3 Coordinates => new Vector3(-1777, -677, -10);
public Vector3 Coordinates => new Vector3(-1769.41f, -668.4f, 10.4f);

// Define the on-scene police cars (if any)
public EmergencyCar[] EmergencyCars => new[]
Expand All @@ -47,7 +45,7 @@ public string[] Notifications()
.GiveWeapon(WeaponHash.Flare)
};

public ObjectModel[] ObjectModels => new[]
public ObjectModel[] ObjectModels => new ObjectModel[]
{
new ObjectModel(new Vector3(-1778.23f, -659.09f, 10f), 939377219),
new ObjectModel(new Vector3(-1775.35f, -658.70f, 10f), 939377219),
Expand Down Expand Up @@ -100,20 +98,13 @@ public void Accept()

public void Start(Ped[] CivilianPeds = null, Vehicle[] CrashedCars = null)
{
SpawnedCivilianPeds = CivilianPeds;
SpawnedCrashedCars = CrashedCars;

ShowSubtitle("[Officer] I am trying to block the road here for you, I have not evaluated the situation yet",
10000);
}

public void Finish()
{
if (SpawnedCivilianPeds != null && SpawnedCivilianPeds != null)
{
SpawnedCivilianPeds[0].Task.EnterVehicle(SpawnedCrashedCars[2]);
SpawnedCivilianPeds[1].Task.EnterVehicle(SpawnedCrashedCars[3]);
}

}

public Task RunAdditionalTasks()
Expand Down
102 changes: 75 additions & 27 deletions VehicleCollisions/VehicleCollisions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Threading.Tasks;
using CitizenFX.Core;
using FivePD.API;
using VehicleCollisions.Entities;
using VehicleCollisions.Scenes;
using static CitizenFX.Core.Native.API;
using static CitizenFX.Core.UI.Screen;
using Utilities = VehicleCollisions.Utils.Utilities;

namespace VehicleCollisions
{
[CalloutProperties("Vehicle Collisions", "Dennis Smink", "1.1")]
[CalloutProperties("Vehicle Collisions", "Dennis Smink", "1.1.1")]
public class VehicleCollisions : Callout
{
private readonly IScene _scene;
Expand All @@ -36,20 +37,55 @@ public override async Task OnAccept()
// When user accepts, continue
InitBlip();

// Spawn the on-scene emergency cars (if any)
await SpawnOnSceneEmergencyCars();
try
{
// Spawn the on-scene emergency cars (if any)
await SpawnOnSceneEmergencyCars();
}
catch (Exception exception)
{
Debug.WriteLine($"[Vehicle Collisions] Unable to spawn emergency cars for scene: {exception}");
}

// Spawn the on-scene emergency peds
await SpawnOnSceneEmergencyPeds();
try
{
// Spawn the on-scene emergency peds
await SpawnOnSceneEmergencyPeds();
}
catch (Exception exception)
{
Debug.WriteLine($"[Vehicle Collisions] Unable to spawn emergency peds for scene: {exception}");
}

// Spawn the scene objects
await SpawnObjects();
try
{
// Spawn the scene objects
await SpawnObjects();
}
catch (Exception exception)
{
Debug.WriteLine($"[Vehicle Collisions] Unable to spawn objects for scene: {exception}");
}

// Spawn crashed cars
await SpawnCrashedCars();
try
{
// Spawn crashed cars
await SpawnCrashedCars();
}
catch (Exception exception)
{
Debug.WriteLine($"[Vehicle Collisions] Unable to spawn crashed cars for scene: {exception}");
}

// Spawn the civilians for the cars
await SpawnCivilians();
try
{
// Spawn the civilians for the cars
await SpawnCivilians();
}
catch (Exception exception)
{
Debug.WriteLine($"[Vehicle Collisions] Unable to spawn civilian peds for scene: {exception}");
}

// Run the notifications
RunNotifications();
Expand All @@ -65,10 +101,17 @@ public override void OnStart(Ped player)
// Run the scene start method
_scene.Start(_civilianPeds, _crashedCars);

if (_scene.HasAdditionalTasks) Tick += _scene.RunAdditionalTasks;
try
{
if (_scene.HasAdditionalTasks) Tick += _scene.RunAdditionalTasks;
}
catch (Exception exception)
{
Debug.WriteLine("[Vehicle Collisions] We we're unable to run the Tick");
}
}

public async Task SpawnOnSceneEmergencyCars()
private async Task SpawnOnSceneEmergencyCars()
{
_emergencyCars = new Vehicle[_scene.EmergencyCars.Length];
for (var i = 0; i < _scene.EmergencyCars.Length; i++)
Expand All @@ -84,33 +127,35 @@ public async Task SpawnOnSceneEmergencyCars()
}
}

public async Task SpawnOnSceneEmergencyPeds()
private async Task SpawnOnSceneEmergencyPeds()
{
_emergencyPeds = new Ped[_scene.EmergencyPeds.Length];
for (var i = 0; i < _scene.EmergencyPeds.Length; i++)
{
var emergencyPed = _scene.EmergencyPeds[i];
EmergencyPed emergencyPed = _scene.EmergencyPeds[i];

_emergencyPeds[i] = await SpawnPed(emergencyPed.Model, emergencyPed.Location);
_emergencyPeds[i].AlwaysKeepTask = true;
_emergencyPeds[i].BlockPermanentEvents = true;

_emergencyPeds[i].Weapons.Give(emergencyPed.Weapon, 1, true, true);

SetEntityHeading(_emergencyPeds[i].Handle, emergencyPed.Heading);

if (emergencyPed.AnimationLib != null)
{
RequestAnimDict(emergencyPed.AnimationLib);
_emergencyPeds[i].Task.PlayAnimation(emergencyPed.AnimationLib, emergencyPed.AnimationName);
}

if (emergencyPed.Scenario != null)
{
TaskStartScenarioInPlace(_emergencyPeds[i].Handle, emergencyPed.Scenario, 0, true);
}
}
}

public async Task SpawnObjects()
private async Task SpawnObjects()
{
_spawnedObjects = new int[_scene.ObjectModels.Length];

Expand Down Expand Up @@ -138,7 +183,7 @@ public async Task SpawnObjects()
}
}

public async Task SpawnCrashedCars()
private async Task SpawnCrashedCars()
{
_crashedCars = new Vehicle[_scene.CrashedCars.Length];
for (var i = 0; i < _scene.CrashedCars.Length; i++)
Expand Down Expand Up @@ -264,6 +309,7 @@ public async Task SpawnCrashedCars()

// If we have any drivers for the crashed car, spawn these
if (crashedCar.Peds != null)
{
foreach (var vehiclePed in crashedCar.Peds)
{
if (vehiclePed.ShouldRandomSpawn && Utilities.RandomBool()) continue;
Expand All @@ -283,6 +329,7 @@ public async Task SpawnCrashedCars()
driver.AttachedBlip.Color = BlipColor.Green;
}
}
}

// Attach trailer
if (crashedCar.AttachedTrailer != null)
Expand All @@ -305,7 +352,7 @@ public async Task SpawnCrashedCars()
}
}

public async Task SpawnCivilians()
private async Task SpawnCivilians()
{
_civilianPeds = new Ped[_scene.CivilianPeds.Length];
for (var i = 0; i < _scene.CivilianPeds.Length; i++)
Expand Down Expand Up @@ -360,12 +407,13 @@ public override void OnCancelBefore()
if (spawnedCar != null && spawnedCar.AttachedBlip != null) spawnedCar.AttachedBlip?.Delete();

// Remove ped blip
foreach (var passenger in spawnedCar.Occupants)
{
if (passenger == null) continue;
if (spawnedCar != null)
foreach (var passenger in spawnedCar.Occupants)
{
if (passenger == null) continue;

passenger.AttachedBlip?.Delete();
}
passenger.AttachedBlip?.Delete();
}
}
}
catch (Exception)
Expand All @@ -384,7 +432,7 @@ public override void OnCancelBefore()
spawnedCivilian.AttachedBlip?.Delete();
}

if (!spawnedCivilian.IsVisible) spawnedCivilian.Delete();
if (spawnedCivilian != null && !spawnedCivilian.IsVisible) spawnedCivilian.Delete();
}
}
catch (Exception)
Expand Down
1 change: 1 addition & 0 deletions VehicleCollisions/VehicleCollisions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<AssemblyName>VehicleIncidents.net</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.dll
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.pdb
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\CitizenFX.Core.dll
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csprojAssemblyReference.cache
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csproj.CoreCompileInputs.cache
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleCollisions.csproj.CopyComplete
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\FivePD.net.dll
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.dll
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\VehicleIncidents.net.pdb
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleIncidents.net.dll
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\obj\Debug\VehicleIncidents.net.pdb
C:\Users\Dennis\RiderProjects\VehicleCollisions\VehicleCollisions\bin\Debug\FivePD.net.dll
Binary file modified VehicleCollisions/obj/Debug/VehicleIncidents.net.dll
Binary file not shown.
Binary file modified VehicleCollisions/obj/Debug/VehicleIncidents.net.pdb
Binary file not shown.

0 comments on commit bd79883

Please sign in to comment.