Batch and Bash

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
Radar
Novice
Posts: 10
Joined: Sat Sep 01, 2018 3:36 pm

Batch and Bash

Post by Radar »

Greets Peeps,

Just thoght I'd drop a little batch file in here, (will drop a bash script once I've installed CSBWin for Linux on my NAS).

I currently have three dungeons, DM, CSB, and Conflux, with the following directory structure...

Code: Select all

\Games\
       |CSBWin\
               |Conflux
               |CSB
               |DM
...With only CSBWin.exe, config.txt (for 1280 x 800 screen) and my CSBWin.bat batch file.

The batch propts for which game you wish to play, at what resolution, then starts the game in the appropriate window size (well, for my 1920 * 1080 resolution with 125% test size, anyways).

Just copy, paste, and adjust to your layout.

Code: Select all

:: Basic Batch file for selecting Game and screen size.
:: Uses a single config.txt file (no need to copy different config.txt
::  for different screen sizes).

@echo off
echo Enter 1 for Dungeon Master.
echo Enter 2 for Chaos Strikes Back.
echo Enter 3 for Conflux: The Undercity.
:: echo Enter 4 for Dungeon 4
:: echo Enter 5 for Dungeon 5
:: To add a 4th custom dungeon, follow the above format, then
:: change the line below to "choice /C 1234 /N /T 9999 /D 1
choice /C 123 /N /T 9999 /D 1
:: Add extra error level for each new dungeon in descending order.
:: IF ERRORLEVEL 5 goto Dungeon5
:: IF ERRORLEVEL 4 goto Dungeon4
IF ERRORLEVEL 3 goto Conflux
IF ERRORLEVEL 2 goto CSB
IF ERRORLEVEL 1 goto DM

:: :Dungeon5
:: Replace <Dungeon5 Directory> with the name of the directory containing the new custom dungeon
:: set a=<Dungeon5 Directory>
:: goto ScreenSize

:: :Dungeon4
:: Replace <Dungeon4 Directory> with the name of the directory containing the new custom dungeon
:: set a=<Dungeon4 Directory>
:: goto ScreenSize

:Conflux
set a="Conflux"
goto ScreenSize

:CSB
set a="CSB"
goto ScreenSize

:DM
set a="DM"
goto ScreenSize

:ScreenSize
cls
echo Enter 1 for 320*200.
echo Enter 2 for 640*400.
echo Enter 3 for 960*600.
echo Enter 4 for 1280*800.
choice /C 1234 /N /T 9999 /D 3
IF ERRORLEVEL 4 goto 1280
IF ERRORLEVEL 3 goto 960
IF ERRORLEVEL 2 goto 640
IF ERRORLEVEL 1 goto 320

:1280
set b="EXTRALARGE"
set c="1300"
set d="820"
goto run

:960
set b="VERYLARGE"
set c="980"
set d="660"
goto run

:640
set b="LARGE"
set c="660"
set d="460"
goto run

:320
set b="SMALL"
set c="340"
set d="280"
goto run

:run
cd %a%
start ..\CSBwin directory=".\" SIZE=%b% x=0 y=0 width=%c% height=%d% directx
exit
Have fun!
Radar =8^)
Radar
Novice
Posts: 10
Joined: Sat Sep 01, 2018 3:36 pm

Re: Batch and Bash

Post by Radar »

Greets peeps ;)

Well, I did the batch the other night, so here's the bash.
I installed CSBwin into /usr/games/CSBWin,so it looks like...

Code: Select all

/usr/games/
          |CSBWin/
                 |Conflux
                 |CSB
                 |DM
Change the paths in the script to suit

Code: Select all

#!/bin/bash
echo "Enter 1 for Dungeon Master"
echo "Enter 2 for Chaos Strikes Back!"
echo "Enter 3 for Conflux"
# echo "Enter 4 for AnotherDungeon "
# echo "Enter 5 for AnotherOtherDungeon"

a="/usr/games/CSBWin"
b="echo It seems you already have a file in your home directory called "
d="echo so I can't create the save-game directory."
e=exit;

read n
case $n in
    1) c=DM ;;
    2) c=CSB ;;
    3) c=Conflux ;;
#    4) c=AnotherDungeon ;;
#    5) c=AnotherOtherDungeon ;;
    *) echo "You have to pick one of them to play!"
       exit ;;
esac
# See if we already have a file with the same name as our intended save directory in our home directory.
        if [[ -e ~/$c && ! -d ~/$c ]]
        then
# If we do have a file with the same name, tell us about it, then quit.
# If we already have a save-game directory in our home directory, everything up to the clear command is skipped.
        $b $c
        $d
        $e
# If we don't have a save-game directory, create one in our home directory now.
                elif [ ! -e ~/$c ]
                then
                mkdir ~/$c
                fi

clear

echo Enter 1 for 320*240.
echo Enter 2 for 640*480.
echo Enter 3 for 960*720.
echo Enter 4 for 1280*960.
echo Enter 5 for 1600*1050.
echo Enter 6 for 1920*1080.

read n
case $n in
     1) f="small" ;;
     2) f="large" ;;
     3) f="verylarge" ;;
     4) f="extralarge" ;;
     5) f="extremelylarge" ;;
     6) f="humongous" ;;
     *) f="small" ;;
esac

# Delete the word "echo"  and the double quotes from the line below.
echo " $a/CSBWin --directory $a/ --module $a/$c/ --dungeon $a/$c/dungeon.dat --gamsav ~/$c/ --$f"
I've left it so that the final command is just printed to the screen, rather than executed, because I couldn't get CSBWin to run
on my headless linux box. I tried both the 32bit and 64bit versions, the ldd command tells me that I have all the correct libraries
that they require, but all I get is this...

Code: Select all

CSBwin 15.7v0
Message:
  Flags = 00000001
  Title = (null)
  Message = System Error  0x00003512
SystemError
terminate called after throwing an instance of 'int'
Aborted
Anyroad, the script works, so if you have a couple of people that like playing CSBWin, you don't have to worry about their saves stomping all over each other.

Have fun!
Radar =8^)
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”