2024-02-15 22:23:36 +08:00
|
|
|
|
|
|
|
#include "../main.h"
|
|
|
|
#include "util.h"
|
2024-05-03 22:07:17 +08:00
|
|
|
#include "keystuff.h"
|
2024-05-03 22:10:08 +08:00
|
|
|
#include "task.h"
|
2024-05-03 22:07:17 +08:00
|
|
|
|
2024-05-03 22:09:09 +08:00
|
|
|
extern CGame *pGame;
|
|
|
|
|
2024-05-03 22:07:17 +08:00
|
|
|
extern BYTE *pbyteCurrentPlayer;
|
2024-02-15 22:23:36 +08:00
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Used for instancing the local player.
|
|
|
|
|
|
|
|
CPlayerPed::CPlayerPed()
|
|
|
|
{
|
|
|
|
m_dwGTAId = 1; // 0x001
|
|
|
|
m_pPed = GamePool_FindPlayerPed();
|
|
|
|
m_pEntity = (ENTITY_TYPE *)GamePool_FindPlayerPed();
|
|
|
|
|
|
|
|
m_bytePlayerNumber = 0;
|
|
|
|
SetPlayerPedPtrRecord(m_bytePlayerNumber,(DWORD)m_pPed);
|
|
|
|
ScriptCommand(&set_actor_weapon_droppable,m_dwGTAId,1);
|
|
|
|
|
|
|
|
ScriptCommand(&set_actor_can_be_decapitated,m_dwGTAId,0);
|
|
|
|
|
|
|
|
field_2A8 = 1;
|
|
|
|
field_2AC = 1;
|
2024-05-05 18:57:12 +08:00
|
|
|
m_dwArrow = 0;
|
2024-02-15 22:23:36 +08:00
|
|
|
field_2B9 = 0;
|
|
|
|
field_2F2 = 0;
|
|
|
|
field_2D2 = 0;
|
|
|
|
field_2DE = 0;
|
|
|
|
field_2E2 = 0;
|
|
|
|
field_48 = 0;
|
2024-05-03 21:48:31 +08:00
|
|
|
m_bGoggleState = FALSE;
|
2024-02-15 22:23:36 +08:00
|
|
|
field_2C1 = 0;
|
|
|
|
field_2C5 = 0;
|
|
|
|
field_2C9 = 0;
|
|
|
|
field_2F6 = 0;
|
|
|
|
field_2F7 = 0;
|
|
|
|
field_2F8 = 0;
|
|
|
|
|
|
|
|
int x=0;
|
|
|
|
while(x!=10) {
|
|
|
|
field_4C[x];
|
|
|
|
field_27C[x] = 0;
|
|
|
|
memset(&field_74[x], 0, sizeof(struc_97));
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
field_2F9 = 0;
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:29:24 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// If the game has internally destroyed the ped
|
|
|
|
// during this frame, the ped pointer should become 0
|
|
|
|
|
|
|
|
void CPlayerPed::ResetPointers()
|
|
|
|
{
|
|
|
|
m_pPed = GamePool_Ped_GetAt(m_dwGTAId);
|
|
|
|
m_pEntity = (ENTITY_TYPE *)m_pPed;
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:30:43 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetInitialState()
|
|
|
|
{
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
//int iPlayerNumber = 0;
|
|
|
|
//DWORD dwPlayerActorID = 0;
|
|
|
|
|
|
|
|
_asm push 0
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov edx, 0x60CD20 ; internal_CPlayerPed_SetInitialState
|
|
|
|
_asm call edx
|
|
|
|
|
|
|
|
/* DESTROY METHOD
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov ebx, [ecx] ; vtable
|
|
|
|
_asm push 1
|
|
|
|
_asm call [ebx] ; destroy
|
|
|
|
*/
|
|
|
|
|
|
|
|
// CREATE PLAYER
|
|
|
|
/*
|
|
|
|
ScriptCommand(&create_player, &iPlayerNumber, x, y, z, &dwPlayerActorID);
|
|
|
|
ScriptCommand(&create_actor_from_player,&iPlayerNumber,&dwPlayerActorID);
|
|
|
|
|
|
|
|
m_dwGTAId = dwPlayerActorID;
|
|
|
|
m_pPed = GamePool_Ped_GetAt(m_dwGTAId);
|
|
|
|
m_bytePlayerNumber = 0;
|
|
|
|
m_pEntity = (ENTITY_TYPE *)GamePool_Ped_GetAt(m_dwGTAId);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:32:43 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BYTE CPlayerPed::GetSpecialKey()
|
|
|
|
{
|
|
|
|
GTA_CONTROLSET *pInternalKeys = GameGetInternalKeys();
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[11]) // yes
|
|
|
|
return 1;
|
|
|
|
else if(pInternalKeys->wKeys1[10]) // no
|
|
|
|
return 2;
|
|
|
|
else if(pInternalKeys->wKeys1[9]) // honk
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-05 18:34:54 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
CAMERA_AIM * CPlayerPed::GetCurrentAim()
|
|
|
|
{
|
|
|
|
return GameGetInternalAim();
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:37:07 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetCurrentAim(CAMERA_AIM *pAim)
|
|
|
|
{
|
|
|
|
GameStoreRemotePlayerAim(m_bytePlayerNumber, pAim);
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:52:08 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BYTE CPlayerPed::GetCurrentWeapon()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0;
|
|
|
|
if(GamePool_Ped_GetAt(m_dwGTAId) == 0) return 0;
|
|
|
|
|
|
|
|
DWORD dwRetVal;
|
|
|
|
ScriptCommand(&get_actor_armed_weapon,m_dwGTAId,&dwRetVal);
|
|
|
|
return (BYTE)dwRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
2024-05-05 18:54:54 +08:00
|
|
|
|
|
|
|
int CPlayerPed::GetCurrentVehicleID()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0;
|
|
|
|
|
|
|
|
VEHICLE_TYPE *pVehicle = (VEHICLE_TYPE *)m_pPed->pVehicle;
|
|
|
|
return GamePool_Vehicle_GetIndex(pVehicle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-05 18:57:12 +08:00
|
|
|
void CPlayerPed::HideMarker()
|
|
|
|
{
|
|
|
|
if (m_dwArrow) ScriptCommand(&disable_marker, m_dwArrow);
|
|
|
|
m_dwArrow = NULL; // Just make sure
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-05 18:59:28 +08:00
|
|
|
BOOL CPlayerPed::IsOnScreen()
|
|
|
|
{
|
|
|
|
if(m_pPed) return GameIsEntityOnScreen((DWORD *)m_pPed);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-05 19:02:17 +08:00
|
|
|
void CPlayerPed::SetImmunities(BOOL bBullet, BOOL bFire, BOOL bExplosion, BOOL bDamage, BOOL bUnknown)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(GamePool_Ped_GetAt(m_dwGTAId) == 0) return;
|
|
|
|
|
|
|
|
ScriptCommand(&set_actor_immunities, m_dwGTAId, bBullet, bFire, bExplosion, bDamage, bUnknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 22:09:09 +08:00
|
|
|
void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
int iModelID = 0;
|
|
|
|
iModelID = GameGetWeaponModelIDFromWeaponID(iWeaponID);
|
|
|
|
|
|
|
|
if(iModelID == -1) return;
|
|
|
|
|
|
|
|
if(!pGame->IsModelLoaded(iModelID)) {
|
|
|
|
pGame->RequestModel(iModelID);
|
|
|
|
pGame->LoadRequestedModels();
|
|
|
|
while(!pGame->IsModelLoaded(iModelID)) Sleep(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//ScriptCommand(&give_actor_weapon,this->m_dwGTAId,iWeaponID,iAmmo);
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = m_bytePlayerNumber;
|
|
|
|
|
|
|
|
GameStoreLocalPlayerWeaponSkills();
|
|
|
|
GameSetRemotePlayerWeaponSkills(m_bytePlayerNumber);
|
|
|
|
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm push 1
|
|
|
|
_asm push iAmmo
|
|
|
|
_asm push iWeaponID
|
|
|
|
_asm mov edx, 0x5E6080
|
|
|
|
_asm call edx
|
|
|
|
|
|
|
|
GameSetLocalPlayerWeaponSkills();
|
|
|
|
|
|
|
|
SetArmedWeapon(iWeaponID, false);
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = 0;
|
|
|
|
|
|
|
|
//pGame->RemoveModel(iModelID);
|
|
|
|
}
|
|
|
|
|
2024-02-15 22:23:36 +08:00
|
|
|
//-----------------------------------------------------------
|
2024-05-03 21:48:31 +08:00
|
|
|
|
2024-05-03 22:07:17 +08:00
|
|
|
void CPlayerPed::SetArmedWeapon(int iWeaponType, bool bUnk)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = m_bytePlayerNumber;
|
|
|
|
|
|
|
|
GameStoreLocalPlayerWeaponSkills();
|
|
|
|
GameSetRemotePlayerWeaponSkills(m_bytePlayerNumber);
|
|
|
|
|
|
|
|
if(m_pPed && IN_VEHICLE(m_pPed) || bUnk)
|
|
|
|
{
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
if(dwPedPtr) {
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm push iWeaponType
|
|
|
|
_asm mov edx, 0x5E6280
|
|
|
|
_asm call edx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ScriptCommand(&set_actor_armed_weapon,m_dwGTAId,iWeaponType);
|
|
|
|
|
|
|
|
GameSetLocalPlayerWeaponSkills();
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 21:56:41 +08:00
|
|
|
WEAPON_SLOT_TYPE * CPlayerPed::GetCurrentWeaponSlot()
|
|
|
|
{
|
|
|
|
if(m_pPed) {
|
|
|
|
return &m_pPed->WeaponSlots[m_pPed->byteCurWeaponSlot];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 22:10:53 +08:00
|
|
|
BOOL CPlayerPed::HasAmmoForCurrentWeapon()
|
|
|
|
{
|
|
|
|
if(m_pPed) {
|
|
|
|
WEAPON_SLOT_TYPE * WeaponSlot = GetCurrentWeaponSlot();
|
|
|
|
|
|
|
|
if(!WeaponSlot) return TRUE;
|
|
|
|
|
|
|
|
// Melee types always have ammo.
|
|
|
|
if( WeaponSlot->dwType <= WEAPON_CANE ||
|
|
|
|
WeaponSlot->dwType == WEAPON_PARACHUTE ) return TRUE;
|
|
|
|
|
|
|
|
if(!WeaponSlot->dwAmmo) return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 21:59:22 +08:00
|
|
|
WORD CPlayerPed::GetAmmo()
|
|
|
|
{
|
|
|
|
if(m_pPed) {
|
|
|
|
WEAPON_SLOT_TYPE * WeaponSlot = GetCurrentWeaponSlot();
|
|
|
|
|
|
|
|
if(!WeaponSlot) return -1;
|
|
|
|
|
|
|
|
// Melee types always have ammo.
|
|
|
|
if( WeaponSlot->dwType <= WEAPON_CANE ||
|
|
|
|
WeaponSlot->dwType == WEAPON_PARACHUTE ) return -1;
|
|
|
|
|
|
|
|
return (WORD)WeaponSlot->dwAmmo;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 21:54:53 +08:00
|
|
|
WEAPON_SLOT_TYPE * CPlayerPed::FindWeaponSlot(DWORD dwWeapon)
|
|
|
|
{
|
|
|
|
if (m_pPed)
|
|
|
|
{
|
|
|
|
BYTE i;
|
|
|
|
for (i = 0; i < 13; i++)
|
|
|
|
{
|
|
|
|
if (m_pPed->WeaponSlots[i].dwType == dwWeapon) return &m_pPed->WeaponSlots[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 22:10:08 +08:00
|
|
|
void CPlayerPed::StartGoggles()
|
|
|
|
{
|
|
|
|
if (HasGoggles()) return;
|
|
|
|
if (FindWeaponSlot( 44 ) == NULL && FindWeaponSlot( 45 ) == NULL)
|
|
|
|
GiveWeapon( 44, 1 ); // Prevents crashing due to lack of animations.
|
|
|
|
|
|
|
|
CTaskGoggles* pGoggles = new CTaskGoggles();
|
|
|
|
pGoggles->ApplyToPed( this );
|
|
|
|
m_bGoggleState = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 21:51:28 +08:00
|
|
|
void CPlayerPed::StopGoggles()
|
|
|
|
{
|
|
|
|
if (!m_pPed || !HasGoggles()) return;
|
|
|
|
|
|
|
|
m_bGoggleState = FALSE;
|
|
|
|
DWORD dwPedPointer = (DWORD)m_pPed;
|
|
|
|
_asm mov ecx, dwPedPointer
|
|
|
|
_asm mov eax, 0x5E6010
|
|
|
|
_asm call eax
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-03 21:48:31 +08:00
|
|
|
BOOL CPlayerPed::HasGoggles()
|
|
|
|
{
|
|
|
|
if (!m_pPed) return FALSE;
|
|
|
|
return (BOOL)(m_pPed->dwActiveVision != 0 || m_bGoggleState);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|