Scripts for FTL: Faster Than Light

Post gaming related scripts
User avatar
Hactar
Posts: 12
Joined: 23 Jul 2015, 20:59

Scripts for FTL: Faster Than Light

25 Jul 2015, 11:42

Hello everyone! I have made a few scripts which I have found handy while playing FTL. Hopefully they can be of use to others as well!

Update 8/19/2015 - Fixed a Tooltip typo in FTLPowerSwitch

Most of these scripts are split into two parts. This is so that they can be easily integrated into an existing "main script" you may have. If these are the only scripts you wish to use, put them all into a folder with the following script:

Code: Select all

#InstallKeybdHook				; Better keyboard handling
#NoEnv							; Better compatibility
#SingleInstance Force			; No dialog when restarting
SendMode Input					; Faster keystrokes
SetWorkingDir %A_ScriptDir%		; Ensures a consistent starting directory

#Include FTLPowerSwitchSetup.ahk
#Include FTLTeleportKeySetup.ahk

Return ; END OF AUTO-EXECUTE SECTION

#Include FTLSheildDrop
#Include FTLPowerSwitch.ahk
#Include FTLTeleportKey.ahk
#Include FTLWeaponFire.ahk
(Of course if there are some you don't want you can simply remove those lines.)

Some of them also have QuickStart support. QuickStart is a little modular launcher that can be easily integrated into larger scripts. Now, onto the scripts themselves!

FTLShieldDrop.ahk - Ion Defense <- NEW! (8-3-15)
It's always difficult going up against a ship with good ion weaponry. But you may not realize that if you drop your shields and then quickly raise them again so that the ion misses them, the ion weapon will usually strike a different system, often even an empty room, instead of taking down your precious shields. This is all well and good in the early sectors when you only have one level of sheilds, but later on it can be quite tedious. So here's a script that should take down all your shields for a single instant to let the ion pass. (For best results, use while unpaused shortly after the ion weapon fires.)
Code
FTLWeaponFire.ahk
Point your mouse at the system you would like to target, and press [A], , [D] or [F] (for weapons 1-4) to target that system. To untarget the system, point your mouse at empty space and hit one of those keys. If the weapon is not yet powered, it will be powered on first. Unfortunately this does not work for beam weapons. :( (It can still be used to untarget beam weapons, just not target them.)
[spoiler2=Code]FTLWeaponFire.ahk (#Include after auto-execute section)
[code=autohotkey file=FTLWeaponFire.ahk]
#IfWinActive ahk_exe FTLGame.exe
*a::
Send {1}
Sleep 50
Click Left
Sleep 50
Click Right
Return
*s::
Send {2}
Sleep 50
Click Left
Sleep 50
Click Right
Return
*d::
Send {3}
Sleep 50
Click Left
Sleep 50
Click Right
Return
*f::
Send {4}
Sleep 50
Click Left
Sleep 50
Click Right
Return

^Space::
Send {Space}
Sleep 100
Send {Space}
Return
#If
[/code][/spoiler2]

FTLTeleportKey.ahk
If you've ever used any of the Mantis cruisers, or just love boarding ships, you'll know the pain of selecting each individual crewmember to go to the teleporter, or having your crew's saved positions be in the teleporter room when they could be manning systems. This script allows you to automatically select certain crewmembers at the press of a button. [Ctrl] + [T] brings up a tooltip in which you can press the number buttons on the top of your keyboard (1-8) to add/remove those crew from the list. Once this is done, press [Enter] or [Space] to save and use [Shift] + [T] to automatically select those crewmembers. (If one of your crew dies, even one not used by this script, you may have to reconfigure it.)
[spoiler2=Code]FTLTeleportKeySetup.ahk (#Include before auto-execute section)
[code=autohotkey file=FTLTeleportKeySetup.ahk]
; MUST BE IMPORTED AFTER QUICKSTART TO HAVE QSv2 SUPPORT

{ ; QuickStart v2
QuickStart.ftltp := Func( "QS_GoSub" ).Bind( "FTLTeleportConfig" )
}

IniRead, FTLTPList, Modules\ModuleConfig.ini, FTLTeleportKey, CrewTPList, %A_Space%
FTLTeleportKeys := {}
If FTLTPList
Loop, Parse, FTLTPList
{
KeyName = F%A_LoopField%
FTLTeleportKeys[KeyName] := A_LoopField
}
FTLTPList =
[/code]

FTLTeleportKey.ahk (#Include after auto-execute section)
[code=autohotkey file=FTLTeleportKey.ahk]
FTLTeleportConfig:
OldFTLTeleportKeys := FTLTeleportKeys
FTLTeleportKeysUpdate()
FTLTeleportKeyCapture := True
BlockInput MouseMove
Return

#If WinActive( "ahk_exe FTLGame.exe" ) And FTLTeleportKeyCapture
`::FTLTeleportKeysUpdate( 0 )
1::FTLTeleportKeysUpdate( 1 )
2::FTLTeleportKeysUpdate( 2 )
3::FTLTeleportKeysUpdate( 3 )
4::FTLTeleportKeysUpdate( 4 )
5::FTLTeleportKeysUpdate( 5 )
6::FTLTeleportKeysUpdate( 6 )
7::FTLTeleportKeysUpdate( 7 )
8::FTLTeleportKeysUpdate( 8 )
Enter::
Space::
ToolTip
FTLTeleportKeyCapture := False
BlockInput MouseMoveOff
IniWrite, % FTLTeleportList( 0 ), Modules\ModuleConfig.ini, FTLTeleportKey, CrewTPList
If ErrorLevel
TrayTip, FTLTeleportKey, There was an error saving the file
Else TrayTip, FTLTeleportKey, Crew config saved!
Return
Esc::
ToolTip
FTLTeleportKeyCapture := False
BlockInput MouseMoveOff
TrayTip, FTLTeleportKey, Operation cancelled
FTLTeleportKeys := OldFTLTeleportKeys
OldFTLTeleportKeys =
Return
#If

#IfWinActive ahk_exe FTLGame.exe
^t::GoSub FTLTeleportConfig
+t::
KeyWait Shift
BlockInput On
Sleep 50
FirstCrew := True
For CrewKey in FTLTeleportKeys
{
If ( FirstCrew ) {
Send {%CrewKey%}
FirstCrew =
}
Else SendSlowModKey( "Shift", CrewKey, 25 )
Sleep 25
}
BlockInput Off
Return
#If

FTLTeleportKeysUpdate( Num="ToolTip" ) {
Global FTLTeleportKeys
If ( Num != "ToolTip" ) {
If ( Num ) {
KeyName = F%Num%
If FTLTeleportKeys[KeyName]
FTLTeleportKeys.Remove( KeyName )
Else FTLTeleportKeys[KeyName] := Num
} Else
FTLTeleportKeys := {}
}
FTLTPList := FTLTeleportList()
If FTLTPList
ToolTip Selected Crew: %FTLTPList%`nPress backtick to reset`nPress [Enter] or [Space] to save`nPress [Esc] to cancel
Else
ToolTip Press the number keys corresponding`nto the crew that will be teleporting.`n`nWhen you are finished`, press [Enter] or [Space].
}

FTLTeleportList( InclSpace=1 ) {
Global FTLTeleportKeys
FTLTeleportList := ""
For CrewKey, CrewNum in FTLTeleportKeys
FTLTeleportList := FTLTeleportList . CrewNum . ( InclSpace ? A_Space : "" )
Return InclSpace ? SubStr( FTLTeleportList, 1, StrLen( FTLTeleportList ) - 1 ) : FTLTeleportList
}
[/code][/spoiler2]

FTLPowerSwitch.ahk
Admit it: at some point you've wasted precious power which could've been directed to your engines or shields by powering your medbay or clonebay while it wasn't being used. Well this script provides a simple solution to that. It's a little complicated, but I'll try my best to explain. [Ctrl] + [W] brings up the "power source" configuration. Here you can press a button on your keyboard (ASDFGH...) that corresponds to the system(s) you want to DEPOWER to provide another system with power. Once you have selected a system, type the amount of power you would like to take from that system (zero to remove). Once you have set that, press [Enter] or [Space] to save. [Ctrl] + [E] opens the "power destination" configuration. Here you can simply select a system (ASDFGH...) to power. For example, if I want to take two power bars from my engines and one from my cloaking to power my medbay/clonebay, I would press first [Ctrl] + [W] to configure the source, then (engines is the second system, generally), then [2] (because we want to take two power bars), then [G] (this may vary depending on how many systems you have installed), then [1] (because we want to take one power from cloaking), then [Enter] (to save the settings). Now I would press [Ctrl] + [E] to configure the destination, which will be our medbay/clonebay, or [D] (the third system). I'm sure this all sounds really complicated, but it can be convenient.
[spoiler2=Code]FTLPowerSwitchSetup.ahk (#Include before auto-execute section)
[code=autohotkey file=FTLPowerSwitchSetup.ahk]
IniRead, FTLPS_FromList, Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchFrom, %A_Space%
IniRead, FTLPS_FromAmts, Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchAmt, %A_Space%
IniRead, FTLPS_To, Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchTo, %A_Space%
FTLPS_From := {}
FTLPS_PowerLevel := 9001 ; IT'S OVER 9000
FTLPS_PowerLevel := 0
If FTLPS_FromList
Loop, Parse, FTLPS_FromList
{
FTLPS_From[A_LoopField] := SubStr( FTLPS_FromAmts, A_Index, 1 )
FTLPS_PowerLevel := FTLPS_PowerLevel + ( A_LoopField = "a" ? 2 * SubStr( FTLPS_FromAmts, A_Index, 1 ) : SubStr( FTLPS_FromAmts, A_Index, 1 )
}
FTLPS_FromList =
FTLPS_FromAmts =
[/code]
FTLPowerSwitch.ahk (#Include after auto-execute section)
[code=autohotkey file=FTLPowerSwitch.ahk]
FTLPS_Config:
FTLPS_Update()
FTLPS_KeyCapture := True
BlockInput MouseMove
Return

#If WinActive( "ahk_exe FTLGame.exe" ) And FTLPS_KeyCapture
a::FTLPS_Update( "a" )
s::FTLPS_Update( "s" )
d::FTLPS_Update( "d" )
f::FTLPS_Update( "f" )
g::FTLPS_Update( "g" )
h::FTLPS_Update( "h" )
k::FTLPS_Update( "k" )
l::FTLPS_Update( "l" )
`::
0::FTLPS_Update( 0 )
1::FTLPS_Update( 1 )
2::FTLPS_Update( 2 )
3::FTLPS_Update( 3 )
4::FTLPS_Update( 4 )
5::FTLPS_Update( 5 )
6::FTLPS_Update( 6 )
7::FTLPS_Update( 7 )
8::FTLPS_Update( 8 )
9::FTLPS_Update( 9 )
Enter::
Space::
ToolTip
FTLPS_KeyCapture := False
BlockInput MouseMoveOff
If ( FTLPS_ConfigMode = "From" ) {
IniWrite, % FTLPS_Text( 1 )[1], Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchFrom
IniWrite, % FTLPS_Text( 1 )[2], Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchAmt
FTLPS_PowerLevel := 0
Loop, Parse, % FTLPS_Text( 1 )[2]
FTLPS_PowerLevel := FTLPS_PowerLevel + ( SubStr( FTLPS_Text( 1 )[1], A_Index, 1 ) = "a" ? 2 * A_LoopField : A_LoopField ) )
} Else If FTLPS_ConfigMode = To
IniWrite, % FTLPS_To, Modules\ModuleConfig.ini, FTLPowerSwitch, SwitchTo
If ErrorLevel
TrayTip, FTLPowerSwitch, There was an error saving the file
Else TrayTip, FTLPowerSwitch, Power config saved!
Return
Esc::
ToolTip
FTLPS_KeyCapture := False
BlockInput MouseMoveOff
TrayTip, FTLPowerSwitch, Operation cancelled
FTLPS_%FTLPS_ConfigMode% := OldFTLPS_%FTLPS_ConfigMode%
OldFTLPS_%FTLPS_ConfigMode% =
Return
#If

{
#IfWinActive ahk_exe FTLGame.exe
^w::
OldFTLPS_From := FTLPS_From
FTLPS_Selected =
FTLPS_ConfigMode = From
GoSub FTLPS_Config
Return
^e::
OldFTPPS_To := FTLPS_To
FTLPS_ConfigMode = To
GoSub FTLPS_Config
Return
+w::
KeyWait Shift
BlockInput On
Sleep 50
Send {Shift Down}
Sleep 50
Loop %FTLPS_PowerLevel% {
Send {%FTLPS_To%}
Sleep 50
}
Send {Shift Up}
For Key, Amount in FTLPS_From
{
Loop %Amount% {
Sleep 50
Send {%Key%}
}
}
PowerLevel =
BlockInput Off
Return
+e::
KeyWait Shift
BlockInput On
Sleep 50
Send {Shift Down}
Sleep 50
For Key, Amount in FTLPS_From
{
Loop %Amount% {
Send {%Key%}
Sleep 50
}
}
Send {Shift Up}
Loop %FTLPS_PowerLevel% {
Sleep 50
Send {%FTLPS_To%}
}
PowerLevel =
BlockInput Off
Return
#If
}

FTLPS_Update( Key="ToolTip" ) {
Global FTLPS_From, FTLPS_To, FTLPS_Selected, FTLPS_ConfigMode
If ( FTLPS_ConfigMode = "From" ) And ( Key != "ToolTip" ) {
If ( Key ) {
If Key is alpha
If ( FTLPS_Selected = Key ) {
FTLPS_Selected =
; FTLPS_From.Remove( Key )
} Else {
FTLPS_Selected := Key
If !FTLPS_From[Key]
FTLPS_From[Key] := "0"
} Else If Key is number
If ( FTLPS_Selected ) {
FTLPS_From[FTLPS_Selected] := Key
FTLPS_Selected =
}
} Else If ( FTLPS_Selected ) {
FTLPS_From.Remove( FTLPS_Selected )
FTLPS_Selected =
}
}
Else If ( FTLPS_ConfigMode = "To" ) And ( Key != "ToolTip" )
If Key is alpha
FTLPS_To := Key
If FTLPS_ConfigMode = To
ToolTip % "Select the system to be powered" . ( FTLPS_To ? "`nCurrently selected: " . FTLPS_To . "`nPress [Enter] or [Space] to save`nPress [Esc] to cancel" : "" )
Else If FTLPS_ConfigMode = From
; If FTLPS_From
ToolTip % "Sacrificial Systems:`n" . FTLPS_Text() . "Press [Enter] or [Space] to save`nPress [Esc] to cancel"
; Else ToolTip % "Sacrificial Systems:" . FTLPS_Text() . "Press [Enter] or [Space] to save`nPress [Esc] to cancel"
}

FTLPS_Text( IniFormat=0 ) {
Global FTLPS_From, FTLPS_Selected
If ( IniFormat ) {
FTLPS_Text := {}
FTLPS_Text[1] := ""
FTLPS_Text[2] := ""
} Else FTLPS_Text := ""
For Key, Amount in FTLPS_From
If ( Key ) {
; If !IniFormat
; MsgBox %Key%`n%Amount%
If ( IniFormat ) {
FTLPS_Text[1] := FTLPS_Text[1] . Key
FTLPS_Text[2] := FTLPS_Text[2] . Amount
} Else FTLPS_Text := FTLPS_Text . Key . A_Tab . ( FTLPS_Selected = Key ? "[" . Amount . "]" : Amount ) . "`n"
}
Return FTLPS_Text
}
[/code][/spoiler2]

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 16 guests