我正在尝试制作批量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),而是显示数学未完成的数据。例如,它显示“A Level 31244/5 +1 Bear(11071/50 +10 HP)方法。你会做什么?”
有什么问题?请帮忙!
答案 0 :(得分:1)
set /?
声明,您需要/a
才能算术。
以你的行为例:
set enemylvl=%random% %%5 +1
应该是:
set /a enemylvl=%random% %%5 +1