《英雄聯盟》:使用AutoHotkey建立滑鼠自動對準敵方英雄的指令碼教學
你展示如何建立一個簡單的AutoHotkey指令碼,可以自動將滑鼠游標對準最近的敵方英雄。我在1.1.36.02版本的AHK中製作了這個指令碼。你可以在這個連結中下載這個版本:https://sourceforge.net/projects/aut...es/v1.1.36.02/
在下載和安裝AHK後,你需要在你的AHK指令碼中包含類(class) memory。下載連結在這裡:https://github.com/Kalamity/classMemory
下載後,將classMemory.ahk和你的script.ahk放在同一個資料夾中,然後進行如下包含操作:
``````
現在我們已經準備好了!
ClassMemory對我們非常重要,因為我們要從遊戲記憶體中讀取值。首先,我們要建立一個記憶體對象:
```- LOLprocess := new _ClassMemory("ahk_exe League of Legends.exe", "", hProcessCopy)
複製代碼 ```
現在讓我們定義一些對我們重要的偏移(offsets):
```- oViewProjMatrix := 0x3133818
- oHeroList := 0x186E1F4
- oLocalPlayer := 0x310DEF0
- oHudInstance := 0x186E15C
複製代碼 ```
我還可以向你展示一些示例,演示在遊戲已經執行階段如何使用ClassMemory從記憶體中讀取值:
```
- local_player_summoner_name := lolprocess.readString(lolprocess.BaseAddress + oLocalPlayer, 30, "utf-8", 0x54)
- local_player_champion_name := lolprocess.readString(lolprocess.BaseAddress + oLocalPlayer, 20, "utf-8", 0x2B04,0x0)
- summoner_name_from_hero_list := lolprocess.readString(lolprocess.BaseAddress + oHeroList, 30, "utf-8", 0x4,0x0, 0x54)
- champion_name_from_hero_list := lolprocess.readString(lolprocess.BaseAddress + oHeroList, 20, "utf-8", 0x4,0x0, 0x2B04,0x0)
- obj_pos_x_from_hero_list := lolprocess.read(lolprocess.BaseAddress + oHeroList, "UFloat", 0x4,0x0,0x1DC)
- obj_pos_y_from_hero_list := lolprocess.read(lolprocess.BaseAddress + oHeroList, "UFloat", 0x4,0x0,0x1E0)
- obj_pos_z_from_hero_list := lolprocess.read(lolprocess.BaseAddress + oHeroList, "UFloat", 0x4,0x0,0x1E4)
- view_matrix_pos_1 := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x0, "UFloat")
- proj_matrix_pos_1 := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x40, "UFloat")
複製代碼 ```
現在讓我們定義一些重要的Vector類:
```- Class Vector2
- {
- __New(x,y)
- {
- this.x := x
- this.y := y
- }
- }
-
- Class Vector3
- {
- __New(x,y,z)
- {
- this.x := x
- this.y := y
- this.z := z
- }
- }
-
- Class Vector4
- {
- __New(x,y,z,w)
- {
- this.x := x
- this.y := y
- this.z := z
- this.w := w
- }
- }
複製代碼 ```
要建立Vector對象,只需使用以下示例:
```- vector3_obj := new Vector3(1,2,8)
- msgbox % vector3_obj.z
複製代碼 ```
現在讓我們定義WorldToScreen變數:
```- ;將你自己的遊戲窗口解析度填入這裡,你可以在遊戲設定中找到它。
- resolution_width := 1920
- resolution_height := 1080
- viewProjMatrix := []
- viewMatrix := []
- projMatrix := []
複製代碼 ```
並建立WorldToScreen函數:
```
- loadViewMatrixFromMemory()
- {
- global oViewProjMatrix
- global viewMatrix
- global lolprocess
- viewMatrix[0] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x0, "UFloat")
- viewMatrix[1] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x4, "UFloat")
- viewMatrix[2] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x8, "UFloat")
- viewMatrix[3] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0xC, "UFloat")
- viewMatrix[4] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x10, "UFloat")
- viewMatrix[5] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x14, "UFloat")
- viewMatrix[6] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x18, "UFloat")
- viewMatrix[7] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x1C, "UFloat")
- viewMatrix[8] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x20, "UFloat")
- viewMatrix[9] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x24, "UFloat")
- viewMatrix[10] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x28, "UFloat")
- viewMatrix[11] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x2C, "UFloat")
- viewMatrix[12] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x30, "UFloat")
- viewMatrix[13] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x34, "UFloat")
- viewMatrix[14] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x38, "UFloat")
- viewMatrix[15] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x3C, "UFloat")
- }
-
- loadProjMatrixFromMemory()
- {
- global oViewProjMatrix
- global projMatrix
- global lolprocess
- projMatrix[0] := lolprocess.read((lolprocess.BaseAddress + oViewProjMatrix)+0x40, "UFloat")
- projMatrix[1] := lolprocess.read((lolprocess.BaseAddress + o
複製代碼
所有站內附件皆會附上安全掃描報告 請會員查看純淨度百分比後判斷使用
相關檔案須知: 取得檔案前,請先詳細閱讀文章內容 避免不必要錯誤與誤會發生。 也可多參考文章討論樓層內容 了解附件檔案相關討論資訊。
|