Age of Empires II: Definitive Edition macros

Post gaming related scripts
Player
Posts: 7
Joined: 03 Feb 2018, 15:21

Age of Empires II: Definitive Edition macros

Post by Player » 26 Jan 2020, 11:42

Here are looping scripts you can use with the numpad. Pressing a key activate the loop, pressing it again disable it. The key ` will quit the loop if you struggle to get out.

Economy:
1: create villagers from all your Town Centers
2: move idle villagers to your cursor, it is advised to use the minimap. This is useful to get resources like sending them to mine gold
3: kill idle villager

Military (the advantage is that they are created by waves, use the minimap for their rallypoint you can shake the mouse to swarm the enemy base):
4: produce halberdier from all your barracks
5: produce skirmishers from all your archeries
6: produce huskarl from all your racks

Tactic:
7: move the idle infantry to the mouse in the minimap, very useful with mass huskarl if the enemy has no walls, start by hovering behind his base and draw ellipses to the entrance of his base to destroy his economy
8: attack move with your idle infantry

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Toggle = 0
#MaxThreadsPerHotkey 2
delay = 1

`::
loop 100{
	Toggle = 0
	sleep 1
}
return

Numpad1:: ;create villagers
Toggle := !Toggle
While Toggle{
	SendInput, h
	sleep delay
	SendInput, g
	sleep delay
	SendInput, q
	sleep delay
}
return

Numpad2:: ;regroup idle villagers on minimap
Toggle := !Toggle
While Toggle{
	SendInput, h
	sleep delay
	SendInput, g
	sleep delay
	SendInput, .
	sleep delay 
	click, right
}
return

Numpad3:: ;kill idle villagers
Toggle := !Toggle
While Toggle{
	SendInput, h
	sleep delay
	SendInput, g
	sleep delay
	SendInput, .
	sleep delay
	SendInput, {delete}
	sleep delay
}
return

Numpad4::
Toggle := !Toggle
While Toggle{
	SendInput, {Ctrl down}
	sleep delay
	SendInput, b
	sleep delay 
	SendInput, {Ctrl up}
	sleep delay
	Click, right
	sleep delay
	SendInput, g
	sleep delay
	SendInput, w
	sleep delay
}
return

Numpad5:: ;create skirmishers
Toggle := !Toggle
While Toggle{
	SendInput, {Ctrl down}
	sleep delay
	SendInput, a
	sleep delay 
	SendInput, {Ctrl up}
	sleep delay
	Click, right
	sleep delay
	SendInput, g
	sleep delay
	SendInput, w
	sleep delay
}
return

Numpad6:: ;create unique unit Goth
Toggle := !Toggle
While Toggle{
	SendInput, {Ctrl down}
	sleep delay
	SendInput, b
	sleep delay 
	SendInput, {Ctrl up}
	sleep delay
	Click, right
	sleep delay
	SendInput, g
	sleep delay
	SendInput, r
	sleep delay
}
return

Numpad7:: ;move idle infantry
Toggle := !Toggle
SendInput, fg
While Toggle{
	SendInput, ,
	sleep delay
	Click, right
	sleep delay
	SendInput, a
	sleep delay
}
SendInput, a
return

Numpad8:: ;attack move idle infantry
Toggle := !Toggle
While Toggle{
	SendInput, ,
	sleep delay
	SendInput, r
	sleep delay
	Click, left
	sleep delay
}
return
DRocks
Posts: 565
Joined: 08 May 2018, 10:20

Re: Age of Empires II: Definitive Edition macros

Post by DRocks » 16 Apr 2021, 08:31

Cool I tried doing some for the initial start up actions you typically would do.

- Queue villagers creation
- Start scouting
- Create first house

Code: Select all

;index.ahk
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetNumLockState AlwaysOn
ListLines, Off
#Include randomNumbers.ahk
#Include basicActions.ahk


; Register Hotkeys when Age of Empires window is active:
#IfWinActive, ahk_class Age of Empires II: Definitive Edition ahk_exe AoE2DE_s.exe
+XButton2::startupAction()
XButton2::createFiveVillagers()
return


startupAction() {
	createFiveVillagers()
	startScounting()
	createFirstHouse()
}

createFiveVillagers() {
	focusTownCenter()
	queueFive()
	sleepRandomShort()
}

startScounting() {
	selectIdleArmy()
	sendHotkey("g")
	sendHotkey("^1")
}

createFirstHouse() {
	selectIdleVillagers()
	createHouse()
}

Code: Select all

;basicActions.ahk
sendHotkey(keys) {
	Send, % keys
	sleepRandomShort()
}

focusTownCenter() {
	sendHotkey("h")
}

queueFive() {
	sendHotkey(">+q")
}

selectIdleVillagers() {
	sendHotkey("<+.")
}

createHouse() {
	sendHotkey("q")
	sendHotkey("a")
}

selectIdleArmy() {
	sendHotkey("<+,")
}

Code: Select all

;randomNumbers.ahk
sleepRandomShort() {
	Sleep, getShortRandomNum()
}

getShortRandomNum() {
	return getRandomNum(150, 210)
}

getRandomNum(min, max) {
	Random, randomNumber, %min%, %max%
	return randomNumber
}
Post Reply

Return to “Gaming Scripts (v1)”