Advertisement
keybode

old css new sdk

Aug 15th, 2015
1,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 28.05 KB | None | 0 0
  1. #ifndef SDK_H
  2. #define SDK_H
  3.  
  4. #pragma once
  5.  
  6. #include "API.h"
  7. #include "Math.h"
  8. #include "Import.h"
  9. #include "CRC32.h"
  10.  
  11. #include "checksum_md5.h"
  12. #include "dt_recv.h"
  13.  
  14. #ifdef DrawText
  15.     #undef DrawText
  16. #endif
  17.  
  18. #ifdef CreateFont
  19.     #undef CreateFont
  20. #endif
  21.  
  22. #define TICK_INTERVAL           (HL2::m_pGlobals->interval_per_tick)
  23.  
  24. #define TIME_TO_TICKS( dt )     ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
  25. #define TICKS_TO_TIME( t )      ( TICK_INTERVAL *( t ) )
  26. #define ROUND_TO_TICKS( t )     ( TICK_INTERVAL * TIME_TO_TICKS( t ) )
  27. #define TICK_NEVER_THINK        (-1)
  28.  
  29. enum
  30. {
  31.     CHAR_TEX_ANTLION = 'A',
  32.     CHAR_TEX_BLOODYFLESH = 'B',
  33.     CHAR_TEX_CONCRETE = 'C',
  34.     CHAR_TEX_DIRT = 'D',
  35.     CHAR_TEX_EGGSHELL = 'E',
  36.     CHAR_TEX_FLESH = 'F',
  37.     CHAR_TEX_GRATE = 'G',
  38.     CHAR_TEX_ALIENFLESH = 'H',
  39.     CHAR_TEX_CLIP = 'I',
  40.     CHAR_TEX_PLASTIC = 'L',
  41.     CHAR_TEX_METAL = 'M',
  42.     CHAR_TEX_SAND = 'N',
  43.     CHAR_TEX_FOLIAGE = 'O',
  44.     CHAR_TEX_COMPUTER = 'P',
  45.     CHAR_TEX_SLOSH = 'S',
  46.     CHAR_TEX_TILE = 'T',
  47.     CHAR_TEX_VENT = 'V',
  48.     CHAR_TEX_WOOD = 'W',
  49.     CHAR_TEX_GLASS = 'Y',
  50.     CHAR_TEX_WARPSHIELD = 'Z'
  51. };
  52.  
  53. enum
  54. {
  55.     LIFE_ALIVE = 0,
  56.     LIFE_DYING,
  57.     LIFE_DEAD
  58. };
  59.  
  60. enum MoveType_t
  61. {
  62.     MOVETYPE_NONE = 0,
  63.     MOVETYPE_ISOMETRIC,
  64.     MOVETYPE_WALK,
  65.     MOVETYPE_STEP,
  66.     MOVETYPE_FLY,
  67.     MOVETYPE_FLYGRAVITY,
  68.     MOVETYPE_VPHYSICS,
  69.     MOVETYPE_PUSH,
  70.     MOVETYPE_NOCLIP,
  71.     MOVETYPE_LADDER,
  72.     MOVETYPE_OBSERVER,
  73.     MOVETYPE_CUSTOM,
  74.     MOVETYPE_LAST = MOVETYPE_CUSTOM,
  75.     MOVETYPE_MAX_BITS = 4
  76. };
  77.  
  78. enum
  79. {
  80.     FL_ONGROUND = (1 << 0),
  81.     FL_DUCKING = (1 << 1)
  82. };
  83.  
  84. enum
  85. {
  86.     IN_ATTACK = (1 << 0),
  87.     IN_JUMP = (1 << 1),
  88.     IN_DUCK = (1 << 2),
  89.     IN_FORWARD = (1 << 3),
  90.     IN_BACK = (1 << 4),
  91.     IN_USE = (1 << 5),
  92.     IN_CANCEL = (1 << 6),
  93.     IN_LEFT = (1 << 7),
  94.     IN_RIGHT = (1 << 8),
  95.     IN_MOVELEFT = (1 << 9),
  96.     IN_MOVERIGHT = (1 << 10),
  97.     IN_ATTACK2 = (1 << 11),
  98.     IN_RUN = (1 << 12),
  99.     IN_RELOAD = (1 << 13),
  100.     IN_ALT1 = (1 << 14),
  101.     IN_ALT2 = (1 << 15),
  102.     IN_SCORE = (1 << 16),
  103.     IN_SPEED = (1 << 17),
  104.     IN_WALK = (1 << 18),
  105.     IN_ZOOM = (1 << 19),
  106.     IN_WEAPON1 = (1 << 20),
  107.     IN_WEAPON2 = (1 << 21),
  108.     IN_BULLRUSH = (1 << 22),
  109.     IN_GRENADE1 = (1 << 23),
  110.     IN_GRENADE2 = (1 << 24)
  111. };
  112.  
  113. enum
  114. {
  115.     MULTIPLAYER_BACKUP = 90
  116. };
  117.  
  118. enum CSWeaponType
  119. {
  120.     WEAPONTYPE_KNIFE = 0,
  121.     WEAPONTYPE_PISTOL,
  122.     WEAPONTYPE_SUBMACHINEGUN,
  123.     WEAPONTYPE_RIFLE,
  124.     WEAPONTYPE_SHOTGUN,
  125.     WEAPONTYPE_SNIPER_RIFLE,
  126.     WEAPONTYPE_MACHINEGUN,
  127.     WEAPONTYPE_C4,
  128.     WEAPONTYPE_GRENADE,
  129.     WEAPONTYPE_UNKNOWN
  130. };
  131.  
  132. enum CSWeaponID
  133. {
  134.     WEAPON_NONE = 0,
  135.     WEAPON_P228,
  136.     WEAPON_GLOCK,
  137.     WEAPON_SCOUT,
  138.     WEAPON_HEGRENADE,
  139.     WEAPON_XM1014,
  140.     WEAPON_C4,
  141.     WEAPON_MAC10,
  142.     WEAPON_AUG,
  143.     WEAPON_SMOKEGRENADE,
  144.     WEAPON_ELITE,
  145.     WEAPON_FIVESEVEN,
  146.     WEAPON_UMP45,
  147.     WEAPON_SG550,
  148.     WEAPON_GALIL,
  149.     WEAPON_FAMAS,
  150.     WEAPON_USP,
  151.     WEAPON_AWP,
  152.     WEAPON_MP5NAVY,
  153.     WEAPON_M249,
  154.     WEAPON_M3,
  155.     WEAPON_M4A1,
  156.     WEAPON_TMP,
  157.     WEAPON_G3SG1,
  158.     WEAPON_FLASHBANG,
  159.     WEAPON_DEAGLE,
  160.     WEAPON_SG552,
  161.     WEAPON_AK47,
  162.     WEAPON_KNIFE,
  163.     WEAPON_P90,
  164.  
  165.     WEAPON_MAX
  166. };
  167.  
  168. enum
  169. {
  170.     FLOW_OUTGOING = 0,
  171.     FLOW_INCOMING,
  172.     MAX_FLOWS
  173. };
  174.  
  175. enum TraceType_t
  176. {
  177.     TRACE_EVERYTHING = 0,
  178.     TRACE_WORLD_ONLY,
  179.     TRACE_ENTITIES_ONLY,
  180.     TRACE_EVERYTHING_FILTER_PROPS
  181. };
  182.  
  183. enum
  184. {
  185.     MAXSTUDIOSKINS = 32,
  186.     MAXSTUDIOBONES = 128
  187. };
  188.  
  189. enum
  190. {
  191.     BONE_USED_BY_HITBOX = 256
  192. };
  193.  
  194. enum MaterialVarFlags_t
  195. {
  196.     MATERIAL_VAR_DEBUG = (1 << 0),
  197.     MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
  198.     MATERIAL_VAR_NO_DRAW = (1 << 2),
  199.     MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),
  200.  
  201.     MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
  202.     MATERIAL_VAR_VERTEXALPHA = (1 << 5),
  203.     MATERIAL_VAR_SELFILLUM = (1 << 6),
  204.     MATERIAL_VAR_ADDITIVE = (1 << 7),
  205.     MATERIAL_VAR_ALPHATEST = (1 << 8),
  206.     MATERIAL_VAR_MULTIPASS = (1 << 9),
  207.     MATERIAL_VAR_ZNEARER = (1 << 10),
  208.     MATERIAL_VAR_MODEL = (1 << 11),
  209.     MATERIAL_VAR_FLAT = (1 << 12),
  210.     MATERIAL_VAR_NOCULL = (1 << 13),
  211.     MATERIAL_VAR_NOFOG = (1 << 14),
  212.     MATERIAL_VAR_IGNOREZ = (1 << 15),
  213.     MATERIAL_VAR_DECAL = (1 << 16),
  214.     MATERIAL_VAR_ENVMAPSPHERE = (1 << 17),
  215.     MATERIAL_VAR_NOALPHAMOD = (1 << 18),
  216.     MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19),
  217.     MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
  218.     MATERIAL_VAR_TRANSLUCENT = (1 << 21),
  219.     MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
  220.     MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23),
  221.     MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
  222.     MATERIAL_VAR_ENVMAPMODE = (1 << 25),
  223.     MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
  224.     MATERIAL_VAR_HALFLAMBERT = (1 << 27),
  225.     MATERIAL_VAR_WIREFRAME = (1 << 28)
  226. };
  227.  
  228. enum ClientFrameStage_t
  229. {
  230.     FRAME_UNDEFINED = -1,
  231.     FRAME_START,
  232.  
  233.     FRAME_NET_UPDATE_START,
  234.     FRAME_NET_UPDATE_POSTDATAUPDATE_START,
  235.     FRAME_NET_UPDATE_POSTDATAUPDATE_END,
  236.     FRAME_NET_UPDATE_END,
  237.  
  238.     FRAME_RENDER_START,
  239.     FRAME_RENDER_END
  240. };
  241.  
  242. struct player_info_t;
  243. struct Ray_t;
  244. struct cplane_t;
  245. struct csurface_t;
  246. struct mstudiobone_t;
  247. struct mstudiobbox_t;
  248. struct mstudiohitboxset_t;
  249. struct studiohdr_t;
  250. struct model_t;
  251. struct surfacephysicsparams_t;
  252. struct surfaceaudioparams_t;
  253. struct surfacesoundnames_t;
  254. struct surfacesoundhandles_t;
  255. struct surfacegameprops_t;
  256. struct surfacedata_t;
  257. struct ModelRenderInfo_t;
  258.  
  259. class IHandleEntity;
  260. class ICollideable;
  261. class IClientNetworkable;
  262. class IClientRenderable;
  263. class C_BaseEntity;
  264. class C_BaseAnimating;
  265. class C_BaseCombatCharacter;
  266. class C_BasePlayer;
  267. class C_CSPlayer;
  268. class C_BaseCombatWeapon;
  269. class C_WeaponCSBase;
  270.  
  271. class CGlobalVarsBase;
  272. class ClientClass;
  273. class IBaseClientDLL;
  274. class CUserCmd;
  275. class CInput;
  276. class IClientEntityList;
  277. class IMoveHelper;
  278. class CMoveData;
  279. class IPrediction;
  280. class IGameMovement;
  281. class INetChannelInfo;
  282. class IVEngineClient;
  283. class ConVar;
  284. class ICvar;
  285. class CBaseTrace;
  286. class CGameTrace;
  287. class ITraceFilter;
  288. class CTraceFilter;
  289. class CTraceFilterSimple;
  290. class CTraceFilterSkipTwoEntities;
  291. class IEngineTrace;
  292. class IVModelInfoClient;
  293. class IPhysicsSurfaceProps;
  294. class IVRenderView;
  295. class IMaterial;
  296. class IMaterialSystem;
  297. class IVModelRender;
  298. class IPanel;
  299. class ISurface;
  300. class IGameEvent;
  301. class IGameEventListener2;
  302. class IGameEventManager2;
  303.  
  304. typedef unsigned long CBaseHandle;
  305. typedef CGameTrace trace_t;
  306. typedef unsigned short MaterialHandle_t;
  307. typedef unsigned short ModelInstanceHandle_t;
  308. typedef unsigned int VPANEL;
  309. typedef unsigned long HFont;
  310.  
  311. typedef void* (*CreateInterfaceFn)(const char*, int*);
  312.  
  313. typedef void (__thiscall* CreateMoveFn)(void*, int, float, bool);
  314. typedef void (__thiscall* FrameStageNotifyFn)(void*, ClientFrameStage_t);
  315. typedef void (__thiscall* ResetMouseFn)(void*);
  316. typedef bool (__thiscall* InPredictionFn)(void*);
  317. typedef void (__thiscall* RunCommandFn)(void*, C_BasePlayer*, CUserCmd*, IMoveHelper*);
  318. typedef void (__thiscall* _UpdateFn)(void*, bool, bool, int, int);
  319. typedef int (__thiscall* DrawModelExFn)(void*, ModelRenderInfo_t&);
  320. typedef void (__thiscall* PaintTraverseFn)(void*, VPANEL, bool, bool);
  321.  
  322. enum
  323. {
  324.     INDEX_GETUSERCMD = 8,
  325.     INDEX_CREATEMOVE = 18,
  326.     INDEX_INPREDICTION = 16,
  327.     INDEX_RUNCOMMAND = 19,
  328.     INDEX__UPDATE = 23,
  329.     INDEX_RESETMOUSE = 23,
  330.     INDEX_FRAMESTAGENOTIFY = 32,
  331.     INDEX_DRAWMODELEX = 19,
  332.     INDEX_PAINTTRAVERSE = 40
  333. };
  334.  
  335. class CGlobalVarsBase
  336. {
  337. public:
  338.     float           realtime;
  339.     int             framecount;
  340.     float           absoluteframetime;
  341.     float           curtime;
  342.     float           frametime;
  343.     int             maxClients;
  344.     int             tickcount;
  345.     float           interval_per_tick;
  346.     float           interpolation_amount;
  347. };
  348.  
  349. class ClientClass
  350. {
  351. public:
  352.     void*           m_pCreateFn;
  353.     void*           m_pCreateEventFn;
  354.     const char*     m_pNetworkName;
  355.     RecvTable*      m_pRecvTable;
  356.     ClientClass*    m_pNext;
  357.     int             m_ClassID;
  358. };
  359.  
  360. class IBaseClientDLL
  361. {
  362. public:
  363.     ClientClass* GetAllClasses()
  364.     {
  365.         typedef ClientClass* (__thiscall* GetAllClassesFn)(void*);
  366.         return GetMethod<GetAllClassesFn>(this, 5)(this);
  367.     }
  368. };
  369.  
  370. class CUserCmd
  371. {
  372. public:
  373.     virtual         ~CUserCmd() {};
  374.  
  375.     int             command_number;
  376.     int             tick_count;
  377.     Vector3         viewangles;
  378.     float           forwardmove;
  379.     float           sidemove;
  380.     float           upmove;
  381.     int             buttons;
  382.     byte            impulse;
  383.     int             weaponselect;
  384.     int             weaponsubtype;
  385.     int             random_seed;
  386.     short           mousedx;
  387.     short           mousedy;
  388.     bool            hasbeenpredicted;
  389. };
  390.  
  391. class CInput
  392. {
  393. public:
  394.     unsigned char   __pad0[0xC4];
  395.     CUserCmd*       m_pCommands;
  396. };
  397.  
  398. class IClientEntityList
  399. {
  400. public:
  401.     C_BaseEntity* GetClientEntity(int entnum)
  402.     {
  403.         typedef C_BaseEntity* (__thiscall* GetClientEntityFn)(void*, int);
  404.         return GetMethod<GetClientEntityFn>(this, 3)(this, entnum);
  405.     }
  406.  
  407.     C_BaseEntity* GetClientEntityFromHandle(CBaseHandle hEnt)
  408.     {
  409.         typedef C_BaseEntity* (__thiscall* GetClientEntityFromHandleFn)(void*, CBaseHandle);
  410.         return GetMethod<GetClientEntityFromHandleFn>(this, 4)(this, hEnt);
  411.     }
  412.  
  413.     int GetHighestEntityIndex()
  414.     {
  415.         typedef int(__thiscall* GetHighestEntityIndexFn)(void*);
  416.         return GetMethod<GetHighestEntityIndexFn>(this, 6)(this);
  417.     }
  418. };
  419.  
  420. class CMoveData
  421. {
  422. public:
  423.     unsigned char   __pad0[0xFF];
  424. };
  425.  
  426. class IPrediction
  427. {
  428. public:
  429.     void SetupMove(C_BasePlayer* player, CUserCmd* ucmd, IMoveHelper* pHelper, CMoveData* move)
  430.     {
  431.         typedef void(__thiscall* SetupMoveFn)(void*, C_BasePlayer*, CUserCmd*, IMoveHelper*, CMoveData*);
  432.         GetMethod<SetupMoveFn>(this, 20)(this, player, ucmd, pHelper, move);
  433.     }
  434.  
  435.     void FinishMove(C_BasePlayer* player, CUserCmd* ucmd, CMoveData* move)
  436.     {
  437.         typedef void(__thiscall* FinishMoveFn)(void*, C_BasePlayer*, CUserCmd*, CMoveData*);
  438.         GetMethod<FinishMoveFn>(this, 21)(this, player, ucmd, move);
  439.     }
  440. };
  441.  
  442. class IGameMovement
  443. {
  444. public:
  445.     void ProcessMovement(C_BasePlayer* pPlayer, CMoveData* pMove)
  446.     {
  447.         typedef void(__thiscall* ProcessMovementFn)(void*, C_BasePlayer*, CMoveData*);
  448.         GetMethod<ProcessMovementFn>(this, 1)(this, pPlayer, pMove);
  449.     }
  450. };
  451.  
  452. struct player_info_t
  453. {
  454.     char            name[32];
  455.     int             userID;
  456.     char            guid[33];
  457.     unsigned int    friendsID;
  458.     char            friendsName[32];
  459.     bool            fakeplayer;
  460.     bool            ishltv;
  461.     unsigned long   customFiles[4];
  462.     unsigned char   filesDownloaded;
  463. };
  464.  
  465. class INetChannelInfo
  466. {
  467. public:
  468.     float GetLatency(int flow)
  469.     {
  470.         typedef float(__thiscall* GetLatencyFn)(void*, int);
  471.         return GetMethod<GetLatencyFn>(this, 9)(this, flow);
  472.     }
  473.  
  474.     float GetAvgLatency(int flow)
  475.     {
  476.         typedef float(__thiscall* GetAvgLatencyFn)(void*, int);
  477.         return GetMethod< GetAvgLatencyFn >(this, 10)(this, flow);
  478.     }
  479. };
  480.  
  481. class IVEngineClient
  482. {
  483. public:
  484.     void GetScreenSize(int& width, int& height)
  485.     {
  486.         typedef void(__thiscall* GetScreenSizeFn)(void*, int&, int&);
  487.         GetMethod<GetScreenSizeFn>(this, 5)(this, width, height);
  488.     }
  489.  
  490.     void ClientCmd(const char* szCmdString)
  491.     {
  492.         typedef void(__thiscall* ClientCmdFn)(void*, const char*);
  493.         GetMethod<ClientCmdFn>(this, 7)(this, szCmdString);
  494.     }
  495.  
  496.     bool GetPlayerInfo(int ent_num, player_info_t* pinfo)
  497.     {
  498.         typedef bool(__thiscall* GetPlayerInfoFn)(void*, int, player_info_t*);
  499.         return GetMethod<GetPlayerInfoFn>(this, 8)(this, ent_num, pinfo);
  500.     }
  501.  
  502.     int GetPlayerForUserID(int userID)
  503.     {
  504.         typedef int(__thiscall* GetPlayerForUserIDFn)(void*, int);
  505.         return GetMethod<GetPlayerForUserIDFn>(this, 9)(this, userID);
  506.     }
  507.  
  508.     bool Con_IsVisible()
  509.     {
  510.         typedef bool(__thiscall* Con_IsVisibleFn)(void*);
  511.         return GetMethod<Con_IsVisibleFn>(this, 11)(this);
  512.     }
  513.  
  514.     int GetLocalPlayer()
  515.     {
  516.         typedef int(__thiscall* GetLocalPlayerFn)(void*);
  517.         return GetMethod<GetLocalPlayerFn>(this, 12)(this);
  518.     }
  519.  
  520.     void GetViewAngles(Vector3& va)
  521.     {
  522.         typedef void(__thiscall* GetViewAnglesFn)(void*, Vector3&);
  523.         GetMethod<GetViewAnglesFn>(this, 19)(this, va);
  524.     }
  525.  
  526.     void SetViewAngles(Vector3& va)
  527.     {
  528.         typedef void(__thiscall* SetViewAnglesFn)(void*, Vector3&);
  529.         GetMethod<SetViewAnglesFn>(this, 20)(this, va);
  530.     }
  531.  
  532.     int GetMaxClients()
  533.     {
  534.         typedef int(__thiscall* GetMaxClientsFn)(void*);
  535.         return GetMethod<GetMaxClientsFn>(this, 21)(this);
  536.     }
  537.  
  538.     bool IsInGame()
  539.     {
  540.         typedef bool(__thiscall* IsInGameFn)(void*);
  541.         return GetMethod<IsInGameFn>(this, 26)(this);
  542.     }
  543.  
  544.     bool IsConnected()
  545.     {
  546.         typedef bool(__thiscall* IsConnectedFn)(void*);
  547.         return GetMethod<IsConnectedFn>(this, 27)(this);
  548.     }
  549.  
  550.     bool IsDrawingLoadingImage()
  551.     {
  552.         typedef bool(__thiscall* IsDrawingLoadingImageFn)(void*);
  553.         return GetMethod<IsDrawingLoadingImageFn>(this, 28)(this);
  554.     }
  555.  
  556.     const VMatrix& WorldToScreenMatrix()
  557.     {
  558.         typedef const VMatrix& (__thiscall* WorldToScreenMatrixFn)(void*);
  559.         return GetMethod<WorldToScreenMatrixFn>(this, 38)(this);
  560.     }
  561.  
  562.     INetChannelInfo* GetNetChannelInfo()
  563.     {
  564.         typedef INetChannelInfo* (__thiscall* GetNetChannelInfoFn)(void*);
  565.         return GetMethod<GetNetChannelInfoFn>(this, 72)(this);
  566.     }
  567.  
  568.     bool IsTakingScreenshot()
  569.     {
  570.         typedef bool(__thiscall* IsTakingScreenshotFn)(void*);
  571.         return GetMethod<IsTakingScreenshotFn>(this, 80)(this);
  572.     }
  573. };
  574.  
  575. class ConVar
  576. {
  577. public:
  578.     float GetFloat()
  579.     {
  580.         return m_fValue;
  581.     }
  582.  
  583.     int GetInt()
  584.     {
  585.         return m_nValue;
  586.     }
  587.  
  588.     bool GetBool()
  589.     {
  590.         return !!GetInt();
  591.     }
  592.  
  593.     void SetValue(const char* value)
  594.     {
  595.         typedef void(__thiscall* SetValueFn)(void*, const char*);
  596.         GetMethod<SetValueFn>(this, 11)(this, value);
  597.     }
  598.  
  599.     void SetValue(float value)
  600.     {
  601.         typedef void(__thiscall* SetValueFn)(void*, float);
  602.         GetMethod<SetValueFn>(this, 10)(this, value);
  603.     }
  604.  
  605.     void SetValue(int value)
  606.     {
  607.         typedef void(__thiscall* SetValueFn)(void*, int);
  608.         GetMethod<SetValueFn>(this, 9)(this, value);
  609.     }
  610.  
  611. private:
  612.     unsigned char   __pad0[0x28];
  613.     float           m_fValue;
  614.     int             m_nValue;
  615. };
  616.  
  617. class ICvar
  618. {
  619. public:
  620.     ConVar* FindVar(const char* var_name)
  621.     {
  622.         typedef ConVar* (__thiscall* FindVarFn)(void*, const char*);
  623.         return GetMethod<FindVarFn>(this, 7)(this, var_name);
  624.     }
  625. };
  626.  
  627. struct Ray_t
  628. {
  629.     Vector3     m_Start;
  630.     Vector3     m_Delta;
  631.     Vector3     m_StartOffset;
  632.     Vector3     m_Extents;
  633.     bool        m_IsRay;
  634.     bool        m_IsSwept;
  635.  
  636.     void Init(Vector3 const& start, Vector3 const& end)
  637.     {
  638.         m_Delta = end - start;
  639.  
  640.         m_IsSwept = (m_Delta.LengthSqr() != 0);
  641.  
  642.         m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
  643.         m_IsRay = true;
  644.  
  645.         m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
  646.         m_Start = start;
  647.     }
  648.  
  649.     void Init(Vector3 const& start, Vector3 const& end, Vector3 const& mins, Vector3 const& maxs)
  650.     {
  651.         m_Delta = end - start;
  652.  
  653.         m_IsSwept = (m_Delta.LengthSqr() != 0);
  654.  
  655.         m_Extents = maxs - mins;
  656.         m_Extents *= 0.5f;
  657.         m_IsRay = (m_Extents.LengthSqr() < 1e-6);
  658.  
  659.         m_StartOffset = mins + maxs;
  660.         m_StartOffset *= 0.5f;
  661.         m_Start = start + m_StartOffset;
  662.         m_StartOffset *= -1.0f;
  663.     }
  664. };
  665.  
  666. struct cplane_t
  667. {
  668.     Vector3     normal;
  669.     float       dist;
  670.     byte        type;
  671.     byte        signbits;
  672.     byte        pad[2];
  673. };
  674.  
  675. class CBaseTrace
  676. {
  677. public:
  678.     Vector3         startpos;
  679.     Vector3         endpos;
  680.     cplane_t        plane;
  681.     float           fraction;
  682.     int             contents;
  683.     unsigned short  dispFlags;
  684.     bool            allsolid;
  685.     bool            startsolid;
  686. };
  687.  
  688. struct csurface_t
  689. {
  690.     const char*     name;
  691.     short           surfaceProps;
  692.     unsigned short  flags;
  693. };
  694.  
  695. class CGameTrace : public CBaseTrace
  696. {
  697. public:
  698.     float           fractionleftsolid;
  699.     csurface_t      surface;
  700.     int             hitgroup;
  701.     short           physicsbone;
  702.     C_BaseEntity*   m_pEnt;
  703.     int             hitbox;
  704. };
  705.  
  706. class ITraceFilter
  707. {
  708. public:
  709.     virtual bool        ShouldHitEntity(IHandleEntity* pEntity, int contentsMask) = 0;
  710.     virtual TraceType_t GetTraceType() const = 0;
  711. };
  712.  
  713. class CTraceFilter : public ITraceFilter
  714. {
  715. public:
  716.     virtual TraceType_t GetTraceType() const
  717.     {
  718.         return TRACE_EVERYTHING;
  719.     }
  720. };
  721.  
  722. class CTraceFilterSimple : public CTraceFilter
  723. {
  724. public:
  725.     CTraceFilterSimple(const IHandleEntity* passentity, int collisionGroup)
  726.     {
  727.         m_pPassEnt = passentity;
  728.     }
  729.  
  730.     virtual bool ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask)
  731.     {
  732.         return !(pHandleEntity == m_pPassEnt);
  733.     }
  734.  
  735. private:
  736.     const IHandleEntity* m_pPassEnt;
  737. };
  738.  
  739. class CTraceFilterSkipTwoEntities : public CTraceFilter
  740. {
  741. public:
  742.     CTraceFilterSkipTwoEntities(const IHandleEntity* passentity, const IHandleEntity* passentity2, int collisionGroup)
  743.     {
  744.         m_pPassEnt = passentity;
  745.         m_pPassEnt2 = passentity2;
  746.     }
  747.  
  748.     virtual bool ShouldHitEntity(IHandleEntity* pHandleEntity, int contentsMask)
  749.     {
  750.         return !(pHandleEntity == m_pPassEnt || pHandleEntity == m_pPassEnt2);
  751.     }
  752.  
  753. private:
  754.     const IHandleEntity* m_pPassEnt;
  755.     const IHandleEntity* m_pPassEnt2;
  756. };
  757.  
  758. class IEngineTrace
  759. {
  760. public:
  761.     int GetPointContents(const Vector3& vecAbsPosition, IHandleEntity** ppEntity = NULL)
  762.     {
  763.         typedef int(__thiscall* GetPointContentsFn)(void*, const Vector3&, IHandleEntity**);
  764.         return GetMethod<GetPointContentsFn>(this, 0)(this, vecAbsPosition, ppEntity);
  765.     }
  766.  
  767.     void TraceRay(const Ray_t& ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace)
  768.     {
  769.         typedef void(__thiscall* TraceRayFn)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*);
  770.         GetMethod<TraceRayFn>(this, 4)(this, ray, fMask, pTraceFilter, pTrace);
  771.     }
  772. };
  773.  
  774. struct mstudiobone_t
  775. {
  776.     int                 sznameindex;
  777.     inline char* const  pszName() const { return ((char*)this) + sznameindex; }
  778.     int                 parent;
  779.     int                 bonecontroller[6];
  780.  
  781.     Vector3             pos;
  782.     float               quat[4];
  783.     Vector3             rot;
  784.  
  785.     Vector3             posscale;
  786.     Vector3             rotscale;
  787.  
  788.     matrix3x4_t         poseToBone;
  789.     float               qAlignment[4];
  790.     int                 flags;
  791.     int                 proctype;
  792.     int                 procindex;
  793.     mutable int         physicsbone;
  794.     inline void*        pProcedure() const { if (procindex == 0) return NULL; else return (void*)(((byte*)this) + procindex); };
  795.     int                 surfacepropidx;
  796.     inline char* const  pszSurfaceProp() const { return ((char*)this) + surfacepropidx; }
  797.     int                 contents;
  798.  
  799.     int                 unused[8];
  800. };
  801.  
  802. struct mstudiobbox_t
  803. {
  804.     int                 bone;
  805.     int                 group;
  806.     Vector3             bbmin;
  807.     Vector3             bbmax;
  808.     int                 szhitboxnameindex;
  809.     int                 unused[8];
  810.  
  811.     char* pszHitboxName()
  812.     {
  813.         if (szhitboxnameindex == 0)
  814.             return "";
  815.  
  816.         return ((char*)this) + szhitboxnameindex;
  817.     }
  818. };
  819.  
  820. struct mstudiohitboxset_t
  821. {
  822.     int                     sznameindex;
  823.     inline char* const      pszName() const { return ((char*)this) + sznameindex; }
  824.     int                     numhitboxes;
  825.     int                     hitboxindex;
  826.     inline mstudiobbox_t*   pHitbox(int i) const { return (mstudiobbox_t*)(((byte*)this) + hitboxindex) + i; };
  827. };
  828.  
  829. struct studiohdr_t
  830. {
  831.     int                     id;
  832.     int                     version;
  833.  
  834.     long                    checksum;
  835.  
  836.     inline const char*      pszName() const { return name; }
  837.     char                    name[64];
  838.     int                     length;
  839.  
  840.     Vector3                 eyeposition;
  841.  
  842.     Vector3                 illumposition;
  843.  
  844.     Vector3                 hull_min;
  845.     Vector3                 hull_max;
  846.  
  847.     Vector3                 view_bbmin;
  848.     Vector3                 view_bbmax;
  849.  
  850.     int                     flags;
  851.  
  852.     int                     numbones;
  853.     int                     boneindex;
  854.     inline mstudiobone_t*   pBone(int i) const { return (mstudiobone_t*)(((byte*)this) + boneindex) + i; };
  855.  
  856.     int                     numbonecontrollers;
  857.     int                     bonecontrollerindex;
  858.  
  859.     int                     numhitboxsets;
  860.     int                     hitboxsetindex;
  861.  
  862.     mstudiohitboxset_t* pHitboxSet(int i) const
  863.     {
  864.         return (mstudiohitboxset_t*)(((byte*)this) + hitboxsetindex) + i;
  865.     };
  866.  
  867.     inline mstudiobbox_t* pHitbox(int i, int set) const
  868.     {
  869.         mstudiohitboxset_t const* s = pHitboxSet(set);
  870.  
  871.         if (!s)
  872.             return NULL;
  873.  
  874.         return s->pHitbox(i);
  875.     };
  876.  
  877.     inline int iHitboxCount(int set) const
  878.     {
  879.         mstudiohitboxset_t const* s = pHitboxSet(set);
  880.  
  881.         if (!s)
  882.             return 0;
  883.  
  884.         return s->numhitboxes;
  885.     };
  886.  
  887.     int                 numlocalanim;
  888.     int                 localanimindex;
  889.  
  890.     int                 numlocalseq;
  891.     int                 localseqindex;
  892.  
  893.     mutable int         activitylistversion;
  894.     mutable int         eventsindexed;
  895.  
  896.     int                 numtextures;
  897.     int                 textureindex;
  898. };
  899.  
  900. class IVModelInfoClient
  901. {
  902. public:
  903.     const char* GetModelName(const model_t* model)
  904.     {
  905.         typedef const char* (__thiscall* GetModelNameFn)(void*, const model_t*);
  906.         return GetMethod<GetModelNameFn>(this, 3)(this, model);
  907.     }
  908.  
  909.     void GetModelMaterials(const model_t* model, int count, IMaterial** ppMaterial)
  910.     {
  911.         typedef void(__thiscall* GetModelMaterialsFn)(void*, const model_t*, int, IMaterial**);
  912.         GetMethod<GetModelMaterialsFn>(this, 16)(this, model, count, ppMaterial);
  913.     }
  914.  
  915.     studiohdr_t* GetStudiomodel(const model_t* mod)
  916.     {
  917.         typedef studiohdr_t* (__thiscall* GetStudiomodelFn)(void*, const model_t*);
  918.         return GetMethod<GetStudiomodelFn>(this, 27)(this, mod);
  919.     }
  920. };
  921.  
  922. struct surfacephysicsparams_t
  923. {
  924.     float   friction;
  925.     float   elasticity;
  926.     float   density;
  927.     float   thickness;
  928.     float   dampening;
  929. };
  930.  
  931. struct surfaceaudioparams_t
  932. {
  933.     float   reflectivity;
  934.     float   hardnessFactor;
  935.     float   roughnessFactor;
  936.  
  937.     float   roughThreshold;
  938.     float   hardThreshold;
  939.     float   hardVelocityThreshold;
  940. };
  941.  
  942. struct surfacesoundnames_t
  943. {
  944.     unsigned short  stepleft;
  945.     unsigned short  stepright;
  946.  
  947.     unsigned short  impactSoft;
  948.     unsigned short  impactHard;
  949.  
  950.     unsigned short  scrapeSmooth;
  951.     unsigned short  scrapeRough;
  952.  
  953.     unsigned short  bulletImpact;
  954.     unsigned short  rolling;
  955.  
  956.     unsigned short  breakSound;
  957.     unsigned short  strainSound;
  958. };
  959.  
  960. struct surfacesoundhandles_t
  961. {
  962.     short   stepleft;
  963.     short   stepright;
  964.  
  965.     short   impactSoft;
  966.     short   impactHard;
  967.  
  968.     short   scrapeSmooth;
  969.     short   scrapeRough;
  970.  
  971.     short   bulletImpact;
  972.     short   rolling;
  973.  
  974.     short   breakSound;
  975.     short   strainSound;
  976. };
  977.  
  978. struct surfacegameprops_t
  979. {
  980.     float           maxSpeedFactor;
  981.     float           jumpFactor;
  982.  
  983.     unsigned short  material;
  984.  
  985.     unsigned char   climbable;
  986.     unsigned char   pad;
  987. };
  988.  
  989. struct surfacedata_t
  990. {
  991.     surfacephysicsparams_t      physics;
  992.     surfaceaudioparams_t        audio;
  993.     surfacesoundnames_t         sounds;
  994.     surfacegameprops_t          game;
  995.  
  996.     surfacesoundhandles_t       soundhandles;
  997. };
  998.  
  999. class IPhysicsSurfaceProps
  1000. {
  1001. public:
  1002.     surfacedata_t* GetSurfaceData(int surfaceDataIndex)
  1003.     {
  1004.         typedef surfacedata_t* (__thiscall* GetSurfaceDataFn)(void*, int);
  1005.         return GetMethod<GetSurfaceDataFn>(this, 5)(this, surfaceDataIndex);
  1006.     }
  1007. };
  1008.  
  1009. class IVRenderView
  1010. {
  1011. public:
  1012.     void SetBlend(float blend)
  1013.     {
  1014.         typedef void(__thiscall* SetBlendFn)(void*, float);
  1015.         GetMethod< SetBlendFn >(this, 4)(this, blend);
  1016.     }
  1017.  
  1018.     void SetColorModulation(float const* blend)
  1019.     {
  1020.         typedef void(__thiscall* SetColorModulationFn)(void*, float const*);
  1021.         GetMethod< SetColorModulationFn >(this, 6)(this, blend);
  1022.     }
  1023. };
  1024.  
  1025. class IMaterial
  1026. {
  1027. public:
  1028.     const char* GetName()
  1029.     {
  1030.         typedef const char* (__thiscall* GetNameFn)(void*);
  1031.         return GetMethod< GetNameFn >(this, 0)(this);
  1032.     }
  1033.  
  1034.     const char* GetTextureGroupName()
  1035.     {
  1036.         typedef const char* (__thiscall* GetTextureGroupNameFn)(void*);
  1037.         return GetMethod< GetTextureGroupNameFn >(this, 1)(this);
  1038.     }
  1039.  
  1040.     void IncrementReferenceCount()
  1041.     {
  1042.         typedef void(__thiscall* IncrementReferenceCountFn)(void*);
  1043.         GetMethod< IncrementReferenceCountFn >(this, 12)(this);
  1044.     }
  1045.  
  1046.     void AlphaModulate(float alpha)
  1047.     {
  1048.         typedef void(__thiscall* AlphaModulateFn)(void*, float);
  1049.         GetMethod< AlphaModulateFn >(this, 29)(this, alpha);
  1050.     }
  1051.  
  1052.     void ColorModulate(float r, float g, float b)
  1053.     {
  1054.         typedef void(__thiscall* ColorModulateFn)(void*, float, float, float);
  1055.         GetMethod< ColorModulateFn >(this, 30)(this, r, g, b);
  1056.     }
  1057.  
  1058.     void SetMaterialVarFlag(MaterialVarFlags_t flag, bool on)
  1059.     {
  1060.         typedef void(__thiscall* SetMaterialVarFlagFn)(void*, MaterialVarFlags_t, bool);
  1061.         GetMethod< SetMaterialVarFlagFn >(this, 31)(this, flag, on);
  1062.     }
  1063. };
  1064.  
  1065. class IMaterialSystem
  1066. {
  1067. public:
  1068.     MaterialHandle_t FirstMaterial()
  1069.     {
  1070.         typedef MaterialHandle_t(__thiscall* FirstMaterialFn)(void*);
  1071.         return GetMethod< FirstMaterialFn >(this, 23)(this);
  1072.     }
  1073.  
  1074.     MaterialHandle_t NextMaterial(MaterialHandle_t h)
  1075.     {
  1076.         typedef MaterialHandle_t(__thiscall* NextMaterialFn)(void*, MaterialHandle_t);
  1077.         return GetMethod< NextMaterialFn >(this, 24)(this, h);
  1078.     }
  1079.  
  1080.     MaterialHandle_t InvalidMaterial()
  1081.     {
  1082.         typedef MaterialHandle_t(__thiscall* InvalidMaterialFn)(void*);
  1083.         return GetMethod< InvalidMaterialFn >(this, 25)(this);
  1084.     }
  1085.  
  1086.     IMaterial* GetMaterial(MaterialHandle_t h)
  1087.     {
  1088.         typedef IMaterial* (__thiscall* GetMaterialFn)(void*, MaterialHandle_t);
  1089.         return GetMethod< GetMaterialFn >(this, 26)(this, h);
  1090.     }
  1091.  
  1092.     IMaterial* FindMaterial(const char* pMaterialName, const char* pTextureGroupName, bool complain = true, const char* pComplainPrefix = NULL)
  1093.     {
  1094.         typedef IMaterial* (__thiscall* FindMaterialFn)(void*, const char*, const char*, bool, const char*);
  1095.         return GetMethod< FindMaterialFn >(this, 27)(this, pMaterialName, pTextureGroupName, complain, pComplainPrefix);
  1096.     }
  1097. };
  1098.  
  1099. struct ModelRenderInfo_t
  1100. {
  1101.     int                     flags;
  1102.     IClientRenderable*      pRenderable;
  1103.     ModelInstanceHandle_t   instance;
  1104.     int                     entity_index;
  1105.     const model_t*          pModel;
  1106.     Vector3                 origin;
  1107.     Vector3                 angles;
  1108.     int                     skin;
  1109.     int                     body;
  1110.     int                     hitboxset;
  1111.     const matrix3x4_t*      pModelToWorld;
  1112.     const matrix3x4_t*      pLightingOffset;
  1113.     const Vector3*          pLightingOrigin;
  1114.  
  1115.     ModelRenderInfo_t()
  1116.     {
  1117.         pModelToWorld = NULL;
  1118.         pLightingOffset = NULL;
  1119.         pLightingOrigin = NULL;
  1120.     }
  1121. };
  1122.  
  1123. class IVModelRender
  1124. {
  1125. public:
  1126.     void ForcedMaterialOverride(IMaterial* newMaterial)
  1127.     {
  1128.         typedef void(__thiscall* ForcedMaterialOverrideFn)(void*, IMaterial*);
  1129.         GetMethod< ForcedMaterialOverrideFn >(this, 1)(this, newMaterial);
  1130.     }
  1131. };
  1132.  
  1133. class IPanel
  1134. {
  1135. public:
  1136.     const char* GetName(VPANEL vguiPanel)
  1137.     {
  1138.         typedef const char* (__thiscall* GetNameFn)(void*, VPANEL);
  1139.         return GetMethod<GetNameFn>(this, 35)(this, vguiPanel);
  1140.     }
  1141. };
  1142.  
  1143. class ISurface
  1144. {
  1145. public:
  1146.     void DrawSetColor(int r, int g, int b, int a)
  1147.     {
  1148.         typedef void (__thiscall* DrawSetColorFn)(void*, int, int, int, int);
  1149.         GetMethod<DrawSetColorFn>(this, 11)(this, r, g, b, a);
  1150.     }
  1151.  
  1152.     void DrawFilledRect(int x0, int y0, int x1, int y1)
  1153.     {
  1154.         typedef void (__thiscall* DrawFilledRectFn)(void*, int, int, int, int);
  1155.         GetMethod<DrawFilledRectFn>(this, 12)(this, x0, y0, x1, y1);
  1156.     }
  1157.  
  1158.     void DrawLine(int x0, int y0, int x1, int y1)
  1159.     {
  1160.         typedef void (__thiscall* DrawLineFn)(void*, int, int, int, int);
  1161.         GetMethod<DrawLineFn>(this, 15)(this, x0, y0, x1, y1);
  1162.     }
  1163.  
  1164.     void DrawSetTextFont(HFont font)
  1165.     {
  1166.         typedef void (__thiscall* DrawSetTextFontFn)(void*, HFont);
  1167.         GetMethod<DrawSetTextFontFn>(this, 17)(this, font);
  1168.     }
  1169.  
  1170.     void DrawSetTextColor(int r, int g, int b, int a)
  1171.     {
  1172.         typedef void (__thiscall* DrawSetTextColorFn)(void*, int, int, int, int);
  1173.         GetMethod<DrawSetTextColorFn>(this, 19)(this, r, g, b, a);
  1174.     }
  1175.  
  1176.     void DrawSetTextPos(int x, int y)
  1177.     {
  1178.         typedef void (__thiscall* DrawSetTextPosFn)(void*, int, int);
  1179.         GetMethod<DrawSetTextPosFn>(this, 20)(this, x, y);
  1180.     }
  1181.  
  1182.     void DrawPrintText(const wchar_t* text, int textLen)
  1183.     {
  1184.         typedef void (__thiscall* DrawPrintTextFn)(void*, const wchar_t*, int, int);
  1185.         GetMethod<DrawPrintTextFn>(this, 22)(this, text, textLen, 0);
  1186.     }
  1187.  
  1188.     HFont CreateFont()
  1189.     {
  1190.         typedef HFont (__thiscall* CreateFontFn)(void*);
  1191.         return GetMethod<CreateFontFn>(this, 64)(this);
  1192.     }
  1193.  
  1194.     void SetFontGlyphSet(HFont font, const char* windowsFontName, int tall, int weight, int blur, int scanlines, int flags)
  1195.     {
  1196.         typedef void (__thiscall* SetFontGlyphSetFn)(void*, HFont, const char*, int, int, int, int, int);
  1197.         GetMethod<SetFontGlyphSetFn>(this, 65)(this, font, windowsFontName, tall, weight, blur, scanlines, flags);
  1198.     }
  1199.  
  1200.     void GetTextSize(HFont font, const wchar_t* text, int& wide, int& tall)
  1201.     {
  1202.         typedef void (__thiscall* GetTextSizeFn)(void*, HFont, const wchar_t*, int&, int&);
  1203.         GetMethod<GetTextSizeFn>(this, 72)(this, font, text, wide, tall);
  1204.     }
  1205. };
  1206.  
  1207. class IGameEvent
  1208. {
  1209. public:
  1210.     const char* GetName()
  1211.     {
  1212.         typedef const char* (__thiscall* GetNameFn)(void*);
  1213.         return GetMethod<GetNameFn>(this, 1)(this);
  1214.     }
  1215.  
  1216.     bool GetBool(const char* keyName = NULL, bool defaultValue = false)
  1217.     {
  1218.         typedef bool(__thiscall* GetBoolFn)(void*, const char*, bool);
  1219.         return GetMethod<GetBoolFn>(this, 5)(this, keyName, defaultValue);
  1220.     }
  1221.  
  1222.     int GetInt(const char* keyName = NULL, int defaultValue = 0)
  1223.     {
  1224.         typedef int(__thiscall* GetIntFn)(void*, const char*, int);
  1225.         return GetMethod<GetIntFn>(this, 6)(this, keyName, defaultValue);
  1226.     }
  1227.  
  1228.     float GetFloat(const char* keyName = NULL, float defaultValue = 0.0f)
  1229.     {
  1230.         typedef float(__thiscall* GetFloatFn)(void*, const char*, float);
  1231.         return GetMethod<GetFloatFn>(this, 7)(this, keyName, defaultValue);
  1232.     }
  1233.  
  1234.     const char* GetString(const char* keyName = NULL, const char* defaultValue = "")
  1235.     {
  1236.         typedef const char* (__thiscall* GetStringFn)(void*, const char*, const char*);
  1237.         return GetMethod<GetStringFn>(this, 8)(this, keyName, defaultValue);
  1238.     }
  1239. };
  1240.  
  1241. class IGameEventListener2
  1242. {
  1243. public:
  1244.     virtual ~IGameEventListener2() {};
  1245.     virtual void FireGameEvent(IGameEvent* event) = 0;
  1246. };
  1247.  
  1248. class IGameEventManager2
  1249. {
  1250. public:
  1251.     bool AddListener(IGameEventListener2* listener, const char* name, bool bServerSide)
  1252.     {
  1253.         typedef bool(__thiscall* AddListenerFn)(void*, IGameEventListener2*, const char*, bool);
  1254.         return GetMethod<AddListenerFn>(this, 3)(this, listener, name, bServerSide);
  1255.     }
  1256. };
  1257.  
  1258. #endif // SDK_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement