Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. //nucopia mata123
  2. #include "hooks.h"
  3. #include "Menu.h"
  4. #include "global.h"
  5. #include "MaterialHelper.h"
  6. #include "xor.h"
  7. #include "Backtrackinghelper.h"
  8. #include "GameUtils.h"
  9. Color rainbow() {
  10.  
  11. static float x = 0, y = 0;
  12. static float r = 0, g = 0, b = 0;
  13.  
  14. if (y >= 0.0f && y < 255.0f) {
  15. r = 255.0f;
  16. g = 0.0f;
  17. b = x;
  18. }
  19. else if (y >= 255.0f && y < 510.0f) {
  20. r = 255.0f - x;
  21. g = 0.0f;
  22. b = 255.0f;
  23. }
  24. else if (y >= 510.0f && y < 765.0f) {
  25. r = 0.0f;
  26. g = x;
  27. b = 255.0f;
  28. }
  29. else if (y >= 765.0f && y < 1020.0f) {
  30. r = 0.0f;
  31. g = 255.0f;
  32. b = 255.0f - x;
  33. }
  34. else if (y >= 1020.0f && y < 1275.0f) {
  35. r = x;
  36. g = 255.0f;
  37. b = 0.0f;
  38. }
  39. else if (y >= 1275.0f && y < 1530.0f) {
  40. r = 255.0f;
  41. g = 255.0f - x;
  42. b = 0.0f;
  43. }
  44.  
  45. x += 0.25f; //increase this value to switch colors faster
  46. if (x >= 255.0f)
  47. x = 0.0f;
  48.  
  49. y += 0.25f; //increase this value to switch colors faster
  50. if (y > 1530.0f)
  51. y = 0.0f;
  52.  
  53.  
  54. return Color((int)r, (int)g, (int)b, 255);
  55. }
  56. void __fastcall Hooks::scene_end(void* thisptr, void* edx)
  57. {
  58.  
  59. static auto scene_end_o = renderviewVMT->GetOriginalMethod< decltype(&scene_end) >(9);
  60. scene_end_o(thisptr, edx);
  61.  
  62. if (vars->Visuals.ChamsEnable)
  63. {
  64. //float Red, Green, Blue, RedZ, GreenZ, BlueZ;
  65.  
  66. static IMaterial* CoveredLit = g_MaterialHelper->CreateMaterial(true);
  67. static IMaterial* OpenLit = g_MaterialHelper->CreateMaterial(false);
  68. static IMaterial* CoveredFlat = g_MaterialHelper->CreateMaterial(true, false);
  69. static IMaterial* OpenFlat = g_MaterialHelper->CreateMaterial(false, false);
  70.  
  71. IMaterial *covered = vars->Visuals.ChamsStyle == 1 ? CoveredLit : CoveredFlat;
  72. IMaterial *open = vars->Visuals.ChamsStyle == 1 ? OpenLit : OpenFlat;
  73.  
  74. auto b_IsThirdPerson = *reinterpret_cast<bool*>(reinterpret_cast<DWORD>(g_pInput) + 0xA5);
  75.  
  76. for (int i = 1; i < g_pEngine->GetMaxClients(); ++i) {
  77. CBaseEntity* ent = (CBaseEntity*)g_pEntitylist->GetClientEntity(i);
  78.  
  79. if (ent == G::LocalPlayer && G::LocalPlayer != nullptr)
  80. {
  81. /*if (G::LocalPlayer->isAlive())
  82. {
  83. if (b_IsThirdPerson && vars->Visuals.FakeAngleGhost != 0)
  84. {
  85. //
  86. Vector OrigAng;
  87. OrigAng = ent->GetEyeAngles();
  88.  
  89. float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  90. float r2 = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / 1.f));
  91. float r3 = 0.30f + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (0.49f - 0.35f)));
  92. float mata[3] = { r, 1.f , r3 };
  93.  
  94. if (vars->Visuals.FakeAngleGhost == 1)
  95. ent->SetAngle2(Vector(vars->Ragebot.fakex, G::FakeAngle.y, vars->Ragebot.fakez));
  96. else
  97. ent->SetAngle2(Vector(0, G::LocalPlayer->LowerBodyYaw(), 0));
  98. g_pRenderView->SetBlend(vars->Colors.transparentaghost);
  99. g_pRenderView->SetColorModulation(mata);
  100. g_pModelRender->ForcedMaterialOverride(covered);
  101. ent->draw_model(0x1, 255);
  102. g_pModelRender->ForcedMaterialOverride(nullptr);
  103. ent->SetAngle2(OrigAng);
  104. }
  105. }
  106. */
  107. int index = ent->Index();
  108. studiohdr_t* pStudioModel = g_pModelInfo->GetStudioModel((model_t*)ent->GetModel());
  109. if (pStudioModel && g_BacktrackHelper->PlayerRecord[index].records.size() > 0)
  110. {
  111. mstudiobone_t* pBone = pStudioModel->pBone(i);
  112.  
  113. if (!pBone || !(pBone->flags & 256) || pBone->parent == -1)
  114. continue;
  115.  
  116. tick_record record = g_BacktrackHelper->PlayerRecord[index].records.back();
  117. Vector sBonePos1 = GameUtils::GetBonePosition(ent, i, record.boneMatrix), vBonePos1; //.back() for nice skeleton
  118.  
  119. if (sBonePos1 == Vector(0, 0, 0))
  120. continue;
  121. if (!GameUtils::WorldToScreen(sBonePos1, vBonePos1))
  122. continue;
  123.  
  124. Vector sBonePos2 = GameUtils::GetBonePosition(ent, pBone->parent, record.boneMatrix), vBonePos2;//.back() for nice skeleton
  125. //
  126. if (vars->Visuals.FakeAngleGhost != 0)
  127. {
  128. //
  129. Vector OrigAng;
  130. OrigAng = ent->GetEyeAngles();
  131.  
  132. float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  133. float r2 = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / 1.f));
  134. float r3 = 0.30f + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (0.49f - 0.35f)));
  135. float mata[3] = { r, 1.f , r3 };
  136.  
  137. if (vars->Visuals.FakeAngleGhost == 1)
  138. ent->SetAngle2(Vector(vBonePos1));
  139. else
  140. ent->SetAngle2(Vector(0, G::LocalPlayer->LowerBodyYaw(), 0));
  141. g_pRenderView->SetBlend(vars->Colors.transparentaghost);
  142. g_pRenderView->SetColorModulation(mata);
  143. g_pModelRender->ForcedMaterialOverride(covered);
  144. ent->draw_model(0x1, 255);
  145. g_pModelRender->ForcedMaterialOverride(nullptr);
  146. ent->SetAngle2(sBonePos2);
  147. }
  148.  
  149. }
  150.  
  151. if (ent->IsValidRenderable() && vars->Visuals.ChamsPlayer)
  152. {
  153. if (vars->Visuals.ChamsPlayerWall)
  154. {
  155. g_pRenderView->SetColorModulation(vars->Colors.PlayerChamsWall);
  156. g_pModelRender->ForcedMaterialOverride(covered);
  157. ent->draw_model(0x1, 255);
  158. ent->SetAngle2(Vector(vars->Ragebot.fakex, G::FakeAngle.y, vars->Ragebot.fakez));
  159. g_pModelRender->ForcedMaterialOverride(nullptr);
  160. }
  161. g_pRenderView->SetColorModulation(vars->Colors.PlayerChams);
  162. g_pModelRender->ForcedMaterialOverride(open);
  163. ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
  164. ent->SetAngle2(Vector(vars->Ragebot.fakex, G::FakeAngle.y, vars->Ragebot.fakez));
  165. g_pModelRender->ForcedMaterialOverride(nullptr);
  166. }
  167. }
  168. }
  169. }
  170. }
  171.  
  172. void __fastcall Hooks::DrawModelExecute(void* ecx, void* edx, void* * ctx, void *state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld)
  173. {
  174. if (!G::LocalPlayer)
  175. {
  176. modelrenderVMT->GetOriginalMethod<DrawModelExecuteFn>(21)(ecx, ctx, state, pInfo, pCustomBoneToWorld);
  177. return;
  178. }
  179.  
  180. const char* ModelName = g_pModelInfo->GetModelName((model_t*)pInfo.pModel);
  181.  
  182. static IMaterial* pWireframeMaterial = g_MaterialHelper->CreateMaterial(false, false, true);
  183. static IMaterial* OpenFlat = g_MaterialHelper->CreateMaterial(false, false);
  184.  
  185. if (!*(bool*)((DWORD)g_pInput + 0xA5)) { // Thirdperson
  186.  
  187. if (vars->Visuals.WeaponChams && strstr(ModelName, XorStr("models/weapons")))
  188. {
  189. g_pRenderView->SetColorModulation(vars->Colors.ChamsWeapon);
  190. g_pRenderView->SetBlend(1.f);
  191. g_pModelRender->ForcedMaterialOverride(OpenFlat);
  192.  
  193. modelrenderVMT->GetOriginalMethod<DrawModelExecuteFn>(21)(ecx, ctx, state, pInfo, pCustomBoneToWorld);
  194.  
  195. if (vars->Visuals.WeaponWireframe)
  196. {
  197. g_pRenderView->SetColorModulation(vars->Colors.WireframeWeapon);
  198. g_pRenderView->SetBlend(1.f);
  199. g_pModelRender->ForcedMaterialOverride(pWireframeMaterial);
  200.  
  201. }
  202. }
  203. }
  204.  
  205. if (vars->Visuals.ChamsHands && strstr(ModelName, XorStr("arms")))
  206. {
  207. g_pRenderView->SetColorModulation(vars->Colors.ChamsHand);
  208. g_pRenderView->SetBlend(1.f);
  209. g_pModelRender->ForcedMaterialOverride(OpenFlat);
  210.  
  211. modelrenderVMT->GetOriginalMethod<DrawModelExecuteFn>(21)(ecx, ctx, state, pInfo, pCustomBoneToWorld);
  212.  
  213. if (vars->Visuals.ChamsHandsWireframe)
  214. {
  215. g_pRenderView->SetColorModulation(vars->Colors.WireframeHand);
  216. g_pRenderView->SetBlend(1.f);
  217. g_pModelRender->ForcedMaterialOverride(pWireframeMaterial);
  218. }
  219. }
  220. modelrenderVMT->GetOriginalMethod<DrawModelExecuteFn>(21)(ecx, ctx, state, pInfo, pCustomBoneToWorld);
  221. g_pModelRender->ForcedMaterialOverride(NULL);
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement