home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #7 / amigamamagazinepolishissue1998.iso / rozrywka / rpg / amigamud / src / proving / doorsroom.m < prev    next >
Text File  |  1997-06-15  |  28KB  |  847 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1997 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * doorsRoom.m - the doors rooms area.
  9.  */
  10.  
  11. define tp_proving tp_doorsRoom CreateTable()$
  12. use tp_doorsRoom
  13.  
  14. define tp_doorsRoom DOOR_TIME     8$
  15. define tp_doorsRoom WINCH_VOLUME_DECREASE    3000$
  16. define tp_doorsRoom DOOR_VOLUME_DECREASE    2000$
  17.  
  18. define tp_doorsRoom r_tunnelX4 CreateThing(r_provingCave)$
  19. SetupRoomDP(r_tunnelX4, "at the south end of a passage",
  20.     "A large wooden door blocks the south end of the passage.")$
  21. UniConnect(r_tunnelX4, r_chasm6, D_SOUTH)$
  22. r_tunnelX4@p_rNoGenerateMonsters := true$
  23. define tp_doorsRoom PR_TUNNELX4_ID NextEffectId()$
  24. define tp_doorsRoom proc drawTunnelX4()void:
  25.  
  26.     if not KnowsEffect(nil, PR_TUNNELX4_ID) then
  27.     DefineEffect(nil, PR_TUNNELX4_ID);
  28.     GSetImage(nil, "Proving/tunnelX4");
  29.     IfFound(nil);
  30.         ShowCurrentImage();
  31.     Else(nil);
  32.         GSetPen(nil, C_DARK_GREY);
  33.         GAMove(nil, 0.0, 0.0);
  34.         GRectangle(nil, 0.5, 1.0, true);
  35.         GSetPen(nil, C_LIGHT_GREY);
  36.         GAMove(nil, 0.207, 0.0);
  37.         GRectangle(nil, 0.087, 0.545, true);
  38.         GSetPen(nil, C_BROWN);
  39.         GAMove(nil, 0.235, 0.55);
  40.         HorizontalDoor();
  41.     Fi(nil);
  42.     EndEffect();
  43.     fi;
  44.     CallEffect(nil, PR_TUNNELX4_ID);
  45. corp;
  46. AutoGraphics(r_tunnelX4, drawTunnelX4)$
  47.  
  48. define tp_doorsRoom o_door1 CreateThing(nil)$
  49. FakeObject(o_door1, r_chasm6, "door;sturdy,wooden",
  50.     "The door is made from massive wooden beams, fastened together with thick "
  51.     "iron straps. There is a small keyhole in the door.")$
  52. o_door1@p_oOpenString := "The door is locked."$
  53. o_door1@p_oPushString := "The door is locked."$
  54. o_door1@p_oPullString := "The door is locked."$
  55. o_door1@p_Image := "Proving/doorFromChasm"$
  56.  
  57. define tp_doorsRoom o_keyHole2 CreateThing(nil)$
  58. FakeObject(o_keyHole2, r_chasm6, "hole,keyhole;small,key", "")$
  59. o_keyHole2@p_oContents := CreateThingList()$
  60. o_keyHole2@p_Image := "Proving/keyhole"$
  61.  
  62. define tp_doorsRoom proc putInKeyHole2(thing key, keyhole)status:
  63.     string name;
  64.     bool hidden;
  65.  
  66.     if Parent(key) = o_ironKey then
  67.     name := CharacterNameG(Me());
  68.     hidden := Me()@p_pHidden;
  69.     Print("The iron key slips into the hole and turns easily. The door "
  70.         "opens and you walk through.\n");
  71.     if hidden then
  72.         OPrint("The door opens, then quickly closes again.\n");
  73.     else
  74.         OPrint(Capitalize(name) +
  75.         " unlocks the door and walks through. The door "
  76.         "then closes again before anyone can follow.\n");
  77.     fi;
  78.     LeaveRoomStuff(r_tunnelX4, D_NORTH, MOVE_SPECIAL);
  79.     EnterRoomStuff(r_tunnelX4, D_SOUTH, MOVE_SPECIAL);
  80.     if hidden then
  81.         OPrint("The door opens, then closes again.\n");
  82.     else
  83.         OPrint("The door opens and " + name + " enters. " +
  84.         "The door quickly closes again.\n");
  85.     fi;
  86.     succeed
  87.     else
  88.     Print("The " + FormatName(key@p_oName) +
  89.         " will not fit into the hole.\n");
  90.     fail
  91.     fi
  92. corp;
  93. o_keyHole2@p_oPutInMeChecker := putInKeyHole2$
  94. define tp_doorsRoom proc doUnlock2(thing keyhole, key)status:
  95.     putInKeyHole2(key, keyhole)
  96. corp;
  97. o_keyHole2@p_oUnlockMeWithChecker := doUnlock2$
  98. SetThingStatus(o_keyHole2, ts_readonly)$
  99. o_door1@p_oUnlockMeWithChecker := doUnlock2$
  100. SetThingStatus(o_door1, ts_readonly)$
  101.  
  102. define tp_doorsRoom proc backThroughDoor()status:
  103.     string name;
  104.     bool hidden;
  105.  
  106.     name := CharacterNameG(Me());
  107.     hidden := Me()@p_pHidden;
  108.     Print("The door opens easily from this side. You pass back into the "
  109.     "chasm area and the door closes and locks again.\n");
  110.     if hidden then
  111.     OPrint("The door opens, then quickly closes again.\n");
  112.     else
  113.     OPrint(Capitalize(name) +
  114.         " opens the door and passes through. The door quickly "
  115.         "closes again.\n");
  116.     fi;
  117.     LeaveRoomStuff(r_chasm6, D_SOUTH, MOVE_SPECIAL);
  118.     EnterRoomStuff(r_chasm6, D_NORTH, MOVE_SPECIAL);
  119.     if hidden then
  120.     OPrint("The door opens, then quickly closes again.\n");
  121.     else
  122.     OPrint("The door opens and " + name + " emerges. "
  123.         "The door quickly closes again.\n");
  124.     fi;
  125.     succeed
  126. corp;
  127. define tp_doorsRoom proc doBackThroughDoor()status:
  128.     ignore backThroughDoor();
  129.     fail
  130. corp;
  131. AddSouthChecker(r_tunnelX4, doBackThroughDoor, false)$
  132.  
  133. define tp_doorsRoom o_door2 CreateThing(nil)$
  134. FakeObject(o_door2, r_tunnelX4, "door;sturdy,wooden", "")$
  135. o_door2@p_oOpenChecker := backThroughDoor$
  136. o_door2@p_oPullChecker := backThroughDoor$
  137. o_door2@p_oPushChecker := backThroughDoor$
  138. o_door2@p_oNotLockable := true$
  139. o_door2@p_Image := "Proving/doorToChasm"$
  140.  
  141. /* Here for a while is the area beyond the door in the crack in the chasm.
  142.    This is the doorsroom area with the winch. */
  143.  
  144. define tp_doorsRoom r_tunnelX CreateThing(r_tunnel)$
  145. r_tunnelX@p_rDark := true$
  146. AutoGraphics(r_tunnelX, AutoTunnels)$
  147. AutoPens(r_tunnelX, C_DARK_GREY, C_LIGHT_GREY, C_LIGHT_GREY, C_LIGHT_GREY)$
  148. SetThingStatus(r_tunnelX, ts_readonly)$
  149.  
  150. define tp_doorsRoom r_tunnelX5 CreateThing(r_tunnelX)$
  151. SetupRoomDP(r_tunnelX5, "in a north-south passage",
  152.     "There is a winch arrangement on the wall here.")$
  153. Connect(r_tunnelX4, r_tunnelX5, D_NORTH)$
  154. Scenery(r_tunnelX5, "hole.rope")$
  155. r_tunnelX5@p_rHintString := "Why do they close so suddenly?"$
  156.  
  157. define tp_doorsRoom r_tunnelX6 CreateThing(r_tunnelX)$
  158. SetupRoomDP(r_tunnelX6, "in a north-south passage", "")$
  159. Connect(r_tunnelX5, r_tunnelX6, D_NORTH)$
  160.  
  161. define tp_doorsRoom r_tunnelX7 CreateThing(r_tunnelX)$
  162. SetupRoomDP(r_tunnelX7, "in a north-south passage", "")$
  163. Connect(r_tunnelX6, r_tunnelX7, D_NORTH)$
  164.  
  165. define tp_doorsRoom PR_DOORS1_ID NextEffectId()$
  166. define tp_doorsRoom proc drawDoors1()void:
  167.  
  168.     if not KnowsEffect(nil, PR_DOORS1_ID) then
  169.     DefineEffect(nil, PR_DOORS1_ID);
  170.     GSetPen(nil, C_BROWN);
  171.     GAMove(nil, 0.127, 0.66);
  172.     VerticalDoor();
  173.     GAMove(nil, 0.165, 0.48);
  174.     NorthWestDoor();
  175.     GAMove(nil, 0.237, 0.4);
  176.     HorizontalDoor();
  177.     GAMove(nil, 0.339, 0.48);
  178.     NorthEastDoor();
  179.     GAMove(nil, 0.376, 0.66);
  180.     VerticalDoor();
  181.     EndEffect();
  182.     fi;
  183.     CallEffect(nil, PR_DOORS1_ID);
  184. corp;
  185.  
  186. define tp_doorsRoom PR_DOORS2_ID NextEffectId()$
  187. define tp_doorsRoom proc drawDoors2()void:
  188.  
  189.     if not KnowsEffect(nil, PR_DOORS2_ID) then
  190.     DefineEffect(nil, PR_DOORS2_ID);
  191.     GSetImage(nil, "Proving/doors2");
  192.     IfFound(nil);
  193.         ShowCurrentImage();
  194.     Else(nil);
  195.         GSetPen(nil, C_DARK_GREY);
  196.         GAMove(nil, 0.0, 0.0);
  197.         GRectangle(nil, 0.5, 1.0, true);
  198.  
  199.         GSetPen(nil, C_LIGHT_GREY);
  200.         GPolygonStart(nil);
  201.         GAMove(nil, 0.219, 0.999);
  202.         GADraw(nil, 0.1875, 0.8);
  203.         GADraw(nil, 0.129, 0.8);
  204.         GADraw(nil, 0.129, 0.6);
  205.         GADraw(nil, 0.1875, 0.405);
  206.         GADraw(nil, 0.3125, 0.405);
  207.         GADraw(nil, 0.374, 0.6);
  208.         GADraw(nil, 0.374, 0.8);
  209.         GADraw(nil, 0.3125, 0.8);
  210.         GADraw(nil, 0.28125, 0.999);
  211.         GPolygonEnd(nil);
  212.  
  213.         drawDoors1();
  214.     Fi(nil);
  215.     EndEffect();
  216.     fi;
  217.     CallEffect(nil, PR_DOORS2_ID);
  218. corp;
  219.  
  220. define tp_doorsRoom PR_DOORS3_ID NextEffectId()$
  221. define tp_doorsRoom proc drawDoors3()void:
  222.  
  223.     if not KnowsEffect(nil, PR_DOORS3_ID) then
  224.     DefineEffect(nil, PR_DOORS3_ID);
  225.     GSetImage(nil, "Proving/doors3");
  226.     IfFound(nil);
  227.         ShowCurrentImage();
  228.     Else(nil);
  229.         GSetPen(nil, C_DARK_GREY);
  230.         GAMove(nil, 0.0, 0.0);
  231.         GRectangle(nil, 0.5, 1.0, true);
  232.  
  233.         GSetPen(nil, C_LIGHT_GREY);
  234.         GPolygonStart(nil);
  235.         GAMove(nil, 0.219, 0.999);
  236.         GADraw(nil, 0.1875, 0.8);
  237.         GADraw(nil, 0.0625, 0.8);
  238.         GADraw(nil, 0.0625, 0.2);
  239.         GADraw(nil, 0.4375, 0.2);
  240.         GADraw(nil, 0.4375, 0.8);
  241.         GADraw(nil, 0.3125, 0.8);
  242.         GADraw(nil, 0.28125, 0.999);
  243.         GPolygonEnd(nil);
  244.         GAMove(nil, 0.219, 0.0);
  245.         GRectangle(nil, 0.0625, 0.2, true);
  246.  
  247.         GSetPen(nil, C_DARK_GREY);
  248.         GAMove(nil, 0.127, 0.8);
  249.         GADraw(nil, 0.127, 0.6);
  250.         GADraw(nil, 0.19, 0.4);
  251.         GADraw(nil, 0.3125, 0.4);
  252.         GADraw(nil, 0.375, 0.6);
  253.         GADraw(nil, 0.375, 0.8);
  254.  
  255.         drawDoors1();
  256.     Fi(nil);
  257.     EndEffect();
  258.     fi;
  259.     CallEffect(nil, PR_DOORS3_ID);
  260. corp;
  261.  
  262. define tp_doorsRoom DOORS1_MAP_GROUP NextMapGroup()$
  263. define tp_doorsRoom DOORS2_MAP_GROUP NextMapGroup()$
  264.  
  265. define tp_doorsRoom r_doorsModel1 CreateThing(r_tunnel)$
  266. r_doorsModel1@p_rDark := true$
  267. r_doorsModel1@p_MapGroup := DOORS1_MAP_GROUP$
  268. r_doorsModel1@p_rDrawAction := drawDoors2$
  269. r_doorsModel1@p_rEnterRoomDraw := EnterRoomDraw$
  270. r_doorsModel1@p_rLeaveRoomDraw := LeaveRoomDraw$
  271. RoomName(r_doorsModel1, "Doors", "Room")$
  272. Scenery(r_doorsModel1, "eye;carved.carving;eye.chamber")$
  273. SetThingStatus(r_doorsModel1, ts_readonly)$
  274.  
  275. define tp_doorsRoom proc makeDoors1(fixed x, y; string name)thing:
  276.     thing doors;
  277.  
  278.     doors := CreateThing(r_doorsModel1);
  279.     doors@p_rName := name;
  280.     doors@p_rContents := CreateThingList();
  281.     doors@p_rExits := CreateIntList();
  282.     doors@p_rCursorX := x;
  283.     doors@p_rCursorY := y;
  284.     SetThingStatus(doors, ts_readonly);
  285.     doors
  286. corp;
  287.  
  288. define tp_doorsRoom r_doorsModel2 CreateThing(r_tunnel)$
  289. r_doorsModel2@p_rDark := true$
  290. r_doorsModel2@p_MapGroup := DOORS2_MAP_GROUP$
  291. r_doorsModel2@p_rDrawAction := drawDoors3$
  292. r_doorsModel2@p_rEnterRoomDraw := EnterRoomDraw$
  293. r_doorsModel2@p_rLeaveRoomDraw := LeaveRoomDraw$
  294. RoomName(r_doorsModel2, "Doors", "Room")$
  295. SetThingStatus(r_doorsModel2, ts_readonly)$
  296.  
  297. define tp_doorsRoom proc makeDoors2(fixed x, y; string name)thing:
  298.     thing doors;
  299.  
  300.     doors := CreateThing(r_doorsModel2);
  301.     doors@p_rName := name;
  302.     doors@p_rContents := CreateThingList();
  303.     doors@p_rExits := CreateIntList();
  304.     doors@p_rCursorX := x;
  305.     doors@p_rCursorY := y;
  306.     SetThingStatus(doors, ts_readonly);
  307.     doors
  308. corp;
  309.  
  310. define tp_doorsRoom r_doorsEntrance makeDoors1(0.253, 0.7,
  311.     "in the room of many doors")$
  312. Connect(r_tunnelX7, r_doorsEntrance, D_NORTH)$
  313. Scenery(r_doorsEntrance, "door.passage")$    /* adds to default */
  314.  
  315. define tp_doorsRoom r_westDoor makeDoors1(0.144, 0.7, "by the west door")$
  316. Connect(r_doorsEntrance, r_westDoor, D_WEST)$
  317.  
  318. define tp_doorsRoom r_northwestDoor makeDoors1(0.172, 0.54,
  319.     "by the northwest door")$
  320. Connect(r_doorsEntrance, r_northwestDoor, D_NORTHWEST)$
  321. Connect(r_westDoor, r_northwestDoor, D_NORTH)$
  322. Connect(r_westDoor, r_northwestDoor, D_NORTHEAST)$
  323.  
  324. define tp_doorsRoom r_northDoor makeDoors1(0.253, 0.45, "by the north door")$
  325. Connect(r_doorsEntrance, r_northDoor, D_NORTH)$
  326. Connect(r_northwestDoor, r_northDoor, D_EAST)$
  327. Connect(r_northwestDoor, r_northDoor, D_NORTHEAST)$
  328.  
  329. define tp_doorsRoom r_northeastDoor makeDoors1(0.328, 0.54,
  330.     "by the northeast door")$
  331. Connect(r_doorsEntrance, r_northeastDoor, D_NORTHEAST)$
  332. Connect(r_northDoor, r_northeastDoor, D_EAST)$
  333. Connect(r_northDoor, r_northeastDoor, D_SOUTHEAST)$
  334.  
  335. define tp_doorsRoom r_eastDoor makeDoors1(0.356, 0.7, "by the east door")$
  336. Connect(r_doorsEntrance, r_eastDoor, D_EAST)$
  337. Connect(r_northeastDoor, r_eastDoor, D_SOUTH)$
  338. Connect(r_northeastDoor, r_eastDoor, D_SOUTHEAST)$
  339.  
  340. define tp_doorsRoom r_westDoor2 makeDoors2(0.106, 0.7, "by the west door")$
  341. Connect(r_westDoor, r_westDoor2, D_WEST)$
  342.  
  343. define tp_doorsRoom r_northwestDoor2 makeDoors2(0.144, 0.46,
  344.     "by the northwest door")$
  345. Connect(r_northwestDoor, r_northwestDoor2, D_NORTHWEST)$
  346. Connect(r_westDoor2, r_northwestDoor2, D_NORTHEAST)$
  347. Connect(r_westDoor2, r_northwestDoor2, D_NORTH)$
  348.  
  349. define tp_doorsRoom r_northDoor2 makeDoors2(0.253, 0.35, "by the north door")$
  350. Connect(r_northDoor, r_northDoor2, D_NORTH)$
  351. Connect(r_northwestDoor2, r_northDoor2, D_NORTHEAST)$
  352. UniConnect(r_northwestDoor2, r_northDoor2, D_NORTH)$
  353. Connect(r_northDoor2, r_northwestDoor2, D_WEST)$
  354.  
  355. define tp_doorsRoom r_northeastDoor2 makeDoors2(0.356, 0.46,
  356.     "by the northeast door")$
  357. Connect(r_northeastDoor, r_northeastDoor2, D_NORTHEAST)$
  358. Connect(r_northeastDoor2, r_northDoor2, D_NORTHWEST)$
  359. UniConnect(r_northeastDoor2, r_northDoor2, D_NORTH)$
  360. Connect(r_northDoor2, r_northeastDoor2, D_EAST)$
  361.  
  362. define tp_doorsRoom r_eastDoor2 makeDoors2(0.394, 0.7, "by the east door")$
  363. Connect(r_eastDoor, r_eastDoor2, D_EAST)$
  364. Connect(r_eastDoor2, r_northeastDoor2, D_NORTHWEST)$
  365. Connect(r_eastDoor2, r_northeastDoor2, D_NORTH)$
  366.  
  367. define tp_proving r_doorsExit makeDoors2(0.25, 0.23,
  368.     "in the room of many doors")$
  369. Connect(r_northDoor2, r_doorsExit, D_NORTH)$
  370.  
  371. ignore DeleteSymbol(tp_doorsRoom, "makeDoors2")$
  372. ignore DeleteSymbol(tp_doorsRoom, "makeDoors1")$
  373.  
  374. define tp_doorsRoom o_doorModel1 CreateThing(nil)$
  375. FakeObject(o_doorModel1, nil, "door;sturdy,wooden", "")$
  376. define tp_doorsRoom proc door1Desc()string:
  377.     if It()@p_oState = 0 then
  378.     "The door looks like it opens by sliding upwards, but it is currently "
  379.     "closed and you can see no way to open it, nor any sign of a keyhole "
  380.     "or other mechanism."
  381.     else
  382.     /* this cannot ever happen */
  383.     "The door is currently slid upwards out of the way."
  384.     fi
  385. corp;
  386. o_doorModel1@p_oDescAction := door1Desc$
  387. define tp_doorsRoom proc door1Unlock(thing door, key)status:
  388.     Print("You can see no lock mechanism on the door.\n");
  389.     succeed
  390. corp;
  391. o_doorModel1@p_oUnlockMeWithChecker := door1Unlock$
  392. o_doorModel1@p_Image := "Proving/doorOutside"$
  393. SetThingStatus(o_doorModel1, ts_readonly)$
  394.  
  395. define tp_doorsRoom o_winch CreateThing(nil)$
  396. FakeObject(o_winch, r_tunnelX5, "winch.arrangement;winch.crank", "")$
  397. o_winch@p_oState := 0$
  398. define tp_doorsRoom proc winchDesc()string:
  399.     "The winch is a hand turned mechanism used for lifting things. A rope "
  400.     "transmits the force from the winch through a hole in the ceiling. It is "
  401.     "not obvious what purpose the winch serves. " +
  402.     if o_winch@p_oState = 0 then
  403.     "The winch is currently fully unwound."
  404.     elif o_winch@p_oState = 5 then
  405.     "The winch is currently fully wound."
  406.     else
  407.     "The winch is currently partly wound."
  408.     fi
  409. corp;
  410. o_winch@p_oDescAction := winchDesc$
  411. o_winch@p_Image := "Proving/winch"$
  412.  
  413. define tp_doorsRoom p_oOtherDoor CreateThingProp()$
  414. define tp_doorsRoom p_oSound CreateStringProp()$
  415. define tp_doorsRoom p_oDoorName CreateStringProp()$
  416.  
  417.     /* The locations actually in the doors room: */
  418. define tp_doorsRoom p_oSoundList CreateThingListProp()$
  419. o_winch@p_oSoundList := CreateThingList()$
  420. AddTail(o_winch@p_oSoundList, r_westDoor)$
  421. AddTail(o_winch@p_oSoundList, r_northwestDoor)$
  422. AddTail(o_winch@p_oSoundList, r_northDoor)$
  423. AddTail(o_winch@p_oSoundList, r_northeastDoor)$
  424. AddTail(o_winch@p_oSoundList, r_eastDoor)$
  425. AddTail(o_winch@p_oSoundList, r_westDoor2)$
  426. AddTail(o_winch@p_oSoundList, r_northwestDoor2)$
  427. AddTail(o_winch@p_oSoundList, r_northDoor2)$
  428. AddTail(o_winch@p_oSoundList, r_northeastDoor2)$
  429. AddTail(o_winch@p_oSoundList, r_eastDoor2)$
  430. AddTail(o_winch@p_oSoundList, r_doorsExit)$
  431.  
  432.     /* The corridor, in order going away from the doors room: */
  433. define tp_doorsRoom p_oSoundList2 CreateThingListProp()$
  434. o_winch@p_oSoundList2 := CreateThingList()$
  435. AddTail(o_winch@p_oSoundList2, r_tunnelX7)$
  436. AddTail(o_winch@p_oSoundList2, r_tunnelX6)$
  437. AddTail(o_winch@p_oSoundList2, r_tunnelX5)$
  438. AddTail(o_winch@p_oSoundList2, r_tunnelX4)$
  439.  
  440.     /* The corridor, in order of distance from winch: (with cheats!) */
  441. define tp_doorsRoom p_oSoundList3 CreateThingListProp()$
  442. o_winch@p_oSoundList3 := CreateThingList()$
  443. AddTail(o_winch@p_oSoundList3, r_tunnelX5)$
  444. AddTail(o_winch@p_oSoundList3, r_tunnelX4)$
  445. AddTail(o_winch@p_oSoundList3, r_tunnelX6)$
  446. AddTail(o_winch@p_oSoundList3, r_tunnelX7)$
  447.  
  448. define tp_doorsRoom o_doorModel2 CreateThing(nil)$
  449. FakeObject(o_doorModel2, nil, "door;sturdy,wooden", "")$
  450. define tp_doorsRoom proc door2Desc()string:
  451.     if It()@p_oOtherDoor@p_oState = 0 then
  452.     "The door looks like it opens by sliding upwards. There is a handy "
  453.     "handle on it for lifting with."
  454.     else
  455.     /* Hmm. should never see this! */
  456.     "The door is currently slid upwards out of the way."
  457.     fi
  458. corp;
  459. o_doorModel2@p_oDescAction := door2Desc$
  460. o_doorModel2@p_oNotLockable := true$
  461. o_doorModel2@p_Image := "Proving/doorInside"$
  462. SetThingStatus(o_doorModel2, ts_readonly)$
  463.  
  464. define tp_doorsRoom proc door1Checker()status:
  465.  
  466.     if Here()@p_rContents[0]@p_oState = 0 then
  467.     Print("You cannot go that way - the door is closed.\n");
  468.     fail
  469.     else
  470.     continue
  471.     fi
  472. corp;
  473.  
  474. define tp_doorsRoom p_oSoundName CreateStringProp()$
  475. define tp_doorsRoom p_oSoundVolume CreateIntProp()$
  476.  
  477. define tp_doorsRoom proc makeOneSound(thing client)void:
  478.  
  479.     if SOn(client) then
  480.     SVolume(client, o_winch@p_oSoundVolume);
  481.     SPlaySound(client, o_winch@p_oSoundName, 1, 0);
  482.     SVolume(client, 10000);
  483.     fi;
  484. corp;
  485.  
  486. define tp_doorsRoom proc doDoorSound(string sound; thing room; int volume)void:
  487.     o_winch@p_oSoundName := sound;
  488.     o_winch@p_oSoundVolume := volume;
  489.     /* Doing this test makes the player hear the sound also, regardless
  490.        of whether we are called by a direct player action. */
  491.     if Here() = room then
  492.     makeOneSound(Me());
  493.     fi;
  494.     ForEachAgent(room, makeOneSound);
  495. corp;
  496.  
  497. define tp_doorsRoom proc makeDoorSound(string sound)void:
  498.     list thing lt;
  499.     int i, volume;
  500.  
  501.     volume := 10000;
  502.     lt := o_winch@p_oSoundList;
  503.     for i from 0 upto Count(lt) - 1 do
  504.     doDoorSound(sound, lt[i], volume);
  505.     od;
  506.     doDoorSound(sound, r_doorsEntrance, volume);
  507.     lt := o_winch@p_oSoundList2;
  508.     for i from 0 upto Count(lt) - 1 do
  509.     volume := volume - DOOR_VOLUME_DECREASE;
  510.     doDoorSound(sound, lt[i], volume);
  511.     od;
  512. corp;
  513.  
  514. define tp_doorsRoom proc doWinchSound(string sound;thing room; int volume)void:
  515.     o_winch@p_oSoundName := sound;
  516.     o_winch@p_oSoundVolume := volume;
  517.     if Here() = room then
  518.     makeOneSound(Me());
  519.     fi;
  520.     ForEachAgent(room, makeOneSound);
  521. corp;
  522.  
  523. define tp_doorsRoom proc makeWinchSound(string sound)void:
  524.     list thing lt;
  525.     int i, volume;
  526.  
  527.     volume := 10000;
  528.     lt := o_winch@p_oSoundList3;
  529.     for i from 0 upto Count(lt) - 1 do
  530.     doWinchSound(sound, lt[i], volume);
  531.     if i ~= 1 then
  532.         volume := volume - WINCH_VOLUME_DECREASE;
  533.     fi;
  534.     od;
  535.     doWinchSound(sound, r_doorsEntrance, volume);
  536.     volume := volume - WINCH_VOLUME_DECREASE;
  537.     lt := o_winch@p_oSoundList;
  538.     for i from 0 upto Count(lt) - 1 do
  539.     doWinchSound(sound, lt[i], volume);
  540.     od;
  541. corp;
  542.  
  543. define tp_doorsRoom proc door2Checker()status:
  544.     thing otherDoor;
  545.  
  546.     otherDoor := Here()@p_rContents[0]@p_oOtherDoor;
  547.     if otherDoor@p_oState = 0 then
  548.     Print("You lift the door by the handle and pass through.\n");
  549.     if CanSee(Here(), Me()) then
  550.         OPrint(Capitalize(CharacterNameG(Me())) +
  551.         " lifts the door and passes through.\n");
  552.     fi;
  553.     SayToList(o_winch@p_oSoundList, otherDoor@p_oSound + "!\n");
  554.     makeDoorSound(otherDoor@p_oSound);
  555.     /* The enter checker for the other room will shut all the doors if
  556.        the player has a light. */
  557.     fi;
  558.     continue
  559. corp;
  560.  
  561. define tp_doorsRoom o_door1W CreateThing(o_doorModel1)$
  562. o_door1W@p_oState := 0$
  563. o_door1W@p_oSound := "Thump"$
  564. o_door1W@p_oDoorName := "west"$
  565. AddTail(r_westDoor@p_rContents, o_door1W)$
  566. AddWestChecker(r_westDoor, door1Checker, false)$
  567. define tp_doorsRoom o_door2W CreateThing(o_doorModel2)$
  568. o_door2W@p_oOtherDoor := o_door1W$
  569. AddTail(r_westDoor2@p_rContents, o_door2W)$
  570. AddEastChecker(r_westDoor2, door2Checker, false)$
  571.  
  572. define tp_doorsRoom o_door1NW CreateThing(o_doorModel1)$
  573. o_door1NW@p_oState := 0$
  574. o_door1NW@p_oSound := "Thud"$
  575. o_door1NW@p_oDoorName := "north-west"$
  576. AddTail(r_northwestDoor@p_rContents, o_door1NW)$
  577. AddNorthWestChecker(r_northwestDoor, door1Checker, false)$
  578. define tp_doorsRoom o_door2NW CreateThing(o_doorModel2)$
  579. o_door2NW@p_oOtherDoor := o_door1NW$
  580. AddTail(r_northwestDoor2@p_rContents, o_door2NW)$
  581. AddSouthEastChecker(r_northwestDoor2, door2Checker, false)$
  582.  
  583. define tp_doorsRoom o_door1N CreateThing(o_doorModel1)$
  584. o_door1N@p_oState := 0$
  585. o_door1N@p_oSound := "Boom"$
  586. o_door1N@p_oDoorName := "north"$
  587. AddTail(r_northDoor@p_rContents, o_door1N)$
  588. AddNorthChecker(r_northDoor, door1Checker, false)$
  589. define tp_doorsRoom o_door2N CreateThing(o_doorModel2)$
  590. o_door2N@p_oOtherDoor := o_door1N$
  591. AddTail(r_northDoor2@p_rContents, o_door2N)$
  592. AddSouthChecker(r_northDoor2, door2Checker, false)$
  593.  
  594. define tp_doorsRoom o_door1NE CreateThing(o_doorModel1)$
  595. o_door1NE@p_oState := 0$
  596. o_door1NE@p_oSound := "Crash"$
  597. o_door1NE@p_oDoorName := "north-east"$
  598. AddTail(r_northeastDoor@p_rContents, o_door1NE)$
  599. AddNorthEastChecker(r_northeastDoor, door1Checker, false)$
  600. define tp_doorsRoom o_door2NE CreateThing(o_doorModel2)$
  601. o_door2NE@p_oOtherDoor := o_door1NE$
  602. AddTail(r_northeastDoor2@p_rContents, o_door2NE)$
  603. AddSouthWestChecker(r_northeastDoor2, door2Checker, false)$
  604.  
  605. define tp_doorsRoom o_door1E CreateThing(o_doorModel1)$
  606. o_door1E@p_oState := 0$
  607. o_door1E@p_oSound := "Bang"$
  608. o_door1E@p_oDoorName := "east"$
  609. AddTail(r_eastDoor@p_rContents, o_door1E)$
  610. AddEastChecker(r_eastDoor, door1Checker, false)$
  611. define tp_doorsRoom o_door2E CreateThing(o_doorModel2)$
  612. o_door2E@p_oOtherDoor := o_door1E$
  613. AddTail(r_eastDoor2@p_rContents, o_door2E)$
  614. AddWestChecker(r_eastDoor2, door2Checker, false)$
  615.  
  616. define tp_doorsRoom p_oDoors CreateThingListProp()$
  617. define tp_doorsRoom p_oMapping CreateIntListProp()$
  618. o_winch@p_oDoors := CreateThingList()$
  619. AddTail(o_winch@p_oDoors, o_door1W)$
  620. AddTail(o_winch@p_oDoors, o_door1NW)$
  621. AddTail(o_winch@p_oDoors, o_door1N)$
  622. AddTail(o_winch@p_oDoors, o_door1NE)$
  623. AddTail(o_winch@p_oDoors, o_door1E)$
  624. o_winch@p_oMapping := CreateIntArray(5)$
  625.  
  626. define tp_doorsRoom proc doorsEntranceDesc()string:
  627.     string str, doorName;
  628.     int openCount, i, openOne;
  629.     list thing doors;
  630.  
  631.     doors := o_winch@p_oDoors;
  632.     openCount := 0;
  633.     for i from 0 upto 4 do
  634.     if doors[i]@p_oState = 1 then
  635.         openOne := i;
  636.         openCount := openCount + 1;
  637.     fi;
  638.     od;
  639.     if openCount = 0 then
  640.     str := "All of the doors are closed."
  641.     elif openCount = 1 then
  642.     str := "The " + doors[openOne]@p_oDoorName + " door is open.";
  643.     elif openCount = 2 then
  644.     str := "";
  645.     for i from 0 upto 4 do
  646.         if doors[i]@p_oState = 1 then
  647.         doorName := doors[i]@p_oDoorName;
  648.         if str = "" then
  649.             str := "The " + doorName + " and ";
  650.         else
  651.             str := str + doorName + " doors are open.";
  652.         fi;
  653.         fi;
  654.     od;
  655.     else
  656.     /* openCount = 3, other values should not be possible */
  657.     for i from 0 upto 4 do
  658.         if doors[i]@p_oState = 1 then
  659.         doorName := doors[i]@p_oDoorName;
  660.         case openCount
  661.         incase 3:
  662.             str := "The " + doorName + ", ";
  663.         incase 2:
  664.             str := str + doorName + " and ";
  665.         incase 1:
  666.             str := str + doorName + " doors are open.";
  667.         esac;
  668.         openCount := openCount - 1;
  669.         fi;
  670.     od;
  671.     fi;
  672.     "This small chamber has 5 doors in it, heading east, northeast, north, "
  673.     "northwest and west. Over each door is a carved eye, and a similar but "
  674.     "larger carving fills much of the floor. " + str + " There is also a "
  675.     "passage leading south, which you are currently in front of."
  676. corp;
  677. r_doorsEntrance@p_rDescAction := doorsEntranceDesc$
  678.  
  679. define tp_doorsRoom proc dropDoor(thing door; bool lightThere)void:
  680.     string sound, sound2;
  681.  
  682.     sound := door@p_oSound;
  683.     sound2 := sound + "!\n";
  684.     SayToList(o_winch@p_oSoundList, sound2);
  685.     makeDoorSound(sound);
  686.     makeWinchSound("winch-down");
  687.     ABPrint(r_doorsEntrance, nil, nil,
  688.     if lightThere then
  689.         sound + "! The " + door@p_oDoorName + " door slams closed!\n"
  690.     else
  691.         sound2
  692.     fi);
  693.     ABPrint(r_tunnelX7, nil, nil, sound2);
  694.     ABPrint(r_tunnelX6, nil, nil, sound2);
  695.     ABPrint(r_tunnelX5, nil, nil, "Rattle-rattle-clang! " + sound +
  696.     if o_winch@p_oState = 0 then
  697.         "! The winch releases the rest of the way.\n"
  698.     else
  699.         "! The winch releases part way.\n"
  700.     fi);
  701.     ABPrint(r_tunnelX4, nil, nil, sound2);
  702.     door@p_oState := 0;
  703. corp;
  704.  
  705. define tp_doorsRoom proc doorsDrop(thing winch)void:
  706.     int state;
  707.  
  708.     state := o_winch@p_oState;
  709.     if state ~= 0 then
  710.     state := state - 1;
  711.     o_winch@p_oState := state;
  712.     dropDoor(o_winch@p_oDoors[o_winch@p_oMapping[state]], false);
  713.     if state ~= 0 then
  714.         DoAfter(DOOR_TIME, winch, doorsDrop);
  715.     fi;
  716.     fi;
  717. corp;
  718.  
  719. define tp_doorsRoom proc clearWinch(bool lightThere)void:
  720.     int state;
  721.     list int li;
  722.     list thing lt;
  723.  
  724.     state := o_winch@p_oState;
  725.     li := o_winch@p_oMapping;
  726.     lt := o_winch@p_oDoors;
  727.     while state ~= 0 do
  728.     state := state - 1;
  729.     o_winch@p_oState := state;
  730.     dropDoor(lt[li[state]], lightThere);
  731.     od;
  732. corp;
  733.  
  734. define tp_doorsRoom proc doorsEnter()status:
  735.  
  736.     if o_winch@p_oState ~= 0 then
  737.     ignore CancelDoAfter(o_winch, doorsDrop);
  738.     doorsDrop(o_winch);
  739.     fi;
  740.     continue
  741. corp;
  742. AddAnyEnterChecker(r_tunnelX5, doorsEnter, false)$
  743. AddAnyEnterChecker(r_tunnelX6, doorsEnter, false)$
  744. AddAnyEnterChecker(r_tunnelX7, doorsEnter, false)$
  745.  
  746. define tp_doorsRoom proc doorsLightEnter()status:
  747.  
  748.     if o_winch@p_oState ~= 0 then
  749.     ignore CancelDoAfter(o_winch, doorsDrop);
  750.     if HasLight(Me()) then
  751.         clearWinch(true);
  752.     else
  753.         doorsDrop(o_winch);
  754.     fi;
  755.     fi;
  756.     continue
  757. corp;
  758. AddAnyEnterChecker(r_doorsEntrance, doorsLightEnter, false)$
  759. AddAnyEnterChecker(r_westDoor, doorsLightEnter, false)$
  760. AddAnyEnterChecker(r_northwestDoor, doorsLightEnter, false)$
  761. AddAnyEnterChecker(r_northDoor, doorsLightEnter, false)$
  762. AddAnyEnterChecker(r_northeastDoor, doorsLightEnter, false)$
  763. AddAnyEnterChecker(r_eastDoor, doorsLightEnter, false)$
  764. AddAnyEnterChecker(r_doorsExit, doorsLightEnter, false)$
  765. AddAnyEnterChecker(r_westDoor2, doorsLightEnter, false)$
  766. AddAnyEnterChecker(r_northwestDoor2, doorsLightEnter, false)$
  767. AddAnyEnterChecker(r_northDoor2, doorsLightEnter, false)$
  768. AddAnyEnterChecker(r_northeastDoor2, doorsLightEnter, false)$
  769. AddAnyEnterChecker(r_eastDoor2, doorsLightEnter, false)$
  770.  
  771. define tp_doorsRoom proc checkAddLight()status:
  772.  
  773.     if o_winch@p_oState ~= 0 then
  774.     ignore CancelDoAfter(o_winch, doorsDrop);
  775.     clearWinch(true);
  776.     fi;
  777.     continue
  778. corp;
  779.  
  780. AddRoomLightChecker(r_doorsEntrance, checkAddLight, true)$
  781. AddRoomLightChecker(r_westDoor, checkAddLight, true)$
  782. AddRoomLightChecker(r_northwestDoor, checkAddLight, true)$
  783. AddRoomLightChecker(r_northDoor, checkAddLight, true)$
  784. AddRoomLightChecker(r_northeastDoor, checkAddLight, true)$
  785. AddRoomLightChecker(r_eastDoor, checkAddLight, true)$
  786. AddRoomLightChecker(r_doorsExit, checkAddLight, true)$
  787. AddRoomLightChecker(r_westDoor2, checkAddLight, true)$
  788. AddRoomLightChecker(r_northwestDoor2, checkAddLight, true)$
  789. AddRoomLightChecker(r_northDoor2, checkAddLight, true)$
  790. AddRoomLightChecker(r_northeastDoor2, checkAddLight, true)$
  791. AddRoomLightChecker(r_eastDoor2, checkAddLight, true)$
  792.  
  793. define tp_doorsRoom proc turnWinch()status:
  794.     int i, j, temp;
  795.     list int li;
  796.     list thing lt;
  797.  
  798.     if o_winch@p_oState ~= 0 then
  799.     Print("Before you can crank up the winch, you first release it from "
  800.         "its current position. ");
  801.     ignore CancelDoAfter(o_winch, doorsDrop);
  802.     clearWinch(false);
  803.     fi;
  804.     Print("The winch turns easily and you quickly crank it up all the way.\n");
  805.     ABPrint(r_tunnelX4, nil, nil, "Rattle-rattle.\n");
  806.     if CanSee(r_tunnelX5, Me()) then
  807.     OPrint(Capitalize(CharacterNameG(Me())) + " cranks the winch up.\n");
  808.     else
  809.     OPrint("You hear someone cranking the winch.\n");
  810.     fi;
  811.     ABPrint(r_tunnelX6, nil, nil, "Rattle-rattle.\n");
  812.     ABPrint(r_tunnelX7, nil, nil, "Rattle-rattle.\n");
  813.     makeWinchSound("winch-up");
  814.     li := o_winch@p_oMapping;
  815.     lt := o_winch@p_oDoors;
  816.     for i from 0 upto 4 do
  817.     li[i] := i;
  818.     lt[i]@p_oState := 1;
  819.     od;
  820.     for i from 0 upto 4 do
  821.     j := Random(5 - i);
  822.     temp := li[i + j];
  823.     li[i + j] := li[i];
  824.     li[i] := temp;
  825.     od;
  826.     o_winch@p_oState := 5;
  827.     if LightAt(r_doorsEntrance) or LightAt(r_westDoor) or
  828.     LightAt(r_northwestDoor) or LightAt(r_northDoor) or
  829.     LightAt(r_northeastDoor) or LightAt(r_eastDoor) or
  830.     LightAt(r_doorsExit) or LightAt(r_westDoor2) or
  831.     LightAt(r_northwestDoor2) or LightAt(r_northDoor2) or
  832.     LightAt(r_northeastDoor2) or LightAt(r_eastDoor2)
  833.     then
  834.     SayToList(o_winch@p_oSoundList, "The door smoothly rises up.\n");
  835.     ABPrint(r_doorsEntrance, nil, nil,"The doors all smoothly rise up.\n");
  836.     ABPrint(r_doorsExit, nil, nil, "The north door smoothly rises up.\n");
  837.     clearWinch(true);
  838.     else
  839.     SayToList(o_winch@p_oSoundList, "You hear something moving.\n");
  840.     DoAfter(DOOR_TIME, o_winch, doorsDrop);
  841.     fi;
  842.     succeed
  843. corp;
  844. o_winch@p_oTurnChecker := turnWinch$
  845.  
  846. unuse tp_doorsRoom
  847.