forked from Eddlm/LivelyWorld
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaxi.cs
More file actions
147 lines (135 loc) · 5.84 KB
/
Taxi.cs
File metadata and controls
147 lines (135 loc) · 5.84 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using GTA;
using GTA.Math;
using GTA.Native;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lively_World
{
public class TaxiEvent
{
Ped hitch;
Ped Driver;
Vehicle Taxi;
public bool Finished = false;
int Status = 0;
float Range = 300f;
bool DropOff = false;
public TaxiEvent(Ped ped, Ped driver, Vehicle taxi)
{
hitch = ped;
Driver = driver;
Taxi = taxi;
hitch.IsPersistent = true;
Taxi.IsPersistent = true;
Driver.IsPersistent = true;
if (LivelyWorld.DebugBlips && !taxi.CurrentBlip.Exists())
{
Taxi.AddBlip();
Taxi.CurrentBlip.Sprite = BlipSprite.Cab;
Taxi.CurrentBlip.Color = BlipColor.Yellow;
Taxi.CurrentBlip.IsShortRange = true;
hitch.AddBlip();
hitch.CurrentBlip.Color = BlipColor.White;
hitch.CurrentBlip.Scale = 0.7f;
hitch.CurrentBlip.IsShortRange = true;
}
hitch.AlwaysKeepTask = true;
driver.AlwaysKeepTask = true;
if (hitch.IsInVehicle(Taxi))
{
if(LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("Taxi event mode: dropoff");
DropOff = true;
//Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 15.0, 1.0);
}
else
{
if (LivelyWorld.Debug >= DebugLevel.EventsAndScenarios) UI.Notify("Taxi event mode: pick up");
Vector3 pos = hitch.Position;
Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 15.0, 1.0);
hitch.Task.LookAt(Taxi, -1);
}
//Driver.Task.DriveTo(Taxi, hitch.Position, 10f, 10f, 1+2+ 16+32 + 128 + 256);
}
public void Process()
{
if (hitch.IsInCombat)
{
Finished = true;
return;
}
if (LivelyWorld.CanWeUse(Taxi) && LivelyWorld.CanWeUse(hitch) && LivelyWorld.CanWeUse(Driver) && Taxi.IsInRangeOf(Game.Player.Character.Position, Range))
{
if (DropOff)
{
if (Status == 0)
{
Status++;
Vector3 pos = World.GetSafeCoordForPed(Taxi.Position + (Taxi.ForwardVector * 50f));
Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 5.0, 30.0);
}
else
{
if (Taxi.IsStopped)
{
hitch.Task.LeaveVehicle();
Finished = true;
}
}
}
else
{
switch (Status)
{
case 0:
{
if (Taxi.IsInRangeOf(hitch.Position, 20f))
{
Status++;
Vector3 pos = Taxi.Position + (Taxi.ForwardVector * 10f) + (Taxi.RightVector * 2);
Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 3f, 1, Taxi.Model, 4 + 8 + 16 + 32, 3.0, 50.0);
}
else if (Taxi.IsStopped)
{
Vector3 pos = hitch.Position;
Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, Driver, Taxi, pos.X, pos.Y, pos.Z, 10f, 1, Taxi.Model, 1 + 2 + 8 + 16 + 32 + 128 + 256, 15.0, 1.0);
//Driver.Task.DriveTo(Taxi, hitch.Position, 10f, 10f, 1 + 2 + 16 + 32+ 128 + 256);
}
break;
}
case 1:
{
if (hitch.IsInVehicle(Taxi))
{
Status++;
Range = 50;
}
else if (!hitch.IsGettingIntoAVehicle)
{
hitch.Task.EnterVehicle(Taxi, VehicleSeat.RightRear, -1, 1f);
}
break;
}
case 2:
{
if (Taxi.IsStopped) Function.Call(Hash.TASK_VEHICLE_DRIVE_WANDER, Driver, Taxi, 20f, 1 + 2 + 4 + 8 + 16 + 32 + 128 + 256);
break;
}
}
}
}
else if (!Finished) Finished = true;
}
public void Clear()
{
if (Taxi.CurrentBlip.Exists()) Taxi.CurrentBlip.Color = BlipColor.White;
//if (hitch.CurrentBlip.Exists()) hitch.CurrentBlip.Remove();
//if (Taxi.CurrentBlip.Exists()) Taxi.CurrentBlip.Remove();
hitch.IsPersistent = false;
Taxi.IsPersistent = false;
Driver.IsPersistent = false;
}
}
}