Advertisement
Guest User

Untitled

a guest
Jul 27th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. var status;
  2.  
  3. // These are the maps available for JQ.
  4. var maps = [100000000,101000000,102000000,103000000];
  5. var points = [1,2,3,4];
  6.  
  7. // This array gets pushed with a chosen map's name
  8. var selections = [];
  9.  
  10. // Return map id
  11. var returnMap = 910000000;
  12. var choosing = null;
  13. var playList = false;
  14.  
  15.  
  16. function start() {
  17. status = -1;
  18. var getJQ = cm.getPlayer().getJQ();
  19. if (getJQ == null) {
  20. // cm.sendSimple("Hey, #e#h ##n! I'm the JQ manager. What do you want to do?\r\n" +
  21. // "\t\t\t\t\t#L100##bPlaylist\t\t#L101#Random#k\r\n\r\n\r\n\t\t\t\t#lForget the special modes! I want vanilla!\r\n" + sendMaps());
  22. cm.sendSimple("Which JQ would you like to attempt? You currently have #b"+cm.getPlayer().getJQPoints()+"#k JQ points.\r\n\r\n#b#L101#Random JQ\r\n#L100#Start a playlist\r\n" + sendMaps());
  23. } else {
  24. var notFinished = !getJQ.checkFinished();
  25. if (notFinished) {
  26. if (cm.getParty() != null)
  27. cm.warpParty(maps[getJQ.getNextMap()]);
  28. else
  29. cm.warp(maps[getJQ.getNextMap()]);
  30. }
  31. cm.print(getJQ.getCurrentMap());
  32. cm.getPlayer().yellowMessage("You have gained " +
  33. points[getJQ.getCurrentMap()] + " JQ points!");
  34. cm.getPlayer().gainJQPoints(points[getJQ.getCurrentMap()]);
  35. getJQ.advanceStage();
  36. cm.dispose();
  37. }
  38. }
  39.  
  40. function action(m,t,s) {
  41. if (m != 1) {
  42. cm.dispose();
  43. return;
  44. }
  45. status++;
  46. if (status == 0) {
  47. // Playlist
  48. if (s == 102) {
  49. cm.dispose();
  50. } else if (s == 100 || playList) {
  51. playList = true;
  52. text = "These are your currently selected maps:\r\n\t\t#b" + sendMapNames(false).join(", ") + "\r\n\r\n";
  53. text += "#kWhat maps do you wish to add to your playlist?\r\n" + sendMaps();
  54. text += "#e\r\n#L501#Clear current selections\r\n";
  55. text += "#L1000#Delete a selection\r\n";
  56. text += "#L1001#Shuffle playlist\r\n"
  57. text += "#L500#Start the JQ!";
  58. cm.sendSimple(text);
  59. } else {
  60. selections.push(s == 101 ? Math.floor(Math.random() * maps.length) : s);
  61. text = s == 101 ? "You have been given a #d#erandom map#n#k to play on." : "You have selected " +
  62. "#e#d#m" + maps[s] + "##k#n as your current map.";
  63. cm.sendSimple(text + "\r\n\r\n\t\t#L500#Enter JQ\t\t#L502#View Rankings");
  64. }
  65. } else if (status == 1) {
  66. if (s == 500) {
  67. if (selections.length > 0) {
  68. if (cm.getParty() != null)
  69. cm.warpParty(maps[selections[0]]);
  70. else
  71. cm.warp(maps[selections[0]]);
  72. cm.startJumpQuest(selections, returnMap);
  73. cm.dispose();
  74. } else {
  75. cm.sendOk("You cannot start a JQ when you have no maps chosen!");
  76. cm.dispose();
  77. }
  78. } else if (s==1001) {
  79. cm.sendNext("Your list has been shuffled!");
  80. shuffle();
  81. status = -1;
  82. } else if (s == 1000) {
  83. if (selections.length == 0) {
  84. cm.sendNext("You currently have no selected maps!")
  85. status = -1;
  86. } else {
  87. cm.sendSimple("What maps do you wish to delete from your playlist?\r\n\r\n#b" +
  88. sendMapNames(true));
  89. }
  90. } else if (s == 502) {
  91. cm.sendOk("\t\t\t\t\t\t\t#eRankings for #b#m"+maps[selections[0]]+"##k#n\r\n\r\n" + cm.getRankings(maps[selections[0]]));
  92. cm.dispose();
  93. } else if (s == 501) {
  94. cm.sendNext("Your current playlist has been cleared.");
  95. selections = [];
  96. status = -1;
  97. } else if (playList) {
  98. cm.sendNext("You've chosen #b#m " + maps[s] + "##k as a JQ map.");
  99. selections.push(s);
  100. status = -1;
  101. }
  102. } else if (status == 2) {
  103. cm.sendNext("You have removed #b#m" + maps[s] + "##k from your playlist.");
  104. selections.splice(selections.indexOf(s), 1);
  105. status = -1;
  106. }
  107. }
  108.  
  109. function sendMaps() {
  110. text = "";
  111. for (x = 0; x < maps.length; x++) {
  112. if (selections.indexOf(x) < 0)
  113. text += "#L"+x+"##m"+maps[x]+"# ("+points[x]+" "+(points[x]== 1 ? "point" : "points")+")\r\n";
  114. }
  115. return text;
  116. }
  117.  
  118. function sendMapNames(deletion) {
  119. var mapNames = [];
  120. var text = "";
  121. for (var x = 0; x < selections.length; x++) {
  122. if (!deletion)
  123. mapNames.push("#m"+maps[selections[x]]+"#");
  124. else
  125. text += "#L"+selections[x]+"##m"+maps[selections[x]]+"#\r\n";
  126. }
  127. return deletion ? text : mapNames;
  128. }
  129.  
  130. function shuffle() {
  131. var currentIndex = selections.length, temporaryValue, randomIndex ;
  132.  
  133. // While there remain elements to shuffle...
  134. while (0 !== currentIndex) {
  135.  
  136. // Pick a remaining element...
  137. randomIndex = Math.floor(Math.random() * currentIndex);
  138. currentIndex -= 1;
  139.  
  140. // And swap it with the current element.
  141. temporaryValue = selections[currentIndex];
  142. selections[currentIndex] = selections[randomIndex];
  143. selections[randomIndex] = temporaryValue;
  144.  
  145. }
  146.  
  147. return;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement