#============================================ # XVAN implementation of "Cloak of Darkness" #============================================ TITLE "Cloak of Darkness" AUTHOR "Marnix van den Bos" COVERTEXT "XVAN port of Roger Firth's reference game" VERSION "1.0" $insert ".\\XVAN Library v1-4.lib" #=========================== # Locations part #=========================== #------------------------------------------------------------------------------- $LOCATION l_foyer DESCRIPTIONS d_sys "the foyer of the Opera House", "the spacious hall" d_entr_long "You are standing in a spacious hall, splendidly decorated in / red and gold, with glittering chandeliers overhead. The / entrance from the street is to the north, and there are / doorways south and west.\n" d_entr_short "There are doorways south and west. The entrance from the / street is to the north.\n" d_no_go "You've only just arrived, and besides, the wheather outside / seems to be getting worse..." EXITS south -> l_bar w -> l_cloakroom FLAGS f_lit = 1 TRIGGERS "go north" -> t_no_go t_no_go printcr(d_no_go) disagree() END_LOC #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $LOCATION l_cloakroom DESCRIPTIONS d_sys "the cloakroom", "the wall" d_entr_long "The walls of this room were clearly once lined with hooks, / though now only one remains. The exit is a door to the east.\n" d_entr_short "The exit is a door to the east." EXITS e -> l_foyer FLAGS f_lit = 1 END_LOC #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $LOCATION l_bar DESCRIPTIONS d_sys "the foyer bar" d_entr_long "The bar, much rougher than you'd have guessed after the opulence / of the foyer to the north, is completely empty. There seems to / be some sort of message scrawled in the sawdust on the floor.\n" d_entr_short "The foyer is to the north.\n" EXITS n -> l_foyer FLAGS f_bypass = 1 TRIGGERS "[dir]" -> t_move t_move if not(islit(%this)) then if not(equal(%dir, north)) then o_message.r_damage += 2 printcr("Blundering around in the dark isn't a good idea!") endif else nomatch() t_default if not(owns(%this, o_player)) then disagree() endif if not(islit(%this)) then o_message.r_damage += 1 printcr("In the dark? You could easily disturb something!") disagree() else nomatch() END_LOC #------------------------------------------------------------------------------- #====================== # OBJECTS part #====================== #------------------------------------------------------------------------------- $OBJECT o_player # The o_player object is predefined and represents the human player. DESCRIPTIONS d_sys "You", "me" d_init "Hurrying through the rainswept November night, you're glad to see / the bright lights of the Opera House. It's surprising that there / aren't more people about but, hey, what do you expect in a cheap / demo game...?\n\n" "Cloak of Darkness\n" "A basic IF demonstration.\n\n\n" d_score "\n\nYour score is [r_score] out of a possible [r_max_score], in / [m_init] moves." CONTAINED in l_foyer FLAGS f_alive = 1 f_verbose = 0 f_first = 1 f_exits = 0 # for exits verb f_may_save = 1 f_may_undo = 1 f_verb_help = 1 ATTRIBUTES r_is = are r_have = have r_does = do r_nr_to_reveal = 0 r_score = 0 r_max_score = 2 r_random = 0 TRIGGERS "[dir]" -> t_move t_init # This trigger initializes things. It is started by counter # m_init that goes off right after starting the story. background(blue) printcr(d_init) printcr("") entrance(owner(%this)) t_entrance agree() # prevents calling common t_entrance trigger for player. t_move if valdir(l_location, %dir) then # it's a valid direction if exit(l_location) then # no object objects to the player leaving the room move(o_player, %dir) # move updates current location entrance(l_location) endif else nomatch() # let other objects or verb default code react. endif agree() END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_cloak DESCRIPTIONS d_sys "the black velvet cloak" d_entr_short "\nThere is [a] [o_cloak] here.\n" d_exa "A handsome cloak, of velvet trimmed with satin, and slightly / spattered with raindrops. Its blackness is so deep that it / almost seems to suck the light from the room." d_drop "This isn't the best place to leave a smart cloak lying around." CONTAINED in o_player FLAGS f_bypass = 1 # exclude from interpreter's visibility check f_takeable = 1 f_wearable = 1 f_worn = 1 # initially, the player is wearing the cloak f_scored = 0 # player may only get 1 point for hanging cloak TRIGGERS "take off [o_cloak]" -> t_take_off_cloak "wear [o_cloak]" -> t_wear "drop [o_cloak]" -> t_drop "hang [o_cloak] on [o_hook]" -> t_hang "inventory" -> t_i t_take_off_cloak if testflag(f_worn) then printcr("(Taking off the cloak first).") clearflag(f_worn) endif t_wear if not(owns(o_player, o_cloak)) then printcr("(picking up the cloak first).") move(o_cloak, o_player) endif printcr("Ok, you are now wearing the o_cloak.") setflag(o_cloak.f_worn) clearflag(l_bar.f_lit) t_drop if equal(l_location, l_cloakroom) then if trigger(t_take_off_cloak) then printcr("You drop the o_cloak on the floor.") move(o_cloak, l_cloakroom) setflag(l_bar.f_lit) endif else printcr(d_drop) endif t_hang if owns(o_hook, o_cloak) then printcr("The cloak is already on the hook.") disagree() endif if trigger(t_take_off_cloak) then move(o_cloak, o_hook, on) setflag(l_bar.f_lit) o_cloak.r_preposition = on printcr("Ok, the cloak is now on the hook.") if not(testflag(f_scored)) then setflag(f_scored) o_player.r_score += 1 printcr("") printcr("(Your score has just gone up by 1 point)") endif t_i if not(owns(o_player, %this)) then nomatch() else indent() print("[a] [o_cloak]") if testflag(f_worn) then printcr(", being worn") else printcr("") endif agree() endif END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_hook DESCRIPTIONS d_sys "the small brass hook" d_entr_long "\nThere is [a] [o_hook] on one of the walls.\n" d_entr_short "\nThere is [a] [o_hook] on one of the walls.\n" CONTAINED in l_cloakroom FLAGS f_supporter = 1 TRIGGERS "examine [o_hook]" -> t_exa "take [o_hook]" -> t_take t_exa print("It's just [a] [o_hook], ") if owns(o_hook, o_cloak) then printcr("with [a] [o_cloak] hanging on it.") else printcr("screwed to the wall.") endif t_take printcr("The o_hook is firmly attached to the wall.") END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_message DESCRIPTIONS d_sys "the scrawled message" d_entr_short "\nThere seems to be some sort of message scrawled in the / sawdust on the floor.\n" d_exa_won "The message, neatly marked in the sawdust, reads ....\n\n" " *** You have won ***" d_exa_lost "The message has been carelessly trampled, making it / difficult to read. You can just distinguish the /" "words ....\n\n" " *** You have lost ***" CONTAINED in o_sawdust ATTRIBUTES r_damage = 0 TRIGGERS "examine [o_message]" -> t_exa "read [o_message]" -> t_exa "read [o_message] in [o_sawdust]" -> t_exa t_entrance agree() t_exa if lt(r_damage, 2) then o_player.r_score += 1 printcr(d_exa_won) else printcr(d_exa_lost) endif printcr(o_player.d_score) quit() END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_sawdust DESCRIPTIONS d_sys "the sawdust", "the dust", "the floor" d_take "That doesn't sound like a good idea. It would / scatter the message..." d_exa "There is a message written in the sawdust." CONTAINED in l_bar FLAGS f_takeable = 1 TRIGGERS "take [o_sawdust]" -> t_take t_entrance agree() t_take printcr(d_take) END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_foyer_scenery Descriptions d_sys "the red decoration", "the gold decoration", "the glittering chandeliers" d_scenery_1 "You examine [the] [o_foyer_scenery] and on closer look decide that you / don't need to bother about it to complete this story." d_scenery_2 "Just looks like [o_foyer_scenery]." d_scenery_3 "Beautiful [o_foyer_scenery], very contemporary." CONTAINED in l_foyer FLAGS f_hidden = 1 f_bypass = 1 f_swap = 1 TRIGGERS "examine [o_foyer_scenery]" -> t_exa t_entrance agree() t_exa printcr(pickone(d_scenery_1, d_scenery_2, d_scenery_3)) END_OBJ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- $OBJECT o_unbound DESCRIPTIONS d_no_descr "" CONTAINED in o_player FLAGS f_hidden = 1 ATTRIBUTES r_unbound = %none TRIGGERS t_unbound if equal(%action, hit) and equal(r_unbound, road) then printcr("Please use compass directions to move.") agree() endif if equal(%action, get) and equal(r_unbound, rest) then printcr("Resting costs you 2 moves.") wait(2) agree() endif disagree() END_OBJ #-------------------------------------------------------------------------------