调用批处理AND检查值:批处理文件不断崩溃,但脚本似乎还可以



所以我创建了一个有很多变量的游戏,但我希望用户根据设置的变量限制访问和/或去某个地方或区域

我有所有你可以去的地方,但出于某种原因,似乎有一些语法错误,我无法识别。下面是一个例子,但我在整个游戏中有很多细微的变化,这取决于你已经杀死了什么实体,或者你把你的家乡设置在哪里

我确实收到了一条错误消息,但程序关闭得太快了,我无法阅读它所说的内容。我试过录制"撞车",并放慢了视频的速度,但图像质量不是最好的。类似"spawn0未被识别"的内容,我认为这与语法有关

一些变量检查器可以起作用,例如在允许您进入城堡之前检查角色的级别(见下文)。

set /p cit1=
if %cit1% EQU 1 GOTO citadellvlcheck
if %cit1% EQU 2 GOTO SAVE_GAME_FILES_Masafkel
GOTO CIT_WARN
:citadellvlcheck
if %curlvl% LSS 50 GOTO citadellvlreq
if %curlvl% GEQ 50 GOTO entercitadel
:citadellvlreq
@echo off
color 0F
cls
echo.
echo  You must be level 50 or higher to enter the citadel.
pause > nul
GOTO MasafkelMenu-XC


但因为我无法让产卵检查工作,也无法让MasafkelMenu XC工作,所以用户一登录游戏,它就会立即崩溃。创建用户也是如此。你可以设置你的用户名、密码、游戏中的电子邮件(以防忘记密码)、性别甚至物种;但它只是在之后立即崩溃,甚至没有创建字符批处理文件。下面是一些例子。

:SpawnCheck
@echo off
Title Adrynia
Color 0F
cls
call %name1%.bat
if %spawn%=spawn0 GOTO SpawnMenu0
if %spawn%=spawn1 GOTO SpawnMenu0
if %spawn%=spawn2 GOTO SpawnMenu0
if %spawn%=spawn3 GOTO SpawnMenu0
if %spawn%=spawn4 GOTO SpawnMenu0
if %spawn%=spawn5 GOTO SpawnMenu0
if %spawn%=spawn6 GOTO SpawnMenu0
if %spawn%=spawn7 GOTO SpawnMenu0
if %spawn%=spawn8 GOTO SpawnMenu0
if %spawn%=spawn9 GOTO SpawnMenu0
if %spawn%=Groylle GOTO GroylleMenu
if %spawn%=Meprophia GOTO MeprophiaMenu
if %spawn%=HermitHut GOTO HermitHutMenu
if %spawn%=Masafkel GOTO MasafkelMenu-XC
if %spawn%=Crounver GOTO CrounverMenu
if %spawn%=Bobeindahl GOTO BobeindahlMenu
if %spawn%=Krontay GOTO KrontayMenu
if %spawn%=Slinguss GOTO SlingussMenu
if %spawn%=Tichyster GOTO TichysterMenu
if %spawn%=Houjing GOTO HoujingMenu
if %spawn%=flat1 GOTO FlatMenu1
if %spawn%=flat2 GOTO FlatMenu2
if %spawn%=flat3 GOTO FlatMenu3
if %spawn%=flat4 GOTO FlatMenu4
if %spawn%=flat5 GOTO FlatMenu5
if %spawn%=flat6 GOTO FlatMenu6
if %spawn%=flat7 GOTO FlatMenu7
if %spawn%=flat8 GOTO FlatMenu8
if %spawn%=flat9 GOTO FlatMenu9
if %spawn%=flat10 GOTO FlatMenu10
if %spawn%=house1 GOTO HouseMenu1
if %spawn%=house2 GOTO HouseMenu2
if %spawn%=house3 GOTO HouseMenu3
if %spawn%=house4 GOTO HouseMenu4
if %spawn%=house5 GOTO HouseMenu5
if %spawn%=house6 GOTO HouseMenu6
if %spawn%=house7 GOTO HouseMenu7
if %spawn%=house8 GOTO HouseMenu8
if %spawn%=house9 GOTO HouseMenu9
if %spawn%=house10 GOTO HouseMenu10
GOTO Error

:MasafkelMenu-XC
@echo off
color 0f
cls
call %name1%.bat
if %Criunthma%=0 GOTO MasafkelMenu
if %Criunthma%=1 GOTO Masafkel-CD
GOTO Error


如果在批处理文件中不可能做这样的事情,那就顺其自然,但如果可能的话,我至少会尽我最大的努力。

因此,除了游戏是一款基于文本的游戏外,玩家还可以利用自己的想象力更好地了解周围的游戏世界,从而有望增强游戏体验;我还喜欢使用这个游戏的编码来学习新技能,并测试批脚本的极限,以及我对批MS-DOS和批脚本的小而逐渐增加的知识

现在,当我在cmd中运行一些测试时,显示的是:"Artemis.bat"不被识别为内部或外部命令、可操作程序或批处理文件=此时出现了意外的spawn0。不管你选择的用户名是什么,它都会出现,然而,当它自己运行时,它只说"=此时不需要spawn0"

我不明白%spawnpoint%=spawn0是如何无法识别的,或者可能是意外的,因为该角色在创建时会分配一个spawnpoint(在:CHAR_DATA中)当您第一次创建角色时,:CHAR_DATA为您分配名为"spawnpoint"的后代;但如果您设置了一个家乡,或者购买了一栋房子或一套公寓,那么您的后代将被设置为该城镇或房子/公寓,这样当您开始游戏时,您将从您的后代开始。

:CHAR_DATA
set acc1g=0
set acc1m=Open
set acc2g=0
set acc2m=Open
set acc3g=0
set acc3m=Open
set acc4g=0
set acc4m=Open
set acc5g=0
set acc5m=Open
set cost=
set cost1=
set gcho=
set echo=
set e2cho=
set e1=
set armour=30
set origarmour=30
set Cyrax=0
set Fregwin=0
set Zeschka=0
set Agnorr=0
set Grehln=0
set Meiqa=0
set Lothin=0
set Skatha=0
set Triffyn=0
set Glieza=0
set Areya=0
set Exin=0
set Yewvar=0
set Smuggler=0
set Qwaen=0
set Oracle=0
set Antharr=0
set Cadell=0
set Rhyghan=0
set Helori=0
set Chaerron=0
set Cyntheyrr=0
set Mureh=0
set Llaellyn=0
set Bechim=0
set Brathach=0
set Albreqi=0
set Tausir=0
set Mivrailoksh=0
set Khaen=0
set Criunthma=0
set Vunada=0
set VT=0
set VC=G
set ls1=0
set killcount=0
set ttlbosskill=0
set ttlmonstkill=0
set ttlkills=0
set goodness=0
set evilness=0
set morality=neutral
set ls2=0
set la1=0
set la2=0
set orighp=100
set hp=100
set origsp=25
set sp=25
set armtype=None
set swordtype=Your
set skind=hand
set buyword1=hi
set buyword2=hi
set curlvl=1
set aan=a
set bankqharri=0
set destination=SAVE_GAME_FILES1
set destination2=SAVE_GAME_FILES1
set swordchoice=Nothing
set swordchoice2=Nothing
set swordchoice3=Nothing
set swordexist=Nothing
set rent=0
set sprice=0
set armchoice=No
set armchoice2=Amour
set aprice=0
set playerxp=0
set xpuntil=1000
set origxp=0
set money=0
set platos=0
set lovana=0
set credits=0
set key=0
set dmge=10
set origdmge=10
set dr=0
set spawn=spawn0
set rests=0
set sleep=100
set rochtain=0
set beer=0
set wine=0
set spirits=0
set naeprahv=0
set drunk=0
set ID=0
set day=42
set week=5
set month=12
set year=73734
set status=alive
set gmail=0
set hbone=0
set dhide=0
set rtab=0
set food=0
set cigarette=0
set seaweed=0
set weedcig=0
set rfood=0
set bait=0
set ea=None
set potion=0
set copperingot=0
set ironingot=0
set steelingot=0
set bronzeingot=0
set brassingot=0
set tiningot=0
set silveringot=0
set goldingot=0
set zincingot=0
set manganeseingot=0
set aluminiumingot=0
set chromiumingot=0
set nickelingot=0
set refinedcopper=0
set refinediron=0
set refinedtin=0
set refinedsilver=0
set refinedgold=0
set refinedzinc=0
set refinedmanganese=0
set refinedaluminium=0
set refinedsilicon=0
set refinedchromium=0
set refinednickel=0
set seed=0
set bow=0
set fur=0
set gem=0
set log=0
set wood=0
set copperore=0
set ironore=0
set tinore=0
set silverore=0
set goldore=0
set zincore=0
set manganeseore=0
set aluminiumore=0
set siliconore=0
set chromiumore=0
set nickelore=0
set morb=0
set arm1=0
set arm2=0
set arm3=0
set arm4=0
set arm5=0
set arm6=0
set arm7=0
set arm8=0
set arm9=0
set arm10=0
set arm11=0
set arm12=0
set ma1=0
set ma2=0
set ma3=0
set ma4=0
set ma5=0
set ma6=0
set ma7=0
set ma8=0
set ma9=0
set ma10=0
set ms1=0
set ms2=0
set ms3=0
set ms4=0
set ms5=0
set ms6=0
set ms7=0
set ms8=0
set ms9=0
set ms10=0
set sword1=0
set sword2=0
set sword3=0
set sword4=0
set sword5=0
set sword6=0
set sword7=0
set sword8=0
set sword9=0
set sword10=0
set sword11=0
set sword12=0
set axxx=0
set pgmail=300
set phbone=550
set pdhide=750
set prtab=250
set ppotion=200
set pfood=100
set pingot=473
set pseed=150
set prfood=100
set pbait=2
set pfur=200
set pore=500
set plog=275
set pgem=500
set pbow=713
set pmorb=15000
set Woodcuttinglvl=1
set Woodcuttingxpremain=5000
set Woodcuttingxpgain=20
set Woodcuttingcurxp=0
set Woodcuttingxpleft=5000
set Cooklvl=1
set Cookxpremain=5000
set Cookxpgain=50
set Cookcurxp=0
set Cookxpleft=5000
set Fishinglvl=1
set Fishingxpremain=5000
set Fishingxpgain=50
set Fishingcurxp=0
set Fishingxpleft=5000
set Mininglvl=1
set Miningxpremain=5000
set Miningxpgain=50
set Miningcurxp=0
set Miningxpleft=100
set Smeltinglvl=1
set Smeltingxpremain=5000
set Smeltingxpgain=50
set Smeltingcurxp=0
set Smeltingxpleft=5000
set Thievinglvl=1
set Thievingxpremain=10000
set Thievingxpgain=25
set Thievingcurxp=0
set Thievingxpleft=10000
set ttllvl=13
set prestige=0
set maxprestige=NO
GOTO SpawnCheck


上面的代码用于设置字符日志文件,下面的代码用于将当前变量保存在当前正在使用的字符日志文件中

:SAVE_GAME_FILES1
(
echo set username1=%username1%
echo set password1=%password1%
echo set mailver=%mailver%
echo set species=%species%
:CHAR_DATA
echo set acc1g=%acc1g%
echo set acc1m=%acc1m%
echo set acc2g=%acc2g%
echo set acc2m=%acc2m%
echo set acc3g=%acc3g%
echo set acc3m=%acc3m%
echo set acc4g=%acc4g%
echo set acc4m=%acc4m%
echo set acc5g=%acc5g%
echo set acc5m=%acc5m%
echo set cost1=%cost1%
echo set cost=%cost%
echo set gcho=%gcho%
echo set echo=%echo%
echo set e2cho=%e2cho%
echo set e1=%e1%
echo set armour=%armour%
echo set origarmour=%origarmour%
echo set Cyrax=%Cyrax%
echo set Fregwin=%Fregwin%
echo set Zeschka=%Zeschka%
echo set Agnorr=%Agnorr%
echo set Grehln=%Grehln%
echo set Meiqa=%Meiqa%
echo set Lothin=%Lothin%
echo set Skatha=%Skatha%
echo set Triffyn=%Triffyn%
echo set Glieza=%Glieza%
echo set Areya=%Areya%
echo set Exin=%Exin%
echo set Yewvar=%Yewvar%
echo set Smuggler=%Smuggler%
echo set Qwaen=%Qwaen%
echo set Oracle=%Oracle%
echo set Antharr=%Antharr%
echo set Cadell=%Cadell%
echo set Rhyghan=%Rhyghan%
echo set Helori=%Helori%
echo set Chaerron=%Chaerron%
echo set Cyntheyrr=%Cyntheyrr%
echo set Mureh=%Mureh%
echo set Llaellyn=%Llaellyn%
echo set Bechim=%Bechim%
echo set Brathach=%Brathach%
echo set Albreqi=%Albreqi%
echo set Tausir=%Tausir%
echo set Mivrailoksh=%Mivrailoksh%
echo set Khaen=%Khaen%
echo set Criunthma=%Criunthma%
echo set Vunada=%Vunada%
echo set VT=%VT%
echo set VC=%VC%
echo set ls1=%ls1%
echo set killcount=%killcount%
echo set ttlbosskill=%ttlbosskill%
echo set ttlmonstkill=%ttlmonstkill%
echo set ttlkills=%ttlkills%
echo set goodness=%goodness%
echo set evilness=%evilness%
echo set morality=%morality%
echo set ls2=%ls2%
echo set la1=%la1%
echo set la2=%la2%
echo set orighp=%orighp%
echo set hp=%hp%
echo set origsp=%origsp%
echo set sp=%sp%
echo set armtype=%armtype%
echo set swordtype=%swordtype%
echo set skind=%skind%
echo set buyword1=%buyword1%
echo set buyword2=%buyword2%
echo set curlvl=%curlvl%
echo set aan=%aan%
echo set bankqharri=%bankqharri%
echo set destination=SAVE_GAME_FILES1
echo set destination2=SAVE_GAME_FILES1
echo set swordchoice=Nothing
echo set swordchoice2=Nothing
echo set swordchoice3=Nothing
echo set swordexist=Nothing
echo set rent=%rent%
echo set sprice=%sprice%
echo set armchoice=%armchoice%
echo set armchoice2=%armchoice2%
echo set aprice=%aprice%
echo set playerxp=0
echo set xpuntil=1000
echo set origxp=%origxp%
echo set money=%money%
echo set platos=%platos%
echo set lovana=%lovana%
echo set ruflarii=%ruflarii%
echo set credits=%credits%
echo set key=%key%
echo set dmge=%dmge%
echo set origdmge=%origdmge%
echo set dr=%dr%
echo set spawn=%spawn%
echo set rests=%rests%
echo set sleep=%sleep%
echo set rochtain=%rochtain%
echo set beer=%beer%
echo set wine=%wine%
echo set spirits=%spirits%
echo set naeprahv=%naeprahv%
echo set drunk=%drunk%
echo set ID=%ID%
echo set day=%week%
echo set week=%week%
echo set month=%month%
echo set year=%year%
echo set status=%status%
echo set gmail=%gmail%
echo set hbone=%hbone%
echo set dhide=%dhide%
echo set rtab=%rtab%
echo set food=%food%
echo set cigarette=%cigarette%
echo set seaweed=%seaweed%
echo set weedcig=%weedcig%
echo set rfood=%rfood%
echo set bait=%bait%
echo set ea=%ea%
echo set potion=%potion%
echo set copperingot=%copperingot%
echo set ironingot=%ironingot%
echo set steelingot=%steelingot%
echo set bronzeingot=%bronzeingot%
echo set brassingot=%brassingot%
echo set tiningot=%tiningot%
echo set silveringot=%silveringot%
echo set goldingot=%goldingot%
echo set zincingot=%zincingot%
echo set manganeseingot=%manganeseingot%
echo set aluminiumingot=%aluminiumingot%
echo set chromiumingot=%chromiumingot%
echo set nickelingot=%nickelingot%
echo set refinedcopper=%refinedcopper%
echo set refinediron=%refinediron%
echo set refinedtin=%refinedtin%
echo set refinedsilver=%refinedsilver%
echo set refinedgold=%refinedgold%
echo set refinedzinc=%refinedzinc%
echo set refinedmanganese=%refinedmanganese%
echo set refinedaluminium=%refinedaluminium%
echo set refinedsilicon=%refinedsilicon%
echo set refinedchromium=%refinedchromium%
echo set refinednickel=%refinednickel%
echo set seed=%seed%
echo set bow=%bow%
echo set fur=%fur%
echo set gem=%gem%
echo set log=%log%
echo set wood=%wood%
echo set copperore=%copperore%
echo set ironore=%ironore%
echo set tinore=%tinore%
echo set silverore=%silverore%
echo set goldore=%goldore%
echo set zincore=%zincore%
echo set manganeseore=%manganeseore%
echo set aluminiumore=%aluminiumore%
echo set siliconore=%siliconore%
echo set chromiumore=%chromiumore%
echo set nickelore=%nickelore%
echo set morb=%morb%
echo set arm1=%arm1%
echo set arm2=%arm2%
echo set arm3=%arm3%
echo set arm4=%arm4%
echo set arm5=%arm5%
echo set arm6=%arm6%
echo set arm7=%arm7%
echo set arm8=%arm8%
echo set arm9=%arm9%
echo set arm10=%arm10%
echo set arm11=%arm11%
echo set arm12=%arm12%
echo set ma1=%ma1%
echo set ma2=%ma2%
echo set ma3=%ma3%
echo set ma4=%ma4%
echo set ma5=%ma5%
echo set ma6=%ma6%
echo set ma7=%ma7%
echo set ma8=%ma8%
echo set ma9=%ma9%
echo set ma10=%ma10%
echo set ms1=%ms1%
echo set ms2=%ms2%
echo set ms3=%ms3%
echo set ms4=%ms4%
echo set ms5=%ms5%
echo set ms6=%ms6%
echo set ms7=%ms7%
echo set ms8=%ms8%
echo set ms9=%ms9%
echo set ms10=%ms10%
echo set sword1=%sword1%
echo set sword2=%sword2%
echo set sword3=%sword3%
echo set sword4=%sword4%
echo set sword5=%sword5%
echo set sword6=%sword6%
echo set sword7=%sword7%
echo set sword8=%sword8%
echo set sword9=%sword9%
echo set sword10=%sword10%
echo set sword11=%sword11%
echo set sword12=%sword12%
echo set axxx=%axxx%
echo set pgmail=%pgmail%
echo set phbone=%phbone%
echo set pdhide=%pdhide%
echo set prtab=%prtab%
echo set ppotion=%ppotion%
echo set pingot=%pingot%
echo set pfood=%pfood%
echo set prfood=%prfood%
echo set pbait=%pbait%
echo set pseed=%pseed%
echo set pfur=%pfur%
echo set pore=%pore%
echo set pbow=%pbow%
echo set plog=%plog%
echo set pgem=%pgem%
echo set pmorb=%pmorb%
echo set Woodcuttinglvl=%Woodcuttinglvl%
echo set Woodcuttingxpremain=%Woodcuttingxpremain%
echo set Woodcuttingxpgain=%Woodcuttingxpgain%
echo set Woodcuttingcurxp=%Woodcuttingcurxp%
echo set Woodcuttingxpleft=%woodcuttingxpleft%
echo set Cooklvl=%Cooklvl%
echo set Cookxpremain=%Cookxpremain%
echo set Cookxpgain=%Cookxpgain%
echo set Cookcurxp=%Cookcurxp%
echo set Cookxpleft=%Cookxpleft%
echo set Fishinglvl=%Fishinglvl%
echo set Fishingxpremain=%Fishingxpremain%
echo set Fishingxpgain=%Fishingxpgain%
echo set Fishingcurxp=%Fishingcurxp%
echo set Fishingxpleft=%Fishingxpleft%
echo set Mininglvl=%Mininglvl%
echo set Miningxpremain=%Miningxpremain%
echo set Miningxpgain=%Miningxpgain%
echo set Miningcurxp=%Miningcurxp%
echo set Miningxpleft=%Miningxpleft%
echo set Smeltinglvl=%Smeltinglvl%
echo set Smeltingxpremain=%Smeltingxpremain%
echo set Smeltingxpgain=%Smeltingxpgain%
echo set Smeltingcurxp=%Smeltingcurxp%
echo set Smeltingxpleft=%Smeltingxpleft%
echo set Thievinglvl=%Thievinglvl%
echo set Thievingxpremain=%Thievingxpremain%
echo set Thievingxpgain=%Thievingxpgain%
echo set Thievingcurxp=%Thievingcurxp%
echo set Thievingxpleft=%Thievingxpleft%
echo set ttllvl=%ttllvl%
echo set prestige=%prest%
echo set maxprestige=%maxprest%
)>%username1%.bat
GOTO SpawnCheck


登录部分似乎很好,但为了以防万一,下面是它的代码。

:login
cls
set /p name1="Username: "
if not exist "%name1%.bat" (
echo.
echo That is not a valid Username.
timeout /T 3 > nul
GOTO entergame1
)
set /p pass1="Password: "
call %name1%.bat
if %password1% NEQ %pass1% (
echo.
echo That is not a valid Password, please enter your in-game email.
timeout /T 3 > nul
GOTO emailver
)
GOTO SAVE_GAME_FILES1
:emailver
cls
echo.
set /p mailver="In-game Email: "
call %name1%.bat
if %mailver% NEQ %mailver% (
echo.
echo That is not a valid in-game email address.
timeout /T 3 > nul
cls
GOTO entergame1
)
GOTO SAVE_GAME_FILES1


角色创建者部分似乎也很有用,但一旦进入:生育检查,它就会崩溃。

:createuser
@echo off
Title Adrynia
color 0F
cls
echo.
echo What would you like your Username to be?
set /p username1=
set v1f=0
:checkforspaces
set x=!v1f!
set Letter%v1f%=!username1:~%x%,1!
if "!Letter%v1f%!" EQU " " (
echo.
echo.
echo Sorry, you cant use spaces in your Username.
pause > nul
GOTO createuser
)
if NOT "!Letter%v1f%!" EQU "" (
set /a v1f=%v1f%+1
GOTO checkforspaces
)
echo.
echo What would you like your Password to be?
set /p password1=
echo.
echo What would you like your in-game email to be? (This will be used as secondary login/verification option).
set /a rpc=1
set /p mailver=
GOTO choosespecies2

:choosespecies2
@echo off
Title Adrynia
color 0F
cls
echo.
echo What species would you like to be?
echo.
echo 1) Adrynian
echo 2) Bryniskan
echo 3) Cruvoshnian
echo 4) Gangloidian
echo 5) Human
echo 6) Hybrid
echo 7) Sehyapov
echo.
set /p input=
if %input% EQU 1 set species=Adrynian && GOTO CHAR_DATA
if %input% EQU 2 set species=Bryniskan && GOTO CHAR_DATA
if %input% EQU 3 set species=Cruvoshnian && GOTO CHAR_DATA
if %input% EQU 4 set species=Gangloidian && GOTO CHAR_DATA
if %input% EQU 5 set species=Human && GOTO CHAR_DATA
if %input% EQU 6 set species=Hybrid && GOTO CHAR_DATA
if %input% EQU 7 set species=Sehyapov && GOTO CHAR_DATA
GOTO choosespecies2


目前,唯一出现错误的地方是:SpawnCheck和:Masafkel XC,但我保留了代码的其他部分,以防出现任何其他可能导致我当前问题的错误。

我知道批量脚本是一种过时的编码形式,尤其是对于RPG风格的游戏来说,但任何帮助或更正,和/或关于为什么会出现这种情况的信息,都将不胜感激。非常感谢。

我解决了你的问题。我用你的代码行进行了一个简单的测试,下面是测试

工作测试:

@echo off
set spawn= spawn0
if %spawn% == spawn0 GOTO SpawnMenu0
:SpawnMenu0
cls
echo it works
pause
exit

你最初的非工作测试:

@echo off
set spawn= spawn0
if %spawn%=spawn0 GOTO SpawnMenu0
:SpawnMenu0
cls
echo it works
pause
exit

你的问题是等号

if %spawn%=spawn0 GOTO SpawnMenu0

它应该在变量后面有一个空格,然后是两个并排的等号,然后是另一个这样的空格:

if %spawn% == spawn0 GOTO SpawnMenu0

我希望我在SpawnCheck 中帮助解决了您的问题

最新更新