#include #include #include #include #include #include #include #include ; "inv" command Global $turns = 0 Global $temp = "" Global $nv = 24 ;max number of verbs Global $no[30] ;max number of nouns/objects Global $nr = 30 ;max number of rooms, directions Global $ni = 30 ;item locations, item descriptions Global $n, $v, $iview, $inv Global $rnum = 1, $lastnum = 1, $iCount = 0 Global $r[$nr], $d[$nr], $iLoc[$ni], $item[$ni], $iMsg ;[Rooms] $r[1] = 'You woke up in a daze with a horrible headache. You are wet and confused. ' $r[1] = $r[1] & 'It seems your small fishing boat has capsized and you were rendered unconscious. ' $r[1] = $r[1] & 'You washed ashore on a small island in the Caribbean.' $r[2] = 'You are on the beach. There is a jungle to the east, the wind is picking up.' $r[3] = 'You are treading water just offshore. The current is very strong and pushing you toward the south.' $r[4] = 'You have entered a dark, misty jungle. You see a dim light to the west.' $r[5] = 'You see the wreckage of your fishing boat strewn about the beach.' $r[6] = 'You are at a rocky reef. The sand is very hot beneath your feet.' $r[7] = 'You are in a clearing among large mangrove trees. You hear the call of tropical birds and primates.' $r[8] = 'You are at the edge of a crystal clear lagoon. You can see the shimmering of fish swimming about.' $r[9] = 'You are on a winding path.' $r[10] = 'You are on a narrow winding path.' $r[11] = 'You outside a large hut. There is a ladder leading up to the entrance.' $r[12] = 'You are at the entry of a small cave.' $r[13] = 'You are in a small cave.' $r[14] = 'You are at a tiny passage.' $r[15] = 'You are in a very narrow path.' ;[Directions] 99=Dead End $d[1] = '02020203' $d[2] = '05060403' $d[3] = '99990299' $d[4] = '07089908' $d[5] = '99020703' $d[6] = '02990803' $d[7] = '99041405' $d[8] = '04091206' $d[9] = '08991210' $d[10] = '99150999' $d[11] = '12992109' $d[12] = '13112299' $d[13] = '14129999' $d[14] = '99139907' $d[15] = '10291699' ;[Items] 1st 2 char = item location...'-1'=in inventory...'00' not visible $item[1] = '07/a large coconut' $item[2] = '02/a small sand crab' $item[3] = '03/Oh Shit !!! Shaaaaaaaarrrrrks !!' $item[4] = '05/a rusty box' $item[5] = '07/a brass key' $item[6] = '06/a parchment scroll' $item[7] = '06/a small sea lion' $item[8] = '08/several gold coins' $item[9] = '10/a rusty knife' $item[10] = '04/a small bottle' ;Short Descriptions/nouns $no[1] = "coc" $no[2] = "cra" $no[3] = "sha" $no[4] = "box" $no[5] = "key" $no[6] = "scr" $no[7] = "sea" $no[8] = "coi" $no[9] = "kni" $no[10] = "bot" For $i = 1 To $ni - 1 $iLoc[$i] = StringLeft($item[$i], 2) ;initial item locations array Next For $i = 1 To $ni - 1 $item[$i] = StringTrimLeft($item[$i], 3) ;item descriptions array Next ;[Verbs] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Global $vb[$nv] = ["go ", "get", "dro", "loo", "inv", "sco", "sav", "res", "loa", "tak", "ope", "clo", "sta", "qui", "kil", "rea", "ent", "hit", "swi", "yel", "fuc", "cut", "eat", "dri"] HotKeySet("{ENTER}", "ParseInp") ;trap to send to input parser $Form1 = GUICreate("Caribbean Odyssey", 432, 265, -1, -1) $List1 = GUICtrlCreateList("", 16, 32, 401, 175, $WS_BORDER + $WS_VSCROLL + $LBS_NOSEL) $Input1 = GUICtrlCreateInput("", 65, 211, 80, 23) $Label1 = GUICtrlCreateLabel("What now?", 18, 204, 54, 35) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $Button1 = GUICtrlCreateButton("North", 150, 210, 41, 25) $Button2 = GUICtrlCreateButton("South", 195, 210, 41, 25) $Button3 = GUICtrlCreateButton("East", 240, 210, 41, 25) $Button4 = GUICtrlCreateButton("West", 285, 210, 41, 25) $Button5 = GUICtrlCreateButton("Up", 330, 210, 41, 25) $Button6 = GUICtrlCreateButton("Down", 375, 210, 41, 25) $Label3 = GUICtrlCreateLabel("Caribbean Island Adventure", 110, 8, 330, 24) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUISetState() GUICtrlSetData($List1, StringRegExpReplace($r[1], '(.{60,}?)\h', '$1|')) GUICtrlSetFont($List1, 10, 400, 0, "Arial") GUICtrlSetState($List1, $GUI_SHOW) GUICtrlSetState($Input1, $GUI_FOCUS) ;Redimension the arrays For $i = 1 To UBound($r) - 1 If $r[$i] = "" Then $rdim = $i ExitLoop EndIf Next ReDim $r[$rdim] ReDim $d[$rdim] For $i = 1 To UBound($item) - 1 If $item[$i] = '' Then $rdim = $i ExitLoop EndIf Next ReDim $item[$rdim] ReDim $no[$rdim] ShowLoc() Main() Func ProcessVerbs() Select Case StringLeft($v, 2) = "go" ;go $iMsg = "Please use buttons to move around..." MessageBack() Sleep(3000) Case $v = $vb[13] ;quit MsgBox(65, "Quitting...", "Ok. Bye.", 3) Exit Case $v = "" ;blank $iMsg = "Excuse me?" MessageBack() Sleep(3000) Case $v = $vb[4] ;inv $iCount=0 For $i = 1 to UBound($no) -1 if $iLoc[$i] = -1 Then $iCount = $iCount + 1 If $iCount = 1 then GUICtrlSetData($List1, "You are carrying:") EndIf GUICtrlSetData($List1, "> " & $item[$i]) EndIf Next If $iCount = 0 then GUICtrlSetData($List1, "You are empty-handed.") EndIf $v = "" $n = "" GUICtrlSetData($Input1, "") GUICtrlSetState($Input1, $GUI_FOCUS) Wait() Case $v = $vb[1] ;get $iCount = 0 For $i = 1 to UBound($no) -1 ;can you get it? if $n = $no[$i] and $iLoc[$i] <> "-1" and $iLoc[$i] = $rnum Then $iCount = $iCount + 1 $iLoc[$i] = "-1" $iMsg = "Ok. Got it." MessageBack() Sleep(3000) EndIf Next If $iLoc[2] = -1 Then ;you got the crab $iMsg = "Owwwww! Owwww! The crab pinched your finger...you dropped it!" MessageBack() Sleep(3000) $iLoc[2] = $rnum EndIf If $iCount = 0 Then ;don't see it here $iMsg = "It's not here...you might already have it." MessageBack() Sleep(3000) EndIf Case $v = $vb[2] ;drop $iCount = 0 For $i = 1 to UBound($no) -1 ;drop it if you have it if $n = $no[$i] and $iLoc[$i] = "-1" Then $iLoc[$i] = $rnum $iCount = $iCount + 1 $iMsg = "Ok. Dropped." MessageBack() Sleep(3000) EndIf Next If $iCount = 0 Then ;don't have it $iMsg = "It's not something you're carrying." MessageBack() Sleep(3000) EndIf Case $v = $vb[3] ;look if $n = "" Then $iMsg = "What do you want me to look at?" MessageBack() Sleep(3000) Else $Msg = "I can't" MessageBack() Sleep(3000) EndIf Case $v = $vb[20] $iMsg = "Hey you son of a bitch...watch your fucking language!" MessageBack() Sleep(3000) Case Else $iMsg = "I don't understand your command." MessageBack() Sleep(3000) EndSelect $v = "" $n = "" GUICtrlSetData($Input1, "") GUICtrlSetState($Input1, $GUI_FOCUS) ShowLoc() ShowVisibleItems() EndFunc ;==>ProcessVerbs Func MessageBack() GUICtrlSetData($List1, "> " & $iMsg) $v = "" $n = "" GUICtrlSetData($Input1, "") GUICtrlSetState($Input1, $GUI_FOCUS) EndFunc ;==>MessageBack Func Main() While 1 ;process button input $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ;north $rnum = Int(StringLeft($d[$rnum], 2)) ShowLoc() ShowVisibleItems() Case $Button2 ;south $rnum = Int(StringMid($d[$rnum], 3, 2)) ShowLoc() ShowVisibleItems() Case $Button3 ;east $rnum = Int(StringMid($d[$rnum], 5, 2)) ShowLoc() ShowVisibleItems() Case $Button4 ;west $rnum = Int(StringRight($d[$rnum], 2)) ShowLoc() ShowVisibleItems() Case $Button5 ; _ShakeWindow() Case $Button6 ; _ShakeWindow() EndSwitch WEnd EndFunc ;==>Main Func ShowLoc() ;show where you are if $rnum > UBound($r) -1 Then _ShakeWindow() $rnum = $lastnum EndIf $List1 = GUICtrlCreateList("", 16, 32, 401, 175, $WS_BORDER + $WS_VSCROLL + $LBS_NOSEL) $t = $r[$rnum] GUICtrlSetData($List1, StringRegExpReplace($t, '(.{60,}?)\h', '$1|')) GUICtrlSetFont($List1, 10, 400, 0, "Arial") GUICtrlSetData($List1, "-----") $turns = $turns + 1 $lastnum = $rnum GUICtrlSetState($Input1, $GUI_FOCUS) EndFunc ;==>ShowLoc Func ShowVisibleItems() $iCount = 0 For $i = 1 To UBound($iLoc) - 1 If $iLoc[$i] = $rnum Then $iCount = $iCount + 1 If $iCount = 1 Then GUICtrlSetData($List1, "You can see:") EndIf GUICtrlSetData($List1, $item[$i]) EndIf Next EndFunc ;==>ShowVisibleItems Func Inventory() ;what you are carrying $iCount = 0 For $i = 1 To $ni If $iLoc[$i] = "-1" Then ;GUICtrlSetData($List2, $item[$i]) $iCount = $iCount + 1 EndIf Next If $iCount = 0 Then ;GUICtrlSetData($List2, "No items") EndIf EndFunc ;==>Inventory Func ParseInp() ;process typed input $strSentence = GUICtrlRead($Input1) $split = StringInStr($strSentence, " ") If $split = 0 Then ;one word command $v = $strSentence $n = "" Else $v = StringLeft($strSentence, $split - 1) $n = StringMid($strSentence, $split + 1) EndIf If StringLen($v) > 3 Then $v = StringLeft($v, 3) If StringLen($n) > 3 Then $n = StringLeft($n, 3) ProcessVerbs() EndFunc ;==>ParseInp Func _ShakeWindow() ;self-explanatory Local $Window = WinGetTitle("", ""), $ShakeAmount = 5, $Win_pos = WinGetPos($Window) For $i = 0 To 20 WinMove($Window, "", $Win_pos[0], $Win_pos[1] + $ShakeAmount * Mod($i, 2)) Sleep(10) Next EndFunc ;==>_ShakeWindow Func Wait() GUICtrlSetData($List1, "Press to continue...") Do Sleep(10) Until _IsPressed("20");71 for F2 EndFunc