Forums

[Script] Rise of Nations

Auteur Réponses
ekultails Dimanche 20 Mars 2016 à 19:27
ekultailsAnonymous

This script supports:

  • Rise of Nations
  • Rise of Nations: Thrones and Patriots
  • Rise of Natoins: Gold Edition

Please note, that it does NOT support Rise of Nations: Extended Edition from Steam. There is no known workaround for it yet. Since the game engine was redesigned to utilize DirectX 10 instead of DirectX 9 there are some Wine compatibility issues.

This relies on Wine 1.7.18, a version known to work really well with Rise of Nations. The additional depdencies required for sound and video to work properly are: directmusic, dsound, mfc40, mfc42, msvcirt, msxml4, and vcrun6.

There is a false-positive report from PlayOnLinux that says that Wine has crashed when launching the installer. This can be ignored and this script does notify the user about it before it executes the launcher.

Outside of Wine, the Rise of Nations configuration file at "drive_c/users/$USER/Application Data/Microsoft Games/Rise of Nations/rise2.ini" is tweaked. The introduction and main menu videos do not work so they are disabled. That file can also be used for turning on/off fullscreen and setting any custom resolution. 

Test Environment:

  • Operating System: Fedora 23 x64
  • CPU: Intel Core i5-2410M
  • GPU: Intel HD Graphics 3000

Installation/Gameplay Screenshots:

  • https://drive.google.com/file/d/0Bz8JkuXmv9jfcXZseVJkZnpJY00/view?usp=sharing
  • https://drive.google.com/file/d/0Bz8JkuXmv9jfN2E4dVlwcHlFV28/view?usp=sharing
  • https://drive.google.com/file/d/0Bz8JkuXmv9jfSzdDcG85VUZQeEU/view?usp=sharing

Icons:

  • riseofnations-22x22.png
    • https://drive.google.com/file/d/0Bz8JkuXmv9jfT1RfV09oRy1sb3c/view?usp=sharing
  • riseofnations-48x48.png
    • https://drive.google.com/file/d/0Bz8JkuXmv9jfNVBXTC1BNUtteEE/view?usp=sharing
  • top.png
    • https://drive.google.com/file/d/0Bz8JkuXmv9jfTXJ2ZERZZFVlRk0/view?usp=sharing

[code language=playonlinux]
#!/bin/bash
# Rise of Nations - Play On Linux script
# Version: 0.1.0
# Installation Requirements: 
#    wine 1.7.18, directmusic, dsound, mfc40, mfc42, msvcirt, msxml4, vcrun6
# Author: ekultails@gmail.com
# Website: https://github.com/ekultails/playonlinux
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
# enable debugging
POL_Debug_Init
# set global variables
TITLE="Rise of Nations"
PREFIX="RoN"
FULL_POL_PREFIX="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
GAME_PATH="$FULL_POL_PREFIX/drive_c/Program Files/Microsoft Games/Rise of Nations"
# start the installation window
POL_SetupWindow_Init
POL_SetupWindow_presentation "$TITLE" "Big Huge Games" "http://bighugegames.com" "EkulTails" "$PREFIX"
# tell the user's about compatibility
POL_SetupWindow_message "This PlayOnLinux script will work with any version of the non-Steam Rise of Nations game. That includes the base Rise of Nations game, the Thrones and Patriots expansion, and the Gold Edition. The Steam version does not work because the game was rebuilt to use DirectX10 instead of DirectX9. Better support for DirectX10 in Wine is still a work-in-progress." "Compatibility"
# locate the CD mount point and then check to see if the required executable exists
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "Setup.exe"
# use our unique prefix for installing Wine
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "1.7.18"
# install required depedencies in the Wine environment
POL_Call POL_Install_directmusic
POL_Call POL_Install_dsound
POL_Call POL_Install_mfc40
POL_Call POL_Install_mfc42
POL_CALL POL_Install_msxml4
POL_CALL POL_Install_vcrun6
# inform the user about the false-positive PoL error
POL_SetupWindow_message "When the installation starts, PlayOnLinux will throw a false-positive error saying Wine crashed. Click \"Next\" and then continue on with the installation. After it is installed, close the launcher. DO NOT START THE GAME." "Read Before Installation"
# run the RoN installation and wait for it to complete
POL_Wine_WaitBefore "$TITLE"
POL_Wine "$CDROM/Setup.exe"
POL_Wine_WaitExit "$TITLE"
POL_SetupWindow_question "Are you also installing a seperate Thrones and Partiots expansion CD? Select \"No\" if you are only installing the base Rise of Nations game or the Rise of Nations: Gold Edition." "Expansion Pack Installation"
if [[ $APP_ANSWER == "TRUE" ]]; then
    POL_SetupWindow_cdrom
    POL_SetupWindow_check_cdrom "Setup.exe"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$CDROM/Setup.exe"
    POL_Wine_WaitExit "$TITLE"
fi
# this file needs a few tweaks for RoN to run smoothly
rise2ini_path="$FULL_POL_PREFIX/drive_c/users/$USER/Application Data/Microsoft Games/Rise of Nations"
rise2ini="$rise2ini_path/rise2.ini"
# create the rise2.ini file if it does not exist already
if [[ ! -d "$rise2ini_path" ]]; then
    mkdir -p "$rise2ini_path"
fi
if [[ ! -f $rise2ini ]]; then
    touch "$rise2ini"
fi
# delete these entries, if they exist
sed -i '/ForceGDICursor=/d' "$rise2ini"
sed -i '/ForceLowCPUBackgroundVid=/d' "$rise2ini"
sed -i '/SkipIntroMovies=/d' "$rise2ini"
# add the necessary values
echo -e "[RISE OF NATIONS]\nForceGIDCursor=1\nSkipIntroMovies=1\nForceLowCPUBackgroundVid=1\n" >> "$rise2ini"
# create the shortcut and exit
if [[ -f "$GAME_PATH/patriots.exe" ]]; then
    POL_Shortcut "patriots.exe" "$TITLE"
else
    POL_Shortcut "rise.exe" "$TITLE"    
fi
POL_SetupWindow_message "Installation successfully completed. Please submit any bugs to \"https://github.com/ekultails/playonlinux\". Enjoy!" "Rise of Nations Installed."
POL_SetupWindow_Close
exit 0
[/code]

 

ekultails Dimanche 20 Mars 2016 à 19:30
ekultailsAnonymous

I'm having some trouble with the PlayOnLinux code tags, but the script is still readable from my inital post.

#!/bin/bash
# Rise of Nations - Play On Linux script
# Version: 0.1.0
# Installation Requirements: 
#    wine 1.7.18, directmusic, dsound, mfc40, mfc42, msvcirt, msxml4, vcrun6
# Author: ekultails@gmail.com
# Website: https://github.com/ekultails/playonlinux
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
# enable debugging
POL_Debug_Init
# set global variables
TITLE="Rise of Nations"
PREFIX="RoN"
FULL_POL_PREFIX="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
GAME_PATH="$FULL_POL_PREFIX/drive_c/Program Files/Microsoft Games/Rise of Nations"
# start the installation window
POL_SetupWindow_Init
POL_SetupWindow_presentation "$TITLE" "Big Huge Games" "http://bighugegames.com" "EkulTails" "$PREFIX"
# tell the user's about compatibility
POL_SetupWindow_message "This PlayOnLinux script will work with any version of the non-Steam Rise of Nations game. That includes the base Rise of Nations game, the Thrones and Patriots expansion, and the Gold Edition. The Steam version does not work because the game was rebuilt to use DirectX10 instead of DirectX9. Better support for DirectX10 in Wine is still a work-in-progress." "Compatibility"
# locate the CD mount point and then check to see if the required executable exists
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "Setup.exe"
# use our unique prefix for installing Wine
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "1.7.18"
# install required depedencies in the Wine environment
POL_Call POL_Install_directmusic
POL_Call POL_Install_dsound
POL_Call POL_Install_mfc40
POL_Call POL_Install_mfc42
POL_CALL POL_Install_msxml4
POL_CALL POL_Install_vcrun6
# inform the user about the false-positive PoL error
POL_SetupWindow_message "When the installation starts, PlayOnLinux will throw a false-positive error saying Wine crashed. Click \"Next\" and then continue on with the installation. After it is installed, close the launcher. DO NOT START THE GAME." "Read Before Installation"
# run the RoN installation and wait for it to complete
POL_Wine_WaitBefore "$TITLE"
POL_Wine "$CDROM/Setup.exe"
POL_Wine_WaitExit "$TITLE"
POL_SetupWindow_question "Are you also installing a seperate Thrones and Partiots expansion CD? Select \"No\" if you are only installing the base Rise of Nations game or the Rise of Nations: Gold Edition." "Expansion Pack Installation"
if [[ $APP_ANSWER == "TRUE" ]]; then
    POL_SetupWindow_cdrom
    POL_SetupWindow_check_cdrom "Setup.exe"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$CDROM/Setup.exe"
    POL_Wine_WaitExit "$TITLE"
fi
# this file needs a few tweaks for RoN to run smoothly
rise2ini_path="$FULL_POL_PREFIX/drive_c/users/$USER/Application Data/Microsoft Games/Rise of Nations"
rise2ini="$rise2ini_path/rise2.ini"
# create the rise2.ini file if it does not exist already
if [[ ! -d "$rise2ini_path" ]]; then
    mkdir -p "$rise2ini_path"
fi
if [[ ! -f $rise2ini ]]; then
    touch "$rise2ini"
fi
# delete these entries, if they exist
sed -i '/ForceGDICursor=/d' "$rise2ini"
sed -i '/ForceLowCPUBackgroundVid=/d' "$rise2ini"
sed -i '/SkipIntroMovies=/d' "$rise2ini"
# add the necessary values
echo -e "[RISE OF NATIONS]\nForceGIDCursor=1\nSkipIntroMovies=1\nForceLowCPUBackgroundVid=1\n" >> "$rise2ini"
# create the shortcut and exit
if [[ -f "$GAME_PATH/patriots.exe" ]]; then
    POL_Shortcut "patriots.exe" "$TITLE"
else
    POL_Shortcut "rise.exe" "$TITLE"    
fi
POL_SetupWindow_message "Installation successfully completed. Please submit any bugs to \"https://github.com/ekultails/playonlinux\". Enjoy!" "Rise of Nations Installed."
POL_SetupWindow_Close
exit 0

Edité par ekultails

MTres19 Vendredi 20 Mai 2016 à 0:27
MTres19Anonymous

Overall the script looks good, but I have several things that could be corrected to make it better:

1. $PREFIX should have a more unique name than RoN. Not that it's likely that there will be another script that uses the same name, but it would be a good precaution to take.

2. The use of $HOME is discouraged, since it can't be relied upon to be set in all cases. $POL_USER_ROOT will point to /home/<user>/.PlayOnLinux, and can be relied upon to exist.

3. One should never use "Program Files" in a path. Wine translates this based on the set language, and it could be in, for example, Russian, for all you know. Use the $PROGRAMFILES variable instead. (e.g. $POL_USER_ROOT/wineprefix/$PREFIX/drive_c/$PROGRAMFILES/Microsoft Games/Rise of Nations)

4. Per PlayOnLinux contribution guidlines, messages must be translatable. It would be best to make your message about compatibility as concise as possible, leave the explanations for the description on the POL website, then wrap it in eval_gettext. For example:

POL_SetupWindow_message "$(eval_gettext 'This script is incompatible with the Steam version of Rise of Nations.')" "$TITLE"

5. As you also might have noticed in my example above, you should also keep the window title to "$TITLE". This keeps consistency, since many function scripts (i.e. those run with POL_Call) set the window title to "$TITLE" anyway.

6. There is no need for POL_SetupWindow_check_cdrom if you're only checking for Setup.exe. You should instead check for the presence of a file that will likely be unique to that CD.

7. If possible, you should avoid using old development versions of Wine. If 1.8.2 also works, it should be used since it is more likely to be already downloaded by another script. But if functionality is lost when moving to 1.8.2, you should stay with what you have. Or move to the latest development version, which is 1.9.10, I think.

8. While I can see that you have done research to find the POL_Calls you have, have you tested it first without any, then added them back in, one at a time, and omitted the ones that didn't do anything? The AppDB can be really useful, but lots of the tests are old or are people following old tutorials, and you kinda have to use the Scientific Method to sort through and find the tips that are actually helpful.

9. Try using:

POL_Wine --ignore-errors "$CDROM/Setup.exe"

If that doesn't work, the warning message should still be shortened. (See #4.) You also don't need to warn the user to not start the game upon exiting the installer. PlayOnLinux now warns a user about this when he or she first runs a script.

10. Except under certain very unusual circumstances, POL_SetupWindow_WaitBefore and POL_SetupWindow_WaitExit are not both needed. If the installer runs "synchronously" (i.e. the script is paused while the program executes), use POL_Wine_WaitBefore, and get rid of POL_Wine_WaitExit. If the program runs asynchronously (i.e. the script continues executing while the installer runs), use POL_Wine_WaitExit, since POL_Wine_WaitBefore doesn't pause the script.

11. Again, the long messages are a problem. (Don't worry, I've made this mistake too.) Just keep the question part, and make the window title "$TITLE".

12. Again, you should avoid using both POL_Wine_Wait* commands, and again POL_SetupWindow_check_cdrom isn't useful unless it's finding a unique file.

13. I would assume that $USER is also not reccommended. You can get the username from Wine, however, like this:

USERNAME=$(POL_Wine cmd /c echo "%USERNAME%" | tr -d '/015/012')
[ "$USERNAME" = "%USERNAME%" ] && USERNAME="$USER" # Fall back to $USER if Wine method fails

And then use $USERNAME instead of $USER. (That was pretty much copied from the POL_LoadVar_PROGRAMFILES function.)

14. A more elegant way to write multiple lines to a file would be:

cat <<EOF>"$rise2ini"
[RISE OF NATIONS]
ForceGDICursor=1
SkipIntroMovies=1
ForceLowCPUBackgroundVid=1
EOF

Though that doesn't really matter. I also noticed you had "ForceGIDCursor." I fixed that in the example above.

15. Ending success messages are not encouraged. However, you can add a link to your GitHub repository in the script description when you submit it, and you'll get emails when people comment on your script.

16. Lastly, and mostly just a personal preference of mine, is to separate parts of the script (initialization, finding the CD, running the setup, etc.) by blank lines. You don't have to bother with this; I just find it easier to read that way.

 

There you go. Hopefully I didn't sound too harsh---most of the issues are really quite minor.

Regards,

-

ekultails Mardi 25 Octobre 2016 à 5:38
ekultailsAnonymous

Thank you again, MTres19, for your invaluable feedback. :-)

 

I have updated the code to my PoL script to line up with all of your suggestions: [ https://github.com/ekultails/playonlinux/blob/master/rise_of_nations.pol ]. It has been tested on my local system to be working so hopefully others can try this out, too.

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmcayonlinux.com