Guest User

CEntity

a guest
May 1st, 2019
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.65 KB | None | 0 0
  1. #pragma once
  2. #include "Definitions.h"
  3. #include "IClientUnknown.h"
  4. #include "IClientEntityList.h"
  5. #include "CInput.h"
  6. #include "..\Utils\Utils.h"
  7. #include "..\Utils\NetvarManager.h"
  8.  
  9.  
  10.  
  11.  
  12. #define NETVAR(type, name, table, netvar) \
  13. type& name##() const { \
  14. static int _##name = g_pNetvars->GetOffset(table, netvar); \
  15. return *(type*)((uintptr_t)this + _##name); \
  16. }
  17.  
  18. #define PNETVAR(type, name, table, netvar) \
  19. type* name##() const { \
  20. static int _##name = g_pNetvars->GetOffset(table, netvar); \
  21. return (type*)((uintptr_t)this + _##name); \
  22. }
  23.  
  24. #define ANETVAR(type, funcname, num, table, netvar) std::array<type, num>& funcname() \
  25. { \
  26. static int _##name = g_pNetvars->GetOffset(table, netvar); \
  27. return *reinterpret_cast<std::array<type, num>*>( uintptr_t( this ) + _##name ); \
  28. }
  29.  
  30.  
  31.  
  32.  
  33. // class predefinition
  34. class C_BaseCombatWeapon;
  35.  
  36. class C_AnimState
  37. {
  38. public:
  39. char pad[3];
  40. char bUnknown; //0x4
  41. char pad2[91];
  42. void* pBaseEntity; //0x60
  43. void* pActiveWeapon; //0x64
  44. void* pLastActiveWeapon; //0x68
  45. float m_flLastClientSideAnimationUpdateTime; //0x6C
  46. int m_iLastClientSideAnimationUpdateFramecount; //0x70
  47. float m_flEyePitch; //0x74
  48. float m_flEyeYaw; //0x78
  49. float m_flPitch; //0x7C
  50. float m_flGoalFeetYaw; //0x80
  51. float m_flCurrentFeetYaw; //0x84
  52. float m_flCurrentTorsoYaw; //0x88
  53. float m_flUnknownVelocityLean; //0x8C //changes when moving/jumping/hitting ground
  54. float m_flLeanAmount; //0x90
  55. char pad4[4]; //NaN
  56. float m_flFeetCycle; //0x98 0 to 1
  57. float m_flFeetYawRate; //0x9C 0 to 1
  58. float m_fUnknown2;
  59. float m_fDuckAmount; //0xA4
  60. float m_fLandingDuckAdditiveSomething; //0xA8
  61. float m_fUnknown3; //0xAC
  62. Vector m_vOrigin; //0xB0, 0xB4, 0xB8
  63. Vector m_vLastOrigin; //0xBC, 0xC0, 0xC4
  64. float m_vVelocityX; //0xC8
  65. float m_vVelocityY; //0xCC
  66. char pad5[4];
  67. float m_flUnknownFloat1; //0xD4 Affected by movement and direction
  68. char pad6[8];
  69. float m_flUnknownFloat2; //0xE0 //from -1 to 1 when moving and affected by direction
  70. float m_flUnknownFloat3; //0xE4 //from -1 to 1 when moving and affected by direction
  71. float m_unknown; //0xE8
  72. float speed_2d; //0xEC
  73. float flUpVelocity; //0xF0
  74. float m_flSpeedNormalized; //0xF4 //from 0 to 1
  75. float m_flFeetSpeedForwardsOrSideWays; //0xF8 //from 0 to 2. something is 1 when walking, 2.something when running, 0.653 when crouch walking
  76. float m_flFeetSpeedUnknownForwardOrSideways; //0xFC //from 0 to 3. something
  77. float m_flTimeSinceStartedMoving; //0x100
  78. float m_flTimeSinceStoppedMoving; //0x104
  79. unsigned char m_bOnGround; //0x108
  80. unsigned char m_bInHitGroundAnimation; //0x109
  81. char pad7[10];
  82. float m_flLastOriginZ; //0x114
  83. float m_flHeadHeightOrOffsetFromHittingGroundAnimation; //0x118 from 0 to 1, is 1 when standing
  84. float m_flStopToFullRunningFraction; //0x11C from 0 to 1, doesnt change when walking or crouching, only running
  85. char pad8[4]; //NaN
  86. float m_flUnknownFraction; //0x124 affected while jumping and running, or when just jumping, 0 to 1
  87. char pad9[4]; //NaN
  88. float m_flUnknown3;
  89. char pad10[528];
  90. };
  91.  
  92. class AnimationLayer {
  93. public:
  94. char pad_0000[20];
  95. // These should also be present in the padding, don't see the use for it though
  96. //float m_flLayerAnimtime;
  97. //float m_flLayerFadeOuttime;
  98. unsigned int m_nOrder; //0x0014
  99. unsigned int m_nSequence; //0x0018
  100. float m_flPrevCycle; //0x001C
  101. float m_flWeight; //0x0020
  102. float m_flWeightDeltaRate; //0x0024
  103. float m_flPlaybackRate; //0x0028
  104. float m_flCycle; //0x002C
  105. void *m_pOwner; //0x0030 // player's thisptr
  106. char pad_0038[4]; //0x0034
  107. }; //Size: 0x0038
  108.  
  109. class CollisionProperty
  110. {
  111. public:
  112.  
  113. NETVAR(Vector, GetMin, "DT_BaseEntity", "m_vecMins"); // m_vecMins : 0x29BC
  114. NETVAR(Vector, GetMax, "DT_BaseEntity", "m_vecMaxs"); // m_vecMaxs : 0x29C8
  115.  
  116.  
  117.  
  118. };
  119. class viewmodel_t;
  120.  
  121. class C_BaseEntity : public IClientUnknown, public IClientRenderable, public IClientNetworkable
  122. {
  123. private:
  124. template<class T>
  125. T GetPointer(const int offset)
  126. {
  127. return reinterpret_cast<T*>(reinterpret_cast<std::uintptr_t>(this) + offset);
  128. }
  129. // To get value from the pointer itself
  130. template<class T>
  131. T GetValue(const int offset)
  132. {
  133. return *reinterpret_cast<T*>(reinterpret_cast<std::uintptr_t>(this) + offset);
  134. }
  135.  
  136. template <typename T>
  137. T& SetValue(uintptr_t offset)
  138. {
  139. return *reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(this) + offset);
  140. }
  141.  
  142. public:
  143. NETVAR(int, m_iObserverMode, "DT_BasePlayer", "m_iObserverMode");
  144. NETVAR(CHandle<C_BaseEntity>, m_hObserverTarget, "DT_BasePlayer", "m_hObserverTarget");
  145. NETVAR(int, GetGrenadeSmokeTickBegin, "DT_SmokeGrenadeProjectile", "m_nSmokeEffectTickBegin");
  146.  
  147. NETVAR(Vector, GetOBBMins, "DT_BaseEntity", "m_vecMins");
  148. NETVAR(Vector, GetOBBMaxs,"DT_BaseEntity", "m_vecMaxs");
  149. Vector GetBonePosition(int iBone);
  150. Vector GetHitboxPositionxd(int Hitbox);
  151. VMatrix & GetCollisionBoundTrans()
  152. {
  153. return *reinterpret_cast<VMatrix*>((DWORD)this + 0x0440);
  154. }
  155. matrix3x4_t& get_rgflcoordinateframe()
  156. {
  157. static auto _m_rgflCoordinateFrame = g_pNetvars->GetOffset("DT_CSPlayer", "m_CollisionGroup") - 0x30;
  158. return *reinterpret_cast<matrix3x4_t*>(reinterpret_cast<uintptr_t>(this) + _m_rgflCoordinateFrame);
  159. }
  160. CollisionProperty* GetCollision()
  161. {
  162. return reinterpret_cast<CollisionProperty*>((DWORD)this + 0x31C);
  163. }
  164.  
  165. int GetHitboxSet();
  166.  
  167.  
  168. NETVAR(CHandle<viewmodel_t>, m_hViewModel, "DT_BasePlayer", "m_hViewModel[0]");
  169.  
  170. NETVAR(float, m_flFlashDuration, "DT_CSPlayer", "m_flFlashDuration");
  171. C_AnimState *AnimState()
  172. {
  173. return *reinterpret_cast<C_AnimState**>(uintptr_t(this) + 0x3900);
  174. }
  175.  
  176. AnimationLayer *AnimOverlays()
  177. {
  178. return *reinterpret_cast<AnimationLayer**>(uintptr_t(this) + 0x2980);
  179. }
  180. CBaseHandle* m_hMyWeapons()
  181. {
  182. return (CBaseHandle*)((uintptr_t)this + 0x2DF8);
  183. }
  184. int NumOverlays()
  185. {
  186. return 15;
  187. }
  188.  
  189. void UpdateClientAnimation()
  190. {
  191. Utils::GetVFunc<void(__thiscall*)(void*)>(this, 221)(this);
  192. }
  193.  
  194. void ClientAnimations(bool value)
  195. {
  196. static int m_bClientSideAnimation = g_pNetvars->GetOffset("DT_BaseAnimating", "m_bClientSideAnimation");
  197. *reinterpret_cast<bool*>(uintptr_t(this) + m_bClientSideAnimation) = value;
  198. }
  199.  
  200. int GetSequence()
  201. {
  202. static int m_nSequence = g_pNetvars->GetOffset("DT_BaseAnimating", "m_nSequence");
  203. return GetValue<int>(m_nSequence);
  204. }
  205.  
  206. void SetSequence(int Sequence)
  207. {
  208. static int m_nSequence = g_pNetvars->GetOffset("DT_BaseAnimating", "m_nSequence");
  209. *reinterpret_cast<int*>(uintptr_t(this) + m_nSequence) = Sequence;
  210. }
  211.  
  212. void SimulatedEveryTick(bool value)
  213. {
  214. static int m_bSimulatedEveryTick = g_pNetvars->GetOffset("DT_BaseEntity", "m_bSimulatedEveryTick");
  215. *reinterpret_cast<bool*>(uintptr_t(this) + m_bSimulatedEveryTick) = value;
  216. }
  217.  
  218. void SetAbsAngles(Vector angles);
  219. void SetAbsOrigin(Vector origin);
  220. NETVAR(CHandle<C_BaseCombatWeapon>, m_hActiveWeapon, "DT_BaseCombatCharacter", "m_hActiveWeapon");
  221. NETVAR(int32_t, m_iShotsFired, "DT_CSPlayer", "m_iShotsFired");
  222. NETVAR(int, m_nModelIndex, "DT_BaseEntity", "m_nModelIndex");
  223. Vector GetAbsOrigin()
  224. {
  225. return Utils::GetVFunc<Vector&(__thiscall*)(void*)>(this, 10)(this);
  226. }
  227.  
  228.  
  229. void SetAbsVelocity(Vector velocity);
  230.  
  231. C_BaseCombatWeapon* GetActiveWeapon()
  232. {
  233. static int m_hActiveWeapon = g_pNetvars->GetOffset("DT_BaseCombatCharacter", "m_hActiveWeapon");
  234. const auto weaponData = GetValue<CBaseHandle>(m_hActiveWeapon);
  235. return reinterpret_cast<C_BaseCombatWeapon*>(g_pEntityList->GetClientEntityFromHandle(weaponData));
  236. }
  237.  
  238. int GetActiveWeaponIndex()
  239. {
  240. static int m_hActiveWeapon = g_pNetvars->GetOffset("DT_BaseCombatCharacter", "m_hActiveWeapon");
  241. return *reinterpret_cast<int*>(uintptr_t(this) + m_hActiveWeapon) & 0xFFF; //m_hActiveWeapon
  242. }
  243. int GetTeam()
  244. {
  245. static int m_iTeamNum = g_pNetvars->GetOffset("DT_BaseEntity", "m_iTeamNum");
  246. return GetValue<int>(m_iTeamNum);
  247. }
  248. void SetModelIndex(int index)
  249. {
  250. typedef void(__thiscall* OriginalFn)(PVOID, int);
  251. return Utils::GetVFunc<OriginalFn>(this, 75)(this, index);
  252. }
  253.  
  254. int WeaponID()
  255. {
  256. return GetItemDefinitionIndex();
  257. }
  258. short GetItemDefinitionIndex(void)
  259. {
  260. if (!this) return 0;
  261. return *(short*)((uintptr_t)this + 0x2FAA);
  262. }
  263. int Clip1()
  264. {
  265. return *reinterpret_cast<int*>((uintptr_t)this + 0x3244);
  266. }
  267. float GetPostponeFireReadyTime()
  268. {
  269. return *reinterpret_cast<float*>((uintptr_t)this + 0x331c);
  270. }
  271.  
  272.  
  273. EntityFlags GetFlags()
  274. {
  275. static int m_fFlags = g_pNetvars->GetOffset("DT_BasePlayer", "m_fFlags");
  276. return GetValue<EntityFlags>(m_fFlags);
  277. }
  278.  
  279. void SetFlags(int offset)
  280. {
  281. static int m_fFlags = g_pNetvars->GetOffset("DT_BasePlayer", "m_fFlags");
  282. *reinterpret_cast<int*>(uintptr_t(this) + m_fFlags) = offset;
  283. }
  284.  
  285. MoveType_t GetMoveType()
  286. {
  287. static int m_Movetype = g_pNetvars->GetOffset("DT_BaseEntity", "m_nRenderMode") + 1;
  288. return GetValue<MoveType_t>(m_Movetype);
  289. }
  290.  
  291. float GetSimulationTime()
  292. {
  293. static int m_flSimulationTime = g_pNetvars->GetOffset("DT_BaseEntity", "m_flSimulationTime");
  294. return GetValue<float>(m_flSimulationTime);
  295. }
  296.  
  297. float GetOldSimulationTime()
  298. {
  299. static int m_flOldSimulationTime = g_pNetvars->GetOffset("DT_BaseEntity", "m_flSimulationTime") + 4;
  300. return GetValue<float>(m_flOldSimulationTime);
  301. }
  302.  
  303. float GetLowerBodyYaw()
  304. {
  305. static int m_flLowerBodyYawTarget = g_pNetvars->GetOffset("DT_CSPlayer", "m_flLowerBodyYawTarget");
  306. return GetValue<float>(m_flLowerBodyYawTarget);
  307. }
  308.  
  309. void SetLowerBodyYaw(float value)
  310. {
  311. static int m_flLowerBodyYawTarget = g_pNetvars->GetOffset("DT_CSPlayer", "m_flLowerBodyYawTarget");
  312. *reinterpret_cast<float*>(uintptr_t(this) + m_flLowerBodyYawTarget) = value;
  313. }
  314.  
  315. bool GetHeavyArmor()
  316. {
  317. static int m_bHasHeavyArmor = g_pNetvars->GetOffset("DT_CSPlayer", "m_bHasHeavyArmor");
  318. return GetValue<bool>(m_bHasHeavyArmor);
  319. }
  320.  
  321. int ArmorValue()
  322. {
  323. static int m_ArmorValue = g_pNetvars->GetOffset("DT_CSPlayer", "m_ArmorValue");
  324. return GetValue<int>(m_ArmorValue);
  325. }
  326.  
  327. bool HasHelmet()
  328. {
  329. static int m_bHasHelmet = g_pNetvars->GetOffset("DT_CSPlayer", "m_bHasHelmet");
  330. return GetValue<bool>(m_bHasHelmet);
  331. }
  332.  
  333. bool GetLifeState()
  334. {
  335. static int m_lifeState = g_pNetvars->GetOffset("DT_BasePlayer", "m_lifeState");
  336. return GetValue<bool>(m_lifeState);
  337. }
  338. NETVAR(int, m_zoomLevel, "DT_WeaponCSBaseGun", "m_zoomLevel");
  339. bool IsScoped()
  340. {
  341. static int m_bIsScoped = g_pNetvars->GetOffset("DT_CSPlayer", "m_bIsScoped");
  342. return GetValue<bool>(m_bIsScoped);
  343. }
  344.  
  345. int GetHealth()
  346. {
  347. static int m_iHealth = g_pNetvars->GetOffset("DT_BasePlayer", "m_iHealth");
  348. return GetValue<int>(m_iHealth);
  349. }
  350.  
  351. bool IsKnifeorNade();
  352. bool IsKnife();
  353.  
  354. bool IsAlive() { return this->GetHealth() > 0 && this->GetLifeState() == 0; }
  355.  
  356. bool IsEnemy();
  357.  
  358. bool IsImmune()
  359. {
  360. static int m_bGunGameImmunity = g_pNetvars->GetOffset("DT_CSPlayer", "m_bGunGameImmunity");
  361. return GetValue<bool>(m_bGunGameImmunity);
  362. }
  363. DWORD deadflag()
  364. {
  365. return GetValue<DWORD>(g_pNetvars->GetOffset("DT_CSPlayer", "deadflag"));
  366. }
  367. int GetTickBase()
  368. {
  369. static int m_nTickBase = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_nTickBase");
  370. return GetValue<int>(m_nTickBase);
  371. }
  372.  
  373. int GetShotsFired()
  374. {
  375. static int m_iShotsFired = g_pNetvars->GetOffset("DT_CSPlayer", "cslocaldata", "m_iShotsFired");
  376. return GetValue<int>(m_iShotsFired);
  377. }
  378.  
  379. void SetTickBase(int TickBase)
  380. {
  381. static int m_nTickBase = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_nTickBase");
  382. *reinterpret_cast<int*>(uintptr_t(this) + m_nTickBase) = TickBase;
  383. }
  384.  
  385. Vector GetEyeAngles()
  386. {
  387. static int m_angEyeAngles = g_pNetvars->GetOffset("DT_CSPlayer", "m_angEyeAngles");
  388. return GetValue<Vector>(m_angEyeAngles);
  389. }
  390.  
  391. void SetEyeAngles(Vector Angle)
  392. {
  393. static int m_angEyeAngles = g_pNetvars->GetOffset("DT_CSPlayer", "m_angEyeAngles");
  394. *reinterpret_cast<Vector*>(uintptr_t(this) + m_angEyeAngles) = Angle;
  395. }
  396.  
  397. Vector GetOrigin()
  398. {
  399. static int m_vecOrigin = g_pNetvars->GetOffset("DT_BaseEntity", "m_vecOrigin");
  400. return GetValue<Vector>(m_vecOrigin);
  401. }
  402. Vector GetViewOffset()
  403. {
  404. return *reinterpret_cast<Vector*>(uintptr_t(this) + 0x108);
  405.  
  406. }
  407. int SetObserverMode(int mode)
  408. {
  409. return *reinterpret_cast<int*>(uintptr_t(this) + 0x3374) = mode;
  410. }
  411. NETVAR(int, SetObserverModexd, "DT_CSPlayer", "m_iObserverMode");
  412. Vector GetOldOrigin()
  413. {
  414. static int m_vecOldOrigin = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_flFriction") + 12;
  415. return GetValue<Vector>(m_vecOldOrigin);
  416. }
  417.  
  418. Vector GetNetworkOrigin()
  419. {
  420. static int m_vecNetworkOrigin = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_flFriction") + 40;
  421. return GetValue<Vector>(m_vecNetworkOrigin);
  422. }
  423.  
  424. void SetOrigin(Vector Origin)
  425. {
  426. static int m_vecOrigin = g_pNetvars->GetOffset("DT_BaseEntity", "m_vecOrigin");
  427. *reinterpret_cast<Vector*>(uintptr_t(this) + m_vecOrigin) = Origin;
  428. }
  429.  
  430. Vector GetVelocity()
  431. {
  432. static int m_vecVelocity = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_vecVelocity[0]");
  433. return GetValue<Vector>(m_vecVelocity);
  434. }
  435.  
  436. void SetVelocity(Vector velocity)
  437. {
  438. static int m_vecVelocity = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_vecVelocity[0]");
  439. *reinterpret_cast<Vector*>(uintptr_t(this) + m_vecVelocity) = velocity;
  440. }
  441.  
  442. Vector GetAimPunchAngle()
  443. {
  444. return *reinterpret_cast<Vector*>(uintptr_t(this) + uintptr_t(0x302C));
  445. }
  446.  
  447. Vector GetViewPunchAngle()
  448. {
  449. return *reinterpret_cast<Vector*>(uintptr_t(this) + uintptr_t(0x3020));
  450. }
  451.  
  452. Vector GetEyePosition()
  453. {
  454. Vector ret;
  455. typedef void(__thiscall *OrigFn)(void *, Vector&);
  456. Utils::GetVFunc<OrigFn>(this, 279)(this, ret);
  457. return ret;
  458. }
  459.  
  460. ICollideable* GetCollideable()
  461. {
  462. return (ICollideable*)((DWORD)this + 0x31C);
  463. }
  464.  
  465. void SetCurrentCommand(CUserCmd *cmd)
  466. {
  467. static int m_hConstraintEntity = g_pNetvars->GetOffset("DT_BasePlayer", "localdata", "m_hConstraintEntity");
  468. *reinterpret_cast<CUserCmd**>(uintptr_t(this) + m_hConstraintEntity - 0xC) = cmd;
  469. }
  470.  
  471. float FireRate();
  472.  
  473. void FixSetupBones(matrix3x4_t *Matrix);
  474. bool IsVisible(int bone);
  475. bool IsPlayer();
  476. Vector GetHitboxPosition(int Hitbox, matrix3x4_t *Matrix, float *Radius);
  477. Vector GetHitboxPosition(int Hitbox, matrix3x4_t *Matrix);
  478. std::vector<C_BaseCombatWeapon*> GetWeapons();
  479. };
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486. class ragdoll_t : public C_BaseEntity {
  487. public:
  488. NETVAR(Vector, m_vecForce, "DT_CSRagdoll", "m_vecForce");
  489. NETVAR(Vector, m_vecRagdollVelocity, "DT_CSRagdoll", "m_vecRagdollVelocity");
  490. };
  491.  
  492. class C_BaseCombatWeapon : public C_BaseEntity
  493. {
  494. private:
  495. template<class T>
  496. T GetPointer(const int offset)
  497. {
  498. return reinterpret_cast<T*>(reinterpret_cast<std::uintptr_t>(this) + offset);
  499. }
  500. // To get value from the pointer itself
  501. template<class T>
  502. T GetValue(const int offset)
  503. {
  504. return *reinterpret_cast<T*>(reinterpret_cast<std::uintptr_t>(this) + offset);
  505. }
  506.  
  507. public:
  508. HANDLE m_hWeaponWorldModel_h()
  509. {
  510. return *(HANDLE*)((uintptr_t)this + 0x3234); //m_hWeaponWorldModel
  511. }
  512. CBaseHandle m_hWeaponWorldModel_c()
  513. {
  514. return *(CBaseHandle*)((uintptr_t)this + 0x3234); //m_hWeaponWorldModel
  515. }
  516. bool is_grenade() {
  517.  
  518. int WeaponIDz = *fixskins();
  519. if (WeaponIDz == 44 || WeaponIDz == 48 ||
  520. WeaponIDz == 46 || WeaponIDz == 43 ||
  521. WeaponIDz == 47 || WeaponIDz == 45)
  522. return true;
  523. else
  524. false;
  525.  
  526.  
  527. }
  528. bool IsKnife()
  529. {
  530. int iWeaponID = (int)this->GetItemDefinitionIndex();
  531. return (iWeaponID == (int)ItemDefinitionIndex::WEAPON_KNIFE || iWeaponID == (int)ItemDefinitionIndex::WEAPON_KNIFE_T
  532. || iWeaponID == 59 || iWeaponID == 41
  533. || iWeaponID == 500 || iWeaponID == 505 || iWeaponID == 506
  534. || iWeaponID == 507 || iWeaponID == 508 || iWeaponID == 509
  535. || iWeaponID == 515);
  536. }
  537. NETVAR(float, m_fThrowTime, "DT_BaseCSGrenade", "m_fThrowTime");
  538.  
  539. int* OwnerXuidHigh()
  540. {
  541. return (int*)((uintptr_t)this + 0x31B4);
  542. }
  543. int* ModelIndex()
  544. {
  545. return (int*)((uintptr_t)this + 0x258);
  546. }
  547. int* ViewModelIndex()
  548. {
  549. return (int*)((uintptr_t)this + 0x3220);
  550. }
  551. short* fixskins()
  552. {
  553. return (short*)((uintptr_t)this + 0x2FAA);
  554. }
  555. inline int* FallbackPaintKit() {
  556. return (int*)((DWORD)this + 0x31B8);
  557. }
  558. int* GetEntityQuality()
  559. {
  560. return (int*)((uintptr_t)this + 0x2FAC);
  561. }
  562. int* OwnerXuidLow()
  563. {
  564. return (int*)((uintptr_t)this + 0x31B0);
  565. }
  566.  
  567. float* FallbackWear()
  568. {
  569. return (float*)((uintptr_t)this + 0x31C0);
  570. }
  571. int* ItemIDHigh()
  572. {
  573. return (int*)((uintptr_t)this + 0x2FC0);
  574. }
  575.  
  576.  
  577. ItemDefinitionIndex GetItemDefinitionIndex()
  578. {
  579. static int m_iItemDefinitionIndex = g_pNetvars->GetOffset("DT_BaseAttributableItem", "m_AttributeManager", "m_Item", "m_iItemDefinitionIndex");
  580. return GetValue<ItemDefinitionIndex>(m_iItemDefinitionIndex);
  581. }
  582.  
  583. float GetInaccuracy()
  584. {
  585. typedef float(__thiscall* oInaccuracy)(PVOID);
  586. return Utils::GetVFunc< oInaccuracy >(this, 476)(this);
  587. }
  588. CBaseHandle m_hWeaponWorldModel()
  589. {
  590. return *(CBaseHandle*)((uintptr_t)this + g_pNetvars->GetOffset("DT_BaseCombatWeapon", "m_hWeaponWorldModel")); //m_hWeaponWorldModel
  591. }
  592. HANDLE m_hWeaponWorldModel1()
  593. {
  594. return *(HANDLE*)((uintptr_t)this + g_pNetvars->GetOffset("DT_BaseCombatWeapon", "m_hWeaponWorldModel")); //m_hWeaponWorldModel
  595. }
  596. float GetSpread()
  597. {
  598. typedef float(__thiscall* oWeaponSpread)(PVOID);
  599. return Utils::GetVFunc< oWeaponSpread >(this, 446)(this);
  600. }
  601.  
  602. float GetAccuracyPenalty()
  603. {
  604. static int m_fAccuracyPenalty = g_pNetvars->GetOffset("DT_WeaponCSBase", "m_fAccuracyPenalty");
  605. return GetValue<float>(m_fAccuracyPenalty);
  606. }
  607.  
  608. float GetLastShotTime()
  609. {
  610. static int m_fLastShotTime = g_pNetvars->GetOffset("DT_WeaponCSBase", "m_fLastShotTime");
  611. return GetValue<float>(m_fLastShotTime);
  612. }
  613.  
  614. void AccuracyPenalty()
  615. {
  616. typedef void(__thiscall *OrigFn)(void *);
  617. return Utils::GetVFunc<OrigFn>(this, 477)(this);
  618. }
  619.  
  620. float GetNextPrimaryAttack()
  621. {
  622. static int m_flNextPrimaryAttack = g_pNetvars->GetOffset("DT_BaseCombatWeapon", "LocalActiveWeaponData", "m_flNextPrimaryAttack");
  623. return GetValue<float>(m_flNextPrimaryAttack);
  624. }
  625.  
  626.  
  627. bool realWeapon()
  628. {
  629. short idx = (short)GetItemDefinitionIndex();
  630.  
  631. return (idx == (short)ItemDefinitionIndex::WEAPON_C4 || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_BAYONET || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_BUTTERFLY || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_FALCHION
  632. || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_FLIP || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_GUT || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_KARAMBIT || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_M9_BAYONET || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_PUSH
  633. || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_SURVIVAL_BOWIE || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_T || idx == (short)ItemDefinitionIndex::WEAPON_KNIFE_TACTICAL || idx == (short)ItemDefinitionIndex::WEAPON_FLASHBANG || idx == (short)ItemDefinitionIndex::WEAPON_HEGRENADE
  634. || idx == (short)ItemDefinitionIndex::WEAPON_SMOKEGRENADE || idx == (short)ItemDefinitionIndex::WEAPON_MOLOTOV || idx == (short)ItemDefinitionIndex::WEAPON_DECOY || idx == (short)ItemDefinitionIndex::WEAPON_INCGRENADE);
  635. }
  636.  
  637.  
  638. int GetAmmo()
  639. {
  640. static int m_iClip1 = g_pNetvars->GetOffset("DT_BaseCombatWeapon", "m_iClip1");
  641. return GetValue<int>(m_iClip1);
  642. }
  643.  
  644. WeaponInfo_t* GetCSWpnData()
  645. {
  646. return Utils::CallVFunc<454, WeaponInfo_t*>(this);
  647. }
  648.  
  649. std::string GetName()
  650. {
  651. ///TODO: Test if szWeaponName returns proper value for m4a4 / m4a1-s or it doesnt recognize them.
  652. return std::string(this->GetCSWpnData()->weapon_name);
  653. }
  654.  
  655. char * getNameLowerCase()
  656. {
  657. switch (GetItemDefinitionIndex())
  658. {
  659. case ItemDefinitionIndex::WEAPON_KNIFE_BAYONET:
  660. return "bayonet";
  661. case ItemDefinitionIndex::WEAPON_KNIFE_SURVIVAL_BOWIE:
  662. return "bowie";
  663. case ItemDefinitionIndex::WEAPON_KNIFE_BUTTERFLY:
  664. return "butterfly";
  665. case ItemDefinitionIndex::WEAPON_KNIFE:
  666. return "knife";
  667. case ItemDefinitionIndex::WEAPON_KNIFE_FALCHION:
  668. return "falchion";
  669. case ItemDefinitionIndex::WEAPON_KNIFE_FLIP:
  670. return "flip";
  671. case ItemDefinitionIndex::WEAPON_KNIFE_GUT:
  672. return "gut";
  673. case ItemDefinitionIndex::WEAPON_KNIFE_KARAMBIT:
  674. return "karambit";
  675. case ItemDefinitionIndex::WEAPON_KNIFE_M9_BAYONET:
  676. return "m9 bayonet";
  677. case ItemDefinitionIndex::WEAPON_KNIFE_T:
  678. return "knife";
  679. case ItemDefinitionIndex::WEAPON_KNIFE_TACTICAL:
  680. return "huntsman";
  681. case ItemDefinitionIndex::WEAPON_KNIFE_PUSH:
  682. return "daggers";
  683. case ItemDefinitionIndex::WEAPON_DEAGLE:
  684. return "desert eagle";
  685. case ItemDefinitionIndex::WEAPON_ELITE:
  686. return "berretas";
  687. case ItemDefinitionIndex::WEAPON_FIVESEVEN:
  688. return "fiveseven";
  689. case ItemDefinitionIndex::WEAPON_GLOCK:
  690. return "glock";
  691. case ItemDefinitionIndex::WEAPON_HKP2000:
  692. return "p2000";
  693. case ItemDefinitionIndex::WEAPON_P250:
  694. return "p250";
  695. case ItemDefinitionIndex::WEAPON_USP_SILENCER:
  696. return "usp-s";
  697. case ItemDefinitionIndex::WEAPON_TEC9:
  698. return "tec9";
  699. case ItemDefinitionIndex::WEAPON_REVOLVER:
  700. return "revolver";
  701. case ItemDefinitionIndex::WEAPON_MAC10:
  702. return "mac10";
  703. case ItemDefinitionIndex::WEAPON_UMP45:
  704. return "ump45";
  705. case ItemDefinitionIndex::WEAPON_BIZON:
  706. return "bizon";
  707. case ItemDefinitionIndex::WEAPON_MP7:
  708. return "mp7";
  709. case ItemDefinitionIndex::WEAPON_MP5:
  710. return "mp5";
  711. case ItemDefinitionIndex::WEAPON_MP9:
  712. return "mp9";
  713. case ItemDefinitionIndex::WEAPON_P90:
  714. return "p90";
  715. case ItemDefinitionIndex::WEAPON_GALILAR:
  716. return "galil";
  717. case ItemDefinitionIndex::WEAPON_FAMAS:
  718. return "famas";
  719. case ItemDefinitionIndex::WEAPON_M4A1_SILENCER:
  720. return "m4a1-s";
  721. case ItemDefinitionIndex::WEAPON_M4A1:
  722. return "m4a4";
  723. case ItemDefinitionIndex::WEAPON_AUG:
  724. return "aug";
  725. case ItemDefinitionIndex::WEAPON_SG556:
  726. return "sg556";
  727. case ItemDefinitionIndex::WEAPON_AK47:
  728. return "ak47";
  729. case ItemDefinitionIndex::WEAPON_G3SG1:
  730. return "g3sg1";
  731. case ItemDefinitionIndex::WEAPON_SCAR20:
  732. return "scar20";
  733. case ItemDefinitionIndex::WEAPON_AWP:
  734. return "awp";
  735. case ItemDefinitionIndex::WEAPON_SSG08:
  736. return "scout";
  737. case ItemDefinitionIndex::WEAPON_XM1014:
  738. return "xm1014";
  739. case ItemDefinitionIndex::WEAPON_SAWEDOFF:
  740. return "sawedoff";
  741. case ItemDefinitionIndex::WEAPON_MAG7:
  742. return "mag7";
  743. case ItemDefinitionIndex::WEAPON_NOVA:
  744. return "nova";
  745. case ItemDefinitionIndex::WEAPON_NEGEV:
  746. return "negev";
  747. case ItemDefinitionIndex::WEAPON_M249:
  748. return "m249";
  749. case ItemDefinitionIndex::WEAPON_TASER:
  750. return "zeus";
  751. case ItemDefinitionIndex::WEAPON_FLASHBANG:
  752. return "flashbang";
  753. case ItemDefinitionIndex::WEAPON_HEGRENADE:
  754. return "grenade";
  755. case ItemDefinitionIndex::WEAPON_SMOKEGRENADE:
  756. return "smoke";
  757. case ItemDefinitionIndex::WEAPON_MOLOTOV:
  758. return "molotov";
  759. case ItemDefinitionIndex::WEAPON_DECOY:
  760. return "decoy";
  761. case ItemDefinitionIndex::WEAPON_INCGRENADE:
  762. return "incendiary";
  763. case ItemDefinitionIndex::WEAPON_C4:
  764. return "bomb";
  765. case ItemDefinitionIndex::WEAPON_CZ75A:
  766. return "cz75a";
  767. default:
  768. return "error";
  769. }
  770. }
  771. };
  772.  
  773.  
  774. class viewmodel_t : public C_BaseEntity {
  775. public:
  776. NETVAR(int, m_nModelIndex, "DT_BaseViewModel", "m_nModelIndex");
  777. NETVAR(int, m_nViewModelIndex, "DT_BaseViewModel", "m_nViewModelIndex");
  778. NETVAR(CHandle<C_BaseCombatWeapon>, m_hWeapon, "DT_BaseViewModel", "m_hWeapon");
  779. NETVAR(CHandle<C_BaseEntity>, m_hOwner, "DT_BaseViewModel", "m_hOwner");
  780. };
  781.  
  782. class C_BaseViewModel
  783. {
  784. public:
  785.  
  786. inline DWORD GetOwner() {
  787.  
  788. return *(PDWORD)((DWORD)this + 0x29CC);
  789. }
  790.  
  791. inline int GetModelIndex() {
  792.  
  793. return *(int*)((DWORD)this + 0x258);
  794. }
  795. };
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803. #include "shit1.h"
  804.  
  805. class CGlowObjectManager {
  806. public:
  807.  
  808. int RegisterGlowObject(C_BaseEntity *pEntity, const Vector &vGlowColor, float flGlowAlpha, bool bRenderWhenOccluded, bool bRenderWhenUnoccluded, int nSplitScreenSlot) {
  809. int nIndex;
  810. if (m_nFirstFreeSlot == GlowObjectDefinition_t::END_OF_FREE_LIST) {
  811. nIndex = m_GlowObjectDefinitions.AddToTail();
  812. }
  813. else {
  814. nIndex = m_nFirstFreeSlot;
  815. m_nFirstFreeSlot = m_GlowObjectDefinitions[nIndex].m_nNextFreeSlot;
  816. }
  817.  
  818. m_GlowObjectDefinitions[nIndex].m_hEntity = pEntity;
  819. m_GlowObjectDefinitions[nIndex].m_vGlowColor = vGlowColor;
  820. m_GlowObjectDefinitions[nIndex].m_flGlowAlpha = flGlowAlpha;
  821. m_GlowObjectDefinitions[nIndex].flUnk = 0.0f;
  822. m_GlowObjectDefinitions[nIndex].m_flBloomAmount = 1.0f;
  823. m_GlowObjectDefinitions[nIndex].localplayeriszeropoint3 = 0.0f;
  824. m_GlowObjectDefinitions[nIndex].m_bRenderWhenOccluded = bRenderWhenOccluded;
  825. m_GlowObjectDefinitions[nIndex].m_bRenderWhenUnoccluded = bRenderWhenUnoccluded;
  826. m_GlowObjectDefinitions[nIndex].m_bFullBloomRender = false;
  827. m_GlowObjectDefinitions[nIndex].m_nFullBloomStencilTestValue = 0;
  828. m_GlowObjectDefinitions[nIndex].m_nSplitScreenSlot = nSplitScreenSlot;
  829. m_GlowObjectDefinitions[nIndex].m_nNextFreeSlot = GlowObjectDefinition_t::ENTRY_IN_USE;
  830.  
  831. return nIndex;
  832. }
  833.  
  834. void UnregisterGlowObject(int nGlowObjectHandle) {
  835. Assert(!m_GlowObjectDefinitions[nGlowObjectHandle].IsUnused());
  836.  
  837. m_GlowObjectDefinitions[nGlowObjectHandle].m_nNextFreeSlot = m_nFirstFreeSlot;
  838. m_GlowObjectDefinitions[nGlowObjectHandle].m_hEntity = NULL;
  839. m_nFirstFreeSlot = nGlowObjectHandle;
  840. }
  841.  
  842. int HasGlowEffect(C_BaseEntity *pEntity) const {
  843. for (int i = 0; i < m_GlowObjectDefinitions.Count(); ++i) {
  844. if (!m_GlowObjectDefinitions[i].IsUnused() && m_GlowObjectDefinitions[i].m_hEntity == pEntity) {
  845. return i;
  846. }
  847. }
  848.  
  849. return NULL;
  850. }
  851.  
  852. class GlowObjectDefinition_t {
  853. public:
  854. void Set(float r, float g, float b, float a, float bloom, int style) {
  855. m_vGlowColor = Vector(r, g, b);
  856. m_flGlowAlpha = a;
  857. m_bRenderWhenOccluded = true;
  858. m_bRenderWhenUnoccluded = false;
  859. m_flBloomAmount = bloom;
  860. m_nGlowStyle = style;
  861. }
  862.  
  863. C_BaseEntity* GetEnt() {
  864. return m_hEntity;
  865. }
  866.  
  867. bool IsUnused() const { return m_nNextFreeSlot != GlowObjectDefinition_t::ENTRY_IN_USE; }
  868.  
  869. public:
  870. C_BaseEntity * m_hEntity;
  871. Vector m_vGlowColor;
  872. float m_flGlowAlpha;
  873.  
  874. char unknown[4]; //pad
  875. float flUnk; //confirmed to be treated as a float while reversing glow functions
  876. float m_flBloomAmount;
  877. float localplayeriszeropoint3;
  878.  
  879.  
  880. bool m_bRenderWhenOccluded;
  881. bool m_bRenderWhenUnoccluded;
  882. bool m_bFullBloomRender;
  883. char unknown1[1]; //pad
  884.  
  885.  
  886. int m_nFullBloomStencilTestValue; // 0x28
  887. int m_nGlowStyle;
  888. int m_nSplitScreenSlot; //Should be -1
  889.  
  890. // Linked list of free slots
  891. int m_nNextFreeSlot;
  892.  
  893. // Special values for GlowObjectDefinition_t::m_nNextFreeSlot
  894. static const int END_OF_FREE_LIST = -1;
  895. static const int ENTRY_IN_USE = -2;
  896. };
  897.  
  898. CUtlVector< GlowObjectDefinition_t > m_GlowObjectDefinitions;
  899. int m_nFirstFreeSlot;
  900. };
  901. extern CGlowObjectManager* g_pGlow;
  902. extern std::string cleanstd;
  903.  
  904.  
  905. class OverlayText_t;
  906.  
  907. class IVDebugOverlay
  908. {
  909. public:
  910. virtual void __unkn() = 0;
  911. virtual void AddEntityTextOverlay(int ent_index, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
  912. virtual void AddBoxOverlay(const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, int r, int g, int b, int a, float duration) = 0;
  913. virtual void AddSphereOverlay(const Vector& vOrigin, float flRadius, int nTheta, int nPhi, int r, int g, int b, int a, float flDuration) = 0;
  914. virtual void AddTriangleOverlay(const Vector& p1, const Vector& p2, const Vector& p3, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
  915. virtual void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b, bool noDepthTest, float duration) = 0;
  916. virtual void AddTextOverlay(const Vector& origin, float duration, const char *format, ...) = 0;
  917. virtual void AddTextOverlay(const Vector& origin, int line_offset, float duration, const char *format, ...) = 0;
  918. virtual void AddScreenTextOverlay(float flXPos, float flYPos, float flDuration, int r, int g, int b, int a, const char *text) = 0;
  919. virtual void AddSweptBoxOverlay(const Vector& start, const Vector& end, const Vector& mins, const Vector& max, const QAngle & angles, int r, int g, int b, int a, float flDuration) = 0;
  920. virtual void AddGridOverlay(const Vector& origin) = 0;
  921. virtual void AddCoordFrameOverlay(const matrix3x4_t& frame, float flScale, int vColorTable[3][3] = NULL) = 0;
  922. virtual int ScreenPosition(const Vector& point, Vector& screen) = 0;
  923. virtual int ScreenPosition(float flXPos, float flYPos, Vector& screen) = 0;
  924. virtual OverlayText_t* GetFirst(void) = 0;
  925. virtual OverlayText_t* GetNext(OverlayText_t *current) = 0;
  926. virtual void ClearDeadOverlays(void) = 0;
  927. virtual void ClearAllOverlays() = 0;
  928. virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, float r, float g, float b, float alpha, const char *format, ...) = 0;
  929. virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
  930. virtual void AddLineOverlayAlpha(const Vector& origin, const Vector& dest, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
  931. virtual void AddBoxOverlay2(const Vector& origin, const Vector& mins, const Vector& max, QAngle const& orientation, const uint8_t* faceColor, const uint8_t* edgeColor, float duration) = 0;
  932. virtual void PurgeTextOverlays() = 0;
  933. virtual void DrawPill(const Vector& mins, const Vector& max, float& diameter, int r, int g, int b, int a, float duration) = 0;
  934.  
  935. public:
  936. void AddCapsuleOverlay(Vector& mins, Vector& maxs, float pillradius, int r, int g, int b, int a, float duration)
  937. {
  938. Utils::GetVFunc<void(__thiscall*)(void*, Vector&, Vector&, float&, int, int, int, int, float)>(this, 24)(this, mins, maxs, pillradius, r, g, b, a, duration);
  939. };
  940. };
  941.  
  942.  
  943. extern IVDebugOverlay* g_pIVDebugOverlay;
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953. class IEffects
  954. {
  955. public:
  956. virtual ~IEffects() {};
  957.  
  958. virtual void Beam(const Vector &Start, const Vector &End, int nModelIndex,
  959. int nHaloIndex, unsigned char frameStart, unsigned char frameRate,
  960. float flLife, unsigned char width, unsigned char endWidth, unsigned char fadeLength,
  961. unsigned char noise, unsigned char red, unsigned char green,
  962. unsigned char blue, unsigned char brightness, unsigned char speed) = 0;
  963.  
  964. //-----------------------------------------------------------------------------
  965. // Purpose: Emits smoke sprites.
  966. // Input : origin - Where to emit the sprites.
  967. // scale - Sprite scale * 10.
  968. // framerate - Framerate at which to animate the smoke sprites.
  969. //-----------------------------------------------------------------------------
  970. virtual void Smoke(const Vector &origin, int modelIndex, float scale, float framerate) = 0;
  971.  
  972. virtual void Sparks(const Vector &position, int nMagnitude = 1, int nTrailLength = 1, const Vector *pvecDir = NULL) = 0;
  973.  
  974. virtual void Dust(const Vector &pos, const Vector &dir, float size, float speed) = 0;
  975.  
  976. virtual void MuzzleFlash(const Vector &vecOrigin, const QAngle &vecAngles, float flScale, int iType) = 0;
  977.  
  978. // like ricochet, but no sound
  979. virtual void MetalSparks(const Vector &position, const Vector &direction) = 0;
  980.  
  981. virtual void EnergySplash(const Vector &position, const Vector &direction, bool bExplosive = false) = 0;
  982.  
  983. virtual void Ricochet(const Vector &position, const Vector &direction) = 0;
  984.  
  985. // FIXME: Should these methods remain in this interface? Or go in some
  986. // other client-server neutral interface?
  987. virtual float Time() = 0;
  988. virtual bool IsServer() = 0;
  989.  
  990. // Used by the playback system to suppress sounds
  991. virtual void SuppressEffectsSounds(bool bSuppress) = 0;
  992. };
  993.  
  994.  
  995. extern IEffects* g_pIEffects;
  996.  
  997.  
  998.  
  999. struct ColorRGBExp32
  1000. {
  1001. byte r, g, b;
  1002. signed char exponent;
  1003. };
  1004.  
  1005. struct dlight_t
  1006. {
  1007. int flags;
  1008. Vector origin;
  1009. float radius;
  1010. ColorRGBExp32 color;
  1011. float die;
  1012. float decay;
  1013. float minlight;
  1014. int key;
  1015. int style;
  1016. Vector m_Direction;
  1017. float m_InnerAngle;
  1018. float m_OuterAngle;
  1019. float GetRadius() const
  1020. {
  1021. return radius;
  1022. }
  1023. float GetRadiusSquared() const
  1024. {
  1025. return radius * radius;
  1026. }
  1027. float IsRadiusGreaterThanZero() const
  1028. {
  1029. return radius > 0.0f;
  1030. }
  1031. };
  1032.  
  1033. class IVEffects
  1034. {
  1035. public:
  1036. dlight_t * CL_AllocDlight(int key)
  1037. {
  1038. typedef dlight_t*(__thiscall* OriginalFn)(PVOID, int);
  1039. return Utils::GetVFunc<OriginalFn>(this, 4)(this, key);
  1040. }
  1041. dlight_t* CL_AllocElight(int key)
  1042. {
  1043. typedef dlight_t*(__thiscall* OriginalFn)(PVOID, int);
  1044. return Utils::GetVFunc<OriginalFn>(this, 5)(this, key);
  1045. }
  1046. dlight_t* GetElightByKey(int key)
  1047. {
  1048. typedef dlight_t*(__thiscall* OriginalFn)(PVOID, int);
  1049. return Utils::GetVFunc<OriginalFn>(this, 8)(this, key);
  1050. }
  1051. };
  1052.  
  1053.  
  1054. extern IVEffects* g_Dlight;
Add Comment
Please, Sign In to add comment