The forum

[Script] Majesty 2

Author Replies
LinuxScripter Thursday 28 January 2016 at 11:10
LinuxScripterAnonymous

Hello. This script installs a unique strategy game called Majesty 2. It's unique in sense that you cannot directly command your heroes to do stuff but rather you do it though objects called "flags". It have a campain mode, singleplayer missions and multiplayer mode. The script works fine but the game seems to hang when swithing windows. Use the virtual desktop option in winecfg to prevent that. If the game asks you to install directx or Adobe Reader untick those options (the script installs directx and AR only makes the prefix take more disk space).

#!/bin/bash
# Date : (2016-01-21)
# Last revision : (2016-02-03)
# Wine version used : 1.9.2
# Distribution used to test : Ubuntu 15.10 x64
# Author : LinuxScripter
# Licence : GPLv3
 
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
TITLE="Majesty 2"
AUTHOR="LinuxScripter"
PREFIX="Majesty2"
EDITOR="Paradox Interactive"
GAME_URL="http://www.majesty2.com/"
WORKINGWINEVERSION="1.9.2"

POL_SetupWindow_Init
POL_Debug_Init
 
POL_SetupWindow_presentation "$TITLE" "$EDITOR" "$GAME_URL" "$AUTHOR" "$PREFIX"

# Setting prefix path
POL_Wine_SelectPrefix "$PREFIX"
 
# Downloading wine if necessary and creating prefix
POL_System_SetArch "x86"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"

POL_Call POL_Install_vcrun2005
POL_Call POL_Install_d3dx9
 
POL_SetupWindow_InstallMethod "DVD,STEAM"

if [ "$INSTALL_METHOD" == "DVD" ]; then
# Asking for CDROM and checking if it's correct one
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "data1.cab"
POL_Wine start /unix "$CDROM/setup.exe"
POL_Wine_WaitExit "$TITLE"
else
POL_Call POL_Install_steam
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam"
POL_Wine "steam.exe" steam://install/25980
POL_Wine_WaitBefore "$TITLE"
fi

# Making shortcut
if [ "$INSTALL_METHOD" == "STEAM" ]; then
        POL_Shortcut "steam.exe" "$TITLE" "" "steam://rungameid/25980"
else
        POL_Shortcut "Majesty2.exe" "$TITLE" "" "Game;StrategyGame;"
fi

POL_SetupWindow_Close
exit 0

Screenshots coming soon.

Edited by LinuxScripter


MTres19 Saturday 30 January 2016 at 23:08
MTres19Anonymous

Here are some tips that you might find useful:

If you want to automatically set a virtual desktop, just use Set_Desktop "On" "1024" "768". Although that could be any resolution you want, not just 1024x768.

You probably don't need POL_SetupWindow_message to tell the user to put in their CD. POL_SetupWindow_cdrom already asks and if they haven't put it in by then, there is a refresh option.

In this case, POL_SetupWindow_check_cdrom isn't going to do much since practically every Windows CD has an autorun.inf. If there was something more unique that could be used, that would be better.

If not neccessary, it's usually best to avoid start /unix, but if it's needed, that's fine.

Hopefully that helps a bit.

LinuxScripter Wednesday 3 February 2016 at 12:41
LinuxScripterAnonymous

If you want to automatically set a virtual desktop, just use Set_Desktop "On" "1024" "768". Although that could be any resolution you want, not just 1024x768.

You probably don't need POL_SetupWindow_message to tell the user to put in their CD. POL_SetupWindow_cdrom already asks and if they haven't put it in by then, there is a refresh option.

In this case, POL_SetupWindow_check_cdrom isn't going to do much since practically every Windows CD has an autorun.inf. If there was something more unique that could be used, that would be better.

If not neccessary, it's usually best to avoid start /unix, but if it's needed, that's fine.

Thanks for review.

I know about the Set_Desktop function but since not everyone uses the same resolution as me I decided to leave it up to user to do it.

I saw some scripts using the POL_SetupWindow_message when installing via CD/DVD/ISO so I though it's necessary. Anyway I removed it.

About the POL_SetupWindow_check_cdrom

Since there are offen many versions of the game (with diffirent file structure,like remakes or gold/complete editions) picking a specific file could result in some people complaining about the script not working for them. But I changed it to data1.cab lets see if that works.

And about the start/unix after some tests (on many difirent scripts) it works with no problem.

 

EDIT: New version of the script. Now uses a less common file to check if the cd is legit. Also the latest stable Wine is used lets see how it performs.

#!/bin/bash
# Date : (2016-01-21)
# Last revision : (2017-05-08)
# Wine version used : 2.0.1
# Distribution used to test : Ubuntu 17.04 x64
# Author : LinuxScripter
# Licence : GPLv3
 
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
 
TITLE="Majesty 2"
AUTHOR="LinuxScripter"
PREFIX="Majesty2"
EDITOR="Paradox Interactive"
GAME_URL="http://www.majesty2.com/"
WORKINGWINEVERSION="2.0.1"
 
POL_SetupWindow_Init
POL_Debug_Init
 
POL_SetupWindow_presentation "$TITLE" "$EDITOR" "$GAME_URL" "$AUTHOR" "$PREFIX"
 
# Setting prefix path
POL_Wine_SelectPrefix "$PREFIX"
 
# Downloading wine if necessary and creating prefix
POL_System_SetArch "x86"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"
 
POL_Call POL_Install_vcrun2005
POL_Call POL_Install_d3dx9
 
POL_SetupWindow_InstallMethod "DVD,STEAM"
 
if [ "$INSTALL_METHOD" == "DVD" ]; then
# Asking for CDROM and checking if it's correct one
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "0x0409.ini"
POL_Wine start /unix "$CDROM/setup.exe"
POL_Wine_WaitExit "$TITLE"
else
POL_Call POL_Install_steam
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/Steam"
POL_Wine "steam.exe" steam://install/25980
POL_Wine_WaitBefore "$TITLE"
fi
 
# Making shortcut
if [ "$INSTALL_METHOD" == "STEAM" ]; then
        POL_Shortcut "steam.exe" "$TITLE" "" "steam://rungameid/25980"
else
        POL_Shortcut "Majesty2.exe" "$TITLE" "" "Game;StrategyGame;"
fi
 
POL_SetupWindow_Close
exit 0

Edited by LinuxScripter


Dadu042 Monday 20 May 2019 at 22:14
Dadu042
Moderator

Copied to Supported apps.

Dadu042 Thursday 1 August 2019 at 22:56
Dadu042
Moderator

Oops I forgot to check the two first checkboxes,
script is now viewable at : https://www.playonlinux.com/en/app-3519.html