Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.15 KB | None | 0 0
  1. require("/override_mindmg")
  2.  
  3. --------------------------------------------------------------------------------
  4. -- Constants and variables
  5. --------------------------------------------------------------------------------
  6. local enable_ref
  7. local config_ref
  8. local label_ref
  9.  
  10. -- Array of aimbot references
  11. -- references[IDX_BUILTIN] is an array of references to the built-in menu items
  12. -- references[IDX_GLOBAL] is an array of references to the global config
  13. local references = {}
  14. local IDX_BUILTIN = 1
  15. local IDX_GLOBAL = 2
  16.  
  17. local config_idx_to_name = {}
  18. local config_name_to_idx = {}
  19. local weapon_id_to_config_idx = {}
  20.  
  21. -- Active weapon config is managed by the script when the local player is alive
  22. -- Active weapon config is managed by the user (via the menu) while the local player is dead
  23. local active_config_idx
  24.  
  25. local SPECATOR_TEAM_ID = 1
  26.  
  27. --------------------------------------------------------------------------------
  28. -- Utility functions
  29. --------------------------------------------------------------------------------
  30. local function copy_settings(config_idx_src, config_idx_dst)
  31. local src_refs = references[config_idx_src]
  32. local dst_refs = references[config_idx_dst]
  33. for i = 1, #dst_refs do
  34. ui.set(dst_refs[i], ui.get(src_refs[i]))
  35. end
  36. end
  37.  
  38. local function load_config(config_idx)
  39. if active_config_idx ~= config_idx then
  40. active_config_idx = config_idx
  41. copy_settings(config_idx, IDX_BUILTIN)
  42. ui.set(label_ref, "Active weapon config: " .. config_idx_to_name[config_idx])
  43. end
  44. end
  45.  
  46. local function update_config_visibility(state)
  47. local display_config = state
  48. local script_state = ui.get(enable_ref)
  49. if display_config == nil then
  50. display_config = entity.is_alive(entity.get_local_player()) == false
  51. end
  52. local display_label = not display_config
  53. ui.set_visible(config_ref, display_config and script_state)
  54. ui.set_visible(label_ref, display_label and script_state)
  55. return display_config
  56. end
  57.  
  58. local function save_reference(config_idx, setting_idx, ref)
  59. references[config_idx][setting_idx] = ref
  60. return ref
  61. end
  62.  
  63. local function bind(func, ...)
  64. local args = { ... }
  65. return function(ref)
  66. func(ref, unpack(args))
  67. end
  68. end
  69.  
  70. local function delayed_bind(func, delay, ...)
  71. local args = { ... }
  72. return function(ref)
  73. client.delay_call(delay, func, ref, unpack(args))
  74. end
  75. end
  76.  
  77. -- Temporary function for enabling config in the menu
  78. local function temp_task()
  79. update_config_visibility()
  80. client.delay_call(5, temp_task)
  81. end
  82.  
  83. --------------------------------------------------------------------------------
  84. -- Callback functions
  85. --------------------------------------------------------------------------------
  86. local function on_setup_command()
  87. local local_player = entity.get_local_player()
  88. -- Get the local players weapon so we can find its item definition index
  89. local weapon = entity.get_player_weapon(local_player)
  90. -- Get the weapons item definition and toggle off the 16th bit to get the real item def index
  91. local weapon_id = bit.band(entity.get_prop(weapon, "m_iItemDefinitionIndex"), 0xFFFF)
  92. -- Use the weapon_id_to_config_idx lookup table to get the new config index and attempt to load the config
  93. load_config(weapon_id_to_config_idx[weapon_id] or IDX_GLOBAL)
  94. end
  95.  
  96. local function on_player_death(e)
  97. if client.userid_to_entindex(e.userid) == entity.get_local_player() then
  98. update_config_visibility(true)
  99. end
  100. end
  101.  
  102. local function on_player_spawn(e)
  103. if client.userid_to_entindex(e.userid) == entity.get_local_player() then
  104. update_config_visibility(false)
  105. end
  106. end
  107.  
  108. local function on_player_team_change(e)
  109. if client.userid_to_entindex(e.userid) == entity.get_local_player() then
  110. -- Check if the team the local player switched to is spectator(1)
  111. if e.team == SPECATOR_TEAM_ID then
  112. update_config_visibility(true)
  113. end
  114. end
  115. end
  116.  
  117. local function on_game_disconnect()
  118. update_config_visibility(true)
  119. end
  120.  
  121. -- Called when a user selects a different weapon config with the combobox
  122. local function on_weapon_config_selected(ref)
  123. -- If the local player is alive then do nothing and hide this combobox
  124. if update_config_visibility() == false then
  125. -- This should never happen
  126. -- client.error_log("Weapon config selected while local player is alive!")
  127. return
  128. end
  129.  
  130. -- Load settings from the selected weapon config
  131. local config_name = ui.get(ref)
  132. local config_idx = config_name_to_idx[config_name]
  133. load_config(config_idx)
  134. end
  135.  
  136. -- Called when a user changes the value of a built-in menu item (e.g. checking "Automatic penetrationn")
  137. -- Also called when a config is loaded
  138. local function on_builtin_setting_change(ref, setting_idx)
  139. -- Propagate built-in setting changes to the adaptive settings
  140. if active_config_idx ~= nil and ui.get(enable_ref) == true then
  141. ui.set(references[active_config_idx][setting_idx], ui.get(ref))
  142. end
  143. end
  144.  
  145. -- Called when a user changes the value of a weapon configs menu item (e.g. checking "Global automatic penetration")
  146. -- Also called when a config is loaded
  147. local function on_adaptive_setting_changed(ref, config_idx, setting_idx)
  148. -- Propagate adaptive setting changes to the built-in settings
  149. if config_idx == active_config_idx and ui.get(enable_ref) == true then
  150. ui.set(references[IDX_BUILTIN][setting_idx], ui.get(ref))
  151. end
  152. end
  153.  
  154. -- Called when a user toggles the main script checkbox
  155. -- Also called on script load
  156. local function on_adaptive_config_toggled(ref)
  157. local script_state = ui.get(ref)
  158. -- Update the configs visibility when the script is toggled
  159. update_config_visibility()
  160. -- Set / unset event callbacks based on the state of the script so that we aren't just invoking callbacks for no reason
  161. local update_callback = script_state and client.set_event_callback or client.unset_event_callback
  162. update_callback("setup_command", on_setup_command)
  163. update_callback("player_death", on_player_death)
  164. update_callback("player_spawn", on_player_spawn)
  165. update_callback("player_team", on_player_team_change)
  166. update_callback("cs_game_disconnected", on_game_disconnect)
  167. end
  168.  
  169. --------------------------------------------------------------------------------
  170. -- Initialization code
  171. --------------------------------------------------------------------------------
  172. local function duplicate(tab, container, name, ui_func, ...)
  173. -- This menu item will have the same index across all weapon configs
  174. local setting_index = #references[IDX_BUILTIN] + 1
  175. -- Create hidden menu items to store values
  176. for i = IDX_GLOBAL, #references do
  177. local config_name = config_idx_to_name[i]
  178. -- Create a duplicate menu item to store settings that can be copied later
  179. local ref = save_reference(i, setting_index, ui_func(tab, container, config_name .. " " .. name:lower(), ...))
  180. -- Set a default value for the target hitbox as this multiselect cannot be empty
  181. if name == "Target hitbox" then
  182. ui.set(ref, { "Head" })
  183. end
  184. ui.set_visible(ref, false)
  185. ui.set_callback(ref, bind(on_adaptive_setting_changed, i, setting_index))
  186. end
  187. local ref = save_reference(IDX_BUILTIN, setting_index, ui.reference(tab, container, name))
  188. -- Set a callback on the built-in menu items so that settings are not overwritten whenever we are loading a new config
  189. ui.set_callback(ref, delayed_bind(on_builtin_setting_change, 0.01, setting_index))
  190. end
  191.  
  192. local function init_config(name, ...)
  193. local config_idx = #references + 1
  194. references[config_idx] = {}
  195. config_idx_to_name[config_idx] = name
  196. config_name_to_idx[name] = config_idx
  197. -- Populate the weapon_id_to_config_idx lookup table so we can easily get a configs index from a weapon id
  198. for _, weapon_id in ipairs({ ... }) do
  199. weapon_id_to_config_idx[weapon_id] = config_idx
  200. end
  201. return config_idx
  202. end
  203.  
  204. local function init()
  205. IDX_BUILTIN = init_config("Built-in menu items")
  206. init_config("Global")
  207. init_config("Auto", 11, 38)
  208. init_config("Awp", 9)
  209. init_config("Scout", 40)
  210. init_config("Desert Eagle", 1)
  211. init_config("Revolver", 64)
  212. init_config("Pistol", 2, 3, 4, 30, 32, 36, 61, 63)
  213. init_config("Rifle", 7, 8, 10, 13, 16, 39, 60)
  214. -- init_config("Submachine gun", 17, 19, 23, 24, 26, 33, 34)
  215. -- init_config("Machine gun", 14, 28)
  216. -- init_config("Shotgun", 25, 27, 29, 35)
  217.  
  218. assert(config_idx_to_name[IDX_GLOBAL] == "Global")
  219.  
  220. enable_ref = ui.new_checkbox("RAGE", "Other", "Adaptive config")
  221. config_ref = ui.new_combobox("RAGE", "Other", "\nAdaptive config", config_idx_to_name)
  222. label_ref = ui.new_label("RAGE", "Other", "Active weapon config: " .. ui.get(config_ref))
  223.  
  224. duplicate("RAGE", "Aimbot", "Target selection", ui.new_combobox, "Cycle", "Cycle (2x)", "Near crosshair", "Highest damage", "Lowest ping", "Best K/D ratio", "Best hit chance")
  225. duplicate("RAGE", "Aimbot", "Target hitbox", ui.new_multiselect, "Head", "Chest", "Stomach", "Arms", "Legs", "Feet")
  226. duplicate("RAGE", "Aimbot", "Avoid limbs if moving", ui.new_checkbox)
  227. duplicate("RAGE", "Aimbot", "Avoid head if jumping", ui.new_checkbox)
  228. duplicate("RAGE", "Aimbot", "Multi-point", ui.new_multiselect, "Head", "Chest", "Stomach", "Arms", "Legs", "Feet")
  229. duplicate("RAGE", "Aimbot", "Multi-point scale", ui.new_slider, 24, 100, 24, true, "%", 1, multipoint_override)
  230. duplicate("RAGE", "Aimbot", "Dynamic multi-point", ui.new_checkbox)
  231. duplicate("RAGE", "Aimbot", "Prefer safe point", ui.new_checkbox)
  232. duplicate("RAGE", "Aimbot", "Automatic fire", ui.new_checkbox)
  233. duplicate("RAGE", "Aimbot", "Automatic penetration", ui.new_checkbox)
  234. duplicate("RAGE", "Aimbot", "Silent aim", ui.new_checkbox)
  235. duplicate("RAGE", "Aimbot", "Minimum hit chance", ui.new_slider, 0, 100, 50, true, "%", 1, hitchance_override)
  236. duplicate("RAGE", "Aimbot", "Minimum damage", ui.new_slider, 0, 126, 0, true, "%", 1, mindamage_override)
  237. duplicate("RAGE", "Aimbot", "Automatic scope", ui.new_checkbox)
  238. duplicate("RAGE", "Aimbot", "Maximum FOV", ui.new_slider, 1, 180, 180, true, "°")
  239. duplicate("RAGE", "Aimbot", "Override minimum damage", ui.new_slider, 0, 126, 0, true, "%", 1)
  240. duplicate("RAGE", "Other", "Accuracy boost", ui.new_combobox, "Off", "Low", "Medium", "High", "Maximum")
  241. duplicate("RAGE", "Other", "Quick stop", ui.new_checkbox)
  242. duplicate("RAGE", "Other", "Quick stop options", ui.new_multiselect, "Early", "Slow motion", "Duck", "Move between shots", "Ignore molotov")
  243. duplicate("RAGE", "Other", "Prefer body aim", ui.new_checkbox)
  244. duplicate("RAGE", "Other", "Prefer body aim disablers", ui.new_multiselect, "Low inaccuracy", "Target shot fired", "Target resolved", "Safe point headshot", "Low damage")
  245. duplicate("RAGE", "Other", "Delay shot on peek", ui.new_checkbox)
  246.  
  247. ui.set_callback(config_ref, on_weapon_config_selected)
  248. ui.set_callback(enable_ref, on_adaptive_config_toggled)
  249.  
  250. temp_task()
  251. on_adaptive_config_toggled(enable_ref)
  252. end
  253.  
  254. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement