Advertisement
45rfew

Untitled

Jan 20th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var x = 6; // max amount of aliens being spawned
  2.  
  3. // define ships here
  4.  
  5. // deleted
  6.  
  7. // ship defining ends
  8.  
  9. // ship pushes but i deleted them
  10.  
  11.  
  12. var vocabulary = [
  13.   { text: "", icon:"", key:"A" },
  14. ];
  15.  
  16. var map =
  17. "95555555555555555555555555555555555555555555555555555555555555555555559\n"+ //// 1
  18. "5                                                                     5\n"+
  19. "5                                                                     5\n"+
  20. "5                                                                     5\n"+
  21. "5                                                                     5\n"+
  22. "5                                                                     5\n"+ // 5
  23. "5 9999999999999999999999999999999999999999999999999999999999999999999 5\n"+
  24. "5 9999999999999999999999999999999999999999999999999999999999999999999 5\n"+
  25. "5 99                     2                    123456789            99 5\n"+
  26. "5 99456           9      7             9 123456789           99    99 5\n"+
  27. "5 99      6  9    2           17  9               5      5 5       99 5\n"+ //// 10
  28. "5 99  7                  3 7 2   9   6      7    6      4 6   3 1  99 5\n"+
  29. "5 99 3  5765611 5   2  9    9999     7      91 9   7     8     9   99 5\n"+
  30. "5 99      8 5   5556     54  14 1     2  77501  54   1 7     6 2   99 5\n"+
  31. "5 99 28       7060040   91 72 08  15 45  77   502    3       9  3  99 5\n"+
  32. "5 99  6  978    5 3 97   3     2 21    6   1 5 8  21 05     91 972 99 5\n"+ // 15
  33. "5 99 12  97  9   957 958  3    8 70 5     98749 84 5 72 13 9 28    99 5\n"+
  34. "5 99    9  9 9 988 9  897 4 123456789 1 55   9 58  34 3       36   99 5\n"+
  35. "5 99 9638  9  5     83    345  9999     1 341     8   4    9     8 99 5\n"+
  36. "5 99          9   6   8  7   4   3   84        9   2     4   47 8  99 5\n"+
  37. "5 99  9  8  8 6 69  3 384 994 71 995 9 95  1     1   7       3     99 5\n"+ //// 20
  38. "5 99    9 8 8 9 28      2 94   3 92 48 9 9            9   7        99 5\n"+
  39. "5 99                      6                  5   3     9 8     9   99 5\n"+
  40. "5 9999999999999999999999999999999999999999999999999999999999999999999 5\n"+
  41. "5 9999999999999999999999999999999999999999999999999999999999999999999 5\n"+
  42. "5                                                   5      976559988  5\n"+ // 25
  43. "5   9                                              595      876879678 5\n"+
  44. "5                                                   5      967678678  5\n"+
  45. "5                                             5             76978678  5\n"+
  46. "5                     9                      595           6789786    5\n"+
  47. "5                                             5           67967967967 5\n"+ //// 30
  48. "5                                                                     5\n"+
  49. "5                                                                     5\n"+
  50. "5                                                                 5   5\n"+
  51. "5                                                                595  5\n"+
  52. "5         9                                         999           5   5\n"+ // 35
  53. "5                         9                          9                5\n"+
  54. "5                                999999              9                5\n"+
  55. "5                                                    9                5\n"+
  56. "5    9999999999                                      9                5\n"+
  57. "5   999999999999999999                               9                5\n"+ //// 40
  58. "5   9            59999999                            9        5       5\n"+
  59. "5   999999995635999999999999                         9       595      5\n"+
  60. "5          999999998765                              9        5  5    5\n"+
  61. "5                                  5                 9          595   5\n"+
  62. "5                                 595                9           5    5\n"+ // 45
  63. "5                                  5                 9                5\n"+
  64. "5                                                    9                5\n"+
  65. "5       5                                       714269876247634676    5\n"+
  66. "5      595                                    9817498993264869386     5\n"+
  67. "5       5                                  87623846289746873646       5\n"+ //// 50
  68. "5             5                   82364872638766     9                5\n"+
  69. "5            595                                     9                5\n"+
  70. "5             5                                      9            5   5\n"+
  71. "5                              5                     9           595  5\n"+
  72. "5                             595  9874534788888999  976769       5   5\n"+ // 55
  73. "5   999999999999999999999      5          999999 9875979 779          5\n"+
  74. "5   999999999999999999999                         9999 98589 9999     5\n"+
  75. "5   9999999999     999999                    999     9 999 9999 9     5\n"+
  76. "5   9999999999     999999                  9999999   9    99 9999 99  5\n"+
  77. "5   99999999999999 999999  5              999999999  9          9999  5\n"+ //// 60
  78. "5   999999999999     9999 595             999999999  9                5\n"+
  79. "5   9999    9999     9999  5             9999222999999                5\n"+
  80. "5   9999 99 9999     9999                5656  29999                  5\n"+
  81. "5   9999 99 9999 999 9999                99992229999          5       5\n"+
  82. "5   9999 99 9999 999 9999             5   999999999          595      5\n"+ // 65
  83. "5   9999 99      99954599            595  999999999           5       5\n"+
  84. "5        9999999999935699             5    9999999                    5\n"+
  85. "5   999999999999999999999                    999                      5\n"+
  86. "5                                                                     5\n"+
  87. "55555555555555555555555555555555555555555555555555555555555555555555555" ;  //// 70
  88. //1234567890123456789012345678901234567890123456789012345678901234567890
  89. //0        1         2         3    !    4         5         6         7
  90. this.options = {
  91.  
  92.   map_name: "",
  93.   root_mode: "unspecified",
  94.   reset_tree: false,
  95.   // ships:
  96.  
  97.   // asteroids
  98.  
  99.   crystal_value: 5,
  100.   asteroids_strength: 0.6,
  101.  
  102.   // ships
  103.  
  104.   starting_ship: 101,
  105.   starting_ship_maxed: true,
  106.   max_players: 120,
  107.   max_level: 8,
  108.   healing_enabled: true,
  109.   lives: 5,
  110.   friendly_colors: 0,
  111.   healing_ratio: 2,
  112.   release_crystal: true,
  113.  
  114.   // custom game settings
  115.  
  116.   rcs_roggle: true,
  117.   friction_ratio: 1,
  118.   speed_mod: 1,
  119.   shield_regen_factor: 1,
  120.   power_regen_factor: 1,
  121.  
  122.   // secondaries
  123.  
  124.   weapons_store: true,
  125.   auto_refill: true,
  126.   projectile_speed: 1,
  127.   weapon_drop: 0.1,
  128.   mines_self_destroy: false,
  129.   mines_destroy_delay: 99,
  130.  
  131.   // map
  132.  
  133.   map_id: 5000,
  134.   radar_zoom: 1,
  135.   custom_map: map,
  136.   map_size: 70,
  137.  
  138.   // misc
  139.  
  140.   survival_time: 99,
  141.   survival_level: 8,
  142.   vocabulary: vocabulary
  143. };
  144.  
  145. randint = function(max,min=0) {
  146.   return Math.floor(Math.random(min) * Math.floor(max));
  147. };
  148. randAlien = function(lien) {
  149.   for (var i=0; i<lien; i++) {
  150.     nx = (Math.random()-0.5) * game.options.map_size*10 ;
  151.     ny = (Math.random()-0.5) * game.options.map_size*10 ;
  152.     var x = randint(20);
  153.     var mxlvl = 3;
  154.     if (x > 9){
  155.       switch(x){
  156.         case 20:
  157.           break;
  158.         case 12:
  159.           break;
  160.         case 19:
  161.           break;
  162.         case 15:
  163.           break;
  164.         case 16:
  165.           mxlvl = 2;
  166.           break;
  167.         case 18:
  168.           break;
  169.         case 13:
  170.           break;
  171.         default:
  172.             game.addAlien({code:x,level:randint(mxlvl),x:nx,y:ny,crystal_drop:randint(200),weapon_drop:randsc()}) ;
  173.       }
  174.     }
  175.   }
  176. } ;
  177. randsecondary = function(lien) {
  178.   for (var i=0; i<lien; i++) {
  179.     nx = (Math.random()-0.5) * game.options.map_size*10 ;
  180.     ny = (Math.random()-0.5) * game.options.map_size*10 ;
  181.     var x = randint(21);
  182.     var mxlvl = 3;
  183.     if (x > 9){
  184.       switch (x){
  185.         case 10:
  186.           game.addCollectible({code:x,x:ny,y:nx}) ;
  187.           break;
  188.         case 11:
  189.           game.addCollectible({code:x,x:ny,y:nx}) ;
  190.           break;
  191.         case 12:
  192.           game.addCollectible({code:x,x:ny,y:nx}) ;
  193.           break;
  194.         case 20:
  195.           game.addCollectible({code:x,x:ny,y:nx}) ;
  196.           break;
  197.         case 21:
  198.           game.addCollectible({code:x,x:ny,y:nx}) ;
  199.           break;
  200.         default:
  201.           break;
  202.       }
  203.     }
  204.   }
  205. };
  206. randsc = function() {
  207.   while (true){
  208.     var v = randint(21);
  209.     var mxlvl = 3;
  210.     if (v > 9){
  211.       switch (x){
  212.         case 10:
  213.           return v;
  214.         case 11:
  215.           return v;
  216.         case 12:
  217.           return v;
  218.         case 20:
  219.           return v;
  220.         case 21:
  221.           return v;
  222.         default:
  223.           continue;
  224.       }
  225.     }
  226.   }
  227. };
  228. torp = function(torps){
  229.   for (var i=0; i<torps; i++) {
  230.     game.addCollectible({code: 12, x: 0, y: 0});
  231.   }
  232. };
  233. say = function(saysWhat, instructor = "Zoltar"){
  234.     for(var i=0; i<game.ships.length; i++){
  235.         game.ships[i].instructorSays(saysWhat, instructor);
  236.     }
  237. };
  238. hide = function(){
  239.     for(var i=0; i<game.ships.length; i++){
  240.         game.ships[i].hideInstructor();
  241.     }
  242. };
  243. init = function(lvl,who=0){
  244.   if (lvl < 199){
  245.     gem = 20;
  246.   }
  247.   else if (lvl < 299){
  248.     gem = 80;
  249.   }
  250.   else if (lvl < 399){
  251.     gem = 180;
  252.   }
  253.   else if (lvl < 499){
  254.     gem = 320;
  255.   }
  256.   else if (lvl < 599){
  257.     gem = 500;
  258.   }
  259.   else if (lvl < 699){
  260.     gem = 720;
  261.   }
  262.   else if (lvl < 710){
  263.     gem = 980;
  264.   }
  265.   else if (lvl > 715){
  266.     gem = 999999;
  267.   }
  268.   game.ships[who].set({
  269.     type:lvl,
  270.     stats:88888888,
  271.     shield:1000,
  272.     crystals:gem
  273.   });
  274. };
  275. statl = function(dam,rate,speed,shield){
  276. for(var i=0; i<game.aliens.length; i++)
  277.   game.aliens[i].set({
  278.     damage: dam,
  279.     rate: rate,
  280.     laser_speed: speed,
  281.     shield: shield
  282.   });
  283. };
  284. killaliens = function(){
  285. for(var i=0; i<game.aliens.length; i++)
  286.    game.aliens[i].set({
  287.      kill:true
  288.    });
  289. };
  290. kill = function(who){
  291.   game.ships[who].set({kill:true});
  292. };
  293. massset = function(id){
  294. for(var z=0; z<game.ships.length; z++)
  295.   set(id,z);
  296. };
  297. alien = function(code,lvl,qw,wdp,poin){
  298.   game.addAlien({
  299.   code:code,
  300.   level:lvl,
  301.   crystal_drop:qw,
  302.   weapon_drop: wdp,
  303.   points:poin
  304.  });
  305. };
  306. alienwave = function(amm,code,lvl,qw,wdp,poin){
  307.   for (var i=0; i<amm; i++) {
  308.     alien(code,lvl,qw,wdp,poin);
  309.   }
  310. };
  311. maxout = function(wot){
  312. game.ships[wot].set({stats:99999999});
  313. };
  314. set = function(code,shi=0){
  315.   if (code < 710){
  316.     game.ships[shi].set({type:code});
  317.   }
  318.   else if (code > 710){
  319.     game.ships[shi].set({type:code});
  320.     gems(shi,999999)
  321.   }
  322. };
  323. sun = function(wat){
  324.   game.ships[wat].set({x:0,y:0,vx:0,vy:0});
  325. };
  326. tp = function(xx,yy){
  327.   game.ships[0].set({x:xx,y:yy});
  328. };
  329. tpto = function(who){
  330.   ship = game.ships[who];
  331.   game.ships[0].set({x:ship.x,y:ship.y});
  332. };
  333. sunall = function(){
  334. for(var i=0; i<game.ships.length; i++)
  335.   game.ships[i].set({x:0,y:0});
  336. };
  337. sunaliens = function(){
  338. for(var i=0; i<game.aliens.length; i++)
  339.   game.aliens[i].set({x:0,y:0});
  340. };
  341. drain = function(who){
  342.   game.ships[who].set({
  343.     shield:1,
  344.     crystals:0
  345.   });
  346. };
  347. heal = function(who){
  348.   game.ships[who].set({
  349.     shield:999
  350.   });
  351. };
  352. team = function(who,uh){
  353.   game.ships[who].set({team:uh});
  354. };
  355. color = function(who,uh){
  356.   game.ships[who].set({hue:uh});
  357. };
  358. oof = function(heh){
  359.   game.addAsteroid({
  360.     size: 100,
  361.     vx: heh
  362.   });
  363. };
  364. check = function(who,how){
  365.   game.ships[who].set({score:how});
  366. };
  367. playerList = function(){
  368. for(var i = 0; i<game.ships.length; i++)
  369.     game.modding.terminal.echo(i+" - "+game.ships[i]);
  370. }; // //
  371. kick = function(i,reason="Unspecified."){
  372.   game.ships[i].gameover({"You were kicked for reason: ":reason,"Your name: ":ship.name,"Kicked by:":game.ships[0].name,"Score: ":ship.score});
  373. }; // //
  374. rType = function(){
  375.   var a = randint(7)
  376.   switch (a){
  377.     case 0:
  378.       return 101;
  379.     case 1:
  380.       var r = randint(1)
  381.       switch (r){
  382.         case 0: return 201;
  383.         case 1: return 202;
  384.       }
  385.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  386.       return 101
  387.     case 2:
  388.       var r = randint(4)
  389.       switch (r){
  390.         case 0: return 301;
  391.         case 1: return 302;
  392.         case 2: return 303;
  393.         case 3: return 304;
  394.       }
  395.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  396.       return 101
  397.     case 3:
  398.       var r = randint(6)
  399.       switch (r){
  400.         case 0: return 401;
  401.         case 1: return 402;
  402.         case 2: return 403;
  403.         case 3: return 404;
  404.         case 4: return 405;
  405.         case 5: return 406;
  406.       }
  407.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  408.       return 101
  409.     case 4:
  410.       var r = randint(7)
  411.       switch (r){
  412.         case 0: return 501;
  413.         case 1: return 502;
  414.         case 2: return 503;
  415.         case 3: return 504;
  416.         case 4: return 505;
  417.         case 5: return 506;
  418.         case 6: return 507;
  419.       }
  420.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  421.       return 101
  422.     case 5:
  423.       var r = randint(8)
  424.       switch (r){
  425.         case 0: return 601;
  426.         case 1: return 602;
  427.         case 2: return 603;
  428.         case 3: return 604;
  429.         case 4: return 605;
  430.         case 5: return 606;
  431.         case 6: return 607;
  432.         case 7: return 608;
  433.       }
  434.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  435.       return 101
  436.     case 6:
  437.       var r = randint(4)
  438.       switch (r){
  439.         case 0: return 701;
  440.         case 1: return 702;
  441.         case 2: return 703;
  442.         case 3: return 704;
  443.       }
  444.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  445.       return 101
  446.     default:
  447.       game.modding.terminal.echo("something went wrong while trying to assign a random type")
  448.       return 101;
  449.   }
  450. }
  451. randomize = function(){
  452.   randAlien(randint(50))
  453.   for(var i = 0; i<game.ships.length; i++){
  454.     game.ships[i].set({
  455.       type:rType(),
  456.       x: (Math.random()-.5) * game.ships[i].game.options.map_size*10,
  457.       y: (Math.random()-.5) * game.ships[i].game.options.map_size*10,
  458.       crystals: randint(720),
  459.       stats: randint(66666666),
  460.       generator: randint(300),
  461.       score: randint(10000),
  462.       angle: randint(360)
  463.     })
  464.   }
  465. }
  466. restart = function(){
  467.   killaliens()
  468.   for(var i = 0; i<game.ships.length; i++){
  469.     game.ships[i].set({
  470.       type:101,
  471.       x: (Math.random()-.5) * game.ships[i].game.options.map_size*10,
  472.       y: (Math.random()-.5) * game.ships[i].game.options.map_size*10,
  473.       crystals: 0,
  474.       stats: 11111111,
  475.       generator: 0,
  476.       score: randint(0),
  477.       vx: 0,
  478.       vy: 0,
  479.       invulnerable: 250
  480.     })
  481.     msg(i,'The game was restarted.')
  482.   }
  483. }
  484. di = function(q){
  485.   game.ships[q].set({
  486.     healing:true
  487.   });
  488. };
  489. en = function(q){
  490.   game.ships[q].set({
  491.     healing:false
  492.   });
  493. };
  494. idle = function(w){
  495.   game.ships[w].set({
  496.     idle: true
  497.   });
  498. };
  499. idlent = function(w){
  500.   game.ships[w].set({
  501.     idle: false
  502.   });
  503. };
  504. info = function(){
  505. game.modding.terminal.echo('Total amount of aliens:'+game.aliens.length)
  506. game.modding.terminal.echo('Total amount of players:'+game.ships.length)
  507. for(nn=0;nn<game.ships.length;nn++)
  508. game.modding.terminal.echo(nn+": "+game.ships[nn].name+', type: '+game.ships[nn].type);
  509. }; // //
  510. gems = function(who,how){
  511.   game.ships[who].set({
  512.     crystals:how
  513.   });
  514. };
  515. msg = function(who,what){
  516.   game.ships[who].intermission({"Message:":what,"Message sent by:":game.ships[0].name})
  517. };
  518. msgall = function(what){
  519.   for(nn=0;nn<game.ships.length;nn++){
  520.   game.ships[nn].intermission({"Global message:":what,"Message sent by:":game.ships[0].name})
  521.   }
  522. };
  523.  
  524. var gem_button = {
  525.   id: "gem_button",
  526.   position: [2,50,8,14],
  527.   clickable: true,
  528.   shortcut: "M",
  529.   visible: false,
  530.   components: []
  531. };
  532.  
  533. var GiveGems = function(ship) {
  534.   var lvl = ship.type
  535.   var multiplier = 4
  536.   var gemAdd = 5;
  537.   if (lvl < 199){
  538.     gemLim = 20;
  539.     var gemAdd = 3*multiplier;
  540.   }
  541.   else if (lvl < 299){
  542.     var gemLim = 80;
  543.     var gemAdd = 3*multiplier;
  544.   }
  545.   else if (lvl < 399){
  546.     var gemLim = 180;
  547.     var gemAdd = 3*multiplier;
  548.   }
  549.   else if (lvl < 499){
  550.     var gemLim = 320;
  551.     var gemAdd = 6*multiplier;
  552.   }
  553.   else if (lvl < 599){
  554.     var gemLim = 500;
  555.     var gemAdd = 9*multiplier;
  556.   }
  557.   else if (lvl < 699){
  558.     var gemLim = 720;
  559.     var gemAdd = 12*multiplier;
  560.   }
  561.   else if (lvl < 790){
  562.     var gemLim = 980;
  563.     var gemAdd = 16*multiplier;
  564.   }
  565.   else if (lvl > 790){
  566.     var gemLim = 999999;
  567.     var gemAdd = 99999;
  568.   }
  569.   var newcr = ship.crystals+gemAdd;
  570.   if (newcr > gemLim){
  571.     var newcr = gemLim;
  572.   }
  573.   ship.set({
  574.     crystals:newcr,
  575.     generator:0,
  576.     stats:88888888,
  577.   });
  578. } ;
  579.  
  580. var reset_button = {
  581.   id: "reset_button",
  582.   position: [2,50,8,14],
  583.   clickable: true,
  584.   shortcut: "R",
  585.   visible: false,
  586.   components: []
  587. };
  588.  
  589. var Reset = function(ship) {
  590.   ship.set({
  591.     type:101,
  592.     x: (Math.random()-.5) * ship.game.options.map_size*10,
  593.     y: (Math.random()-.5) * ship.game.options.map_size*10,
  594.     crystals: 0,
  595.     stats: 11111111,
  596.     generator: 0,
  597.     score: 0,
  598.     vx: 0,
  599.     vy: 0,
  600.     invulnerable: 250
  601.   })
  602. }
  603.  
  604. var hi_button = {
  605.   id: "hi_button",
  606.   position: [2,50,8,14],
  607.   clickable: true,
  608.   shortcut: "I",
  609.   visible: false,
  610.   components: []
  611. };
  612.  
  613. var healer_button = {
  614.   id: "healer_button",
  615.   position: [2,50,8,14],
  616.   clickable: true,
  617.   shortcut: "P",
  618.   visible: false,
  619.   components: []
  620. };
  621.  
  622. var toggleHeal = function(ship) {
  623.   ship.set({healing:!ship.healing})
  624. }
  625.  
  626. this.tick = function(game) {
  627.   if (game.aliens.length<x){
  628.     randAlien(1);
  629.   };
  630.   if (game.step%60==0){
  631.     for (var i=0;i<game.ships.length;i++){
  632.       var ship = game.ships[i];
  633.       if (!ship.custom.buttons_installed){
  634.         ship.custom.buttons_installed = true
  635.         ship.setUIComponent(gem_button);
  636.         ship.setUIComponent(hi_button);        
  637.         ship.setUIComponent(reset_button);
  638.         ship.setUIComponent(healer_button);        
  639.       }
  640.     }
  641.   }
  642. };
  643.  
  644. this.event = function(event,game){
  645.   switch (event.name){
  646.     case "ui_component_clicked":
  647.       var ship = event.ship ;
  648.       var component = event.id ;
  649.       if (component == "gem_button"){
  650.         GiveGems(ship);
  651.       } else
  652.       if (component == "reset_button"){
  653.         Reset(ship);
  654.       } else
  655.       if (component == "hi_button"){
  656.         game.modding.terminal.echo(ship.name+" says Hi!")
  657.       } else  
  658.       if (component == "healer_button"){
  659.         toggleHeal(ship)
  660.       }      
  661.     break;
  662.   }
  663. };
  664.  
  665. GSPrtp = (who) => {
  666.   game.ships[who].set({
  667.     x: (Math.random()-0.5) * game.options.map_size*10,
  668.     y: (Math.random()-0.5) * game.options.map_size*10,
  669.     invulnerable: 400,
  670.     shield: 1000,
  671.     generator: 1000,
  672.     crystals: 720
  673.   });
  674.   msg(who,'GSP has started!');
  675.   for (var i = 0; i<7; i++)
  676.   game.addCollectible({code:randsc(),x:game.ships[who].x,y:game.ships[who].y});
  677. };
  678.  
  679. gsp = () => {
  680.   for(var i = 0; i<game.ships.length; i++){
  681.     GSPrtp(i);
  682.   }
  683. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement