Advertisement
Xboss_shipmake

Malefore's Dueling Mod

Nov 14th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.21 KB | None | 0 0
  1. //MALEFICS
  2. // by Malefic Machinations
  3. var switch_button = {
  4. id: "switch",
  5. position: [3.5,31,8,14],
  6. clickable: true,
  7. shortcut: "V",
  8. visible: true,
  9. components: [
  10. { type: "box",position:[0,0,100,100],fill:"rgba(68, 85, 102, 0)",stroke:"rgba(204, 221, 238, 0.667)",width:2},
  11. { type: "text",position:[10,23,80,30],value:"SWITCH",color:"rgba(204, 221, 238, 0.8)"},
  12. { type: "text",position:[10,45,80,23],value:"SHIP",color:"rgba(204, 221, 238, 0.8)"},
  13. { type: "text",position:[20,70,60,20],value:"[V]",color:"rgba(204, 221, 238, 0.8)"}
  14. ]
  15. };
  16.  
  17. var stats_button = {
  18. id: "stats",
  19. position: [3.5,48,8,14],
  20. clickable: true,
  21. shortcut: "B",
  22. visible: true,
  23. components: [
  24. { type: "box",position:[0,0,100,100],fill:"rgba(68, 85, 102, 0)",stroke:"rgba(204, 221, 238, 0.667)",width:2},
  25. { type: "text",position:[10,23,80,30],value:"TOGGLE",color:"rgba(204, 221, 238, 0.8)"},
  26. { type: "text",position:[10,45,80,23],value:"STATS",color:"rgba(204, 221, 238, 0.8)"},
  27. { type: "text",position:[20,70,60,20],value:"[B]",color:"rgba(204, 221, 238, 0.8)"}
  28. ]
  29. };
  30.  
  31. var reset_button = {
  32. id: "reset",
  33. position: [3.5,65,8,14],
  34. clickable: true,
  35. shortcut: "R",
  36. visible: true,
  37. components: [
  38. { type: "box",position:[0,0,100,100],fill:"rgba(68, 85, 102, 0)",stroke:"rgba(204, 221, 238, 0.667)",width:2},
  39. { type: "text",position:[10,34,80,25],value:"RESET",color:"rgba(204, 221, 238, 0.8)"},
  40. { type: "text",position:[20,70,60,20],value:"[R]",color:"rgba(204, 221, 238, 0.8)"}
  41. ]
  42. };
  43.  
  44. var crystals_button = {
  45. id: "crystals",
  46. position: [3.5,82,8,14],
  47. clickable: true,
  48. shortcut: "M",
  49. visible: true,
  50. components: [
  51. { type: "box",position:[0,0,100,100],fill:"rgba(68, 85, 102, 0)",stroke:"rgba(204, 221, 238, 0.667)",width:2},
  52. { type: "text",position:[10,34,80,25],value:"CRYSTALS",color:"rgba(204, 221, 238, 0.8)"},
  53. { type: "text",position:[20,70,60,20],value:"[M]",color:"rgba(204, 221, 238, 0.8)"}
  54. ]
  55. };
  56.  
  57. var buttons = [stats_button, reset_button, switch_button, crystals_button];
  58.  
  59. var ship_list = [
  60. [101,201,202,301,302,303,304,401,402,403,404,405,406,501,502,503,504,505,506,507,601,602,603,604,605,606,607,608,701,702,703,704]
  61. ];
  62.  
  63. var vocabulary = [
  64. { text: "You", icon:"\u004e", key:"O" },
  65. { text: "GG", icon:"\u00a3", key:"G" },
  66. { text: "Sorry", icon:"\u00a1", key:"S" },
  67. { text: "No Problem", icon:"\u0047", key:"P" },
  68. { text: "hmm?", icon:"\u004b", key:"Q" },
  69. { text: "Wait", icon:"\u0048", key:"T" },
  70. { text: "Yes", icon:"\u004c", key:"Y" },
  71. { text: "No", icon:"\u004d", key:"N" },
  72. { text: "Attack", icon:"\u00b4", key:"A" },
  73. { text: "Enemy", icon:"\u002b", key:"M" },
  74. { text: "Heal", icon:"\u0037", key:"H" },
  75. { text: "Defend", icon:"\u0025", key:"D" },
  76. { text: "Retreat", icon:"\u00bc", key:"I" },
  77. { text: "Thanks", icon:"\u0041", key:"X" },
  78. { text: "Kill", icon:"\u005b", key:"K" },
  79. { text: "Follow", icon:"\u0050", key:"F" },
  80. { text: "Me", icon:"\u004f", key:"E" },
  81. { text: "Base", icon:"\u0034", key:"B" },
  82. { text: "Upgrade", icon:"\u0078", key:"L" },
  83. ] ;
  84.  
  85. this.options = {
  86. map_name: "Dueling",
  87. root_mode: "",
  88. reset_tree: false,
  89. max_players: 60,
  90. vocabulary: vocabulary,
  91. lives: 5,
  92. map_size: 70,
  93. custom_map: [],
  94. crystal_value: 0,
  95. asteroids_strength: 3,
  96. survival_level: 8,
  97.  
  98. } ;
  99.  
  100. log = function(s){
  101. game.modding.terminal.echo(s);
  102. };
  103. playerList = function(){
  104. for(nn=0;nn<game.ships.length;nn++)
  105. log(nn+" - "+game.ships[nn].name);
  106. } ;
  107.  
  108. playerID = function() {
  109. for (ship of game.ships) echo(ship.id + " : " + ship.name);
  110. };
  111.  
  112. setAll = function() {
  113. for (ship of game.ships) ship.set({type:101, shield:50000});
  114. };
  115.  
  116. instructorSaysAll = function(saysWhat, instructor = "Zoltar"){
  117. for(ship of game.ships) ship.instructorSays(saysWhat, instructor);
  118. };
  119.  
  120. hideInstructor = function(){
  121. for(ship of game.ships) ship.hideInstructor();
  122. };
  123.  
  124. this.tick = function(game) {
  125. if ( game.step % 30 == 0 ) {
  126. for (let ship of game.ships) {
  127. if (!ship.custom.buttons_installed && ship.alive)
  128. {
  129. ship.custom.buttons_installed = true;
  130. for (b in buttons)
  131. {
  132. ship.setUIComponent(buttons[b]);
  133. ship.custom.tree = 0;
  134. for (let tree = 0; tree < ship_list.length; tree++) {
  135. if (ship_list[tree].indexOf(ship.type) >= 0) {
  136. ship.custom.tree = tree;
  137. break;
  138. }
  139. }
  140. }
  141. }
  142. var level = Math.trunc(ship.type / 100);
  143. if (level < 7) {
  144. var max_stats = 11111111 * level;
  145. if (ship.custom.keep_maxed) {
  146. if (ship.stats != max_stats) {
  147. ship.set({stats:max_stats});
  148. }
  149. }
  150. } else if (ship.stats > 0) {
  151. ship.set({stats:0});
  152. }
  153. }
  154. }
  155. };
  156.  
  157.  
  158. this.event = function(event, game) {
  159. switch (event.name)
  160. {
  161. case "ship_destroyed":
  162. if (event.killer !== null)
  163. {
  164. event.killer.custom.kills = event.killer.custom.kills + 1 || 1;
  165. }
  166. break;
  167. case "ui_component_clicked":
  168. var ship = event.ship;
  169. var component = event.id;
  170. switch (component)
  171. {
  172. case "switch":
  173. var tree = ship.custom.tree;
  174. var index = -1;
  175. index = ship_list[tree].indexOf(ship.type);
  176. if (index >= 0) {
  177. var new_type;
  178. var new_stats = 0;
  179. index = (index + 1) % ship_list[tree].length;
  180. new_type = ship_list[tree][index];
  181. var level = Math.trunc(new_type / 100);
  182. if (level < 7 && ship.custom.keep_maxed)
  183. {
  184. var max = 11111111 * level;
  185. if (ship.stats != max) {
  186. new_stats = max;
  187. }
  188. }
  189. ship.set({type:new_type,stats:new_stats});
  190. }
  191. break;
  192. case "stats":
  193. var stats = ship.stats;
  194. var level = Math.trunc(ship.type / 100);
  195. var max = 11111111 * level;
  196. if (level < 7)
  197. {
  198. if (stats == max)
  199. {
  200. ship.custom.keep_maxed = false;
  201. ship.set({stats:0});
  202. } else {
  203. ship.custom.keep_maxed = true;
  204. ship.set({stats:max});
  205. }
  206. }
  207. break;
  208. case "reset":
  209. var new_stats = ship.custom.keep_maxed ? 11111111 : 0;
  210. ship.set({type:101,stats:new_stats});
  211. break;
  212. case "crystals":
  213. var level = Math.trunc(ship.type / 100);
  214. var cargo = 980;
  215. switch (level) {
  216. case 1:
  217. cargo = 20;
  218. break;
  219. case 2:
  220. cargo = 80;
  221. break;
  222. case 3:
  223. cargo = 180;
  224. break;
  225. case 4:
  226. cargo = 320;
  227. break;
  228. case 5:
  229. cargo = 500;
  230. break;
  231. case 6:
  232. cargo = 720;
  233. break;
  234. case 7:
  235. cargo = 980;
  236. break;
  237. }
  238. ship.set({crystals:cargo});
  239. break;
  240. }
  241. break;
  242. }
  243. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement