Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. /*****************
  2. * bossFight.js *
  3. *****************
  4. *
  5. * NO FARTHER, DR. EVAL!!!!
  6. * YOU WILL NOT GET OUT OF HERE ALIVE!!!!
  7. * IT'S TIME YOU SEE MY TRUE FORM!!!!
  8. * FACE MY ROBOT WRATH!!!!!
  9. */
  10.  
  11. function startLevel(map) {
  12. map.defineObject('boss', {
  13. 'type': 'dynamic',
  14. 'symbol': '⊙',
  15. 'color': 'red',
  16. 'interval': 200,
  17. 'onCollision': function (player) {
  18. player.killedBy('the boss');
  19. },
  20. 'behavior': function (me) {
  21. if (!me.direction) {
  22. me.direction = 'right';
  23. }
  24. if (me.canMove(me.direction)) {
  25. me.move(me.direction);
  26. } else {
  27. me.direction = (me.direction == 'right') ? 'left' : 'right';
  28. }
  29. if (Math.random() < 0.3) {
  30. map.placeObject(me.getX(), me.getY() + 2, 'bullet');
  31. }
  32. },
  33. 'onDestroy': function (me) {
  34. if (map.countObjects('boss') == 0) {
  35. map.placeObject(me.getX(), me.getY(), 'theAlgorithm');
  36. }
  37. }
  38. });
  39.  
  40. map.defineObject('bullet', {
  41. 'type': 'dynamic',
  42. 'symbol': '.',
  43. 'color': 'red',
  44. 'interval': 100,
  45. 'projectile': true,
  46. 'behavior': function (me) {
  47. me.move('down');
  48. }
  49. });
  50.  
  51. map.placePlayer(0, map.getHeight() - 3);
  52. map.placeObject(map.getWidth() - 1, map.getHeight() - 1, 'exit');
  53.  
  54. // Not so tough now, huh?
  55. map.getPlayer().removeItem('phone');
  56. map.placeObject(map.getWidth() - 1, map.getHeight() - 3, 'phone');
  57.  
  58. map.placeObject(0, map.getHeight() - 4, 'block');
  59. map.placeObject(1, map.getHeight() - 4, 'block');
  60. map.placeObject(2, map.getHeight() - 4, 'block');
  61. map.placeObject(2, map.getHeight() - 3, 'block');
  62. map.placeObject(map.getWidth() - 1, map.getHeight() - 4, 'block');
  63. map.placeObject(map.getWidth() - 2, map.getHeight() - 4, 'block');
  64. map.placeObject(map.getWidth() - 3, map.getHeight() - 4, 'block');
  65. map.placeObject(map.getWidth() - 3, map.getHeight() - 3, 'block');
  66.  
  67. for (var x = 0; x < map.getWidth(); x++) {
  68. map.placeObject(x, 4, 'block');
  69. }
  70.  
  71. map.placeObject(9, 5, 'boss');
  72. map.placeObject(11, 5, 'boss');
  73. map.placeObject(13, 5, 'boss');
  74. map.placeObject(15, 5, 'boss');
  75. map.placeObject(17, 5, 'boss');
  76. map.placeObject(19, 5, 'boss');
  77. map.placeObject(21, 5, 'boss');
  78. map.placeObject(23, 5, 'boss');
  79. map.placeObject(25, 5, 'boss');
  80. map.placeObject(27, 5, 'boss');
  81. map.placeObject(29, 5, 'boss');
  82. map.placeObject(31, 5, 'boss');
  83.  
  84. map.placeObject(10, 6, 'boss');
  85. map.placeObject(12, 6, 'boss');
  86. map.placeObject(14, 6, 'boss');
  87. map.placeObject(16, 6, 'boss');
  88. map.placeObject(18, 6, 'boss');
  89. map.placeObject(20, 6, 'boss');
  90. map.placeObject(22, 6, 'boss');
  91. map.placeObject(24, 6, 'boss');
  92. map.placeObject(26, 6, 'boss');
  93. map.placeObject(28, 6, 'boss');
  94. map.placeObject(30, 6, 'boss');
  95.  
  96. map.defineObject('hrenoss', {
  97. 'type': 'dynamic',
  98. 'symbol': '⊙',
  99. 'color': 'yellow',
  100. 'interval': 200,
  101. 'onCollision': function (player) {
  102. player.killedBy('the boss');
  103. },
  104. 'behavior': function (me) {
  105. /*
  106. if (!me.direction) {
  107. me.direction = 'right';
  108. }
  109. if (me.canMove(me.direction)) {
  110. me.move(me.direction);
  111. } else {
  112. me.direction = (me.direction == 'right') ? 'left' : 'right';
  113. }
  114. */
  115. if (Math.random() < 0.3 && map.countObjects('boss')>0) {
  116. map.placeObject(me.getX(), me.getY(), 'hrenullet');
  117. }
  118. },
  119. 'onDestroy': function (me) {
  120. //if (map.countObjects('boss') == 0) {
  121. // map.placeObject(me.getX(), me.getY(), 'theAlgorithm');
  122. //}
  123. }
  124. });
  125.  
  126.  
  127.  
  128. map.defineObject('hrenullet', {
  129. 'type': 'dynamic',
  130. 'symbol': '.',
  131. 'color': 'yellow',
  132. 'interval': 100,
  133. 'projectile': true,
  134. 'behavior': function (me) {
  135. me.move('right');
  136. }
  137. });
  138.  
  139.  
  140.  
  141.  
  142. if (map.isStartOfLevel() == false) {
  143. map.placeObject(1, 5, 'hrenoss');
  144. map.placeObject(1, 6, 'hrenoss');
  145. /*
  146. map.placeObject(9, 12, 'hrenoss');
  147. map.placeObject(11, 12, 'hrenoss');
  148. map.placeObject(13, 12, 'hrenoss');
  149. map.placeObject(12, 12, 'hrenoss');
  150. map.placeObject(17, 12, 'hrenoss');
  151. map.placeObject(19, 12, 'hrenoss');
  152. map.placeObject(21, 12, 'hrenoss');
  153. map.placeObject(23, 12, 'hrenoss');
  154. map.placeObject(25, 12, 'hrenoss');
  155. map.placeObject(27, 12, 'hrenoss');
  156. map.placeObject(29, 12, 'hrenoss');
  157.  
  158. map.placeObject(9, 15, 'hrenoss');
  159. map.placeObject(11, 15, 'hrenoss');
  160. map.placeObject(13, 15, 'hrenoss');
  161. map.placeObject(15, 15, 'hrenoss');
  162. map.placeObject(17, 15, 'hrenoss');
  163. map.placeObject(19, 15, 'hrenoss');
  164. map.placeObject(21, 15, 'hrenoss');
  165. map.placeObject(23, 15, 'hrenoss');
  166. map.placeObject(25, 15, 'hrenoss');
  167. map.placeObject(27, 15, 'hrenoss');
  168. map.placeObject(29, 15, 'hrenoss');
  169.  
  170. map.placeObject(9, 16, 'hrenoss');
  171. map.placeObject(11, 16, 'hrenoss');
  172. map.placeObject(13, 16, 'hrenoss');
  173. map.placeObject(16, 16, 'hrenoss');
  174. map.placeObject(17, 16, 'hrenoss');
  175. map.placeObject(19, 16, 'hrenoss');
  176. map.placeObject(21, 16, 'hrenoss');
  177. map.placeObject(23, 16, 'hrenoss');
  178. map.placeObject(25, 16, 'hrenoss');
  179. map.placeObject(27, 16, 'hrenoss');
  180. map.placeObject(29, 16, 'hrenoss');
  181. */
  182. }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. }
  202.  
  203. function validateLevel(map) {
  204. // called at start of level and whenever a callback executes
  205. map.validateAtMostXObjects(59, 'block');
  206. map.validateAtMostXObjects(1, 'phone');
  207.  
  208. if (map.countObjects('theAlgorithm') > 0 && map.countObjects('boss') > 0) {
  209. throw "The Algorithm can only be dropped by the boss!";
  210. }
  211.  
  212. // only called at start of level
  213. if (map.isStartOfLevel()) {
  214. map.validateAtMostXDynamicObjects(23);
  215. map.validateNoTimers();
  216. }
  217. }
  218.  
  219. function onExit(map) {
  220. if (!map.getPlayer().hasItem('theAlgorithm')) {
  221. map.writeStatus("You must take back the Algorithm!!");
  222. return false;
  223. } else if (!map.getPlayer().hasItem('phone')) {
  224. map.writeStatus("We need the phone!");
  225. return false;
  226. } else {
  227. return true;
  228. }
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement