Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Batch Programming  (Read 3476 times)

McMagma

  • Bay Watcher
  • McMagma, Fortress Addict.
    • View Profile
Batch Programming
« 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 ;)
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: Batch Programming
« Reply #1 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? :)
Logged

quinnr

  • Bay Watcher
    • View Profile
Re: Batch Programming
« Reply #2 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!
Logged
To exist or not exist, that is the query. For whether it is more optimal of the CPU to endure the viruses and spam of outragous fortune, or to something something something.

Sensei

  • Bay Watcher
  • Haven't tried coffee crisps.
    • View Profile
Re: Batch Programming
« Reply #3 on: October 13, 2013, 05:33:24 pm »

Maybe try making just a random number, and then using it on a separate line?
Logged
Let's Play: Automation! Bay 12 Motor Company Buy the 1950 Urist Wagon for just $4500! Safety features optional.
The Bay 12 & Mates Discord Join now! Voice/text chat and play games with other Bay12'ers!
Add me on Steam: [DFC] Sensei

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: Batch Programming
« Reply #4 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
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MrWillsauce

  • Bay Watcher
  • Has an ass that won't quit
    • View Profile
Re: Batch Programming
« Reply #5 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.
Logged