Page 1 of 1

It's a little bit failing fight simulator.

Posted: 12 Jan 2012 13:12
by Mattis95
Ok, I have made a some-kind-of fight simulator. But when going from attack phase or defend phase, it says something about an - that shouldn't be there. But the thing is, I don't have any - on any place where it shouldn't be. If someone could see what the problem is, please tell me! And this is just a little bit modified part of the whole file.

Code: Select all

@echo off
set def=4
set atk=5
set lol=0
set max=12
set min=6
set name=Mattis95
set mon=monster
set monhp=30
set manhp=40
set maxman=40
set maxmon=30
set potn=3
set atk=5
set def=4
goto batmen

:batmen
cls
title ::::::::BATTLE MENU::::::::
echo    ::::::::BATTLE MENU::::::::
echo.
echo Your hp: %manhp%/%maxman%
echo The %mon%'s hp: %monhp%/%maxmon%
echo You have %potn% pot(s).
echo 1) Attack the %mon%
echo 2) Just defend (nearly the same as skip)
echo 3) Drink a potion
set /p bch=
if %bch% == 1 goto attack
if %bch% == 2 goto defend
if %bch% == 3 goto potion

:attack
title ::::ATTACK::::
set /a mandmg=%random% %% (max - min + 1)+min
echo You attack the %mon% and deal %mandmg%+%atk% hp.
set /a monhp=%monhp% - %mandmg% - %atk%
if %monhp% leq 0 goto yay
set /a mondmg=%random% %% (max - min + 1)+ min
echo The %mon% attacks you and deals %mondmg%-%def%!
set manhp=%manhp% - 10 + %def%
set /a lol=%lol% + 1
pause
if %manhp% leq 0 goto no
goto batmen

:defend
title ::::DEFEND::::
echo You defend.
pause
set /a mondmg=%random% %% (max - min + 1)+ min
echo The %mon% attack you and deals %mondmg%-%def%.
set manhp=%manhp% - %mondmg% + %def%
pause
if %manhp% leq 0 goto no
goto batmen
:potion
title ::::POTION::::
echo You have %potn% potions. Do you really want to use one?
set /p yn=(yes/no)
if %yn% == no goto batmen
echo Ok, you drink one and refill your hp by 10.
pause
echo If it goes over %maxman%, it will stop at %maxman%.
set /a manhp=%manhp% + 10
if %manhp% gtr %maxman% set manhp=%maxman%
pause
goto batmen
:no
cls
title lose...
echo Sorry, really sorry.
pause
echo You... Lost!
pause
echo.
echo Do you want to play again?
set /p yn=(yes/no)
if %yn% == yes goto top
if %yn% == no exit

Re: It's a little bit failing fight simulator.

Posted: 12 Jan 2012 13:35
by dbenham
Comment out the @echo off at the top and run the program. You should then be able to see which line is causing the problem.

Also, at least one of your SET statements is missing the /A option. But that shouldn't be causing your syntax error.


Dave Benham

Re: It's a little bit failing fight simulator.

Posted: 12 Jan 2012 14:08
by jeb
dbenham wrote:Comment out the @echo off at the top and run the program. You should then be able to see which line is causing the problem.
Yes, that will show you your problem
Programming without the knowledge of debugging is useless.

dbenham wrote:Also, at least one of your SET statements is missing the /A option. But that shouldn't be causing your syntax error.
But this is exactly the probem :) :!:

jeb

Re: It's a little bit failing fight simulator.

Posted: 12 Jan 2012 14:41
by dbenham
jeb wrote:
dbenham wrote:Also, at least one of your SET statements is missing the /A option. But that shouldn't be causing your syntax error.
But this is exactly the probem :) :!:
Yes - it is the root of the problem. But the SET line is not generating the syntax error. :lol:


Dave Benham

Re: It's a little bit failing fight simulator.

Posted: 13 Jan 2012 10:35
by Mattis95
Thanks! I have no idea how I could miss that... But it helped and got it working!