The forum

[Script] The Matrix: Path of Neo

Author Replies
Xenos5 Saturday 5 April 2014 at 0:55
Xenos5

Hi
I have written a script for The Matrix: Path of Neo. It is the third Matrix game, made in 2005, where you follow Neo through the three movies and play through many scenes from the movies, and many additional scenes. Full of cool fighting, gunplay and slow motion badassery.

The game works, and works well. There's a bug on Nvidia cards where your screen gets a blue tinge when firing bullets in slow motion; this is fixed by disabling GLSL. I ask the user in the script which brand of card he has. Not sure if there's a function for picking it up automatically.

[code language=playonlinux]
#!/bin/bash
# Date : (2014-04-04 18:56)
# Last revision : (2014-04-05 11:27)
# Wine version used : 1.7.10-CSMT-a632585
# Distribution used to test : Arch Linux
# Author : Alexander Borysov
# Script licence : GPLv3
# Program licence: Proprietary

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

TITLE="The Matrix: Path of Neo"
PREFIX="MatrixPathOfNeo"

POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$PREFIX/left.jpg" "$TITLE"

POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Atari" "http://atari.com" "Alexander Borysov" "$PREFIX"
POL_Call POL_Function_NoCDWarning
POL_Wine_SelectPrefix "$PREFIX"
POL_SetupWindow_wait "$(eval_gettext "Please wait while the wine prefix is created.")" "$TITLE"
POL_Wine_PrefixCreate "1.7.10-CSMT-a632585"

POL_SetupWindow_InstallMethod "LOCAL,DVD"

if [ "$INSTALL_METHOD" = "DVD" ]; then
    POL_SetupWindow_cdrom
    POL_SetupWindow_check_cdrom "PoN.ico"
    POL_Wine "$CDROM/setup.exe"
    POL_Wine_WaitExit "$TITLE"
elif [ "$INSTALL_METHOD" = "LOCAL" ]; then
    POL_SetupWindow_browse "$(eval_gettext "Please select the setup file to run.")" "$TITLE"
    POL_Wine "$APP_ANSWER"
    POL_Wine_WaitExit "$TITLE"
fi

# fix a bug on Nvidia where the screen becomes bluer and bluer with each bullet fired in slow motion
POL_Wine_DetectCard
[ "$DRVID" = "NVIDIA" ] && POL_Wine_Direct3D "UseGLSL" "disabled"

POL_Wine_Direct3D "CSMT" "enabled"

POL_SetupWindow_VMS "128"
POL_Shortcut "Matrix3.exe" "$TITLE" "The Matrix: Path of Neo.png"

POL_SetupWindow_Close
exit
[/code]

Screenshots:
Lobby Shootout

Subway Fight

Smiths Fight
Icons/images:
48x48: 48x48
22x22: 22x22
top: Top
left: Left

Edited by Xenos5

Xenos5 Sunday 6 April 2014 at 13:00
Xenos5

Here's a script for installing the latest update. It comes in two patches, 'Update 1', and 'Update 1 to 2'; this script installs one, then the other, in order to get it to the latest version.

If it's possible/wanted, I'd like to contribute the gamefront download function to the Functions category in PoL, for future use by anybody.
EDIT: This has been done: see POL_Gamefront_Download

And if there aren't any issues with the game scripts, I'd like to get them into the repo too. :)

#!/bin/bash
# Date : (2014-04-06T10:42Z)
# Last revision : (2014-04-06T10:42Z)
# Distribution used to test : Arch Linux
# Author : Alexander Borysov
# Script licence : GPLv3
# Program licence: Proprietary

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

install_patch () {
    local ID="$1"
    local FILENAME="$2"
    local NAME="$3"
    local MD5="$4"

    if [ "$INSTALL_METHOD" = "DOWNLOAD" ]; then
        local URI="${POL_System_TmpDir}/$FILENAME"
        POL_Call POL_Gamefront_Download "$ID" "$POL_System_TmpDir" "$URI" "$NAME"
        PATCHNAME="$URI"
    else
        POL_SetupWindow_browse "$NAME: $(eval_gettext "Please select the setup file to run.")" "$TITLE"
        PATCHNAME="$APP_ANSWER"
    fi

    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$PATCHNAME"
}

TITLE_REQUIRED="The Matrix: Path of Neo"
TITLE="$TITLE_REQUIRED Update 2"
PREFIX="MatrixPathOfNeo"


POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.png" "http://files.playonlinux.com/resources/setups/$PREFIX/left.png" "$TITLE"
POL_SetupWindow_Init
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Atari" "http://atari.com" "Alexander Borysov" "$PREFIX"

if [ "$(POL_Wine_PrefixExists $PREFIX)" != "True" ]; then
    POL_SetupWindow_message "$(eval_gettext 'Please install $TITLE_REQUIRED first')" "$TITLE"
    POL_SetupWindow_Close
    exit
fi

POL_Wine_SelectPrefix "$PREFIX"

POL_SetupWindow_InstallMethod "LOCAL,DOWNLOAD"

[ "$INSTALL_METHOD" = "DOWNLOAD" ] && POL_System_TmpCreate "$PREFIX"
install_patch 4344398 "pathofneo_retail-update1_usa.exe" "$TITLE_REQUIRED Update 1" "2481b5c1b40471345b839e53b7b38da9"
install_patch 4560917 "pathofneo_update1-to-update2_usa.exe" "$TITLE_REQUIRED Update 1-2" "2edfe8414403b6e3517a83edc7d6b5da"

POL_SetupWindow_Close
exit

Edited by Xenos5

petch Monday 7 April 2014 at 21:02
petch

petch Monday 7 April 2014 at 21:11
petch

About the script itself now,

if [ ! -e "$REPERTOIRE/wineprefix/$PREFIX" ]; then
...


You can use
if [ "$(POL_Wine_PrefixExists $PREFIX)" != "True" ]; then

to the same effect (and slightly less tied to PlayOnLinux user data layout).

I'm personally not convinced by the syntax of arrays in Bash so I'd go for abstracting all the processing of one patch in a function then call it twice with all the required parameters, but that's a matter of taste...

Regards,
Pierre.
Xenos5 Tuesday 8 April 2014 at 0:55
Xenos5

Yeah, I designed it like that simply from a software architecture point of view. The syntax is pretty horrifying, but it does decrease the script size by 10-15 lines, so I went for it. You can't actually make a function for it without lots of duplication, because I loop through the patch names both in the DOWNLOAD branch and the LOCAL branch, so instead I'm just going to add a few comments to explain the arcane syntax, and leave it. :P
But a side question: is there any reason PoL didn't just use Python for scripts? It seems a lot friendlier than Bash to non-programmers.

Script-wise: I edited the above post. The patch script now uses the POL_Gamefront_Download function (thank you), the better prefix test, and has some for loop comments.

EDIT: Disregard the below. I just discovered POL_Wine_DetectCard, and I've edited the main script to use it. I also forgot to enable CSMT, so I added a line to do that too.
-----------------------
Regarding the actual game script, here's a proposed function for detecting the GPU brand. I don't have access to a computer with an AMD or an Intel GPU, so I can't actually test that the vendor strings contain " AMD " or " Intel ", but it seems reasonable.
local VENDOR_STR=`glxinfo | grep 'server glx vendor string'`
POL_Debug_Trace "Vendor string: $VENDOR_STR"
local BRANDS=( AMD Nvidia Intel )
for i in $(seq 0 $((${#BRANDS[@]} - 1)))
do
    local BRAND="${BRANDS[$i]}"
    if echo "$VENDOR_STR" | grep -i " $BRAND " > /dev/null; then
        POL_Debug_Message "Detected GPU brand: $BRAND"
        local RESULT="$BRAND"
        break
    fi
done
if [ "$RESULT" = "" ]; then
    local OPTIONS=$(printf "%s~" "${BRANDS[@]}")
    local UNKNOWN="Don't Know"
    POL_SetupWindow_menu "$(eval_gettext "What is your graphics card brand?")" "$TITLE" "${OPTIONS}${UNKNOWN}" "~"
    if [ "$APP_ANSWER" != "$UNKNOWN" ]; then
        local RESULT="$APP_ANSWER"
    fi
fi
GPU_BRAND="$RESULT"

Edited by Xenos5

Xenos5 Tuesday 8 April 2014 at 13:52
Xenos5

I requested signatures for both scripts, unless there are any more suggestions. I hope I did all the shortcut/icon stuff correctly...
petch Tuesday 8 April 2014 at 19:04
petch

Yeah, I designed it like that simply from a software architecture point
of view. The syntax is pretty horrifying, but it does decrease the
script size by 10-15 lines, so I went for it. You can't actually make a
function for it without lots of duplication, because I loop through the
patch names both in the DOWNLOAD branch and the LOCAL branch

Quote

What about something like

install_patch () {
  local NAME="$1"
  local ID="$2"
  local MD5="$3"

  if [ "$INSTALL_METHOD" = "DOWNLOAD" ]; then
    cd "${POL_System_TmpDir}"
    POL_Call POL_Gamefront_Download "$ID" "$POL_System_TmpDir" "$NAME" "$NAME"
    PATCHNAME="${POL_System_TmpDir}/$NAME"
  else
    POL_SetupWindow_browse "$NAME: $(eval_gettext "Please select the setup file to run.")" "$TITLE"
    PATCHNAME="$APP_ANSWER"
  fi

  POL_Wine_WaitBefore "$TITLE"
  POL_Wine "$PATCHNAME"
}

[ "$INSTALL_METHOD" = "DOWNLOAD" ] && POL_System_TmpCreate "$PREFIX"
install_patch "$TITLE_REQUIRED Update 1" 4344398 "2481b5c1b40471345b839e53b7b38da9"
install_patch "$TITLE_REQUIRED Update 1-2" 4560917 "2edfe8414403b6e3517a83edc7d6b5da" 



But a side question: is there any reason PoL didn't just use Python for
scripts? It seems a lot friendlier than Bash to non-programmers.

Quote

Because PlayOnLinux started as a Bash program.

About the function proposal, there's already existing GPU detection routines (for POL_Wine_SetVideoDriver), so this function won't be added without a good use case. It's not PlayOnMac compatible, either. But it seems you found it by yourself already...

Edited by petch

Xenos5 Tuesday 8 April 2014 at 19:56
Xenos5

Yeah, that's a pretty good solution actually. Updated in the post. Can't cancel the signature request, though.
petch Tuesday 8 April 2014 at 20:58
petch

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 dmca-notice@playonlinux.com