I have put this script together to allow people to use auto-attack (aka rapid fire) for some of the heroes attacks.
Since each heroe has its particularities, I have decided to put hotkeys F5 to F8 to tweak the behavior of auto-attacks for each heroe.
F5: Apprentice
[left mouse hold preceded by left mouse doubleclick -> auto-attack]
[t -> Toggle between charged and non charged auto-attacks]
[Right Alt followed by a number (1,2...9,0) -> adjust length of charged auto-attacks]
[left mouse hold -> single shot charged staff attack]
F6: Squire
[left mouse hold -> auto-attack]
F7: Huntress [nothing, she already has auto-attack]
F8: Monk
[left mouse hold -> auto-attack]
[right mouse hold -> auto-attack]
RShift: Suspend Script [toggle or key hold mechanism, see bSuspendToggle in CUSTOMIZE OTHER SETTINGS section]
So you only got to make sure to select the correct setup (F5 to F8 ) for the heroe that is going to go through the Combat Phases.
New Features
1) Script Suspend functionality, either a toggle state or a key hold mechanism, adjustable via variable bSuspendToggle in CUSTOMIZE OTHER SETTINGS section. This functionality has been added mainly to let users hold down the left mouse button in certain situations where rapid fire is not desired, like dropping mana or upgrading equipment.
MOST RECENT VERSION
Code:
; Title: Dungeon Defenders Rapid Fire
; AutoHotkey Version Tested: AutoHotkey Basic and AutoHotkey_L Unicode 64 bits
; Language: English
; Platform: WINDOWS
; Author: doppleganger
; Version 1.5 Minor Adjustments, Script Suspend functionality added.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetTitleMatchMode, 2
; ++++++++++++++++++++ CUSTOMIZE YOUR KEYBINDINGS ++++++++++++++++++++++
; For a list of the keys that can be used, see http://www.autohotkey.com/docs/KeyList.htm
keyUseWeapon:="LButton" ;Left mouse Button by default, change this for the keybinding you use In Game
keyAlternateWeapon:="RButton" ;Right mouse Button by default, change this for the keybinding you use In Game
keyApprentice:="F5" ;Activate auto-attack settings for Apprentice
keySquire:="F6" ;Activate auto-attack settings for Squire
keyHuntress:="F7" ;Activate auto-attack settings for Huntress
keyMonk:="F8" ;Activate auto-attack settings for Monk
keyToggleStaff:="t" ;Toggle between charged versus non charged staff attacks (Apprentice)
keySelectChargeDuration:="RAlt" ;User has 3 seconds to select charge duration by choosing from 1,2,...9,0 (Apprentice)
KeySuspend:="RShift" ;Suspend script hotkeys (script stops responding to keystrokes, excepted the suspend key)
; ++++++++++++++++++++ CUSTOMIZE MOUSE CLICK SPAM RATE +++++++++++++++++
mainMeleeDelay=50 ;Delay between melee attacks, in milliseconds
mainRangedDelay=20 ;Delay between main ranged attacks, , in milliseconds, 10 is around the lower you should put
alternateRangedDelay=75 ;Delay between alternate ranged attacks, in milliseconds, 50 is around the lower you should put
; +++++++++++++++++++++ CUSTOMIZE OTHER SETTINGS +++++++++++++++++++++++
mouseHoldDelay=0.2 ;Delay necessary for a mouse hold to be registered, in seconds
initialRapidfireDelay=200 ;Additional delay necessary before rapidfire kicks in, in milliseconds
bSuspendToggle:=false ;Make the Suspend key work as a toggle (true) or while key is held down (false)
; ++++++++++++++++++++ END OF CUSTOMIZE SECTION ++++++++++++++++++++++++
;Dynamically create the Hotkeys, based on the keybindings
HotKey, IfWinActive, Dungeon Defenders ;Make all Hotkeys work only if Dungeon Defenders is the active window
Hotkey, % "*$" keyUseWeapon, MainWeapon, Off ;Hotkey turned off at first, to force player to choose a setup (F5,F6...)
Hotkey, % "*$" keyAlternateWeapon, AlternateWeapon, Off ;Hotkey turned off at first, to force player to choose a setup (F5,F6...)
Hotkey, % keyApprentice, SetHeroeApprentice
Hotkey, % keySquire, SetHeroeSquire
Hotkey, % keyHuntress, SetHeroeHuntress
Hotkey, % keyMonk, SetHeroeMonk
Hotkey, % "*~" keyToggleStaff, ToggleStaffAttack
Hotkey, % "*" keySelectChargeDuration, SetChargeDuration
Hotkey, % "*" KeySuspend, SuspendHotkeys
;Initialization
bLDoubleClickAutoAttack:=false
bChargedStaff:=false
staffChargeDuration=500 ;Some initial value from the delayValues list
delayValues=50,100,250,500,750,1000,1250,1500,1750,2000
StringSplit, arrayDelays, delayValues, `,
return ; End of Auto-execute section
MainWeapon:
{
send {%keyUseWeapon% Down}
keywait, %keyUseWeapon%, t%mouseHoldDelay% ;Wait to see if mouse is released in the next 200 milliseconds
if errorlevel = 1 ;This registers as a 'press-n-hold' on the mouse button.
{
if (bLDoubleClickAutoAttack = true) ;Do we monitor double-cliks for this heroe?
{
; This detect if a double-click has been done, if so, enter in auto-attack mode
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500)
{
send {%keyUseWeapon% Up}
sleep initialRapidfireDelay ;Delay to prevent auto-attack firing mode from kicking in too fast
While GetKeyState(keyUseWeapon, "P")
{
;Are we doing charged staff attacks?
if(bChargedStaff = true)
{
Send {%keyUseWeapon% Down}
Sleep staffChargeDuration
Send {%keyUseWeapon% Up}
sleep mainRangedDelay
}
else ;We are doing non charged staff attacks
{
Send {%keyUseWeapon%}
sleep mainRangedDelay
}
}
}
else ;Enter in single shot 'charge up' attack mode (mainly for the apprentice staff charge attacks)
{
keywait, %keyUseWeapon%, u
send {%keyUseWeapon% Up}
}
}
else ;We monitor only single clicks for this heroe, this is mainly for melee attacks
{
;Enter in auto-attack mode
send {%keyUseWeapon% Up}
sleep initialRapidfireDelay ;Delay to prevent auto-attack firing mode from kicking in too fast
While GetKeyState(keyUseWeapon, "P")
{
Send {%keyUseWeapon%}
sleep mainMeleeDelay
}
}
}
else ;There was no 'press-n-hold', finish sending a regular mouse click
send {%keyUseWeapon% Up}
return
}
AlternateWeapon:
{
send {%keyAlternateWeapon% Down}
keywait, %keyAlternateWeapon%, t%mouseHoldDelay% ;Wait to see if mouse is released in the next 200 milliseconds
if errorlevel = 1 ;This registers a 'press-n-hold' on the mouse button.
{
;Enter in auto-attack mode
send {%keyAlternateWeapon% Up}
sleep initialRapidfireDelay ;Delay to prevent auto-attack firing mode from kicking in too fast
While GetKeyState(keyAlternateWeapon, "P")
{
Send {%keyAlternateWeapon%}
sleep alternateRangedDelay
}
}
else ;There was no 'press-n-hold', finish sending a regular mouse click
send {%keyAlternateWeapon% Up}
return
}
SuspendHotkeys:
;This suspends the script. It can either work as a toggling state
;or to suspend on key down and reactivate on key up
;User has to modify the bSuspendToggle value in the CUSTOMIZE section
Suspend
if(bSuspendToggle = false)
{
keywait, %KeySuspend%, u ;Wait for the release of suspend key
Suspend
}
return
ToggleStaffAttack:
bChargedStaff:= !bChargedStaff
return
SetChargeDuration:
Input, UserInput, L1 T2, , 1,2,3,4,5,6,7,8,9,0
if ErrorLevel = Match
{
if(UserInput = 0)
UserInput=10
staffChargeDuration = % arrayDelays%UserInput%
}
return
SetHeroeApprentice:
bLDoubleClickAutoAttack:=true
Hotkey, % "*$" keyUseWeapon, On
Hotkey, % "*$" keyAlternateWeapon, Off
return
SetHeroeSquire:
bLDoubleClickAutoAttack:=false
Hotkey, % "*$" keyUseWeapon, On
Hotkey, % "*$" keyAlternateWeapon, Off
return
SetHeroeHuntress:
bLDoubleClickAutoAttack:=false
Hotkey, % "*$" keyUseWeapon, Off
Hotkey, % "*$" keyAlternateWeapon, Off
return
SetHeroeMonk:
bLDoubleClickAutoAttack:=false
Hotkey, % "*$" keyUseWeapon, On
Hotkey, % "*$" keyAlternateWeapon, On
return