sfranked.txt 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. carved_pumpkin = read.item("carved_pumpkin");
  2. leaves_tag = block.getTag("minecraft:leaves");
  3. double_block_half_property = block.getProperty("double_block_half");
  4. gosub("setstart");
  5. step = 1;
  6. gamename = "§aSammelfieber";
  7. rankingtable = "sfsingle";
  8. game_short = "sfsingle";
  9. sign.started(gamesignloc);
  10. event.load("bucket_use");
  11. event.load("player_pickup");
  12. event.load("craft");
  13. min = 16;
  14. sec = 0;
  15. timer_string = concat("§bTimer: §r", text.number(min), " min 0", text.number(sec), " s");
  16. farmtypes = list.new();
  17. list.add(farmtypes, "minecraft:carrots");
  18. list.add(farmtypes, "minecraft:melon_stem");
  19. list.add(farmtypes, "minecraft:potatoes");
  20. list.add(farmtypes, "minecraft:wheat");
  21. player_blocks = set.new();
  22. set.add(player_blocks, "minecraft:crafting_table");
  23. set.add(player_blocks, "minecraft:furnace");
  24. set.add(player_blocks, "minecraft:chest");
  25. nextitems = list.new();
  26. founditems = list.new();
  27. player_blocks_placed = set.new();
  28. resetlist_type = list.new();
  29. resetlist_loc = list.new();
  30. resetlistdouble_type = list.new();
  31. resetlistdouble_loc = list.new();
  32. resetlistdouble_loc2 = list.new();
  33. sgoto(2, "tick");
  34. minigame.speakAll(gamename, "Collect as many shown items as you can.");
  35. minigame.speakAll(gamename, "Drop and collect not counted items again.");
  36. @wait
  37. wait();
  38. if(event == "living_pre_hurt") {
  39. if(!isPlayer(living_entity)) {
  40. goto("wait");
  41. }
  42. player = living_entity;
  43. }
  44. if(player.hasMinigameId(player, script_id)) {
  45. ignoreGoto(event);
  46. }
  47. goto("wait");
  48. @player_join
  49. templist = list.new();
  50. list.add(templist, items1);
  51. list.add(templist, items2);
  52. list.add(templist, items3);
  53. list.add(templist, items4);
  54. for(h = 0; h < list.getSize(templist); h++) {
  55. list = list.getIndex(templist, h);
  56. for(i = 0; i < list.getSize(list); i++) {
  57. item_type = list.getIndex(list, i);
  58. item = read.item(item_type);
  59. if(item == null) {
  60. minigame.speakAll(item_type);
  61. minigame.speakAll("False Item found. Game termed. Inform marvinius.");
  62. term();
  63. }
  64. }
  65. }
  66. player_list = minigame.getPlayers(script_id);
  67. minigame.speakAll(gamename, "The game has started.");
  68. iter = list.iterator(player_list);
  69. while(hasNext(iter)) {
  70. player = player.get(next(iter));
  71. entity.teleport(player, spawn_loc);
  72. player.setGamemode(player, "survival");
  73. player.setFly(player, false);
  74. entity.cleareffects(player);
  75. living.setHealth(player, 20);
  76. player.setHunger(player, 20);
  77. player.setSaturation(player, 5);
  78. player.clearInventory(player);
  79. display.reset(player);
  80. display.add(player, 1, gamename);
  81. display.add(player, 2, timer_string);
  82. display.add(player, 3, "§bFound Items: §r0");
  83. display.add(player, 4, "§bNext Items:");
  84. entity.addEffect(player, "speed", 19200, 1);
  85. }
  86. for(h = 0; h < 3; h++) {
  87. gosub("newitem");
  88. }
  89. goto("wait");
  90. @block_click
  91. if(action == "right") {
  92. if(set.contains(player_blocks, block_type)) {
  93. goto("wait");
  94. }
  95. if(hand == "MAIN_HAND") {
  96. hand = "hand";
  97. } else {
  98. hand = "offhand";
  99. }
  100. item_type = item.getType(living.getEquip(player, hand));
  101. if(set.contains(player_blocks, item_type)) {
  102. goto("wait");
  103. }
  104. cancel = true;
  105. if(block_type == "minecraft:pumpkin" && item_type == "minecraft:shears") {
  106. item.drop(block_loc, carved_pumpkin);
  107. }
  108. }
  109. goto("wait");
  110. @living_pre_hurt
  111. if(isPlayer(living_entity)) {
  112. cancel = true;
  113. }
  114. goto("wait");
  115. @block_break
  116. cancel = false;
  117. if(set.contains(player_blocks, block_type)) {
  118. goto("wait");
  119. }
  120. if(block.hasTag(leaves_tag, block.get(block_loc))) {
  121. split_list = text.split("_", block_type);
  122. drop_type = concat(text.concatList(split_list, "_", 0, list.getSize(split_list) - 2), "_sapling");
  123. item.drop(block_loc, read.item(drop_type));
  124. }
  125. state = block.property.getValue(block_loc, double_block_half_property);
  126. if(state != null) {
  127. if(state == "lower") {
  128. loc = block_loc;
  129. loc2 = loc.mod(block_loc, 0, 1, 0);
  130. } else {
  131. loc = loc.mod(block_loc, 0, -1, 0);
  132. loc2 = block_loc;
  133. }
  134. list.add(resetlistdouble_type, block_type);
  135. list.add(resetlistdouble_loc, loc);
  136. list.add(resetlistdouble_loc2, loc2);
  137. sgoto(2, "doubleresetblock");
  138. goto("wait");
  139. }
  140. if(block_type == "minecraft:vine") {
  141. cancel = true;
  142. goto("wait");
  143. }
  144. if(block_type == "minecraft:sugar_cane") {
  145. cancel = true;
  146. item.drop(block_loc, read.item("sugar_cane"));
  147. goto("wait");
  148. }
  149. if(block_type == "minecraft:farmland") {
  150. cancel = true;
  151. goto("wait");
  152. }
  153. list.add(resetlist_type, block_type);
  154. list.add(resetlist_loc, block_loc);
  155. sgoto(2, "resetblock");
  156. goto("wait");
  157. @bucket_use
  158. cancel = true;
  159. goto("wait");
  160. @block_place
  161. cancel = true;
  162. if(set.contains(player_blocks, block_type)) {
  163. cancel = false;
  164. set.add(player_blocks_placed, block_loc);
  165. }
  166. goto("wait");
  167. @doubleresetblock
  168. btype = list.getIndex(resetlistdouble_type, 0);
  169. loc = list.getIndex(resetlistdouble_loc, 0);
  170. loc2 = list.getIndex(resetlistdouble_loc2, 0);
  171. list.removeIndex(resetlistdouble_type, 0);
  172. list.removeIndex(resetlistdouble_loc, 0);
  173. list.removeIndex(resetlistdouble_loc2, 0);
  174. block.set(loc, concat(btype, "[half=lower]"));
  175. block.set(loc2, concat(btype, "[half=upper]"));
  176. goto("wait");
  177. @resetblock
  178. btype = list.getIndex(resetlist_type, 0);
  179. bloc = list.getIndex(resetlist_loc, 0);
  180. list.removeIndex(resetlist_type, 0);
  181. list.removeIndex(resetlist_loc, 0);
  182. if(list.contains(farmtypes, btype)) {
  183. block.set(bloc, concat(btype, "[age=7]"));
  184. } else {
  185. block.set(bloc, btype);
  186. }
  187. goto("wait");
  188. @tick
  189. if(sec == 0) {
  190. sec = 59;
  191. min--;
  192. if(min == -1) {
  193. goto("endgame");
  194. }
  195. } else {
  196. sec--;
  197. if(sec < 10) {
  198. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min 0", text.number(sec), " s"));
  199. } else {
  200. minigame.displayAll(2, concat("§bTimer: §r", text.number(min), " min ", text.number(sec), " s"));
  201. }
  202. if(min == 0) {
  203. if(sec == 30) {
  204. minigame.speakAll(gamename, "30 seconds left!");
  205. } elseif(sec == 10) {
  206. minigame.speakAll(gamename, "10 seconds left!");
  207. } elseif(sec == 5) {
  208. minigame.speakAll(gamename, "5 seconds left!");
  209. }
  210. }
  211. }
  212. sgoto(20, "tick");
  213. goto("wait");
  214. @player_pickup
  215. @craft
  216. itype = item.getType(item);
  217. if(list.contains(nextitems, itype)) {
  218. list.add(founditems, itype);
  219. list.remove(nextitems, itype);
  220. minigame.displayAll(3, concat("§bFound Items: §r", text.number(list.getSize(founditems))));
  221. gosub("newitem");
  222. }
  223. goto("wait");
  224. @newitem
  225. if(min < 12) {
  226. if(step == 1) {
  227. for(i = 0; i < list.getSize(items2); i++) {
  228. list.add(items1, list.getIndex(items2, i));
  229. }
  230. step = 2;
  231. }
  232. if(min < 8) {
  233. if(step == 2) {
  234. for(i = 0; i < list.getSize(items3); i++) {
  235. list.add(items1, list.getIndex(items3, i));
  236. }
  237. step = 3;
  238. }
  239. if(min < 4) {
  240. if(step == 3) {
  241. for(i = 0; i < list.getSize(items4); i++) {
  242. list.add(items1, list.getIndex(items4, i));
  243. }
  244. step = 4;
  245. }
  246. }
  247. }
  248. }
  249. items1_size = list.getSize(items1);
  250. if(items1_size == 0) {
  251. return;
  252. }
  253. randomitemstring = list.getIndex(items1, math.random(0, items1_size - 1));
  254. list.remove(items1, randomitemstring);
  255. list.add(nextitems, randomitemstring);
  256. for(i = 0; i < list.getSize(nextitems); i++) {
  257. type = list.getIndex(nextitems, i);
  258. minigame.displayAll(5 + i, text.replace(type, "minecraft:", ""));
  259. }
  260. return;
  261. @endgame
  262. yetfound = list.getSize(founditems);
  263. iter = list.iterator(player_list);
  264. while(hasNext(iter)) {
  265. player = player.get(next(iter));
  266. player_id = player.getId(player);
  267. playedgames = minigame.getPlayed(player_id, game_short) + 1;
  268. minigame.setPlayed(player_id, game_short, playedgames);
  269. last_record = ranking.getPoints(rankingtable, player_id);
  270. if(last_record < yetfound) {
  271. diff = yetfound - last_record;
  272. last_record = yetfound;
  273. }
  274. ranking.setPoints(rankingtable, player_id, last_record);
  275. minigame.statsHeader(player, $gamename, "§e");
  276. minigame.statsLine(player, "§e", "Found Items", text.number(yetfound));
  277. if(diff != null) {
  278. msg(player, " §e- §rBeat own record by §e", text.number(diff));
  279. }
  280. minigame.statsLine(player, "§e", "Played games", text.number(playedgames));
  281. money.addBoost(player, yetfound / 2);
  282. }
  283. @player_logout
  284. @player_giveup
  285. script = script.getFromId(script_id);
  286. iter = set.iterator(player_blocks_placed);
  287. while(hasNext(iter)) {
  288. block.set(next(iter), "minecraft:air");
  289. }
  290. entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
  291. minigame.kickplayer(script, player);
  292. minigame.term(script, gamesignloc);
  293. term();