Articles

Batch RPG game won't load after saved please help???

January 26, 2013 at 18:29:10
Specs: Windows XP

@echo off
title RPG
mode 1000
:main
cls
echo Welcome to the game...
echo.
echo 1.start
echo 2.exit
set /p $=enter:

if %$% equ 1 goto start
if %$% equ 2 exit
goto main

:start
cls
setlocal enabledelayedexpansion
set /p name=Enter you name:
if exist QE%name%sav.dll set load=1
goto new

:new
set hp=100
set exp=0
set exptill=60
set gold=50
set lvl=1
set power=4
set powergain=3
set weappower=2
set weapprice=120
set pots=1
set armor=10
goto home

:load
for /f %%a in (QE%name%SAV.dll) do set %%a
set /a temp2=(%hp% * %lvl% + %exp% * %exptill% + %weapprice% + %power% * %weappower%)/(%gold% + %pots% * %powergain%)
if not %temp1% equ %temp2% set temp3=1
goto home

:death
cls
echo You Died!
echo You Lost some stuff...
set /a exp=%exp% - (%exp% * 65/100)
set hp=1
pause>nul
goto home

:runaway
cls
echo You successfully ran away!
set hp=1
pause>nul
goto home

:levelup
cls
echo Congrats! LEVEL UP!
pause>nul
set /a lvl=%lvl% + 1
set /a exp=%exp% - %exptill%
set /a exptill=%exptill% + %exptill% * 66 / 100
set /a power=%power% + %powergain%
set /a powergain=%powergain% + 1
set hp =100
goto save

::# HOME ##############################################

:home
set en1hp=40
set en2hp=80
set en3hp=160
if %exp% geq %exptill% goto levelup
cls
if "%temp3%" equ "1" echo you are a cheater...
echo level %lvl%/ experience %exp%/%exptill% armor %armor%
echo health %hp%/100 gold %gold% potions %potions%
echo.
echo Where do you want to go?
echo.
echo 1.Outside the village
echo 2.shop
echo 3.healer
echo 4.save game
echo 5.exit
echo.
set /p input=Enter:
if %input% equ 1 goto out
if %input% equ 2 goto shop
if %input% equ 3 goto healer
if %input% equ 4 goto save
if %input% equ 5 goto exit
goto home

:: # Enemy1 ############################################

:out
set en1hp=40
cls
echo You were attacked by a goblin!
pause>nul
goto fightgoblin

:fightgoblin
cls
echo You have %hp% health
echo Goblin has %en1hp%
echo.
echo 1.Attack
echo 2.Drink potion
echo 3. RUN AWAY!
set input=5
set /p input= Enter:
if %input% equ 1 goto attackgoblin
if %input% equ 2 goto drinkpotgoblin
if %input% equ 3 goto runaway

:attackgoblin
cls
set /a en1hp=%en1hp% - (%power% + %weappower%)
if %en1hp% leq 0 goto killedgoblin
set /a hp=%hp% - (7 - %armor%)
if %hp% leq 0 goto death
goto fightgoblin

:drinkpotgoblin
if %pots% 1ss 1 (
echo You don't have any potions
pause>nul
goto fightgoblin
)
set /a hp = %hp% + 50
set /a pots=%pots% - 1
goto fightgoblin

:killedgoblin
cls
echo YOU KILLED HIM!
echo You gained 7 exp and 6 gold
set /a exp=%exp% + 7
set gold=%gold% + 6
pause>nul
goto out2


:: # enemy 2 ########################################
:out2
cls
echo 1.Go further
echo 2.wait Here
echo 3.go home
set /p input=Enter:
if %input% equ 1 goto out3
if %input% equ 2 goto out2
if %input% equ 3 goto home
goto out2

:out3
set en2hp=80
cls
echo You have %hp% health
echo skeleton has %en2hp%
echo.
echo 1.attack
echo 2.Drink potion
echo 3. Run Away
set /p input=Enter:
if %input% equ 1 goto attackskeleton
if %input% equ 2 goto drinkpotskeleton
if %input% equ 3 goto runaway
goto fightskeleton

:attackskeleton
cls
set /a en1hp=%en1hp% - (%power% + %weappower%)
if %en1hp% leq 0 goto killedskeleton
set /a hp=%hp% - (7 - %armor%)
if %hp% leq 0 goto death
goto fightskeleton

:drinkpotskeleton
if %pots% 1ss 1 (
echo You don't have any potions
pause>nul
goto fightskeleton
)
set /a hp = %hp% + 50
set /a pots=%pots% - 1
goto fightskeleton

:killedskeleton
cls
echo YOU KILLED HIM!
echo You gained 7 exp and 6 gold
echo There's more of them
set /a exp=%exp% + 7
set gold=%gold% + 6
pause>nul
goto out3

:fightskeleton
cls
echo You have %hp% health
echo skeleton has %en1hp%
echo.
echo 1.Attack
echo 2.Drink potion
echo 3.RUN AWAY!
set /p input= Enter:
if %input% equ 1 goto attackskeleton
if %input% equ 2 goto drinkpotskeleton
if %input% equ 3 goto runaway

:: # save ############################################

:save
if "%temp3%" equ "1" (
cls
echo You're a cheater, YOU NO SAVE!
pause>nul
goto stats
)
echo saving...
set /a temp2=(%hp% * %lvl% + %exp% * %exptill% + %weapprice% + %power% * %weappower%)/(%gold% + %pots% * %powergain%)
(echo hp=%hp%)>> QE%name%SAV.dll
(echo exp=%exp%)>> QE%name%SAV.dll
(echo exptill=%exptill%)>> QE%name%SAV.dll
(echo gold=%gold%)>> QE%name%SAV.dll
(echo lvl=%lvl%)>> QE%name%SAV.dll
(echo power=%power%)>> QE%name%SAV.dll
(echo powergain=%powergain%)>> QE%name%SAV.dll
(echo weappower=%weappower%)>> QE%name%SAV.dll
(echo weapprice=%weapprice%)>> QE%name%SAV.dll
(echo pots=%pots%)>> QE%name%SAV.dll
(echo armor=%armor%)>> QE%name%SAV.dll
(echo temp1=%temp1%)>> QE%name%SAV.dll
goto stats

:stats
cls
echo %name% %lvl%
echo %exp%/%exptill% expierience
echo.
echo %hp%/100 health
echo %gold% gold
echo %pots% potions
echo.
echo Your power is %power%
echo Your weapon power is %weappower%
echo.
echo PRESS ANY KEY
pause>nul
goto home


:healer
cls
set hp=100
echo you've been healed.
pause
goto home

:shop
cls
echo armor costs 15 gold
echo.
echo Potions cost 20 gold
echo.
echo If you have -gold you have a debt to pay, which you can pay by killing things.
echo.
echo 1.Go back
echo 2.Buy armor
echo 3.Buy potions
set /p input=enter:

if %input% == 1 goto home
if %input% == 2 goto buy
if %input% == 3 goto buy2


:buy
set armor= %armor% + 10
set gold= %gold% - 15
goto home


:buy2
set potions= %pots% + 1
set gold= %gold% - 20
goto home


See More: Batch RPG game wont load after saved please help???

Report •


#1
January 26, 2013 at 20:35:30

Ha! you get 100 HP for persistance and 1000 HP for patience ;-)
Might be, you're accumulating the file QE%namer%SAV.dll every time the game is played, which (i would guess) is not your intention. Number of ways to handle, depending: 1) delete or move the file, 2) name each file unique (date+timestamp or serial), or clear the file with a null output (f/e under the SAVE:
set temp=>QE%name%SAV.dll
#2 leaves options of re-starting from various "save-points".
I might be wrong, I didn't read the whole code, just the loading and save parts.

Report •

#2
January 27, 2013 at 08:24:08

It looks like you are not loading the settings

try changing this
if exist QE%name%sav.dll set load=1
to this
if exist QE%name%sav.dll set load=1 && goto load

edit: btw kinda genious using a .dll to hide game information from the unwise. I like it.

:: mike


Report •

#3
January 27, 2013 at 08:35:28

mikelinus: kinda genious using a .dll to hide game information
I'm not entirely sure you want to have the anti-virus go scan crazy because you're too lazy to pick a proper extension, but what do I know? I'm not a crazy person who tries to use batch files to make RPGs.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
January 27, 2013 at 08:58:21

Fair enough Razor2.3, something I should have considered. I was just thinking it was an easy way to skip the "cheating" aspect. Forethought tends to be a weakness of mine.

:: mike


Report •


Ask Question