From 58059d947190615ca9de7f9780745d80bfd11211 Mon Sep 17 00:00:00 2001 From: Veloscocity Date: Mon, 9 Oct 2023 18:23:06 -0400 Subject: [PATCH 1/3] New Effect: Use the Force --- .../Effects/db/Player/PlayerCopyForce.cpp | 83 +++++++++++++++++++ ConfigApp/Effects.cs | 1 + 2 files changed, 84 insertions(+) create mode 100644 ChaosMod/Effects/db/Player/PlayerCopyForce.cpp diff --git a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp new file mode 100644 index 000000000..b6fd7e11c --- /dev/null +++ b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp @@ -0,0 +1,83 @@ +// +// Effect by Veloscocity +// + +#include + +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) }, }; } } From f9c127d7e46d98cb55ace1301aae3f213ade284c Mon Sep 17 00:00:00 2001 From: Veloscocity Date: Sat, 21 Oct 2023 13:02:48 -0400 Subject: [PATCH 2/3] .vcxproj update --- ChaosMod/ChaosMod.vcxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/ChaosMod/ChaosMod.vcxproj b/ChaosMod/ChaosMod.vcxproj index bdc8121b7..e29254586 100644 --- a/ChaosMod/ChaosMod.vcxproj +++ b/ChaosMod/ChaosMod.vcxproj @@ -151,6 +151,7 @@ + From 61fddd348fe2f64aa3c46d616cfd33fcfa72b58c Mon Sep 17 00:00:00 2001 From: pongo1231 Date: Sat, 21 Oct 2023 20:14:58 +0200 Subject: [PATCH 3/3] Update ChaosMod/Effects/db/Player/PlayerCopyForce.cpp --- ChaosMod/Effects/db/Player/PlayerCopyForce.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp index b6fd7e11c..30c293bc5 100644 --- a/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp +++ b/ChaosMod/Effects/db/Player/PlayerCopyForce.cpp @@ -4,7 +4,7 @@ #include -Vector3 playerVelocity; +static Vector3 playerVelocity; static void OnStart() {