diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp index e0f79e6ba4..209bcbc1a2 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp @@ -910,6 +910,12 @@ ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions") ADD_ENUM(PreloadAreaOption::ALL, "all") IMPLEMENT_ENUM_CLASS_END("preload-area-option") + +IMPLEMENT_ENUM_CLASS_BEGIN(taskType) +ADD_ENUM(taskType::PRIMARY_TASK, "primary") +ADD_ENUM(taskType::SECONDARY_TASK, "secondary") +IMPLEMENT_ENUM_CLASS_END("tasks-types") + IMPLEMENT_ENUM_BEGIN(eEntityType) ADD_ENUM(ENTITY_TYPE_NOTHING, "unknown") ADD_ENUM(ENTITY_TYPE_BUILDING, "building") diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h index fc692a8f16..d755b4e5e3 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h @@ -88,8 +88,10 @@ DECLARE_ENUM(ePools); DECLARE_ENUM(eWorldProperty); DECLARE_ENUM_CLASS(eModelLoadState); DECLARE_ENUM_CLASS(PreloadAreaOption); +DECLARE_ENUM_CLASS(taskType); DECLARE_ENUM(eEntityType); + class CRemoteCall; enum eDXHorizontalAlign diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index f38096dcee..6caf245618 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -115,6 +115,7 @@ void CLuaPedDefs::LoadFunctions() {"isPedDucked", IsPedDucked}, {"isPedDead", IsPedDead}, {"isPedReloadingWeapon", IsPedReloadingWeapon}, + {"killPedTask", ArgumentParser}, }; // Add functions @@ -2493,3 +2494,20 @@ bool CLuaPedDefs::SetPedExitVehicle(CClientPed* pPed) { return pPed->ExitVehicle(); } + +bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept +{ + switch (taskType) + { + case taskType::PRIMARY_TASK: + { + return ped->KillTask(taskNumber, gracefully.value_or(true)); + } + case taskType::SECONDARY_TASK: + { + return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true)); + } + default: + return false; + } +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index d97a484d8e..76b9771332 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -115,4 +115,6 @@ class CLuaPedDefs : public CLuaDefs static bool SetPedExitVehicle(CClientPed* pPed); static bool IsPedBleeding(CClientPed* ped); static bool SetPedBleeding(CClientPed* ped, bool bleeding); + + static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional gracefully) noexcept; }; diff --git a/Client/sdk/game/CTaskManager.h b/Client/sdk/game/CTaskManager.h index 3467f34928..f89d145dd4 100644 --- a/Client/sdk/game/CTaskManager.h +++ b/Client/sdk/game/CTaskManager.h @@ -41,6 +41,13 @@ enum ABORT_PRIORITY_IMMEDIATE }; +enum taskType +{ + PRIMARY_TASK = 0, + SECONDARY_TASK +}; + + class CTaskManager { public: