FPS通用压枪V2

  1. ;-------------------------------------------------------------------------------
  2. ; AHK_V2
  3. ; author kzf
  4. ; describe : FPS 游戏通用压枪程序
  5. ; usage 按住左键,鼠标会模拟下拉动作
  6. ; version , time, content
  7. ; v0.1.0 , 202171 22:56:35, init
  8. ;===============================================================================
  9. #include <_JXON>
  10. #include <my_lib>
  11. ;全局变量
  12. ;json配置
  13. global g_config := Map()
  14. global g_config_path := A_ScriptDir . "/config/config.json"
  15. loadconfig(&g_config, g_config_path)
  16. if(!g_config.Has("version"))
  17. {
  18. MsgBox("load config error, exit!")
  19. ExitApp()
  20. }
  21. else
  22. {
  23. MsgBox(g_config["version"])
  24. }
  25. global MyGui := Gui(, "自动压枪")
  26. global gui_data_change := Gui(, "压枪幅度调整")
  27. global g_user := gun_user()
  28. global sys_delay := 20
  29. global g_all_time := 5000
  30. global all_index := 10
  31. ;注册热键
  32. Hotkey("f7",on_event_guihide)
  33. Hotkey("f8",on_event_adjust_guihide)
  34. hotkey("~1", on_event_choose_gun)
  35. hotkey("~2", on_event_choose_gun)
  36. hotkey("~$*LButton", on_vent_shotting)
  37. f6::reload
  38. f5::ExitApp()
  39. main()
  40. main()
  41. {
  42. create_data_adjust_gui()
  43. create_gui()
  44. }
  45. create_gui()
  46. {
  47. MyGui.Opt("+AlwaysOnTop +SysMenu -MinimizeBox +Owner") ; +Owner 避免显示任务栏按钮.
  48. MyGui.Add("Text","Section y+10 x+30", "枪:").SetFont("cee2641")
  49. MyGui.Add("Text", "x+130", "镜子:").SetFont("cee2641")
  50. MyGui.Add("Text", "x+115", "枪口:").SetFont("cee2641")
  51. MyGui.Add("Text", "x+115", "握把:").SetFont("cee2641")
  52. MyGui.Add("Text", "x+115", "枪托:").SetFont("cee2641")
  53. MyGui.Add("Text","Section xs-40", "gun1:").SetFont("cee2641")
  54. MyGui.Add("DropDownList", "vgun1_chuck x+10", g_config["parts"]["gun"]).OnEvent("change", gui_update_data)
  55. MyGui.Add("DropDownList", "vgun1_mirror x+10", g_config["parts"]["mirror"]).OnEvent("change", gui_update_data)
  56. MyGui.Add("DropDownList", "vgun1_muzzle x+10", g_config["parts"]["muzzle"]).OnEvent("change", gui_update_data)
  57. MyGui.Add("DropDownList", "vgun1_grip x+10", g_config["parts"]["grip"]).OnEvent("change", gui_update_data)
  58. MyGui.Add("DropDownList", "vgun1_butt_of_gun x+10", g_config["parts"]["butt"]).OnEvent("change", gui_update_data)
  59. MyGui.Add("Text", "Section xs", "gun2:").SetFont("cee2641")
  60. MyGui.Add("DropDownList", "vgun2_chuck x+10", g_config["parts"]["gun"]).OnEvent("change", gui_update_data)
  61. MyGui.Add("DropDownList", "vgun2_mirror x+10", g_config["parts"]["mirror"]).OnEvent("change", gui_update_data)
  62. MyGui.Add("DropDownList", "vgun2_muzzle x+10", g_config["parts"]["muzzle"]).OnEvent("change", gui_update_data)
  63. MyGui.Add("DropDownList", "vgun2_grip x+10", g_config["parts"]["grip"]).OnEvent("change", gui_update_data)
  64. MyGui.Add("DropDownList", "vgun2_butt_of_gun x+10", g_config["parts"]["butt"]).OnEvent("change", gui_update_data)
  65. MyGui.Add("text","Section xs h20 w450 ","F5:退出 F6:重启 F7:显示隐藏 F8:调整数据 1/2:切枪").SetFont("s12 cff009d")
  66. MyGui.Add("Button", "x+150 vdata_change", "调整数据").OnEvent("Click", on_event_gui_data_change )
  67. MyGui.Add("Button", "x+10 vdata_save", "保存数据").OnEvent("Click", on_event_gui_save_data)
  68. MyGui.Add("StatusBar","vstatusbar")
  69. MyGui.BackColor := "black"
  70. MyGui.Show() ; NoActivate 让当前活动窗口继续保持活动状态.
  71. MyGui["gun1_chuck"].Text := g_config["current_use"]["gun1"]["gun_name"]
  72. MyGui["gun2_chuck"].Text := g_config["current_use"]["gun2"]["gun_name"]
  73. gui_update_data()
  74. update_win_title()
  75. }
  76. create_data_adjust_gui()
  77. {
  78. gui_data_change.Opt("+AlwaysOnTop +SysMenu -MinimizeBox +Owner") ; +Owner 避免显示任务栏按钮.
  79. loop(10)
  80. {
  81. opt := "x+10 w30 h15 vadjust_edit" . A_Index
  82. gui_data_change.Add("text",opt)
  83. }
  84. gui_data_change.add("Text","x0","")
  85. loop(10)
  86. {
  87. opt := "x+20 h200 -tooltiptop Range0-80 Vertical +AltSubmit +invert vslider" . A_Index . " Buddy1adjust_edit" . A_Index
  88. gui_data_change.Add("Slider", opt, 50).OnEvent("change", on_event_slider_adjust)
  89. }
  90. gui_data_change.Show()
  91. gui_data_change.Hide()
  92. }
  93. gui_update_data(*)
  94. {
  95. MyGui.Submit(false)
  96. gun1_info := MyGui["gun1_chuck"].Text
  97. gun1_info .= (MyGui["gun1_mirror"].Text != "") ? ("_" . MyGui["gun1_mirror"].Text) : ""
  98. gun1_info .= (MyGui["gun1_muzzle"].Text != "") ? ("_" . MyGui["gun1_muzzle"].Text) : ""
  99. gun1_info .= (MyGui["gun1_grip"].Text != "") ? ("_" . MyGui["gun1_grip"].Text) : ""
  100. gun1_info .= (MyGui["gun1_butt_of_gun"].Text != "") ? ("_" . MyGui["gun1_butt_of_gun"].Text) : ""
  101. gun2_info := MyGui["gun2_chuck"].Text
  102. gun2_info .= (MyGui["gun2_mirror"].Text != "") ? ("_" . MyGui["gun2_mirror"].Text) : ""
  103. gun2_info .= (MyGui["gun2_muzzle"].Text != "") ? ("_" . MyGui["gun2_muzzle"].Text) : ""
  104. gun2_info .= (MyGui["gun2_grip"].Text != "") ? ("_" . MyGui["gun2_grip"].Text) : ""
  105. gun2_info .= (MyGui["gun2_butt_of_gun"].Text != "") ? ("_" . MyGui["gun2_butt_of_gun"].Text) : ""
  106. MyGui["statusbar"].SetText("枪1: " . gun1_info . " | 枪2: " . gun2_info)
  107. if(!g_config["gun"].has(gun1_info))
  108. {
  109. g_config["gun"][gun1_info] := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  110. }
  111. if(!g_config["gun"].has(gun2_info))
  112. {
  113. g_config["gun"][gun2_info] := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  114. }
  115. g_user.config_presure2gun(gun1_info, gun2_info)
  116. gui_data_adjustment()
  117. update_win_title()
  118. }
  119. on_vent_shotting(this_key)
  120. {
  121. g_user.shotting()
  122. }
  123. on_event_choose_gun(thishotkey)
  124. {
  125. if(thishotkey == "~1")
  126. {
  127. my_tooltip(g_user.gun1.gun_name, 1000)
  128. gun_user.current_gun_index := "gun1"
  129. }
  130. else
  131. {
  132. my_tooltip(g_user.gun2.gun_name, 1000)
  133. gun_user.current_gun_index := "gun2"
  134. }
  135. gui_data_adjustment()
  136. update_win_title()
  137. }
  138. update_win_title()
  139. {
  140. if(gun_user.current_gun_index == "gun1")
  141. {
  142. win_title := "枪1:" . g_user.gun1.gun_name
  143. }
  144. else
  145. {
  146. win_title := "枪2:" . g_user.gun2.gun_name
  147. }
  148. mygui.Title := win_title
  149. gui_data_change.Title := win_title
  150. }
  151. on_event_gui_data_change(*)
  152. {
  153. gui_data_change.Show("w550 h250")
  154. gui_data_adjustment()
  155. }
  156. on_event_gui_save_data(GuiCtrlObj, info)
  157. {
  158. g_user.save_gun_data2config()
  159. MsgBox("save success")
  160. }
  161. on_event_guihide(ThisHotkey)
  162. {
  163. if(WinExist("ahk_id" . MyGui.Hwnd))
  164. {
  165. MyGui.Hide()
  166. }
  167. else
  168. {
  169. MyGui.Restore()
  170. }
  171. }
  172. on_event_adjust_guihide(*)
  173. {
  174. if(WinExist("ahk_id" . gui_data_change.Hwnd))
  175. {
  176. gui_data_change.Hide()
  177. }
  178. else
  179. {
  180. gui_data_change.Restore()
  181. }
  182. }
  183. on_event_slider_adjust(*)
  184. {
  185. loop(10)
  186. {
  187. opt := "slider" . A_Index
  188. text_opt := "adjust_edit" . A_Index
  189. if(gun_user.current_gun_index == "gun1")
  190. {
  191. g_config["gun"][g_user.gun1.gun_name][A_Index] := gui_data_change[opt].Value
  192. }
  193. else
  194. {
  195. g_config["gun"][g_user.gun2.gun_name][A_Index] := gui_data_change[opt].Value
  196. }
  197. gui_data_change[text_opt].Value := gui_data_change[opt].Value
  198. }
  199. }
  200. ;gun数据传递到ui界面
  201. gui_data_adjustment()
  202. {
  203. loop(10)
  204. {
  205. opt := "slider" . A_Index
  206. text_opt := "adjust_edit" . A_Index
  207. if(gun_user.current_gun_index == "gun1")
  208. {
  209. gui_data_change[opt].Value := g_config["gun"][g_user.gun1.gun_name][A_Index]
  210. }
  211. else
  212. {
  213. gui_data_change[opt].Value := g_config["gun"][g_user.gun2.gun_name][A_Index]
  214. }
  215. gui_data_change[text_opt].Value := gui_data_change[opt].Value
  216. }
  217. }
  218. class gun_user
  219. {
  220. static current_gun_index := "gun1"
  221. gun1 := gun()
  222. gun2 := gun()
  223. __New()
  224. {
  225. this.gun1.gun_name := g_config["current_use"]["gun1"]["gun_name"]
  226. this.gun2.gun_name := g_config["current_use"]["gun2"]["gun_name"]
  227. }
  228. __Delete()
  229. {
  230. }
  231. config_presure2gun(gun1_name, gun2_name)
  232. {
  233. this.gun1.gun_name := gun1_name
  234. this.gun2.gun_name := gun2_name
  235. }
  236. shotting()
  237. {
  238. if(gun_user.current_gun_index == "gun1")
  239. {
  240. this.gun1.shotting()
  241. }
  242. else
  243. {
  244. this.gun2.shotting()
  245. }
  246. }
  247. ;保存枪数据到配置文件
  248. save_gun_data2config()
  249. {
  250. saveconfig(g_config, g_config_path)
  251. }
  252. }
  253. class gun
  254. {
  255. gun_name := g_config["current_use"]["gun1"]["gun_name"]
  256. set_gun_name(gun_name)
  257. {
  258. this.gun_name := gun_name
  259. }
  260. shotting()
  261. {
  262. if((isMouseShown() == true) && (GetKeyState("alt","P")!=1))
  263. {
  264. Return
  265. }
  266. while (GetKeyState("LButton","P"))
  267. {
  268. ;时间
  269. time := (A_Index * sys_delay)
  270. ;区间左坐标
  271. x1 := Ceil(time / (g_all_time / all_index))
  272. if(x1 > all_index - 1)
  273. {
  274. break
  275. }
  276. ;y = kx + b
  277. ;k = (y2 - y1)/(x2-x1)
  278. ;b = y1 - kx1
  279. k := (g_config["gun"][this.gun_name][x1 + 1] - g_config["gun"][this.gun_name][x1]) / (g_all_time/all_index)
  280. b := g_config["gun"][this.gun_name][x1] - k * (x1 -1) * (g_all_time / all_index)
  281. y := k * time + b
  282. mouseXY(0, y)
  283. Sleep(sys_delay)
  284. }
  285. }
  286. }

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
应用

游戏简易后台挂机脚本,带开始暂停控制键

2021-7-12 14:36:30

其他应用教程

AHK语法生成器

2021-7-19 20:22:46

18 条回复 A文章作者 M管理员
欢迎您,新朋友,感谢参与互动!
  1. Emokeshi

    老大,这个彩六能用吗,直接把这个代码改成ahk文件就可以了是吧?

    • ahker

      改改配置文件就能用

  2. popu29

    6666

  3. ??13111

    怎么好像编译不了

  4. 科少

    c编译?

  5. 冥器

    这10个数据分别代表什么呀?

    • ahker

      40发子弹分成10个阶段,每个阶段的 压枪调节幅度

  6. xcgrehxc

    试试,学习下

  7. ?15526

    这个是怎么用的啊

  8. user15806

    看看大佬

  9. user15806

    这个是怎么用的啊

  10. JackyChan

    感谢大佬

  11. user16266

    木有积分看不到隐藏T.T

  12. MEQH

    作为非计算机专业的萌新来说,抄作业都抄不明白啊

个人中心
购物车
优惠劵
私信列表
搜索