From 8b83557eb1bdd8fa21bb9f2ec545e2c59cad5497 Mon Sep 17 00:00:00 2001 From: Veloscocity Date: Mon, 20 Nov 2023 20:43:44 -0500 Subject: [PATCH] New Effect: Shunt Boost --- ChaosMod/ChaosMod.vcxproj | 1 + ChaosMod/Effects/db/Misc/MiscShuntBoost.cpp | 47 +++++++++++++++++++++ ConfigApp/Effects.cs | 1 + 3 files changed, 49 insertions(+) create mode 100644 ChaosMod/Effects/db/Misc/MiscShuntBoost.cpp diff --git a/ChaosMod/ChaosMod.vcxproj b/ChaosMod/ChaosMod.vcxproj index 6d21948f5..8f8a8053d 100644 --- a/ChaosMod/ChaosMod.vcxproj +++ b/ChaosMod/ChaosMod.vcxproj @@ -120,6 +120,7 @@ + diff --git a/ChaosMod/Effects/db/Misc/MiscShuntBoost.cpp b/ChaosMod/Effects/db/Misc/MiscShuntBoost.cpp new file mode 100644 index 000000000..0d608c6af --- /dev/null +++ b/ChaosMod/Effects/db/Misc/MiscShuntBoost.cpp @@ -0,0 +1,47 @@ +#include + +#define PI 3.14159265 + +static void OnStart() +{ + std::vector entities; + + for (Ped ped : GetAllPeds()) + { + if (!IS_PED_IN_ANY_VEHICLE(ped, false)) + entities.push_back(ped); + } + + for (Vehicle veh : GetAllVehs()) + { + entities.push_back(veh); + } + + for (Object prop : GetAllProps()) + { + entities.push_back(prop); + } + + for (Entity ent : entities) + { + float rot = GET_ENTITY_HEADING(ent); + Vector3 velocity = GET_ENTITY_VELOCITY(ent); + float len = std::max(velocity.Length(), 3.f); + float y = sin((360 - rot) * PI / 180) * len * 2.5f; + float x = cos((360 - rot) * PI / 180) * len * 2.5f; + if (g_Random.GetRandomInt(0, 1)) + x = -x; + else + y = -y; + + SET_ENTITY_VELOCITY(ent, velocity.x + x, velocity.y + y, velocity.z); + } +} + +// clang-format off +REGISTER_EFFECT(OnStart, nullptr, nullptr, EffectInfo + { + .Name = "Shunt Boost", + .Id = "misc_shunt_boost" + } +); \ No newline at end of file diff --git a/ConfigApp/Effects.cs b/ConfigApp/Effects.cs index b03e5efe6..bf684ed50 100644 --- a/ConfigApp/Effects.cs +++ b/ConfigApp/Effects.cs @@ -415,6 +415,7 @@ public enum EffectTimedType { "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) }, + { "misc_shunt_boost", new EffectInfo("Shunt Boost", EffectCategory.Misc) }, }; } }