FPS通用压枪V2

;-------------------------------------------------------------------------------
; AHK_V2
; author : kzf
; describe : FPS 游戏通用压枪程序
; usage : 按住左键,鼠标会模拟下拉动作
; version , time, content
; v0.1.0 , 2021年7月1日 22:56:35, init
;===============================================================================
#include <_JXON>
#include <my_lib>
;全局变量
;json配置
global g_config := Map() 
global g_config_path := A_ScriptDir . "/config/config.json"
loadconfig(&g_config, g_config_path)
if(!g_config.Has("version"))
{
    MsgBox("load config error, exit!")
    ExitApp()
}
else
{
    MsgBox(g_config["version"])
}
global MyGui := Gui(, "自动压枪")
global gui_data_change := Gui(, "压枪幅度调整")
global g_user := gun_user()
global sys_delay := 20
global g_all_time := 5000
global all_index := 10
;注册热键
Hotkey("f7",on_event_guihide)
Hotkey("f8",on_event_adjust_guihide)
hotkey("~1", on_event_choose_gun)
hotkey("~2", on_event_choose_gun)
hotkey("~$*LButton", on_vent_shotting)
f6::reload
f5::ExitApp()
main()
main()
{
    create_data_adjust_gui()
    create_gui()
}
create_gui()
{
    MyGui.Opt("+AlwaysOnTop  +SysMenu -MinimizeBox +Owner")  ; +Owner 避免显示任务栏按钮.
    MyGui.Add("Text","Section y+10 x+30", "枪:").SetFont("cee2641")
    MyGui.Add("Text", "x+130", "镜子:").SetFont("cee2641")
    MyGui.Add("Text", "x+115", "枪口:").SetFont("cee2641")
    MyGui.Add("Text", "x+115", "握把:").SetFont("cee2641")
    MyGui.Add("Text", "x+115", "枪托:").SetFont("cee2641")
    MyGui.Add("Text","Section xs-40", "gun1:").SetFont("cee2641")
    MyGui.Add("DropDownList", "vgun1_chuck x+10", g_config["parts"]["gun"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun1_mirror x+10", g_config["parts"]["mirror"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun1_muzzle x+10", g_config["parts"]["muzzle"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun1_grip x+10", g_config["parts"]["grip"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun1_butt_of_gun x+10", g_config["parts"]["butt"]).OnEvent("change", gui_update_data)
    MyGui.Add("Text", "Section xs", "gun2:").SetFont("cee2641")
    MyGui.Add("DropDownList", "vgun2_chuck x+10", g_config["parts"]["gun"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun2_mirror x+10", g_config["parts"]["mirror"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun2_muzzle x+10", g_config["parts"]["muzzle"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun2_grip x+10", g_config["parts"]["grip"]).OnEvent("change", gui_update_data)
    MyGui.Add("DropDownList", "vgun2_butt_of_gun x+10", g_config["parts"]["butt"]).OnEvent("change", gui_update_data)
    MyGui.Add("text","Section xs h20 w450 ","F5:退出  F6:重启  F7:显示隐藏   F8:调整数据  1/2:切枪").SetFont("s12 cff009d")
    MyGui.Add("Button", "x+150   vdata_change", "调整数据").OnEvent("Click", on_event_gui_data_change )
    MyGui.Add("Button", "x+10  vdata_save", "保存数据").OnEvent("Click", on_event_gui_save_data)
    MyGui.Add("StatusBar","vstatusbar")
    MyGui.BackColor := "black"
    MyGui.Show()  ; NoActivate 让当前活动窗口继续保持活动状态.
    MyGui["gun1_chuck"].Text := g_config["current_use"]["gun1"]["gun_name"]
    MyGui["gun2_chuck"].Text := g_config["current_use"]["gun2"]["gun_name"]
    gui_update_data()
    update_win_title()
}
create_data_adjust_gui()
{
    gui_data_change.Opt("+AlwaysOnTop  +SysMenu -MinimizeBox +Owner")  ; +Owner 避免显示任务栏按钮.
    loop(10)
    {
        opt := "x+10 w30 h15 vadjust_edit" . A_Index
        gui_data_change.Add("text",opt)
    }
    gui_data_change.add("Text","x0","")
    loop(10)
    {
        opt := "x+20 h200 -tooltiptop Range0-80 Vertical +AltSubmit +invert  vslider" . A_Index . " Buddy1adjust_edit" . A_Index 
        gui_data_change.Add("Slider", opt, 50).OnEvent("change", on_event_slider_adjust)
    }
    gui_data_change.Show()
    gui_data_change.Hide()
}
gui_update_data(*)
{
    MyGui.Submit(false)
    gun1_info := MyGui["gun1_chuck"].Text
    gun1_info .= (MyGui["gun1_mirror"].Text != "") ? ("_" . MyGui["gun1_mirror"].Text) : ""
    gun1_info .= (MyGui["gun1_muzzle"].Text != "") ? ("_" . MyGui["gun1_muzzle"].Text) : ""
    gun1_info .= (MyGui["gun1_grip"].Text != "") ? ("_" . MyGui["gun1_grip"].Text) : ""
    gun1_info .= (MyGui["gun1_butt_of_gun"].Text != "") ? ("_" . MyGui["gun1_butt_of_gun"].Text) : ""
    gun2_info := MyGui["gun2_chuck"].Text
    gun2_info .= (MyGui["gun2_mirror"].Text != "") ? ("_" . MyGui["gun2_mirror"].Text) : ""
    gun2_info .= (MyGui["gun2_muzzle"].Text != "") ? ("_" . MyGui["gun2_muzzle"].Text) : ""
    gun2_info .= (MyGui["gun2_grip"].Text != "") ? ("_" . MyGui["gun2_grip"].Text) : ""
    gun2_info .= (MyGui["gun2_butt_of_gun"].Text != "") ? ("_" . MyGui["gun2_butt_of_gun"].Text) : ""
    MyGui["statusbar"].SetText("枪1: " . gun1_info . "    |    枪2: " . gun2_info)
    if(!g_config["gun"].has(gun1_info))
    {
        g_config["gun"][gun1_info] := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    }
    if(!g_config["gun"].has(gun2_info))
    {
        g_config["gun"][gun2_info] := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    }
    g_user.config_presure2gun(gun1_info, gun2_info)
    gui_data_adjustment()
    update_win_title()
}
on_vent_shotting(this_key)
{
    g_user.shotting()
}
on_event_choose_gun(thishotkey)
{
    if(thishotkey == "~1")
    {
        my_tooltip(g_user.gun1.gun_name, 1000)
        gun_user.current_gun_index := "gun1"
    }
    else
    {
        my_tooltip(g_user.gun2.gun_name, 1000)
        gun_user.current_gun_index := "gun2"
    }
    gui_data_adjustment()
    update_win_title()
}
update_win_title()
{
    if(gun_user.current_gun_index == "gun1")
    {
        win_title := "枪1:" . g_user.gun1.gun_name
    }
    else
    {
        win_title := "枪2:" . g_user.gun2.gun_name
    }
    mygui.Title := win_title
    gui_data_change.Title := win_title
}
on_event_gui_data_change(*)
{
    gui_data_change.Show("w550 h250")
    gui_data_adjustment()
}
on_event_gui_save_data(GuiCtrlObj, info)
{
    g_user.save_gun_data2config()
    MsgBox("save success")
}
on_event_guihide(ThisHotkey)
{
    if(WinExist("ahk_id" . MyGui.Hwnd))
    {
        MyGui.Hide()
    }
    else
    {
        MyGui.Restore()
    }
}
on_event_adjust_guihide(*)
{    
    if(WinExist("ahk_id" . gui_data_change.Hwnd))
    {
        gui_data_change.Hide()
    }
    else
    {
        gui_data_change.Restore()
    }
}
on_event_slider_adjust(*)
{
    loop(10)
    {
        opt := "slider" . A_Index
        text_opt := "adjust_edit" . A_Index
        if(gun_user.current_gun_index == "gun1")
        {
            g_config["gun"][g_user.gun1.gun_name][A_Index] := gui_data_change[opt].Value
        }
        else
        {
            g_config["gun"][g_user.gun2.gun_name][A_Index] := gui_data_change[opt].Value
        }
        gui_data_change[text_opt].Value := gui_data_change[opt].Value
    }
}
;gun数据传递到ui界面
gui_data_adjustment()
{
    loop(10)
    {
        opt := "slider" . A_Index
        text_opt := "adjust_edit" . A_Index
        if(gun_user.current_gun_index == "gun1")
        {
            gui_data_change[opt].Value := g_config["gun"][g_user.gun1.gun_name][A_Index]
        }
        else
        {
            gui_data_change[opt].Value := g_config["gun"][g_user.gun2.gun_name][A_Index]
        }
        gui_data_change[text_opt].Value := gui_data_change[opt].Value
    }
}
class gun_user
{
    static current_gun_index := "gun1"
    gun1 := gun()
    gun2 := gun()
    __New() 
    {
        this.gun1.gun_name := g_config["current_use"]["gun1"]["gun_name"]
        this.gun2.gun_name := g_config["current_use"]["gun2"]["gun_name"]
    }
    __Delete() 
    {
        
    }
    config_presure2gun(gun1_name, gun2_name)
    {
        this.gun1.gun_name := gun1_name
        this.gun2.gun_name := gun2_name
    }
    shotting()
    {
        if(gun_user.current_gun_index == "gun1")
        {
            this.gun1.shotting()
        }
        else
        {
            this.gun2.shotting()
        }
    }
    ;保存枪数据到配置文件
    save_gun_data2config()
    {
        saveconfig(g_config, g_config_path)
    }
}
class gun
{
    gun_name := g_config["current_use"]["gun1"]["gun_name"]
    set_gun_name(gun_name)
    {
        this.gun_name := gun_name
    }
    shotting()
    {
        if((isMouseShown() == true) && (GetKeyState("alt","P")!=1))
        {
            Return
        }
        while (GetKeyState("LButton","P"))
        {
            ;时间
            time := (A_Index * sys_delay)
            ;区间左坐标
            x1 := Ceil(time / (g_all_time / all_index))
            if(x1 > all_index - 1)
            {
                break
            }
            ;y = kx + b
            ;k = (y2 - y1)/(x2-x1)
            ;b = y1 - kx1
            k := (g_config["gun"][this.gun_name][x1 + 1] - g_config["gun"][this.gun_name][x1]) / (g_all_time/all_index)
            b := g_config["gun"][this.gun_name][x1] - k * (x1 -1) * (g_all_time / all_index)
            y := k * time + b
            mouseXY(0, y)
            Sleep(sys_delay)
        }
    }
}

 

给TA捐赠
共{{data.count}}人
人已捐赠
应用

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

2021-7-12 14:36:30

其他

一键恢复QQ浏览器的收藏夹并启动QQ浏览器.bat

2021-7-13 12:19:05

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

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

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