Skip to content

Add support for driving and being a passenger in client-side vehicles, client-side vehicle damage and animated vehicle entering/exiting through new functions for client-side peds/local players #620

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1c861ce
Add support for driving and being a passenger in client-side vehicles…
MegadreamsBE Sep 30, 2018
956db60
Added support for "onClientVehicleStartEnter", "onClientVehicleEnter"…
MegadreamsBE Sep 30, 2018
b3ce972
Enabled damage for client-side vehicles that haven't been entered yet.
MegadreamsBE Oct 18, 2018
615cc9c
Added "getPedNearestCarEntryPoint" and resolved some glitches with ca…
MegadreamsBE Oct 18, 2018
a976eba
Added proper support for client-side ped carjacking.
MegadreamsBE Oct 18, 2018
b737666
Added "setPedEnterVehicle" and "setPedLeaveVehicle" to control client…
MegadreamsBE Oct 21, 2018
8b39b2a
Modified "warpPedIntoVehicle" and "removePedFromVehicle" to allow you…
MegadreamsBE Oct 21, 2018
a8d82b0
Merge branch 'master' into feature/improve-client-side-vehicles
MegadreamsBE Oct 26, 2018
5deae7c
Prevent projectiles and explosions from client-side from syncing.
MegadreamsBE Oct 30, 2018
479bdd6
Prevent projectiles and explosions from client-side vehicles from syn…
MegadreamsBE Oct 30, 2018
3f1912e
Merge branch 'feature/improve-client-side-vehicles' of git@github.com…
MegadreamsBE Oct 30, 2018
e741466
Reset InOut state when using setPedAnimation
MegadreamsBE Apr 25, 2019
e5d6b9a
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
MegadreamsBE Apr 25, 2019
ecd6692
Added cancelPedEnterVehicle and fixed ped vehicle state glitch
MegadreamsBE Apr 26, 2019
d0ab6ad
Fix network trouble when carjacking gets abandoned and fix for softlo…
MegadreamsBE Apr 27, 2019
2f5a8c3
Added getPedEnterVehicleTarget and modified getPedNearestVehicleEntry…
MegadreamsBE Apr 27, 2019
c2f0c5c
Added getVehicleEntryPoints
MegadreamsBE Apr 27, 2019
f2c0240
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
MegadreamsBE Feb 26, 2020
0bd6de1
Merge branch 'master' into feature/improve-client-side-vehicles
qaisjp Apr 2, 2020
2025cd9
Merge branch 'master' of github.com:multitheftauto/mtasa-blue into fe…
MegadreamsBE Oct 17, 2020
5f7118e
Remove ASM code
MegadreamsBE Oct 17, 2020
13b3f3b
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
MegadreamsBE Oct 27, 2020
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
13 changes: 13 additions & 0 deletions Client/game_sa/CCarEnterExitSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,16 @@ bool CCarEnterExitSA::IsRoomForPedToLeaveCar(CVehicle* pVehicle, int iDoor, CVec

return bRet;
}

void CCarEnterExitSA::GetPositionToOpenCarDoor(CVector& vecPosition, CVehicle* pVehicle, unsigned int uiDoor)
{
CVehicleSA* pVehicleSA = dynamic_cast<CVehicleSA*>(pVehicle);

if (pVehicleSA)
{
CVehicleSAInterface* pVehicleInterface = pVehicleSA->GetVehicleInterface();

auto CCarEnterExit_GetPositionToOpenCarDoor = (void(__cdecl*)(CVector&, CVehicleSAInterface*, int))FUNC_GetPositionToOpenCarDoor;
CCarEnterExit_GetPositionToOpenCarDoor(vecPosition, pVehicleInterface, uiDoor);
}
}
2 changes: 2 additions & 0 deletions Client/game_sa/CCarEnterExitSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define FUNC_GetNearestCarPassengerDoor 0x650BB0
#define FUNC_ComputeTargetDoorToExit 0x64F110
#define FUNC_IsRoomForPedToLeaveCar 0x6504C0
#define FUNC_GetPositionToOpenCarDoor 0x64E740

class CCarEnterExitSA : public CCarEnterExit
{
Expand All @@ -27,4 +28,5 @@ class CCarEnterExitSA : public CCarEnterExit
bool GetNearestCarPassengerDoor(CPed* pPed, CVehicle* pVehicle, CVector* pVector, int* pDoor, bool bUnknown, bool bUnknown2, bool bCheckIfRoomToGetIn);
int ComputeTargetDoorToExit(CPed* pPed, CVehicle* pVehicle);
bool IsRoomForPedToLeaveCar(CVehicle* pVehicle, int iDoor, CVector* pUnknown = 0);
void GetPositionToOpenCarDoor(CVector& vecPosition, CVehicle* pVehicle, unsigned int uiDoor);
};
22 changes: 22 additions & 0 deletions Client/mods/deathmatch/logic/CClientExplosionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ bool CClientExplosionManager::Hook_ExplosionCreation(CEntity* pGameExplodingEnti
if (!bIsLocalPlayer && !bIsLocalPlayerVehicle && !bIsUnoccupiedVehicleSynced)
return false;

if (bIsLocalPlayer || bIsLocalPlayerVehicle)
{
CClientEntity* pOriginSource = NULL;

// Check if the "weapon" used was a rocket or a tank grenade.
if (explosionWeaponType == WEAPONTYPE_ROCKET || explosionWeaponType == WEAPONTYPE_TANK_GRENADE)
{
CClientVehicle* pOccupiedVehicle = pLocalPlayer->GetOccupiedVehicle();

// Is the player in a vehicle?
if (pOccupiedVehicle)
{
// Is the vehicle only available locally?
if (pOccupiedVehicle->IsLocalEntity())
{
// It is pretty safe to asume this was a projectile from a client-side vehicle driven by the player. Abort.
return true;
}
}
}
}

CClientEntity* pOriginSource = nullptr;

// Is this an exploding vehicle?
Expand Down
745 changes: 535 additions & 210 deletions Client/mods/deathmatch/logic/CClientGame.cpp

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ class CClientGame
bool GetDamageSent() { return m_bDamageSent; }
void SetDamageSent(bool b) { m_bDamageSent = b; }

bool ProcessExitVehicle();
bool ProcessEnterVehicle(CClientVehicle* pVehicle, unsigned int uiSeat, unsigned int uiDoor);
void ProcessVehicleInOutKey(bool bPassenger);

void ResetVehicleInOut();
Expand Down Expand Up @@ -605,6 +607,14 @@ class CClientGame
void SendFireSync(CFire* pFire);
void SendProjectileSync(CClientProjectile* pProjectile);

void SetGettingOutOfVehicle(bool bGettingOutOfVehicle) { m_bIsGettingOutOfVehicle = bGettingOutOfVehicle; };
void SetGettingIntoVehicle(bool bGettingIntoVehicle) { m_bIsGettingIntoVehicle = bGettingIntoVehicle; };
void SetVehicleInOutID(ElementID vehicleInOutID) { m_VehicleInOutID = vehicleInOutID; };
void SetVehicleInOutSeat(unsigned char ucVehicleInOutSeat) { m_ucVehicleInOutSeat = ucVehicleInOutSeat; };

void SetGettingJacked(bool bIsGettingJacked) { m_bIsGettingJacked = bIsGettingJacked; };
void SetGettingJackedBy(CClientPed* pJacker) { m_pGettingJackedBy = pJacker; };

void SetServerVersionSortable(const SString& strVersion) { m_strServerVersionSortable = strVersion; }
const SString& GetServerVersionSortable() { return m_strServerVersionSortable; }

Expand Down Expand Up @@ -729,13 +739,14 @@ class CClientGame
unsigned long m_ulLastVehicleInOutTime;
bool m_bIsGettingOutOfVehicle;
bool m_bIsGettingIntoVehicle;
CClientPed* m_pJackingPed;
bool m_bIsJackingVehicle;
bool m_bIsGettingJacked;
ElementID m_VehicleInOutID;
unsigned char m_ucVehicleInOutSeat;
bool m_bNoNewVehicleTask;
ElementID m_NoNewVehicleTaskReasonID;
CClientPlayer* m_pGettingJackedBy;
CClientPed* m_pGettingJackedBy;

CEntity* m_pTargetedGameEntity;
CClientEntity* m_pTargetedEntity;
Expand Down
Loading