如果%sx%==1(转到%zz5%),此时GOTO是意外的



我正在开发一款RPG风格的批处理游戏,但我一直在获得goto was unexpected at this time.。我已经看了几个小时的代码,仍然不知道它为什么要这么做。

它也不一致。在测试attack动画时,当我击中slime敌人时,我很少能在不关闭批处理文件的情况下杀死slime。但在其他情况下,当我尝试这样做时,批处理文件会自行终止。

这就是httmhmbm等的含义:

REM Sets box type.
set ht=Í
set hm=Í
set hb=Í
set vl=º
set vm=º
set vr=º
set tl=É
set tm=Ë
set tm2=Ë
set tr=»
set tr2=»
set ml2=Ì
set ml=Ì
set mm=Î
set mm2=Î
set mr2=¹
set mr=¹
set bl=È
set bm=Ê
set bm2=Ê
set br=¼

这就是";主体;代码的。玩家将在哪里度过大部分时间:

:battle
call :movement %movement%
set itemvar=0
set sx=1
set sx1=%icon%
set zz0=battle
set zz=battle2
set zz1=updo
set zz2=%zz%
set zz3=exit
set zz4=battlese
set zz5=batatk1
set max=4
set itemnum=0
set /a phpmaxh=%phpmax%/2
:battle2
set itemmenu=no
set itemmenu2=no
set battlemenu=no
set fight=no
set item=no
set menu=yes
if %pstatusch% == good (goto worncheck
) else (goto battle21)
:worncheck
if %php% leq %phpmaxh% (set pstatus=Worn Down       
set pstatusch=worn)
:battle21
if %errorlevel% == 1 (set wcon=Û) else (set wcon= )
if %errorlevel% == 2 (set acon1=ß
set acon2=Ü) else (set acon1= 
set acon2= )
if %errorlevel% == 3 (set scon=Û) else (set scon= )
if %errorlevel% == 4 (set dcon1=Ü
set dcon2=ß) else (set dcon1= 
set dcon2= )
if %errorlevel% == 0 (set wcon=Ü
set scon=ß) else if %errorlevel% gtr 4 (set wcon=Ü
set scon=ß)
if %sx% == 1 (set detail= Swing your weapon at 'em. )
if %sx% == 2 (set detail=  Cast a spell their way.  )
if %sx% == 3 (set detail=   Block and regain SPD.   )
if %sx% == 4 (set detail=    Use an item or two.    )
if %php% lss 10 (set phpsp= ) else (set phpsp=)
if %pmp% lss 10 (set pmpsp= ) else (set pmpsp=)
if %phpmax% lss 10 (set phpmaxsp= ) else (set phpmaxsp=)
if %pmpmax% lss 10 (set pmpmaxsp= ) else (set pmpmaxsp=)
if %patk% lss 10 (set patksp= ) else (set patksp=)
if %pdef% lss 10 (set pdefsp= ) else (set pdefsp=)
if %pint% lss 10 (set pintsp= ) else (set pintsp=)
if %pspd% lss 10 (set pspdsp= ) else (set pspdsp=)
if %pdefmax% lss 10 (set pdefmaxsp= ) else (set pdefmaxsp=)
if %pintmax% lss 10 (set pintmaxsp= ) else (set pintmaxsp=)
if %pspdmax% lss 10 (set pspdmaxsp= ) else (set pspdmaxsp=)
if %pshdrb% lss 10 (set shdrbsp= ) else (set shdrbsp=)
if %pardrb% lss 10 (set ardrbsp= ) else (set ardrbsp=)
if %pbtdrb% lss 10 (set btdrbsp= ) else (set btdrbsp=)
if %pexp% lss 10 (set pexpsp= ) else (set pexpsp=)
if %plvl% lss 10 (set plvlsp= ) else (set plvlsp=)
:battle3
if %menu% == yes (mode con: cols=65 lines=19
) else if %fight% == yes (mode con: cols=65 lines=17
) else (mode con: cols=65 lines=24)
if %menu% == yes (call :normal_menu menu1,menu2,menu3,menu4,menu5,menu6
) else if %itemmenu% == yes (call :normal_menu2 menu1,menu2,menu3,menu4,menu5,menu6
) else if %battlemenu% == yes (call :normal_menu3 menu1,menu2,menu3,menu4,menu5,menu6)
cls
echo.
echo.
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%      %enemy1%       %menu1%
echo   %vl% %ename%%enamesp% %vr%      %enemy2%       %menu2%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mr%      %enemy3%       %menu3%
echo   %vl% HP %ehpbar% %vr%      %enemy4%       %menu4%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%      %enemy5%        %menu5%
echo                          %enemy6%        %menu6%
echo.
if %itemmenu2% == yes (goto %zz5%
) else if %fight% == yes (goto %zz5%)
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tm%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%                     %tl%%ht%%ht%%ht%%ht%%tm%%ht%%ht%%ht%%ht%%tr%
echo   %vl% Status %vm% %pstatus% %vr%                     %vl%Curr%vm%Max %vr%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%bm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%mr%
echo   %vl% Shield %vm% %shdrbsp%%pshdrb% %vm% %detail% %vm% HP  %vm% %phpsp%%php% %vm% %phpmaxsp%%phpmax% %vr%
echo   %vl% Armor  %vm% %ardrbsp%%pardrb% %ml2%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%mr2% MP  %vm% %pmpsp%%pmp% %vm% %pmpmaxsp%%pmpmax% %vr%
echo   %vl% Boots  %vm% %btdrbsp%%pbtdrb% %vm% LVL %vm% %plvlsp%%plvl% %vm% %acon2% %wcon% %dcon1% %vm% ATK %vm% %patksp%%patk% %vm% DEF %vm% %pdefsp%%pdef% %vm% %pdefmaxsp%%pdefmax% %vr%
echo   %vl%        %vm%    %vm% EXP %vm% %pexpsp%%pexp% %vm% %acon1% %scon% %dcon2% %vm% INT %vm% %pintsp%%pint% %vm% SPD %vm% %pspdsp%%pspd% %vm% %pspdmaxsp%%pspdmax% %vr%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%br%
goto wasdqe /nul

这就是问题产生的地方。声明else if %sx% == 4 (set menu...)工作正常的部分,似乎只有if %sx% == 1 (goto %zz5%)有问题。我想指出的是,将%zz5%切换到batatk1并不能解决任何问题。

:battlese
if %sx% == 1 (goto %zz5%
) else if %sx% == 4 (set menu=no
set item=yes
goto itemselect)

此外,这是batatk1:的代码

:batatk1
set extradamageatk=+0
set extradamageint=+0
set weaponatk=yes
if %wpequip1% == yes (set x6=%wpequip1%
set x7=%inven1sp%
set x8=%inven1%
set x9=%inname1%
set x10=%wint1%
set x11=%watk1%
set x12=1
set x13=%wdrb1%
set x14=%wdrb1%
) else if %wpequip2% == yes (set x6=%wpequip2%
set x7=%inven2sp%
set x8=%inven2%
set x9=%inname2%
set x10=%wint2%
set x11=%watk2%
set x12=2
set x13=%wdrb2%
set x14=wdrb2
) else if %wpequip3% == yes (set x6=%wpequip3%
set x7=%inven3sp%
set x8=%inven3%
set x9=%inname3%
set x10=%wint3%
set x11=%watk3%
set x12=3
set x13=%wdrb3%
set x14=wdrb3
) else if %wpequip4% == yes (set x6=%wpequip4%
set x7=%inven4sp%
set x8=%inven4%
set x9=%inname4%
set x10=%wint4%
set x11=%watk4%
set x12=4
set x13=%wdrb4%
set x14=wdrb4
) else if %wpequip5% == yes (set x6=%wpequip5%
set x7=%inven5sp%
set x8=%inven5%
set x9=%inname5%
set x10=%wint5%
set x11=%watk5%
set x12=5
set x13=%wdrb5%
set x14=wdrb5
) else if %wpequip6% == yes (set x6=%wpequip6%
set x7=%inven6sp%
set x8=%inven6%
set x9=%inname6%
set x10=%wint6%
set x11=%watk6%
set x12=6
set x13=%wdrb6%
set x14=wdrb6
) else if %wpequip7% == yes (set x6=%wpequip7%
set x7=%inven7sp%
set x8=%inven7%
set x9=%inname7%
set x10=%wint7%
set x11=%watk7%
set x12=7
set x13=%wdrb7%
set x14=wdrb7
) else if %wpequip8% == yes (set x6=%wpequip8%
set x7=%inven8sp%
set x8=%inven8%
set x9=%inname8%
set x10=%wint8%
set x11=%watk8%
set x12=8
set x13=%wdrb8%
set x14=wdrb8
) else if %wpequip9% == yes (set x6=%wpequip9%
set x7=%inven9sp%
set x8=%inven9%
set x9=%inname9%
set x10=%wint9%
set x11=%watk9%
set x12=9
set x13=%wdrb9%
set x14=wdrb9
) else if %wpequip10% == yes (set x6=%wpequip10%
set x7=%inven10sp%
set x8=%inven10%
set x9=%inname10%
set x10=%wint10%
set x11=%watk10%
set x12=10
set x13=%wdrb10%
set x14=wdrb10
) else if %wpequip11% == yes (set x6=%wpequip11%
set x7=%inven11sp%
set x8=%inven11%
set x9=%inname11%
set x10=%wint11%
set x11=%watk11%
set x12=11
set x13=%wdrb11%
set x14=wdrb11
) else if %wpequip12% == yes (set x6=%wpequip12%
set x7=%inven12sp%
set x8=%inven12%
set x9=%inname12%
set x10=%wint12%
set x11=%watk12%
set x12=12
set x13=%wdrb12%
set x14=wdrb12
) else if %wpequip13% == yes (set x6=%wpequip13%
set x7=%inven13sp%
set x8=%inven13%
set x9=%inname13%
set x10=%wint13%
set x11=%watk13%
set x12=13
set x13=%wdrb13%
set x14=wdrb13
) else if %wpequip14% == yes (set x6=%wpequip14%
set x7=%inven14sp%
set x8=%inven14%
set x9=%inname14%
set x10=%wint14%
set x11=%watk14%
set x12=14
set x13=%wdrb14%
set x14=wdrb14
) else if %wpequip15% == yes (set x6=%wpequip15%
set x7=%inven15sp%
set x8=%inven15%
set x9=%inname15%
set x10=%wint15%
set x11=%watk15%
set x12=15
set x13=%wdrb15%
set x14=wdrb15
) else (set weaponatk=no)
set fn=0
set crit=1
:batatk2
set /a fn=%fn%+1
set /a rd%fn%=%random%/5500
if %fn% neq 2 goto batatk2
set fn=0
if %eability% == jelly (set extradamageatk=/2)
set /a crit=%rd1%-%rd2%
if %crit% lss 0 (set crit=+0) else (set crit=+%crit%)
if %rd1% == %rd2% goto rdcheck
if %pability% == weakspot (goto pweakspot)
if %equipatk% == physical (goto batatkph
) else if %equipatk% == mystic (goto batatkmy
) else if %equipatk% == both (goto batatkboth)
goto error
:rdcheck
if %rd1% == 0 (set /a miss=%miss%+1
) else if %rd1% == 5 (set crit=*2)
if %miss% == 2 goto pmiss
if %pability% == weakspot (goto pweakspot)
if %equipatk% == physical (goto batatkph
) else if %equipatk% == mystic (goto batatkmy
) else if %equipatk% == both (goto batatkboth)
goto error
:pweakspot
if %eability% == jelly (goto batatkmy
) else if %emp% gtr %ehp% (goto batatkph
) else if %ehp% gtr %emp% (goto batatkmy
)
goto error
:batatk3
set /a fn=%fn%+1
set /a rd%fn%=%random%/5500
if %fn% neq 2 goto batatk3
if %edamage% gtr 9 (set edamagesp=) else (set edamagesp= )
set fn=0
if %crit% == *2 (set rd1=0
set rd2=0)
if %rd1% == %rd2% (goto weapondamage)
:batatk4
set /a fn=%fn%+1
if %fn% == 2 (set enemy1=      ÜßÜ    Ü  
set enemy2=    ÜÛ   ÛÜ ßÜß
set enemy3=  ÜÛ       ÛÜ  
set enemy4=ÞÛ  ÛÜ ÜÛ    ÛÝ
set enemy5=ÞÛ   ÜÜÜ     ÛÝ
set enemy6=  ßßÜÜÜÜÜÜÜßß   )
if %fn% == 3 (set enemy1=       ÜßÜ    Ü 
set enemy2=     ÜÛ   ÛÜ ßÜß
set enemy3=   ÜÛ       ÛÜ  
set enemy4= ÞÛ  ÛÜ ÜÛ    ÛÝ
set enemy5= ÞÛ   ÜÜÜ     ÛÝ
set enemy6=   ßßÜÜÜÜÜÜÜßß  )
if %fn% == 4 (set enemy1=      ÜßÜ    Ü  
set enemy2=    ÜÛ   ÛÜ ßÜß
set enemy3=  ÜÛ       ÛÜ  
set enemy4=ÞÛ  ÛÜ ÜÛ    ÛÝ
set enemy5=ÞÛ   ÜÜÜ     ÛÝ
set enemy6=  ßßÜÜÜÜÜÜÜßß   )
if %fn% == 5 (set enemy1=      ÜßÜ       
set enemy2=    ÜÛ   ÛÜ    
set enemy3=  ÜÛ       ÛÜ  
set enemy4=ÞÛ   Ûß ßÛ   ÛÝ
set enemy5=ÞÛ    ÜÜÜ    ÛÝ
set enemy6=  ßßÜÜÜÜÜÜÜßß   )
cls
echo.
echo.
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%      %enemy1%       %menu1%
echo   %vl% %ename%%enamesp% %vr%      %enemy2%       %menu2%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mr%      %enemy3%       %menu3%
echo   %vl% HP %ehpbar% %vr%      %enemy4%       %menu4%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%      %enemy5%        %menu5%
echo                          %enemy6%        %menu6%
echo     %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%
if %weaponatk% == yes (echo     %vl%%enamesp% You swung your %x8% at the %ename%!   %x7%%vr%
) else if %weaponatk% == no (echo     %vl%               You punched the %ename%! %enamesp%          %vr%)
echo     %vl%               The enemy took %edamage% damage! %edamagesp%               %vr%
echo     %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%
if %fn% == 2 goto batatk6
:batatk5
if %fn% gtr 5 (set /a fn=%fn%+1)
if %fn% lss 6 (
timeout /t 0 >nul
) else (
timeout /t -1 >nul)
if %fn% lss 6 (goto batatk4)
if %ehp% leq 0 (set ehp=0
goto battle_win)
goto %zz0%
:batatk6
if %ehp% leq 0 (set ehpbar=°°°°°°°°°°
) else if %ehp% == 1 (set ehpbar=²°°°°°°°°°
) else if %ehp% == 2 (set ehpbar=Û°°°°°°°°°
) else if %ehp% == 3 (set ehpbar=Û²°°°°°°°°
) else if %ehp% == 4 (set ehpbar=ÛÛ°°°°°°°°
) else if %ehp% == 5 (set ehpbar=ÛÛ²°°°°°°°
) else if %ehp% == 6 (set ehpbar=ÛÛÛ°°°°°°°
) else if %ehp% == 7 (set ehpbar=ÛÛÛ²°°°°°°
) else if %ehp% == 8 (set ehpbar=ÛÛÛÛ°°°°°°
) else if %ehp% == 9 (set ehpbar=ÛÛÛÛ²°°°°°
) else if %ehp% == 10 (set ehpbar=ÛÛÛÛÛ°°°°°
) else if %ehp% == 11 (set ehpbar=ÛÛÛÛÛ²°°°°
) else if %ehp% == 12 (set ehpbar=ÛÛÛÛÛÛ°°°°
) else if %ehp% == 13 (set ehpbar=ÛÛÛÛÛÛ²°°°
) else if %ehp% == 14 (set ehpbar=ÛÛÛÛÛÛÛ°°°
) else if %ehp% == 15 (set ehpbar=ÛÛÛÛÛÛÛ²°°
) else if %ehp% == 16 (set ehpbar=ÛÛÛÛÛÛÛÛ°°
) else if %ehp% == 17 (set ehpbar=ÛÛÛÛÛÛÛÛ²°
) else if %ehp% == 18 (set ehpbar=ÛÛÛÛÛÛÛÛÛ°
) else if %ehp% == 19 (set ehpbar=ÛÛÛÛÛÛÛÛÛ²
) else if %ehp% == 20 (set ehpbar=ÛÛÛÛÛÛÛÛÛÛ)
goto batatk4
:weapondamage
if %weapondamage% == no goto batatk4
if %rd1% == 0 (set /a %x14%=%x13%-2) else (set /a %x14%=%x13%-1)
if %rd1% == 0 (set /a x13=%x13%-2) else (set /a x13=%x13%-1)
if %x13% leq 0 (set item%x12%=none
set inven%x12%=Scraps         
set inname%x12%=none
set wpequip%x12%=no
set indesc%x12%=%x9%
set x9=none
set equipatk=physical)
if %x9% == woodsword (set indesc%x12%=A toy children play with. ATK:3 DRB:%x13%                  
) else if %x9% == woodstaff (set indesc%x12%=A type of staff used on hiking trips. INT:3 DRB:%x13%      
) else if %x9% == wooddagger (set indesc%x12%=Artistic carving of a beautiful dagger. INT/ATK:2 DRB:%x13%
) else if %x9% == none (set indesc%x12%=Scraps left behind from shattered equipment.           )
if %x13% leq 0 (set /a patk=%patk%-%x11%)
if %x13% leq 0 (set /a pint=%pint%-%x10%)
goto batatk4
:batatkph
set /a edamage=((%patk%%crit%)%extradamageatk%)-%edef%
if %edamage% leq 0 (set edamage=1)
set /a ehp=%ehp%-%edamage%
goto batatk3
:batatkmy
set /a edamage=((%pint%%crit%)%extradamageint%)-%edef%
if %edamage% leq 0 (set edamage=1)
set /a ehp=%ehp%-%edamage%
goto batatk3

唯一导致我的游戏无法运行的问题是if %sx% == 1 (goto %zz5%),我不知道该怎么办。我试过将代码复制并粘贴到一个新程序上。我试过把它保存在记事本上,我试过用记事本++,我甚至把它从我让它做的循环开关的数量切换到了它现在正在做的事情,但它仍然不起作用。我甚至尝试过稍微清理一下我的代码,但这并不能解决任何问题。直到我添加了Smoosh(黏液敌人的名称(动画,这个问题才开始。在那之前,没有任何问题。Slime动画可以在:batatk4:batatk6中找到感谢您花时间仔细阅读并浏览大量代码。如果有人能弄清楚我做错了什么,我将不胜感激。

让我与您分享开发批处理文件时最隐蔽的问题之一。当您执行批处理文件时,shell会通过记住下一个要执行的命令的字节偏移量来记住它停止的位置,并且每次都会关闭和重新打开文件。这意味着,如果在批处理文件运行时更改它,灾难就会随之而来,因为保存的字节指针可能指向一行的中间。

我不能重复你的问题。注意,如果变量可能为空,则不能说if %sx% == 1;这会导致语法错误。你必须说if "%sx%" == "1"if x%sx% == x1之类的话。

而且,恕我直言,当我看到这段代码时,我所能想到的就是";善良的上帝";。

编辑

这里有一个你可以尝试的例子,它展示了这种语法的工作原理。

set xx=XX
if "%xx%" == "1" (goto one
) else (goto two
)
echo What?
:one
echo One
goto :eof
:two
echo Two

我不认为这个问题实际上与编码有关。我把代码复制到一个新的文本文件中,发送到我的电子邮件中,重置我的电脑,把文件保存回我的电脑中,现在它似乎工作得很好。感谢那些试图给我解决方案的人。

由于您似乎已经自行解决了问题,下面只是建议您对问题中使用的代码进行语法更改。你应该使用它们,作为最佳实践:

REM Sets box type.
set "ht=Í"
set "hm=Í"
set "hb=Í"
set "vl=º"
set "vm=º"
set "vr=º"
set "tl=É"
set "tm=Ë"
set "tm2=Ë"
set "tr=»"
set "tr2=»"
set "ml2=Ì"
set "ml=Ì"
set "mm=Î"
set "mm2=Î"
set "mr2=¹"
set "mr=¹"
set "bl=È"
set "bm=Ê"
set "bm2=Ê"
set "br=¼""
:battle
call :movement %movement%
set "itemvar=0"
set "sx=1"
set "sx1=%icon%"
set "zz0=battle"
set "zz=battle2"
set "zz1=updo"
set "zz2=%zz%"
set "zz3=exit"
set "zz4=battlese"
set "zz5=batatk1"
set "max=4"
set "itemnum=0"
set /a phpmaxh=phpmax / 2
:battle2
set "itemmenu=no"
set "itemmenu2=no"
set "battlemenu=no"
set "fight=no"
set "item=no"
set "menu=yes"
if "%pstatusch%" == "good" (goto worncheck
) else goto battle21
:worncheck
if %php% leq %phpmaxh% (set "pstatus=Worn Down       "
set "pstatusch=worn")
:battle21
if %errorlevel% equ 1 (set "wcon=Û") else set "wcon= "
if %errorlevel% equ 2 (set "acon1=ß"
set "acon2=Ü") else (set "acon1= "
set "acon2= ")
if %errorlevel% equ 3 (set "scon=Û") else set "scon= "
if %errorlevel% equ 4 (set "dcon1=Ü"
set "dcon2=ß") else (set "dcon1= "
set "dcon2= ")
if %errorlevel% equ 0 (set "wcon=Ü"
set "scon=ß") else if %errorlevel% gtr 4 (set "wcon=Ü"
set "scon=ß")
if %sx% equ 1 set "detail= Swing your weapon at 'em. "
if %sx% equ 2 set "detail=  Cast a spell their way.  "
if %sx% equ 3 set "detail=   Block and regain SPD.   "
if %sx% equ 4 set "detail=    Use an item or two.    "
if %php% lss 10 (set "phpsp= ") else set "phpsp="
if %pmp% lss 10 (set "pmpsp= ") else set "pmpsp="
if %phpmax% lss 10 (set "phpmaxsp= ") else set "phpmaxsp="
if %pmpmax% lss 10 (set "pmpmaxsp= ") else set "pmpmaxsp="
if %patk% lss 10 (set "patksp= ") else set "patksp="
if %pdef% lss 10 (set "pdefsp= ") else set "pdefsp="
if %pint% lss 10 (set "pintsp= ") else set "pintsp="
if %pspd% lss 10 (set "pspdsp= ") else set "pspdsp="
if %pdefmax% lss 10 (set "pdefmaxsp= ") else set "pdefmaxsp="
if %pintmax% lss 10 (set "pintmaxsp= ") else set "pintmaxsp="
if %pspdmax% lss 10 (set "pspdmaxsp= ") else set "pspdmaxsp="
if %pshdrb% lss 10 (set "shdrbsp= ") else set "shdrbsp="
if %pardrb% lss 10 (set "ardrbsp= ") else set "ardrbsp="
if %pbtdrb% lss 10 (set "btdrbsp= ") else set "btdrbsp="
if %pexp% lss 10 (set "pexpsp= ") else set "pexpsp="
if %plvl% lss 10 (set "plvlsp= ") else set "plvlsp="
:battle3
if "%menu%" == "yes" (mode con: cols=65 lines=19
) else if "%fight%" == "yes" (mode con: cols=65 lines=17
) else (mode con: cols=65 lines=24)
if "%menu%" == "yes" (call :normal_menu menu1,menu2,menu3,menu4,menu5,menu6
) else if "%itemmenu%" == "yes" (call :normal_menu2 menu1,menu2,menu3,menu4,menu5,menu6
) else if "%battlemenu%" == "yes" call :normal_menu3 menu1,menu2,menu3,menu4,menu5,menu6
cls
echo(
echo(
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%      %enemy1%       %menu1%
echo   %vl% %ename%%enamesp% %vr%      %enemy2%       %menu2%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mr%      %enemy3%       %menu3%
echo   %vl% HP %ehpbar% %vr%      %enemy4%       %menu4%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%      %enemy5%        %menu5%
echo                          %enemy6%        %menu6%
echo(
if "%itemmenu2%" == "yes" (goto %zz5%
) else if "%fight%" == "yes" goto %zz5%
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tm%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%                     %tl%%ht%%ht%%ht%%ht%%tm%%ht%%ht%%ht%%ht%%tr%
echo   %vl% Status %vm% %pstatus% %vr%                     %vl%Curr%vm%Max %vr%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%bm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%mm%%hm%%hm%%hm%%hm%%mr%
echo   %vl% Shield %vm% %shdrbsp%%pshdrb% %vm% %detail% %vm% HP  %vm% %phpsp%%php% %vm% %phpmaxsp%%phpmax% %vr%
echo   %vl% Armor  %vm% %ardrbsp%%pardrb% %ml2%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%hm%%tm2%%hm%%hm%%hm%%hm%%mr2% MP  %vm% %pmpsp%%pmp% %vm% %pmpmaxsp%%pmpmax% %vr%
echo   %vl% Boots  %vm% %btdrbsp%%pbtdrb% %vm% LVL %vm% %plvlsp%%plvl% %vm% %acon2% %wcon% %dcon1% %vm% ATK %vm% %patksp%%patk% %vm% DEF %vm% %pdefsp%%pdef% %vm% %pdefmaxsp%%pdefmax% %vr%
echo   %vl%        %vm%    %vm% EXP %vm% %pexpsp%%pexp% %vm% %acon1% %scon% %dcon2% %vm% INT %vm% %pintsp%%pint% %vm% SPD %vm% %pspdsp%%pspd% %vm% %pspdmaxsp%%pspdmax% %vr%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%bm%%hb%%hb%%hb%%hb%%br%
goto wasdqe /nul
:battlese
if %sx% equ 1 (goto %zz5%
) else if %sx% equ 4 (set "menu=no"
set "item=yes"
goto itemselect)
:batatk1
set "extradamageatk=+ 0"
set "extradamageint=+ 0"
set "weaponatk=yes"
if "%wpequip1%" == "yes" (set "x6=%wpequip1%"
set "x7=%inven1sp%"
set "x8=%inven1%"
set "x9=%inname1%"
set "x10=%wint1%"
set "x11=%watk1%"
set "x12=1"
set "x13=%wdrb1%"
set "x14=%wdrb1%"
) else if "%wpequip2%" == "yes" (set "x6=%wpequip2%"
set "x7=%inven2sp%"
set "x8=%inven2%"
set "x9=%inname2%"
set "x10=%wint2%"
set "x11=%watk2%"
set "x12=2"
set "x13=%wdrb2%"
set "x14=wdrb2"
) else if "%wpequip3%" == "yes" (set "x6=%wpequip3%"
set "x7=%inven3sp%"
set "x8=%inven3%"
set "x9=%inname3%"
set "x10=%wint3%"
set "x11=%watk3%"
set "x12=3"
set "x13=%wdrb3%"
set "x14=wdrb3"
) else if "%wpequip4%" == "yes" (set "x6=%wpequip4%"
set "x7=%inven4sp%"
set "x8=%inven4%"
set "x9=%inname4%"
set "x10=%wint4%"
set "x11=%watk4%"
set "x12=4"
set "x13=%wdrb4%"
set "x14=wdrb4"
) else if "%wpequip5%" == "yes" (set "x6=%wpequip5%"
set "x7=%inven5sp%"
set "x8=%inven5%"
set "x9=%inname5%"
set "x10=%wint5%"
set "x11=%watk5%"
set "x12=5"
set "x13=%wdrb5%"
set "x14=wdrb5"
) else if "%wpequip6%" == "yes" (set "x6=%wpequip6%"
set "x7=%inven6sp%"
set "x8=%inven6%"
set "x9=%inname6%"
set "x10=%wint6%"
set "x11=%watk6%"
set "x12=6"
set "x13=%wdrb6%"
set "x14=wdrb6"
) else if "%wpequip7%" == "yes" (set "x6=%wpequip7%"
set "x7=%inven7sp%"
set "x8=%inven7%"
set "x9=%inname7%"
set "x10=%wint7%"
set "x11=%watk7%"
set "x12=7"
set "x13=%wdrb7%"
set "x14=wdrb7"
) else if "%wpequip8%" == "yes" (set "x6=%wpequip8%"
set "x7=%inven8sp%"
set "x8=%inven8%"
set "x9=%inname8%"
set "x10=%wint8%"
set "x11=%watk8%"
set "x12=8"
set "x13=%wdrb8%"
set "x14=wdrb8"
) else if "%wpequip9%" == "yes" (set "x6=%wpequip9%"
set "x7=%inven9sp%"
set "x8=%inven9%"
set "x9=%inname9%"
set "x10=%wint9%"
set "x11=%watk9%"
set "x12=9"
set "x13=%wdrb9%"
set "x14=wdrb9"
) else if "%wpequip10%" == "yes" (set "x6=%wpequip10%"
set "x7=%inven10sp%"
set "x8=%inven10%"
set "x9=%inname10%"
set "x10=%wint10%"
set "x11=%watk10%"
set "x12=10"
set "x13=%wdrb10%"
set "x14=wdrb10"
) else if "%wpequip11%" == "yes" (set "x6=%wpequip11%"
set "x7=%inven11sp%"
set "x8=%inven11%"
set "x9=%inname11%"
set "x10=%wint11%"
set "x11=%watk11%"
set "x12=11"
set "x13=%wdrb11%"
set "x14=wdrb11"
) else if "%wpequip12%" == "yes" (set "x6=%wpequip12%"
set "x7=%inven12sp%"
set "x8=%inven12%"
set "x9=%inname12%"
set "x10=%wint12%"
set "x11=%watk12%"
set "x12=12"
set "x13=%wdrb12%"
set "x14=wdrb12"
) else if "%wpequip13%" == "yes" (set "x6=%wpequip13%"
set "x7=%inven13sp%"
set "x8=%inven13%"
set "x9=%inname13%"
set "x10=%wint13%"
set "x11=%watk13%"
set "x12=13"
set "x13=%wdrb13%"
set "x14=wdrb13"
) else if "%wpequip14%" == "yes" (set "x6=%wpequip14%"
set "x7=%inven14sp%"
set "x8=%inven14%"
set "x9=%inname14%"
set "x10=%wint14%"
set "x11=%watk14%"
set "x12=14"
set "x13=%wdrb14%"
set "x14=wdrb14"
) else if "%wpequip15%" == "yes" (set "x6=%wpequip15%"
set "x7=%inven15sp%"
set "x8=%inven15%"
set "x9=%inname15%"
set "x10=%wint15%"
set "x11=%watk15%"
set "x12=15"
set "x13=%wdrb15%"
set "x14=wdrb15"
) else set "weaponatk=no"
set "fn=0"
set "crit=1"
:batatk2
set /a fn += 1
set /a rd%fn%=%random% / 5500
if %fn% neq 2 goto batatk2
set "fn=0"
if "%eability%" == "jelly" set "extradamageatk=/ 2"
set /a crit=rd1 - rd2
if %crit% lss 0 (set "crit=+ 0") else set "crit=+ crit"
if %rd1 equ %rd2% goto rdcheck
if "%pability%" == "weakspot" goto pweakspot
if "%equipatk%" == "physical" (goto batatkph
) else if "%equipatk%" == "mystic" (goto batatkmy
) else if "%equipatk%" == "both" goto batatkboth
goto error
:rdcheck
if %rd1% equ 0 (set /a miss += 1
) else if %rd1% equ 5 set "crit=* 2"
if %miss% equ 2 goto pmiss
if "%pability%" == "weakspot" goto pweakspot
if "%equipatk%" == "physical" (goto batatkph
) else if "%equipatk%" == "mystic" (goto batatkmy
) else if "%equipatk%" == "both" goto batatkboth
goto error
:pweakspot
if "%eability%" == "jelly" (goto batatkmy
) else if %emp% gtr %ehp% (goto batatkph
) else if %ehp% gtr %emp% goto batatkmy
goto error
:batatk3
set /a fn += 1
set /a rd%fn%=%random% / 5500
if %fn% neq 2 goto batatk3
if %edamage% gtr 9 (set "edamagesp=") else set "edamagesp= "
set "fn=0"
if "%crit%" == "* 2" (set "rd1=0"
set "rd2=0")
if %rd1% equ %rd2% goto weapondamage
:batatk4
set /a fn += 1
if %fn% equ 2 (set "enemy1=      ÜßÜ    Ü  "
set "enemy2=    ÜÛ   ÛÜ ßÜß"
set "enemy3=  ÜÛ       ÛÜ  "
set "enemy4=ÞÛ  ÛÜ ÜÛ    ÛÝ"
set "enemy5=ÞÛ   ÜÜÜ     ÛÝ"
set "enemy6=  ßßÜÜÜÜÜÜÜßß   ")
if %fn% equ 3 (set "enemy1=       ÜßÜ    Ü "
set "enemy2=     ÜÛ   ÛÜ ßÜß"
set "enemy3=   ÜÛ       ÛÜ  "
set "enemy4= ÞÛ  ÛÜ ÜÛ    ÛÝ"
set "enemy5= ÞÛ   ÜÜÜ     ÛÝ"
set "enemy6=   ßßÜÜÜÜÜÜÜßß  ")
if %fn% equ 4 (set "enemy1=      ÜßÜ    Ü  "
set "enemy2=    ÜÛ   ÛÜ ßÜß"
set "enemy3=  ÜÛ       ÛÜ  "
set "enemy4=ÞÛ  ÛÜ ÜÛ    ÛÝ"
set "enemy5=ÞÛ   ÜÜÜ     ÛÝ"
set "enemy6=  ßßÜÜÜÜÜÜÜßß   ")
if %fn% equ 5 (set "enemy1=      ÜßÜ       "
set "enemy2=    ÜÛ   ÛÜ    "
set "enemy3=  ÜÛ       ÛÜ  "
set "enemy4=ÞÛ   Ûß ßÛ   ÛÝ"
set "enemy5=ÞÛ    ÜÜÜ    ÛÝ"
set "enemy6=  ßßÜÜÜÜÜÜÜßß   ")
cls
echo(
echo(
echo   %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%      %enemy1%       %menu1%
echo   %vl% %ename%%enamesp% %vr%      %enemy2%       %menu2%
echo   %ml%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%hm%%mr%      %enemy3%       %menu3%
echo   %vl% HP %ehpbar% %vr%      %enemy4%       %menu4%
echo   %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%      %enemy5%        %menu5%
echo                          %enemy6%        %menu6%
echo     %tl%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%ht%%tr%
if "%weaponatk%" == "yes" (echo     %vl%%enamesp% You swung your %x8% at the %ename%!   %x7%%vr%
) else if "%weaponatk%" == "no" (echo     %vl%               You punched the %ename%! %enamesp%          %vr%)
echo     %vl%               The enemy took %edamage% damage! %edamagesp%               %vr%
echo     %bl%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%hb%%br%
if %fn% equ 2 goto batatk6
:batatk5
if %fn% gtr 5 set /a fn += 1
if %fn% lss 6 (
timeout /t 0 >nul
) else timeout /t -1 >nul
if %fn% lss 6 goto batatk4
if %ehp% leq 0 (set "ehp=0"
goto battle_win)
goto %zz0%
:batatk6
if %ehp% leq 0 (set "ehpbar=°°°°°°°°°°"
) else if %ehp% equ 1 (set "ehpbar=²°°°°°°°°°"
) else if %ehp% equ 2 (set "ehpbar=Û°°°°°°°°°"
) else if %ehp% equ 3 (set "ehpbar=Û²°°°°°°°°"
) else if %ehp% equ 4 (set "ehpbar=ÛÛ°°°°°°°°"
) else if %ehp% equ 5 (set "ehpbar=ÛÛ²°°°°°°°"
) else if %ehp% equ 6 (set "ehpbar=ÛÛÛ°°°°°°°"
) else if %ehp% equ 7 (set "ehpbar=ÛÛÛ²°°°°°°"
) else if %ehp% equ 8 (set "ehpbar=ÛÛÛÛ°°°°°°"
) else if %ehp% equ 9 (set "ehpbar=ÛÛÛÛ²°°°°°"
) else if %ehp% equ 10 (set "ehpbar=ÛÛÛÛÛ°°°°°"
) else if %ehp% equ 11 (set "ehpbar=ÛÛÛÛÛ²°°°°"
) else if %ehp% equ 12 (set "ehpbar=ÛÛÛÛÛÛ°°°°"
) else if %ehp% equ 13 (set "ehpbar=ÛÛÛÛÛÛ²°°°"
) else if %ehp% equ 14 (set "ehpbar=ÛÛÛÛÛÛÛ°°°"
) else if %ehp% equ 15 (set "ehpbar=ÛÛÛÛÛÛÛ²°°"
) else if %ehp% equ 16 (set "ehpbar=ÛÛÛÛÛÛÛÛ°°"
) else if %ehp% equ 17 (set "ehpbar=ÛÛÛÛÛÛÛÛ²°"
) else if %ehp% equ 18 (set "ehpbar=ÛÛÛÛÛÛÛÛÛ°"
) else if %ehp% equ 19 (set "ehpbar=ÛÛÛÛÛÛÛÛÛ²"
) else if %ehp% equ 20 set "ehpbar=ÛÛÛÛÛÛÛÛÛÛ"
goto batatk4
:weapondamage
if "%weapondamage%" == "no" goto batatk4
if %rd1% equ 0 (set /a %x14%=x13 - 2) else set /a %x14%=x13 - 1
if %rd1% equ 0 (set /a x13 -= 2) else set /a x13 -= 1
if %x13% leq 0 (set "item%x12%=none"
set "inven%x12%=Scraps         "
set "inname%x12%=none"
set "wpequip%x12%=no"
set "indesc%x12%=%x9%"
set "x9=none"
set "equipatk=physical")
if "%x9%" == "woodsword" (set "indesc%x12%=A toy children play with. ATK:3 DRB:%x13%                  "
) else if "%x9%" == "woodstaff" (set "indesc%x12%=A type of staff used on hiking trips. INT:3 DRB:%x13%      "
) else if "%x9%" == "wooddagger" (set "indesc%x12%=Artistic carving of a beautiful dagger. INT/ATK:2 DRB:%x13%"
) else if "%x9%" == "none" set "indesc%x12%=Scraps left behind from shattered equipment.           "
if %x13% leq 0 set /a patk -= x11
if %x13% leq 0 set /a pint -= x10
goto batatk4
:batatkph
set /a "edamage=((patk crit) extradamageatk) - edef"
if %edamage% leq 0 set "edamage=1"
set /a ehp -= edamage
goto batatk3
:batatkmy
set /a "edamage=((pint crit) extradamageint) - edef"
if %edamage% leq 0 set "edamage=1"
set /a ehp -= edamage
goto batatk3

请注意,我已经尝试不更改您的任何变量名、值、字符串、结构或布局,因此您应该能够将这些部分直接复制并粘贴到代码的其余部分中,而不会出现问题(只要我没有拼写错误(。但是,我建议您修改代码的其余部分以匹配上述语法。

相关内容

  • 没有找到相关文章

最新更新