我是一个简单的人,所以如果这可以尽可能地保持愚蠢,那就太好了 问题
@echo off
goto preparation
:damageCalculator
set /a damage=(((((2 * %level% / 5) + 2) * %attackStat% * %attackPower% / %opponentDefenceStat%) / 50) + 2)
set /a opponentHealth-=%damage%
echo %opponentHealth%
pause>nul
:preparation
set /a level=25
set /a attackStat=35
set /a attackPower=75
set /a opponentDefenceStat=46
set /a opponentHealth=350
:attack
call :damageCalculator
echo It did %damage% damage!!
pause>nul
问题是“CALL”充当了goto,我陷入了无尽的循环中 我确定我没有正确设置 请告诉我无数的错误
答案 0 :(得分:0)
您需要添加
goto :eof
退出子程序并返回批处理文件的调用部分。
:damageCalculator
set /a damage=(((((2 * %level% / 5) + 2) * %attackStat% * %attackPower% / %opponentDefenceStat%) / 50) + 2)
set /a opponentHealth-=%damage%
echo %opponentHealth%
pause>nul
goto :eof