Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Effect: Use the Force #3597

Merged
merged 3 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChaosMod/ChaosMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<ClCompile Include="Effects\db\Peds\PedsMinions.cpp" />
<ClCompile Include="Effects\db\Peds\PedsSpawnAngryJimmy.cpp" />
<ClCompile Include="Effects\db\Peds\PedsSpawnRoastingLamar.cpp" />
<ClCompile Include="Effects\db\Player\PlayerCopyForce.cpp" />
<ClCompile Include="Effects\db\Player\PlayerAFK.cpp" />
<ClCompile Include="Effects\db\Peds\PedsReflectiveDamage.cpp" />
<ClCompile Include="Effects\db\Peds\PedsToast.cpp" />
Expand Down
83 changes: 83 additions & 0 deletions ChaosMod/Effects/db/Player/PlayerCopyForce.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// Effect by Veloscocity
//

#include <stdafx.h>

Vector3 playerVelocity;
pongo1231 marked this conversation as resolved.
Show resolved Hide resolved

static void OnStart()
{
Ped playerPed = PLAYER_PED_ID();

if (IS_PED_IN_ANY_VEHICLE(playerPed, false))
{
playerVelocity = GET_ENTITY_VELOCITY(GET_VEHICLE_PED_IS_IN(playerPed, false));
}
else
{
playerVelocity = GET_ENTITY_VELOCITY(playerPed);
}
}

static void OnTick()
{
Ped playerPed = PLAYER_PED_ID();
Vector3 newVelocity;

if (IS_PED_IN_ANY_VEHICLE(playerPed, false))
{
newVelocity = GET_ENTITY_VELOCITY(GET_VEHICLE_PED_IS_IN(playerPed, false));
}
else
{
newVelocity = GET_ENTITY_VELOCITY(playerPed);
}
Vector3 newForce = newVelocity - playerVelocity;
playerVelocity = newVelocity;
std::vector<Entity> entities;

for (Ped ped : GetAllPeds())
{
if (ped != playerPed && !IS_PED_IN_ANY_VEHICLE(ped, false))
{
entities.push_back(ped);
}
}

for (Vehicle veh : GetAllVehs())
{
if (!IS_PED_IN_VEHICLE(playerPed, veh, false))
{
entities.push_back(veh);
}
}

for (Entity prop : GetAllProps())
{
entities.push_back(prop);
}

Vector3 playerCoord = GET_ENTITY_COORDS(playerPed, false);
for (Entity entity : entities)
{
Vector3 entityCoord = GET_ENTITY_COORDS(entity, false);
float distance = GET_DISTANCE_BETWEEN_COORDS(playerCoord.x, playerCoord.y, playerCoord.z, entityCoord.x,
entityCoord.y, entityCoord.z, true);
if (distance < 50)
{
Vector3 vel = GET_ENTITY_VELOCITY(entity) + newForce;
SET_ENTITY_VELOCITY(entity, vel.x, vel.y, vel.z);
}
}
}

// clang-format off
REGISTER_EFFECT(OnStart, nullptr, OnTick, EffectInfo
{
.Name = "Use The Force",
.Id = "player_copyforce",
.IsTimed = true,
.IsShortDuration = true
}
);
1 change: 1 addition & 0 deletions ConfigApp/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public enum EffectTimedType
{ "cocktail_shaker", new EffectInfo("Cocktail Shaker", EffectCategory.Misc, true, true) },
{ "screen_realfp", new EffectInfo("Real First Person", EffectCategory.Screen, true) },
{ "screen_hueshift", new EffectInfo("Hue Shift", EffectCategory.Screen, true) },
{ "player_copyforce", new EffectInfo("Use The Force", EffectCategory.Player, true, true) },
};
}
}