Bay 12 Games Forum

Finally... => Creative Projects => Topic started by: McMagma on October 13, 2013, 11:43:51 am

Title: Batch Programming
Post by: McMagma on October 13, 2013, 11:43:51 am
Im trying to make a game in Batch and im having a problem with the %Random% in my healing command:
Code: [Select]
:Heal
echo You try to heal yourself
if %mana% geq 10 (
set /a mana=%mana%-%Random% %%10 +5
set /a hp=%hp%+%Random% %%20 +5
echo %name% Heals himself
echo %hp%
pause
cls
goto Monster
) else (
echo You dont have enough mana!(you need atleast 10)
)
pause
cls
goto Battle
Rest of the code:
Code: [Select]
@echo off
set hp=75
set maxhp=100
set monhp=70
set maxmonhp=100
set mana=25
set maxmana=50

:Start
cls
echo What is thy name
set /p name=
echo So your name is %name%!
pause
cls
echo Would you like to battle THE GREAT ORC?
set /p battle=
if %battle%==yes or %battle%==Yes or %battle%==y (
goto Battle
) else (
exit )

:Battle
cls
echo %name% it is your move! What would you like to do?
echo %name% HP %hp%/%maxhp% MANA %mana%/%maxmana%
echo THE ORC %monhp%/%maxmonhp%
echo.
echo Press S for Slash
echo Press H for Heal
echo Press M for Magic regen

set /p attack=
if %attack%==s goto Slash
if %attack%==h goto Heal
if %attack%==exit exit
if %attack%==m (
goto Mgrg
) else (
goto Battle )

:Slash
echo You Slash the Orc
set /a monhp=%monhp%+%Random% %%15 + 10
goto Monster

:Heal
echo You try to heal yourself
if %mana% geq 10 (
set /a mana=%mana%-%Random% %%10 +5
set /a hp=%hp%+%Random% %%20 +5
echo %name% Heals himself
echo %hp%
pause
cls
goto Monster
) else (
echo You dont have enough mana!(you need atleast 10)
)
pause
cls
goto Battle
I hope this is the right place on the forum, i know this isnt a programming forum or anything similiar but i hope someone knows Batch.
Thanks in advance ;)
Title: Re: Batch Programming
Post by: MorleyDev on October 13, 2013, 02:05:48 pm
Oh god why...I mean, that's certainly an interesting project. Did read an article on making PacMan in Batch files recently, actually.

Can you be more specific about what the problem is? Maybe recreate it with a minimal example? :)
Title: Re: Batch Programming
Post by: quinnr on October 13, 2013, 02:08:40 pm
Just a hunch, but perhaps try making %Random% all uppercase or all lowercase? Note that I know little to nothing about batch script programming...this is also assuming that random gives you nothing, not a number out of the range of the numbers you wanted, or something. More details would be helpful!
Title: Re: Batch Programming
Post by: Sensei on October 13, 2013, 05:33:24 pm
Maybe try making just a random number, and then using it on a separate line?
Title: Re: Batch Programming
Post by: Skyrunner on October 14, 2013, 08:22:45 am
Oh god why...I mean, that's certainly an interesting project. Did read an article on making PacMan in Batch files recently, actually.
o_O
Title: Re: Batch Programming
Post by: MrWillsauce on October 18, 2013, 12:55:03 pm
Is there a time keyword in batch programming? If so, you could just make your own little RNG like you would in a normal programming language.