Skip to content

Instantly share code, notes, and snippets.

@jahabrewer
Created April 21, 2018 18:06
Show Gist options
  • Save jahabrewer/83c7fe8d6d03d8ed8f794df58e7844ed to your computer and use it in GitHub Desktop.
Save jahabrewer/83c7fe8d6d03d8ed8f794df58e7844ed to your computer and use it in GitHub Desktop.
Tropico 4 autohotkey script
; Tropico 4 Betterizer - jahabrewer edition
;
; This is a modified version of an ahk script I found on steam. I've added the
; ability to set game speed directly with 1,2,3 and reversed the Q,E rotation to
; be what I expected. I got my feel for Q,E rotation from XCOM.
;
; I got really used to the control scheme of Rimworld, and I love Tropico 4.
; I stumbled across an AHK script written years ago, and decided to improve it.
; License: Public domain.
; Author: Kamerad ggppjj on Steam
;
; Original Credits:
; Thanks to http://www.wikihouse.com/tropico/ Tropico Wiki for the most of this script,
; Thanks to http://www.autohotkey.com/ for making this functionality possible!
; Additional Credits:
; Thanks to Urbankain for the original script, based on a post found here: http://steamcommunity.com/app/57690/discussions/0/846958724745718767/
; Thanks to Trolbridge for the intial fix for rotation, updated to allow movement when rotating.
; Thanks to User Eklei on Steam, for helpful hints, and answers to stupid questions.
;
; What this script does:
; WASD is now camera control.
; Q and E are camera rotation.
; Spacebar is pause when the game is open.
; Shift W turns on and off the script, no matter whether the game is open or not.
; Enable/disable script with Ctrl + W, Globally.
*^W::
Suspend
return
; Use 1,2,3 to directly set game speed
1::
Send,---=
return
2::
Send,---==
return
3::
Send,===
return
; Variables
blockE := false
blockQ := false
; WASD camera movement and Spacebar pause/unpause while game is active in the foreground.
#ifWinActive, ahk_class Tropico 4
{
W::Send {Up down}
W up::Send {Up up}
A::Send {left down}
A up::Send {Left up}
S::Send {Down down}
S up::Send {Down up}
D::Send {Right down}
D up::Send {Right up}
Space::Send {Pause}
}
; Rotate screen with Q and E if neither of those rotations are already happening, modified.
#if !(blockQ) && WinActive("ahk_class Tropico 4")
{
Q::
blockE := !blockE
BlockInput, MouseMove
Click down middle
Send {Right down}
Loop
{
if (GetKeyState("Q","P") == false)
{
Send {Right up}
Click up middle
BlockInput, MouseMoveOff
blockE := !blockE
break
}
}
return
}
#if !(blockE) && WinActive("ahk_class Tropico 4")
{
E::
blockQ := !blockQ
BlockInput, MouseMove
Click down middle
Send {Left down}
Loop
{
if (GetKeyState("E","P") == false)
{
Send {Left up}
Click up middle
BlockInput, MouseMoveOff
blockQ:=!blockQ
break
}
}
return
}
; Do nothing and do not send keypress to application if other hotkeys are already running.
#if blockQ && WinActive("ahk_class Tropico 4")
{
Q::return
}
#if blockE && WinActive("ahk_class Tropico 4")
{
E::return
}
@ggppjj
Copy link

ggppjj commented Jun 17, 2018

Glad to see someone found it useful!

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