mirror of
https://github.com/GTAmodding/re3.git
synced 2024-12-27 22:05:47 +00:00
implemented some of CCam and dependencies
This commit is contained in:
parent
c5a058b615
commit
820fd66a94
13 changed files with 1367 additions and 42 deletions
|
@ -6,6 +6,7 @@ workspace "re3"
|
||||||
files { "src/math/*.*" }
|
files { "src/math/*.*" }
|
||||||
files { "src/modelinfo/*.*" }
|
files { "src/modelinfo/*.*" }
|
||||||
files { "src/entities/*.*" }
|
files { "src/entities/*.*" }
|
||||||
|
files { "src/weapons/*.*" }
|
||||||
files { "src/render/*.*" }
|
files { "src/render/*.*" }
|
||||||
files { "src/control/*.*" }
|
files { "src/control/*.*" }
|
||||||
files { "src/audio/*.*" }
|
files { "src/audio/*.*" }
|
||||||
|
@ -13,6 +14,7 @@ workspace "re3"
|
||||||
includedirs { "src" }
|
includedirs { "src" }
|
||||||
includedirs { "src/modelinfo" }
|
includedirs { "src/modelinfo" }
|
||||||
includedirs { "src/entities" }
|
includedirs { "src/entities" }
|
||||||
|
includedirs { "src/weapons" }
|
||||||
includedirs { "src/render" }
|
includedirs { "src/render" }
|
||||||
includedirs { "src/control" }
|
includedirs { "src/control" }
|
||||||
includedirs { "src/audio" }
|
includedirs { "src/audio" }
|
||||||
|
|
1140
src/Camera.cpp
1140
src/Camera.cpp
File diff suppressed because it is too large
Load diff
17
src/Camera.h
17
src/Camera.h
|
@ -85,7 +85,7 @@ struct CCam
|
||||||
float f_Roll; //used for adding a slight roll to the camera in the
|
float f_Roll; //used for adding a slight roll to the camera in the
|
||||||
float f_rollSpeed;
|
float f_rollSpeed;
|
||||||
float m_fSyphonModeTargetZOffSet;
|
float m_fSyphonModeTargetZOffSet;
|
||||||
float m_unknownZOffset;
|
float m_fUnknownZOffSet;
|
||||||
float m_fAmountFractionObscured;
|
float m_fAmountFractionObscured;
|
||||||
float m_fAlphaSpeedOverOneFrame; // 100
|
float m_fAlphaSpeedOverOneFrame; // 100
|
||||||
float m_fBetaSpeedOverOneFrame;
|
float m_fBetaSpeedOverOneFrame;
|
||||||
|
@ -162,9 +162,20 @@ float m_unknownZOffset;
|
||||||
bool m_bFirstPersonRunAboutActive;
|
bool m_bFirstPersonRunAboutActive;
|
||||||
|
|
||||||
|
|
||||||
void Process_Debug(float *vec, float a, float b, float c);
|
|
||||||
void Process_Kalvin(float*, float, float, float);
|
|
||||||
void GetVectorsReadyForRW(void);
|
void GetVectorsReadyForRW(void);
|
||||||
|
CVector DoAverageOnVector(const CVector &vec);
|
||||||
|
float GetPedBetaAngleForClearView(const CVector &Target, float Dist, float BetaOffset, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies);
|
||||||
|
void WorkOutCamHeightWeeCar(CVector &TargetCoors, float TargetOrientation);
|
||||||
|
void WorkOutCamHeight(const CVector &TargetCoors, float TargetOrientation, float TargetHeight);
|
||||||
|
bool RotCamIfInFrontCar(CVector &TargetCoors, float TargetOrientation);
|
||||||
|
bool FixCamIfObscured(CVector &TargetCoors, float TargetHeight, float TargetOrientation);
|
||||||
|
void Cam_On_A_String_Unobscured(const CVector &TargetCoors, float BaseDist);
|
||||||
|
void FixCamWhenObscuredByVehicle(const CVector &TargetCoors);
|
||||||
|
|
||||||
|
void Process_Debug(float *vec, float a, float b, float c);
|
||||||
|
void Process_FollowPed(const CVector &CameraTarget, float TargetOrientation, float, float);
|
||||||
|
void Process_BehindCar(const CVector &CameraTarget, float TargetOrientation, float, float);
|
||||||
|
void Process_Cam_On_A_String(const CVector &CameraTarget, float TargetOrientation, float, float);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
|
static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
|
||||||
static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
|
static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
|
||||||
|
|
|
@ -30,7 +30,7 @@ CClock::Initialise(uint32 scale)
|
||||||
void
|
void
|
||||||
CClock::Update(void)
|
CClock::Update(void)
|
||||||
{
|
{
|
||||||
if(CPad::GetPad(1)->NewState.r1){
|
if(CPad::GetPad(1)->GetRightShoulder1()){
|
||||||
ms_nGameClockMinutes += 8;
|
ms_nGameClockMinutes += 8;
|
||||||
ms_nLastClockTick = CTimer::GetTimeInMilliseconds();
|
ms_nLastClockTick = CTimer::GetTimeInMilliseconds();
|
||||||
if(ms_nGameClockMinutes >= 60){
|
if(ms_nGameClockMinutes >= 60){
|
||||||
|
|
|
@ -2,8 +2,40 @@ class CGeneral
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static float GetATanOfXY(float x, float y){
|
static float GetATanOfXY(float x, float y){
|
||||||
if(y >= 0.0f) return atan2(x, y);
|
// why exactly doesn't this work?
|
||||||
return atan2(x, y) + 2*M_PI;
|
// if(y >= 0.0f) return atan2(x, y);
|
||||||
|
// return atan2(x, y) + 2*M_PI;
|
||||||
|
|
||||||
|
if(x == 0.0f && y == 0.0f)
|
||||||
|
return 0.0f;
|
||||||
|
float xabs = fabs(x);
|
||||||
|
float yabs = fabs(y);
|
||||||
|
|
||||||
|
if(xabs < yabs){
|
||||||
|
if(y > 0.0f){
|
||||||
|
if(x > 0.0f)
|
||||||
|
return 0.5f*PI - atan2(x / y, 1.0f);
|
||||||
|
else
|
||||||
|
return 0.5f*PI + atan2(-x / y, 1.0f);
|
||||||
|
}else{
|
||||||
|
if(x > 0.0f)
|
||||||
|
return 1.5f*PI + atan2(x / -y, 1.0f);
|
||||||
|
else
|
||||||
|
return 1.5f*PI - atan2(-x / -y, 1.0f);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(y > 0.0f){
|
||||||
|
if(x > 0.0f)
|
||||||
|
return atan2(y / x, 1.0f);
|
||||||
|
else
|
||||||
|
return PI - atan2(y / -x, 1.0f);
|
||||||
|
}else{
|
||||||
|
if(x > 0.0f)
|
||||||
|
return 2.0f*PI - atan2(-y / x, 1.0f);
|
||||||
|
else
|
||||||
|
return PI + atan2(-y / -x, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not too sure about all these...
|
// not too sure about all these...
|
||||||
|
|
107
src/Pad.cpp
107
src/Pad.cpp
|
@ -14,24 +14,91 @@ CMouseControllerState &CPad::PCTempMouseControllerState = *(CMouseControllerStat
|
||||||
void
|
void
|
||||||
CControllerState::Clear(void)
|
CControllerState::Clear(void)
|
||||||
{
|
{
|
||||||
leftX = 0;
|
LeftStickX = 0;
|
||||||
leftY = 0;
|
LeftStickY = 0;
|
||||||
rightX = 0;
|
RightStickX = 0;
|
||||||
rightY = 0;
|
RightStickY = 0;
|
||||||
l1 = 0;
|
LeftShoulder1 = 0;
|
||||||
l2 = 0;
|
LeftShoulder2 = 0;
|
||||||
r1 = 0;
|
RightShoulder1 = 0;
|
||||||
r2 = 0;
|
RightShoulder2 = 0;
|
||||||
up = 0;
|
DPadUp = 0;
|
||||||
down = 0;
|
DPadDown = 0;
|
||||||
left = 0;
|
DPadLeft = 0;
|
||||||
right = 0;
|
DPadRight = 0;
|
||||||
start = 0;
|
Start = 0;
|
||||||
select = 0;
|
Select = 0;
|
||||||
square = 0;
|
Square = 0;
|
||||||
triangle = 0;
|
Triangle = 0;
|
||||||
cross = 0;
|
Cross = 0;
|
||||||
circle = 0;
|
Circle = 0;
|
||||||
leftshock = 0;
|
LeftShock = 0;
|
||||||
rightshock = 0;
|
RightShock = 0;
|
||||||
|
NetworkTalk = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::ForceCameraBehindPlayer(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
switch(Mode){
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return !!NewState.LeftShoulder1;
|
||||||
|
case 2:
|
||||||
|
return !!NewState.Triangle;
|
||||||
|
case 3:
|
||||||
|
return !!NewState.Circle;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::GetWeapon(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
switch(Mode){
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return !!NewState.Circle;
|
||||||
|
case 2:
|
||||||
|
return !!NewState.Cross;
|
||||||
|
case 3:
|
||||||
|
return !!NewState.RightShoulder1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::GetLookBehindForCar(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
return NewState.LeftShoulder2 && NewState.RightShoulder2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::GetLookBehindForPed(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
return !!NewState.RightShock;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::GetLookLeft(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
return !!NewState.LeftShoulder2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CPad::GetLookRight(void)
|
||||||
|
{
|
||||||
|
if(DisablePlayerControls)
|
||||||
|
return false;
|
||||||
|
return !!NewState.RightShoulder2;
|
||||||
}
|
}
|
||||||
|
|
38
src/Pad.h
38
src/Pad.h
|
@ -53,19 +53,19 @@ enum Key
|
||||||
class CControllerState
|
class CControllerState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int16 leftX, leftY;
|
int16 LeftStickX, LeftStickY;
|
||||||
int16 rightX, rightY;
|
int16 RightStickX, RightStickY;
|
||||||
int16 l1, l2;
|
int16 LeftShoulder1, LeftShoulder2;
|
||||||
int16 r1, r2;
|
int16 RightShoulder1, RightShoulder2;
|
||||||
int16 up, down, left, right;
|
int16 DPadUp, DPadDown, DPadLeft, DPadRight;
|
||||||
int16 start, select;
|
int16 Start, Select;
|
||||||
int16 square, triangle, cross, circle;
|
int16 Square, Triangle, Cross, Circle;
|
||||||
int16 leftshock, rightshock;
|
int16 LeftShock, RightShock;
|
||||||
int16 networktalk;
|
int16 NetworkTalk;
|
||||||
float getLeftX(void) { return leftX/32767.0f; };
|
float GetLeftStickX(void) { return LeftStickX/32767.0f; };
|
||||||
float getLeftY(void) { return leftY/32767.0f; };
|
float GetLeftStickY(void) { return LeftStickY/32767.0f; };
|
||||||
float getRightX(void) { return rightX/32767.0f; };
|
float GetRightStickX(void) { return RightStickX/32767.0f; };
|
||||||
float getRightY(void) { return rightY/32767.0f; };
|
float GetRightStickY(void) { return RightStickY/32767.0f; };
|
||||||
|
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
};
|
};
|
||||||
|
@ -108,6 +108,18 @@ public:
|
||||||
static CMouseControllerState &NewMouseControllerState;
|
static CMouseControllerState &NewMouseControllerState;
|
||||||
static CMouseControllerState &PCTempMouseControllerState;
|
static CMouseControllerState &PCTempMouseControllerState;
|
||||||
|
|
||||||
|
int GetLeftShoulder1(void) { return NewState.LeftShoulder1; }
|
||||||
|
int GetLeftShoulder2(void) { return NewState.LeftShoulder2; }
|
||||||
|
int GetRightShoulder1(void) { return NewState.RightShoulder1; }
|
||||||
|
int GetRightShoulder2(void) { return NewState.RightShoulder2; }
|
||||||
|
|
||||||
|
bool ForceCameraBehindPlayer(void);
|
||||||
|
bool GetWeapon(void);
|
||||||
|
bool GetLookBehindForCar(void);
|
||||||
|
bool GetLookBehindForPed(void);
|
||||||
|
bool GetLookLeft(void);
|
||||||
|
bool GetLookRight(void);
|
||||||
|
|
||||||
static CPad *GetPad(int n) { return &Pads[n]; }
|
static CPad *GetPad(int n) { return &Pads[n]; }
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CPad) == 0xFC, "CPad: error");
|
static_assert(sizeof(CPad) == 0xFC, "CPad: error");
|
||||||
|
|
|
@ -584,6 +584,7 @@ STARTPATCHES
|
||||||
InjectHook(0x4B3B50, CWorld::FindRoofZFor3DCoord, PATCH_JUMP);
|
InjectHook(0x4B3B50, CWorld::FindRoofZFor3DCoord, PATCH_JUMP);
|
||||||
ENDPATCHES
|
ENDPATCHES
|
||||||
|
|
||||||
|
WRAPPER CPed *FindPlayerPed(void) { EAXJMP(0x4A1150); }
|
||||||
WRAPPER CVector &FindPlayerCoors(CVector &v) { EAXJMP(0x4A1030); }
|
WRAPPER CVector &FindPlayerCoors(CVector &v) { EAXJMP(0x4A1030); }
|
||||||
WRAPPER CVehicle *FindPlayerVehicle(void) { EAXJMP(0x4A10C0); }
|
WRAPPER CVehicle *FindPlayerVehicle(void) { EAXJMP(0x4A10C0); }
|
||||||
WRAPPER CVehicle *FindPlayerTrain(void) { EAXJMP(0x4A1120); }
|
WRAPPER CVehicle *FindPlayerTrain(void) { EAXJMP(0x4A1120); }
|
||||||
|
|
|
@ -89,7 +89,9 @@ public:
|
||||||
static float GetWorldY(int y) { return y*40.0f - 2000.0f; }
|
static float GetWorldY(int y) { return y*40.0f - 2000.0f; }
|
||||||
};
|
};
|
||||||
|
|
||||||
CVector &FindPlayerCoors(CVector &v);
|
class CPed;
|
||||||
class CVehicle;
|
class CVehicle;
|
||||||
|
CPed *FindPlayerPed(void);
|
||||||
|
CVector &FindPlayerCoors(CVector &v);
|
||||||
CVehicle *FindPlayerVehicle(void);
|
CVehicle *FindPlayerVehicle(void);
|
||||||
CVehicle *FindPlayerTrain(void);
|
CVehicle *FindPlayerTrain(void);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#pragma warning(disable: 4244) // int to float
|
#pragma warning(disable: 4244) // int to float
|
||||||
#pragma warning(disable: 4800) // int to bool
|
#pragma warning(disable: 4800) // int to bool
|
||||||
|
#pragma warning(disable: 4305) // double to float
|
||||||
#pragma warning(disable: 4838) // narrowing conversion
|
#pragma warning(disable: 4838) // narrowing conversion
|
||||||
#pragma warning(disable: 4996) // POSIX names
|
#pragma warning(disable: 4996) // POSIX names
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Physical.h"
|
#include "Physical.h"
|
||||||
|
#include "Weapon.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PED_MAX_WEAPONS = 13
|
||||||
|
};
|
||||||
|
|
||||||
enum PedState
|
enum PedState
|
||||||
{
|
{
|
||||||
|
@ -63,6 +68,14 @@ enum PedState
|
||||||
PED_ARRESTED,
|
PED_ARRESTED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PEDMOVE_NONE,
|
||||||
|
PEDMOVE_STILL,
|
||||||
|
PEDMOVE_WALK,
|
||||||
|
PEDMOVE_RUN,
|
||||||
|
PEDMOVE_SPRINT,
|
||||||
|
};
|
||||||
|
|
||||||
class CVehicle;
|
class CVehicle;
|
||||||
|
|
||||||
class CPed : public CPhysical
|
class CPed : public CPhysical
|
||||||
|
@ -145,7 +158,9 @@ public:
|
||||||
uint8 m_ped_flagI80 : 1;
|
uint8 m_ped_flagI80 : 1;
|
||||||
uint8 stuff1[199];
|
uint8 stuff1[199];
|
||||||
int32 m_nPedState;
|
int32 m_nPedState;
|
||||||
uint8 stuff2[196];
|
int32 m_nLastPedState;
|
||||||
|
int32 m_nMoveState;
|
||||||
|
uint8 stuff2[188];
|
||||||
CEntity *m_pCurrentPhysSurface;
|
CEntity *m_pCurrentPhysSurface;
|
||||||
CVector m_vecOffsetFromPhysSurface;
|
CVector m_vecOffsetFromPhysSurface;
|
||||||
CEntity *m_pCurSurface;
|
CEntity *m_pCurSurface;
|
||||||
|
@ -157,7 +172,11 @@ public:
|
||||||
|
|
||||||
uint8 stuff5[28];
|
uint8 stuff5[28];
|
||||||
CEntity *m_pCollidingEntity;
|
CEntity *m_pCollidingEntity;
|
||||||
uint8 stuff6[496];
|
uint8 stuff6[12];
|
||||||
|
CWeapon m_weapons[PED_MAX_WEAPONS];
|
||||||
|
int32 stuff7;
|
||||||
|
uint8 m_currentWeapon;
|
||||||
|
uint8 stuff[167];
|
||||||
|
|
||||||
// static void *operator new(size_t);
|
// static void *operator new(size_t);
|
||||||
// static void operator delete(void*, size_t);
|
// static void operator delete(void*, size_t);
|
||||||
|
@ -165,10 +184,13 @@ public:
|
||||||
bool IsPlayer(void) { return m_nPedType == 0 || m_nPedType== 1 || m_nPedType == 2 || m_nPedType == 3; }
|
bool IsPlayer(void) { return m_nPedType == 0 || m_nPedType== 1 || m_nPedType == 2 || m_nPedType == 3; }
|
||||||
bool UseGroundColModel(void);
|
bool UseGroundColModel(void);
|
||||||
void KillPedWithCar(CVehicle *veh, float impulse);
|
void KillPedWithCar(CVehicle *veh, float impulse);
|
||||||
|
CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
|
||||||
};
|
};
|
||||||
static_assert(offsetof(CPed, m_nPedState) == 0x224, "CPed: error");
|
static_assert(offsetof(CPed, m_nPedState) == 0x224, "CPed: error");
|
||||||
static_assert(offsetof(CPed, m_pCurSurface) == 0x2FC, "CPed: error");
|
static_assert(offsetof(CPed, m_pCurSurface) == 0x2FC, "CPed: error");
|
||||||
static_assert(offsetof(CPed, m_pMyVehicle) == 0x310, "CPed: error");
|
static_assert(offsetof(CPed, m_pMyVehicle) == 0x310, "CPed: error");
|
||||||
static_assert(offsetof(CPed, m_nPedType) == 0x32C, "CPed: error");
|
static_assert(offsetof(CPed, m_nPedType) == 0x32C, "CPed: error");
|
||||||
static_assert(offsetof(CPed, m_pCollidingEntity) == 0x34C, "CPed: error");
|
static_assert(offsetof(CPed, m_pCollidingEntity) == 0x34C, "CPed: error");
|
||||||
|
static_assert(offsetof(CPed, m_weapons) == 0x35C, "CPed: error");
|
||||||
|
static_assert(offsetof(CPed, m_currentWeapon) == 0x498, "CPed: error");
|
||||||
static_assert(sizeof(CPed) == 0x540, "CPed: error");
|
static_assert(sizeof(CPed) == 0x540, "CPed: error");
|
||||||
|
|
4
src/weapons/Weapon.cpp
Normal file
4
src/weapons/Weapon.cpp
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#include "common.h"
|
||||||
|
#include "patcher.h"
|
||||||
|
#include "Weapon.h"
|
||||||
|
|
31
src/weapons/Weapon.h
Normal file
31
src/weapons/Weapon.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
enum eWeaponType
|
||||||
|
{
|
||||||
|
WEAPONTYPE_UNARMED = 0,
|
||||||
|
WEAPONTYPE_BASEBALLBAT,
|
||||||
|
WEAPONTYPE_COLT45,
|
||||||
|
WEAPONTYPE_UZI,
|
||||||
|
WEAPONTYPE_SHOTGUN,
|
||||||
|
WEAPONTYPE_AK47,
|
||||||
|
WEAPONTYPE_M16,
|
||||||
|
WEAPONTYPE_SNIPERRIFLE,
|
||||||
|
WEAPONTYPE_ROCKETLAUNCHER,
|
||||||
|
WEAPONTYPE_FLAMETHROWER,
|
||||||
|
WEAPONTYPE_MOLOTOV,
|
||||||
|
WEAPONTYPE_GRENADE,
|
||||||
|
WEAPONTYPE_DETONATOR,
|
||||||
|
WEAPONTYPE_HELICANNON
|
||||||
|
};
|
||||||
|
|
||||||
|
class CWeapon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
eWeaponType m_eWeaponType;
|
||||||
|
int32 m_eWeaponState;
|
||||||
|
int32 m_nAmmoInClip;
|
||||||
|
int32 m_nAmmoTotal;
|
||||||
|
int32 m_nTimer;
|
||||||
|
bool m_bAddRotOffset;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error");
|
Loading…
Reference in a new issue