My RPG game is messed up(saving and loading)
Posted: 26 Jan 2013 17:43
The saving/loading won't work
@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
@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