Advertisement
Bob_the_Hamster

pushpush.hss

Jan 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.41 KB | None | 0 0
  1. #---------------------------------------------------------------------
  2. # PUSH-PUSH (SOKOBAN) SCRIPT for the O.H.R.RPG.C.E
  3. #---------------------------------------------------------------------
  4. include, plotscr.hsd
  5. include, scancode.hsi
  6. #---------------------------------------------------------------------
  7. define script(1,init game,none)
  8. define script(2,each step handler,none)
  9. define script(3,on keypress handler,none)
  10. define script(autonumber,load next map,none)
  11. define script(autonumber,load previous map,none)
  12. define script(autonumber,reload current map,none)
  13. define script(autonumber,set starting point,none)
  14. define script(autonumber,build box list,none)
  15. define script(autonumber,check for victory,none)
  16. define script(autonumber,save progress,none)
  17. #---------------------------------------------------------------------
  18. global variable(0,allow play)
  19. global variable(1,steps)
  20. global variable(2,cheater)
  21. global variable(3,boxes)
  22. global variable(4,save)
  23. #---------------------------------------------------------------------
  24. define constant(5,box)
  25. define constant(31,max map width)
  26. define constant(19,max map height)
  27. define constant(2,song offset)
  28. define constant(12,number of songs)
  29. define constant(1,palette offset)
  30. define constant(10,number of palettes)
  31. #---------------------------------------------------------------------
  32. script, init game, begin
  33. cheater:=false
  34. suspend player
  35. allow play:=false
  36. suspend box advance
  37. show text box(2)
  38. wait for key
  39. advance text box
  40. resume box advance
  41. fade screen out
  42. advance text box
  43. load next map
  44. $1="Steps:"
  45. end
  46. #---------------------------------------------------------------------
  47. script, load next map, begin
  48. allow play:=false
  49. steps:=0
  50. variable(old map)
  51. old map:=current map
  52. teleport to map(current map+1,0,0)
  53. if(old map==current map)
  54. then(teleport to map(1,0,0))
  55. write gmap
  56. play song(song offset+(current map,mod,number of songs))
  57. show no value
  58. write gmap(4,0) # disable map name display
  59. set starting point
  60. build box list
  61. check for victory
  62. alter NPC(0,NPCstat:move speed,4)
  63. alter NPC(0,NPCstat:pushability,NPCpush:full)
  64. alter NPC(1,NPCstat:move speed,4)
  65. alter NPC(1,NPCstat:pushability,NPCpush:full)
  66. alter NPC(1,NPCstat:picture,1)
  67. show string at (0,5,5)
  68. $0="Level:"
  69. append number (0,current map)
  70. hide string (2)
  71. wait(1)
  72. fade screen in
  73. allow play:=true
  74. set hero speed(me,4)
  75. end
  76. #---------------------------------------------------------------------
  77. script, set starting point, begin
  78. variable(x,y)
  79. for(y,0,max map height) do(
  80. for(x,0,max map width) do(
  81. if(read pass block(x,y),and,harm tile) then(
  82. set hero position (me,x,y)
  83. )
  84. )
  85. )
  86. end
  87. #---------------------------------------------------------------------
  88. script, reload current map, begin
  89. fade screen out
  90. teleport to map (current map--1,0,0)
  91. load next map
  92. end
  93. #---------------------------------------------------------------------
  94. script, load previous map, begin
  95. fade screen out
  96. teleport to map (current map--2,0,0)
  97. load next map
  98. end
  99. #---------------------------------------------------------------------
  100. script, on keypress handler, begin
  101. variable(x,y,handle,wall)
  102. x:=hero X(me)
  103. y:=hero Y(me)
  104. if(hero is walking(me)==false, and, allow play) then(
  105. if(key is pressed(key:UP)) then(
  106. handle:=NPC at spot(X,Y--1)
  107. if(handle<<0) then(
  108. wall:=read pass block(X,Y--2)
  109. if((wall,and,south wall)==false,and,NPC at spot(X,Y--2)>=0) then(
  110. walk NPC(handle,UP,1)
  111. change NPC ID(handle,0)
  112. )
  113. )
  114. walk hero(me,UP,1)
  115. )else(
  116. if(key is pressed(key:RIGHT)) then(
  117. handle:=NPC at spot(X+1,Y)
  118. if(handle<<0) then(
  119. wall:=read pass block(X+2,Y)
  120. if((wall,and,west wall)==false,and,NPC at spot(X+2,Y)>=0) then(
  121. walk NPC(handle,RIGHT,1)
  122. change NPC ID(handle,0)
  123. )
  124. )
  125. walk hero(me,RIGHT,1)
  126. )else(
  127. if(key is pressed(key:DOWN)) then(
  128. handle:=NPC at spot(X,Y+1)
  129. if(handle<<0) then(
  130. wall:=read pass block(X,Y+2)
  131. if((wall,and,north wall)==false,and,NPC at spot(X,Y+2)>=0) then(
  132. walk NPC(handle,DOWN,1)
  133. change NPC ID(handle,0)
  134. )
  135. )
  136. walk hero(me,DOWN,1)
  137. )else(
  138. if(key is pressed(key:LEFT)) then(
  139. handle:=NPC at spot(X--1,Y)
  140. if(handle<<0) then(
  141. wall:=read pass block(X--2,Y)
  142. if((wall,and,east wall)==false,and,NPC at spot(X--2,Y)>=0) then(
  143. walk NPC(handle,LEFT,1)
  144. change NPC ID(handle,0)
  145. )
  146. )
  147. walk hero(me,LEFT,1)
  148. )
  149. )
  150. )
  151. )
  152. )
  153. if(key is pressed(key:ESC)) then(
  154. show text box(3)
  155. wait for text box
  156. if(check tag(2)) then(
  157. set tag(2,OFF)
  158. wait for hero(me)
  159. reload current map
  160. )
  161. if(check tag(3)) then(
  162. set tag(3,OFF)
  163. fade screen out
  164. game over
  165. )
  166. )
  167. if(key is pressed(key:PERIOD)) then(
  168. wait for hero(me)
  169. fade screen out
  170. cheater:=current map+1
  171. show text box(6) # cheater
  172. load next map
  173. )
  174. if(key is pressed(key:COMMA)) then(
  175. if(current map<=cheater) then(cheater:=false)
  176. wait for hero(me)
  177. load previous map
  178. )
  179. if(key is pressed(key:SPACE)>>1) then(
  180. set hero palette(0,palette offset+((get hero palette(0)--palette offset+1),mod,number of palettes))
  181. )
  182. end
  183. #---------------------------------------------------------------------
  184. script, build box list, begin
  185. variable(x,y,tile,ref)
  186. boxes:=0
  187. for(y,0,max map height) do(
  188. for(x,0,max map width) do(
  189. tile:=read pass block(x,y)
  190. if(tile,and,vehicle B) then(
  191. ref:=create NPC(0,x,y)
  192. write global(box+boxes,ref)
  193. boxes:=boxes+1
  194. )
  195. )
  196. )
  197. end
  198. #---------------------------------------------------------------------
  199. script, each step handler, begin
  200. if(allow play) then(
  201. steps:=steps+1
  202. copy string(2,1)
  203. append number(2,steps)
  204. show string at (2,315--string length(2)*8,5)
  205. check for victory
  206. )
  207. end
  208. #---------------------------------------------------------------------
  209. script, check for victory, begin
  210. variable(i,ref,tile,done)
  211. # search to see if all tiles are done
  212. done:=0
  213. for(i,0,boxes--1) do(
  214. ref:=read global(box+i)
  215. tile:=read pass block(NPC X(ref),NPC Y(ref))
  216. if(tile,and,vehicle A) then(
  217. done:=done+1
  218. change NPC ID(ref,1)
  219. )else(
  220. change NPC ID(ref,0)
  221. )
  222. )
  223. if(done>=boxes) then(
  224. allow play:=false
  225. alter NPC(0,NPCstat:move speed,0)
  226. alter NPC(0,NPCstat:pushability,NPCpush:off)
  227. alter NPC(1,NPCstat:move speed,0)
  228. alter NPC(1,NPCstat:pushability,NPCpush:off)
  229. set hero speed(me,0)
  230. play song(1)
  231. suspend box advance
  232. if(cheater)
  233. then(show text box (6)) # cheater
  234. else(show text box (1)) # victory
  235. wait (6)
  236. wait for key
  237. advance text box
  238. resume box advance
  239. save progress
  240. wait (1)
  241. fade screen out
  242. stop song
  243. load next map
  244. )
  245. end
  246. #---------------------------------------------------------------------
  247. script, save progress, begin
  248. if (save >= 0) then (
  249. if (autosave) else (save := -1)
  250. )
  251. end
  252. #---------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement