Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;
- ;; INIT ;;
- ;;;;;;;;;;
- #Include Init.ahk
- ;;;;;;;;;;;;;
- ;; GLOBALS ;;
- ;;;;;;;;;;;;;
- global burstMode := 1 ; 1 / 2 - Burst mode methods
- global burstCount := 5 ; Rounds per burst (AR baseline)
- global enableYY := 1 ; Enable YY functionality
- global showUI := 1 ; Enable the Firing Mode text
- ;System
- global burstShotsLeft := burstCount ;
- global fireLoopSleepTime := 90 ; Full auto subroutine duration
- global UITick := fireLoopSleepTime/2 ; Update UI interval
- global ROF := ; Firing Mode controller
- global ROFCurrent := 1
- global yyLock := 0 ; YY lock controller
- global fireLoop := 0 ; Firing Mode system lockout
- global CurrentSlot := 1
- global ROFSlot1 := 1
- global ROFSlot2 := 1
- ;;;;;;;;;;;;;;;;;;;;;;;
- ;; FIRING MODE ARRAY ;;
- ;;;;;;;;;;;;;;;;;;;;;;;
- firingModes := []
- firingModes.Push("Default")
- ;firingModes.Push("SemiAuto")
- ;firingModes.Push("Burst")
- firingModes.Push("FullAuto")
- firingModes.Push("Latch")
- ;firingModes.Push("AutoLatch")
- ;firingModes.Push("Hybrid")
- ;firingModes.Push("RXYY")
- ROF := firingModes[1]
- ;;;;;;;;;;;;;;;;;;;;;
- ;; RATE OF FIRE UI ;;
- ;;;;;;;;;;;;;;;;;;;;;
- ; Example: On-screen display (OSD) via transparent window:
- customBGColor = EEAA99 ; Can be any RGB color (it will be made transparent below).
- textColor0 = 00FF00
- textColor1 = FF8000
- Gui, Color, %customBGColor%
- Gui +LastFound +AlwaysOnTop -Caption +ToolWindow ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
- Gui, Font, s24 Arial Bold Underline ; Set a large font size (32-point).
- Gui, Add, Text, vROFText cFF8000, XXXXX YYYYY ; XX & YY serve to auto-size the window.
- WinSet, TransColor, %CustomBGColor% 255 ; Make all pixels of this color transparent and make the text itself translucent (150):
- if (showUI == 1)
- {
- Gui, Show, x1000 y550 NoActivate ; NoActivate avoids deactivating the currently active window.
- }
- rofSwitch()
- return
- ;;;;;;;;;;;;;;
- ;; BINDINGS ;;
- ;;;;;;;;;;;;;;
- ~*Esc:: ; Escape
- reload
- return
- #If WinActive("ahk_exe HaloInfinite.exe")
- LAlt & Tab:: ; Alt tab
- resetStates()
- if !(ROF = "Default")
- {
- resetROF()
- setROF(firingModes[ROFCurrent]) ;Reset firing mode to default
- }
- Send {Alt down}{tab} ;Send a proper alt tab
- reload
- return
- ;These keys stop full auto firing loop.
- ~*1:: ; Grapple
- ~*2:: ; Dash
- ~*3:: ; Shield
- ~*4:: ; Sensor
- ~*j:: ; Chat
- ~*CapsLock:: ; Grapple
- ~*Shift:: ; Sprint
- resetStates()
- return
- ~*XButton2:: ;Melee
- send {blind}{XButton2 up}
- updateText("FFFF00", "MELEE 1")
- meleeYY()
- updateText("FF8000", "MELEE 2")
- meleeYY()
- updateText("FF0000", "MELEE LOOP")
- loopMelee()
- resetStates()
- rofSwitch()
- return
- meleeYY()
- {
- if !GetKeyState("XButton2", "P")
- {
- return
- }
- melee()
- sleep 85
- yy()
- if !GetKeyState("XButton2", "P")
- {
- return
- }
- sleep 225
- if !GetKeyState("XButton2", "P")
- {
- return
- }
- sleep 225
- if !GetKeyState("XButton2", "P")
- {
- return
- }
- sleep 225
- }
- loopMelee()
- {
- loop
- {
- if !GetKeyState("XButton2", "P")
- {
- break
- }
- melee()
- sleep 1
- }
- }
- melee()
- {
- send {blind}{/ down}
- sleep 1
- send {blind}{/ up}
- }
- yy()
- {
- send {blind}{u up}
- sleep 1
- send {blind}{u down}
- sleep 1
- send {blind}{u up}
- sleep 1
- send {blind}{u down}
- sleep 1
- send {blind}{u up}
- }
- ~*WheelUp::
- ~*g::
- resetStates()
- if (CurrentSlot == 1)
- {
- ROFSlot1 = %ROFCurrent%
- CurrentSlot := 2
- ROFCurrent = %ROFSlot2%
- setROF(firingModes[ROFCurrent])
- }
- else if (CurrentSlot == 2)
- {
- ROFSlot2 = %ROFCurrent%
- CurrentSlot := 1
- ROFCurrent = %ROFSlot1%
- setROF(firingModes[ROFCurrent])
- }
- rofSwitch()
- ;msgbox Slot %currentSlot%, current ROF %ROFCurrent% %ROF%, slot 1 %ROFSlot1%, slot 2 %ROFSlot2%,
- sleep 55
- if (A_PriorHotkey = "~*WheelUp" and A_TimeSincePriorHotkey < 275)
- {
- sleep 250
- }
- return
- ~*MButton:: ; Grenade
- if (ROF != "Latch")
- {
- resetStates() ;Ignore "Latch" to handle charged weapons
- }
- return
- ~*XButton1:: ; Reload
- if (GetKeyState("LButton", "P")) ;YY if simultaneously held with fire
- {
- fireRXYY()
- }
- return
- ;Firing mode - Next
- ~*.::
- ~*x::
- if (fireLoop = 0)
- {
- resetStates()
- if (ROFCurrent == firingModes.Length())
- {
- ROFCurrent := 1
- }
- else
- {
- ROFCurrent++
- }
- setROF(firingModes[ROFCurrent])
- rofSwitch()
- }
- return
- ;Firing mode - Previous
- ~*,::
- if (fireLoop = 0)
- {
- resetStates()
- if (ROFCurrent == 1)
- {
- ROFCurrent := firingModes.Length()
- }
- else
- {
- ROFCurrent--
- }
- setROF(firingModes[ROFCurrent])
- rofSwitch()
- }
- return
- ~*LButton:: ; Fire
- ;First check for an RXYY
- if (GetKeyState("XButton1", "P"))
- {
- fireRXYY()
- }
- ;Check if no longer holding after RXYY to bypass switch
- if !(GetKeyState("LButton", "P"))
- {
- return
- }
- switch ROF
- {
- case "Default":
- fireDefault()
- case "SemiAuto":
- fireSemiAuto()
- case "Burst":
- fireBurst()
- case "FullAuto":
- fireFullAuto()
- case "Hybrid":
- fireHybrid()
- case "Latch":
- fireLatch()
- case "AutoLatch":
- fireAutoLatch()
- case "RXYY":
- fireRXYY()
- default:
- msgBox ROF %ROF% is fucked on trigger pull
- }
- return
- ;;;;;;;;;;;;;;;;;
- ;; FIRNG MODES ;;
- ;;;;;;;;;;;;;;;;;
- ;Default - unchagned
- fireDefault(s:="Default")
- {
- updateText("FF8000", s)
- fireLoop = 1
- send {Blind}{k down}
- loop
- {
- if !GetKeyState("LButton", "P")
- {
- send {Blind}{k up}
- break
- }
- }
- fireLoop = 0
- resetStates()
- rofSwitch()
- }
- ;Semi-automatic - down and then up immediately
- fireSemiAuto()
- {
- updateText("FF8000", "Semi-Auto")
- fireLoop = 1
- send {Blind}{k down}
- sleep ((fireLoopSleepTime / 6) * 1)
- loop, 3
- {
- send {Blind}{k up}
- sleep ((fireLoopSleepTime / 6) * 1)
- }
- fireLoop = 0
- resetStates()
- rofSwitch()
- }
- ;Burst fire (AR baseline)
- fireBurst()
- {
- updateText("FF8000", "Burst " burstShotsLeft)
- fireLoop = 1
- switch burstMode
- {
- case 1:
- burstMethod1()
- case 2:
- burstMethod2()
- default:
- msgBox Invalid Burst Mode selected
- return
- }
- loop, 5
- {
- sleep 5
- }
- burstShotsLeft := burstCount
- fireLoop = 0
- resetStates()
- rofSwitch()
- }
- ;Full auto - loops the input
- fireFullAuto()
- {
- updateText("FF6000", "Full Auto")
- fireLoop = 1
- loop
- {
- if !GetKeyState("LButton", "P")
- {
- break
- }
- autoFireLoop("Full Auto")
- }
- fireLoop = 0
- resetStates()
- rofSwitch()
- }
- ;Latch - Pressing toggles key down/up
- fireLatch()
- {
- updateText("FF8000", "Latch . . .")
- fireLoop = 1
- send {Blind}{k down}
- KeyWait, LButton
- updateText("FFFF00", "Latch ON")
- fireFullLatched()
- resetStates()
- rofSwitch()
- }
- ;AutoLatch - Press 1 is default, up toggles full auto on, press 2 toggles off
- fireAutoLatch()
- {
- updateText("FF8000", "Auto Latch . . .")
- fireLoop = 1
- send {Blind}{k down}
- KeyWait, LButton
- updateText("FFFF00", "Auto Latch ON")
- send {Blind}{k up}
- fireFullAutoLatched("Auto Latch ON")
- resetStates()
- rofSwitch()
- }
- ;Hybrid - Default, double-press toggles AutoLatch
- fireHybrid()
- {
- updateText("FF8000", "Hybrid")
- fireDefault("Hybrid")
- if (A_PriorHotkey = "~*LButton" && A_TimeSincePriorHotkey < 250)
- {
- updateText("FFFF00", "Hybrid Auto")
- fireLoop = 1
- while GetKeyState("LButton", "P")
- {
- autoFireLoop("Hybrid Auto")
- }
- fireFullAutoLatched("Hybrid Auto")
- fireLoop = 0
- }
- resetStates()
- rofSwitch()
- }
- ;RXYY - Fast Fire (Mangler, Snipe, Shock)
- fireRXYY()
- {
- fireLoop = 1
- updateText("FF8000", "R X Y Y")
- RXYY()
- resetStates()
- rofSwitch()
- }
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; FIRING MODE SUB-ROUTINES ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;Method 1 - 3 individual shots using "Full Auto" logic
- burstMethod1()
- {
- burstShotsLeft := burstCount
- loop, %burstCount%
- {
- autoFireLoop("Burst " burstShotsLeft)
- burstShotsLeft := (burstShotsLeft - 1)
- updateText("FF8000", "Burst " burstShotsLeft)
- }
- }
- ;Method 2 - 3 individual shots using "Default" logic
- burstMethod2()
- {
- send {Blind}{k down}
- sleep (burstCount * 72)
- send {Blind}{k up}
- }
- ;Full Auto fire
- autoFireLoop(s:="")
- {
- send {Blind}{k down}
- updateText("FF0000", s)
- sleep ((fireLoopSleepTime / 6) * 1)
- send {Blind}{k up}
- updateText("FF8000", s)
- sleep ((fireLoopSleepTime / 6) * 5)
- }
- ;Latch loop
- fireFullLatched()
- {
- loop
- {
- if (fireLoop = 0)
- {
- breakLoop()
- break
- }
- if GetKeyState("LButton", "P")
- {
- fireLoop = 0
- }
- }
- }
- ;AutoLatched loop for AutoLatch and Hybrid
- fireFullAutoLatched(s:="")
- {
- loop
- {
- if (fireLoop = 0)
- {
- breakLoop()
- break
- }
- while !GetKeyState("LButton", "P")
- {
- autoFireLoop(s)
- }
- fireLoop = 0
- }
- }
- ;RXYY loop
- RXYY(s:="R X Y Y")
- {
- send {blind}{XButton1 up}{k up}{r up}
- loop
- {
- if (!(GetKeyState("XButton1", "P") && GetKeyState("LButton", "P")) && !(ROF = "RXYY" && GetKeyState("LButton", "P")))
- {
- break
- }
- updateText("FF8000", "R")
- send {blind}{k down}{k up}
- sleep 55
- updateText("FF8000", "R X")
- send {blind}{r down}{r up}
- yySwitch(s)
- updateText("FFFF00", "R X Y Y . . .")
- sleep 365
- }
- }
- ;Setup before breaking out of loop
- breakLoop()
- {
- fireLoop = 0
- releaseFire()
- Run "audio\sound_locked.ahk"
- }
- ;Release ALL fire inputs
- releaseFire()
- {
- send {Blind}{k up}
- send {Blind}{LButton up}
- }
- ;YY switch
- yySwitch(s:="")
- {
- if (enableYY = 1)
- {
- send {blind}{u up}
- sleep 1
- updateText("FF8000", "R X Y")
- send {blind}{u down}
- sleep 1
- send {blind}{u up}
- sleep 1
- updateText("FFFF00", "R X Y Y")
- send {blind}{u down}
- sleep 1
- send {blind}{u up}
- }
- }
- ;;;;;;;;;;;
- ;; SETUP ;;
- ;;;;;;;;;;;
- ; Reset states back to default
- resetStates()
- {
- yyLock = 0 ;Unlock YY
- fireLoop = 0 ;Reset loop (breaks out of states)
- releaseFire() ;Release the fire inputs}
- }
- ; Update ROF text
- rofSwitch()
- {
- switch ROF
- {
- case "Default":
- updateText("00FF00", "Default")
- case "SemiAuto":
- updateText("00FF00", "Semi-Auto")
- case "Burst":
- updateText("00FF00", "Burst " burstCount)
- case "FullAuto":
- updateText("00FF00", "Full Auto")
- case "Hybrid":
- updateText("00FF00", "Hybrid")
- case "Latch":
- updateText("00FF00", "Latch")
- case "AutoLatch":
- updateText("00FF00", "Auto Latch")
- case "RXYY":
- updateText("00FF00", "R X Y Y")
- default:
- updateText("00FF00", "Bro.")
- }
- }
- ; can we simplify the Firing Mode changes with appropriate audio based on the name?
- setROF(newROF)
- {
- ROF := newROF
- s1 := "audio\sound_"
- s2 := newROF
- s3 := ".AHK"
- target := s1 . s2 . s3
- run %target% ;Yes we can.
- return
- }
- updateText(rofColor="FFFFFF", string:="...")
- {
- GuiControl, +c%rofColor%, ROFText
- GuiControl,, ROFText, %string%
- }
- resetROF()
- {
- ROFCurrent := 1
- }
Add Comment
Please, Sign In to add comment