I strongly suspect that you have set a variable random
. If you've done that, then the value that you set in the environment overrides the magic variable.
You can clear it by set "random="
It's normal practice to use a setlocal
after your @echo off
. That way, any changes you make to the envirnment are backed out when the batch terminates. Without it, any changes made will remain until they are explicitly changed again.
Personally, I prefer
set /a value=%random% %% limit + 1
to generate a value 1..limit. If for no other reason, it's easier to type.
@echo off
setlocal
rem environment changes made after here will be backed-out when the batch finishes...
....whatever....
The setlocal
command sets up a 'local' environment which exists only until the batch ends or an endlocal
command is encountered.
see setlocal /?
from the prompt for more info.
Your batch appears to work fine once I'd added a win_fight_1
routine.
Note however that batch will barf on set /p answer
==(1)continue or (2)quit?
but removing one of those = will fix it.
Beyond that, just watch whether you want to go to menu
or start_1
.
And the
if %f2% gtr 4 goto fight_2
if %f2% lss 1 goto fight_2
will be ineffective - certainly if you've used set /a f2=%random% %% 4 + 1