Skip to content

Commit

Permalink
add killPedTask function (#3808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Proxy-99 authored Dec 21, 2024
1 parent 5b59e22 commit e4a502b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void CLuaPedDefs::LoadFunctions()
{"isPedDucked", IsPedDucked},
{"isPedDead", IsPedDead},
{"isPedReloadingWeapon", IsPedReloadingWeapon},
{"killPedTask", ArgumentParser<killPedTask>},
};

// Add functions
Expand Down Expand Up @@ -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<bool> 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;
}
}
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> gracefully) noexcept;
};
7 changes: 7 additions & 0 deletions Client/sdk/game/CTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ enum
ABORT_PRIORITY_IMMEDIATE
};

enum taskType
{
PRIMARY_TASK = 0,
SECONDARY_TASK
};


class CTaskManager
{
public:
Expand Down

0 comments on commit e4a502b

Please sign in to comment.