Batch File Game
Hello! This is my first instructable! Thanks for coming! I hope you are having fun!
Copy the Code and Paste It Into Notepad.
Copy this code and paste it into Notepad! :
@echo off
setlocal EnableDelayedExpansion
title Batch Game Series
::Stats
set hp=100
set maxhp=100
set monhp=100
set maxmonhp=100
set exp=1
set monexp=1
set money=1000
::Limits
set gunlimit=4
set aklimit=2
set c4limit=1
set maxak=2
set maxc4=1
::shop
set akstatus=n
set c4status=n
::Exp attack stats
set attack=0
::Order of Attacks
set order=0
::Armor
set armor=0
set monarmor=0
set maxarmor=2
set maxmonarmor=2
set attacknum=0
set monattacknum=0
set monwin=0
:Start
echo PRESS N IF YOU ARE A NEW USER
echo PRESS L TO LOAD A SAVE FILE
set /p start=
if %start% == n goto New
if %start% == l goto Load
:Load
(
set /p maxhp=
set /p monhp=
set /p maxc4=
set /p maxak=
set /p akstatus=
set /p c4status=
set /p name=
set /p exp=
set /p monexp=
set /p money=
set /p maxarmor=
set /p maxmonarmor=
set /p monwin=
)goto loadsc
:New
echo What is your name?
set /p name=
echo So your name is %name%
goto loadsc
:loadsc
echo PRESS B TO GOTO BATTLE
echo PRESS S TO SAVE
echo PRESS H TO GOTO THE SHOP
set /p loadsc=
if %loadsc% == s goto save
if %loadsc% == b goto Battle1
if %loadsc% == h goto shop
goto loadsc
:Battle1
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
goto Battle
:Battle
cls
echo %name% %hp% VS MONSTER %monhp% %name% %exp% MONSTER %monexp% $%money%
if %akstatus% EQU active echo PRESS A TO USE YOUR AK
if %c4status% EQU active echo PRESS C TO USE YOUR C4
echo PRESS P FOR A punch
echo PRESS K FOR A KICK
echo PRESS G FOR A GUN
echo PRESS S TO USE YOUR SWORD
set /p option=
if %option% == a goto preattack
if %option% == c goto preattack
if %option% == p goto preattack
if %option% == k goto preattack
if %option% == g goto preattack
if %option% == s goto preattack
:shop
cls
echo PRESS A AND PAY $500 FOR AN AK
echo PRESS AR AND PAY $1000 TO INCREASE YOUR ARMOR STATS
echo PRESS C AND PAY $1500 FOR A C4
echo PRESS H AND PAY 200 TO ADD 25 HP
echo PRESS AK TO ADD TO YOUR AK LIMITER AND PAY $700
echo PRESS C4 TO ADD TO YOUR C4 LIMITER AND PAY $1000
set /p shop=
if %shop% == a goto akbuy
if %shop% == ar goto aradd
if %shop% == c goto c4buy
if %shop% == h goto hpadd
if %shop% == ak goto akadd
if %shop% == c4 goto c4add
goto shop
:hpadd
if %money% lss 200 goto loadsc
set /a money=%money%-200
set /a maxhp=%maxhp%+25
set /a maxmonhp=%maxmonhp%+10
goto loadsc
:aradd
if %money% LSS 1000 goto loadsc
set /a money=%money%-1000
set /a maxarmor=%maxarmor%+1
goto loadsc
:c4add
if not %c4status% EQU active goto loadsc
if %money% lss 1000 goto loadsc
set /a money=%money%-1000
set /a maxc4=%maxc4%+1
goto loadsc
:akadd
if not %akstatus% EQU active goto loadsc
if %money% lss 700 goto loadsc
set /a money=%money%-700
set /a maxak=%maxak%+1
goto loadsc
:akbuy
if %money% lss 500 goto loadsc
set /a money=%money%-500
set akstatus=active
goto loadsc
:c4buy
if %money% lss 1500 goto loadsc
set /a money=%money%-1500
set c4status=active
goto loadsc
:save
(
echo %maxhp%
echo %maxmonhp%
echo %maxc4%
echo %maxak%
echo %akstatus%
echo %c4status%
echo %name%
echo %exp%
echo %monexp%
echo %money%
echo %maxarmor%
echo %maxmonarmor%
echo %monwin%
)>save.dlb
goto loadsc
:preattack
set /a order=%Random% * 2 / 32768 +1
if %order% EQU 1 goto preuser
if %order% EQU 2 goto monattack
:preuser
if %option% == a goto ak
if %option% == c goto c4
if %option% == p goto punch
if %option% == k goto kick
if %option% == g goto gun
if %option% == s goto sword
:ak
if not %akstatus% EQU active goto Battle
if %aklimit% LEQ 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 39 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a aklimit=%aklimit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:c4
if not %c4status% EQU active goto Battle
if %c4limit% LEQ 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 42 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a c4limit=%c4limit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:punch
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 17 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:kick
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 22 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:gun
if %gunlimit% leq 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 28 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a gunlimit=%gunlimit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:sword
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 24 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:space
goto monattack
:monattack
set /a monattacknum=%monattacknum%+1
set /a attack=%Random% * 39 / 32768 +1
set /a attack=%attack%+%monexp%
set /a armor=%Random% * %maxarmor% / 32768 +1
set /a armor=%armor%-%monattacknum%
if %armor% LEQ 0 set /a armor=0
set /a attack=%attack%-%armor%
set /a hp=%hp%-%attack%
if %hp% LEQ 0 goto loss
if %order% EQU 1 goto Battle
if %order% EQU 2 goto preuser
:loss
set /a monwin=%monwin%+1
set /a monexp=%monexp%+1
set /a money=%money%-50
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
set gunlimit=4
set attacknum=0
set monattacknum=0
if %monwin% GEQ 5 goto monaradd
echo You lose! Play again? Y,N?
set /p l=
if %l% == y goto loadsc
if %l% == n exit
:monaradd
set /a maxmonarmor=%maxmonarmor%+1
echo You lose! Play again? Y,N?
set /p l=
if %l% == y goto loadsc
if %l% == n exit
:win
set /a exp=%exp%+1
set /a money=%money%+50
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
set gunlimit=4
set attacknum=0
set monattacknum=0
echo You win! Play again? Y,N
set /p w=
if %w% == y goto loadsc
if %w% == n exit
Now Save it as BGS 7.bat
@echo off
setlocal EnableDelayedExpansion
title Batch Game Series
::Stats
set hp=100
set maxhp=100
set monhp=100
set maxmonhp=100
set exp=1
set monexp=1
set money=1000
::Limits
set gunlimit=4
set aklimit=2
set c4limit=1
set maxak=2
set maxc4=1
::shop
set akstatus=n
set c4status=n
::Exp attack stats
set attack=0
::Order of Attacks
set order=0
::Armor
set armor=0
set monarmor=0
set maxarmor=2
set maxmonarmor=2
set attacknum=0
set monattacknum=0
set monwin=0
:Start
echo PRESS N IF YOU ARE A NEW USER
echo PRESS L TO LOAD A SAVE FILE
set /p start=
if %start% == n goto New
if %start% == l goto Load
:Load
(
set /p maxhp=
set /p monhp=
set /p maxc4=
set /p maxak=
set /p akstatus=
set /p c4status=
set /p name=
set /p exp=
set /p monexp=
set /p money=
set /p maxarmor=
set /p maxmonarmor=
set /p monwin=
)goto loadsc
:New
echo What is your name?
set /p name=
echo So your name is %name%
goto loadsc
:loadsc
echo PRESS B TO GOTO BATTLE
echo PRESS S TO SAVE
echo PRESS H TO GOTO THE SHOP
set /p loadsc=
if %loadsc% == s goto save
if %loadsc% == b goto Battle1
if %loadsc% == h goto shop
goto loadsc
:Battle1
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
goto Battle
:Battle
cls
echo %name% %hp% VS MONSTER %monhp% %name% %exp% MONSTER %monexp% $%money%
if %akstatus% EQU active echo PRESS A TO USE YOUR AK
if %c4status% EQU active echo PRESS C TO USE YOUR C4
echo PRESS P FOR A punch
echo PRESS K FOR A KICK
echo PRESS G FOR A GUN
echo PRESS S TO USE YOUR SWORD
set /p option=
if %option% == a goto preattack
if %option% == c goto preattack
if %option% == p goto preattack
if %option% == k goto preattack
if %option% == g goto preattack
if %option% == s goto preattack
:shop
cls
echo PRESS A AND PAY $500 FOR AN AK
echo PRESS AR AND PAY $1000 TO INCREASE YOUR ARMOR STATS
echo PRESS C AND PAY $1500 FOR A C4
echo PRESS H AND PAY 200 TO ADD 25 HP
echo PRESS AK TO ADD TO YOUR AK LIMITER AND PAY $700
echo PRESS C4 TO ADD TO YOUR C4 LIMITER AND PAY $1000
set /p shop=
if %shop% == a goto akbuy
if %shop% == ar goto aradd
if %shop% == c goto c4buy
if %shop% == h goto hpadd
if %shop% == ak goto akadd
if %shop% == c4 goto c4add
goto shop
:hpadd
if %money% lss 200 goto loadsc
set /a money=%money%-200
set /a maxhp=%maxhp%+25
set /a maxmonhp=%maxmonhp%+10
goto loadsc
:aradd
if %money% LSS 1000 goto loadsc
set /a money=%money%-1000
set /a maxarmor=%maxarmor%+1
goto loadsc
:c4add
if not %c4status% EQU active goto loadsc
if %money% lss 1000 goto loadsc
set /a money=%money%-1000
set /a maxc4=%maxc4%+1
goto loadsc
:akadd
if not %akstatus% EQU active goto loadsc
if %money% lss 700 goto loadsc
set /a money=%money%-700
set /a maxak=%maxak%+1
goto loadsc
:akbuy
if %money% lss 500 goto loadsc
set /a money=%money%-500
set akstatus=active
goto loadsc
:c4buy
if %money% lss 1500 goto loadsc
set /a money=%money%-1500
set c4status=active
goto loadsc
:save
(
echo %maxhp%
echo %maxmonhp%
echo %maxc4%
echo %maxak%
echo %akstatus%
echo %c4status%
echo %name%
echo %exp%
echo %monexp%
echo %money%
echo %maxarmor%
echo %maxmonarmor%
echo %monwin%
)>save.dlb
goto loadsc
:preattack
set /a order=%Random% * 2 / 32768 +1
if %order% EQU 1 goto preuser
if %order% EQU 2 goto monattack
:preuser
if %option% == a goto ak
if %option% == c goto c4
if %option% == p goto punch
if %option% == k goto kick
if %option% == g goto gun
if %option% == s goto sword
:ak
if not %akstatus% EQU active goto Battle
if %aklimit% LEQ 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 39 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a aklimit=%aklimit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:c4
if not %c4status% EQU active goto Battle
if %c4limit% LEQ 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 42 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a c4limit=%c4limit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:punch
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 17 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:kick
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 22 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:gun
if %gunlimit% leq 0 goto Battle
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 28 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
set /a gunlimit=%gunlimit%-1
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:sword
set /a attacknum=%attacknum%+1
set /a attack=%Random% * 24 / 32768 +1
set /a attack=%attack%+%exp%
set /a monarmor=%Random% * %maxmonarmor% / 32768 +1
set /a monarmor=%monarmor%-%attacknum%
if %monarmor% LEQ 0 set /a monarmor=0
set /a attack=%attack%-%monarmor%
set /a monhp=%monhp%-%attack%
if %monhp% LEQ 0 goto win
if %order% EQU 1 goto space
if %order% EQU 2 goto Battle
:space
goto monattack
:monattack
set /a monattacknum=%monattacknum%+1
set /a attack=%Random% * 39 / 32768 +1
set /a attack=%attack%+%monexp%
set /a armor=%Random% * %maxarmor% / 32768 +1
set /a armor=%armor%-%monattacknum%
if %armor% LEQ 0 set /a armor=0
set /a attack=%attack%-%armor%
set /a hp=%hp%-%attack%
if %hp% LEQ 0 goto loss
if %order% EQU 1 goto Battle
if %order% EQU 2 goto preuser
:loss
set /a monwin=%monwin%+1
set /a monexp=%monexp%+1
set /a money=%money%-50
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
set gunlimit=4
set attacknum=0
set monattacknum=0
if %monwin% GEQ 5 goto monaradd
echo You lose! Play again? Y,N?
set /p l=
if %l% == y goto loadsc
if %l% == n exit
:monaradd
set /a maxmonarmor=%maxmonarmor%+1
echo You lose! Play again? Y,N?
set /p l=
if %l% == y goto loadsc
if %l% == n exit
:win
set /a exp=%exp%+1
set /a money=%money%+50
set hp=%maxhp%
set monhp=%maxmonhp%
set c4limit=%maxc4%
set aklimit=%maxak%
set gunlimit=4
set attacknum=0
set monattacknum=0
echo You win! Play again? Y,N
set /p w=
if %w% == y goto loadsc
if %w% == n exit
Now Save it as BGS 7.bat