Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理-命令提示符不';我不会做数学_Batch File_Math_Cmd - Fatal编程技术网

Batch file 批处理-命令提示符不';我不会做数学

Batch file 批处理-命令提示符不';我不会做数学,batch-file,math,cmd,Batch File,Math,Cmd,我正在尝试制作一个批量RPG游戏,我正在制作一个战斗系统 代码如下: :Explore cls if %lvl% EQU 1 %random% %%5 +1 if %lvl% EQU 2 %random% %%5 +1 if %lvl% EQU 3 %random% %%5 +1 if %lvl% EQU 4 %random% %%5 +1 if %lvl% EQU 5 %random% %%5 +1 if %random% EQU 1 goto Bear if %random% EQU 2 g

我正在尝试制作一个批量RPG游戏,我正在制作一个战斗系统

代码如下:

:Explore
cls
if %lvl% EQU 1 %random% %%5 +1
if %lvl% EQU 2 %random% %%5 +1
if %lvl% EQU 3 %random% %%5 +1
if %lvl% EQU 4 %random% %%5 +1
if %lvl% EQU 5 %random% %%5 +1
if %random% EQU 1 goto Bear
if %random% EQU 2 goto Wolf
if %random% EQU 3 goto Foot Soldier
if %random% EQU 4 goto Cannibal
if %random% EQU 5 goto Tiger

::Enemies

:Bear
set enemyname=Bear
set enemylvl=%random% %%5 +1
set enemyhp=%random% %%50 +10
goto Battle

:Wolf
set enemyname=Wolf
set enemylvl=%random% %%5 +1
set enemyhp=%random% %%25 +5
goto Battle

:Foot Soldier
set enemyname=Foot Soldier
set enemylvl=%random% %%5 +1
set enemyhp=%random% %%25 +5
goto Battle

:Cannibal
set enemyname=Cannibal
set enemylvl=%random% %%5 +1
set enemyhp=%random% %%25 +5
goto Battle

:Tiger
set enemyname=Tiger
set enemylvl=%random% %%5 +1
set enemyhp=%random% %%30 +1
goto Battle

:Battle
cls
echo A level %enemylvl% %enemyname% (%enemyhp% HP) approaches! 
echo What will you do?
echo.
echo 1-Fight
echo 2-Run
echo.
set /p wwyd="Enter selection here:"
if %wwyd%==1 goto Fight
if %wwyd%==2 goto Run
当我运行程序时,它显示的不是敌人的变量(HP、name、lvl),而是未完成的数学运算。例如,它显示“等级31244/5+1熊(11071/50+10马力)接近。你会怎么做?”


怎么了?请帮忙

set/?
声明,您需要
/a
执行算术

例如,您的产品线:

set enemylvl=%random% %%5 +1
应该是:

set /a enemylvl=%random% %%5 +1

再次感谢Stephan!我将来可能会有更多的问题。除了Youtube之外,还有其他学习批处理的资源吗?Tim Hill的书,Windows NT Shell脚本。批处理语言自Windows NT以来没有太大变化,所以它仍然是一本适合您购买的好书。我将查看它。谢谢