Repository navigation
Expand file tree
/
Copy pathCardiacArrestCallout.cs
More file actions
63 lines (51 loc) · 2.25 KB
/
Copy pathCardiacArrestCallout.cs
File metadata and controls
63 lines (51 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Threading;
using System.Threading.Tasks;
using CitizenFX.Core;
using CitizenFX.Core.Native;
using FivePRS.Client;
using FivePRS.Client.Callouts;
using FivePRS.Core.Models;
using FivePRS.EMS.Callouts;
namespace ExampleCallouts
{
[CalloutInfo(
name: "Cardiac Arrest",
department: Department.EMS,
priority: CalloutPriority.High,
weight: 15,
cooldownSeconds: 300,
xpReward: 100)]
public sealed class CardiacArrestCallout : PatientCallout
{
private const float HandOverDistance = 6f;
private readonly Vector3 _location;
private Ped? _bystander;
private bool _handedOver;
public CardiacArrestCallout()
{
_location = World.GetNextPositionOnSidewalk(Positions.Around(Game.PlayerPed.Position, 250f + Rng.Next(250), Rng));
Data.Description = "A person collapsed and isn't breathing. A bystander has started CPR.";
}
protected override Vector3 Location => _location;
protected override string BlipName => "Cardiac arrest";
protected override async Task<Ped?> SetupSceneAsync(CancellationToken ct)
{
var patient = await SpawnPatientAsync(_location, Rng.Next(360));
if (patient is null) return null;
_bystander = TrackEntity(await Spawn.PedAsync("a_f_y_business_02", patient.Position + patient.RightVector * 1.2f, patient.Heading + 90f));
if (_bystander is not null)
API.TaskStartScenarioInPlace(_bystander.Handle, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true);
return patient;
}
public override void OnUpdate()
{
if (_handedOver || _bystander is null || !_bystander.Exists()) return;
if (Vector3.Distance(Game.PlayerPed.Position, _bystander.Position) > HandOverDistance) return;
_handedOver = true;
_bystander.Task.ClearAll();
_bystander.Task.WanderAround();
ClientBrain.ShowNotification("They just dropped! I've been doing compressions since.", "~b~Bystander");
}
public override void OnCalloutDeclined() => ClientBrain.ShowNotification("Cardiac arrest call declined.", "~r~Dispatch");
}
}