Skip to content
This repository was archived by the owner on Dec 25, 2022. It is now read-only.

Commit 5ffa66f

Browse files
committed
Companions can use parachute now
1 parent 26bc29b commit 5ffa66f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Client/Companions.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Companions : BaseScript
1010
{
1111
private const string FlagDecor = "POCCE_COMPANION_FLAG";
1212
private const string PlayerDecor = "POCCE_COMPANION_PLAYER";
13+
private const uint Parachute = 0xFBAB5776; // gadget_parachute
1314

1415
public Companions()
1516
{
@@ -95,6 +96,31 @@ private static bool CheckAndHandlePlayerCombat(IEnumerable<int> peds, IEnumerabl
9596
return false;
9697
}
9798

99+
private static bool CheckAndHandleFreefall(int companion, Vector3 coords)
100+
{
101+
var paraState = API.GetPedParachuteState(companion);
102+
if (paraState == 1 || paraState == 2)
103+
{
104+
API.SetParachuteTaskTarget(companion, coords.X, coords.Y, coords.Z);
105+
return true;
106+
}
107+
108+
if ((API.IsPedFalling(companion) || API.IsPedInParachuteFreeFall(companion)) &&
109+
!API.IsPedInAnyVehicle(companion, false))
110+
{
111+
API.SetPedSeeingRange(companion, 1f);
112+
API.SetPedHearingRange(companion, 1f);
113+
API.SetPedKeepTask(companion, true);
114+
API.GiveWeaponToPed(companion, Parachute, 1, false, true);
115+
API.TaskParachuteToTarget(companion, coords.X, coords.Y, coords.Z);
116+
return true;
117+
}
118+
119+
API.SetPedSeeingRange(companion, 100f);
120+
API.SetPedHearingRange(companion, 100f);
121+
return false;
122+
}
123+
98124
private static void FollorPlayerToVehicle(int player, IEnumerable<int> companions)
99125
{
100126
var vehicle = API.GetVehiclePedIsIn(player, false);
@@ -127,6 +153,9 @@ private static void FollowPlayer(int player, IEnumerable<int> companions)
127153
var coords = API.GetEntityCoords(player, true);
128154
foreach (var companion in companions)
129155
{
156+
if (CheckAndHandleFreefall(companion, coords))
157+
continue;
158+
130159
var pos = API.GetEntityCoords(companion, true);
131160
if (API.IsPedInAnyVehicle(companion, true))
132161
{

0 commit comments

Comments
 (0)