简体   繁体   中英

GOTO was unexpected at this time if %sx% == 1 (goto %zz5%)

I'm working on an RPG style batch game, but I keep getting goto was unexpected at this time. I've looked over my code for hours, and still have no idea why it's doing this.

It's inconsistent as well. When testing out the attack animation, when I hit the slime enemy, I can rarely kill the slime without the batch file shutting down whatsoever. But there are other times when I attempt doing this, and the batch file just kills itself.

This is what the ht , tm , hm , bm etc. things mean:

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=¼

This is the "main body" of the code. Where the player will spend most of their time:

: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

This is where the problem arises. The portion that states else if %sx% == 4 (set menu...) works fine, it's only if %sx% == 1 (goto %zz5%) that seems to be having issues. I would like to note that switching %zz5% to batatk1 doesn't fix a thing.

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

Also, here is the code for 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

The only issue that's causing my game to literally not work is if %sx% == 1 (goto %zz5%) , and I don't know what to do. I've tried copying and pasting my code onto a new program. I've tried saving it on notepad, I've tried on notepad++, I've even switched it from the amount of loop switches I had it doing to what it's doing, now, and it still isn't working. I've even attempted cleaning up my code a little bit, and that isn't fixing anything. This problem didn't start until I added the Smoosh (name of the slime enemy) animation. Before that happened, there was no problems at all. The Slime animation can be found in :batatk4 and :batatk6 Thank you for taking your time to read over this and look through this amount of code. I'd be ever grateful if anyone could figure out what I'm doing wrong.

Let me share with you one of the most insidious problems when developing a batch file. When you're executing a batch file, the shell remembers where it left off by remembering the byte offset of the next command to be executed, and it closes and reopens the file each time. What that means is, if you CHANGE the batch file WHILE IT IS RUNNING, disaster ensues, because the saved byte pointer likely points to the middle of a line.

I cannot duplicate your problem. Note, if there is any change that a variable might be empty, then you can't say if %sx% == 1 ; that results in a syntax error. You have to say something like if "%sx%" == "1" or if x%sx% == x1 .

And, with all due respect, when I look at this code, all I can think is "good God".

EDIT

Here's one you can try that shows this syntax works.

set xx=XX

if "%xx%" == "1" (goto one
) else (goto two
)
echo What?

:one
echo One
goto :eof

:two
echo Two

I don't believe the problem was actually coding related. I copied my code to a new text file, sent it to my email, reset my computer, saved the file back to my computer, and now it seems to be working fine. Thank you to those who tried giving me solutions.

As you appear to have self fixed your issue, the following is simply recommended syntax changes, to the code you've used in your question. You should use them, as best practice:

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

Please note, that I've tried not to change any of your variable names, values, strings, structure, or layout, so you should be able to copy and paste these sections directly into the rest of your code without issue (as long as I've not made any typos) . I would recommend however, that you modify the rest of your code to match the above syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM