Skip to content
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
17 changes: 14 additions & 3 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void CClientPed::Init(CClientManager* pManager, unsigned long ulModelID, bool bI
m_pTaskManager = NULL;
m_pOccupiedVehicle = NULL;
m_pOccupyingVehicle = NULL;
// m_uiOccupyingSeat = 0;
m_uiOccupyingSeat = 0;
m_uiOccupiedVehicleSeat = 0xFF;
m_bHealthLocked = false;
m_bDontChangeRadio = false;
Expand Down Expand Up @@ -1464,7 +1464,7 @@ void CClientPed::WarpIntoVehicle(CClientVehicle* pVehicle, unsigned int uiSeat)
CClientVehicle* pPrevVehicle = GetRealOccupiedVehicle();
// Eventually remove us from a previous vehicle
RemoveFromVehicle();
// m_uiOccupyingSeat = uiSeat;
m_uiOccupyingSeat = uiSeat;
m_bForceGettingIn = false;
m_bForceGettingOut = false;
m_ucLeavingDoor = 0xFF;
Expand Down Expand Up @@ -7279,4 +7279,15 @@ void CClientPed::RunSwimTask() const

inWaterTask->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_EVENT_RESPONSE_NONTEMP, true);
}


bool CClientPed::IsEnteringToVehicle()
{
int inOutState = GetVehicleInOutState();
return inOutState == VEHICLE_INOUT_GETTING_IN || inOutState == VEHICLE_INOUT_JACKING;
}

bool CClientPed::IsExitingFromVehicle()
{
int inOutState = GetVehicleInOutState();
return inOutState == VEHICLE_INOUT_GETTING_OUT || inOutState == VEHICLE_INOUT_GETTING_JACKED;
}
7 changes: 6 additions & 1 deletion Client/mods/deathmatch/logic/CClientPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
CClientVehicle* GetOccupyingVehicle() noexcept { return m_pOccupyingVehicle; };
const CClientVehicle* GetOccupyingVehicle() const noexcept { return m_pOccupyingVehicle; };

unsigned int GetOccupyingVehicleSeat() const noexcept { return m_uiOccupyingSeat; };

CClientVehicle* GetRealOccupiedVehicle();
CClientVehicle* GetClosestEnterableVehicle(bool bGetPositionFromClosestDoor, bool bCheckDriverDoor, bool bCheckPassengerDoors,
bool bCheckStreamedOutVehicles, unsigned int* uiClosestDoor = NULL, CVector* pClosestDoorPosition = NULL,
Expand All @@ -267,6 +269,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
void WarpIntoVehicle(CClientVehicle* pVehicle, unsigned int uiSeat = 0);
CClientVehicle* RemoveFromVehicle(bool bIgnoreIfGettingOut = false);

bool IsEnteringToVehicle();
bool IsExitingFromVehicle();

bool IsVisible();
void SetVisible(bool bVisible);
bool GetUsesCollision();
Expand Down Expand Up @@ -644,7 +649,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
unsigned long m_ulLastOnScreenTime;
CClientVehiclePtr m_pOccupiedVehicle;
CClientVehiclePtr m_pOccupyingVehicle;
// unsigned int m_uiOccupyingSeat;
unsigned int m_uiOccupyingSeat;
unsigned int m_uiOccupiedVehicleSeat;
bool m_bForceGettingIn;
bool m_bForceGettingOut;
Expand Down
5 changes: 2 additions & 3 deletions Client/mods/deathmatch/logic/CClientVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4139,8 +4139,7 @@ void CClientVehicle::SetPedOccupyingVehicle(CClientPed* pClientPed, CClientVehic

// Ped vars
pClientPed->m_pOccupyingVehicle = pVehicle;
// if ( uiSeat >= 0 && uiSeat < 8 )
// pClientPed->m_uiOccupyingSeat = uiSeat;
pClientPed->m_uiOccupyingSeat = uiSeat;

if (ucDoor != 0xFF)
pVehicle->AllowDoorRatioSetting(ucDoor, false);
Expand Down Expand Up @@ -4266,7 +4265,7 @@ void CClientVehicle::UnpairPedAndVehicle(CClientPed* pClientPed, CClientVehicle*
{
INFO(("UnpairPedAndVehicle: pClientPed:%s from m_pOccupyingVehicle:0x%08x", GetPlayerName(pClientPed).c_str(), pVehicle));
pClientPed->m_pOccupyingVehicle = NULL;
// pClientPed->m_uiOccupyingSeat = 0xFF;
pClientPed->m_uiOccupyingSeat = NULL;
}
}

Expand Down
33 changes: 33 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ void CLuaPedDefs::LoadFunctions()
{"getPedTotalAmmo", GetPedTotalAmmo},
{"getPedOccupiedVehicle", GetPedOccupiedVehicle},
{"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat},
{"isPedEnteringToVehicle", ArgumentParser<IsPedEnteringToVehicle>},
{"isPedExitingFromVehicle", ArgumentParser<IsPedExitingFromVehicle>},
{"getPedVehicleEnteringTo", ArgumentParser<GetPedVehicleEnteringTo>},
{"getPedVehicleEnteringToSeat", ArgumentParser<GetPedVehicleEnteringToSeat>},

{"getPedBonePosition", GetPedBonePosition},
{"getPedClothes", GetPedClothes},
{"getPedMoveState", GetPedMoveState},
Expand Down Expand Up @@ -155,6 +160,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getMoveState", "getPedMoveState");
lua_classfunction(luaVM, "getOccupiedVehicle", "getPedOccupiedVehicle");
lua_classfunction(luaVM, "getOccupiedVehicleSeat", "getPedOccupiedVehicleSeat");
lua_classfunction(luaVM, "getVehicleEnteringTo", "getPedVehicleEnteringTo");
lua_classfunction(luaVM, "getVehicleEnteringToSeat", "getPedVehicleEnteringToSeat");
lua_classfunction(luaVM, "getOxygenLevel", "getPedOxygenLevel");
lua_classfunction(luaVM, "getStat", "getPedStat");
lua_classfunction(luaVM, "getTarget", "getPedTarget");
Expand Down Expand Up @@ -213,6 +220,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle");
lua_classfunction(luaVM, "setBleeding", "setPedBleeding");
lua_classfunction(luaVM, "playVoiceLine", "playPedVoiceLine");
lua_classfunction(luaVM, "isEnteringToVehicle", "isPedEnteringToVehicle");
lua_classfunction(luaVM, "isExitingFromVehicle", "isPedExitingFromVehicle");

lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat");
Expand All @@ -232,6 +241,10 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "ducked", NULL, "isPedDucked");
lua_classvariable(luaVM, "headless", "setPedHeadless", "isPedHeadless");
lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle");
lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle");
lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle");
lua_classvariable(luaVM, "vehicleEnteringTo", NULL, "getPedVehicleEnteringTo");
lua_classvariable(luaVM, "vehicleEnteringToSeat", NULL, "getPedVehicleEnteringToSeat");
lua_classvariable(luaVM, "onFire", "setPedOnFire", "isPedOnFire");
lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround");
lua_classvariable(luaVM, "dead", NULL, "isPedDead");
Expand Down Expand Up @@ -2560,3 +2573,23 @@ void CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<

ped->Say(speechContextId, probability.value_or(1.0f));
}

bool CLuaPedDefs::IsPedEnteringToVehicle(CClientPed* const ped) noexcept
{
return ped->IsEnteringToVehicle();
}

bool CLuaPedDefs::IsPedExitingFromVehicle(CClientPed* const ped) noexcept
{
return ped->IsExitingFromVehicle();
}

CClientVehicle* CLuaPedDefs::GetPedVehicleEnteringTo(CClientPed* const ped)
{
return ped->GetOccupyingVehicle();
}

int CLuaPedDefs::GetPedVehicleEnteringToSeat(CClientPed* const ped)
{
return ped->GetOccupyingVehicleSeat();
}
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,8 @@ class CLuaPedDefs : public CLuaDefs
static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully);

static void PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probability);
static bool IsPedEnteringToVehicle(CClientPed* const ped) noexcept;
static bool IsPedExitingFromVehicle(CClientPed* const ped) noexcept;
static CClientVehicle* GetPedVehicleEnteringTo(CClientPed* const ped);
static int GetPedVehicleEnteringToSeat(CClientPed* const ped);
};
16 changes: 16 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ void CLuaPedDefs::LoadFunctions()
{"getPedOccupiedVehicle", GetPedOccupiedVehicle},
{"getPedOccupiedVehicleSeat", GetPedOccupiedVehicleSeat},
{"isPedInVehicle", IsPedInVehicle},
{"isPedEnteringToVehicle", ArgumentParser<IsPedEnteringToVehicle>},
{"isPedExitingFromVehicle", ArgumentParser<IsPedExitingFromVehicle>},
{"isPedReloadingWeapon", ArgumentParser<IsPedReloadingWeapon>},

// Ped set functions
Expand Down Expand Up @@ -120,6 +122,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "isHeadless", "isPedHeadless");
lua_classfunction(luaVM, "isWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846
lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon");
lua_classfunction(luaVM, "isEnteringToVehicle", "isPedEnteringToVehicle");
lua_classfunction(luaVM, "isExitingFromVehicle", "isPedExitingFromVehicle");

lua_classfunction(luaVM, "getArmor", "getPedArmor");
lua_classfunction(luaVM, "getFightingStyle", "getPedFightingStyle");
Expand Down Expand Up @@ -153,6 +157,8 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846

lua_classvariable(luaVM, "inVehicle", NULL, "isPedInVehicle");
lua_classvariable(luaVM, "enteringToVehicle", NULL, "isPedEnteringToVehicle");
lua_classvariable(luaVM, "exitingFromVehicle", NULL, "isPedExitingFromVehicle");
lua_classvariable(luaVM, "ducked", NULL, "isPedDucked");
lua_classvariable(luaVM, "inWater", NULL, "isPedInWater");
lua_classvariable(luaVM, "onGround", NULL, "isPedOnGround");
Expand Down Expand Up @@ -1555,3 +1561,13 @@ int CLuaPedDefs::TakeAllWeapons(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

bool CLuaPedDefs::IsPedEnteringToVehicle(CPed* const ped) noexcept
{
return ped->GetVehicleAction() == CPed::VEHICLEACTION_ENTERING;
}

bool CLuaPedDefs::IsPedExitingFromVehicle(CPed* const ped) noexcept
{
return ped->GetVehicleAction() == CPed::VEHICLEACTION_EXITING;
}
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(GetPedOccupiedVehicle);
LUA_DECLARE(GetPedOccupiedVehicleSeat);
LUA_DECLARE(IsPedInVehicle);
static bool IsPedEnteringToVehicle(CPed* const ped) noexcept;
static bool IsPedExitingFromVehicle(CPed* const ped) noexcept;
LUA_DECLARE(GetPedAmmoInClip);
LUA_DECLARE(GetPedTotalAmmo);
static bool IsPedReloadingWeapon(CPed* const ped) noexcept;
Expand Down