np2.for 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. C GETOBJ-- FIND OBJ DESCRIBED BY ADJ, NAME PAIR
  2. C
  3. C COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142
  4. C ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED
  5. C WRITTEN BY R. M. SUPNIK
  6. C
  7. C DECLARATIONS
  8. C
  9. C THIS ROUTINE DETAILS ON BIT 3 OF PRSFLG
  10. C
  11. INTEGER FUNCTION GETOBJ(OIDX,AIDX,SPCOBJ)
  12. IMPLICIT INTEGER(A-Z)
  13. LOGICAL THISIT,GHERE,LIT,CHOMP
  14. include 'parser.h'
  15. include 'gamestat.h'
  16. C
  17. C MISCELLANEOUS VARIABLES
  18. C
  19. COMMON /STAR/ MBASE,STRBIT
  20. include 'debug.h'
  21. include 'objects.h'
  22. include 'oflags.h'
  23. include 'advers.h'
  24. include 'vocab.h'
  25. C GETOBJ, PAGE 2
  26. C
  27. D DFLAG=IAND(PRSFLG, 8).NE.0
  28. CHOMP=.FALSE.
  29. AV=AVEHIC(WINNER)
  30. OBJ=0
  31. C !ASSUME DARK.
  32. IF(.NOT.LIT(HERE)) GO TO 200
  33. C !LIT?
  34. C
  35. OBJ=SCHLST(OIDX,AIDX,HERE,0,0,SPCOBJ)
  36. C !SEARCH ROOM.
  37. D IF(DFLAG) PRINT 10,OBJ
  38. D10 FORMAT(' SCHLST- ROOM SCH ',I6)
  39. IF(OBJ) 1000,200,100
  40. C !TEST RESULT.
  41. 100 IF((AV.EQ.0).OR.(AV.EQ.OBJ).OR.
  42. & (IAND(OFLAG2(OBJ),FINDBT).NE.0)) GO TO 200
  43. IF(OCAN(OBJ).EQ.AV) GO TO 200
  44. C !TEST IF REACHABLE.
  45. CHOMP=.TRUE.
  46. C !PROBABLY NOT.
  47. C
  48. 200 IF(AV.EQ.0) GO TO 400
  49. C !IN VEHICLE?
  50. NOBJ=SCHLST(OIDX,AIDX,0,AV,0,SPCOBJ)
  51. C !SEARCH VEHICLE.
  52. D IF(DFLAG) PRINT 20,NOBJ
  53. D20 FORMAT(' SCHLST- VEH SCH ',I6)
  54. IF(NOBJ) 1100,400,300
  55. C !TEST RESULT.
  56. 300 CHOMP=.FALSE.
  57. C !REACHABLE.
  58. IF(OBJ.EQ.NOBJ) GO TO 400
  59. C !SAME AS BEFORE?
  60. IF(OBJ.NE.0) NOBJ=-NOBJ
  61. C !AMB RESULT?
  62. OBJ=NOBJ
  63. C
  64. 400 NOBJ=SCHLST(OIDX,AIDX,0,0,WINNER,SPCOBJ)
  65. C !SEARCH ADVENTURER.
  66. D IF(DFLAG) PRINT 30,NOBJ
  67. D30 FORMAT(' SCHLST- ADV SCH ',I6)
  68. IF(NOBJ) 1100,600,500
  69. C !TEST RESULT
  70. 500 IF(OBJ.NE.0) NOBJ=-NOBJ
  71. C !AMB RESULT?
  72. 1100 OBJ=NOBJ
  73. C !RETURN NEW OBJECT.
  74. 600 IF(CHOMP) OBJ=-10000
  75. C !UNREACHABLE.
  76. 1000 GETOBJ=OBJ
  77. C
  78. IF(GETOBJ.NE.0) GO TO 1500
  79. C !GOT SOMETHING?
  80. DO 1200 I=STRBIT+1,OLNT
  81. C !NO, SEARCH GLOBALS.
  82. IF(.NOT.THISIT(OIDX,AIDX,I,SPCOBJ)) GO TO 1200
  83. IF(.NOT.GHERE(I,HERE)) GO TO 1200
  84. C !CAN IT BE HERE?
  85. IF(GETOBJ.NE.0) GETOBJ=-I
  86. C !AMB MATCH?
  87. IF(GETOBJ.EQ.0) GETOBJ=I
  88. 1200 CONTINUE
  89. C
  90. 1500 CONTINUE
  91. C !END OF SEARCH.
  92. D IF(DFLAG) PRINT 40,GETOBJ
  93. D40 FORMAT(' SCHLST- RESULT ',I6)
  94. RETURN
  95. END
  96. C SCHLST-- SEARCH FOR OBJECT
  97. C
  98. C DECLARATIONS
  99. C
  100. INTEGER FUNCTION SCHLST(OIDX,AIDX,RM,CN,AD,SPCOBJ)
  101. IMPLICIT INTEGER(A-Z)
  102. LOGICAL THISIT,QHERE,NOTRAN,NOVIS
  103. C
  104. COMMON /STAR/ MBASE,STRBIT
  105. include 'objects.h'
  106. include 'oflags.h'
  107. C
  108. C FUNCTIONS AND DATA
  109. C
  110. NOTRAN(O)=(IAND(OFLAG1(O),TRANBT).EQ.0).AND.
  111. & (IAND(OFLAG2(O),OPENBT).EQ.0)
  112. NOVIS(O)=(IAND(OFLAG1(O),VISIBT).EQ.0)
  113. C
  114. SCHLST=0
  115. C !NO RESULT.
  116. DO 1000 I=1,OLNT
  117. C !SEARCH OBJECTS.
  118. IF(NOVIS(I).OR.
  119. & (((RM.EQ.0).OR.(.NOT.QHERE(I,RM))).AND.
  120. & ((CN.EQ.0).OR.(OCAN(I).NE.CN)).AND.
  121. & ((AD.EQ.0).OR.(OADV(I).NE.AD)))) GO TO 1000
  122. IF(.NOT.THISIT(OIDX,AIDX,I,SPCOBJ)) GO TO 200
  123. IF(SCHLST.NE.0) GO TO 2000
  124. C !GOT ONE ALREADY?
  125. SCHLST=I
  126. C !NO.
  127. C
  128. C IF OPEN OR TRANSPARENT, SEARCH THE OBJECT ITSELF.
  129. C
  130. 200 IF(NOTRAN(I)) GO TO 1000
  131. C
  132. C SEARCH IS CONDUCTED IN REVERSE. ALL OBJECTS ARE CHECKED TO
  133. C SEE IF THEY ARE AT SOME LEVEL OF CONTAINMENT INSIDE OBJECT 'I'.
  134. C IF THEY ARE AT LEVEL 1, OR IF ALL LINKS IN THE CONTAINMENT
  135. C CHAIN ARE OPEN, VISIBLE, AND HAVE SEARCHME SET, THEY CAN QUALIFY
  136. C AS A POTENTIAL MATCH.
  137. C
  138. DO 500 J=1,OLNT
  139. C !SEARCH OBJECTS.
  140. IF(NOVIS(J).OR. (.NOT.THISIT(OIDX,AIDX,J,SPCOBJ)))
  141. & GO TO 500
  142. X=OCAN(J)
  143. C !GET CONTAINER.
  144. 300 IF(X.EQ.I) GO TO 400
  145. C !INSIDE TARGET?
  146. IF(X.EQ.0) GO TO 500
  147. C !INSIDE ANYTHING?
  148. IF(NOVIS(X).OR.NOTRAN(X).OR.
  149. & (IAND(OFLAG2(X),SCHBT).EQ.0)) GO TO 500
  150. X=OCAN(X)
  151. C !GO ANOTHER LEVEL.
  152. GO TO 300
  153. C
  154. 400 IF(SCHLST.NE.0) GO TO 2000
  155. C !ALREADY GOT ONE?
  156. SCHLST=J
  157. C !NO.
  158. 500 CONTINUE
  159. C
  160. 1000 CONTINUE
  161. RETURN
  162. C
  163. 2000 SCHLST=-SCHLST
  164. C !AMB RETURN.
  165. RETURN
  166. C
  167. END
  168. C
  169. C THISIT-- VALIDATE OBJECT VS DESCRIPTION
  170. C
  171. C DECLARATIONS
  172. C
  173. LOGICAL FUNCTION THISIT(OIDX,AIDX,OBJ,SPCOBJ)
  174. IMPLICIT INTEGER(A-Z)
  175. LOGICAL NOTEST
  176. include 'vocab.h'
  177. C
  178. C FUNCTIONS AND DATA
  179. C
  180. NOTEST(O)=(O.LE.0).OR.(O.GE.R50MIN)
  181. C
  182. C THE FOLLOWING DATA STATEMENT USED RADIX-50 NOTATION (R50MIN/1RA/)
  183. C IN RADIX-50 NOTATION, AN "A" IN THE FIRST POSITION IS
  184. C ENCODED AS 1*40*40 = 1600.
  185. C
  186. DATA R50MIN/1600/
  187. C
  188. THISIT=.FALSE.
  189. C !ASSUME NO MATCH.
  190. IF((SPCOBJ.NE.0).AND.(OBJ.EQ.SPCOBJ)) GO TO 500
  191. C
  192. C CHECK FOR OBJECT NAMES
  193. C
  194. I=OIDX+1
  195. 100 I=I+1
  196. IF(NOTEST(OVOC(I))) RETURN
  197. C !IF DONE, LOSE.
  198. IF(OVOC(I).NE.OBJ) GO TO 100
  199. C !IF FAIL, CONT.
  200. C
  201. IF(AIDX.EQ.0) GO TO 500
  202. C !ANY ADJ?
  203. I=AIDX+1
  204. 200 I=I+1
  205. IF(NOTEST(AVOC(I))) RETURN
  206. C !IF DONE, LOSE.
  207. IF(AVOC(I).NE.OBJ) GO TO 200
  208. C !IF FAIL, CONT.
  209. C
  210. 500 THISIT=.TRUE.
  211. RETURN
  212. END