Skip to content

Commit

Permalink
Modify gravity effects to not apply when player is in a jetpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordmau5 committed May 4, 2024
1 parent 3511b99 commit af7dcdf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gtasa/effects/custom/gravity/GravityEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ class SimpleGravityEffect : public EffectBase
{
GameUtil::SetVehiclesToRealPhysics ();

CPlayerPed *player = FindPlayerPed ();
if (!player) return;

for (CPed *ped : CPools::ms_pPedPool)
{
if (ped == player)
{
// Don't apply gravity effects to the player if they are using a
// jetpack
if (player->m_pIntelligence->GetTaskJetPack ()) continue;
}

NegateGravity (ped);
ApplyGravity (ped);
}
Expand Down
10 changes: 10 additions & 0 deletions src/gtasa/effects/custom/gravity/InvertedGravityEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ class InvertedGravityEffect : public EffectBase
{
GameUtil::SetVehiclesToRealPhysics ();

CPlayerPed *player = FindPlayerPed ();
if (!player) return;

for (CPed *ped : CPools::ms_pPedPool)
{
if (ped == player)
{
// Don't apply gravity effects to the player if they are using a
// jetpack
if (player->m_pIntelligence->GetTaskJetPack ()) continue;
}

NegateGravity (ped);
ApplyGravity (ped, -0.002f);
}
Expand Down
12 changes: 12 additions & 0 deletions src/gtasa/effects/custom/gravity/ZeroGravityEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ class ZeroGravityEffect : public EffectBase
{
GameUtil::SetVehiclesToRealPhysics ();

CPlayerPed *player = FindPlayerPed ();
if (!player) return;

for (CPed *ped : CPools::ms_pPedPool)
{
if (ped == player)
{
// Don't apply gravity effects to the player if they are using a
// jetpack
if (player->m_pIntelligence->GetTaskJetPack ()) continue;
}

NegateGravity (ped);
}

for (CVehicle *vehicle : CPools::ms_pVehiclePool)
NegateGravity (vehicle);
Expand Down

0 comments on commit af7dcdf

Please sign in to comment.