Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.45 KB | None | 0 0
  1. #include "Menu.hpp"
  2. #define NOMINMAX
  3. #include <Windows.h>
  4. #include <chrono>
  5.  
  6. #include "valve_sdk/csgostructs.hpp"
  7. #include "helpers/input.hpp"
  8. #include "helpers/utils.hpp"
  9.  
  10. #define IMGUI_DEFINE_MATH_OPERATORS
  11. #include "imgui/imgui_internal.h"
  12. #include "imgui/directx9/imgui_impl_dx9.h"
  13.  
  14. #include "json.hpp"
  15. #include "configuration.hpp"
  16. #include "itemdefinitions.hpp"
  17. #include "options.hpp"
  18.  
  19. static ConVar* cl_mouseenable = nullptr;
  20.  
  21. namespace ImGuiEx
  22. {
  23. inline bool ColorButton(const char* label, Color* v)
  24. {
  25. auto clr = ImVec4{
  26. v->r() / 255.0f,
  27. v->g() / 255.0f,
  28. v->b() / 255.0f,
  29. v->a() / 255.0f
  30. };
  31.  
  32. if (ImGui::ColorEdit4(label, &clr.x, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel)) {
  33. v->SetColor(clr.x, clr.y, clr.z, clr.w);
  34. return true;
  35. }
  36.  
  37. return false;
  38. }
  39. }
  40.  
  41. void ShowHelpMarker(const char* desc)
  42. {
  43. ImGui::TextDisabled("(?)");
  44. if (ImGui::IsItemHovered())
  45. {
  46. ImGui::BeginTooltip();
  47. ImGui::PushTextWrapPos(450.0f);
  48. ImGui::TextUnformatted(desc);
  49. ImGui::PopTextWrapPos();
  50. ImGui::EndTooltip();
  51. }
  52. }
  53.  
  54. void Menu::Initialize()
  55. {
  56. _visible = true;
  57.  
  58. cl_mouseenable = g_CVar->FindVar("cl_mouseenable");
  59.  
  60. ImGui_ImplDX9_Init(InputSys::Get().GetMainWindow(), g_D3DDevice9);
  61. }
  62.  
  63. void Menu::Shutdown()
  64. {
  65. ImGui_ImplDX9_Shutdown();
  66. cl_mouseenable->SetValue(true);
  67. }
  68.  
  69. void Menu::OnDeviceLost()
  70. {
  71. ImGui_ImplDX9_InvalidateDeviceObjects();
  72. }
  73.  
  74. void Menu::OnDeviceReset()
  75. {
  76. ImGui_ImplDX9_CreateDeviceObjects();
  77. }
  78.  
  79. void Menu::Render()
  80. {
  81. if (!_visible)
  82. return;
  83.  
  84. ImGui_ImplDX9_NewFrame();
  85.  
  86. ImGui::GetIO().MouseDrawCursor = _visible;
  87.  
  88. ImGui::SetNextWindowSize(ImVec2(625, 525), ImGuiCond_FirstUseEver);
  89. if (ImGui::Begin("lowerbody", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse))
  90. {
  91. static int page;
  92.  
  93. const char* tabs[] = {
  94. "Rage",
  95. "Legit",
  96. "Visual",
  97. "Miscellaneous",
  98. "Skins"
  99. };
  100.  
  101. for (int i = 0; i < ARRAYSIZE(tabs); i++)
  102. {
  103. if (ImGui::Button(tabs[i], ImVec2(ImGui::GetWindowSize().x / ARRAYSIZE(tabs) - 10, 30)))
  104. page = i;
  105.  
  106. if (i < ARRAYSIZE(tabs) - 1)
  107. ImGui::SameLine();
  108. }
  109.  
  110. ImGui::Separator();
  111.  
  112. static char* hitboxes[] = { "Head", "Neck", "Chest", "Pelvis" };
  113. static char* pitches[] = { "None", "Zero", "Up", "Down" };
  114. static char* breakable_yaws[] = { "None", "Backwards", "ManualAA", "Right", "Left Random", "Right Random", "Left Half Spin", "Right Half Spin", "Automatic", "Automatic Random", "Automatic Half Spin", "Local View", "Spin", "Lower Body" };
  115. static char* yaws[] = { "None", "Backwards", "ManualAA", "Right", "Left Random", "Right Random", "Left Half Spin", "Right Half Spin", "Automatic", "Automatic Random", "Automatic Half Spin", "Local View", "Spin", "Inverse" };
  116.  
  117. ImGui::BeginChild("");
  118. switch (page)
  119. {
  120. case 0:
  121. if (ImGui::TreeNode("Aimbot"))
  122. {
  123. ImGui::Checkbox("Enabled", &g_Options.ragebot_enabled);
  124. ImGui::Checkbox("Teammates", &g_Options.ragebot_teammates);
  125. ImGui::Checkbox("Auto shoot", &g_Options.ragebot_auto_shoot);
  126. ImGui::Checkbox("Auto scope", &g_Options.ragebot_auto_scope);
  127. ImGui::Checkbox("Auto wall", &g_Options.ragebot_auto_wall);
  128. ImGui::Checkbox("Hit scan", &g_Options.ragebot_hit_scan);
  129. ImGui::Combo("Hitbox", &g_Options.ragebot_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  130. ImGui::SliderInt("Field of view", &g_Options.ragebot_fov, 1, 360, "%.0f degrees");
  131. ImGui::SliderInt("Minimum damage", &g_Options.ragebot_minimum_damage, 1, 100, "%.0f health");
  132. ImGui::SliderInt("Hit chance", &g_Options.ragebot_hit_chance, 1, 100, "%.0f percent");
  133. ImGui::TreePop();
  134. }
  135.  
  136. if (ImGui::TreeNode("Anti Aimbot"))
  137. {
  138. ImGui::Checkbox("Enabled", &g_Options.anti_aimbot_enabled);
  139. ImGui::Combo("Pitch", &g_Options.anti_aimbot_pitch, pitches, IM_ARRAYSIZE(pitches));
  140. ImGui::Combo("Yaw", &g_Options.anti_aimbot_yaw, breakable_yaws, IM_ARRAYSIZE(breakable_yaws));
  141. ImGui::SliderInt("Yaw offset", &g_Options.anti_aimbot_yaw_offset, -180, 180, "%.0f degrees");
  142. ImGui::Combo("Yaw while running", &g_Options.anti_aimbot_yaw_while_running, yaws, IM_ARRAYSIZE(yaws));
  143. ImGui::SliderInt("Yaw while running offset", &g_Options.anti_aimbot_yaw_while_running_offset, -180, 180, "%.0f degrees");
  144. ImGui::Combo("Fake yaw", &g_Options.anti_aimbot_fake_yaw, yaws, IM_ARRAYSIZE(yaws));
  145. ImGui::SliderInt("Fake yaw offset", &g_Options.anti_aimbot_fake_yaw_offset, -180, 180, "%.0f degrees");
  146. ImGui::SliderInt("Spin speed", &g_Options.anti_aimbot_spin_speed, 1, 100, "%.0f ap/t");
  147. ImGui::TreePop();
  148. }
  149.  
  150. if (ImGui::TreeNode("Corrections"))
  151. {
  152. ImGui::Checkbox("Fake yaw correction", &g_Options.corrections_fake_yaw_correction); ImGui::SameLine(); ShowHelpMarker("Attempt to remove faked yaw angles.");
  153. ImGui::TreePop();
  154. }
  155. break;
  156. case 1:
  157. if (ImGui::TreeNode("Pistol"))
  158. {
  159. ImGui::Checkbox("Enabled", &g_Options.pistol_enabled);
  160. ImGui::Checkbox("Teammates", &g_Options.pistol_teammates);
  161. ImGui::Checkbox("Recoil control system", &g_Options.pistol_rcs);
  162. ImGui::Combo("Hitbox", &g_Options.pistol_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  163. ImGui::SliderInt("Field of view", &g_Options.pistol_fov, 1, 360, "%.0f degrees");
  164. ImGui::SliderInt("Smooth pitch", &g_Options.pistol_smooth_x, 1, 100);
  165. ImGui::SliderInt("Smooth yaw", &g_Options.pistol_smooth_y, 1, 100);
  166. ImGui::TreePop();
  167. }
  168.  
  169. if (ImGui::TreeNode("Shotgun"))
  170. {
  171. ImGui::Checkbox("Enabled", &g_Options.shotgun_enabled);
  172. ImGui::Checkbox("Teammates", &g_Options.shotgun_teammates);
  173. ImGui::Checkbox("Recoil control system", &g_Options.shotgun_rcs);
  174. ImGui::Combo("Hitbox", &g_Options.shotgun_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  175. ImGui::SliderInt("Field of view", &g_Options.shotgun_fov, 1, 360, "%.0f degrees");
  176. ImGui::SliderInt("Smooth pitch", &g_Options.shotgun_smooth_x, 1, 100);
  177. ImGui::SliderInt("Smooth yaw", &g_Options.shotgun_smooth_y, 1, 100);
  178. ImGui::TreePop();
  179. }
  180.  
  181. if (ImGui::TreeNode("SMG"))
  182. {
  183. ImGui::Checkbox("Enabled", &g_Options.smg_enabled);
  184. ImGui::Checkbox("Teammates", &g_Options.smg_teammates);
  185. ImGui::Checkbox("Recoil control system", &g_Options.smg_rcs);
  186. ImGui::Combo("Hitbox", &g_Options.smg_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  187. ImGui::SliderInt("Field of view", &g_Options.smg_fov, 1, 360, "%.0f degrees");
  188. ImGui::SliderInt("Smooth pitch", &g_Options.smg_smooth_x, 1, 100);
  189. ImGui::SliderInt("Smooth yaw", &g_Options.smg_smooth_y, 1, 100);
  190. ImGui::TreePop();
  191. }
  192.  
  193. if (ImGui::TreeNode("Rifle"))
  194. {
  195. ImGui::Checkbox("Enabled", &g_Options.rifle_enabled);
  196. ImGui::Checkbox("Teammates", &g_Options.rifle_teammates);
  197. ImGui::Checkbox("Recoil control system", &g_Options.rifle_rcs);
  198. ImGui::Combo("Hitbox", &g_Options.rifle_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  199. ImGui::SliderInt("Field of view", &g_Options.rifle_fov, 1, 360, "%.0f degrees");
  200. ImGui::SliderInt("Smooth pitch", &g_Options.rifle_smooth_x, 1, 100);
  201. ImGui::SliderInt("Smooth yaw", &g_Options.rifle_smooth_y, 1, 100);
  202. ImGui::TreePop();
  203. }
  204.  
  205. if (ImGui::TreeNode("Sniper"))
  206. {
  207. ImGui::Checkbox("Enabled", &g_Options.sniper_enabled);
  208. ImGui::Checkbox("Teammates", &g_Options.sniper_teammates);
  209. ImGui::Checkbox("Recoil control system", &g_Options.sniper_rcs);
  210. ImGui::Combo("Hitbox", &g_Options.sniper_hitbox, hitboxes, IM_ARRAYSIZE(hitboxes));
  211. ImGui::SliderInt("Field of view", &g_Options.sniper_fov, 1, 360, "%.0f degrees");
  212. ImGui::SliderInt("Smooth pitch", &g_Options.sniper_smooth_x, 1, 100);
  213. ImGui::SliderInt("Smooth yaw", &g_Options.sniper_smooth_y, 1, 100);
  214. ImGui::TreePop();
  215. }
  216. break;
  217. case 2:
  218. if (ImGui::TreeNode("ESP"))
  219. {
  220. ImGui::Checkbox("Teammates", &g_Options.esp_teammates);
  221. ImGui::Checkbox("Bounding box", &g_Options.esp_bounding_box); ImGui::SameLine(); ImGuiEx::ColorButton("Bounding box", &g_Options.color_esp_bounding_box);
  222. ImGui::Checkbox("Name", &g_Options.esp_name);
  223. ImGui::Checkbox("Flags", &g_Options.esp_flags);
  224. ImGui::Checkbox("Health", &g_Options.esp_health);
  225. ImGui::Checkbox("Weapon", &g_Options.esp_weapon);
  226. ImGui::Checkbox("Ammo", &g_Options.esp_ammo);
  227. ImGui::TreePop();
  228. }
  229.  
  230. if (ImGui::TreeNode("Glow"))
  231. {
  232. ImGui::Checkbox("Teammates", &g_Options.glow_teammates);
  233. ImGui::Checkbox("Players", &g_Options.glow_players); ImGui::SameLine(); ImGuiEx::ColorButton("Players", &g_Options.color_glow_players);
  234. ImGui::TreePop();
  235. }
  236.  
  237. if (ImGui::TreeNode("Colored Models"))
  238. {
  239. ImGui::Checkbox("Teammates", &g_Options.colored_models_teammates);
  240. ImGui::Checkbox("Players", &g_Options.colored_models_players); ImGui::SameLine(); ImGuiEx::ColorButton("Players", &g_Options.color_colored_models_players);
  241. ImGui::Checkbox("Players (behind walls)", &g_Options.colored_models_players_behind_walls); ImGui::SameLine(); ImGuiEx::ColorButton("Players (behind walls)", &g_Options.color_colored_models_players_behind_walls);
  242. ImGui::TreePop();
  243. }
  244.  
  245. if (ImGui::TreeNode("Removals"))
  246. {
  247. ImGui::Checkbox("Remove scope", &g_Options.removals_remove_scope);
  248. ImGui::Checkbox("Remove flashbang effects", &g_Options.removals_remove_flashbang_effects);
  249. ImGui::Checkbox("Remove smoke grenades", &g_Options.removals_remove_smoke_grenades);
  250. ImGui::Checkbox("Remove visual recoil", &g_Options.removals_remove_visual_recoil);
  251. ImGui::TreePop();
  252. }
  253.  
  254. if (ImGui::TreeNode("Aesthetic##visuals"))
  255. {
  256. ImGui::Checkbox("Night mode", &g_Options.aesthetics_night_mode);
  257. ImGui::Checkbox("Transparent props", &g_Options.aesthetics_transparent_props);
  258. ImGui::Checkbox("Bullet tracers", &g_Options.aesthetics_bullet_tracers); ImGui::SameLine(); ImGuiEx::ColorButton("Bullet tracers", &g_Options.color_bullet_tracers);
  259. ImGui::TreePop();
  260. }
  261.  
  262. if (ImGui::TreeNode("Information##visuals"))
  263. {
  264. ImGui::Checkbox("Third person", &g_Options.information_third_person);
  265. ImGui::Checkbox("Visualize spread", &g_Options.information_visualize_spread); ImGui::SameLine(); ImGuiEx::ColorButton("Visualize spread", &g_Options.color_visualize_spread);
  266. ImGui::Checkbox("Visualize angles", &g_Options.information_visualize_angles);
  267. ImGui::Checkbox("Indicators", &g_Options.information_indicators);
  268. ImGui::Checkbox("Event logs", &g_Options.information_event_logs);
  269. ImGui::TreePop();
  270. }
  271. break;
  272. case 3:
  273. if (ImGui::TreeNode("Movement"))
  274. {
  275. ImGui::Checkbox("Bunnyhop", &g_Options.movement_bunnyhop);
  276. ImGui::Checkbox("Auto strafe", &g_Options.movement_auto_strafe);
  277. ImGui::TreePop();
  278. }
  279.  
  280. if (ImGui::TreeNode("Aesthetic##miscellaneous"))
  281. {
  282. if (ImGui::Checkbox("Clantag spammer", &g_Options.aesthetics_clantag_spammer))
  283. Utils::SetClantag("");
  284. ImGui::TreePop();
  285. }
  286.  
  287. if (ImGui::TreeNode("Information##miscellaneous"))
  288. {
  289. ImGui::Checkbox("Hit markers", &g_Options.information_hit_markers);
  290. ImGui::Checkbox("Rank revealer", &g_Options.information_rank_revealer);
  291. ImGui::TreePop();
  292. }
  293.  
  294. if (ImGui::TreeNode("Automation"))
  295. {
  296. ImGui::Checkbox("Auto accept", &g_Options.automation_auto_accept);
  297. ImGui::TreePop();
  298. }
  299.  
  300. if (ImGui::TreeNode("Exploits"))
  301. {
  302. ImGui::Checkbox("Backtrack moving targets", &g_Options.exploits_backtrack_moving_targets);
  303. ImGui::SliderInt("Backtrack ticks", &g_Options.exploits_backtrack_ticks, 1, 16, "%.0f ticks");
  304. ImGui::TreePop();
  305. }
  306. break;
  307. case 4:
  308. if (ImGui::TreeNode("Items")) {
  309. // Loop through the game item list.
  310. for (const auto& item : ItemDefinitionIndex) {
  311. // Get the configuration for the current item.
  312. EconomyItem_t& weapon = config.GetWeaponConfiguration(item.first);
  313.  
  314. // Ensure that our settings will be used.
  315. if (!weapon.is_valid)
  316. weapon.is_valid = true;
  317.  
  318. // Hide place holder items.
  319. if (strcmp(item.second.entity_name, "WEAPON_KNIFE_BAYONET") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_FLIP") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_GUT") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_KARAMBIT") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_M9_BAYONET") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_TACTICAL") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_FALCHION") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_SURVIVAL_BOWIE") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_BUTTERFLY") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_PUSH") == 0)
  320. continue;
  321.  
  322. // Create a new node in the tree for this item.
  323. if (ImGui::TreeNode(item.second.display_name)) {
  324. // Add input forms to edit values for this item.
  325. ImGui::Text("Paint kit");
  326. if (ImGui::InputInt(std::string("##paint_kit").append(item.second.entity_name).c_str(), &weapon.fallback_paint_kit))
  327. g_ClientState->ForceFullUpdate();
  328. ImGui::Spacing();
  329.  
  330. ImGui::Text("Custom seed");
  331. if (ImGui::InputInt(std::string("##seed").append(item.second.entity_name).c_str(), &weapon.fallback_seed))
  332. g_ClientState->ForceFullUpdate();
  333. ImGui::Spacing();
  334.  
  335. ImGui::Text("Item quality");
  336. if (ImGui::InputInt(std::string("##quality").append(item.second.entity_name).c_str(), &weapon.entity_quality))
  337. g_ClientState->ForceFullUpdate();
  338. ImGui::Spacing();
  339.  
  340. // Check if they should be able to change the item's index.
  341. if (strcmp(item.second.entity_name, "WEAPON_KNIFE") == 0 || strcmp(item.second.entity_name, "WEAPON_KNIFE_T") == 0) {
  342. ImGui::Text("Override item index");
  343. if (ImGui::InputInt(std::string("##override_item").append(item.second.entity_name).c_str(), &weapon.item_definition_index))
  344. g_ClientState->ForceFullUpdate();
  345. ImGui::Spacing();
  346. }
  347.  
  348. ImGui::Text("Item wear");
  349. if (ImGui::SliderFloat(std::string("##wear").append(item.second.entity_name).c_str(), &weapon.fallback_wear, 0.00001f, 2.0f, "(%.5f)"))
  350. g_ClientState->ForceFullUpdate();
  351. ImGui::Spacing();
  352.  
  353. if (ImGui::Button("Reset")) {
  354. // Reset all settings for this weapon to default.
  355. weapon.Reset();
  356.  
  357. // Perform a full update.
  358. g_ClientState->ForceFullUpdate();
  359. }
  360.  
  361. ImGui::SameLine();
  362.  
  363. if (ImGui::Button("Apply")) {
  364. // Perform a full update.
  365. g_ClientState->ForceFullUpdate();
  366. }
  367.  
  368. ImGui::TreePop();
  369. }
  370. }
  371.  
  372. ImGui::TreePop();
  373. }
  374.  
  375. if (ImGui::TreeNode("Presets")) {
  376. // Get the configuration file extension.
  377. static std::string extension = config.GetConfigExtension();
  378.  
  379. // Get a list of configuration files in the working directory.
  380. static std::vector<std::string> presets = config.GetPresets();
  381.  
  382. // Show a text box for creating new presets.
  383. static char preset_filename[64];
  384. ImGui::Text("Preset filename");
  385. ImGui::InputText("##current_filename", preset_filename, 64);
  386. ImGui::SameLine();
  387.  
  388. if (ImGui::Button("New")) {
  389. // Append the file extension if the user did not specify it.
  390. std::string filename(preset_filename);
  391.  
  392. if (!std::equal(extension.rbegin(), extension.rend(), filename.rbegin()))
  393. filename = filename.append(extension);
  394.  
  395. // Save the new preset to disk.
  396. config.SavePreset(filename);
  397.  
  398. // Refresh the list of presets.
  399. presets = config.GetPresets();
  400. }
  401.  
  402. // Whether we should clear other item settings when loading a preset.
  403. static bool reset_on_load = false;
  404. ImGui::Checkbox("Reset settings on load", &reset_on_load);
  405.  
  406. if (presets.size() >= 1) {
  407. for (const std::string& preset : presets) {
  408. // Display the filename of this preset.
  409. ImGui::AlignFirstTextHeightToWidgets();
  410. ImGui::BulletText(preset.c_str());
  411. ImGui::SameLine();
  412.  
  413. if (ImGui::Button(std::string("Save##").append(preset).c_str())) {
  414. // Overwrite this file with current item settings.
  415. config.SavePreset(preset);
  416. }
  417.  
  418. ImGui::SameLine();
  419.  
  420. if (ImGui::Button(std::string("Load##").append(preset).c_str())) {
  421. // Load current settings from this file.
  422. config.LoadPreset(preset, reset_on_load);
  423.  
  424. // Perform a full update.
  425. g_ClientState->ForceFullUpdate();
  426. }
  427.  
  428. ImGui::SameLine();
  429.  
  430. if (ImGui::Button(std::string("Delete##").append(preset).c_str()) && config.RemovePreset(preset.c_str())) {
  431. // Attempt to delete the preset file from disk.
  432. presets = config.GetPresets();
  433. }
  434.  
  435. ImGui::Spacing();
  436. }
  437. }
  438. else {
  439. // Show default text when no presets exist.
  440. ImGui::TextWrapped("No presets found. You can create a preset by entering a name above and pressing the 'New' button.");
  441. }
  442.  
  443. if (ImGui::Button("Refresh preset list")) {
  444. // Check the folder again for more presets.
  445. presets = config.GetPresets();
  446. }
  447.  
  448. ImGui::SameLine();
  449.  
  450. if (ImGui::Button("Reset all settings")) {
  451. // Reset all user settings.
  452. config.ResetWeaponConfiguration();
  453.  
  454. // Perform a full update.
  455. g_ClientState->ForceFullUpdate();
  456. }
  457. }
  458. ImGui::TreePop();
  459. break;
  460. }
  461. ImGui::EndChild();
  462. }
  463.  
  464. ImGui::End();
  465.  
  466. ImGui::Render();
  467. }
  468.  
  469. void Menu::Show()
  470. {
  471. _visible = true;
  472. cl_mouseenable->SetValue(false);
  473. }
  474.  
  475. void Menu::Hide()
  476. {
  477. _visible = false;
  478. cl_mouseenable->SetValue(true);
  479. }
  480.  
  481. void Menu::Toggle()
  482. {
  483. _visible = !_visible;
  484. cl_mouseenable->SetValue(!_visible);
  485. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement