Age of Empires 2 on Linux – 2019 Edition

# Installing AoC on Linux without PlayOnLinux

## Variables

export AOCWINEPREFIX=~/.wine
export AOCDIR="${AOCWINEPREFIX}"/drive_c/Program\ Files/Microsoft\ Games/Age\ of\ Empires\ II
export voobly_desktop=~/.local/share/applications/Voobly.desktop
export aofe_desktop=~/.local/share/applications/TheForgottenEmpires.desktop
export aoc_desktop=~/.local/share/applications/TheConquerors.desktop
mkdir -p "$( dirname "${voobly_desktop}" )"

# Learn OS and flavor
. /usr/libexec/bgscripts/framework.sh

# Install wine-staging
# References:
#    https://wine-staging.com/installation.html
#    https://wiki.winehq.org/Debian
case "${thisflavor}" in
   ubuntu|debian|mint|devuan)
      sudo su -
      #wget -nc https://repos.wine-staging.com/wine/Release.key
      dpkg --add-architecture i386 # needed for winehq.org packages
      wget -nc https://dl.winehq.org/wine-builds/Release.key
      apt-key add Release.key && /bin/rm -f Release.key
      {
         echo "# And for Debian Sid this one:"
         echo "deb https://dl.winehq.org/wine-builds/debian/ sid main"
      } >> /etc/apt/sources.list.d/winehq.list
      apt-get update
      apt-get install -y winehq-staging winetricks
      test "${USER}" = "root" && exit
      ;;

   fedora|korora|centos|redhat)
      # Fedora already has wine staging
      sudo dnf -y install wine.i686 winetricks
      ;;
esac 

export WINEPREFIX="${AOCWINEPREFIX}"
export WINEARCH=win32

winetricks -q directplay

# mount AoE2 disc
sudo mkdir -p /mnt/aoe2
sudo mount -v -o loop /mnt/public/CDROMs/Games/AgeOfEmpires/ISO/AOE2.ISO /mnt/aoe2

# install AoE2
wine /mnt/aoe2/AOESETUP.EXE

# mount AoC disc
sudo mkdir -p /mnt/age2_x1
sudo mount -v -o loop /mnt/public/CDROMs/Games/AgeOfEmpires/ISO/AGE2_X1.ISO /mnt/age2_x1

# install AoC
wine /mnt/age2_x1/AOCSETUP.EXE

sudo umount -lv /mnt/age2_x1 ; sudo umount -lv /mnt/aoe2 ; sudo rmdir /mnt/aoe2 /mnt/age2_x1

# Install aoc 1.0c
cp -p /mnt/public/Support/Setups/Games/Age2XPatch.exe "${AOCDIR}"
wine "${AOCDIR}"/Age2XPatch.exe

# Install AoFE
# If the download is working.
#cp -p '/mnt/public/Age Of Empires/Downloaded/AoFE_Launcher.exe' "${AOCDIR}"
#pushd "${AOCDIR}"; wine "${AOCDIR}"/AoFE_Launcher.exe ; popd
# Alternate instruction for getting AoFE
pushd "${AOCDIR}" ; unzip '/mnt/public/Age Of Empires/Downloaded/fe_update.zip' ; mv Age2_x1/* age2_x1/ && rmdir Age2_x1 ; popd

# Install voobly
cp -p /mnt/public/Age\ Of\ Empires/Downloaded/voobly-v2.2.4.51.exe "${AOCDIR}"
wine "${AOCDIR}"/voobly-v2.2.4.51.exe

# get WololoKingdoms, as of 2018-09-22
# which I generated on my one Windows machine with the tool from https://github.com/AoE2CommunityGitHub/WololoKingdoms/releases and the Steam version of the game.
wk_dir="${AOCDIR}/Voobly Mods/AOC/Data Mods"
mkdir -p "${wk_dir}"
pushd "${wk_dir}" ; time 7za x /mnt/public/Age\ Of\ Empires/Wololo\ Kingdoms/WololoKingdoms.full.2018-09-11.zip ; popd

# customize voobly desktop file
tf=${AOCWINEPREFIX}/voobly.sh
touch "${tf}"; chmod 0755 "${tf}"
cat < "${tf}"
#!/bin/sh
env WINEPREFIX="${WINEPREFIX}" STAGING_WRITECOPY=1 /usr/bin/wine C:\\\\Program\\ Files\\\\Voobly\\\\voobly.exe
EOFVOOBLYSH

mkdir -p ~/.local/share/icons
cp -p '/mnt/public/Age Of Empires/Images/voobly.png' ~/.local/share/icons/
touch "${voobly_desktop}"; chmod 0755 "${voobly_desktop}"
cat < "${voobly_desktop}"
[Desktop Entry]
Name=Voobly
Exec="${tf}"
Type=Application
StartupNotify=true
Path=${WINEPREFIX}/dosdevices/c:/Program Files/Voobly
Icon=/home/${USER}/.local/share/icons/voobly.png
StartupWMClass=voobly.exe
Comment=Matchmaking service for AoC
Categories=Game;StrategyGame;
EOFVOOBLY

# customize AoFE desktop file
cp -p '/mnt/public/Age Of Empires/Images/age2_x2.png' ~/.local/share/icons/
touch "${aofe_desktop}"; chmod 0755 "${aofe_desktop}"
cat < "${aofe_desktop}"
[Desktop Entry]
Name=The Forgotten Empires
Exec=env WINEPREFIX="${WINEPREFIX}" /usr/bin/wine "${AOCDIR}/age2_x1/age2_x2.exe" /nostartup
Type=Application
StartupNotify=true
Path=${AOCDIR}
Icon=/home/${USER}/.local/share/icons/age2_x2.png
StartupWMClass=age2_x1.exe
Comment=Forgotten Empires 2.2 mod for AoC
Categories=Game;StrategyGame;
EOFAOFE

# customize AoC desktop file
thisicon="$( find ~ -regex '.*.local.*age2_x1.*png' 2>/dev/null | sort | tail -n1 )"
touch "${aoc_desktop}"; chmod 0755 "${aoc_desktop}"
cat < "${aoc_desktop}"
[Desktop Entry]
Name=The Conquerors
Exec=env WINEPREFIX="${WINEPREFIX}" /usr/bin/wine "${AOCDIR}/age2_x1/age2_x1.exe" /nostartup
Type=Application
StartupNotify=true
Path=${AOCDIR}
Icon=${thisicon}
StartupWMClass=age2_x1.exe
Comment=Age of Empires 2: The Conquerors Expansion
Categories=Game;StrategyGame;
EOFAOC

echo done

2 thoughts on “Age of Empires 2 on Linux – 2019 Edition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.