Skip to content

Instantly share code, notes, and snippets.

@sclark39
Last active June 23, 2018 15:45
Show Gist options
  • Save sclark39/6ae9f40ec6db8dfa425eeaaf9b4dee54 to your computer and use it in GitHub Desktop.
Save sclark39/6ae9f40ec6db8dfa425eeaaf9b4dee54 to your computer and use it in GitHub Desktop.
123 lines to becoming a Fortnite god - Custom lastinv bind, hold to toggle crouch, and confirm build on mouse up
HotKey, IfWinActive, Fortnite
; Fortnite Binds
Fortnite.RegisterKey( "1", "MeleeSlotKey" )
Fortnite.RegisterKey( "2", "WeaponSlotKey" )
Fortnite.RegisterKey( "3", "WeaponSlotKey" )
Fortnite.RegisterKey( "4", "WeaponSlotKey" )
Fortnite.RegisterKey( "z", "WeaponSlotKey" )
Fortnite.RegisterKey( "x", "WeaponSlotKey" )
Fortnite.RegisterKey( "q", "BuildKey" )
Fortnite.RegisterKey( "f", "BuildKey" )
Fortnite.RegisterKey( "MButton", "BuildKey" )
Fortnite.RegisterKey( "5", "BuildKey" )
Fortnite.RegisterKey( "F4", "BuildKey" )
Fortnite.RegisterKey( "c", "EditKey" )
Fortnite.RegisterKey( "b", "InventoryKey" )
Fortnite.RegisterKey( "Esc", "EscKey" )
Fortnite.RegisterKey( "LCtrl", "Crouch" )
Fortnite.RegisterKey( "LButton", "PrimaryFire" )
Fortnite.RegisterKey( "RButton", "SecondaryFire" )
Fortnite.RegisterKey( "XButton1", "SwapBuild" )
; Activate Special Custom Binds
HotKey, % "*" Fortnite.Keys.SwapBuild, LastInv
HotKey, % "*$" Fortnite.Keys.Crouch, HoldToToggleCrouch
HotKey, % "~*" Fortnite.Keys.PrimaryFire " Up", ConfirmEdit
HotKey, % "~*" Fortnite.Keys.SecondaryFire " Up", ConfirmEdit
; Alternates between your two most recent weapon slots, and
; switches back to a weapon if you're on melee or build mode.
LastInv() {
LastInv:
{
if ( Fortnite.Building + Fortnite.UsingMelee > 0 )
{
SendInput % Fortnite.ActiveWeapon
Fortnite.SwitchedToWeapon( Fortnite.ActiveWeapon )
}
else
{
SendInput % Fortnite.PreviousWeapon
Fortnite.SwitchedToWeapon( Fortnite.PreviousWeapon )
}
return
}}
; Quick press will toggle crouch, long press will toggle again
; when you let go
HoldToToggleCrouch() {
HoldToToggleCrouch:
{
ckey := SanitizeKey( A_ThisHotkey )
SendInput {%ckey%}
KeyWait, % ckey
;if ( A_TimeSinceThisHotkey > 150 )
SendInput {%ckey%}
return
}}
; Confirm editing buildings when letting go of primary or
; secondary fire
ConfirmEdit() {
ConfirmEdit:
{
_editKey:= Fortnite.Keys.EditKey
if ( Fortnite.Editing = 1 )
{
Critical
Sleep, 150
SendInput {%_editKey% down}
Fortnite.EditingOff()
Sleep, 50
SendInput {%_editKey% up}
if ( Fortnite.Building = 1 )
{
Sleep, 50
SendInput % Fortnite.ActiveWeapon
Fortnite.SwitchedToWeapon( Fortnite.ActiveWeapon )
}
}
return
}}
; Tracks the state of the game
class Fortnite
{
static Keys:={}
static ActiveWeapon:=2
static PreviousWeapon:=3
static Building:=0
static InventoryOpen:=0
static Editing:=0
static UsingMelee:=0
RegisterKey( Name, Label ) {
{
fullName := "~*" Name
Fortnite.Keys[Label] := Name
if ( IsLabel( Label ) )
Hotkey, % fullName, % Label
}}
SwitchedToWeapon(key) {
WeaponSlotKey:
{
if ( key = "" )
{
Fortnite.SwitchedToWeapon(SanitizeKey( A_ThisHotkey ))
return
}
if ( Fortnite.ActiveWeapon != key )
{
Fortnite.PreviousWeapon := Fortnite.ActiveWeapon
Fortnite.ActiveWeapon := key
}
Fortnite.Building := Fortnite.UsingMelee := Fortnite.Editing := 0
return
}}
SwitchedToMelee() {
MeleeSlotKey:
{
Fortnite.UsingMelee:=1
return
}}
SwitchedToBuild() {
BuildKey:
{
Fortnite.Building := 1
Fortnite.Editing := 0
return
}}
EditingOn() {
EditKey:
{
Fortnite.Editing := 1
return
}}
EditingOff() {
{
Fortnite.Editing := 0
return
}}
ToggledInventory() {
InventoryKey:
{
Fortnite.InventoryOpen := !Fortnite.InventoryOpen
return
}}
ClosedInventory() {
EscKey:
{
Fortnite.InventoryOpen := 0
return
}}
}
SanitizeKey(key)
{
key := RegExReplace(key,"[^\w]","")
;if ( StrLen(key) > 1 )
; key := "{" key "}"
return key
}
@sclark39
Copy link
Author

This is no longer 123 lines. 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment