2024-02-15 22:23:36 +08:00
|
|
|
|
2024-10-28 19:37:24 +08:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#define _ASSERT assert
|
|
|
|
|
2024-02-15 22:23:36 +08:00
|
|
|
#include "../main.h"
|
2024-10-28 19:37:24 +08:00
|
|
|
#include "game.h"
|
2024-02-15 22:23:36 +08:00
|
|
|
#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-10-31 17:26:43 +08:00
|
|
|
extern CNetGame *pNetGame;
|
|
|
|
extern BOOL bIgnoreNextEntry;
|
|
|
|
extern BOOL bIgnoreNextExit;
|
2024-05-03 22:09:09 +08:00
|
|
|
|
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;
|
2024-10-31 19:19:32 +08:00
|
|
|
m_iPissingState = 0;
|
|
|
|
m_iDanceState = 0;
|
2024-02-15 22:23:36 +08:00
|
|
|
field_2DE = 0;
|
|
|
|
field_2E2 = 0;
|
2024-11-02 23:03:00 +08:00
|
|
|
m_iCellPhoneEnabled = 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) {
|
2024-07-13 23:26:40 +08:00
|
|
|
field_4C[x] = 0;
|
2024-02-15 22:23:36 +08:00
|
|
|
field_27C[x] = 0;
|
|
|
|
memset(&field_74[x], 0, sizeof(struc_97));
|
|
|
|
x++;
|
|
|
|
}
|
2024-07-13 23:26:40 +08:00
|
|
|
|
2024-02-15 22:23:36 +08:00
|
|
|
field_2F9 = 0;
|
|
|
|
}
|
|
|
|
|
2024-07-13 23:26:40 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
_asm push 0
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov edx, 0x60CD20 ; internal_CPlayerPed_SetInitialState
|
|
|
|
_asm call edx
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:32:43 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 16:57:03 +08:00
|
|
|
void CPlayerPed::SetKeys(WORD wKeys, WORD lrAnalog, WORD udAnalog)
|
|
|
|
{
|
|
|
|
GTA_CONTROLSET *pPlayerKeys = GameGetPlayerKeys(m_bytePlayerNumber);
|
|
|
|
|
|
|
|
// LEFT/RIGHT
|
|
|
|
if(pPlayerKeys->wKeys1[0] && lrAnalog) {
|
|
|
|
pPlayerKeys->wKeys1[0] = lrAnalog;
|
|
|
|
pPlayerKeys->wKeys2[0] = lrAnalog;
|
|
|
|
}
|
|
|
|
else if(lrAnalog && !pPlayerKeys->wKeys1[0]) {
|
|
|
|
pPlayerKeys->wKeys1[0] = lrAnalog;
|
|
|
|
pPlayerKeys->wKeys2[0] = 0;
|
|
|
|
}
|
|
|
|
else if(!lrAnalog) {
|
|
|
|
pPlayerKeys->wKeys1[0] = 0;
|
|
|
|
pPlayerKeys->wKeys2[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UP/DOWN
|
|
|
|
if(pPlayerKeys->wKeys1[1] && udAnalog) {
|
|
|
|
pPlayerKeys->wKeys1[1] = udAnalog;
|
|
|
|
pPlayerKeys->wKeys2[1] = udAnalog;
|
|
|
|
}
|
|
|
|
else if(udAnalog && !pPlayerKeys->wKeys1[1]) {
|
|
|
|
pPlayerKeys->wKeys1[1] = udAnalog;
|
|
|
|
pPlayerKeys->wKeys2[1] = 0;
|
|
|
|
}
|
|
|
|
else if(!udAnalog) {
|
|
|
|
pPlayerKeys->wKeys1[1] = 0;
|
|
|
|
pPlayerKeys->wKeys2[1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SECONDARY FIRE (4)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[4]) {
|
|
|
|
pPlayerKeys->wKeys1[4] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[4] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[4] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[4] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[4] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[4] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 1
|
|
|
|
|
|
|
|
// CROUCHING TOGGLE (18)
|
|
|
|
if(IsInVehicle() && wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[18]) {
|
|
|
|
pPlayerKeys->wKeys1[18] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[18] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[18] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[18] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[18] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[18] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 2
|
|
|
|
|
|
|
|
// FIRING (17)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[17]) {
|
|
|
|
pPlayerKeys->wKeys1[17] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[17] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[17] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[17] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[17] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[17] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 3
|
|
|
|
|
|
|
|
// SPRINT (16)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[16]) {
|
|
|
|
pPlayerKeys->wKeys1[16] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[16] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[16] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[16] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[16] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[16] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 4
|
|
|
|
|
|
|
|
|
|
|
|
// SECONDARY ONFOOT ATTACK (15)
|
|
|
|
if( (wKeys & 1) && !IsInJetpackMode() ) {
|
|
|
|
if(pPlayerKeys->wKeys1[15]) {
|
|
|
|
pPlayerKeys->wKeys1[15] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[15] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[15] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[15] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[15] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[15] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 5
|
|
|
|
|
|
|
|
// JUMP (14)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[14]) {
|
|
|
|
pPlayerKeys->wKeys1[14] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[14] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[14] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[14] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[14] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[14] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 6
|
|
|
|
|
|
|
|
// INCAR LOOK RIGHT (7)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[7]) {
|
|
|
|
pPlayerKeys->wKeys1[7] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[7] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[7] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[7] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[7] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[7] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 7
|
|
|
|
|
|
|
|
// INCAR HANDBRAKE / ONFOOT TARGET (6)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[6]) {
|
|
|
|
pPlayerKeys->wKeys1[6] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[6] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[6] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[6] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[6] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[6] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 8
|
|
|
|
|
|
|
|
// INCAR LOOK LEFT (5)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[5]) {
|
|
|
|
pPlayerKeys->wKeys1[5] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[5] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[5] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[5] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[5] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[5] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 9
|
|
|
|
|
|
|
|
// SUBMISSION (19)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[19] == 0xFF) {
|
|
|
|
pPlayerKeys->wKeys1[19] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[19] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[19] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[19] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[19] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[19] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 10
|
|
|
|
|
|
|
|
// WALKING (21)
|
|
|
|
if(wKeys & 1) {
|
|
|
|
if(pPlayerKeys->wKeys1[21] == 0xFF) {
|
|
|
|
pPlayerKeys->wKeys1[21] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[21] = 0xFF;
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[21] = 0xFF;
|
|
|
|
pPlayerKeys->wKeys2[21] = 0x00;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[21] = 0x00;
|
|
|
|
pPlayerKeys->wKeys2[21] = 0x00;
|
|
|
|
}
|
|
|
|
wKeys >>= 1; // 11
|
|
|
|
|
|
|
|
// ANALOG2 D/U
|
|
|
|
BYTE byteVal = wKeys & 3;
|
|
|
|
|
|
|
|
if(byteVal==2) {
|
|
|
|
pPlayerKeys->wKeys1[3] = (WORD)(128);
|
|
|
|
pPlayerKeys->wKeys2[3] = (WORD)(128);
|
|
|
|
} else if(byteVal==1) {
|
|
|
|
pPlayerKeys->wKeys1[3] = (WORD)(-128);
|
|
|
|
pPlayerKeys->wKeys2[3] = (WORD)(-128);
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[3] = 0;
|
|
|
|
pPlayerKeys->wKeys2[3] = 0;
|
|
|
|
}
|
|
|
|
wKeys >>= 2; // 12-13
|
|
|
|
|
|
|
|
// ANALOG2 L/R
|
|
|
|
byteVal = wKeys & 3;
|
|
|
|
|
|
|
|
if(byteVal==2) {
|
|
|
|
pPlayerKeys->wKeys1[2] = (WORD)(128);
|
|
|
|
pPlayerKeys->wKeys2[2] = (WORD)(128);
|
|
|
|
} else if(byteVal==1) {
|
|
|
|
pPlayerKeys->wKeys1[2] = (WORD)(-128);
|
|
|
|
pPlayerKeys->wKeys2[2] = (WORD)(-128);
|
|
|
|
} else {
|
|
|
|
pPlayerKeys->wKeys1[2] = 0;
|
|
|
|
pPlayerKeys->wKeys2[2] = 0;
|
|
|
|
}
|
|
|
|
// 14-15
|
|
|
|
|
|
|
|
GameStoreRemotePlayerKeys(m_bytePlayerNumber,pPlayerKeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 16:55:38 +08:00
|
|
|
WORD CPlayerPed::GetKeys(WORD * lrAnalog, WORD * udAnalog)
|
|
|
|
{
|
|
|
|
WORD wRet=0;
|
|
|
|
GTA_CONTROLSET *pInternalKeys = GameGetInternalKeys();
|
|
|
|
|
|
|
|
*lrAnalog = pInternalKeys->wKeys1[0]; // left/right analog
|
|
|
|
*udAnalog = pInternalKeys->wKeys1[1]; // up/down analog
|
|
|
|
|
|
|
|
if(((short)pInternalKeys->wKeys1[2]) > 0) wRet |= 1; // analog2 L
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(((short)pInternalKeys->wKeys1[2]) < 0) wRet |= 1; // analog2 R
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(((short)pInternalKeys->wKeys1[3]) > 0) wRet |= 1; // analog2 D
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(((short)pInternalKeys->wKeys1[3]) < 0) wRet |= 1; // analog2 U
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[21]) wRet |= 1; // walking
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[19]) wRet |= 1; // submission
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(IsInVehicle() && pInternalKeys->wKeys1[5]) wRet |= 1; // incar look left
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[6]) wRet |= 1; // incar handbrake / target
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(IsInVehicle() && pInternalKeys->wKeys1[7]) wRet |= 1; // incar look right
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[14]) wRet |= 1; // jump
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(!IsInJetpackMode() && pInternalKeys->wKeys1[15]) wRet |= 1; // secondary onfoot attack
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[16]) wRet |= 1; // sprint
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(HasAmmoForCurrentWeapon() && pInternalKeys->wKeys1[17]) wRet |= 1; // fire
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[18]) wRet |= 1; // crouch
|
|
|
|
wRet <<= 1;
|
|
|
|
|
|
|
|
if(pInternalKeys->wKeys1[4]) wRet |= 1; // secondary fire
|
|
|
|
|
|
|
|
return wRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
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-10-28 19:37:24 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Shows the normal marker
|
|
|
|
|
|
|
|
void CPlayerPed::ShowMarker(int iMarkerColorID)
|
|
|
|
{
|
|
|
|
if (m_dwArrow) HideMarker();
|
|
|
|
ScriptCommand(&create_arrow_above_actor, m_dwGTAId, &m_dwArrow);
|
|
|
|
ScriptCommand(&set_marker_color, m_dwArrow, iMarkerColorID);
|
|
|
|
ScriptCommand(&show_on_radar2, m_dwArrow, 2);
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:54:54 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
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-05 19:04:57 +08:00
|
|
|
float CPlayerPed::GetHealth()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0.0f;
|
|
|
|
return m_pPed->fHealth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-05-05 19:06:45 +08:00
|
|
|
void CPlayerPed::SetHealth(float fHealth)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
m_pPed->fHealth = fHealth;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:10:52 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
float CPlayerPed::GetArmour()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0.0f;
|
|
|
|
return m_pPed->fArmour;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:11:39 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetArmour(float fArmour)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
m_pPed->fArmour = fArmour;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:12:31 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
DWORD CPlayerPed::GetStateFlags()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0;
|
|
|
|
return m_pPed->dwStateFlags;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:13:40 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetStateFlags(DWORD dwState)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
m_pPed->dwStateFlags = dwState;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:14:11 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL CPlayerPed::IsDead()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return TRUE;
|
|
|
|
if(m_pPed->fHealth > 0.0f) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:16:15 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BYTE CPlayerPed::GetActionTrigger()
|
|
|
|
{
|
|
|
|
return (BYTE)m_pPed->dwAction;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:16:50 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetActionTrigger(BYTE byteTrigger)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
|
|
|
|
m_pPed->dwAction = byteTrigger;
|
|
|
|
}
|
|
|
|
|
2024-05-05 22:18:25 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL CPlayerPed::IsInVehicle()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return FALSE;
|
|
|
|
|
|
|
|
if(IN_VEHICLE(m_pPed)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-08-05 18:11:12 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
float CPlayerPed::GetTargetRotation()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return 0.0f;
|
|
|
|
if(GamePool_Ped_GetAt(m_dwGTAId) == 0) return 0.0f;
|
|
|
|
|
|
|
|
MATRIX4X4 mat;
|
|
|
|
GetMatrix(&mat);
|
|
|
|
|
|
|
|
float fZAngle = atan2(-mat.up.X, mat.up.Y) * 180.0f / PI;
|
|
|
|
// Bound it to [0, 360)
|
|
|
|
if ( fZAngle < 0.0f )
|
|
|
|
fZAngle += 360.0f;
|
|
|
|
else if ( fZAngle >= 360.0f )
|
|
|
|
fZAngle -= 360.0f;
|
|
|
|
return fZAngle;
|
|
|
|
}
|
|
|
|
|
2024-08-05 18:12:18 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetTargetRotation(float fRotation)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
m_pPed->fRotation2 = DegToRad(fRotation);
|
|
|
|
m_pPed->fRotation1 = DegToRad(fRotation);
|
|
|
|
}
|
|
|
|
|
2024-08-05 18:14:12 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::ForceTargetRotation(float fRotation)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
m_pPed->fRotation1 = DegToRad(fRotation);
|
|
|
|
m_pPed->fRotation2 = DegToRad(fRotation);
|
|
|
|
|
|
|
|
ScriptCommand(&set_actor_z_angle,m_dwGTAId,fRotation);
|
|
|
|
}
|
|
|
|
|
2024-08-11 23:42:32 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL CPlayerPed::IsAPassenger()
|
|
|
|
{
|
|
|
|
if( m_pPed->pVehicle && IN_VEHICLE(m_pPed) )
|
|
|
|
{
|
|
|
|
VEHICLE_TYPE * pVehicle = (VEHICLE_TYPE *)m_pPed->pVehicle;
|
|
|
|
|
|
|
|
if( pVehicle->pDriver != m_pPed ||
|
|
|
|
pVehicle->entity.nModelIndex == TRAIN_PASSENGER ||
|
|
|
|
pVehicle->entity.nModelIndex == TRAIN_FREIGHT ) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-08-11 23:44:07 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
VEHICLE_TYPE * CPlayerPed::GetGtaVehicle()
|
|
|
|
{
|
|
|
|
return (VEHICLE_TYPE *)m_pPed->pVehicle;
|
|
|
|
}
|
|
|
|
|
2024-10-31 17:22:38 +08:00
|
|
|
//-----------------------------------------------------------
|
2024-05-05 19:06:45 +08:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
*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;
|
|
|
|
}
|
|
|
|
|
2024-02-15 22:23:36 +08:00
|
|
|
//-----------------------------------------------------------
|
2024-05-03 21:48:31 +08:00
|
|
|
|
2024-08-13 23:12:39 +08:00
|
|
|
void CPlayerPed::ClearAllWeapons()
|
|
|
|
{
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = m_bytePlayerNumber;
|
|
|
|
|
|
|
|
if(dwPedPtr) {
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov eax, 0x5E6320
|
|
|
|
_asm call eax
|
|
|
|
}
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
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);
|
|
|
|
|
2024-08-05 18:15:05 +08:00
|
|
|
if((!m_pPed || !IN_VEHICLE(m_pPed)) && !bUnk)
|
|
|
|
ScriptCommand(&set_actor_armed_weapon,m_dwGTAId,iWeaponType);
|
|
|
|
else
|
2024-05-03 22:07:17 +08:00
|
|
|
{
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
if(dwPedPtr) {
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm push iWeaponType
|
|
|
|
_asm mov edx, 0x5E6280
|
|
|
|
_asm call edx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameSetLocalPlayerWeaponSkills();
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-13 23:13:17 +08:00
|
|
|
void CPlayerPed::RemoveWeaponWhenEnteringVehicle()
|
|
|
|
{
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
|
|
|
|
if(dwPedPtr) {
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm push 0
|
|
|
|
_asm mov edx, 0x5E6370
|
|
|
|
_asm call edx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
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-10-31 17:22:38 +08:00
|
|
|
|
2024-08-13 23:29:34 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
float CPlayerPed::GetDistanceFromVehicle(CVehicle *pVehicle)
|
|
|
|
{
|
|
|
|
MATRIX4X4 matFromPlayer;
|
|
|
|
MATRIX4X4 matThis;
|
|
|
|
float fSX,fSY,fSZ;
|
|
|
|
|
|
|
|
GetMatrix(&matThis);
|
|
|
|
pVehicle->GetMatrix(&matFromPlayer);
|
|
|
|
|
|
|
|
fSX = (matThis.pos.X - matFromPlayer.pos.X) * (matThis.pos.X - matFromPlayer.pos.X);
|
|
|
|
fSY = (matThis.pos.Y - matFromPlayer.pos.Y) * (matThis.pos.Y - matFromPlayer.pos.Y);
|
|
|
|
fSZ = (matThis.pos.Z - matFromPlayer.pos.Z) * (matThis.pos.Z - matFromPlayer.pos.Z);
|
|
|
|
|
|
|
|
return (float)sqrt(fSX + fSY + fSZ);
|
|
|
|
}
|
2024-05-03 22:10:53 +08:00
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 17:45:42 +08:00
|
|
|
int CPlayerPed::GetVehicleSeatID()
|
|
|
|
{
|
|
|
|
VEHICLE_TYPE *pVehicle;
|
|
|
|
|
|
|
|
if( GetActionTrigger() == ACTION_INCAR && (pVehicle = (VEHICLE_TYPE *)m_pPed->pVehicle) != 0 ) {
|
|
|
|
if(pVehicle->pDriver == m_pPed) return 0;
|
|
|
|
if(pVehicle->pPassengers[0] == m_pPed) return 1;
|
|
|
|
if(pVehicle->pPassengers[1] == m_pPed) return 2;
|
|
|
|
if(pVehicle->pPassengers[2] == m_pPed) return 3;
|
|
|
|
if(pVehicle->pPassengers[3] == m_pPed) return 4;
|
|
|
|
if(pVehicle->pPassengers[4] == m_pPed) return 5;
|
|
|
|
if(pVehicle->pPassengers[5] == m_pPed) return 6;
|
|
|
|
if(pVehicle->pPassengers[6] == m_pPed) return 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2024-10-31 17:22:38 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::PutDirectlyInVehicle(int iVehicleID, int iSeat)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Vehicle_GetAt(iVehicleID)) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
if(GetCurrentWeapon() == WEAPON_PARACHUTE) {
|
|
|
|
SetArmedWeapon(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
VEHICLE_TYPE *pVehicle = GamePool_Vehicle_GetAt(iVehicleID);
|
|
|
|
|
|
|
|
if(pVehicle->fHealth == 0.0f) return;
|
|
|
|
|
|
|
|
// Check to make sure internal data structure of the vehicle hasn't been deleted
|
|
|
|
// by checking if the vtbl points to CPlaceable_vtbl
|
|
|
|
if (pVehicle->entity.vtable == 0x863C40) return;
|
|
|
|
|
|
|
|
if ((GetVehicleSubtypeFromVehiclePtr(pVehicle) == VEHICLE_SUBTYPE_CAR ||
|
|
|
|
GetVehicleSubtypeFromVehiclePtr(pVehicle) == VEHICLE_SUBTYPE_BIKE) &&
|
|
|
|
iSeat > pVehicle->byteMaxPassengers)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(iSeat==0) {
|
|
|
|
if(pVehicle->pDriver && IN_VEHICLE(pVehicle->pDriver)) return;
|
|
|
|
ScriptCommand(&put_actor_in_car,m_dwGTAId,iVehicleID);
|
|
|
|
} else {
|
|
|
|
iSeat--;
|
|
|
|
ScriptCommand(&put_actor_in_car2,m_dwGTAId,iVehicleID,iSeat);
|
|
|
|
}
|
|
|
|
if(m_pPed == GamePool_FindPlayerPed() && IN_VEHICLE(m_pPed)) {
|
|
|
|
pGame->GetCamera()->SetBehindPlayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pNetGame) {
|
|
|
|
CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool();
|
|
|
|
VEHICLEID TrainVehicleId = pVehiclePool->FindIDFromGtaPtr(pVehicle);
|
|
|
|
if(TrainVehicleId == INVALID_VEHICLE_ID || TrainVehicleId > MAX_VEHICLES) return;
|
|
|
|
|
|
|
|
CVehicle* pTrain = pVehiclePool->GetAt(TrainVehicleId);
|
|
|
|
if ( pTrain && pTrain->IsATrainPart() && m_pPed == GamePool_FindPlayerPed() ) {
|
|
|
|
ScriptCommand(&camera_on_vehicle, pTrain->m_dwGTAId, 3, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 17:26:43 +08:00
|
|
|
void CPlayerPed::EnterVehicle(int iVehicleID, BOOL bPassenger)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
VEHICLE_TYPE *ThisVehicleType;
|
|
|
|
if((ThisVehicleType = GamePool_Vehicle_GetAt(iVehicleID)) == NULL) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
bIgnoreNextEntry = TRUE;
|
|
|
|
|
|
|
|
if(GetCurrentWeapon() == WEAPON_PARACHUTE) {
|
|
|
|
SetArmedWeapon(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bPassenger) {
|
|
|
|
if(ThisVehicleType->entity.nModelIndex == TRAIN_PASSENGER && (m_pPed == GamePool_FindPlayerPed())) {
|
|
|
|
ScriptCommand(&put_actor_in_car2,m_dwGTAId,iVehicleID,-1);
|
|
|
|
} else {
|
|
|
|
ScriptCommand(&send_actor_to_car_passenger,m_dwGTAId,iVehicleID,3000,-1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ScriptCommand(&send_actor_to_car_driverseat,m_dwGTAId,iVehicleID,3000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-31 17:27:54 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Graceful vehicle exit.
|
|
|
|
|
|
|
|
void CPlayerPed::ExitCurrentVehicle()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
if(IN_VEHICLE(m_pPed)) {
|
|
|
|
if(GetCurrentVehicleID()) {
|
|
|
|
int iVehicleID;
|
|
|
|
VEHICLE_TYPE *pVehicle = GamePool_Vehicle_GetAt(GetCurrentVehicleID());
|
|
|
|
if(pVehicle) {
|
|
|
|
if( pVehicle->entity.nModelIndex != TRAIN_PASSENGER &&
|
|
|
|
pVehicle->entity.nModelIndex != TRAIN_PASSENGER_LOCO ) {
|
|
|
|
ScriptCommand(&make_actor_leave_car,m_dwGTAId,GetCurrentVehicleID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-15 17:52:24 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
// Forceful removal
|
|
|
|
|
|
|
|
void CPlayerPed::RemoveFromVehicleAndPutAt(float fX, float fY, float fZ)
|
|
|
|
{
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
if(m_pPed && IN_VEHICLE(m_pPed)) {
|
|
|
|
ScriptCommand(&remove_actor_from_car_and_put_at,m_dwGTAId,fX,fY,fZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-15 17:45:42 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 17:56:30 +08:00
|
|
|
void CPlayerPed::TogglePlayerControllable(int iControllable)
|
|
|
|
{
|
|
|
|
MATRIX4X4 mat;
|
|
|
|
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
if(!iControllable) {
|
|
|
|
ScriptCommand(&toggle_player_controllable,m_bytePlayerNumber,0);
|
|
|
|
ScriptCommand(&lock_actor,m_dwGTAId,1);
|
|
|
|
} else {
|
|
|
|
ScriptCommand(&toggle_player_controllable,m_bytePlayerNumber,1);
|
|
|
|
ScriptCommand(&lock_actor,m_dwGTAId,0);
|
|
|
|
if(!IsInVehicle()) {
|
|
|
|
GetMatrix(&mat);
|
|
|
|
TeleportTo(mat.pos.X,mat.pos.Y,mat.pos.Z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 18:05:38 +08:00
|
|
|
void CPlayerPed::HandsUp()
|
|
|
|
{
|
|
|
|
if(!m_pPed || IN_VEHICLE(m_pPed)) return;
|
|
|
|
if(!IsAdded()) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
ScriptCommand(&actor_task_handsup,m_dwGTAId,-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:14:05 +08:00
|
|
|
BOOL CPlayerPed::HasHandsUp()
|
|
|
|
{
|
|
|
|
if(!m_pPed || IN_VEHICLE(m_pPed)) return FALSE;
|
|
|
|
if(!IsAdded()) return FALSE;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return FALSE;
|
|
|
|
if(m_pPed->Tasks->pdwJumpJetPack == NULL) return FALSE;
|
|
|
|
DWORD dwJmpVtbl = m_pPed->Tasks->pdwJumpJetPack[0];
|
|
|
|
if(dwJmpVtbl == 0x85A29C) return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:15:00 +08:00
|
|
|
void CPlayerPed::HoldItem(int iObject)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!IsAdded()) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
DWORD dwPed = (DWORD)m_pPed;
|
|
|
|
_asm push 1
|
|
|
|
_asm push iObject
|
|
|
|
_asm mov ecx, dwPed
|
|
|
|
_asm mov ebx, 0x5E4390
|
|
|
|
_asm call ebx
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:42:58 +08:00
|
|
|
BOOL CPlayerPed::IsJumping()
|
|
|
|
{
|
|
|
|
if(m_pPed && !IN_VEHICLE(m_pPed) && m_pPed->Tasks->pdwJumpJetPack)
|
|
|
|
{
|
|
|
|
return GetTaskTypeFromTask(m_pPed->Tasks->pdwJumpJetPack) == 211;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:48:04 +08:00
|
|
|
BOOL CPlayerPed::IsFighting()
|
|
|
|
{
|
|
|
|
if(m_pPed && !IN_VEHICLE(m_pPed) && m_pPed->Tasks->pdwFighting)
|
|
|
|
{
|
|
|
|
return GetTaskTypeFromTask(m_pPed->Tasks->pdwFighting) == 1016;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:50:38 +08:00
|
|
|
BOOL CPlayerPed::IsFalling()
|
|
|
|
{
|
|
|
|
if(m_pPed && !IN_VEHICLE(m_pPed) && m_pPed->Tasks->pdwDamage)
|
|
|
|
{
|
|
|
|
return GetTaskTypeFromTask(m_pPed->Tasks->pdwDamage) == 208;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:52:02 +08:00
|
|
|
BOOL CPlayerPed::IsSwimming()
|
|
|
|
{
|
|
|
|
if(m_pPed && !IN_VEHICLE(m_pPed) && m_pPed->Tasks->pdwSwimWasted)
|
|
|
|
{
|
|
|
|
return GetTaskTypeFromTask(m_pPed->Tasks->pdwSwimWasted) == 268;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-11 23:37:07 +08:00
|
|
|
void CPlayerPed::StartJetpack()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = m_bytePlayerNumber;
|
|
|
|
|
|
|
|
// reset CTasks so the CJetPack task priority can be enforced
|
|
|
|
TeleportTo(m_pPed->entity.mat->pos.X, m_pPed->entity.mat->pos.Y, m_pPed->entity.mat->pos.Z);
|
|
|
|
|
|
|
|
_asm mov eax, 0x439600
|
|
|
|
_asm call eax
|
|
|
|
|
|
|
|
*pbyteCurrentPlayer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-11 23:36:29 +08:00
|
|
|
void CPlayerPed::StopJetpack()
|
|
|
|
{
|
|
|
|
if(!m_pPed || IN_VEHICLE(m_pPed)) return;
|
|
|
|
|
|
|
|
if(m_pPed->Tasks->pdwJumpJetPack == NULL) return;
|
|
|
|
|
|
|
|
DWORD dwJmpVtbl = m_pPed->Tasks->pdwJumpJetPack[0];
|
|
|
|
|
|
|
|
if(dwJmpVtbl == 0x8705C4) {
|
|
|
|
DWORD dwJetPackTask = (DWORD)m_pPed->Tasks->pdwJumpJetPack;
|
|
|
|
_asm mov ecx, dwJetPackTask
|
|
|
|
_asm mov edx, 0x6801D0
|
|
|
|
_asm push 1
|
|
|
|
_asm call edx
|
|
|
|
m_pPed->Tasks->pdwJumpJetPack = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-11 23:34:43 +08:00
|
|
|
BOOL CPlayerPed::IsInJetpackMode()
|
|
|
|
{
|
|
|
|
if(!m_pPed || IN_VEHICLE(m_pPed)) return FALSE;
|
|
|
|
if(m_pPed->Tasks->pdwJumpJetPack == NULL) return FALSE;
|
|
|
|
|
|
|
|
DWORD dwJmpVtbl = m_pPed->Tasks->pdwJumpJetPack[0];
|
|
|
|
|
|
|
|
if(dwJmpVtbl == 0x8705C4) return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
2024-10-15 17:11:01 +08:00
|
|
|
|
2024-10-31 19:10:40 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetAnimationSet(PCHAR szAnim)
|
|
|
|
{
|
|
|
|
if(m_pPed) {
|
|
|
|
ScriptCommand(&set_actor_animation_set,m_dwGTAId,szAnim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
void CPlayerPed::SetMoney(int iAmount)
|
|
|
|
{
|
|
|
|
ScriptCommand(&set_actor_money,m_dwGTAId,0);
|
|
|
|
ScriptCommand(&set_actor_money,m_dwGTAId,iAmount);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:16:49 +08:00
|
|
|
void CPlayerPed::ApplyAnimation( char *szAnimName, char *szAnimFile, float fT,
|
|
|
|
int opt1, int opt2, int opt3, int opt4, int iUnk )
|
|
|
|
{
|
|
|
|
int iWaitAnimLoad=0;
|
|
|
|
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
// Can't allow 'naughty' anims!
|
|
|
|
if( !stricmp(szAnimFile,"SEX") )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!pGame->IsAnimationLoaded(szAnimFile)) {
|
|
|
|
pGame->RequestAnimation(szAnimFile);
|
|
|
|
while(!pGame->IsAnimationLoaded(szAnimFile)) {
|
|
|
|
Sleep(1);
|
|
|
|
iWaitAnimLoad++;
|
|
|
|
if(iWaitAnimLoad == 15) return; // we can't wait forever
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptCommand(&apply_animation,m_dwGTAId,szAnimName,szAnimFile,fT,opt1,opt2,opt3,opt4,iUnk);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:17:46 +08:00
|
|
|
BOOL CPlayerPed::IsPerformingAnimation(char *szAnimName)
|
|
|
|
{
|
|
|
|
if(m_pPed && ScriptCommand(&is_actor_performing_anim,m_dwGTAId,szAnimName)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 17:11:01 +08:00
|
|
|
float CPlayerPed::GetAimZ()
|
|
|
|
{
|
|
|
|
if(m_pPed) {
|
|
|
|
DWORD dwPlayerInfo = m_pPed->dwPlayerInfoOffset;
|
|
|
|
|
|
|
|
float fAimZ;
|
|
|
|
_asm mov eax, dwPlayerInfo
|
|
|
|
_asm mov ebx, [eax+84]
|
|
|
|
_asm mov fAimZ, ebx
|
|
|
|
|
|
|
|
return fAimZ;
|
|
|
|
}
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 17:11:37 +08:00
|
|
|
void CPlayerPed::SetAimZ(float fAimZ)
|
|
|
|
{
|
|
|
|
if(_isnan(fAimZ) || (fAimZ > 100.0f || fAimZ < -100.0f)) return;
|
|
|
|
|
|
|
|
if(m_pPed) {
|
|
|
|
DWORD dwPlayerInfo = m_pPed->dwPlayerInfoOffset;
|
|
|
|
_asm mov eax, dwPlayerInfo
|
|
|
|
_asm mov ebx, fAimZ
|
|
|
|
_asm mov [eax+84], ebx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
2024-10-15 17:16:42 +08:00
|
|
|
|
|
|
|
ENTITY_TYPE* CPlayerPed::GetGtaContactEntity()
|
|
|
|
{
|
|
|
|
return (ENTITY_TYPE*)m_pPed->pContactEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-15 17:18:06 +08:00
|
|
|
VEHICLE_TYPE* CPlayerPed::GetGtaContactVehicle()
|
|
|
|
{
|
|
|
|
return (VEHICLE_TYPE*)m_pPed->pContactVehicle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:19:32 +08:00
|
|
|
char DanceStyleLibs[4][16] = {"WOP","GFUNK","RUNNINGMAN","STRIP"};
|
|
|
|
char DanceIdleLoops[4][16] = {"DANCE_LOOP","DANCE_LOOP","DANCE_LOOP","STR_Loop_B"};
|
|
|
|
|
|
|
|
void CPlayerPed::StartDancing(int iStyle)
|
|
|
|
{
|
|
|
|
if(iStyle < 0 || iStyle > 3) return;
|
|
|
|
|
|
|
|
m_iDanceState = 1;
|
|
|
|
m_iDanceStyle = iStyle;
|
|
|
|
|
|
|
|
if(m_bytePlayerNumber == 0) {
|
|
|
|
ApplyAnimation(DanceIdleLoops[m_iDanceStyle],DanceStyleLibs[m_iDanceStyle],16.0,1,0,0,0,-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:20:07 +08:00
|
|
|
void CPlayerPed::StopDancing()
|
|
|
|
{
|
|
|
|
m_iDanceState = 0;
|
|
|
|
MATRIX4X4 mat;
|
|
|
|
GetMatrix(&mat);
|
|
|
|
TeleportTo(mat.pos.X,mat.pos.Y,mat.pos.Z);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-31 19:20:37 +08:00
|
|
|
BOOL CPlayerPed::IsDancing()
|
|
|
|
{
|
|
|
|
if(m_iDanceState) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:54:28 +08:00
|
|
|
void CPlayerPed::ProcessMarkers(BOOL bMarkerStreamingEnabled, float fMarkerStreamRadius, BOOL bVisible)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:55:17 +08:00
|
|
|
void CPlayerPed::ApplyCommandTask(char *szTaskName, int p1, int p2, int p3,
|
|
|
|
VECTOR *p4, int p5, float p6, int p7, int p8, int p9)
|
|
|
|
{
|
|
|
|
DWORD dwPed = (DWORD)m_pPed;
|
|
|
|
if(!dwPed) return;
|
|
|
|
|
2024-11-02 22:58:45 +08:00
|
|
|
_asm push p9
|
2024-11-02 22:55:17 +08:00
|
|
|
_asm push p8
|
|
|
|
_asm push p7
|
|
|
|
_asm push p6
|
|
|
|
_asm push p5
|
|
|
|
_asm push p4
|
|
|
|
_asm push p3
|
|
|
|
_asm push p2
|
|
|
|
_asm push p1
|
|
|
|
_asm push dwPed
|
|
|
|
_asm push szTaskName
|
|
|
|
_asm mov ecx, 0xC15448
|
|
|
|
_asm mov edx, 0x618970
|
|
|
|
_asm call edx
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 22:58:45 +08:00
|
|
|
DWORD dwExt4;
|
|
|
|
|
|
|
|
void CPlayerPed::DestroyFollowPedTask()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
dwExt4 = (DWORD)m_pPed->Tasks->pdwIK;
|
|
|
|
if(!dwExt4) return;
|
|
|
|
|
|
|
|
_asm mov ecx, dwExt4
|
|
|
|
_asm mov edx, 0x639330
|
|
|
|
_asm push 1
|
|
|
|
_asm call edx
|
|
|
|
|
|
|
|
m_pPed->Tasks->pdwIK = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 23:03:00 +08:00
|
|
|
void CPlayerPed::ToggleCellphone(int iOn)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
m_iCellPhoneEnabled = iOn;
|
|
|
|
ScriptCommand(&toggle_actor_cellphone,m_dwGTAId,iOn);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 23:03:33 +08:00
|
|
|
int CPlayerPed::IsCellphoneEnabled()
|
|
|
|
{
|
|
|
|
return m_iCellPhoneEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 23:04:47 +08:00
|
|
|
int CPlayerPed::GetFightingStyle()
|
|
|
|
{
|
|
|
|
if (!m_pPed) return 0;
|
|
|
|
return m_pPed->byteFightingStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-02 23:06:07 +08:00
|
|
|
void CPlayerPed::SetFightingStyle(int iStyle)
|
|
|
|
{
|
|
|
|
if (!m_pPed) return;
|
|
|
|
|
|
|
|
ScriptCommand( &set_fighting_style, m_dwGTAId, iStyle, 6 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-29 11:47:52 +08:00
|
|
|
void CPlayerPed::ProcessVehicleHorn()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
GTA_CONTROLSET *pPlayerControls;
|
|
|
|
|
|
|
|
if(!m_bytePlayerNumber) {
|
|
|
|
pPlayerControls = GameGetInternalKeys();
|
|
|
|
} else {
|
|
|
|
pPlayerControls = GameGetPlayerKeys(m_bytePlayerNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
VEHICLE_TYPE *pGtaVehicle = (VEHICLE_TYPE *)m_pPed->pVehicle;
|
|
|
|
|
|
|
|
if(pGtaVehicle) {
|
|
|
|
if(IN_VEHICLE(m_pPed) && (pGtaVehicle->pDriver == m_pPed)) {
|
|
|
|
if(pPlayerControls->wKeys1[18]) {
|
|
|
|
pGtaVehicle->byteHorn2 = 1;
|
|
|
|
} else {
|
|
|
|
pGtaVehicle->byteHorn2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 19:59:56 +08:00
|
|
|
PCHAR CPlayerPed::GetLoadedShopName()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return NULL;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return NULL;
|
|
|
|
|
|
|
|
return (PCHAR)0xA9A7D8;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 20:00:42 +08:00
|
|
|
void CPlayerPed::LoadShoppingDataSubsection(PCHAR szSectionName)
|
|
|
|
{
|
|
|
|
if(strlen(szSectionName) > 8) return;
|
|
|
|
|
|
|
|
_asm push szSectionName
|
|
|
|
_asm mov edx, 0x49BBE0
|
|
|
|
_asm call edx
|
|
|
|
_asm pop edx
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 20:01:44 +08:00
|
|
|
PCHAR CPlayerPed::GetShopName()
|
|
|
|
{
|
|
|
|
if(!m_pPed) return NULL;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return NULL;
|
|
|
|
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
PCHAR szResult = NULL;
|
|
|
|
|
|
|
|
_asm mov eax, dwPedPtr
|
|
|
|
_asm mov ebx, [eax+1932]
|
|
|
|
_asm mov szResult, ebx
|
|
|
|
|
|
|
|
return szResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 20:02:24 +08:00
|
|
|
CHAR szShopName[32];
|
|
|
|
|
|
|
|
void CPlayerPed::SetShopName(char *szNewShopName)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return;
|
|
|
|
if(!GamePool_Ped_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
|
|
|
|
if(szNewShopName && strlen(szNewShopName))
|
|
|
|
{
|
|
|
|
if(strlen(szNewShopName) <= 31)
|
|
|
|
{
|
|
|
|
memset(szShopName, 0, sizeof(szShopName));
|
|
|
|
strncpy(szShopName, szNewShopName, sizeof(szShopName));
|
|
|
|
|
|
|
|
_asm mov eax, dwPedPtr
|
|
|
|
_asm mov ebx, offset szShopName
|
|
|
|
_asm mov [eax+1932], ebx
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_asm mov eax, dwPedPtr
|
|
|
|
_asm mov byte ptr [eax+1932], 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-11-03 17:34:44 +08:00
|
|
|
void CPlayerPed::SetWeaponSkillLevel(int iSkill, WORD wLevel)
|
2024-10-28 20:02:55 +08:00
|
|
|
{
|
|
|
|
if(m_bytePlayerNumber == 0)
|
2024-11-03 17:34:44 +08:00
|
|
|
GameSetLocalPlayerWeaponSkillLevel(iSkill, wLevel);
|
2024-10-28 20:02:55 +08:00
|
|
|
else
|
2024-11-03 17:34:44 +08:00
|
|
|
GameSetPlayerWeaponSkillLevel(m_bytePlayerNumber, iSkill, wLevel);
|
2024-10-28 20:02:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 20:03:31 +08:00
|
|
|
VECTOR* CPlayerPed::GetBonePosition(int iBone, VECTOR *vecPos)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return NULL;
|
|
|
|
if(m_pPed->entity.vtable == 0x863C40) return NULL;
|
|
|
|
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
VECTOR* vecResult;
|
|
|
|
|
|
|
|
_asm push 0
|
|
|
|
_asm push iBone
|
|
|
|
_asm push vecPos
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov edx, 0x5E4280 ; CPed__GetBonePosition
|
|
|
|
_asm call edx
|
|
|
|
_asm mov vecResult, eax
|
|
|
|
|
|
|
|
return vecResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-10-28 20:04:13 +08:00
|
|
|
VECTOR* CPlayerPed::GetTransformedBonePosition(int iBone, VECTOR *vecOffset)
|
|
|
|
{
|
|
|
|
if(!m_pPed) return NULL;
|
|
|
|
if(m_pPed->entity.vtable == 0x863C40) return NULL;
|
|
|
|
|
|
|
|
DWORD dwPedPtr = (DWORD)m_pPed;
|
|
|
|
VECTOR* vecResult;
|
|
|
|
|
|
|
|
_asm push 0
|
|
|
|
_asm push iBone
|
|
|
|
_asm push vecOffset
|
|
|
|
_asm mov ecx, dwPedPtr
|
|
|
|
_asm mov edx, 0x5E01C0 ; CPed__GetTransformedBonePosition
|
|
|
|
_asm call edx
|
|
|
|
_asm mov vecResult, eax
|
|
|
|
|
|
|
|
return vecResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|