diff --git a/ChaosMod/ChaosMod.vcxproj b/ChaosMod/ChaosMod.vcxproj index ff98c027d..63fbda73f 100644 --- a/ChaosMod/ChaosMod.vcxproj +++ b/ChaosMod/ChaosMod.vcxproj @@ -151,6 +151,7 @@ + diff --git a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp new file mode 100644 index 000000000..30c293bc5 --- /dev/null +++ b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp @@ -0,0 +1,83 @@ +// +// Effect by Veloscocity +// + +#include + +static Vector3 playerVelocity; + +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 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 + } +); \ No newline at end of file diff --git a/ConfigApp/Effects.cs b/ConfigApp/Effects.cs index 2b021b11e..b03e5efe6 100644 --- a/ConfigApp/Effects.cs +++ b/ConfigApp/Effects.cs @@ -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) }, }; } }