I have two problems in this code at the moment, attempting to write out a smiple battle system.
1.
: PlrTrnGob
if %ehp% LSS 1 goto Win
This gives an error of "1 was not expected at this time"
2.
: PlrTrnGob
echo Player HP: %php%
echo Enemy HP: %ehp%
these display the text "Player HP" and "Enemy HP", but not the variables
code is below.
@echo off
if not exist %appdata%\Ld22PPursuit mkdir %appdata%\Ld22PPursuit
if not exist %appdata%\Ld22PPursuit\Goblin mkdir %appdata%\Ld22PPursuit\Goblin
if not exist %appdata%\Ld22PPursuit\Player mkdir %appdata%\Ld22PPursuit\Player
if not exist %Appdata%\LD22PPursuit\Goblin\Attack.tas echo 2 > %Appdata%\LD22PPursuit\Goblin\Attack.tas
if not exist %Appdata%\LD22PPursuit\Goblin\Defense.tas echo 2 > %Appdata%\LD22PPursuit\Goblin\Defense.tas
if not exist %Appdata%\LD22PPursuit\Goblin\Dexterity.tas echo 2 > %Appdata%\LD22PPursuit\Goblin\Dexterity.tas
if not exist %Appdata%\LD22PPursuit\Goblin\BaseHealth.tas echo 5 > %Appdata%\LD22PPursuit\Goblin\BaseHealth.tas
if not exist %Appdata%\LD22PPursuit\Player\Attack.tas echo 4 > %Appdata%\LD22PPursuit\Player\Attack.tas
if not exist %Appdata%\LD22PPursuit\Player\Defense.tas echo 1 > %Appdata%\LD22PPursuit\Player\Defense.tas
if not exist %Appdata%\LD22PPursuit\Player\Dexterity.tas echo 3 > %Appdata%\LD22PPursuit\Player\Dexterity.tas
if not exist %Appdata%\LD22PPursuit\Player\BaseHealth.tas echo 10 > %Appdata%\LD22PPursuit\Player\BaseHealth.tas
cls
:Welcome
echo Welcome to ArenaTech
echo.
set /p log="Login or Quit? "
if /i %log%==login goto Login
if /i %log%==quit goto Quit
:Login
cls
set /p user="Username: "
cls
echo Username: %user%
set /p %pass%="Password: "
cls
echo Welcome back %user%
echo Please wait while we load your user profile.
ping localhose -n 3 >nul
:Menu
cls
echo You may fight or shop.
echo.
set /p choice="What would you like to do? "
if /i %choice%==fight goto Fight
if /i %choice%==shop goto Shop
:Fight
cls
echo You may fight the following creatures.
echo.
echo Goblin
echo Quit
echo.
set /p choice="What would you like to fight? "
if /i %choice%==goblin goto Gob
if /i %choice%==quit goto Quit
:Gob
cls
set eatt=< %Appdata%\Ld22PPursuit\Goblin\Attack.tas
set edef=< %Appdata%\Ld22PPursuit\Goblin\Defense.tas
set edex=< %Appdata%\Ld22PPursuit\Goblin\Dexterity.tas
set ehp=< %Appdata%\Ld22PPursuit\Goblin\BaseHealth.tas
set patt=< %Appdata%\Ld22PPursuit\Player\Attack.tas
set pdef=< %Appdata%\Ld22PPursuit\Player\Defense.tas
set pdex=< %Appdata%\Ld22PPursuit\Player\Dexterity.tas
set php=< %Appdata%\Ld22PPursuit\Player\BaseHealth.tas
goto PlrTrnGob
:PlrTrnGob
cls
if %ehp% LSS 1 goto Win
if %php% LSS 1 goto Lose
echo A goblin stands before you
echo Player HP: %php%
echo Enemy HP: %ehp%
echo.
echo Attack
echo Flee (N/A)
echo Quit
echo.
set /p action="What would you like to do? "
if /i %action%==attack goto Tohitp
if /i %action%==defend goto Defend
if /i %action%==flee goto Flee
if /i %action%==quit goto Quit
:Flee
echo You run away in shame
goto Menu
:Tohitp
set rnd=%random%
if %rnd% GTR 20 goto Tohitp
set /a hit=%pdex% + %rnd%
if %hit% GEQ 15 echo You hit!
if %hit% GEQ 15 ping localhost -n 3 >nul
if %hit% GEQ 15 goto Dmgp
if %hit% LEQ 15 echo You miss!
if %hit% LEQ 15 ping localhost -n 3 >nul
if %hit% LEQ 15 goto Tohite
:Dmgp
set /a %dmg%=%patt% - %edef%
set /a %ehp%=%ehp% - %dmg%
goto Tohite
:Tohite
set rnd=%random%
if %rnd% GTR 20 goto Tohite
set /a hit=%pdex% + %rnd%
if %hit% GEQ 15 echo Enemy hits!
if %hit% GEQ 15 ping localhost -n 3 >nul
if %hit% GEQ 15 goto Dmge
if %hit% LEQ 15 echo Enemy misses!
if %hit% LEQ 15 ping localhost -n 3 >nul
if %hit% LEQ 15 goto PlrTrnGob
:Dmge
set /a %dmg%=%eatt% - %pdef%
set /a %php%=%php% - %dmg%
goto Tohite
:Win
echo You Win
echo.
echo.
echo Please wait while we record your battle statistics.
ping localhost -n3 >nul
goto Menu
:Lose
echo You Lose
echo.
echo.
echo Please wait while we record your battle statistics.
ping localhost -n3 >nul
goto Menu
:Quit
cls
echo ArenaTech Copyright Jeremy Fryer
echo.
echo Thank you for playing.
ping localhost /n 4 >nul
pause
Need some help here.
Moderator: DosItHelp
Re: Need some help here.
The variables are not defined since you use a simple SET for reading data from a file. Use SET /P instead (in block :Gob).
Regards
aGerman
Regards
aGerman
Re: Need some help here.
Thank you for your help, but now I get missing operand and missing operator errors whenever it tries to process blocks
:Dmgp
:Dmge
:Dmgp
:Dmge
Re: Need some help here.
oh wait, my bad, that was a stupid mistake.