From 8bd3610cf7451beb2ffd336cecc0410cfcd2088d Mon Sep 17 00:00:00 2001 From: 0TheSpy Date: Sun, 13 Nov 2022 14:56:18 +0300 Subject: [PATCH] Add files via upload --- SpyCustom/sdk/c_baseentity.h | 21 ++- SpyCustom/sdk/gamemovement.h | 307 ++++++++++++++++++++++++++++++++++ SpyCustom/sdk/igamemovement.h | 157 +++++++++++++++++ SpyCustom/sdk/imovehelper.h | 76 ++++++++- SpyCustom/sdk/iprediction.h | 21 +++ SpyCustom/sdk/ivmodelinfo.h | 3 +- SpyCustom/sdk/vector.h | 32 ++++ 7 files changed, 613 insertions(+), 4 deletions(-) create mode 100644 SpyCustom/sdk/gamemovement.h create mode 100644 SpyCustom/sdk/igamemovement.h diff --git a/SpyCustom/sdk/c_baseentity.h b/SpyCustom/sdk/c_baseentity.h index da269cf..00e5f8c 100644 --- a/SpyCustom/sdk/c_baseentity.h +++ b/SpyCustom/sdk/c_baseentity.h @@ -62,6 +62,7 @@ public: NETVAR2(IsScoped, "DT_CSPlayer", "m_bIsScoped", bool); NETVAR2(GetViewOffset, "DT_CSPlayer", "m_vecViewOffset[0]", Vector); + NETVAR2(GetVelocity, "DT_CSPlayer", "m_vecVelocity[0]", Vector); int GetSequenceActivity(int sequence, studiohdr_t* hdr) { @@ -114,7 +115,8 @@ public: NETVAR2(GetTickBase, "DT_BasePlayer", "m_nTickBase", unsigned); NETVAR2(GetObserverTarget, "DT_BasePlayer", "m_hObserverTarget", short); - + + NETVAR2(GetAccount, "DT_CSPlayer", "m_iAccount", int); /* bool isDormant() { @@ -189,7 +191,21 @@ public: NETVAR(GetScore, "CCSPlayerResource", "m_iScore", int[MAX_PLAYERS]); NETVAR(IsVIP, "CCSPlayerResource", "m_iPlayerVIP", int[MAX_PLAYERS]); + + NETVAR(GetTotalCashSpent, "CCSPlayerResource", "m_iTotalCashSpent", int[MAX_PLAYERS]); + NETVAR(GetCashSpentThisRound, "CCSPlayerResource", "m_iCashSpentThisRound", int[MAX_PLAYERS]); + NETVAR(GetMatchStats_CashEarned_Total, "CCSPlayerResource", "m_iMatchStats_CashEarned_Total", int[MAX_PLAYERS]); + NETVAR(IsAlive, "CCSPlayerResource", "m_bAlive", bool[MAX_PLAYERS]); + NETVAR(IsConnected, "CCSPlayerResource", "m_bConnected", bool[MAX_PLAYERS]); + static C_CS_PlayerResource** GetPlayerResource() + { + const auto team_arr_prop = C_CS_PlayerResource::GetTeamProp(); + const auto team_prop = team_arr_prop->m_pDataTable->m_pProps; + const auto proxy_addr = std::uintptr_t(team_prop->m_ProxyFn); + printfdbg("PlayerResource proxy_addr ptr: %x\n", proxy_addr + 0x10); + return *reinterpret_cast(proxy_addr + 0x10); + } }; class CBaseWeaponWorldModel : public C_BaseEntity @@ -221,7 +237,8 @@ public: NETVAR2(GetBombDefuser, "DT_PlantedC4", "m_hBombDefuser", int); NETVAR2(IsHaveBombDefuser, "DT_PlantedC4", "m_hBombDefuser", bool); NETVAR2(GetBombSite, "DT_PlantedC4", "m_nBombSite", unsigned); - }; + }; + #endif diff --git a/SpyCustom/sdk/gamemovement.h b/SpyCustom/sdk/gamemovement.h new file mode 100644 index 0000000..1c9560d --- /dev/null +++ b/SpyCustom/sdk/gamemovement.h @@ -0,0 +1,307 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//=============================================================================// +#if !defined( GAMEMOVEMENT_H ) +#define GAMEMOVEMENT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "igamemovement.h" +#include "cmodel.h" +#include "vprof.h" + +#define CTEXTURESMAX 512 // max number of textures loaded +#define CBTEXTURENAMEMAX 13 // only load first n chars of name + +#define GAMEMOVEMENT_DUCK_TIME 1000 // ms +#define GAMEMOVEMENT_JUMP_TIME 510 // ms approx - based on the 21 unit height jump +#define GAMEMOVEMENT_JUMP_HEIGHT 21.0f // units +#define GAMEMOVEMENT_TIME_TO_UNDUCK_MSECS ( TIME_TO_UNDUCK_MSECS ) // ms +#define GAMEMOVEMENT_TIME_TO_UNDUCK_MSECS_INV ( GAMEMOVEMENT_DUCK_TIME - GAMEMOVEMENT_TIME_TO_UNDUCK_MSECS ) + +enum +{ + SPEED_CROPPED_RESET = 0, + SPEED_CROPPED_DUCK = 1, + SPEED_CROPPED_WEAPON = 2, +}; + +struct surfacedata_t; + +class CBasePlayer; + +class CGameMovement : public IGameMovement +{ +public: + DECLARE_CLASS_NOBASE( CGameMovement ); + + CGameMovement( void ); + virtual ~CGameMovement( void ); + + virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ); + virtual void Reset( void ); + virtual void StartTrackPredictionErrors( CBasePlayer *pPlayer ); + virtual void FinishTrackPredictionErrors( CBasePlayer *pPlayer ); + virtual void DiffPrint( PRINTF_FORMAT_STRING char const *fmt, ... ); + virtual const Vector& GetPlayerMins( bool ducked ) const; + virtual const Vector& GetPlayerMaxs( bool ducked ) const; + virtual const Vector& GetPlayerViewOffset( bool ducked ) const; + virtual void SetupMovementBounds( CMoveData *pMove ); + + virtual bool IsMovingPlayerStuck( void ) const; + virtual CBasePlayer *GetMovingPlayer( void ) const; + virtual void UnblockPusher( CBasePlayer *pPlayer, CBaseEntity *pPusher ); + +// For sanity checking getting stuck on CMoveData::SetAbsOrigin + virtual void TracePlayerBBox( const Vector& start, const Vector& end, unsigned int fMask, int collisionGroup, trace_t& pm ); + + // wrapper around tracehull to allow tracelistdata optimizations + void GameMovementTraceHull( const Vector& start, const Vector& end, const Vector &mins, const Vector &maxs, unsigned int fMask, ITraceFilter *pFilter, trace_t *pTrace ); + +#define BRUSH_ONLY true + virtual unsigned int PlayerSolidMask( bool brushOnly = false, CBasePlayer *testPlayer = NULL ) const; ///< returns the solid mask for the given player, so bots can have a more-restrictive set + CBasePlayer *player; + CMoveData *GetMoveData() { return mv; } +protected: + // Input/Output for this movement + CMoveData *mv; + + int m_nOldWaterLevel; + float m_flWaterEntryTime; + int m_nOnLadder; + + Vector m_vecForward; + Vector m_vecRight; + Vector m_vecUp; + + + // Does most of the player movement logic. + // Returns with origin, angles, and velocity modified in place. + // were contacted during the move. + virtual void PlayerMove( void ); + + // Set ground data, etc. + void FinishMove( void ); + + virtual float CalcRoll( const QAngle &angles, const Vector &velocity, float rollangle, float rollspeed ); + + // helper function for decaying punch angles over time with exponential and linear terms + void DecayAngles( QAngle& v, float fExp, float fLin, float dT ); + + virtual void DecayViewPunchAngle( void ); + + virtual void CheckWaterJump(void ); + + virtual void WaterMove( void ); + + virtual void WaterJump( void ); + + // Handles both ground friction and water friction + virtual void Friction( void ); + + virtual void AirAccelerate( Vector& wishdir, float wishspeed, float accel ); + + virtual void AirMove( void ); + + virtual bool CanAccelerate(); + virtual void Accelerate( Vector& wishdir, float wishspeed, float accel); + + // Only used by players. Moves along the ground when player is a MOVETYPE_WALK. + virtual void WalkMove( void ); + + // Try to keep a walking player on the ground when running down slopes etc + virtual void StayOnGround( void ); + + // Handle MOVETYPE_WALK. + virtual void FullWalkMove(); + + // allow overridden versions to respond to jumping + virtual void OnJump( float fImpulse ) {} + virtual void OnLand( float fVelocity ) {} + + // Implement this if you want to know when the player collides during OnPlayerMove + virtual void OnTryPlayerMoveCollision( trace_t &tr ) {} + + virtual const Vector& GetPlayerMins( void ) const; // uses local player + virtual const Vector& GetPlayerMaxs( void ) const; // uses local player + + typedef enum + { + GROUND = 0, + STUCK, + LADDER, + LADDER_WEDGE + } IntervalType_t; + + virtual int GetCheckInterval( IntervalType_t type ); + + // Useful for things that happen periodically. This lets things happen on the specified interval, but + // spaces the events onto different frames for different players so they don't all hit their spikes + // simultaneously. + bool CheckInterval( IntervalType_t type ); + + + // Decompoosed gravity + virtual void StartGravity( void ); + virtual void FinishGravity( void ); + + // Apply normal ( undecomposed ) gravity + virtual void AddGravity( void ); + + // Handle movement in noclip mode. + void FullNoClipMove( float factor, float maxacceleration ); + + // Returns true if he started a jump (ie: should he play the jump animation)? + virtual bool CheckJumpButton( void ); // Overridden by each game. + + // Dead player flying through air., e.g. + virtual void FullTossMove( void ); + + // Player is a Observer chasing another player + void FullObserverMove( void ); + + // Handle movement when in MOVETYPE_LADDER mode. + virtual void FullLadderMove(); + + // The basic solid body movement clip that slides along multiple planes + virtual int TryPlayerMove( Vector *pFirstDest=NULL, trace_t *pFirstTrace=NULL ); + + virtual bool LadderMove( void ); + virtual bool OnLadder( trace_t &trace ); + virtual float LadderDistance( void ) const { return 2.0f; } ///< Returns the distance a player can be from a ladder and still attach to it + virtual unsigned int LadderMask( void ) const { return MASK_PLAYERSOLID; } + virtual float ClimbSpeed( void ) const { return MAX_CLIMB_SPEED; } + virtual float LadderLateralMultiplier( void ) const { return 1.0f; } + + // special case code when starting the Ladder MoveType + void OnStartMoveTypeLadder( void ); + + // See if the player has a bogus velocity value. + void CheckVelocity( void ); + + // Does not change the entities velocity at all + void PushEntity( Vector& push, trace_t *pTrace ); + + // Slide off of the impacting object + // returns the blocked flags: + // 0x01 == floor + // 0x02 == step / wall + virtual int ClipVelocity( Vector& in, Vector& normal, Vector& out, float overbounce ); + + // If pmove.origin is in a solid position, + // try nudging slightly on all axis to + // allow for the cut precision of the net coordinates +#ifdef PORTAL + virtual +#endif + int CheckStuck( void ); + + // Check if the point is in water. + // Sets refWaterLevel and refWaterType appropriately. + // If in water, applies current to baseVelocity, and returns true. + virtual bool CheckWater( void ); + virtual void GetWaterCheckPosition( int waterLevel, Vector *pos ); + + // Determine if player is in water, on ground, etc. + virtual void CategorizePosition( void ); + + virtual void CheckParameters( void ); + + virtual void ReduceTimers( void ); + + virtual void CheckFalling( void ); + + virtual void PlayerRoughLandingEffects( float fvol ); + + void PlayerWaterSounds( void ); + + void ResetGetWaterContentsForPointCache(); + int GetWaterContentsForPointCached( const Vector &point, int slot ); + + // Ducking + virtual void Duck( void ); + virtual void HandleDuckingSpeedCrop(); + virtual void FinishUnDuck( void ); + virtual void FinishDuck( void ); + virtual bool CanUnduck(); + virtual void UpdateDuckJumpEyeOffset( void ); + virtual bool CanUnDuckJump( trace_t &trace ); + virtual void StartUnDuckJump( void ); + virtual void FinishUnDuckJump( trace_t &trace ); + virtual void SetDuckedEyeOffset( float duckFraction ); + virtual void FixPlayerCrouchStuck( bool moveup ); + + float SplineFraction( float value, float scale ); + + virtual void CategorizeGroundSurface( trace_t &pm ); + + virtual bool InWater( void ); + + // Commander view movement + void IsometricMove( void ); + + // Traces the player bbox as it is swept from start to end + virtual CBaseHandle TestPlayerPosition( const Vector& pos, int collisionGroup, trace_t& pm ); + + // Checks to see if we should actually jump + void PlaySwimSound(); + + bool IsDead( void ) const; + + // Figures out how the constraint should slow us down + float ComputeConstraintSpeedFactor( void ); + + virtual void SetGroundEntity( trace_t *pm ); + + virtual void StepMove( Vector &vecDestination, trace_t &trace ); + + bool CheckValidStandableGroundCandidate( trace_t &pm, float flStandableZ ); + +protected: + virtual ITraceFilter *LockTraceFilter( int collisionGroup ); + virtual void UnlockTraceFilter( ITraceFilter *&pFilter ); + + // Performs the collision resolution for fliers. + void PerformFlyCollisionResolution( trace_t &pm, Vector &move ); + + virtual bool GameHasLadders() const; + + enum + { + // eyes, waist, feet points (since they are all deterministic + MAX_PC_CACHE_SLOTS = 3, + }; + + // Cache used to remove redundant calls to GetPointContents() for water. + int m_CachedGetPointContents[ MAX_PLAYERS ][ MAX_PC_CACHE_SLOTS ]; + Vector m_CachedGetPointContentsPoint[ MAX_PLAYERS ][ MAX_PC_CACHE_SLOTS ]; + +//private: + int m_iSpeedCropped; + + bool m_bProcessingMovement; + bool m_bInStuckTest; + + float m_flStuckCheckTime[MAX_PLAYERS+1][2]; // Last time we did a full test + + // special function for teleport-with-duck for episodic +#ifdef HL2_EPISODIC +public: + void ForceDuck( void ); + +#endif + void *m_pTraceListData; + + int m_nTraceCount; +}; + + + + +#endif // GAMEMOVEMENT_H \ No newline at end of file diff --git a/SpyCustom/sdk/igamemovement.h b/SpyCustom/sdk/igamemovement.h new file mode 100644 index 0000000..795c739 --- /dev/null +++ b/SpyCustom/sdk/igamemovement.h @@ -0,0 +1,157 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//=============================================================================// + +#if !defined( IGAMEMOVEMENT_H ) +#define IGAMEMOVEMENT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vector.h" +#include "interface.h" +#include "imovehelper.h" +#include "const.h" + +//----------------------------------------------------------------------------- +// Name of the class implementing the game movement. +//----------------------------------------------------------------------------- + +#define INTERFACENAME_GAMEMOVEMENT "GameMovement001" + +//----------------------------------------------------------------------------- +// Forward declarations. +//----------------------------------------------------------------------------- + +class IMoveHelper; + +//----------------------------------------------------------------------------- +// Purpose: Encapsulated input parameters to player movement. +//----------------------------------------------------------------------------- + +class CMoveData +{ +public: + bool m_bFirstRunOfFunctions : 1; + bool m_bGameCodeMovedPlayer : 1; + //bool m_bNoAirControl : 1; + + EntityHandle_t m_nPlayerHandle; // edict index on server, client entity handle on client + + int m_nImpulseCommand; // Impulse command issued. + QAngle m_vecViewAngles; // Command view angles (local space) + QAngle m_vecAbsViewAngles; // Command view angles (world space) + int m_nButtons; // Attack buttons. + int m_nOldButtons; // From host_client->oldbuttons; + float m_flForwardMove; + float m_flSideMove; + float m_flUpMove; + + float m_flMaxSpeed; + float m_flClientMaxSpeed; + + // Variables from the player edict (sv_player) or entvars on the client. + // These are copied in here before calling and copied out after calling. + Vector m_vecVelocity; // edict::velocity // Current movement direction. + //Vector m_vecTrailingVelocity; + //float m_flTrailingVelocityTime; + QAngle m_vecAngles; // edict::angles + QAngle m_vecOldAngles; + +// Output only + float m_outStepHeight; // how much you climbed this move + Vector m_outWishVel; // This is where you tried + Vector m_outJumpVel; // This is your jump velocity + + // Movement constraints (radius 0 means no constraint) + Vector m_vecConstraintCenter; + float m_flConstraintRadius; + float m_flConstraintWidth; + float m_flConstraintSpeedFactor; + //bool m_bConstraintPastRadius; ///< If no, do no constraining past Radius. If yes, cap them to SpeedFactor past radius + + float u0[5]; + + void SetAbsOrigin( const Vector &vec ); + const Vector &GetAbsOrigin() const; + +//private: + Vector m_vecAbsOrigin; // edict::origin +}; + +inline const Vector &CMoveData::GetAbsOrigin() const +{ + return m_vecAbsOrigin; +} + +#if !defined( CLIENT_DLL ) && defined( _DEBUG ) +// We only ever want this code path on the server side in a debug build +// and you have to uncomment the code below and rebuild to have the test operate. +//#define PLAYER_GETTING_STUCK_TESTING + +#endif + +#if !defined( PLAYER_GETTING_STUCK_TESTING ) + +// This is implemented with a more exhaustive test in gamemovement.cpp. We check if the origin being requested is +// inside solid, which it never should be +inline void CMoveData::SetAbsOrigin( const Vector &vec ) +{ + m_vecAbsOrigin = vec; +} + +#endif + + +//----------------------------------------------------------------------------- +// Purpose: The basic player movement interface +//----------------------------------------------------------------------------- + +abstract_class IGameMovement +{ +public: + virtual ~IGameMovement( void ) {} + + // Process the current movement command + virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) = 0; + virtual void Reset( void ) = 0; + virtual void StartTrackPredictionErrors( CBasePlayer *pPlayer ) = 0; + virtual void FinishTrackPredictionErrors( CBasePlayer *pPlayer ) = 0; + virtual void DiffPrint( PRINTF_FORMAT_STRING char const *fmt, ... ) = 0; + + // Allows other parts of the engine to find out the normal and ducked player bbox sizes + virtual Vector const& GetPlayerMins( bool ducked ) const = 0; + virtual Vector const& GetPlayerMaxs( bool ducked ) const = 0; + virtual Vector const& GetPlayerViewOffset( bool ducked ) const = 0; + + virtual bool IsMovingPlayerStuck( void ) const = 0; + virtual CBasePlayer *GetMovingPlayer( void ) const = 0; + virtual void UnblockPusher( CBasePlayer *pPlayer, CBaseEntity *pPusher ) = 0; + + virtual void SetupMovementBounds( CMoveData *pMove ) = 0; + + void ProcessMovement_v(C_BaseEntity* player, CMoveData* move) { + typedef bool(__thiscall* OriginalFn)(void*, C_BaseEntity*, CMoveData*); + getvfunc(this, 2)(this, player, move); + } + + void StartTrackPredictionErrors_v(C_BaseEntity* player) { + typedef void(__thiscall* OriginalFn)(void*, C_BaseEntity*); + getvfunc(this, 4)(this, player); + } + + void FinishTrackPredictionErrors_v(C_BaseEntity* player) { + typedef void(__thiscall* OriginalFn)(void*, C_BaseEntity*); + getvfunc(this, 5)(this, player); + } + +}; + + +#endif // IGAMEMOVEMENT_H \ No newline at end of file diff --git a/SpyCustom/sdk/imovehelper.h b/SpyCustom/sdk/imovehelper.h index 32432c4..048d34a 100644 --- a/SpyCustom/sdk/imovehelper.h +++ b/SpyCustom/sdk/imovehelper.h @@ -54,12 +54,18 @@ public: virtual bool IsWorldEntity(const CBaseHandle& handle) = 0; -protected: +//protected: static void SetSingleton(IMoveHelper* pMoveHelper) { sm_pSingleton = pMoveHelper; } virtual ~IMoveHelper() {} static IMoveHelper* sm_pSingleton; + + + void SetHost_v(C_BaseEntity* player) { + typedef void(__thiscall* OriginalFn)(void*, C_BaseEntity*); + getvfunc(this, 1)(this, player); + } }; #define IMPLEMENT_MOVEHELPER() \ @@ -70,5 +76,73 @@ inline IMoveHelper* MoveHelper() return IMoveHelper::GetSingleton(); } +//movehelper_client.cpp +//https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/client/movehelper_client.cpp + +class CMoveHelperClient : public IMoveHelper +{ +public: + CMoveHelperClient(void); + virtual ~CMoveHelperClient(void); + + char const* GetName(EntityHandle_t handle) const; + + // touch lists + virtual void ResetTouchList(void); + virtual bool AddToTouched(const trace_t& tr, const Vector& impactvelocity); + virtual void ProcessImpacts(void); + + // Numbered line printf + virtual void Con_NPrintf(int idx, char const* fmt, ...); + + virtual bool PlayerFallingDamage(void); + virtual void PlayerSetAnimation(PLAYER_ANIM eAnim); + + // These have separate server vs client impementations + virtual void StartSound(const Vector& origin, int channel, char const* sample, float volume, soundlevel_t soundlevel, int fFlags, int pitch); + virtual void StartSound(const Vector& origin, const char* soundname); + virtual void PlaybackEventFull(int flags, int clientindex, unsigned short eventindex, float delay, Vector& origin, Vector& angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); + virtual IPhysicsSurfaceProps* GetSurfaceProps(void); + + virtual bool IsWorldEntity(const CBaseHandle& handle); + + inline void SetHost(C_BaseEntity* host); + +//private: + // results, tallied on client and server, but only used by server to run SV_Impact. + // we store off our velocity in the trace_t structure so that we can determine results + // of shoving boxes etc. around. + struct touchlist_t + { + Vector deltavelocity; + trace_t trace; + + touchlist_t() {} + + private: + touchlist_t(const touchlist_t& src); + }; + + CUtlVector m_TouchList; + + C_BaseEntity* m_pHost; +}; + + +//----------------------------------------------------------------------------- +// Indicates which entity we're going to move +//----------------------------------------------------------------------------- + +inline void CMoveHelperClient::SetHost(C_BaseEntity* host) +{ + m_pHost = host; + + // In case any stuff is ever left over, sigh... + ResetTouchList(); +} + + + + #endif \ No newline at end of file diff --git a/SpyCustom/sdk/iprediction.h b/SpyCustom/sdk/iprediction.h index e02d8f3..a4a89a9 100644 --- a/SpyCustom/sdk/iprediction.h +++ b/SpyCustom/sdk/iprediction.h @@ -259,6 +259,27 @@ public: CPDumpPanel* m_pPDumpPanel; #endif + + + bool InPrediction_v() { + typedef bool(__thiscall* o_in_prediction)(void*); + return getvfunc(this, 10)(this); + } + + void RunCommand_v(C_BaseEntity* player, CUserCmd* cmd, IMoveHelper* helper) { + typedef void(__thiscall* o_run_command)(void*, C_BaseEntity*, CUserCmd*, IMoveHelper*); + return getvfunc(this, 19)(this, player, cmd, helper); + } + + void SetupMove_v(C_BaseEntity* player, CUserCmd* cmd, IMoveHelper* helper, void* data) { + typedef void(__thiscall* o_setup_move)(void*, C_BaseEntity*, CUserCmd*, IMoveHelper*, void*); + return getvfunc(this, 20)(this, player, cmd, helper, data); + } + + void FinishMove_v(C_BaseEntity* player, CUserCmd* cmd, void* data) { + typedef void(__thiscall* o_finish_move)(void*, C_BaseEntity*, CUserCmd*, void*); + return getvfunc(this, 21)(this, player, cmd, data); + } }; diff --git a/SpyCustom/sdk/ivmodelinfo.h b/SpyCustom/sdk/ivmodelinfo.h index f1f236a..bf132a0 100644 --- a/SpyCustom/sdk/ivmodelinfo.h +++ b/SpyCustom/sdk/ivmodelinfo.h @@ -7,6 +7,7 @@ #include "platform.h" #include "dbg.h" +#include "gametrace.h" class IMaterial; class KeyValues; @@ -14,7 +15,7 @@ struct vcollide_t; struct model_t; class Vector; class QAngle; -class CGameTrace; +//class CGameTrace; struct cplane_t; typedef CGameTrace trace_t; struct studiohdr_t; diff --git a/SpyCustom/sdk/vector.h b/SpyCustom/sdk/vector.h index 81c65fd..d415f33 100644 --- a/SpyCustom/sdk/vector.h +++ b/SpyCustom/sdk/vector.h @@ -23,6 +23,13 @@ #include "minmax.h" +#include +//#include . +#define pi_v 3.14159265358979323846 +template constexpr auto deg2rad(T degrees) noexcept { return degrees * (static_cast(pi_v) / static_cast(180)); } +template constexpr auto rad2deg(T radians) noexcept { return radians * (static_cast(180) / static_cast(pi_v)); } + + #define X_INDEX 0 #define Y_INDEX 1 #define Z_INDEX 2 @@ -150,6 +157,26 @@ public: private: Vector(const Vector& vOther); #endif + + inline Vector toAngle() const + { + return Vector{ rad2deg(std::atan2(-z, std::hypot(x, y))), + rad2deg(std::atan2(y, x)), + 0.0f }; + } + + static auto fromAngle(const Vector& angle) + { + return Vector{ std::cos(deg2rad(angle.x)) * std::cos(deg2rad(angle.y)), + std::cos(deg2rad(angle.x)) * std::sin(deg2rad(angle.y)), + -std::sin(deg2rad(angle.x)) }; + } + + auto length2D() const noexcept + { + return std::sqrt(x * x + y * y); + } + }; FORCEINLINE void NetworkVarConstruct(Vector& v) { v.Zero(); } @@ -1893,4 +1920,9 @@ inline bool Vector::IsLengthLessThan(float val) const return LengthSqr() < val * val; } + + + + + #endif