From 94ab5b9437a048747792db134dd37f95cd0f31c6 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:23:15 +0800 Subject: [PATCH] [bot] Implement/match `n_GetPlayerHealth(...)` * Implement/match `CNetGame::GetPlayerHealth(...)` --- README.md | 33 --------------------------------- bot/net/netgame.cpp | 23 +++++++++++++++++++++++ bot/net/netgame.h | 1 + bot/scrcustom.cpp | 5 ++++- 4 files changed, 28 insertions(+), 34 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 4861b94..0000000 --- a/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# San Andreas Multiplayer -This is an ongoing matching decompilation of the 0.3.7 version of San Andreas Multiplayer. -## Status -- [ ] **samp.exe** - Mostly decompiled. Not matching due to issues with PACKAGEINFO. -- [ ] **samp.dll** - Incomplete. -- [x] **rcon.exe** - Fully decompiled. -- [x] **samp_debug.exe** - Fully decompiled. -- [ ] **samp-server.exe** - Incomplete. -- [ ] **samp03svr** - Incomplete. -- [x] **announce.exe** - Fully decompiled. -- [ ] **announce** - System and the GCC version not have been determined. -- [ ] **samp-npc.exe** - Incomplete. -- [ ] **samp-npc** - Incomplete. - -## Building -### Requirements -- A clean virtual machine with Windows XP installed -- Microsoft Visual C++ 6.0 -- Microsoft Visual C++ 6.0 (Service Pack 6) -- Microsoft Visual Studio .NET 2003 -- Borland Delphi 7 - -Note(s): -- Make a backup of your Microsoft Visual C++ 6.0 installation before you install Service Pack 6 update. This update will overwrite your compiler binaries and alter your building results. You can find your Visual C++ 6.0 installation at `C:\Program Files\Microsoft Visual Studio`. - -### Compiling -#### Windows -TODO -#### Linux -TODO - -## Contributing -If you are interested in this decompilation project, feel free to create a pull request. diff --git a/bot/net/netgame.cpp b/bot/net/netgame.cpp index 663b3c4..82530b2 100644 --- a/bot/net/netgame.cpp +++ b/bot/net/netgame.cpp @@ -142,6 +142,29 @@ BYTE CNetGame::GetPlayerArmedWeapon(PLAYERID playerId) } } +BYTE CNetGame::GetPlayerHealth(PLAYERID playerId) +{ + if(playerId >= MAX_PLAYERS) return 0; + if(bPlayerSlotState[playerId] == FALSE) return 0; + + if(bytePlayerState[playerId] == PLAYER_STATE_ONFOOT) + { + return unnamed_3[playerId].byteHealth; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_DRIVER) + { + return unnamed_4[playerId].bytePlayerHealth; + } + else if(bytePlayerState[playerId] == PLAYER_STATE_PASSENGER) + { + return unnamed_5[playerId].bytePlayerHealth; + } + else + { + return 0; + } +} + //---------------------------------------------------- // MATCH BOOL CNetGame::IsPlayerAdded(PLAYERID playerId) diff --git a/bot/net/netgame.h b/bot/net/netgame.h index cfd833f..b058d94 100644 --- a/bot/net/netgame.h +++ b/bot/net/netgame.h @@ -111,6 +111,7 @@ public: BOOL GetPlayerPos(PLAYERID playerId, PVECTOR Vector); VEHICLEID GetPlayerVehicleID(PLAYERID playerId); BYTE GetPlayerArmedWeapon(PLAYERID playerId); + BYTE GetPlayerHealth(PLAYERID playerId); void StopRecordingPlayback(); void PauseRecordingPlayback(); diff --git a/bot/scrcustom.cpp b/bot/scrcustom.cpp index df1d77d..e9b61c2 100644 --- a/bot/scrcustom.cpp +++ b/bot/scrcustom.cpp @@ -186,7 +186,10 @@ static cell AMX_NATIVE_CALL n_GetPlayerArmedWeapon(AMX *amx, cell *params) // native GetPlayerHealth(playerid) static cell AMX_NATIVE_CALL n_GetPlayerHealth(AMX *amx, cell *params) { - // TODO: n_GetPlayerHealth + if(pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)params[1])) + { + return (cell)pNetGame->GetPlayerHealth((PLAYERID)params[1]); + } return 0; }