Commit 1b3ea019 authored by SR_team's avatar SR_team 💬

Update thin

parent 8408ac4c
[submodule "d3d9/imgui"]
path = d3d9/imgui
url = https://github.com/ocornut/imgui
[submodule "llmo/SRHookVtable"]
path = llmo/SRHookVtable
url = https://gitlab.com/SR_team/SRHookVtable.git
[submodule "d3d9/hook"]
path = d3d9/hook
url = https://gitlab.com/SR_team/d3d9hook.git
[submodule "sys/SRSignal"]
path = sys/SRSignal
url = https://gitlab.com/SR_team/SRSignal
#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 );
}
#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
#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
#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
#include "CCam.h"
#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
#include "CCamera.h"
CU IS_SPHERE_VISIBLE_FUNC = 0x420D40;
CU FADE_FUNC = 0x50AC20;
CU F3PCTV_FUNC = 0x514970;
CU SHAKE_FUNC = 0x50A970;
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 );
}
void CCamera::setShake( float stretch ) {
typedef void( __thiscall * CCamera__CamShakeNoPos )( CCamera * _this, float d );
return ( CCamera__CamShakeNoPos( SHAKE_FUNC ) )( this, stretch );
}
#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;