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

add killPedTask function #3808

Open
wants to merge 11 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
5 changes: 5 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,11 @@ 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")

//
// CResource from userdata
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ DECLARE_ENUM(ePools);
DECLARE_ENUM(eWorldProperty);
DECLARE_ENUM_CLASS(eModelLoadState);
DECLARE_ENUM_CLASS(PreloadAreaOption);
DECLARE_ENUM_CLASS(taskType);

class CRemoteCall;

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be consistent with another code. eTaskType. It's not a part of hungarian notation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what letter e reference to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enumeration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can use hungarian notation with enums?
I mean I don't see any benefits of using that format

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can use hungarian notation with enums? I mean I don't see any benefits of using that format

Using e for enumartion is not considered Hungarian notation, it's a different principle and a practiced used in all code

{
PRIMARY_TASK = 0,
SECONDARY_TASK
};


class CTaskManager
{
public:
Expand Down
Loading