As shown in my "A.I." discussion, I prefer to avoid graphics. Any ideas on how to create a text-based game?
Interactive Fiction
Blitz3D Forums/Blitz3D Programming/Interactive Fiction research how to write a parser. Do a google search on the various types of parsers used in various adventure games from the 80's and 90's.
moving, keeping track of objects etc. is just adding and subtracting from lists, but the parser is what makes or breaks your game.
Most parsers are simple, just reacting to certain words or phrases, but even a simple parser for an adventure game can add great depth to the game.
Andy
moving, keeping track of objects etc. is just adding and subtracting from lists, but the parser is what makes or breaks your game.
Most parsers are simple, just reacting to certain words or phrases, but even a simple parser for an adventure game can add great depth to the game.
Andy
Ive made a few in my youth.. I might give you a structure when I come back from work today.
Ok, this is how i would set it up with Blitz:
Type Room
Field Nr ; Number of the room (might be useful)
Field Name$ ; Short name of the room eg. The Cave
Field ShortDesc$ ; Gives short description of a room eg. The cave is dark and wet
Field LongDesc$ ; You are standing in the middle of a dark and wet cave. A breeze
; can be felt from somewhere.
Field Exits[12] ; Holds the number of the room you will come to if you type any of
; the directions (up, down, in, out, n,w,e,s.. etc)
Field Holds[10] ; The room can hold up to 20 objects (stores objectnumber)
End type
Type Message
Field Nr
Field Mess$
Endtype
Type Object
Field Nr
Field Name
Field Weight
Field Shortdesc$
Field Longdesc$
End type
Type Noun
Field Nr
Field word[2]
Endtype
Type Verb
Field Nr
Field word[4]
Endtype
Type adverb ; this one is used for everything else, prepositions, adverb and words that just will be ignored but not giving errormessage from engine (like 'an','the')
Field Nr
Field word
End type
Ok, then you set up code like this:
Precode (whats happening before player types? Eg. Timeevents)
Player inputs words
Engine check words with all the words in Objects, Noun, Verb and Adverb and “flags” them to be used.
Processcode: if Verb 3 and Noun 2 then Mess 9
If verb 7 and noun 11 then goto room 2, describe room
If verb 28 and object X and room Y contains object X then pick up object
Etc etc
Then just finishing code to set flags correct and start over again
hope it did make any sense
Type Room
Field Nr ; Number of the room (might be useful)
Field Name$ ; Short name of the room eg. The Cave
Field ShortDesc$ ; Gives short description of a room eg. The cave is dark and wet
Field LongDesc$ ; You are standing in the middle of a dark and wet cave. A breeze
; can be felt from somewhere.
Field Exits[12] ; Holds the number of the room you will come to if you type any of
; the directions (up, down, in, out, n,w,e,s.. etc)
Field Holds[10] ; The room can hold up to 20 objects (stores objectnumber)
End type
Type Message
Field Nr
Field Mess$
Endtype
Type Object
Field Nr
Field Name
Field Weight
Field Shortdesc$
Field Longdesc$
End type
Type Noun
Field Nr
Field word[2]
Endtype
Type Verb
Field Nr
Field word[4]
Endtype
Type adverb ; this one is used for everything else, prepositions, adverb and words that just will be ignored but not giving errormessage from engine (like 'an','the')
Field Nr
Field word
End type
Ok, then you set up code like this:
Precode (whats happening before player types? Eg. Timeevents)
Player inputs words
Engine check words with all the words in Objects, Noun, Verb and Adverb and “flags” them to be used.
Processcode: if Verb 3 and Noun 2 then Mess 9
If verb 7 and noun 11 then goto room 2, describe room
If verb 28 and object X and room Y contains object X then pick up object
Etc etc
Then just finishing code to set flags correct and start over again
hope it did make any sense
Here's a small text adventure I made for a mini competition.
AppTitle "D A R K N E S S" Graphics 640,480,0,1 ;----------------; ;Global Variables;-------------------------------------------------------- ;----------------; Global Room = 13 ;Current room number Global Shown = False ;Area description has been shown Global Typed$ = "" ;Player input Global North = False ;Can go North Global South = False ;Can go South Global East = False ;Can go East Global West = False ;Can go South Global Up = False ;Can go Up Global Down = False ;Can go Down Global RoomGrid = 5 ;Number of rooms = RoomGrid x RoomGrid Global In = 0 ;Items inside a container Global InText = 0 ;Shown inside container list Global Items = False ;Player is carrying items Global Hint = 1 ;Hint number to show Global Help$ = "" ;Help text to display Global Turn = 0 ;How many turns Global PlayerDead = False ;Died Global PlayerOnItem$ = "" ;Standing on item Global PlayerScore = 0 ;Current score Global MaxPoints = 100 ;Maximum amount of points available Global MaxItems = 5 ;Maximun items the player can carry Global PlayerItems = 0 ;Items carried by player Global PlayerHunger = 100 ;Turns until death by hunger Global PlayerThirst = 70 ;Turns until death by thirst Global StartHunger = 70 ;Maximum turns before death by hunger Global StartThirst = 70 ;Maximum turns before death by thirst Global GameCompleted = False ;Completed the game Global Bound = True ;Player bound at start Global CuffScore = False ;Earned points for removing cuffs Global LockScore = False ;Earned points for unlocking ladder Global HelpScore = False ;Earned points for giving money to homeless man Global HitScore = False ;Earned points for killed bad guy Global DogScore = False ;Earned points for feeding the dog ;------; ;Arrays;------------------------------------------------------------------ ;------; Dim ReadLines$ (999) ;Amount of text lines to make Dim TalkLines$ (999) ;Amount of talk lines to make ;-------------------------; ;Create Text Lines To Read;----------------------------------------------- ;-------------------------; CreateReadLines() Function CreateReadLines() ReadLines$(000) = " D A R K N E S S " ReadLines$(001) = " " ReadLines$(002) = " C O D E D " ReadLines$(003) = " " ReadLines$(004) = " B Y " ReadLines$(005) = " " ReadLines$(006) = " J U A N " ReadLines$(007) = "Free To Hate Heaven " End Function ;------------------------------; ;Create Dialogue For Characters;------------------------------------------ ;------------------------------; CreateTalkLines() Function CreateTalkLines() TalkLines$(000) = "Can you spare some loose change sir? " TalkLines$(001) = "Thank you very much. " TalkLines$(002) = "There is a man waiting for you in the car park. He's got a gun! " End Function ;------------; ;Custom Types;------------------------------------------------------------ ;------------; Type Item Field Room ;Item location Field Description$ ;Description of item Field DescriptionB$ ;Description of item after it has been used Field Carried ;Player is carrying the item Field Pick ;Item can be picked up Field Name$ ;Item name Field Use$ ;Name of item that this item can be used with Field Used ;Item has been used or not Field UseText$ ;Text to display when using the item Field Readable ;Item is readable i.e a book/newpaper etc Field ReadStart ;Line to start reading from Field ReadLines ;How many lines to read Field Eat ;Can eat the item Field Drink ;Can drink the item Field Effect ;Effect item has Field EffectText$ ;Text to display when eating\drinking item Field Locked ;Item is locked Field Open ;Item is open Field Closed ;Item is closed Field Inside$ ;Item is inside another item Field Examined ;Item has been examined Field OnTop$ ;Item is on top of another item Field Weapon ;Item can be used as a weapon Field Break$ ;Item is breakable with another object Field Container ;Item can have items placed inside Field Surface ;Item can have things placed on top Field Stand ;Player can stand on this item Field Climb ;Player can climb object i.e ladder/rope Field Slots ;How many items a container can hold Field Hidden ;Item name is not shown in room Field CanTurn ;Can be turned on/off Field Turn ;Turned on/off Field Move ;Can be moved/pushed/pulled Field Combo$ ;Combination to a lock Field Worn ;Item is worn Field CanBeWorn ;Item is wearable End Type Type Enemy Field Name$ ;Name or short description of enemy Field Room ;Enemy location Field Description$ ;Description of enemy Field Inside$ ;Inside an item i.e wardrobe etc Field Kill$ ;Item that kills this enemy Field KillText$ ;Text to show when you kill this enemy Field KillByText$ ;Text to show if you are killed by this enemy Field Action$ ;What enemy does when found i.e "jumps" out of the wardrobe Field Examined ;Enemy has been examined Field Hidden ;Don't show to player Field Item$ ;Item to give this enemy Field Given ;Given item to this enemy End Type Type Character Field Name$ ;Characters name Field Room ;Where the character is Field Description$ ;What the character looks like Field Inside$ ;Character starts inside an item i.e coffin Field TalkStart ;Line to start talking from Field TalkLines ;How many lines to talk Field TalkStartB ;Line to start talking from after giving item Field TalkLinesB ;How many lines to talk after giving item Field Action$ ;What character does when found i.e "climbs" out of the coffin Field Hidden ;Don't show to player Field Item$ ;Item character wants Field Given ;Player has given this character their item End Type Type Event Field Turn ;Turn to play this event on Field Item$ ;Item to create Field Enemy$ ;Enemy to create Field Character$ ;Character to create Field Event$ ;Text to shown when event happens Field Room ;Room event happens in Field Kill ;Event kills player End Type ;-----; ;Title;------------------------------------------------------------------- ;-----; Cls SetStyle (255,255,255,24,1,0,0) Text 319,239,"D A R K N E S S",1,1 Text 320,239,"D A R K N E S S",1,1 Text 321,239,"D A R K N E S S",1,1 Text 319,240,"D A R K N E S S",1,1 Text 321,240,"D A R K N E S S",1,1 Text 319,241,"D A R K N E S S",1,1 Text 320,241,"D A R K N E S S",1,1 Text 321,241,"D A R K N E S S",1,1 SetStyle (0,0,0,24,1,0,0) Text 320,240,"D A R K N E S S",1,1 FlushKeys() WaitKey() FlushKeys() Cls SetStyle (255,255,255,14,0,0,0) Locate 0,0 Print "Waking from a deep sleep, you soon come to your senses and realise that you " Print "are in grave danger. You have been hand cuffed and your feet are tightly " Print "bound together. Your bruised skin stings as a bead of sweat drips from your " Print "forehead. At the window, snow can be seen settling in the corners of it's " Print "frame. A cool breeze blows gently in through a large crack in the glass... " WaitKey() FlushKeys() ;----------; ;Setup Game; ;----------; Restart() Function Restart() Cls Room = 13 ;Starting room number Shown = False ;Area description has been shown Hint = 1 ;Hint number to show Turn = 0 ;How many turns PlayerDead = False ;Died PlayerOnItem$ = "" ;Standing on item PlayerScore = 0 ;Current score MaxPoints = 100 ;Maximum amount of points available MaxItems = 5 ;Maximum items the player can carry PlayerItems = 0 ;Items carried by player PlayerHunger = 100 ;Turns until death by hunger PlayerThirst = 70 ;Turns until death by thirst StartHunger = PlayerHunger ;Maximum turns before death by hunger StartThirst = PlayerThirst ;Maximum turns before death by thirst GameCompleted = False ;Completed the game Bound = True ;Player bound at start CuffScore = False ;Player earned points for removing cuffs LockScore = False ;Player earned points for unlocking the ladder HelpScore = False ;Player earned points for giving money to homeless man HitScore = False ;Player earned points for killed bad guy DogScore = False ;Player earned points for feeding the dog ;----------------; ;Delete Old Types;-------------------------------------------------------- ;----------------; For IM.Item = Each Item Delete IM Next For EY.Enemy = Each Enemy Delete EY Next For CR.Character = Each Character Delete CR Next For ET.Event = Each Event Delete CR Next ;-------------; ;Create Events;----------------------------------------------------------- ;-------------; ET.Event = New Event ET\Turn = 20 ET\Event = "Suddenly, the door bursts open. A dark man with a gun enters. You are executed!" ET\Kill = True ET\Room = 13 ;-----------------; ;Create Characters;------------------------------------------------------- ;-----------------; CR.Character = New Character CR\Room = 22 CR\Name = "homeless man" CR\Description = "He looks awful!" CR\TalkStart = 0 CR\TalkLines = 0 CR\Item = "loose change" CR\TalkStartB = 1 CR\TalkLinesB = 2 ;--------------; ;Create Enemies;---------------------------------------------------------- ;--------------; EY.Enemy = New Enemy EY\Room = 17 EY\Name = "bulky man" EY\Description = "A short, bulky man with a shaved head. Looks pretty tough..." EY\Kill = "plank" EY\KillText = "You attack the man from behind, leaving him wounded and unconscious." EY\KillByText = "The man takes a pistol from his jacket. He repeatedly shoots you..." EY.Enemy = New Enemy EY\Room = 24 EY\Name = "dog" EY\Description = "It's a huge, vicious looking creature. Better keep away from it. EY\Item = "chunk of flesh" EY\KillByText = "The dog jumps at you, pulling you to the ground. Then, it rips out your throat." ;------------; ;Create Items;------------------------------------------------------------ ;------------; IM.Item = New Item IM\Name = "car" IM\Room = 17 IM\Hidden = True IM\Description = "It's really beat up. The snow on the trunk has recently been disturbed." IM.Item = New Item IM\Name = "trunk" IM\Locked = True IM\Container = True IM\Closed = True IM\Slots = 1 IM\Room = 17 IM\Hidden = True IM\Description = "The trunk of the car looks like it has recently been locked." IM.Item = New Item IM\Name = "black bag" IM\Description = "A black bag. You don't want to open it..." IM\Inside = "trunk" IM\Hidden = True IM\Room = 17 IM.Item = New Item IM\Name = "chunk of flesh" IM\Inside = "trunk" IM\Pick = True IM\Description = "A bloody piece of flesh. It's human..." IM\Hidden = True IM\Room = 17 IM.Item = New Item IM\Name = "loose change" IM\Carried = True IM\Pick = True IM\Room = 13 IM\Description = "Just a few coins. Nothing much..." IM.Item = New Item IM\Name = "window" IM\Closed = True IM\Description = "A ledge can be seen on the other side of the window." IM\Room = 13 IM\Hidden = True IM.Item = New Item IM\Name = "desk" IM\Description = "The desk is very tidy." IM\Room = 13 IM\Hidden = True IM.Item = New Item IM\Name = "folder" IM\Open = True IM\OnTop = "desk" IM\Container = True IM\Slots = 1 IM\Pick = True IM\Room = 13 IM.Item = New Item IM\Name = "letter" IM\Inside = "folder" IM\Description = "You can read this by typing `read letter'" IM\Readable = True IM\Pick = True IM\Room = 13 IM\Hidden = True IM\ReadStart = 0 IM\ReadLines = 6 IM.Item = New Item IM\Name = "paperclip" IM\OnTop = "letter" IM\Description = "A metal paperclip." IM\Hidden = True IM\Pick = True IM\Use = "cuffs" IM\UseText = "You unlock the hand cuffs using the paperclip." IM\Room = 13 IM.Item = New Item IM\Name = "cuffs" IM\Description = "A pair of hand cuffs." IM\Locked = True IM\Worn = True IM\CanBeWorn = True IM\Carried = True IM\Room = 13 IM.Item = New Item IM\Name = "chair" IM\Room = 13 IM\Hidden = True IM.Item = New Item IM\Name = "jacket" IM\Description = "A man's black leather jacket." IM\OnTop = "chair" IM\Room = 13 IM\Container = True IM\Slots = 1 IM\Open = True IM\Hidden = True IM.Item = New Item IM\Name = "car key" IM\Room = 13 IM\Inside = "jacket" IM\Pick = True IM\Hidden = True IM\Use = "trunk" IM\UseText = "You have unlocked the trunk of the car." IM.Item = New Item IM\Name = "door" IM\Room = 13 IM\Hidden = True IM\Description = "The door is locked from the other side." IM\Locked = True IM.Item = New Item IM\Name = "wall" IM\Room = 9 IM\Hidden = True IM\Description = "Someone has sprayed graffiti on the wall." IM.Item = New Item IM\Name = "graffiti" IM\Room = 9 IM\Hidden = True IM\Readable = True IM\ReadStart = 7 IM\ReadLines = 7 IM\Description = "It reads, Free To Hate Heaven" IM.Item = New Item IM\Description = "It's old and rusted. I hope it's still safe." IM\Room = 18 IM\Hidden = True IM\Name = "ladder" IM.Item = New Item IM\Locked = True IM\Combo = "3287" IM\Name = "lock" IM\Description = "A 4 digit combination lock. Type `set lock to xxxx to use'." IM\Room = 18 IM\Hidden = True IM\Locked = True IM\OnTop = "ladder" IM.Item = New Item IM\Description = "Just trash. Nothing useful." IM\Room = 23 IM\Hidden = True IM\Name = "trash" IM.Item = New Item IM\Description = "Metal trash cans. Mostly old and dented." IM\Room = 23 IM\Hidden = True IM\Name = "trash cans" IM.Item = New Item IM\Description = "A metal trash can..." IM\Room = 21 IM\Hidden = True IM\Name = "trash can" IM\Open = True IM\Container = True IM\Slots = 1 IM.Item = New Item IM\Name = "plank" IM\Description = "A splintered plank of wood. It looks pretty dangerous..." IM\DescriptionB = "A splintered plank of wood. It's covered in blood." IM\Weapon = True IM\Pick = True IM\Hidden = True IM\Inside = "trash can" IM\Room = 21 IM.Item = New Item IM\Name = "rat" IM\Description = "Yuck!" IM\Room = 21 IM\Hidden = True ;-------------; ;Carried Items;----------------------------------------------------------- ;-------------; For IM.Item = Each Item If IM\Carried = True PlayerItems = PlayerItems + 1 EndIf Next ;-----------------------------------------; ;Use Slots In Container And Surfaced Items;------------------------------- ;-----------------------------------------; For IM.Item = Each Item For IMB.Item = Each Item If IM\Inside = IMB\Name IMB\Slots = IMB\Slots - 1 EndIf Next Next For IM.Item = Each Item For IMB.Item = Each Item If IM\OnTop = IMB\Name IMB\Slots = IMB\Slots - 1 EndIf Next Next ;-----; ;Start;------------------------------------------------------------------- ;-----; Refresh() End Function ;------------; ;Command List;------------------------------------------------------------ ;------------; Function Command() SetStyle (200,200,200,14,0,0,0) ;-----------; ;Player Died;------------------------------------------------------------- ;-----------; If PlayerDead = True If Typed = "y" Or Typed = "yes" Restart() ElseIf Typed = "n" Or Typed = "no" End EndIf Turn = Turn - 1 PlayerHungry = PlayerHungry - 1 PlayerThirst = PlayerThirst - 1 Refresh() EndIf ;----------; ;Directions;-------------------------------------------------------------- ;----------; SetStyle (200,200,200,14,0,0,0) If Typed = "west" Or Typed = "w" If PlayerOnItem = "" Print If West = True Then Room = Room - 1 : Shown = False : Refresh() If West = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() ElseIf Typed = "south" Or Typed = "s" If PlayerOnItem = "" Print If South = True Then Room = Room + RoomGrid : Shown = False : Refresh() If South = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() ElseIf Typed = "north" Or Typed = "n" If PlayerOnItem = "" Print If North = True Then Room = Room - RoomGrid : Shown = False : Refresh() If North = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() ElseIf Typed = "east" Or Typed = "e" If PlayerOnItem = "" Print If East = True Then Room = Room + 1 : Shown = False : Refresh() If East = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() ElseIf Typed = "up" Or Typed = "u" If PlayerOnItem = "" Print If Up = True Then Room = Room - RoomGrid : Shown = False : Refresh() If Up = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() ElseIf Typed = "down" Or Typed = "d" If PlayerOnItem = "" Print If Down = True Then Room = Room + RoomGrid : Shown = False : Refresh() If Down = False Then Print "You can't go that way..." : Refresh() Else Print Print "Climb down from the " + PlayerOnItem + " first. EndIf Refresh() EndIf ;--------------; ;Refresh Screen;---------------------------------------------------------- ;--------------; If Typed = "look" Or Typed = "refresh" Shown = False Refresh() EndIf ;---------; ;Quit Game;--------------------------------------------------------------- ;---------; If Typed = "quit" Or Typed = "exit" Or Typed = "escape" Or Typed = "esc" Or Typed = "leave" Or Typed = "end" Or Typed = "stop" Or Typed = "give up" End EndIf ;----------; ;Wear Items;-------------------------------------------------------------- ;----------; For IM.Item = Each Item If Typed = "wear " + IM\Name Or Typed = "put on " + IM\Name SetStyle (50,250,50,14,0,0,0) If IM\Carried = True If IM\CanBeWorn = True If IM\Worn = False Print Print "You put on the " + IM\Name + "." IM\Worn = True Else Print Print "You are already wearing it." EndIf Else Print Print "The " + IM\Name + " cannot be worn." EndIf Else Print Print "You do have the " + IM\Name + "." EndIf Refresh() EndIf Next For IM.Item = Each Item If Typed = "remove " + IM\Name Or Typed = "take off " + IM\Name SetStyle (50,250,50,14,0,0,0) If IM\Worn = True If IM\Locked = False Print Print "You take off the " + IM\Name + "." IM\Worn = False Else Print Print "It's locked." EndIf Else Print Print "You aren't wearing the " + IM\Name + "." EndIf Refresh() EndIf Next ;----; ;---;Take;---------------------------------------------------------------- ;----; For IM.Item = Each Item If (Typed = "get " + IM\Name) Or (Typed = "take " + IM\Name) Or (Typed = "pick up " + IM\Name) SetStyle (50,250,50,14,0,0,0) If IM\Carried = False If IM\Room = Room; And IM\Hidden = False For IMB.Item = Each Item If IM\Inside = IMB\Name If IMB\Open = True If IM\Pick = True If PlayerItems < MaxItems Print Print "You take the " + IM\Name + "." IM\Carried = True IM\Inside = "" IM\OnTop = "" IMB\Slots = IMB\Slots + 1 PlayerItems = PlayerItems + 1 Else Print Print "You can't carry any more." EndIf ElseIf IM\Pick = False Print Print "The " + IM\Name + " cannot be taken." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() EndIf Next For IMB.Item = Each Item If IM\OnTop = IMB\Name If IMB\Examined = True If IM\Pick = True If PlayerItems < MaxItems Print Print "You take the " + IM\Name + "." IM\Carried = True IM\Inside = "" IM\OnTop = "" IMB\Slots = IMB\Slots + 1 PlayerItems = PlayerItems + 1 Else Print Print "You can't carry any more." EndIf ElseIf IM\Pick = False Print Print "The " + IM\Name + " cannot be taken." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() EndIf Next If IM\Pick = True If PlayerItems < MaxItems Print Print "You take the " + IM\Name + "." IM\Carried = True PlayerItems = PlayerItems + 1 Else Print Print "You can't carry any more." EndIf Else Print Print "The " + IM\Name + " cannot be taken." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Else Print Print "You are already carrying the " + IM\Name + "." EndIf Refresh() ;----; ;---;Drop;---------------------------------------------------------------- ;----; ElseIf (Typed = "drop " + IM\Name) Or (Typed = "put down " + IM\Name) SetStyle (50,250,50,14,0,0,0) If IM\Carried = True If IM\Worn = False IM\Carried = False IM\Room = Room Print Print "You have dropped the " + IM\Name + "." PlayerItems = PlayerItems - 1 Else Print Print "You must take off the " + IM\Name + " first." EndIf Else Print Print "You are not carrying the " + IM\Name + "." EndIf Refresh() ;-------; ;---;Examine;------------------------------------------------------------- ;-------; ElseIf (Typed = "examine " + IM\Name) Or (Typed = "look at " + IM\Name) Or (Typed = "ex " + IM\Name) Or (Typed = "search " + IM\Name) And IM\Container = False SetStyle (150,250,150,14,0,0,0) If IM\Room = Room Or IM\Carried = True; And IM\Inside = "" And IM\OnTop = "" IM\Examined = True Print If IM\Description <> "" And IM\Used = False Then Print IM\Description If IM\DescriptionB <> "" And IM\Used = True Then Print IM\DescriptionB If IM\Description = "" And IM\DescriptionB = "" Then Print "Nothing special." Space = True For IMB.Item = Each Item If IMB\Room = Room If IMB\OnTop = IM\Name If IM\Examined = True SetStyle (50,250,50,14,0,0,0) If Space = True Print Print "On the " + IM\Name + " is:" Print Space = False EndIf SetStyle (150,150,250,14,0,0,0) Print "> A " + IMB\Name + "." EndIf EndIf EndIf Next Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() ;----; ;---;Read;---------------------------------------------------------------- ;----; ElseIf (IM\Readable = True And Typed = "read " + IM\Name) SetStyle (150,100,50,14,0,0,0) If IM\Room = Room Or IM\Carried = True Print For A = IM\ReadStart To IM\ReadLines Print ReadLines(A) Next Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() ;---; ;---;Eat;----------------------------------------------------------------- ;---; ElseIf Typed = "eat " + IM\Name Or Typed = "consume " + IM\Name Or Typed = "swallow " + IM\Name SetStyle (50,50,250,14,0,0,0) If IM\Room = Room Or IM\Carried = True If IM\Eat = True Print Print IM\EffectText Select IM\Effect Case 1 PlayerHunger = StartHunger Case 2 PlayerDead = True End Select Delete IM PlayerItems = PlayerItems - 1 Else Print Print "The " + IM\Name + " cannot be eaten." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() ;-----; ;---;Drink;--------------------------------------------------------------- ;-----; ElseIf Typed = "drink " + IM\Name SetStyle (50,50,250,14,0,0,0) If IM\Room = Room Or IM\Carried = True If IM\Drink = True Print Print IM\EffectText Select IM\Effect Case 1 PlayerThirst = StartThirst Case 2 PlayerDead = True End Select Delete IM PlayerItems = PlayerItems - 1 Else Print Print "You can't drink the " + IM\Name + "." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() ;----; ;---;Open;---------------------------------------------------------------- ;----; ElseIf Typed = "open " + IM\Name SetStyle (50,250,50,14,0,0,0) If IM\Room = Room Or IM\Carried = True If IM\Closed = True And IM\Locked = False Print Print "You open the " + IM\Name + "." IM\Open = True IM\Closed = False If IM\Container = True Print Print "The " + IM\Name + " contains:" Print In = 0 For IMB.Item = Each Item If IMB\Room = Room If IMB\Inside = IM\Name In = In + 1 SetStyle (150,150,250,14,0,0,0) If IM\Open = True If In > 0 Then Print "> A " + IMB\Name + "." EndIf EndIf EndIf Next SetStyle (150,150,250,14,0,0,0) If In = 0 Then Print "> Nothing." In = 0 EndIf For EY.Enemy = Each Enemy If EY\Room = Room If EY\Inside = IM\Name In = In + 1 If IM\Open = True SetStyle (250,50,50,14,0,0,0) If In > 0 Print Print "A " + EY\Name + " " + EY\Action + " out of the " + IM\Name + "." EndIf EndIf EY\Inside = "" EndIf EndIf Next ElseIf IM\Closed = True And IM\Locked = True Print Print "It's locked." ElseIf IM\Closed = False And IM\Open = False Print Print "The " + IM\Name + " cannot be opened." ElseIf IM\Closed = False And IM\Open = True Print Print "The " + IM\Name + " is already open." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() ;-----; ;---;Close;--------------------------------------------------------------- ;-----; ElseIf Typed = "close " + IM\Name Or Typed = "shut " + IM\Name SetStyle (50,50,250,14,0,0,0) If IM\Room = Room Or IM\Carried = True If IM\Open = True Print Print "You close the " + IM\Name + "." IM\Closed = True IM\Open = False ElseIf IM\Closed = False And IM\Open = False Print Print "The " + IM\Name + " cannot be closed." ElseIf IM\Closed = True And IM\Open = False Print Print "The " + IM\Name + " is already closed." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() EndIf Next ;--------------; ;Show Inventory;---------------------------------------------------------- ;--------------; Items = False InText = False If Typed = "in" Or Typed = "Inventory" Or Typed = "Carried" SetStyle (50,250,50,14,0,0,0) Print If InText = False Then Print "You are carrying:" : Print : InText = True SetStyle (150,150,250,14,0,0,0) For IM.Item = Each Item If IM\Carried = True Then Print "> A " + IM\Name : Items = True Next If Items = False Then Print "> Nothing" Refresh() EndIf ;---------; ;Use Items;--------------------------------------------------------------- ;---------; For IM.Item = Each Item For IMB.Item = Each Item If IM\Use = IMB\Name If (Typed = "use " + IM\Name + " on " + IMB\Name) Or (Typed = "use " + IM\Name + " with " + IMB\Name) SetStyle (50,50,250,14,0,0,0) If IM\Carried = True IMB\Used = True Print Print IM\UseText If IMB\Worn = True IMB\Worn = False IMB\Carried = False EndIf Refresh() Else Print Print "You aren't carrying the " + IM\Name + "." Refresh() EndIf EndIf EndIf Next Next ;------; ;Unlock;------------------------------------------------------------------ ;------; For IM.Item = Each Item For IMB.Item = Each Item If IMB\Use = IM\Name If (Typed = "unlock " + IM\Name + " with " + IMB\Name) Or (Typed = "unlock " + IM\Name + " using " + IMB\Name) Or (Typed = "pick " + IM\Name + " with " + IMB\Name) Or (Typed = "pick " + IM\Name + " using " + IMB\Name) SetStyle (50,250,50,14,0,0,0) If IM\Room = Room If IM\Locked = True If IMB\Carried = True IM\Used = True IM\Locked = False Print Print IMB\UseText If IMB\Worn = True IMB\Worn = False IMB\Carried = False EndIf Refresh() Else Print Print "You aren't carrying the " + IMB\Name + "." EndIf Else Print Print "The " + IM\Name + " is not locked." EndIf EndIf Refresh() EndIf EndIf Next Next For IM.Item = Each Item If Typed = "unlock " + IM\Name Or Typed = "pick " + IM\Name SetStyle (50,50,250,14,0,0,0) If IM\Room = Room If IM\Locked = True Print Print "You need a key." Else Print Print "It's not locked." EndIf Else Print Print "You can't see the " + IM\Name EndIf Refresh() EndIf Next ;----; ;Lock;-------------------------------------------------------------------- ;----; For IM.Item = Each Item For IMB.Item = Each Item If IMB\Use = IM\Name If (Typed = "lock " + IM\Name + " with " + IMB\Name) Or (Typed = "lock " + IM\Name + " using " + IMB\Name) SetStyle (50,50,250,14,0,0,0) If IM\Room = Room If IM\Locked = False If IMB\Carried = True IM\Used = False Print Print "You have locked the " + IM\Name + "." Refresh() Else Print Print "You aren't carrying the " + IMB\Name + "." EndIf Else Print Print "The " + IM\Name + " is already locked." Refresh() EndIf EndIf EndIf EndIf Next Next ;----; ;Hint;-------------------------------------------------------------------- ;----; If Typed = "hint" Or Typed = "help" SetStyle (250,200,50,14,0,0,0) Print Print Help Hint = Hint + 1 Refresh() EndIf ;---; ;Hit;--------------------------------------------------------------------- ;---; For IM.Item = Each Item For EY.Enemy = Each Enemy If (Typed = "hit " + EY\Name + " with " + IM\Name) Or (Typed = "attack " + EY\Name + " with " + IM\Name) Or (Typed = "kill " + EY\Name + " with " + IM\Name) Or (Typed = "hit " + EY\Name + " using " + IM\Name) Or (Typed = "attack " + EY\Name + " using " + IM\Name) Or (Typed = "kill " + EY\Name + " using " + IM\Name) SetStyle (250,50,50,14,0,0,0) If EY\Room = Room And EY\Inside = "" And EY\Hidden = False If IM\Carried = True If IM\Weapon = True If IM\Name = EY\Kill Print Print EY\KillText IM\Used = True Space = False For IM.Item = Each Item If IM\OnTop = EY\Name Space = True SetStyle (50,250,50,14,0,0,0) If Space = True Print Print "The " + EY\Name + " dropped:" Print Space = False EndIf SetStyle (150,150,250,14,0,0,0) Print "> A " + IM\Name + "." IM\Room = Room IM\Inside = "" IM\OnTop = "" IM\Carried = False EndIf Next Delete EY Else SetStyle (250,50,50,14,0,0,0) Print Print "Your foolish attemps to harm the " + EY\Name + " end in tragedy..." Print EY\KillByText PlayerDead = True EndIf Else Print Print IM\Name + " is not a weapon." EndIf Else Print Print "You are not carrying the " + IM\Name + "." EndIf Else Print Print "You cannot see the " + EY\Name + "." EndIf Refresh() EndIf Next Next For IM.Item = Each Item For EY.Enemy = Each Enemy If EY\Room = Room And EY\Inside = "" And EY\Hidden = False If Typed = "hit " + EY\Name Or Typed = "attack " + EY\Name Or Typed = "hit" + EY\Name Or Typed = "attack " + EY\Name Or Typed = "kill " + EY\Name Or Typed = "squash " + EY\Name Or Typed = "squish " + EY\Name Or Typed = "crush " + EY\Name Or Typed = "punch " + EY\Name Or Typed = "kick " + EY\Name Or Typed = "Step on " + EY\Name Or Typed = "jump on " + EY\Name Or Typed = "slap " + EY\Name SetStyle (255,50,50,14,0,0,0) Print Print "Your foolish attemps to harm the " + EY\Name + " end in tragedy..." Print EY\KillByText PlayerDead = True Refresh() EndIf EndIf Next Next For IM.Item = Each Item For IMB.Item = Each Item If (Typed = "hit " + IMB\Name + " with " + IM\Name) Or (Typed = "break " + IMB\Name + " with " + IM\Name) Or (Typed = "hit " + IMB\Name + " using " + IM\Name) Or (Typed = "break " + IMB\Name + " using " + IM\Name) SetStyle (50,250,50,14,0,0,0) If IM\Carried = True And IMB\Carried = True If IMB\Break = IM\Name And IMB\Used = False Print Print "You break the " + IMB\Name + " with the " + IM\Name + "." IMB\Open = True IMB\Used = True For IMC.Item = Each Item If IMC\Inside = IMB\Name If IMB\Open = True IMC\Room = Room IMC\Carried = False IMC\Inside = "" Print Print "There is a " + IMC\Name + " inside the " + IMB\Name + "." EndIf EndIf Next Else Print Print "You can't do that." EndIf Else Print If IM\Carried = False Then Print "You are not carrying the " + IM\Name + "." If IMB\Carried = False Then Print "You are not carrying the " + IMB\Name + "." EndIf Refresh() EndIf Next Next ;-------------------------------; ;Put Items On Top Of Other Items;----------------------------------------- ;-------------------------------; For IM.Item = Each Item For IMB.Item = Each Item If (Typed = "put " + IM\Name + " on " + IMB\Name) Or (Typed = "place " + IM\Name + " on " + IMB\Name) Or (Typed = "drop " + IM\Name + " on " + IMB\Name) SetStyle (50,250,50,14,0,0,0) If IMB\Surface = True If IM\Carried = True If IMB\Slots > 0 If IM\Worn = False IM\OnTop = IMB\Name IM\Carried = False IM\Room = Room Print Print "You put the " + IM\Name + " on the " + IMB\Name + "." IMB\Slots = IMB\Slots - 1 PlayerItems = PlayerItems - 1 Else Print Print "You must take off the " + IM\Name + " first." EndIf Else Print Print "There isn't enough room." EndIf Else Print Print "You are not carrying the " + IM\Name + "." EndIf Else Print Print "You can't do that." EndIf Refresh() EndIf Next Next ;----------------------------; ;Put Items Inside Other Items;-------------------------------------------- ;----------------------------; For IM.Item = Each Item For IMB.Item = Each Item If (Typed = "put " + IM\Name + " in " + IMB\Name) Or (Typed = "place " + IM\Name + " in " + IMB\Name) Or (Typed = "put " + IM\Name + " inside " + IMB\Name) Or (Typed = "place " + IM\Name + " inside " + IMB\Name) Or (Typed = "insert " + IM\Name + " in " + IMB\Name) Or (Typed = "insert " + IM\Name + " into " + IMB\Name) SetStyle (50,250,50,14,0,0,0) If IMB\Container = True If IMB\Open = True If IM\Carried = True If IMB\Slots > 0 If IM\Worn = False IM\Inside = IMB\Name IM\Carried = False IM\Room = Room Print Print "You put the " + IM\Name + " inside the " + IMB\Name + "." IMB\Slots = IMB\Slots - 1 PlayerItems = PlayerItems - 1 Else Print Print "You must take off the " + IM\Name + " first." EndIf Else Print Print "It won't fit." EndIf Else Print Print "You are not carrying the " + IM\Name + "." EndIf Else Print Print "The " + IMB\Name + " is not open." EndIf Else If IM\Use = IMB\Name SetStyle (50,50,250,14,0,0,0) If IM\Carried = True IMB\Used = True Print Print IM\UseText Delete IM Refresh() EndIf Else Print Print "The " + IMB\Name + " is not a container." EndIf EndIf Refresh() EndIf Next Next ;--------------; ;Stand On Items;---------------------------------------------------------- ;--------------; For IM.Item = Each Item If (Typed = "stand on " + IM\Name) Or (Typed = "get on " + IM\Name) Or (Typed = "climb on " + IM\Name) Or (Typed = "climb up " + IM\Name) Or (Typed = "climb " + IM\Name) SetStyle (50,250,50,14,0,0,0) If IM\Stand = True PlayerOnItem = IM\Name Print Print "You climb up onto the " + IM\Name EndIf If IM\Climb = True PlayerOnItem = IM\Name Print Print "You climb up the " + IM\Name EndIf Refresh() EndIf Next For IM.Item = Each Item If (Typed = "jump off " + IM\Name) Or (Typed = "get off " + IM\Name) Or (Typed = "climb down " + IM\Name) SetStyle (50,250,50,14,0,0,0) If PlayerOnItem = IM\Name PlayerOnItem = "" Print Print "You get off the " + IM\Name EndIf If IM\Climb = True PlayerOnItem = "" Print Print "You climb down the " + IM\Name EndIf Refresh() EndIf Next ;-----------------------; ;Show Container Contents;------------------------------------------------- ;-----------------------; InText = False In = 0 For IM.Item = Each Item If (Typed = "examine " + IM\Name) Or (Typed = "look at " + IM\Name) Or (Typed = "ex " + IM\Name) Or (Typed = "search " + IM\Name) And IM\Container = True SetStyle (50,250,50,14,0,0,0) If IM\Open = True If InText = False For IMB.Item = Each Item If IMB\Inside = IM\Name In = In + 1 EndIf Next If In > 0 And InText = False Print Print "Inside the " + IM\Name + " is:" Print InText = True EndIf EndIf For IMB.Item = Each Item If IMB\Inside = IM\Name SetStyle (150,150,250,14,0,0,0) Print "> A " + IMB\Name EndIf Next SetStyle (150,250,150,14,0,0,0) If In = 0 Print If IM\Description <> "" And IM\Used = False Then Print IM\Description If IM\DescriptionB <> "" And IM\Used = True Then Print IM\DescriptionB If IM\Description = "" And IM\DescriptionB = "" Then Print "Nothing special." EndIf Else SetStyle (150,250,150,14,0,0,0) Print If IM\Description <> "" And IM\Used = False Then Print IM\Description If IM\DescriptionB <> "" And IM\Used = True Then Print IM\DescriptionB If IM\Description = "" And IM\DescriptionB = "" Then Print "Nothing special." EndIf Refresh() EndIf Next ;---------; ;Show Time;--------------------------------------------------------------- ;---------; If Typed = "time" SetStyle (250,200,50,14,0,0,0) Print Print CurrentTime() Refresh() EndIf ;-----------------; ;Show Command List;------------------------------------------------------- ;-----------------; If Typed = "instructions" Or Typed = "ins" Or Typed = "com" Or Typed = "commands" Or Typed = "command" Or Typed = "control" Or Typed = "controls" Or Typed = "con" Or Typed = "task" Or Typed = "quest" Or Typed = "mission" Or Typed = "intro" SetStyle (255,200,50,14,0,0,0) Print Print "Command List: " Print Print "Refresh Room: Look " Print "Get Items: Take - Get - Pick Up " Print "Examine Items: Examine - Ex - Search " Print "Item Commands: Open - Unlock - Remove " Print "Character Commands: Talk To - Give " Print "Quit Game: Quit - Exit " Print Print "There are also other commands but you'll have to work them out for yourself." Refresh() EndIf ;-----; ;Score;------------------------------------------------------------------- ;-----; If Typed = "score" SetStyle (250,200,50,14,0,0,0) Turn = Turn - 1 PlayerHungry = PlayerHungry - 1 PlayerThirst = PlayerThirst - 1 Print Print "You have scored " + PlayerScore + "/" + MaxPoints + " in " + Turn + " turns." Refresh() EndIf ;-------; ;Restart;----------------------------------------------------------------- ;-------; If Typed = "restart" Or Typed = "again" Or Typed = "try again" Or Typed = "retry" Restart() EndIf If Typed = "suicide" PlayerDead = True Refresh() EndIf ;--------------------------------; ;Enemy And Character Descriptions;---------------------------------------- ;--------------------------------; For EY.Enemy = Each Enemy For CR.Character = Each Character If (Typed = "examine " + EY\Name) Or (Typed = "look at " + EY\Name) Or (Typed = "ex " + EY\Name) Or (Typed = "search " + EY\Name) SetStyle (150,250,150,14,0,0,0) If EY\Room = Room And EY\Inside = "" And EY\Hidden = False Print Print EY\Description Else Print Print "You cannot see the " + EY\Name + "." EndIf Refresh() ElseIf (Typed = "examine " + Lower (CR\Name)) Or (Typed = "look at " + Lower (CR\Name)) Or (Typed = "ex " + Lower (CR\Name)) Or (Typed = "search " + Lower (CR\Name)) SetStyle (150,250,150,14,0,0,0) If CR\Room = Room And CR\Inside = "" And CR\Hidden = False Print Print CR\Description Else Print Print "You cannot see " + CR\Name + "." EndIf Refresh() EndIf Next Next ;----; ;Talk;-------------------------------------------------------------------- ;----; For CR.Character = Each Character For EY.Enemy = Each Enemy If Typed = "talk to " + Lower (EY\Name) Or Typed = "talk with " + Lower (EY\Name) Or Typed = "converse with " + Lower (EY\Name) Or Typed = "communicate with " + Lower (EY\Name) SetStyle (150,250,150,14,0,0,0) If EY\Room = Room And EY\Inside = "" And EY\Hidden = False Print Print "You get no reply..." Else Print Print "You cannot see the " + EY\Name + "." EndIf Refresh() ElseIf Typed = "talk to " + Lower (CR\Name) Or Typed = "talk with " + Lower (CR\Name) Or Typed = "converse with " + Lower (CR\Name) Or Typed = "communicate with " + Lower (CR\Name) SetStyle (50,50,250,14,0,0,0) If CR\Room = Room And CR\Inside = "" And CR\Hidden = False Print Print CR\Name + ":" Print SetStyle (150,250,150,14,0,0,0) For A = CR\TalkStart To CR\TalkLines Print TalkLines(A) Next Else Print CR\Name + " is not here." EndIf Refresh() EndIf Next Next ;----; ;Give;-------------------------------------------------------------------- ;----; For EY.Enemy = Each Enemy For IM.Item = Each Item For CR.Character = Each Character If (Typed = "give " + IM\Name + " to " + Lower (CR\Name)) Or (Typed = "give the " + IM\Name + " to " + Lower (CR\Name)) Or (Typed = "offer " + IM\Name + " to " + Lower (CR\Name)) Or (Typed = "offer the " + IM\Name + " to " + Lower (CR\Name)) Or (Typed = "offer the " + IM\Name + " to " + Lower (CR\Name)) Or (Typed = "give " + Lower (CR\Name) + " the " + IM\Name) Or (Typed = "offer " + Lower (CR\Name) + " the " + IM\Name) SetStyle (50,250,50,14,0,0,0) If CR\Room = Room If IM\Carried = True If CR\Item = IM\Name Item = False Print Print "You give the " + IM\Name + " to " + CR\Name + "." Delete IM CR\Given = True For IMB.Item = Each Item If IMB\OnTop = CR\Name Item = True If Item = True Print Print "In exchange, " + CR\Name + " gives you:" Print EndIf SetStyle (150,150,250,14,0,0,0) Print "> A " + IMB\Name IMB\Room = Room IMB\OnTop = "" IMB\Inside = "" IMB\Carried = True IMB\Hidden = False EndIf Next SetStyle (50,50,250,14,0,0,0) Print Print CR\Name + ":" Print SetStyle (150,250,150,14,0,0,0) For A = CR\TalkStartB To CR\TalkLinesB Print TalkLines(A) Next Else Print Print CR\Name + " doesn't seem to want the " + IM\Name + "." EndIf Else Print Print "You do not have the " + IM\Name + "." EndIf Else Print Print CR\Name + " is not here." EndIf Refresh() ElseIf (Typed = "give " + IM\Name + " to " + EY\Name) Or (Typed = "give the " + IM\Name + " to " + EY\Name) Or (Typed = "offer " + IM\Name + " to " + EY\Name) Or (Typed = "offer the " + IM\Name + " to " + EY\Name) Or (Typed = "offer the " + IM\Name + " to " + EY\Name) Or (Typed = "give " + EY\Name + " the " + IM\Name) Or (Typed = "offer " + EY\Name + " the " + IM\Name) SetStyle (50,250,50,14,0,0,0) If EY\Room = Room If IM\Carried = True If EY\Item = IM\Name Item = False Print Print "You give the " + IM\Name + " to the " + EY\Name + "." Delete IM EY\Given = True Else SetStyle (250,50,50,14,0,0,0) Print Print "You spend your last moments fumbling around looking for the " + IM\Name + "..." Print EY\KillByText PlayerDead = True EndIf Else Print Print "You do not have the " + IM\Name + "." EndIf Else Print Print "The " + EY\Name + " is not here." EndIf Refresh() EndIf Next Next Next ;----; ;Wait;-------------------------------------------------------------------- ;----; If Typed = "wait" Or Typed = "nothing" Or Typed = "do nothing" SetStyle (50,250,50,14,0,0,0) Print Print "..." Refresh() EndIf ;-----------; ;Turn On/Off;------------------------------------------------------------- ;-----------; For IM.Item = Each Item If Typed = "turn " + IM\Name Or Typed = "turn on " + IM\Name Or Typed = "switch " + IM\Name Or Typed = "switch on " + IM\Name Or Typed = "turn off " + IM\Name Or Typed = "switch off " + IM\Name SetStyle (50,250,50,14,0,0,0) If IM\Room = Room Or IM\Carried = True; And IM\Hidden = False If IM\CanTurn = True If IM\Turn = 0 IM\Turn = 1 Print Print "You turn on the " + IM\Name + "." Else IM\Turn = 0 Print Print "You turn off the " + IM\Name + "." EndIf Else Print Print "The " + IM\Name + " cannot be turned on/off." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() EndIf Next ;----------; ;Move Items;-------------------------------------------------------------- ;----------; For IM.Item = Each Item If Typed = "push " + IM\Name Or Typed = "pull " + IM\Name Or Typed = "move " + IM\Name SetStyle (50,250,50,14,0,0,0) If IM\Move = True Print Print "You have " + Left (Typed,4) + "ed the " + IM\Name Moved = False For IMB.Item = Each Item If IMB\OnTop = IM\Name If Moved = False Print Moved = True EndIf IMB\Room = Room IMB\Carried = False IMB\Hidden = False IMB\OnTop = "" Print "You have found a " + IMB\Name + "." EndIf Next Else Print Print "You can't " + Typed + "the " + IM\Name EndIf Refresh() EndIf Next ;---------; ;Use Locks;--------------------------------------------------------------- ;---------; For IM.Item = Each Item If Typed = "set " + IM\Name + " to " + Right (Typed,4) SetStyle (50,250,50,14,0,0,0) If IM\Room = Room And IM\Inside = "" If IM\Combo <> "" And IM\Locked = True If Right (Typed,4) = IM\Combo Print Print "You have successfully unlocked the " + IM\Name + "." IM\Locked = False Else Print Print "That didn't work..." EndIf Else Print Print "The " + IM\Name + " cannot be unlocked." EndIf Else Print Print "You cannot see the " + IM\Name + "." EndIf Refresh() EndIf Next ;-------------------------; ;User Typed Something Else;----------------------------------------------- ;-------------------------; SetStyle (250,250,250,14,0,0,0) Response = Rand (1,4) Select Response Case 1 Print Print "What?" Case 2 Print Print "Huh?" Case 3 Print Print "I don't know what you mean." Case 4 Print Print "Try something else." End Select Refresh() End Function ;---------; ;Set Style;--------------------------------------------------------------- ;---------; Function SetStyle (Red#=255,Green#=255,Blue#=255,Height=14,Bold=False,Italic=False,UnderLine=False) Color Red,Green,Blue SetFont LoadFont ("Courier",Height,Bold,Italic,UnderLine) End Function ;----------------------; ;Show Room Descriptions;-------------------------------------------------- ;----------------------; Function RoomText() North = False South = False East = False West = False Up = False Down = False Cls Locate 0,0 Select Room Case 9 South = True Print "The smell of freshly sprayed paint fills your nose. A wall blocks your path " Print "north. You have no choice but to turn around. " Case 13 Print "You are standing in what seems to be a small office. The moonlight is shining in" Print "through a window to the east. Icy flakes of snow can be seen building up on the " Print "glass. A desk with a pile of documents on stands against the wall with a chair " Print "neatly under. Faint voices can be heard through a wooden door to the north. It " Print "is the only visible exit from this room. " Case 14 West = True South = True North = True Done = False For IM.Item = Each Item If IM\Name = "cuffs" And IM\Worn = True Print Print "Foolishly, you climb out of the window, still hand cuffed and bound. As " Print "you attempt to stand upright on the icy ledge, you slip and fall to the " Print "streets below. With nothing to break your fall, you crack your skull on " Print "the ice cold pavement. Death swiftly frees you of your pain... " PlayerDead = True Exit Else If Done = False Print "You are standing on a breezy narrow ledge high above the streets " Print "below. The cold wind bites as it brushes across your bruised skin. " Print "To the west is the room where you were held captive. The ledge you " Print "are on extends north and south. " Done = True EndIf EndIf Next Case 17 South = True Done = False For IM.Item = Each Item If IM\Name = "plank" And IM\Carried = False Print Print "As you enter the car park, a short, bulky man approaches you. He reaches" Print "inside his jacket and takes out a silenced pistol. Immediately, he aims " Print "the weapon at your head and squeezes the trigger. The impact forces you " Print "backwards. Your lifeless body slumps to the ground and your blood oozes " Print "out across the fresh snow. " PlayerDead = True Exit Else If Done = False Print "You have come to a small car park. A broken down old car sits to the" Print "side of the area, all four wheels are missing. The only exit from " Print "here is south, back through the alley way. " Done = True EndIf EndIf Next Print Case 18 East = True Print "You have made it to the fire escape. The ladder leading down to the alley way is" Print "held in place with a combination lock. The lock has 4 digits. " For IM.Item = Each Item If IM\Name = "lock" And IM\Locked = False Print Print "You can now go down the ladder to the alley way below." EndIf Next Case 19 North = True West = True Print "You are standing at the corner of the ledge. The icy wind feels much stronger " Print "without the building to shield you. Beneath you is an alley way. North leads " Print "back along the ledge. To the west, you can see the ladder of a fire escape. " Case 21 East = True Print "You have come to the end of the alley way. A decaying rat corpse is laying half " Print "submerged in a frozen puddle. Various pieces of trash are laying on the ground. " Print "A trash can in the corner is emitting a quiet scraping sound... " Case 22 North = True West = True East = True Print "Your surroundings are partially lit by a flickering light on the wall. This " Print "whole place has a nauseating stench of garbage. From here, the alley way extends" Print "east and west. A car park can be seen to the north. " Case 23 Up = True West = True East = True Print "You are in an alley way at the bottom of the fire escape. Trash cans are " Print "scattered on the ground, their contents spewed on the floor. Flakes of snow " Print "gently drift in from above. The alley way extends east and west. " Case 24 West = True East = True Print "You are coming to the end of the alley way. The darkened city street can be seen" Print "just a few meters away. The falling snow has begun to settle in the road. The " Print "street lays east and is completely deserted. The alley way stretches back to the" Print "west... " Done = False Case 25 For EY.Enemy = Each Enemy If EY\Name = "dog" If EY\Given = False Print "You try to sneak past the fierce dog... It sees you and goes wild, " Print "growling and barking. It leaps up towards you and drags you to the " Print "ground. It's huge slobbering jaws close in around your throat, razor " Print "sharp teeth pierce your wind pipe. You drown in your own blood. " PlayerDead = True Exit Else If Done = False Print "You have made it to a dark city street. The snow is still falling " Print "heavily around you. Illuminated only my the moonlight, you proceed " Print "to walk along the road side. Your figure gradually fades into the " Print "shadows. " Print SetStyle (250,200,50,14,0,0,0) Print "Congratulations! " Print Print "You score " + PlayerScore + " out of " + MaxPoints + " in " + Turn + " turns." GameCompleted = True Done = True EndIf EndIf EndIf Next End Select End Function ;---------; ;Main Loop;--------------------------------------------------------------- ;---------; Function Refresh() ;------------------------------------; ;Carried Items In Same Room As Player;------------------------------------ ;------------------------------------; For IM.Item = Each Item If IM\Carried = True Or IM\Worn = True IM\Room = Room IM\Hidden = False IM\InSide = "" IM\OnTop = "" EndIf Next ;-------------------------------------------------; ;Close Containers Inside Containers Or On Surfaces;----------------------- ;-------------------------------------------------; For IM.Item = Each Item For IMB.Item = Each Item If IM\Container = True And IMB\Container = True If IM\Inside = IMB\Name IM\Closed = True IM\Open = False EndIf EndIf Next Next For IM.Item = Each Item For IMB.Item = Each Item If IM\Container = True And IMB\Surface = True If IM\OnTop = IMB\Name IM\Closed = True IM\Open = False EndIf EndIf Next Next ;------------; ;Update Hints;------------------------------------------------------------ ;------------; Select Hint Case 1 Help = "You need to remove your handcuffs before trying to escape." Case 2 Help = "Try thinking out loud." Case 3 Help = "Give generously." Case 4 Help = "Search everywhere." Case 5 Help = "Sorry, no more help is available." Case 5 Hint = 5 End Select ;-----------------; ;Room Descriptions;------------------------------------------------------- ;-----------------; SetStyle (200,200,200,14,0,0,0) If Shown = False RoomText() EndIf
And this...
All one big piece of code. Had to break it up for the code box...
Hope you find it useful...
;-------; ;Special;----------------------------------------------------------------- ;-------; SetStyle (250,200,50,14,0,0,0) Select Room Case 13 For IM.Item = Each Item If IM\Name = "window" And IM\Open = True Then East = True Next Case 17 For IM.Item = Each Item If IM\Name = "trunk" And IM\Locked = False If HitScore = False Print Print "While trying to unlock the trunk of the car, you have alerted the bulky man" Print "standing near by. Before you have chance to react, he runs over to you and slams" Print "you into the cold concrete floor. He caves in your skull with a nearby rock." PlayerDead = True EndIf EndIf Next End Select For IM.Item = Each Item If IM\Name = "cuffs" And IM\Worn = True MaxItems = 3 EndIf If IM\Name = "cuffs" And Bound = True And IM\Worn = False Print Print "With your cuffs off, you quickly untie your legs. Now you need to escape!" Bound = False If CuffScore = False PlayerScore = PlayerScore + 20 CuffScore = True MaxItems = 10 EndIf EndIf If IM\Name = "lock" And IM\Locked = False Down = True If LockScore = False PlayerScore = PlayerScore + 20 LockScore = True EndIf EndIf If IM\Name = "plank" And IM\Used = True If HitScore = False PlayerScore = PlayerScore + 20 HitScore = True EndIf EndIf Next For CR.Character = Each Character If CR\Name = "homeless man" And CR\Given = True If HelpScore = False PlayerScore = PlayerScore + 20 HelpScore = True EndIf EndIf Next For EY.Enemy = Each Enemy If EY\Name = "dog" And EY\Given = True If DogScore = False PlayerScore = PlayerScore + 20 DogScore = True EndIf EndIf Next ;-----------------; ;Enemies And Items;------------------------------------------------------- ;-----------------; If Shown = False ;Print ;-----; ;---;Items;--------------------------------------------------------------- ;-----; SetStyle (50,150,50,14,0,0,0) For IM.Item = Each Item If IM\Inside = "" And IM\OnTop = "" And IM\Hidden = False If IM\Room = Room And IM\Carried = False And IM\Worn = False Print "You can also see a " + IM\Name + "." EndIf EndIf Next ;------------------------; ;---;Items Inside Other Items;-------------------------------------------- ;------------------------; SetStyle (50,50,150,14,0,0,0) For IM.Item = Each Item For IMB.Item = Each Item If IM\Room = Room If IM\Inside = IMB\Name And IM\Carried = False And IMB\Carried = False And IM\Hidden = False If IMB\Open = True And IMB\Break = "" Print "There is a " + IM\Name + " inside the " + IMB\Name + "." ElseIf IMB\Open = True And IMB\Break <> "" Print "You can also see a " + IM\Name + "." EndIf EndIf EndIf Next Next ;---------------------------; ;---;Items On Top Of Other Items;----------------------------------------- ;---------------------------; SetStyle (50,50,150,14,0,0,0) For IM.Item = Each Item For IMB.Item = Each Item If IM\Room = Room If IM\OnTop = IMB\Name And IM\Carried = False And IM\Hidden = False If IMB\Examined = True Print "There is a " + IM\Name + " on the " + IMB\Name + "." EndIf EndIf EndIf Next Next ;-------------------------; ;---;Player Is Wearing An Item;------------------------------------------- ;-------------------------; SetStyle (200,200,200,14,0,0,0) For IM.Item = Each Item If IM\Worn = True And PlayerDead = False Print Print "You are wearing " + IM\Name + "." EndIf Next ;-----------------------------; ;---;Player Is Standing On An Item;--------------------------------------- ;-----------------------------; SetStyle (200,200,200,14,0,0,0) For IM.Item = Each Item If PlayerOnItem = IM\Name And PlayerDead = False Print Print "You are standing on a " + IM\Name + "." EndIf Next ;----------; ;---;Characters;---------------------------------------------------------- ;----------; SetStyle (50,50,250,14,0,0,0) For CR.Character = Each Character If CR\Room = Room And CR\Inside = "" And CR\Hidden = False And PlayerDead = False Print Print CR\Name + " is here." EndIf Next ;-------; ;---;Enemies;------------------------------------------------------------- ;-------; SetStyle (250,50,50,14,0,0,0) For EY.Enemy = Each Enemy If EY\Room = Room If EY\Inside = "" And EY\Hidden = False And PlayerDead = False Print Print "A " + EY\Name + " is here." EndIf EndIf Next EndIf ;-------------; ;Update Events;----------------------------------------------------------- ;-------------; Turn = Turn + 1 SetStyle (250,200,50,14,0,0,0) For ET.Event = Each Event If ET\Turn = Turn And PlayerDead = False If ET\Room = 0 Or ET\Room = Room Print Print ET\Event For EY.Enemy = Each Enemy If ET\Enemy = EY\Name EY\Hidden = False EndIf Next For IM.Item = Each Item If ET\Item = IM\Name IM\Hidden = False EndIf Next For CR.Character = Each Character If ET\Character = CR\Name CR\Hidden = False EndIf Next If ET\Kill = True Then PlayerDead = True EndIf Delete ET EndIf Next ;------------------------; ;Update Hunger And Thirst;------------------------------------------------ ;------------------------; If PlayerDead = False Then PlayerHunger = PlayerHunger - 1 If PlayerDead = False Then PlayerThirst = PlayerThirst - 1 SetStyle (250,200,50,14,0,0,0) If PlayerHunger = 50 Print Print "You feel hungry." ElseIf PlayerHunger = 25 Print Print "You are starving." ElseIf PlayerHunger = 10 Print Print "You are famished." ElseIf PlayerHunger = 5 Print Print "You are feeling weak." ElseIf PlayerHunger = 0 Print Print "You have starved to death..." PlayerDead = True EndIf If PlayerThirst = 24 Print Print "You feel thirsty." ElseIf PlayerThirst = 9 Print Print "You feel parched." ElseIf PlayerThirst = 4 Print Print "You are feeling weak." ElseIf PlayerThirst <= 0 Print Print "Your dehydrated body slumps to the ground..." PlayerDead = True EndIf ;-----------; ;Player Died;------------------------------------------------------------- ;-----------; If PlayerDead = True SetStyle (250,50,50,14,1,0,0) Print Print "You have died!" Print "You scored " + PlayerScore + " out of " + MaxPoints + " in " + Turn + " moves!" Promt = 0 EndIf ;----------; ;User Input;-------------------------------------------------------------- ;----------; If GameCompleted = True Then PlayerDead = True If PlayerDead = False Then Promt = Rand (1,4) SetStyle (200,200,200,14,0,0,0) Shown = True Print Select Promt Case 0 Print "Would you like to try again?" Case 1 Print "What will you do now?" Case 2 Print "What next?" Case 3 Print "What now?" Case 4 Print "What will you do now?" End Select SetStyle (255,255,255,14,0,0,0) Print Typed$ = Input ("> ") Command() End Function
All one big piece of code. Had to break it up for the code box...
Hope you find it useful...
Just talking (writing) about it made me want to make one again :)
Thanks, everyone!