Forum

Age of Wonders III: Shadow Magic (GoG)

Författare Svar
petch Monday 12 December 2011 at 0:54
petch

Hello all, time for a new script ;)
This time I wrote a script for Age of Wonders: Shadow Magic.
There's a trick to make it responsive, wineserver must be given a lower priority(!)
Other than that nothing really special...
Enjoy!
https://raw.github.com/petchema/playonlinux/master/ageofwonders3-shadowmagic-gog
#!/bin/bash
# Date : (2012-12-11 20-52)
# Last revision : (2011-12-12 00-45)
# Wine version used : 1.3.34
# Distribution used to test : Debian Sid (Unstable)
# Author : Pierre Etchemaite petchema@concept-micro.com
# Script licence : GPL v.2
# Program licence : Retail
# Depend :

[ -z "$PLAYONLINUX" ] && exit 0
source "$PLAYONLINUX/lib/sources"

check_install_archive () {
    FILE="$1"
    EXPECTED_NAME="$2"
    EXPECTED_SIZE="$3"
    EXPECTED_MD5="$4"

    POL_SetupWindow_wait "$(eval_gettext 'Checking install archive...')" "$TITLE"
    # Temporarily prevent word splitting
    OLDIFS="$IFS"
    IFS=''
    NAME="$(basename $FILE)"
    SIZE="$(stat -c%s $FILE)"
    MD5="$(POL_MD5_file $FILE)"
    IFS="$OLDIFS"

    if [ $SIZE -ne $EXPECTED_SIZE -o "$MD5" != "$EXPECTED_MD5" ]; then
        POL_Debug_Error "$(eval_gettext 'Install archive mismatch.\\nEither your install archive is corrupted, or is not the expected version.\\nThis script cannot guarantee that installation will work correctly. Please report success or failure to PlayOnLinux forums.')\\n$(eval_gettext 'Name:') $NAME ($(eval_gettext 'expected') $EXPECTED_NAME)\\n$(eval_gettext 'Size:') $SIZE ($(eval_gettext 'expected') $EXPECTED_SIZE)\\n$(eval_gettext 'MD5:') $MD5\\n     ($(eval_gettext 'expected') $EXPECTED_MD5)"
        POL_SetupWindow_question "$(eval_gettext 'Continue?')" "$TITLE"
        [ "$APP_ANSWER" != "TRUE" ] && POL_Debug_Fatal "$(eval_gettext 'Not the expected archive')"
    fi
}


PREFIX="AgeOfWonders3_gog"
WORKING_WINE_VERSION="1.3.34"

TITLE="$(eval_gettext 'Age of Wonders III: Shadow Magic (GoG release)')"
SHORTCUT_NAME="Age of Wonders: Shadow Magic"
SHORTCUT_EDITOR="$SHORTCUT_NAME - $(eval_gettext 'Editor')"
SHORTCUT_DOC="$SHORTCUT_NAME - $(eval_gettext 'Quickplay Guide')"
SHORTCUT_README="$SHORTCUT_NAME - $(eval_gettext 'Readme')"

POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Triumph Studios" "http://www.gog.com/en/gamecard/age_of_wonders_shadow_magic" "Pierre Etchemaite" "$PREFIX"

POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"

cd $HOME
POL_SetupWindow_browse "$(eval_gettext 'Please select the setup file to run.')" "$TITLE"
ARCHIVE="$APP_ANSWER"

check_install_archive "$ARCHIVE" setup_age_of_wonders_shadow_magic.exe 538389298 85786a3a6872896adc1720536a626f05


POL_SetupWindow_wait "$(eval_gettext 'Please wait while $TITLE is installed.')" "$TITLE"

# Associate .PDF with native app
# http://wiki.winehq.org/FAQ#head-91bf3f0a8ccbfab8dee96f82fae2f1a489e0d243
# Do it before installing the game, so you have the possibility to open
# PDFs with Win32 reader if you choose to install it
cat <<'_EOF_' > $REPERTOIRE/tmp/pdfnativereader.reg
[HKEY_CLASSES_ROOT\\.pdf]
@="PDFfile"
"Content Type"="application/pdf"
[HKEY_CLASSES_ROOT\\PDFfile\\Shell\\Open\\command]
@="winebrowser \\"%1\\""
_EOF_
POL_Wine regedit $REPERTOIRE/tmp/pdfnativereader.reg

POL_Wine start /unix "$ARCHIVE" || POL_Debug_Fatal "$(eval_gettext 'Error while installing archive')"

POL_Wine_WaitExit "$TITLE"

POL_Call POL_Install_directplay


# GoG work!
Set_OS winxp

POL_SetupWindow_VMS "16"

## PlayOnMac Section
[ -n "$PLAYONMAC" ] && Set_SoundDriver "alsa"
[ -n "$PLAYONMAC" ] || Set_Managed "Off"
## End Section

# Direct3D: off; Cursor: colors
cat <<_EOFINI_ > "$REPERTOIRE/tmp/aow3_video.reg"
REGEDIT4

[HKEY_CURRENT_USER\\Software\\Triumph Studios\\Age of Wonders Shadow Magic\\Video]
"Cursor Mode"=dword:00000002
"Use Direct3D"=dword:00000000
_EOFINI_
POL_Wine regedit "$REPERTOIRE/tmp/aow3_video.reg"
rm "$REPERTOIRE/tmp/aow3_video.reg"

# Doesn't hurt ;)
POL_Wine_reboot

POL_Shortcut "AoWSM.exe" "$SHORTCUT_NAME"
# Now the trick: Shadow magic needs a "slow" wineserver to be responsive!
# http://appdb.winehq.org/objectManager.php?sClass=version&iId=3101&iTestingId=14987
POL_Shortcut_InsertBeforeWine "$SHORTCUT_NAME" "POL_Wine_AutoSetVersionEnv\\nwineserver -k\\nnice -19 wineserver"

POL_Shortcut "AoWSMEd.exe" "$SHORTCUT_EDITOR"
POL_Shortcut "start.exe" "$SHORTCUT_DOC" "" "'C:/$PROGRAMFILES/GOG.com/Age of Wonders Shadow Magic/QuickStart.pdf'"
POL_Shortcut "start.exe" "$SHORTCUT_README" "" "'C:/$PROGRAMFILES/GOG.com/Age of Wonders Shadow Magic/Readme.html'"

POL_SetupWindow_Close

cat <<_EOF_ > "$REPERTOIRE/configurations/configurators/$SHORTCUT_NAME"
#!/bin/bash
[ -z "\\$PLAYONLINUX" ] && exit 0
source "\\$PLAYONLINUX/lib/sources"
export WINEPREFIX="$REPERTOIRE/wineprefix/$PREFIX"
export WINEDEBUG=""

POL_LoadVar_PROGRAMFILES

cd "\\$WINEPREFIX/drive_c/\\$PROGRAMFILES/GOG.com/Age of Wonders Shadow Magic/" || exit 1

POL_Wine AoWSMSetup.exe

_EOF_

exit
Arcitens Saturday 1 December 2012 at 17:41
ArcitensAnonymous

Hi there, what do you mean "wineserver must be given a lower priority"? I bought the game from GOG and used the script but the game is not "responsive" - I can't click anywhere on the game, like to click "new campaign". Thanks in advance for help.
petch Saturday 1 December 2012 at 23:42
petch

Hi,
I mean what's line 110 of above script.
The script in the repository no longer uses that trick, since in my later tests, going thru the launcher instead of running the game directly seems to have fixed the issue for me.
Maybe I've just been lucky.

I re-added the old way starting the game to the official script as an "alternate" shortcut, do you have better results with this one?
Arcitens Sunday 2 December 2012 at 1:09
ArcitensAnonymous

I always open from the launcher and not desktop shortcuts. "Alternate" shortcut in the launcher worked perfectly. Thank you so much for the quick response and action. Let me know if I can help in any way diagnosing what the problem is on my machine with the other shortcut.
petch Sunday 2 December 2012 at 9:36
petch

Cool :)

I'll leave this alternate shortcut around for the time being then.