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: Pepega Traffic #3594

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion ChaosMod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ file(GLOB ROOT_SRC ${PROJECT_SOURCE_DIR}/*.cpp)
file(GLOB_RECURSE SRC ${PROJECT_SOURCE_DIR}/Components/*.cpp ${PROJECT_SOURCE_DIR}/Effects/*.cpp
${PROJECT_SOURCE_DIR}/Memory/*.cpp ${PROJECT_SOURCE_DIR}/Util/*.cpp)
file(GLOB PATTERNS_SRC ${PROJECT_SOURCE_DIR}/../vendor/Patterns/Patterns.cpp)
add_library(ChaosMod MODULE ${ROOT_SRC} ${SRC} ${PATTERNS_SRC} ChaosMod.rc)
add_library(ChaosMod MODULE ${ROOT_SRC} ${SRC} ${PATTERNS_SRC} ChaosMod.rc "Effects/db/Vehs/VehsPepegaTraffic.cpp")

set_property(TARGET ChaosMod PROPERTY CXX_STANDARD 20)

Expand Down
85 changes: 85 additions & 0 deletions ChaosMod/Effects/db/Vehs/VehsPepegaTraffic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Effect by Bad Koa
*/

#include <stdafx.h>

enum DriveTasks
{
BRAKE, // 1
BRAKE_REVERSE, // 3
LEFT_90_BRAKE, // 4
RIGHT_90_BRAKE, // 5
BRAKE_STRONG, // 6
LEFT_ACCEL, // 7
RIGHT_ACCEL, // 8
LEFT_RESTORE_WHELL, // 10
RIGTH_RESTORE_WHELL, // 11
LEFT_GO_REVERSE, // 13
RIGTH_GO_REVERSE, // 14
STRONGBRAKE_TURN, // 19
WEAKBRAKE_TURN_LEFTRIGHT, // 20
WEAKBRAKE_TURN_RIGHTLEFT, // 21
ACCEL_FAST, // 23
BRAKE_TURNLEFT_MORELEFT, // 25
BRAKE_TURNIGHT_MORERIGHT, // 26
BRAKE_TILLSTOP, // 27
BRAKE_REVERSEACCEL, // 28
BURNOUT, // 30
ACCEL_HANDBRAKE, // 31
ACCEL_HARD // 32
};

struct DriveTaskData
{
DriveTasks task;
int taskValue;
};

static std::vector<DriveTaskData> validTasks = { { LEFT_ACCEL, 7 },
{ RIGHT_ACCEL, 8 },
{ LEFT_RESTORE_WHELL, 10 },
{ RIGTH_RESTORE_WHELL, 11 },
{ LEFT_GO_REVERSE, 13 },
{ RIGTH_GO_REVERSE, 14 },
{ WEAKBRAKE_TURN_LEFTRIGHT, 20 },
{ WEAKBRAKE_TURN_RIGHTLEFT, 21 },
{ ACCEL_FAST, 23 },
{ BRAKE_REVERSEACCEL, 28 },
{ BURNOUT, 30 },
{ ACCEL_HANDBRAKE, 31 },
{ ACCEL_HARD, 32 } };

static void OnTick()
{
static DWORD64 lastTick = 0;
DWORD64 curTick = GET_GAME_TIMER();

DWORD64 taskPeriod = g_Random.GetRandomInt(1000, 1500);

// Check if the task period has passed
if (curTick - lastTick >= taskPeriod)
{
lastTick = curTick;

for (Ped ped : GetAllPeds())
{
if (DOES_ENTITY_EXIST(ped) && !IS_PED_A_PLAYER(ped) && IS_PED_IN_ANY_VEHICLE(ped, false))
{
DriveTaskData task = validTasks.at(g_Random.GetRandomInt(0, validTasks.size() - 1));
Vehicle veh = GET_VEHICLE_PED_IS_IN(ped, false);
TASK_VEHICLE_TEMP_ACTION(ped, veh, task.taskValue, taskPeriod);
}
}
}
}

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