Browse Source

упс, не та ветка

master
Тим 11 months ago
parent
commit
04a447e759
100 changed files with 4986 additions and 0 deletions
  1. 184
    0
      CGame/CAiming.cpp
  2. 68
    0
      CGame/CAiming.h
  3. 75
    0
      CGame/CBone.h
  4. 20
    0
      CGame/CBulletTrace.h
  5. 1
    0
      CGame/CCam.cpp
  6. 195
    0
      CGame/CCam.h
  7. 43
    0
      CGame/CCamera.cpp
  8. 378
    0
      CGame/CCamera.h
  9. 59
    0
      CGame/CEntity.cpp
  10. 224
    0
      CGame/CEntity.h
  11. 13
    0
      CGame/CHAnimIFrame.h
  12. 23
    0
      CGame/CObject.cpp
  13. 38
    0
      CGame/CObject.h
  14. 30
    0
      CGame/CParticleData.h
  15. 168
    0
      CGame/CPed.cpp
  16. 199
    0
      CGame/CPed.h
  17. 24
    0
      CGame/CPedIK.h
  18. 107
    0
      CGame/CPhysical.cpp
  19. 209
    0
      CGame/CPhysical.h
  20. 68
    0
      CGame/CPlaceable.cpp
  21. 79
    0
      CGame/CPlaceable.h
  22. 105
    0
      CGame/CVehicle.cpp
  23. 331
    0
      CGame/CVehicle.h
  24. 25
    0
      CGame/CWeaponSlot.h
  25. 40
    0
      CGame/Pools.h
  26. 68
    0
      CGame/Pools/CEntityPool.h
  27. 7
    0
      CGame/Pools/CObjectPool.cpp
  28. 13
    0
      CGame/Pools/CObjectPool.h
  29. 7
    0
      CGame/Pools/CPedPool.cpp
  30. 13
    0
      CGame/Pools/CPedPool.h
  31. 119
    0
      CGame/Pools/CPhysicalPool.h
  32. 68
    0
      CGame/Pools/CPlaceablePool.h
  33. 116
    0
      CGame/Pools/CPool.h
  34. 49
    0
      CGame/Pools/CVehiclePool.cpp
  35. 32
    0
      CGame/Pools/CVehiclePool.h
  36. 85
    0
      CGame/SAMP/SAMP.cpp
  37. 40
    0
      CGame/SAMP/SAMP.h
  38. 1
    0
      CGame/SAMP/SAMPActorPool.cpp
  39. 27
    0
      CGame/SAMP/SAMPActorPool.h
  40. 1
    0
      CGame/SAMP/SAMPAudio.cpp
  41. 15
    0
      CGame/SAMP/SAMPAudio.h
  42. 1
    0
      CGame/SAMP/SAMPCamera.cpp
  43. 16
    0
      CGame/SAMP/SAMPCamera.h
  44. 1
    0
      CGame/SAMP/SAMPChatEntry.cpp
  45. 32
    0
      CGame/SAMP/SAMPChatEntry.h
  46. 185
    0
      CGame/SAMP/SAMPChatInfo.cpp
  47. 77
    0
      CGame/SAMP/SAMPChatInfo.h
  48. 1
    0
      CGame/SAMP/SAMPChatPlayer.cpp
  49. 23
    0
      CGame/SAMP/SAMPChatPlayer.h
  50. 1
    0
      CGame/SAMP/SAMPDialogInfo.cpp
  51. 34
    0
      CGame/SAMP/SAMPDialogInfo.h
  52. 1
    0
      CGame/SAMP/SAMPDxutScrollBar.cpp
  53. 56
    0
      CGame/SAMP/SAMPDxutScrollBar.h
  54. 23
    0
      CGame/SAMP/SAMPEntity.h
  55. 1
    0
      CGame/SAMP/SAMPFontRenderer.cpp
  56. 27
    0
      CGame/SAMP/SAMPFontRenderer.h
  57. 1
    0
      CGame/SAMP/SAMPGangzonePool.cpp
  58. 31
    0
      CGame/SAMP/SAMPGangzonePool.h
  59. 1
    0
      CGame/SAMP/SAMPInputBox.cpp
  60. 28
    0
      CGame/SAMP/SAMPInputBox.h
  61. 133
    0
      CGame/SAMP/SAMPInputInfo.cpp
  62. 68
    0
      CGame/SAMP/SAMPInputInfo.h
  63. 1
    0
      CGame/SAMP/SAMPKillEntry.cpp
  64. 25
    0
      CGame/SAMP/SAMPKillEntry.h
  65. 17
    0
      CGame/SAMP/SAMPKillInfo.cpp
  66. 37
    0
      CGame/SAMP/SAMPKillInfo.h
  67. 7
    0
      CGame/SAMP/SAMPLocalPlayer.cpp
  68. 76
    0
      CGame/SAMP/SAMPLocalPlayer.h
  69. 38
    0
      CGame/SAMP/SAMPMiscInfo.cpp
  70. 115
    0
      CGame/SAMP/SAMPMiscInfo.h
  71. 1
    0
      CGame/SAMP/SAMPObject.cpp
  72. 27
    0
      CGame/SAMP/SAMPObject.h
  73. 1
    0
      CGame/SAMP/SAMPObjectPool.cpp
  74. 24
    0
      CGame/SAMP/SAMPObjectPool.h
  75. 1
    0
      CGame/SAMP/SAMPPed.cpp
  76. 33
    0
      CGame/SAMP/SAMPPed.h
  77. 1
    0
      CGame/SAMP/SAMPPickupPool.cpp
  78. 35
    0
      CGame/SAMP/SAMPPickupPool.h
  79. 50
    0
      CGame/SAMP/SAMPPlayerPool.cpp
  80. 46
    0
      CGame/SAMP/SAMPPlayerPool.h
  81. 1
    0
      CGame/SAMP/SAMPPools.cpp
  82. 25
    0
      CGame/SAMP/SAMPPools.h
  83. 1
    0
      CGame/SAMP/SAMPRemotePlayer.cpp
  84. 28
    0
      CGame/SAMP/SAMPRemotePlayer.h
  85. 1
    0
      CGame/SAMP/SAMPRemotePlayerData.cpp
  86. 56
    0
      CGame/SAMP/SAMPRemotePlayerData.h
  87. 1
    0
      CGame/SAMP/SAMPScoreboardInfo.cpp
  88. 30
    0
      CGame/SAMP/SAMPScoreboardInfo.h
  89. 1
    0
      CGame/SAMP/SAMPServerInfo.cpp
  90. 21
    0
      CGame/SAMP/SAMPServerInfo.h
  91. 1
    0
      CGame/SAMP/SAMPServerPresets.cpp
  92. 38
    0
      CGame/SAMP/SAMPServerPresets.h
  93. 1
    0
      CGame/SAMP/SAMPTextDrawTransmit.cpp
  94. 46
    0
      CGame/SAMP/SAMPTextDrawTransmit.h
  95. 1
    0
      CGame/SAMP/SAMPTextLabelPool.cpp
  96. 35
    0
      CGame/SAMP/SAMPTextLabelPool.h
  97. 1
    0
      CGame/SAMP/SAMPTextdraw.cpp
  98. 54
    0
      CGame/SAMP/SAMPTextdraw.h
  99. 1
    0
      CGame/SAMP/SAMPTextdrawPool.cpp
  100. 0
    0
      CGame/SAMP/SAMPTextdrawPool.h

+ 184
- 0
CGame/CAiming.cpp View File

@@ -0,0 +1,184 @@
#include "CAiming.h"

#include "../base.hpp"
#include <cmath>

CAiming::CAiming() {
resetCenter();
resetTarget();
resetSpeed();
resetRange();

moveX = 0;
moveY = 0;

process = g_class.events->onScriptLoop.connect( [this]() { processAiming(); } );
}

CAiming::~CAiming() { g_class.events->onScriptLoop.disconnect( process ); }

bool CAiming::isAimed() {
updatePos();
if ( dist2D( currentPos, center ) <= range * 2.0 ) return true;
return false;
}

bool CAiming::isAimingInProcess() { return ( !isTargetedX || !isTargetedY ); }

void CAiming::setCenter( float X, float Y ) { center = {X, Y}; }

void CAiming::setCenter( RwV2D center ) { this->center = center; }

RwV2D CAiming::getCenter() { return center; }

void CAiming::resetCenter() { center = {339.1f, 179.1f}; }

bool CAiming::setTarget( RwV3D target ) {
RwV2D ts = ConvertGlobalXYZToGameScreenXY( target );

if ( dist2D( center, ts ) < range * 2 ) return false;

if ( dist1D( center.fX, ts.fX ) > range ) isTargetedX = false;
if ( dist1D( center.fY, ts.fY ) > range ) isTargetedY = false;

moveX = 0;
moveY = 0;

distance = center - ConvertGlobalXYZToGameScreenXY( target );
if ( distance.fX < 0.0f ) distance.fX *= -1.0f;
if ( distance.fX < 100.0f ) distance.fX = 100.0f;
if ( distance.fY < 0.0f ) distance.fY *= -1.0f;
if ( distance.fY < 100.0f ) distance.fY = 100.0f;

this->target = target;
return true;
}

RwV3D CAiming::getTarget() { return target; }

void CAiming::resetTarget() {
isTargetedX = true;
isTargetedY = true;
}

void CAiming::setSpeed( double min, double max ) {
speedMin = min;
speedMax = max;
}

void CAiming::setSpeed( RwV2D speed ) {
speedMin = speed.fX;
speedMax = speed.fY;
}

RwV2D CAiming::getSpeed() { return {float( speedMin ), float( speedMax )}; }

void CAiming::resetSpeed() {
speedMin = 0.0001;
speedMax = 0.03;
}

void CAiming::setSpeedMin( double speed ) { speedMin = speed; }

double CAiming::getSpeedMin() { return speedMin; }

void CAiming::resetSpeedMin() { speedMin = 0.0001; }

void CAiming::setSpeedMax( double speed ) { speedMax = speed; }

double CAiming::getSpeedMax() { return speedMax; }

void CAiming::resetSpeedMax() { speedMax = 0.03; }

void CAiming::setRange( double range ) { this->range = range; }

double CAiming::getRange() { return range; }

void CAiming::resetRange() { range = 2.5; }

float CAiming::dist3D( RwV3D pos1, RwV3D pos2 ) {
pos1 -= pos2;
return pos1.length();
}

float CAiming::dist2D( RwV2D pos1, RwV2D pos2 ) {
pos1 -= pos2;
return pos1.length();
}

float CAiming::dist1D( float pos1, float pos2 ) {
pos1 -= pos2;
return ( pos1 < 0.0f ? -pos1 : pos1 );
}

void CAiming::processAiming() {
if ( isTargetedX && isTargetedY ) return;
if ( !LOCAL_CAMERA->isSphereVisible( target, 0.1f ) ) return;

updatePos();
updateSpeed();
CVector2D tcam = LOCAL_CAMERA->getTarget();

if ( !isTargetedX ) {
if ( currentPos.fX < center.fX ) {
if ( moveX == 2 )
isTargetedX = true;
else {
tcam.fX += currentSpeedX;
moveX = 1;
}
} else if ( currentPos.fX > center.fX ) {
if ( moveX == 1 )
isTargetedX = true;
else {
tcam.fX -= currentSpeedX;
moveX = 2;
}
}
}
if ( !isTargetedY ) {
if ( currentPos.fY < center.fY ) {
if ( moveY == 2 )
isTargetedY = true;
else {
tcam.fY += currentSpeedY;
moveY = 1;
}
} else if ( currentPos.fY > center.fY ) {
if ( moveY == 2 )
isTargetedY = true;
else {
tcam.fY -= currentSpeedY;
moveY = 1;
}
}
}

if ( dist1D( currentPos.fX, center.fX ) < range ) isTargetedX = true;
if ( dist1D( currentPos.fY, center.fY ) < range ) isTargetedY = true;
LOCAL_CAMERA->setTarget( tcam );
}

void CAiming::updatePos() { currentPos = ConvertGlobalXYZToGameScreenXY( target ); }

void CAiming::updateSpeed() {
RwV2D dst = center - currentPos;
if ( dst.fX < 0.0f ) dst.fX *= -1.0f;
if ( dst.fY < 0.0f ) dst.fY *= -1.0f;

if ( dst.fX >= distance.fX ) {
currentSpeedX = speedMax;
return;
}
if ( dst.fY >= distance.fY ) {
currentSpeedY = speedMax;
return;
}

double pX = ( 1000.0 / distance.fX ) * dst.fX;
double pY = ( 1000.0 / distance.fY ) * dst.fY;
double speedDelta = speedMax - speedMin;

currentSpeedX = speedMin + ( ( speedDelta / 1000.0 ) * pX );
currentSpeedY = speedMin + ( ( speedDelta / 1000.0 ) * pY );
}

+ 68
- 0
CGame/CAiming.h View File

@@ -0,0 +1,68 @@
#ifndef CAIMING_H
#define CAIMING_H

#include "methods.h"

class CAiming
{
public:
CAiming();
virtual ~CAiming();
virtual bool isAimed();
virtual bool isAimingInProcess();

virtual void setCenter(float X, float Y);
virtual void setCenter(RwV2D center);
virtual RwV2D getCenter();
virtual void resetCenter();

virtual bool setTarget(RwV3D target);
virtual RwV3D getTarget();
virtual void resetTarget();

virtual void setSpeed(double min, double max);
virtual void setSpeed(RwV2D speed);
virtual RwV2D getSpeed();
virtual void resetSpeed();

virtual void setSpeedMin(double speed);
virtual double getSpeedMin();
virtual void resetSpeedMin();

virtual void setSpeedMax(double speed);
virtual double getSpeedMax();
virtual void resetSpeedMax();

virtual void setRange(double range);
virtual double getRange();
virtual void resetRange();

protected:
RwV2D center;
RwV3D target;
double speedMin;
double speedMax;
double range;

size_t process;

virtual float dist3D(RwV3D pos1, RwV3D pos2);
virtual float dist2D(RwV2D pos1, RwV2D pos2);
virtual float dist1D(float pos1, float pos2);

private:
bool isTargetedX;
bool isTargetedY;
RwV2D currentPos;
RwV2D distance;
double currentSpeedX;
double currentSpeedY;
byte moveX;
byte moveY;

void processAiming();
void updatePos();
void updateSpeed();
};

#endif // CAIMING_H

+ 75
- 0
CGame/CBone.h View File

@@ -0,0 +1,75 @@
#ifndef CBONE_H
#define CBONE_H

#include "Types.h"
#include "CHAnimIFrame.h"

namespace BodyPed{
namespace Head{
enum{
Throat = 4,
Neck,
Brain,
zzz_RightTemple, // Does not use it ))
Face
};
};
namespace Torso{
enum {
Groin = 1,
Venter,
Chest
};
};
namespace Arms{
namespace Left{
enum {
Forearm = 31,
Shoulder,
Elbow,
Wrist,
Truss,
Fingers
};
};
namespace Right{
enum {
Forearm = 21,
Shoulder,
Elbow,
Wrist,
Truss,
Fingers
};
};
};
namespace Legs{
namespace Left{
enum{
Hip = 41,
Knee,
Shin,
Foot
};
};
namespace Right{
enum{
Hip = 51,
Knee,
Shin,
Foot
};
};
};
};

class CBone
{
public:
BYTE m_bFlags;
RwV3D m_vOffset; // Статичное смещение относительно родительской кости
CHAnimIFrame *m_pIFrame; // Указатель на структуру, которая содержит интерполированные данные о положении кости
DWORD m_dwNodeId; // Специальный идентификатор кости
};

#endif // CBONE_H

+ 20
- 0
CGame/CBulletTrace.h View File

@@ -0,0 +1,20 @@
#ifndef CBULLETTRACE_H
#define CBULLETTRACE_H

#include "Types.h"

#pragma pack( push, 1 )
struct CBulletTrace {
RwV3D from;
RwV3D to;
bool isExist;
uint8_t _pad[3];
uint32_t createTime;
uint32_t lifeTime;
float radius;
byte alpha;
uint8_t _pad2[3];
};
#pragma pack( pop )

#endif // CBULLETTRACE_H

+ 1
- 0
CGame/CCam.cpp View File

@@ -0,0 +1 @@
#include "CCam.h"

+ 195
- 0
CGame/CCam.h View File

@@ -0,0 +1,195 @@
#ifndef CCAM_H
#define CCAM_H

#include "Types.h"
#include "CEntity.h"
#include "CVehicle.h"

#pragma pack(push, 1)
class CCam_obj1
{
public:
int field_0;
RwV3D field_4;
int field_10;
int field_14;
RwV3D field_18;
int field_24;
int field_28;
int field_2C;
int field_30;
int field_34;
int field_38;
int field_3C;
int field_40;
int field_44;
int field_48;
int field_4C;
int field_50;
int field_54;
int field_58;
int field_5C;
int field_60;
int field_64;
int field_68;
int field_6C;
int field_70;
int field_74;
char field_78;
char field_79;
char field_7A;
char field_7B;
int field_7C;
int field_80;
int field_84;
int field_88;
int field_8C;
int field_90;
int field_94;
};

class CCam
{
public:
char field_0;
char field_1;
char field_2;
char field_3;
char field_4;
char field_5;
char field_6;
char field_7;
char field_8;
char field_9;
char field_A;
char field_B;
uint16_t field_C;
char field_E;
char field_F;
int field_10;
int field_14;
int field_18;
int field_1C;
int field_20;
int field_24;
int field_28;
int field_2C;
int field_30;
int field_34;
int field_38;
int field_3C;
int field_40;
int field_44;
int field_48;
int field_4C;
int field_50;
int field_54;
int field_58;
int field_5C;
int field_60;
int field_64;
int field_68;
int field_6C;
int field_70;
int field_74;
char field_78;
char field_79;
char field_7A;
char field_7B;
int field_7C;
int field_80;
int field_84;
int field_88;
int field_8C;
int field_90;
int field_94;
int field_98;
int field_9C;
int field_A0;
int field_A4;
int field_A8;
int field_AC;
int field_B0;
int zoomFactor;
int field_B8;
int field_BC;
int field_C0;
int field_C4;
int field_C8;
int field_CC;
int field_D0;
int field_D4;
int field_D8;
int field_DC;
int field_E0;
int field_E4;
int field_E8;
int field_EC;
int field_F0;
int field_F4;
int field_F8;
int field_FC;
int field_100;
int field_104;
int field_108;
int field_10C;
int field_110;
int field_114;
int field_118;
int field_11C;
int field_120;
int field_124;
int field_128;
int field_12C;
int field_130;
int field_134;
int field_138;
int field_13C;
int field_140;
int field_144;
int field_148;
int field_14C;
int field_150;
int field_154;
int field_158;
int field_15C;
int field_160;
int field_164;
int field_168;
int field_16C;
int field_170;
int field_174;
int field_178;
int field_17C;
uint16_t field_180;
uint16_t field_182;
int field_184;
int field_188;
int field_18C;
RwV3D field_190;
RwV3D field_19C;
int field_1A8;
int field_1AC;
int field_1B0;
RwV3D field_1B4;
int field_1C0;
int field_1C4;
int field_1C8;
int field_1CC;
int field_1D0;
int field_1D4;
RwV3D field_1D8[4];
int field_208[4];
int field_218;
CVehicle *field_21C;
int field_220;
int field_224;
int field_228;
int field_22C;
int field_230;
int field_234;
};
#pragma pack(pop)


#endif // CCAM_H

+ 43
- 0
CGame/CCamera.cpp View File

@@ -0,0 +1,43 @@
#include "CCamera.h"
CU IS_SPHERE_VISIBLE_FUNC = 0x420D40;
CU FADE_FUNC = 0x50AC20;
CU F3PCTV_FUNC = 0x514970;

bool CCamera::isSphereVisible(RwV3D pos, float range)
{
typedef bool (__thiscall *CCamera__isSphereVisible)(CCamera* _this, RwV3D *pos, float radius);
return (CCamera__isSphereVisible(IS_SPHERE_VISIBLE_FUNC))(this, &pos, range);
}

RwV3D CCamera::getPosition()
{
return *(RwV3D *)(0x00B6F338);
}

RwV3D CCamera::getRotation()
{
return *(RwV3D *)(0x00B6F32C);
}

CVector2D CCamera::getTarget()
{
return {*(float *)0x00B6F258, *(float *)0x00B6F248};
}

void CCamera::setTarget(CVector2D vec)
{
*(float *)0x00B6F258 = vec.fX;
*(float *)0x00B6F248 = vec.fY;
}

int CCamera::fade(float diraction, uint16_t inOut)
{
typedef int(__thiscall *CCamera__fade)(CCamera *_this, float d, uint16_t io);
return (CCamera__fade(FADE_FUNC))(this, diraction, inOut);
}

void CCamera::Find3rdPersonCamTargetVector(float dist, float posX, float posY, float posZ, RwV3D *unkVec, RwV3D *output)
{
typedef void(__thiscall *CCamera__Find3rdPersonCamTargetVector)(CCamera *_this, float dist, float posX, float posY, float posZ, RwV3D *unkVec, RwV3D *output);
return (CCamera__Find3rdPersonCamTargetVector(F3PCTV_FUNC))(CLASS_CCamera, dist, posX, posY, posZ, unkVec, output);
}

+ 378
- 0
CGame/CCamera.h View File

@@ -0,0 +1,378 @@
#ifndef CCAMERA_H
#define CCAMERA_H

#include "Types.h"
#include "CPlaceable.h"
#include "CEntity.h"
#include "CCam.h"

#pragma pack(push, 1)
struct CCamera_obj2
{
int field_0;
int field_4;
int field_8;
int field_C;
};

class CCamera : public CPlaceable
{
public:
char bAboveGroundTrainNodesLoaded;
char bBelowGroundTrainNodesLoaded;
char bCamDirectlyBehind;
char bCamDirectlyInFront;
char field_1C;
char field_1D;
char field_1E;
char field_1F;
char field_20;
char field_21;
char field_22;
char field_23;
char field_24;
char field_25;
char field_26;
char field_27;
char field_28;
char field_29;
char field_2A;
char field_2B;
char field_2C;
char field_2D;
char field_2E;
char field_2F;
char field_30;
char field_31;
char field_32;
char field_33;
char field_34;
char field_35;
char field_36;
char field_37;
char field_38;
char field_39;
char field_3A;
char field_3B;
char field_3C;
char field_3D;
char field_3E;
char field_3F;
char field_40;
char field_41;
char field_42;
char twoPlayerMode;
char field_44;
char field_45;
uint16_t field_46;
uint16_t field_48;
uint16_t field_4A;
uint16_t field_4C;
char field_4E;
char field_4F;
char field_50;
char isFading;
char field_52;
char field_53;
char field_54;
char field_55;
char field_56;
char field_57;
char field_58;
char activeCam;
char field_5A;
char field_5B;
int field_5C;
int field_60;
int field_64;
int field_68;
int field_6C;
int field_70;
int field_74;
int field_78;
int field_7C;
int field_80;
int field_84;
int field_88;
int field_8C;
int field_90;
int field_94;
int field_98;
int field_9C;
int field_A0;
int field_A4;
int field_A8;
int field_AC;
int field_B0;
int field_B4;
int field_B8;
int field_BC;
int field_C0;
int field_C4;
int field_C8;
int field_CC;
int field_D0;
int field_D4;
int field_D8;
int field_DC;
int field_E0;
float DistanceToWater;
int HeightOfNearestWater;
int field_EC;
int field_F0;
float field_F4;
int field_F8;
int field_FC;
int field_100;
int field_104;
int field_108;
int field_10C;
int field_110;
int field_114;
int field_118;
int field_11C;
int field_120;
int field_124;
int field_128;
int field_12C;
int field_130;
int field_134;
int nearClipPlane;
int field_13C;
int field_140;
int field_144;
int field_148;
int field_14C;
int field_150;
int field_154;
int field_158;
int field_15C;
int field_160;
int field_164;
uint16_t field_168;
uint16_t field_16A;
int field_16C;
int field_170;
CCam cams[3];
void *pInteractingGarage;
void *field_820;
int field_824;
int field_828;
int field_82C;
uint16_t field_830;
uint16_t field_832;
int field_834;
uint16_t field_838;
uint16_t field_83A;
int field_83C;
int field_840;
int field_844;
RwV3D field_848;
RwV3D field_854;
RwV3D field_860;
RwV3D cameraPosition;
RwV3D cameraRotation;
int field_884;
int field_888;
int field_88C;
int field_890;
int field_894;
int field_898;
int field_89C;
int field_8A0;
int field_8A4;
int field_8A8;
int field_8AC;
int field_8B0;
int field_8B4;
int field_8B8;
int field_8BC;
int field_8C0;
int field_8C4;
int field_8C8;
int field_8CC;
int field_8D0;
int field_8D4;
int field_8D8;
int field_8DC;
int field_8E0;
int field_8E4;
int field_8E8;
int field_8EC;
int field_8F0;
int field_8F4;
int field_8F8;
int field_8FC;
int field_900;
int field_904;
RwV3D field_908;
int field_914;
int field_918;
int field_91C;
RwV3D field_920;
RwV3D field_92C;
RwV3D field_938;
RwV3D field_944;
int field_950;
RwCamera *rwCamera;
CEntity *targetEntity;
int field_95C;
int field_960[4];
char field_970;
char field_971;
char field_972;
char field_973;
CMatrix field_974;
CMatrix field_9BC;
CMatrix cameraViewMatrix;
CMatrix field_A4C;
CMatrix field_A94;
CMatrix TvCamMatrix;
RwV3D field_B24;
RwV3D field_B30;
RwV3D field_B3C;
RwV3D field_B48;
int field_B54;
int field_B58;
int field_B5C;
int field_B60;
int field_B64;
int field_B68;
int field_B6C;
int field_B70;
int field_B74;
int field_B78;
int field_B7C;
int field_B80;
int field_B84;
int field_B88;
int field_B8C;
int field_B90;
int field_B94;
int field_B98;
int field_B9C;
int field_BA0;
int field_BA4;
int field_BA8;
int field_BAC;
int field_BB0;
int field_BB4;
int field_BB8;
int field_BBC;
int field_BC0;
int field_BC4;
int field_BC8;
int field_BCC;
int field_BD0;
int field_BD4;
int field_BD8;
int field_BDC;
int field_BE0;
int field_BE4;
int field_BE8;
int field_BEC;
int field_BF0;
int field_BF4;
int field_BF8;
int _fadeAlpha;
int field_C00;
int _fFadeDuration;
int field_C08;
int field_C0C;
int field_C10;
int field_C14;
int field_C18;
int field_C1C;
int field_C20;
int field_C24;
int field_C28;
int field_C2C;
uint16_t _fadeInOutFlag;
uint16_t field_C32;
int field_C34;
uint16_t field_C38;
uint16_t field_C3A;
uint16_t field_C3C;
uint16_t field_C3E;
int _fadeStartTime;
int field_C44;
int field_C48;
int field_C4C;
int field_C50;
int field_C54;
int field_C58;
int transverseStartTime;
int transverseEndTime;
RwV3D transverseEndPoint;
RwV3D transverseStartPoint;
char transverseMode;
char field_C7D;
char field_C7E;
char field_C7F;
RwV3D field_C80;
char field_C8C;
char field_C8D;
char field_C8E;
char field_C8F;
int field_C90;
int _startJiggleTime;
int _endJiggleTime;
int field_C9C;
int field_CA0;
int _startZoomTime;
int _endZoomTime;
int _zoomInFactor;
int _zoomOutFactor;
char _zoomMode;
char field_CB5;
char field_CB6;
char field_CB7;
int field_CB8;
int field_CBC;
int field_CC0;
RwV3D field_CC4;
RwV3D field_CD0;
char field_CDC;
char field_CDD;
char field_CDE;
char field_CDF;
RwV3D field_CE0;
char field_CEC;
char field_CED;
char field_CEE;
char field_CEF;
char field_CF0;
char field_CF1;
char field_CF2;
char field_CF3;
CCamera_obj2 field_CF4[5];
int field_D44;
int field_D48;
int field_D4C;
int field_D50;
int field_D54;
int field_D58;
int field_D5C;
int field_D60;
int field_D64;
int field_D68;
int field_D6C;
int field_D70;
int field_D74;

bool isSphereVisible(RwV3D pos, float range);
RwV3D getPosition();
RwV3D getRotation();
CVector2D getTarget();
void setTarget(CVector2D);
int fade(float diraction, uint16_t inOut);
void Find3rdPersonCamTargetVector(float dist, float posX, float posY, float posZ, RwV3D *unkVec, RwV3D *output);
};
#pragma pack(pop)


#define CLASS_CCamera (CCamera*)0xB6F028
#define LOCAL_CAMERA ((CCamera*)CLASS_CCamera)
#define CLASS_RwCamera 0xB6F97C

#endif // CCAMERA_H

+ 59
- 0
CGame/CEntity.cpp View File

@@ -0,0 +1,59 @@
#include "CEntity.h"

CU REMOVE_REF_TO_ENTITY_FUNC = 0x544280;

bool CEntity::teleport(RwV3D pos, bool lockRotate)
{
return teleport(pos.fX, pos.fY, pos.fZ, lockRotate);
}

bool CEntity::isVehicle()
{
return (modelID >= 400 && modelID <= 611);
}

bool CEntity::isPed()
{
return modelID <= 311;
}

bool CEntity::isUnderWater()
{
return this->bUnderwater;
}

bool CEntity::isOnScreen()
{
return this->bOffscreen ^ true;
}

bool CEntity::isVisible()
{
return this->bIsVisible;
}

void CEntity::setVisible(bool visible)
{
this->bIsVisible = visible;
}

bool CEntity::isUsesCollision()
{
return this->bUsesCollision;
}

bool CEntity::isCollisionProcessed()
{
return this->bCollisionProcessed;
}

void CEntity::setUsesCollision(bool collision)
{
this->bUsesCollision = collision;
}

bool CEntity::_removeRefsToEntity(int a2)
{
typedef bool(__thiscall *CEntity__removeRefToEntity)(CEntity *_this, int a2);
return (CEntity__removeRefToEntity(REMOVE_REF_TO_ENTITY_FUNC))(this, a2);
}

+ 224
- 0
CGame/CEntity.h View File

@@ -0,0 +1,224 @@
#ifndef CENTITY_H
#define CENTITY_H

#include "Types.h"
#include "CPlaceable.h"

enum eEntityType
{
ENTITY_TYPE_NOTHING,
ENTITY_TYPE_BUILDING,
ENTITY_TYPE_VEHICLE,
ENTITY_TYPE_PED,
ENTITY_TYPE_OBJECT,
ENTITY_TYPE_DUMMY,
ENTITY_TYPE_NOTINPOOLS
};

enum eEntityStatus
{
STATUS_PLAYER,
STATUS_PLAYER_PLAYBACKFROMBUFFER,
STATUS_SIMPLE,
STATUS_PHYSICS,
STATUS_ABANDONED,
STATUS_WRECKED,
STATUS_TRAIN_MOVING,
STATUS_TRAIN_NOT_MOVING,
STATUS_HELI,
STATUS_PLANE,
STATUS_PLAYER_REMOTE,
STATUS_PLAYER_DISABLED,
STATUS_TRAILER,
STATUS_SIMPLE_TRAILER
};

class CEntity : public CPlaceable
{
public:
//CPlaceable placeable;
DWORD ptr_RwObject;
/********** BEGIN CFLAGS **************/
/// does entity use collision
unsigned long bUsesCollision : 1;
/// has object been processed by a ProcessEntityCollision function
unsigned long bCollisionProcessed : 1;
/// is entity static
unsigned long bIsStatic : 1;
/// has entity processed some contact forces
unsigned long bHasContacted : 1;
/// is entity stuck
unsigned long bIsStuck : 1;
/// is entity in a collision free safe position
unsigned long bIsInSafePosition : 1;
/// was entity control processing postponed
unsigned long bWasPostponed : 1;
///is the entity visible
unsigned long bIsVisible : 1;
/// Set if this entity is a big building
unsigned long bIsBIGBuilding : 1;
/// use damaged LOD models for objects with applicable damage
unsigned long bRenderDamaged : 1;
/// Dont let the streaming remove this
unsigned long bStreamingDontDelete : 1;
/// remove this entity next time it should be processed
unsigned long bRemoveFromWorld : 1;
/// has collided with a building (changes subsequent collisions)
unsigned long bHasHitWall : 1;
/// don't delete me because I'm being rendered
unsigned long bImBeingRendered : 1;
/// draw object last
unsigned long bDrawLast : 1;
/// Fade entity because it is far away
unsigned long bDistanceFade : 1;
/// Dont cast shadows on this object
unsigned long bDontCastShadowsOn : 1;
/// offscreen flag. This can only be trusted when it is set to true
unsigned long bOffscreen : 1;
/// this is used by script created entities - they are static until the collision is loaded below them
unsigned long bIsStaticWaitingForCollision : 1;
/// tell the streaming not to stream me
unsigned long bDontStream : 1;
/// this object is underwater change drawing order
unsigned long bUnderwater : 1;
/// Object has a prerender effects attached to it
unsigned long bHasPreRenderEffects : 1;
/// whether or not the building is temporary (i.e. can be created and deleted more than once)
unsigned long bIsTempBuilding : 1;
/// Don't update the aniamtion hierarchy this frame
unsigned long bDontUpdateHierarchy : 1;
/// entity is roadsign and has some 2deffect text stuff to be rendered
unsigned long bHasRoadsignText : 1;
unsigned long bDisplayedSuperLowLOD : 1;
/// set object has been generate by procedural object generator
unsigned long bIsProcObject : 1;
/// has backface culling on
unsigned long bBackfaceCulled : 1;
/// light object with directional lights
unsigned long bLightObject : 1;
/// set that this object is unimportant, if streaming is having problems
unsigned long bUnimportantStream : 1;
/// Is this model part of a tunnel
unsigned long bTunnel : 1;
/// This model should be rendered from within and outside of the tunnel
unsigned long bTunnelTransition : 1;
/********** END CFLAGS **************/

uint8_t wSeedColFlags; // 0x20
uint8_t wSeedVisibleFlags; // 0x21
WORD modelID;
uint8_t __unknown_36[4]; // 36 - collision related (objects only?)

//CReferences *pReferences; //36
/// CLink<CEntity*>* m_pLastRenderedLink;
uint32_t *m_pLastRenderedLink; // 40
uint16_t timer; // 44
/// used to define which IPL file object is in
uint8_t m_iplIndex; // 46
uint8_t interior_id; // 47
uint8_t __unknown_48[6]; // 48

//********* BEGIN CEntityInfo **********//
/// what type is the entity (2 == Vehicle)
uint8_t nType : 3; // 54
/// control status
uint8_t nStatus : 5; // 54

// 55 alignment
//********* END CEntityInfo **********//
uint8_t __unknown_56[8]; // 56
/// this really needs to be figured out cos it's probably a bit field
uint8_t quantumPhysics; // 64

virtual int __add_CRect() = 0;
virtual void add() = 0;
virtual int /*unk, mb it void*/ remove() = 0;
virtual void setIsStatic(bool state) = 0;
/**
* @brief Изменение модели сущности
* @param index Номер модели
*/
virtual void setModelIndex(eModelIndex index) = 0;
/**
* @brief Устанавливает модель сущности, но не меняет ее
* @param index Номер модели
* @return BaseModelInfo
*/
virtual void /*BaseModelInfo*/ *setModelIndexNoCreate(eModelIndex index) = 0;
virtual int createRwObject() = 0;
virtual void deleteRwObject() = 0;
virtual CRect *getBoundRect(CRect*rect) = 0;
virtual int processControl() = 0;
virtual int __processCollision() = 0;
virtual int processShift() = 0;
virtual bool _testCollision(char a2) = 0;
/**
* @brief Телепортирует сущность
* @details Телепорт от перемещения отличается тем, что при телепорте сбрасываются скорость, анимация, вращение (опционально), повороты (кроме Z)
* @param X Координата X
* @param Y Координата Y
* @param Z Координата Z
* @param lockRotate Блокировка вращения при телепорте
* @return Успешность телепортации?
*/
virtual bool teleport(float X, float Y, float Z, bool lockRotate = true) = 0;
virtual bool _specialEntityPreCollisionStuff(int a1, int a2, int a3, int a4, int a5, int a6) = 0;
virtual bool _SpecialEntityCalcCollisionSteps(int a1, int a2) = 0;
/// Подготовка сущности к рендеру
virtual void preRender() = 0;
/// Рендер сущности
virtual void render() = 0;
/// Установка освещения сущности
virtual bool setupLighting() = 0;
virtual bool _removeLighting(bool a2 = true) = 0;
virtual void flagToDestroyWhenNextProcessed() = 0;

/**
* @brief Телепортирует сущность
* @details Телепорт от перемещения отличается тем, что при телепорте сбрасываются скорость, анимация, вращение (опционально), повороты (кроме Z)
* @param pos Координаты
* @param lockRotate Блокировка вращения при телепорте
* @return Успешность телепортации?
*/
bool teleport(RwV3D pos, bool lockRotate = true);

/// Проверяет является ли сущность транспортом
bool isVehicle();
/// Проверяет является ли сущность человеком
bool isPed();
/// Проверяет находитсяли сущность под водой
bool isUnderWater();
/// Проверяет находится ли сущность на экране
bool isOnScreen();

/**
* @brief Проверяет является ли сущность видимой
* @return Видимость
*/
bool isVisible();
/**
* @brief Устанавливает видимость сущности
* @param visible Видимость
*/
void setVisible(bool visible);

/**
* @brief Проверяет имеет ли сущность коллизию
* @return Наличие коллизии
*/
bool isUsesCollision();
/**
* @brief Проверяет сталкивается ли сущность с другими сущностями
* @return Наличие столкновений
*/
bool isCollisionProcessed();
/**
* @brief Устанавливает наличие коллизии сущности
* @param collision Наличие коллизии
*/
void setUsesCollision(bool collision);

bool _removeRefsToEntity(int a2);
};

#endif // CENTITY_H

+ 13
- 0
CGame/CHAnimIFrame.h View File

@@ -0,0 +1,13 @@
#ifndef CHANIMIFRAME_H
#define CHANIMIFRAME_H

#include "Types.h"

class CHAnimIFrame
{
public:
Quaternion m_qOrientation;
RwV3D m_vTranslation;
};

#endif // CHANIMIFRAME_H

+ 23
- 0
CGame/CObject.cpp View File

@@ -0,0 +1,23 @@
#include "CObject.h"

CU SET_TARGATABLE_FUNC = 0x59F300;
CU IS_TARGATABLE_FUNC = 0x59F320;
CU IS_DAMAGED_FUNC = 0x46A2F0;

int CObject::setTargatable(bool targatable)
{
typedef int(__thiscall *CObject__setTargatable)(CObject *_this, uint8_t targatable);
return (CObject__setTargatable(SET_TARGATABLE_FUNC))(this, targatable);
}

bool CObject::isTargatable()
{
typedef int(__thiscall *CObject__isTargatable)(CObject *_this);
return (CObject__isTargatable(IS_TARGATABLE_FUNC))(this);
}

bool CObject::isDamaged()
{
typedef int(__thiscall *CObject__isDamafed)(CObject *_this);
return (CObject__isDamafed(IS_DAMAGED_FUNC))(this);
}

+ 38
- 0
CGame/CObject.h View File

@@ -0,0 +1,38 @@
#ifndef COBJECT_H
#define COBJECT_H

#include "Types.h"
#include "CPhysical.h"

class CObject : public CPhysical
{
public:
//CPhysical physical;
uint8_t __unknown_312[8]; /* 312 */
DWORD flags;
// бит 10 = обьект сломан
// бит 11 = включен сигнал поезда
// бит 12 = обьект сфотографирован камерой
// бит 13 = обьект можно поднимать, переносить
// бит 18 = обьект можно прицепить к магниту
// бит 22 = иммунитет к педам(не включая игрока)
byte EffectDamage;
// 0 = нет эффекта
// 1 = происходит смена модели
// 20 = разрушается
// 21 = изменяется модель, затем разрушается
// 200 = ломается
// 202 = ломается и удаляется
uint8_t __unknown_325[3]; /* 325 */
byte DamagByWeaponID;
uint8_t __unknown_327[11]; /* 327 */
float hitpoints;
float size;
DWORD ptr_CObjectInfo;

int setTargatable(bool targatable);
bool isTargatable();
bool isDamaged();
};

#endif // COBJECT_H

+ 30
- 0
CGame/CParticleData.h View File

@@ -0,0 +1,30 @@
#ifndef CPARTICLEDATA_H
#define CPARTICLEDATA_H

#include "Types.h"

class CParticleData
{
public:
DWORD prt_blood;
DWORD prt_boatsplash;
DWORD prt_bubble;
DWORD prt_cardebris;
DWORD prt_collisionsmoke;
DWORD prt_gunshell;
DWORD prt_sand;
DWORD prt_sand2;
DWORD prt_smoke_huge;
DWORD prt_smokeII_3_expand;
DWORD prt_spark;
DWORD prt_spark_2;
DWORD prt_splash;
DWORD prt_wake;
DWORD prt_watersplash;
DWORD prt_wheeldirt;
DWORD prt_glass;
};

#define POOL_CPARTICLE_DATA 0xA9AE00;

#endif // CPARTICLEDATA_H

+ 168
- 0
CGame/CPed.cpp View File

@@ -0,0 +1,168 @@
#include "CPed.h"
#include "CVehicle.h"
#include "methods.h"

CU BONE_POS_FUNC = 0x5E01C0;
CU GIVE_WEAPON_FUNC = 0x5E6080;
CU SET_AMMO_FUNC = 0x5DF290;
CU IS_AVAILABLE_FUNC = 0x5E0170;
CU SET_ACTIVE_WEAPON_SLOT_FUNC = 0x5E61F0;
CU SET_WEAPON_FUNC = 0x5E6280;
CU CLEAR_WEAPONS_FUNC = 0x5E6320;
CU GET_WEAPON_SKILL_INDEX_FUNC = 0x5E6580;
CU GET_WEAPON_SKILL_BY_TYPE_FUNC = 0x5E3B60;
CU REMOVE_WEAPON_MODEL_FUNC = 0x5E3990;
CU GRANT_AMMO_FUNC = 0x5DF220;
//CU SET_MODEL_INDEX_FUNC = 0x5E4880;
CU IS_CONTROLABLE_FUNC = 0x609590;
CU CPED_CONSTRUCTOR = 0x5E8030;
CU SET_PLAYER_STAT_VALUE_FUNC = 0x55A070;
CU GET_PLAYER_STAT_VALUE_FUNC = 0x558E40;
CU GET_PLAYER_NUMBER_FUNC = 0x563FA0;

CPed* CPed::new_CPed(uint32_t pedType)
{
byte *_this = new byte[sizeof (CPed)];
typedef bool(__thiscall *CPed__CPed)(void *_this, uint32_t type);
(CPed__CPed(CPED_CONSTRUCTOR))(_this, pedType);
return reinterpret_cast<CPed*>(_this);
}

bool CPed::isDriving()
{
return state == 50;
}

bool CPed::isDriver()
{
if (!isDriving())
return false;
return vehicle->driver == this;
}

bool CPed::isPassenger()
{
return (isDriving() && !isDriver());
}

bool CPed::isLeavingCar()
{
if (isDriving())
return false;
return state == 0;
}

bool CPed::isActorDead()
{
return (state == 55 || state == 63 || hitpoints == 0.0f);
}

bool CPed::isAvailable()
{
typedef bool(__thiscall *CPed__isAvailable)(CPed *_this);
return (CPed__isAvailable(IS_AVAILABLE_FUNC))(this);
}

bool CPed::isControlable()
{
typedef bool(__thiscall *CPed__isControlable)(CPed *_this);
return (CPed__isControlable(IS_CONTROLABLE_FUNC))(this);
}

bool CPed::isStopped()
{
return (getSpeed() < 0.0001f);
}

bool CPed::isCrouch()
{
return (crouchStatus == 132);
}

bool CPed::isJumping()
{
return (animation_state == 0 || jumpStatus == 34 || jumpStatus == 36);
}

RwV3D CPed::getBonePos(byte boneId, bool includeAnim)
{
RwV3D Position = {0.0, 0.0, 0.0};

typedef int(__thiscall *CPed__getBonePositionWithOffset) (CPed *_this, RwV3D *_offset, int _bodeId, bool _includeAnim);
(CPed__getBonePositionWithOffset(BONE_POS_FUNC))(this, &Position, boneId, includeAnim);

return Position;
}

int CPed::giveWeapon(int weaponId, int ammo)
{
loadWeaponModel(weaponId);
typedef int(__thiscall *CPed__giveWeapon)(CPed *_this, int weapId, int ammo, int unk);
return (CPed__giveWeapon(GIVE_WEAPON_FUNC))(this, weaponId, ammo, 0);
}

int CPed::setAmmo(int weaponId, int ammo)
{
typedef int(__thiscall *CPed__setAmmo)(CPed *_this, int weaponId, int ammo);
return (CPed__setAmmo(SET_AMMO_FUNC))(this, weaponId, ammo);
}

void CPed::setActiveWeaponSlot(int slotId)
{
typedef void(__thiscall *CPed__setActiveWeaponSlot)(CPed *_this, int slotId);
(CPed__setActiveWeaponSlot(SET_ACTIVE_WEAPON_SLOT_FUNC))(this, slotId);
}

unsigned CPed::setWeapon(int weaponId)
{
typedef unsigned(__thiscall *CPed__setWeapon)(CPed *_this, int weaponId);
return (CPed__setWeapon(SET_WEAPON_FUNC))(this, weaponId);
}

void CPed::clearWeapons()
{
typedef void(__thiscall *CPed__clearWeapons)(CPed *_this);
(CPed__clearWeapons(CLEAR_WEAPONS_FUNC))(this);
}

uint8_t CPed::getWeaponSkillIndex()
{
typedef uint8_t(__thiscall *CPed__getWeaponSkillIndex)(CPed *_this);
return (CPed__getWeaponSkillIndex(GET_WEAPON_SKILL_INDEX_FUNC))(this);
}

uint8_t CPed::getWeaponSkillByType(int weaponId)
{
typedef uint8_t(__thiscall *CPed__getWeaponSkillByType)(CPed *_this, int wType);
return (CPed__getWeaponSkillByType(GET_WEAPON_SKILL_BY_TYPE_FUNC))(this, weaponId);
}

void *CPed::removeWeaponModel(int model)
{
typedef void*(__thiscall *CPed__removeWeaponModel)(CPed *_this, int model);
return (CPed__removeWeaponModel(REMOVE_WEAPON_MODEL_FUNC))(this, model);
}

int CPed::grantAmmo(int weaponId, int ammo)
{
typedef int(__thiscall *CPed__grantAmmo)(CPed *_this, int weaponId, int ammo);
return (CPed__grantAmmo(GRANT_AMMO_FUNC))(this, weaponId, ammo);
}

int CPed::getPlayerNumber()
{
typedef int(__cdecl*CPlayer__getPlayerNumberForPed)(CPed *ped);
return (CPlayer__getPlayerNumberForPed(GET_PLAYER_NUMBER_FUNC))(this);
}

void CPed::setPlayerStatValue(int statId, float value)
{
typedef void(__cdecl*__setPlayerStatValue)(int statId, float value);
(__setPlayerStatValue(SET_PLAYER_STAT_VALUE_FUNC))(statId, value);
}

float CPed::getPlayerStatValue(int statId)
{
typedef float(__cdecl*__getPlayerStatValue)(uint16_t statId);
return (__getPlayerStatValue(GET_PLAYER_STAT_VALUE_FUNC))(statId);
}

+ 199
- 0
CGame/CPed.h View File

@@ -0,0 +1,199 @@
#ifndef CPED_H
#define CPED_H

#include "Types.h"
#include "CObject.h"
#include "CPhysical.h"
#include "CPedIK.h"
#include "CWeaponSlot.h"

class CPed : public CPhysical
{
public:
//CPhysical physical;
uint8_t __unknown_316[32]; /* 316 */
uint8_t animation_state;
// 0 = прыгает от земли
// 61 = ударяет
// 102 = остановился
// 154 = спринт(бежит с ускорением)
// 205 = бежит
uint8_t __unknown_349[7]; /* 349 */
RwV3D step_pos; /* 356 - coordinates, last foot step */
RwV3D step_pos_before; /* 368 - coordinates, foot step before last one */
uint8_t __unknown_380[280]; /* 380 */
byte CPedSound[0x100];
uint8_t __unknown_916[216]; /* 916 */
byte playerStatus;
// 0 = в воздухе / воде
// 1 = в машине
// 2 = входит в интерьер
// 3 = пешком
// 18 = истекает кровью
byte jumpStatus;
// 32 = приземлился / ожидает
// 33 = в машине(? )
// 34 = в воздухе
// 36 = приземление
byte __unk_flag;
byte crouchStatus;
// 128 = стоит
// 132 = присел
DWORD propirties;
// 3 = невидимость(не включая оружие)
// 12 = иммунитет к выстрелам в голову
// 20 = тонет в воде
DWORD propirties2; /* 1140 */
// 2 = невидимость(включая оружие)
// 9 = не создавать пикап оружия после смерти
DWORD __unknownFlags_1144; /* 1144 | 0x200000 - test control?*/
DWORD ptr_stAnim; /* 1148 */
void *pPlayerData; /* 1152 */

uint8_t __unknown_1156[8]; /* 1156 */

// relative body-part-positions
void *pNeck; /* 1164 - void* pNeck
(pChest?)
- 4 unknown
- float height
- float front/back
- float left/right
- void* pObject
(same class for the following body-part-pointers [except pLeft/RightArm])
*/
class CBone *boneHead; /* 1168 */
class CBone *boneLeftArm; /* 1172 */
class CBone *boneRightArm; /* 1176 */
class CBone *pboneLeftLowArm; /* 1180 */
class CBone *boneRightLowArm; /* 1184 */
class CBone *boneLeftLeg; /* 1188 */
class CBone *boneRightLeg; /* 1192 */
class CBone *boneLeftLowLeg; /* 1196 */
class CBone *boneRightLowLeg; /* 1200 */
class CBone *boneRightMidLeg; /* 1204 */
class CBone *boneLeftMidLeg; /* 1208 */
class CBone *boneLeftMidArm; /* 1212 */
class CBone *boneRightMidArm; /* 1216 */
class CBone *boneLeftShoulder; /* 1220 */
class CBone *boneRightShoulder; /* 1224 */
class CBone *boneChest; /* 1228 */
class CBone *boneMouth; /* 1232 */
DWORD animGroup;
uint8_t __unknown_1240[4]; /* 1240 */
float runspeed; /* 1244 */
byte animLoopStatus;
// 0 = ничего
// 61 = начало / остановка
// 62 = идёт цикл
uint8_t __unknown_1249[19]; /* 1249 */
DWORD CurrentWeapon; /* RpClump */
DWORD muzzle_flash; /* RpClump */
DWORD Scores; /* RpClump */
DWORD ScoresType;
DWORD AlphaBlendMuzzle_flash;
DWORD AlphaBlendMuzzle_flash2;
class CPedIK PedIK;
uint8_t __unknown_1324[4]; /* 1324 */

uint32_t state; /* 1328 - ACTOR_STATE_* */
uint32_t run_state; /* 1332 - ACTOR_MSTATE_* */
uint8_t __unknown_1336[8]; /* 1336 */
float hitpoints; /* 1344 */
float hitpoints_max; /* 1348 - нужный_уровень_ХП * 5.69 */
float armor; /* 1352 */
RwV3D reset_position; /* 1356 */
float fCurrentRotation; /* 1368 */
float fTargetRotation; /* 1372 */
float fRotationSpeed; /* 1376 */
float fRotationCalculation; /* 1380 - is 0.1 when target rotation reached */
class CVehicle *pContactVehicle; /* CVehicle */
RwV3D vehicle_contact_dist;
RwV3D fPlaneAnglesContactEntity;
CEntity *item_contact;
float fUnknown_1416; /* 1416 - only changing when slightly under map */
union{
class CVehicle *vehicle; /* CVehicle */
class CAutomobile *automobile; /* CAutomobile */
class CMonsterTruck *mtruck; /* CMonsterTruck */
class CTrailer *trailer; /* CTrailer */
class CBike *bike; /* CBike */
class CQuad *quad; /* CQuad */
class CBmx *bmx; /* CBmx */
class CHeli *heli; /* CHeli */
class CPlane *plane; /* CPlane */
class CBoat *boat; /* CBoat */
};
uint8_t __unknown_1424[8]; /* 1424 */
uint8_t actor_lock; /* 1432 */
uint8_t __unknown_1433[7]; /* 1433 */
CWeaponSlot WeaponSlot[13]; /* 1440 */
DWORD turrelWeaponID;
uint8_t __unknown_1808[8]; /* 1808 */
uint8_t weapon_slot; /* 1816 */
uint8_t __unknown_1817; /* 1817 */
uint8_t AccuracyShot;
uint8_t __unknown_1819; /* 1819 */
CObject *targetObject;
RwV3D fImpactPos_close;
byte weaponSkills;
byte fightStyle;
byte fightStyle2;
uint8_t __unknown_1839; /* 1839 */
DWORD ptr_CFire;
uint8_t __unknown_1836[12]; /* 1844 */
uint32_t weapon_model; /* 1856 */
uint8_t __unknown_1860[18]; /* 1860 */
WORD money;
uint8_t __unknown_1880[8]; /* 1880 */
DWORD killedByWeaponID;
CPed *killer;
uint8_t __unknown_1896[4]; /* 1896 */
RwV3D turrelOffset;
float angleTurrelA;
float angleTurrelB;
DWORD vievPosInTurrel;
DWORD ammoInTurrel;
uint8_t __unknown_1928[20]; /* 1928 */
CPed *TargetedPed;
uint8_t __unknown_1952[36]; /* 1952 */

static CPed *new_CPed(uint32_t pedType);

// Car methods
bool isDriving();
bool isDriver();
bool isPassenger();
bool isLeavingCar();

bool isActorDead();
bool isAvailable();
bool isControlable();
bool isStopped();
bool isCrouch();
bool isJumping();

RwV3D getBonePos(byte boneId, bool includeAnim = true); // TODO: change to enumeration

int giveWeapon(int weaponId, int ammo);
int setAmmo(int weaponId, int ammo); // return slot
void setActiveWeaponSlot(int slotId);
unsigned setWeapon(int weaponId);
void clearWeapons();
uint8_t getWeaponSkillIndex();
uint8_t getWeaponSkillByType(int weaponId);
void* removeWeaponModel(int model);
int grantAmmo(int weaponId, int ammo); // return slot

int getPlayerNumber();

static void setPlayerStatValue(int statId, float value);
static float getPlayerStatValue(int statId);
};

#define LOCAL_PLAYER (*reinterpret_cast<CPed**>(0xB6F5F0))
#define CPED_POOL_START 0xB7CD98
#define CPEDS_MAXIMUM 0xB74498
#define CPED_SIZE 0x7C4

#endif // CPED_H

+ 24
- 0
CGame/CPedIK.h View File

@@ -0,0 +1,24 @@
#ifndef CPEDIK_H
#define CPEDIK_H

#include "Types.h"

class CPedIK
{
public:
class CPed *thisPed;
float RotationZ; /* radians */
float RotationX; /* radians */
float m_fSlopePitch;
float m_fSlopePitchLimitMult;
float m_fSlopeRoll;
float m_fBodyRoll;
DWORD flags;
// 1 = PEDIK_GUN_REACHED_TARGET
// 2 = PEDIK_TORSO_USED
// 4 = PEDIK_USE_ARM
// 8 = PEDIK_SLOPE_PITCH
// 16 = PEDIK_EVERYTHING_USED
};

#endif // CPEDIK_H

+ 107
- 0
CGame/CPhysical.cpp View File

@@ -0,0 +1,107 @@
#include "CPhysical.h"
#include "methods.h"

CU APPLY_MOVE_FORCE_FUNC = 0x542A07;
CU APPLY_GRAVITY_FORCE_FUNC = 0x542B50;

float CPhysical::getSpeed()
{
return speed.length();
}

void CPhysical::setSpeed(RwV3D spd)
{
speed.fX = spd.fX;
speed.fY = spd.fY;
speed.fZ = spd.fZ;
}

void CPhysical::addSpeed(RwV3D spd)
{
speed.fX += spd.fX;
speed.fY += spd.fY;
speed.fZ += spd.fZ;
}

void CPhysical::setSpinRot(RwV3D rot)
{
spin.fX = matrix->getOffset(rot).fX;
spin.fY = matrix->getOffset(rot).fY;
spin.fZ = rot.fZ;
}

void CPhysical::addSpinRot(RwV3D rot)
{
spin.fX += matrix->getOffset(rot).fX;
spin.fY += matrix->getOffset(rot).fY;
spin.fZ += rot.fZ;
}

void CPhysical::applyMoveForce(RwV3D mov)
{
typedef void(__thiscall *CPhysical__applyMoveForce)(CPhysical *_this, CVector vec);
(CPhysical__applyMoveForce(APPLY_MOVE_FORCE_FUNC))(this, mov);
}

void CPhysical::applyGravityForce(RwV3D a, CVector b, char a4)
{
typedef void(__thiscall *CPhysical__applyGravityForce)(CPhysical *_this, RwV3D a, CVector b, char a4);
(CPhysical__applyGravityForce(APPLY_GRAVITY_FORCE_FUNC))(this, a, b, a4);
}

void CPhysical::stickToPlace()
{
float grav = *reinterpret_cast<float*>(0x863984);
RwV3D place = matrix->getOffset({0.0f, 0.0f, -1.0f}) * (mass * grav);
RwV3D standard(0.0f, 0.0f, -(mass * grav));
if (!IsLineOfSightClear(getPosition(), getPositionOffset({0.0f, 0.0f, -3.0f}), 1, 0, 0, 1, 1, 0, 0))
applyGravityForce(place, place, 1);
else applyGravityForce(standard, standard, 1);
}

void CPhysical::lock()
{
bLock = 1;
}

void CPhysical::unlock()
{
bLock = 0;
}

void CPhysical::toggleLock(bool state)
{
if (state)
lock();
else unlock();
}

bool CPhysical::isLocked()
{
return bLock;
}

bool CPhysical::isUsesGravity()
{
return this->bUsesGravity;
}

void CPhysical::setUsesGravity(bool use_gravity)
{
this->bUsesGravity = use_gravity;
}

bool CPhysical::isOnPlace()
{
return this->isOnPlace();
}

float CPhysical::getSpeedRotationZ()
{
return this->speed_z;
}

void CPhysical::setSpeedRotationZ(float speed)
{
this->speed_z = speed;
}

+ 209
- 0
CGame/CPhysical.h View File

@@ -0,0 +1,209 @@
#ifndef CPHYSICAL_H
#define CPHYSICAL_H

#include "Types.h"
#include "CEntity.h"

class CPhysical : public CEntity
{
public:
//CEntity entity;
union {
struct
{
union{
struct{
uint8_t __unk1_nImmunities : 1;
uint8_t bUsesGravity : 1;
uint8_t __unk3_nImmunities : 1; // used for lock in 0519:
uint8_t __unk4_nImmunities : 1; // used for lock in 0519:
uint8_t __unk5_nImmunities : 1;
uint8_t __unk6_nImmunities : 1;
uint8_t __unk7_nImmunities : 1;
uint8_t __unk8_nImmunities : 1;
};
uint8_t nImmunities; // 65
};
union{
struct{
uint8_t __unk1__unknown_66 : 1;
uint8_t bIsOnPlace : 1;
uint8_t __unk3__unknown_66 : 1;
uint8_t __unk4__unknown_66 : 1;
uint8_t __unk5__unknown_66 : 1;
uint8_t bLock : 1;
uint8_t __unk7__unknown_66 : 1;
uint8_t __unk8__unknown_66 : 1;
};
uint8_t __unknown_66; // 66
};
union{
struct
{
uint8_t soft : 1;
uint8_t pedFreeze : 1;
uint8_t bullet_proof : 1;
uint8_t fire_proof : 1;
uint8_t collision_proof : 1;
uint8_t melee_proof : 1;
uint8_t __unk7_flag : 1;
uint8_t explosion_proof : 1;
};
uint8_t flags; /* 67 immunities */
};
union{
struct{
uint8_t __unk1__unknown_68 : 1;
uint8_t __unk2__unknown_68 : 1;
uint8_t __unk3__unknown_68 : 1;
uint8_t __unk4__unknown_68 : 1;
uint8_t __unk5__unknown_68 : 1;
uint8_t __unk6__unknown_68 : 1;
uint8_t __unk7__unknown_68 : 1;
uint8_t __unk8__unknown_68 : 1;
};
uint8_t __unknown_68; /* 68 */
};
};
uint32_t immunities; // 65
};
RwV3D speed;
RwV3D spin;
RwV3D speed_rammed;
RwV3D spin_rammed;
uint8_t __unknown_116[24]; /* 116 */
float mass;
float massWhenTurning;
float gripDivider;
// 1.0 = 1 x gGrip
// 10.1 = 10 x gGrip
// 100.0 = g / 100Grip
float massToGrip;
float Elasticity;
float Buoyancy;
RwV3D massCenter;
void *__unknown_176; /* 176 - pointer to a "entry node info" pool item */
void *__unknown_180; /* 180 - pointer to a "ptr node Double" pool item */
byte __unknown_184;
WORD collisionCount;
byte __unknown_187;
CPhysical *last_collided_object;
CPhysical *last_collided_object2;
CPhysical *last_collided_object3;
CPhysical *last_collided_object4;
CPhysical *last_collided_object5;
CPhysical *last_collided_object6;
float speed_z; /* 212 */
float damageValue; /* 216 мб это таймер коллизии */
CPhysical *damagedBy; /* 220 он может быть CPed'ом */
RwV3D collided_pos_local;
RwV3D collided_pos;
WORD collided_part; // TODO: захерачить метод в CPed и в наследниках CVehicle
// ѕримечание: ƒл€ автомобилей используютс€ следующие номера частей :
// 1 - капот ? (лева€ передн€€ фара ? )
// 2 - багажник ?
// 3 - передний бампер ?
// 4 - задний бампер ?
// 5 - лева€ передн€€ дверь
// 6 - права€ передн€€ дверь
// 7 - лева€ задн€€ дверь
// 8 - права€ задн€€ дверь
// 9 - левое крыло ?
// 10 - правое крыло ?
// 17 - права€ передн€€ фара ?
CPhysical *attachedSubject;
RwV3D target_pos;
RwV3D target_angle;
byte __unknown_280[16];
CPhysical *collide_ignored;
float lightLevel;
DWORD __unknown_304;
DWORD *CShadowData;

virtual int processEntityCollision(CEntity *pEntity, char *pColPoint) = 0;

/**
* @brief Возвращает скорость объекта
* @return скорость
*/
float getSpeed();
/**
* @brief Установливает скорость объекта
* @param spd скорость
*/
void setSpeed(RwV3D spd);
/**
* @brief Добавляет скорость объекту
* @param spd скорость
*/
void addSpeed(RwV3D spd);

/**
* @brief Установливает вращение объекта
* @param rot вращение
*/
void setSpinRot(RwV3D rot);
/**
* @brief Добавляет вращение объекту
* @param rot вращение
*/
void addSpinRot(RwV3D rot);

/**
* @brief Принудительное движение объекта
* @param mov назначение
*/
void applyMoveForce(RwV3D mov);
/**
* @brief Принудительное указание гравитации объекту
* @param a Максимальное значение гравитации
* @param b Минимальное значение гравитации
* @param a4 хз
*/
void applyGravityForce(RwV3D a, CVector b, char a4 = 1);

/// Прикрепляет объект к поверхности под ногами/колесами
void stickToPlace();

/// Блокирует движение объекта
void lock();
/// Разблокирует движение объекта
void unlock();
/**
* @brief Изменяет состояние блокировки объекта
* @param state Новое состояние
*/
void toggleLock(bool state);
/**
* @brief Проверяет, заблокирован ли объект
* @return состояние блокировки
*/
bool isLocked();

/**
* @brief Проверяет, использует ли объект гравитацию
* @return состояние гравитации для объекта
*/
bool isUsesGravity();
/**
* @brief Устанавливает использование гравитации объектом
* @param use_gravity состояние гравитации для объекта
*/
void setUsesGravity(bool use_gravity);

/// Проверяет, что объект соприкосается с "землей"
bool isOnPlace();

/**
* @brief Возвращает скорость вращения объекта по оси Z
* @return скорость вращения по оси Z
*/
float getSpeedRotationZ();
/**
* @brief Устанавливает скорость вращения объекта по оси Z
* @param speed скорость вращения по оси Z
*/
void setSpeedRotationZ(float speed);
};

#endif // CPHYSICAL_H

+ 68
- 0
CGame/CPlaceable.cpp View File

@@ -0,0 +1,68 @@
#include "CPlaceable.h"

CU SET_ROTATION_FUNC = 0x439A80;
CU SET_HEADING_FUNC = 0x43E0C0;
CU GET_ROTATION_FUNC = 0x441DB0;

float CPlaceable::setRotation(float X, float Y, float Z)
{
typedef float(__thiscall *CPlaceable__setRotation)(CPlaceable *_this, float rotX, float rotY, float rotZ);
return (CPlaceable__setRotation(SET_ROTATION_FUNC))(this, X, Y, Z);
}

float CPlaceable::setRotation(RwV3D rot)
{
return setRotation(rot.fX, rot.fY, rot.fZ);
}

int CPlaceable::setHeading(float Zangle)
{
typedef int(__thiscall *CPlaceable__setHeading)(CPlaceable *_this, float rotZ);
return (CPlaceable__setHeading(SET_HEADING_FUNC))(this, Zangle);
}