0

I am making a game dealing with four different attacks, it is my crummy Pokemon ripoff, but when I play and use one of the attacks for the first time, the enemy's health doesn't change. It only happens with one attack called "stab".

set /p attack= I will...
if '%Attack%'=='firebolt' set /a mana=%mana%-40-%exp% & set /a monsterhealth=%monsterhealth%-60-%exp% & echo You set ablaze the %monster%! & goto cam
if '%Attack%'=='block' goto ctblockm & echo You stand ready to block! 
if '%Attack%'=='regeneratemana' set /a mana=%mana%+40 & echo You have regenerated 40 points of Mana by using your special ability! & goto cam
if '%Attack%'=='stab' goto stabm 
if not '%Attack%'==[['firebolt']]-o[['stab']]-o[['block']]-o[['regeneratemana']] echo check spelling 
if '%mana%' lss 1 goto nomanam
pause
goto cm


:stabm
set max1=4
set min1=1
Set /A dmg=%random% %% (max1 - min1 + 1)+ min1 & echo you ready your blade for a lethal strike!
if '%dmg%'=='1' set stabdmg=30 & set /a monsterhealth=%monsterhealth%-%stabdmg%-%exp% & echo You strike!
if '%dmg%'=='2' set stabdmg=30 & set /a monsterhealth=%monsterhealth%-%stabdmg%-%exp% & echo You strike!
if '%dmg%'=='3' set stabdmg=30 & set /a monsterhealth=%monsterhealth%-%stabdmg%-%exp% & echo You strike!
if '%dmg%'=='4' set stabdmg=50 & set /a monsterhealth=%monsterhealth%-%stabdmg%-%exp% & echo critical hit! 
goto cam 

If you want me to edit it for more detail, please ask me to in the comments. Thank you!

S Blas
  • 3
  • 3
  • 2
    On an unrelated note, I don't know what you think `[['firebolt']]-o[['stab']]-o[['block']]-o[['regeneratemana']]` does, but that's not valid batch syntax. – SomethingDark Oct 13 '15 at 01:55

2 Answers2

0

It's so obvious where's your problem is, you did not add percent signs around "max1" and "min1" on the 3rd line after :stabm. Please check typos first before posting questions.

Happy Face
  • 1,061
  • 7
  • 18
  • That is not the issue. The problem is that the first time you use the attack in a round, it doesn't work, however it works the second time you use it in the same round. Adding in the % signs would do nothing, but thank you for replying. – S Blas Oct 13 '15 at 01:53
  • @SBlas - except to use variables, you _must_ surround them with `%` symbols, otherwise you are using a literal string. So even if this doesn't solve your immediate problem, it will solve another one further down the line. – SomethingDark Oct 13 '15 at 01:55
  • 1
    @darkfang: the Syntax without percent-signs is ok for `set /a` (sometimes even better - see my answer) – Stephan Oct 13 '15 at 06:36
0

Problem: a line is parsed at once one time, so variables Keep their values before that line:

if '%dmg%'=='1' set stabdmg=30 & set /a monsterhealth=%monsterhealth%-%stabdmg%-%exp% & echo You strike!

You set stabdmg but %stabdmg% is still the value before that. You Need either delayed expansion or the same Syntax as in the 3rd line (without percent-signs):

if '%dmg%'=='1' set stabdmg=30 & set /a monsterhealth=monsterhealth-stabdmg-exp & echo You strike!

(the same for the next three lines of Course)

Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91