Page 1 of 1

Ghoul

Posted: 17 Sep 2010 11:28
by iarnazca
I had to learn bat files for one of the servers at work. In learning it I made this code. (And kept it as a cookie on the actual file) but now its just gonna sit there.


If any one wants to take it and make it better or look at it or just play the little game real quick feel free.


type "help" for help and "commands" for available commands.

I couldent get the loot command to work because I couldent get it to generate a random number between 1 and 8.
because the loot command didn't work i never scripted equip, unequip and drop. so no items!

the Game can be beaten without looted items though. all you gotta do to "win" is kill the ghoul.

The ghoul was supposed to drop [Thunderfury, Blessed Blade of the Windseeker]

a little world of warcraft joke.

of course you'll need to copy it and paste it into a .bat file

Re: Ghoul

Posted: 17 Sep 2010 11:28
by iarnazca
typing loot will crash it

Code: Select all

@echo off
title Ghoul

:start
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo               Type "help" for help
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo               Scripted by John Newell

echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
pause

echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo                    GHOUL
echo                   v.1.1.0b

echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
pause

echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.

echo What would you like your characters name to be?
:input
set INPUT=
set /P INPUT=%=%
if "%INPUT%"=="" goto input



echo.
echo.
echo Your name is: %INPUT%

set NAME=%INPUT%
set LEVEL=1
set XP=1
set LOC=world1
set COMBAT=0
set DAMAGE=2
set HEALTH=10
set MAXHEALTH=10
set STONES=0
set KEY=0

set LOOTED=0
set EQUIPING=0
set LOOTING=0
set DESTROYING=0

set ITEMSLOTONEID=item0
set ITEMSLOTONENAME=Nothing
set ITEMSLOTTWOID=item0
set ITEMSLOTTWONAME=Nothing
set ITEMSLOTTHREEID=item6
set ITEMSLOTTHREENAME=Bent Longsword
set ITEMSLOTFOURID=item0
set ITEMSLOTFOURNAME=Nothing
set ITEMSLOTFIVEID=item0
set ITEMSLOTFIVENAME=Nothing
set ITEMSLOTSIXID=item0
set ITEMSLOTSIXNAME=Nothing

set BAGSLOTONEID=item0
set BAGSLOTONENAME=Nothing
set BAGSLOTTWOID=item0
set BAGSLOTTWONAME=Nothing
set BAGSLOTTHREEID=item0
set BAGSLOTTHREENAME=Nothing
set BAGSLOTFOURID=item0
set BAGSLOTFOURNAME=Nothing
set BAGSLOTFIVEID=item0
set BAGSLOTFIVENAME=Nothing
set BAGSLOTSIXID=item0
set BAGSLOTSIXNAME=Nothing
set BAGSLOTSEVENID=item0
set BAGSLOTSEVENNAME=Nothing
set BAGSLOTEIGHTID=item0
set BAGSLOTEIGHTNAME=Nothing
set BAGSLOTNINEID=item0
set BAGSLOTNINENAME=Nothing
set BAGSLOTTENID=item0
set BAGSLOTTENNAME=Nothing

set MONEY=100




:world

goto %LOC%

:world1
set AREANAME=Base Camp
set N=world4
set E=world3
set W=world2
set S=world5
set AREADESC=You are at the base camp.  Looking around your proud camp you see the Chiefs hut to the north, the armory to the east, the relief hut to the west, and a pathwat to the main gate to your south.
set MOBID=mob1
goto mobs

:world4
set AREANAME=Chief's Hut
set N=cant
set E=cant
set W=cant
set S=world1
set AREADESC=Thrall sits on his throne eye'ing you.  You may travel to the south back to base camp
set MOBID=mob3
goto mobs

:world2
set AREANAME=Relief Hut
set N=cant
set E=world1
set W=cant
set S=cant
set AREADESC=This is the relief hut.  Heeeals. You may travel east to the crossroads.
set MOBID=mob1
goto mobs

:world3
set AREANAME=Armory
set N=cant
set E=cant
set w=world1
set s=cant
set AREADESC= Weapons are sold from the vendor here.  You may travel west back to base camp.
set MOBID=mob2
goto mobs

:world5
set AREANAME=Path
set N=world1
set E=cant
set W=cant
set S=world6
set AREADESC=You are on a path.  To the north is base camp to the south you can see the main gate to your tribes village.
set MOBID=none
goto mobs

:world6
set AREANAME=Main Gate
set N=world5
set E=cant
set W=cant
set S=world7
set AREADESC=This is the main gate.  A guard is here at all times by order of thrall.
set MOBID=mob6
goto mobs

:world7
set AREANAME=Wilderness
set N=world6
set E=world9
set W=world8
set S=world10
set AREADESC=Your in the wilderness.  Your surrounded by wilderness and you can see a cave entrance to your south.  Its a little rocky to the west.
set MOBID=none
goto mobs

:world8
set AREANAME=Wilderness
set N=cant
set E=world7
set W=cant
set S=world12
set AREADESC=Theres some unusual stones on the ground with an inscription on them.  You pick them up.  You see a cliff wall to the south and wilderness to the east.
set MOBID=none
set STONES=1
goto mobs

:world9
set AREANAME=Wilderness
set N=cant
set E=cant
set W=world7
set S=world11
set AREADESC=Your in the wilderness to the south is some thick trees that you dont think you can make it through.
set MOBID=none
goto mobs

:world12
set AREANAME=Cliff Wall
set N=world8
set E=world10
set W=cant
set S=cant
set AREADESC=You see a cliff wall to your south.  East is the Cave entrance.  There is nothing here.
set MOBID=none
goto mobs

:world10
set AREANAME=Dungeon Entrance
set N=world7
set E=world11
set W=world12
set S=world13
set AREADESC=The dungeon entrance.  Travel south to go inside. Otherwise your surrounded by wilderness.
set MOBID=none
goto mobs

:world11
set AREANAME=Thick Trees
set N=world9
set E=cant
set W=world10
set S=cant
set AREADESC=Your stuck in thick trees.  get outta here!
set MOBID=none
goto mobs

:world13
set AREANAME=Stairs
set N=world10
set E=cant
set W=cant
set S=world14
set AREADESC=Your on a flight of stairs.  There is a dark passage to the south and light to your north.
set MOBID=none
goto mobs

:world14
set AREANAME=Dark Passage
set N=world13
set E=cant
set W=cant
set S=world15
set AREADESC=Your in a dark passage.  Its hard to see.  You think you can feel your way south.
set MOBID=mob4
goto mobs

:world15
set AREANAME=Dark Passage
set N=world14
set E=world16
set W=cant
set S=cant
set AREADESC=North and east both seem to be open.
set MOBID=mob4
goto mobs

:world16
set AREANAME=Dark Passage
set N=cant
set E=world17
set W=world15
set S=cant
set AREADESC=East and West seem to give you an open feeling.
set MOBID=mob4
goto mobs

:world17
set AREANAME=Dark Passage
set N=cant
set E=world18
set W=world16
set S=cant
set AREADESC=You hear breathing to the east.
set MOBID=mob4
goto mobs

:world18
set AREANAME=Cavern
set N=cant
set E=cant
set W=world17
set S=cant
set AREADESC=Your in the lair of the Ghoul!  Its power resenates through your body.  It looks at your with a pleading stare.  You suddenly realise that theres no way you can defeat this monster.  Its just too powerful.  Unless you had some sort of magical item.  An image pops into your mind of some stones.
set MOBID=mob5
goto mobs




:mobs
goto %MOBID%

:none
goto worldend

:mob1
set MOBNAME=Peon
set MOBDESC=He works.
set MOBHEALTH=10
set MOBDAMAGE=1
set MOBALIVE=1
set MOBTALK=Dont bother me...
goto worldend

:mob2
set MOBNAME=Nazca
set MOBDESC=A 5000gs Death Knight
set MOBHEALTH=500
set MOBDAMAGE=20
set MOBALIVE=1
set MOBTALK=Hashcakes is so gay.
goto worldend

:mob3
set MOBNAME=Thrall
set MOBDESC=Cheif of this tribe
set MOBHEALTH=100
set MOBDAMAGE=2
set MOBALIVE=1
set MOBTALK=I have a mission for you %name%.  There is a terrible monstrosity living within our midst.  I have locked him in a dungeon to the south.  You may enter it using this key. [Thrall gives you a key] Kill this monstrosity so we may all live in piece.
goto worldend

:mob4
set MOBNAME=Minion
set MOBDESC=The Ghouls Minion
set MOBHEALTH=10
set MOBDAMAGE=1
set MOBALIVE=1
set MOBTALK=heeauy!?
goto worldend

:mob5
set MOBNAME=Ghoul
set MOBDESC=The Horrible Monstrosity Thrall was talking about!
set MOBHEALTH=100
if "%STONES%"=="0" set MOBDAMAGE=%random%
if "%STONES%"=="1" set MOBDAMAGE=0
set MOBALIVE=1
set MOBTALK=Raaaawr!
goto worldend

:mob6
set MOBNAME=Guard
set MOBDESC=Gate Guard
set MOBHEALTH=25
set MOBDAMAGE=5
set MOBALIVE=1
set MOBTALK=Move along...
goto worldend



:worldend





:engine
echo.
echo.


if "%COMBAT%"=="1" COLOR 4
if "%COMBAT%"=="1" echo %MOBNAME% attacks you for %MOBDAMAGE% damage!
if "%COMBAT%"=="1" set /a HEALTH=%HEALTH%-%MOBDAMAGE%
if "%COMBAT%"=="1" echo You have %HEALTH% health left!
if /i %HEALTH% LSS 1 goto gameover

if "%COMBAT%"=="0" COLOR 7
if "%COMBAT%"=="0" if not "%HEALTH%"=="%MAXHEALTH%" set /a HEALTH=%HEALTH%+1



echo %NAME% you have %HEALTH% health out of %MAXHEALTH%
echo %AREANAME%
echo.
echo %AREADESC%
echo.
if %MOBID%==none goto skip
if "%MOBALIVE%"=="1" echo There is a %MOBNAME% here.
if "%MOBALIVE%"=="0" echo There is a dead %MOBNAME% here.
if "%MOBNAME%"=="Ghoul" if "%MOBALIVE%"=="0" echo Did you kill it?  It just wanted to be your friend.
:skip
echo What would you like to do?

:input2
set INPUT=
set /P INPUT=%=%
if "%INPUT%"=="" goto input2

if "%INPUT%"=="commands" echo attack, N, E, S, W, talk, quit, patchnotes
if "%INPUT%"=="commands" goto input2

if "%INPUT%"=="help" echo.
if "%INPUT%"=="help" echo.
if "%INPUT%"=="help" echo Scripted by Nazca
if "%INPUT%"=="help" echo type "commands" to see commands.
if "%KEY%"=="0" if "%INPUT%"=="help" echo Also, the chief wants to talk to you.
if "%INPUT%"=="help" goto input2


if "%INPUT%"=="quit" goto quit
if "%INPUT%"=="exit" exit


if "%INPUT%"=="attack" if "%MOBALIVE%"=="0" echo You cant attack %MOBNAME%
if "%INPUT%"=="attack" if "%MOBALIVE%"=="0" goto input2
if "%INPUT%"=="attack" if "%MOBALIVE%"=="0" goto engine
if "%INPUT%"=="attack" set COMBAT=1
if "%INPUT%"=="attack" echo You attack the %MOBNAME% for %DAMAGE% damage!
if "%INPUT%"=="attack" set /a MOBHEALTH=%MOBHEALTH%-%DAMAGE%
if "%INPUT%"=="attack" if /i %MOBHEALTH% LSS 0 set MOBHEALTH=0
if "%INPUT%"=="attack" echo He has %MOBHEALTH% health left!






if "%MOBHEALTH%"=="0" if "%MOBALIVE%"=="1" echo %MOBNAME% has died.
if "%MOBHEALTH%"=="0" set COMBAT=0
if "%MOBHEALTH%"=="0" set MOBALIVE=0

if "%INPUT%"=="n" if "%N%"=="cant" echo You cant do that!
if "%INPUT%"=="n" if "%N%"=="cant" goto input2
if "%INPUT%"=="s" if "%S%"=="cant" echo You cant do that!
if "%INPUT%"=="s" if "%S%"=="cant" goto input2
if "%INPUT%"=="e" if "%E%"=="cant" echo You cant do that!
if "%INPUT%"=="e" if "%E%"=="cant" goto input2
if "%INPUT%"=="w" if "%W%"=="cant" echo You cant do that!
if "%INPUT%"=="w" if "%W%"=="cant" goto input2

if "%INPUT%"=="n" set LOC=%N%
if "%INPUT%"=="n" goto world
if "%INPUT%"=="e" set LOC=%E%
if "%INPUT%"=="e" goto world
if "%INPUT%"=="s" if "%LOC%"=="world10" if "%KEY%"=="0" echo You need the key to go inside the dungeon!
if "%INPUT%"=="s" if "%LOC%"=="world10" if "%KEY%"=="0" goto input2

if "%INPUT%"=="s" set LOC=%S%
if "%INPUT%"=="s" goto world
if "%INPUT%"=="w" set LOC=%W%
if "%INPUT%"=="w" goto world

if "%INPUT%"=="talk" echo You talk to %MOBNAME%
if "$INPUT%"=="talk" if "%MOBALIVE%"=="0" echo You cant speak with the dead...
if "%INPUT%"=="talk" if "%MOBALIVE%"=="0" goto input2
if "%INPUT%"=="talk" echo %MOBNAME% says "%MOBTALK%"
if "%INPUT%"=="talk" if "%MOBNAME%"=="Thrall" set KEY=1
if "%INPUT%"=="talk" goto input2

if "%INPUT%"=="patchnotes" echo 1.0.0
if "%INPUT%"=="patchnotes" echo You can kill the ghoul.  Its sad you killed him.
if "%INPUT%"=="patchnotes" echo 1.0.1
if "%INPUT%"=="patchnotes" echo Changed input interface to a not stupid one.
if "%INPUT%"=="patchnotes" echo Added a small world.
if "%INPUT%"=="patchnotes" echo 1.0.2
if "%INPUT%"=="patchnotes" echo You are no longer invincible
if "%INPUT%"=="patchnotes" echo fixed crash when trying to go to an area that doesn't exist.
if "%INPUT%"=="patchnotes" echo 1.0.3
if "%INPUT%"=="patchnotes" echo Talking is more user friendly now.
if "%INPUT%"=="patchnotes" echo 1.1.0
if "%INPUT%"=="patchnotes" echo Items!  You can loot and equip items!

if "%INPUT%"=="loot" if "%MOBALIVE%"=="1" echo Hey!
if "%INPUT%"=="loot" if "%MOBALIVE%"=="1" set COMBAT=1
if "%INPUT%"=="loot" if "%MOBALIVE%"=="1" goto engine

if "%INPUT%"=="loot" if "%MOBALIVE%"=="0" goto lootingfirst

if "%INPUT%"=="bag" echo SLOT 1  - %BAGSLOTONENAME%
if "%INPUT%"=="bag" echo SLOT 2  - %BAGSLOTTWONAME%
if "%INPUT%"=="bag" echo SLOT 3  - %BAGSLOTTHREENAME%
if "%INPUT%"=="bag" echo SLOT 4  - %BAGSLOTFOURNAME%
if "%INPUT%"=="bag" echo SLOT 5  - %BAGSLOTFIVENAME%
if "%INPUT%"=="bag" echo SLOT 6  - %BAGSLOTSIXNAME%
if "%INPUT%"=="bag" echo SLOT 7  - %BAGSLOTSEVENNAME%
if "%INPUT%"=="bag" echo SLOT 8  - %BAGSLOTEIGHTNAME%
if "%INPUT%"=="bag" echo SLOT 9  - %BAGSLOTNINENAME%
if "%INPUT%"=="bag" echo SLOT 10 - %BAGSLOTTENNAME%


goto engine




:lootingfirst

if "%MOBNAME%"=="Ghoul" set LOOTING=1
if "%MOBNAME%"=="Ghoul" goto item10

:loopone
set RND=set /a %random% % 7 +1
goto finish01
:finish01


set LOOTING=1
goto item%RND%

:looting




if "%BAGSLOTONEID%"=="item0" set "%BAGSLOTONEID%"=="item%random%"
if "%BAGSLOTONEID%"=="item0" set "%BAGSLOTONENAME%"=="%ITEMNAME%"
if "%BAGSLOTONENAME%"=="%ITEMNAME%" goto engine
:bag2
if "%BAGSLOTTWOID%"=="item0" set "%BAGSLOTTWOID%"=="item%random%"
if "%BAGSLOTTWOID%"=="item0" set "%BAGSLOTTWONAME%"=="%ITEMNAME%"
if "%BAGSLOTTHREENAME%"=="%ITEMNAME%" goto engine
:bag3
if "%BAGSLOTTHREEID%"=="item0" set "%BAGSLOTTHREEID%"=="item%random%"
if "%BAGSLOTTHREEID%"=="item0" set "%BAGSLOTTHREENAME%"=="%ITEMNAME%"
if "%BAGSLOTTHREENAME%"=="%ITEMNAME%" goto engine
:bag4
if "%BAGSLOTFOURID%"=="item0" set "%BAGSLOTFOURID%"=="item%random%"
if "%BAGSLOTFOURID%"=="item0" set "%BAGSLOTFOURNAME%"=="%ITEMNAME%"
if "%BAGSLOTFOURNAME%"=="%ITEMNAME%" goto engine
:bag5
if "%BAGSLOTFIVEID%"=="item0" set "%BAGSLOTFIVEID%"=="item%random%"
if "%BAGSLOTFIVEID%"=="item0" set "%BAGSLOTFIVENAME%"=="%ITEMNAME%"
if "%BAGSLOTFIVENAME%"=="%ITEMNAME%" goto engine
:bag6
if "%BAGSLOTSIXID%"=="item0" set "%BAGSLOTSIXID%"=="item%random%"
if "%BAGSLOTSIXID%"=="item0" set "%BAGSLOTSIXNAME%"=="%ITEMNAME%"
if "%BAGSLOTSIXNAME%"=="%ITEMNAME%" goto engine
:bag7
if "%BAGSLOTSEVENID%"=="item0" set "%BAGSLOTSEVENID%"=="item%random%"
if "%BAGSLOTSEVENID%"=="item0" set "%BAGSLOTSEVENNAME%"=="%ITEMNAME%"
if "%BAGSLOTSEVENNAME%"=="%ITEMNAME%" goto engine
:bag8
if "%BAGSLOTEIGHTID%"=="item0" set "%BAGSLOTEIGHTID%"=="item%random%"
if "%BAGSLOTEIGHTID%"=="item0" set "%BAGSLOTEIGHTNAME%"=="%ITEMNAME%"
if "%BAGSLOTEIGHTNAME%"=="%ITEMNAME%" goto engine
:bag9
if "%BAGSLOTNINEID%"=="item0" set "%BAGSLOTNINEID%"=="item%random%"
if "%BAGSLOTNINEID%"=="item0" set "%BAGSLOTNINENAME%"=="%ITEMNAME%"
if "%BAGSLOTNINENAME%"=="%ITEMNAME%" goto engine
:bag10
if "%BAGSLOTTENID%"=="item0" set "%BAGSLOTTENID%"=="item%random%"
if "%BAGSLOTTENID%"=="item0" set "%BAGSLOTTENNAME%"=="%ITEMNAME%"
if "%BAGSLOTTENNAME%"=="%ITEMNAME%" goto engine

echo "Your bags are full."
goto engine



:equiping
set /a DAMAGE=%DAMAGE%+ITEMDAMAGE
set /a MAXHEALTH=%MAXHEALTH%+%ARMORVALUE%

:quit
echo are you sure you want to quit? (y,n)
set INPUT=
set /P INPUT=%=%
if "%INPUT%"=="y" exit
goto engine

:gameover
COLOR 7
echo.
echo                   You have died.
echo                   Game Over
echo                   Credits:
echo                   John Newell - Programming
echo                   John Newell - Story
echo                   Some one say [Thunderfury, Blessed Blade of the Windseeker]
echo.
echo.
echo.
echo.
echo.
echo.

pause
exit

:items

:item0
set ITEMNAME=Nothing
set ITEMTYPE=nothing
set ITEMDAMAGE=0
set ITEMLEVEL=0
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item1
set ITEMNAME=Broken Sword
set ITEMTYPE=oweapon
set ITEMDAMAGE=1
set ITEMLEVEL=1
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item10

set ITEMNAME=[Thunderfury Blessed Blade of the Windseeker]
set ITEMTYPE=oweapon
set ITEMDAMAGE=53
set ITEMLEVEL=80
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying


:item3

set ITEMNAME=Helmet
set ITEMTYPE=head
set ITEMDAMAGE=0
set ITEMLEVEL=1
set ARMORVALUE=10
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item4
set ITEMNAME=Cracked Breastplate
set ITEMTYPE=chest
set ITEMDAMAGE=0
set ITEMLEVEL=1
set ARMORVALUE=10
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item5
set ITEMNAME=Soggy Wooden Shield
set ITEMTYPE=shield
set ITEMDAMAGE=0
set ITEMLEVEL=1
set ARMORVALUE=30
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item6
set ITEMNAME=Bent Longsword
set ITEMTYPE=tweapon
set ITEMDAMAGE=10
set ITEMLEVEL=1
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying

:item7
set ITEMNAME=Combat Boots
set ITEMTYPE=feet
set ITEMDAMAGE=0
set ITEMLEVEL=1
set ARMORVALUE=5
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying


:item2
set ITEMNAME=Parachute Pants
set ITEMTYPE=pants
set ITEMDAMAGE=0
set ITEMLEVEL=1
set ARMORVALUE=5
if "%EQUIPING%"=="1" goto equipitem
if "%LOOTING%"=="1" goto looting
if "%DESTROYING%"=="1" goto destroying



Re: Ghoul

Posted: 08 Mar 2011 11:46
by iarnazca

Code: Select all

@echo off &setlocal
set "number=12345678"
set /a x1=%random%%%8
call set "ros=%%number:~%x1%,1%%"
ECHO %ros%
pause



Code by Batmaster with help from aGerman.

Solution to the looting problem. Should generate a random number between 1 and 8

Re: Ghoul

Posted: 08 Mar 2011 12:33
by aGerman
What about

Code: Select all

@echo off &setlocal
set /a ros=%random% %% 8 + 1
echo %ros%
pause

Regards
aGerman