itemhunt.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. pumpkin_mat = material.get("pumpkin");
  2. shears_mat = material.get("shears");
  3. vine_mat = material.get("vine");
  4. sugar_cane_mat = material.get("sugar_cane");
  5. farmland_mat = material.get("farmland");
  6. carved_pumpkin = item.new(material.get("carved_pumpkin"));
  7. sugar_cane = item.new(sugar_cane_mat);
  8. minigame.initStart();
  9. step = 1;
  10. gamename = "§aItemHunt";
  11. minigame.setPlayerResetInCore(false);
  12. templist = list.new();
  13. list.add(templist, items1);
  14. list.add(templist, items2);
  15. list.add(templist, items3);
  16. list.add(templist, items4);
  17. for(h = 0; h < list.getSize(templist); h++) {
  18. list = list.getIndex(templist, h);
  19. for(i = 0; i < list.getSize(list); i++) {
  20. item_type = list.getIndex(list, i);
  21. mat = material.get(item_type);
  22. if(mat == null) {
  23. minigame.speakAll(gamename, item_type);
  24. minigame.speakAll(gamename, "False Item found. Game termed. Inform marvinius.");
  25. term();
  26. }
  27. }
  28. }
  29. goto("simplelobby");
  30. @specificLobbyHandling
  31. if(event == "minigame_join") {
  32. if(init_signs == null) {
  33. sign.setString(sign_min_block, 2, string.number(min));
  34. sign.setString(sign_amount_block, 2, string.number(amount_nextitems));
  35. init_signs = true;
  36. }
  37. return;
  38. }
  39. if(event == "block_click") {
  40. if(slot.isOffHand(hand)) {
  41. return;
  42. }
  43. if(block == null) {
  44. return;
  45. }
  46. block_loc = block.getLocation(block);
  47. if(block_loc == plus_min_loc) {
  48. if(min < max_mins) {
  49. min++;
  50. }
  51. sign.setString(sign_min_block, 2, string.number(min));
  52. return;
  53. }
  54. if(block_loc == minus_min_loc) {
  55. if(min > 1) {
  56. min--;
  57. }
  58. sign.setString(sign_min_block, 2, string.number(min));
  59. return;
  60. }
  61. if(block_loc == plus_amount_loc) {
  62. if(amount_nextitems < max_nextitems) {
  63. amount_nextitems++;
  64. }
  65. sign.setString(sign_amount_block, 2, string.number(amount_nextitems));
  66. return;
  67. }
  68. if(block_loc == minus_amount_loc) {
  69. if(amount_nextitems > 1) {
  70. amount_nextitems--;
  71. }
  72. sign.setString(sign_amount_block, 2, string.number(amount_nextitems));
  73. return;
  74. }
  75. }
  76. return;
  77. @finalstart
  78. player_list = minigame.getPlayers(script_id);
  79. minigame.speakAll(gamename, "The game has started.");
  80. whole_secs = min * 60 + sec;
  81. time_phase_1 = whole_secs / 4 * 3;
  82. time_phase_2 = whole_secs / 4 * 2;
  83. time_phase_3 = whole_secs / 4;
  84. timer_string = string.concat("§bTimer: §r", string.number(min), " min 0", string.number(sec), " s");
  85. iter = iterator(player_list);
  86. while(hasNext(iter)) {
  87. player = player.get(next(iter));
  88. entity.teleport(player, spawn_loc);
  89. player.setGamemode(player, "SURVIVAL");
  90. player.setFly(player, false);
  91. living.cleareffects(player);
  92. living.setHealth(player, 20);
  93. player.setHunger(player, 20);
  94. player.setSaturation(player, 5);
  95. player.clearInventory(player);
  96. sb.add(player, 99, gamename);
  97. sb.add(player, 98, timer_string);
  98. sb.add(player, 97, "§bFound Items: §r0");
  99. sb.add(player, 96, "§bNext Items:");
  100. sb.add(player, 85, sb.getSpacer());
  101. living.addEffect(player, "SPEED", 19200, 1);
  102. }
  103. event.load("bucket_use");
  104. event.load("living_pickup");
  105. event.load("craft");
  106. farmtypes = list.new();
  107. list.add(farmtypes, material.get("minecraft:carrots"));
  108. list.add(farmtypes, material.get("minecraft:melon_stem"));
  109. list.add(farmtypes, material.get("minecraft:potatoes"));
  110. list.add(farmtypes, material.get("minecraft:wheat"));
  111. player_blocks = set.new();
  112. set.add(player_blocks, material.get("minecraft:crafting_table"));
  113. set.add(player_blocks, material.get("minecraft:furnace"));
  114. set.add(player_blocks, material.get("minecraft:chest"));
  115. saplings = map.new();
  116. map.add(saplings, material.get("oak_leaves"), item.new(material.get("oak_sapling")));
  117. map.add(saplings, material.get("spruce_leaves"), item.new(material.get("spruce_sapling")));
  118. map.add(saplings, material.get("birch_leaves"), item.new(material.get("birch_sapling")));
  119. map.add(saplings, material.get("jungle_leaves"), item.new(material.get("jungle_sapling")));
  120. map.add(saplings, material.get("acacia_leaves"), item.new(material.get("acacia_sapling")));
  121. map.add(saplings, material.get("dark_oak_leaves"), item.new(material.get("dark_oak_sapling")));
  122. nextitems = list.new();
  123. founditems = list.new();
  124. player_blocks_placed = set.new();
  125. resetlist_type = list.new();
  126. resetlist_block = list.new();
  127. resetlist_data = list.new();
  128. resetlist_block_2 = list.new();
  129. resetlistdouble_data = list.new();
  130. resetlistdouble_data_2 = list.new();
  131. resetlistdouble_block = list.new();
  132. resetlistdouble_block2 = list.new();
  133. sgoto(2, "tick");
  134. for(h = 0; h < amount_nextitems; h++) {
  135. gosub("newitem");
  136. }
  137. minigame.speakAll(gamename, "Collect as many shown items as you can.");
  138. minigame.speakAll(gamename, "Drop and collect not counted items again.");
  139. @wait
  140. wait();
  141. if(event == "living_pickup") {
  142. if(!isPlayer(living_entity)) {
  143. goto("wait");
  144. }
  145. player = living_entity;
  146. }
  147. if(event == "entity_damage") {
  148. if(!isPlayer(entity)) {
  149. goto("wait");
  150. }
  151. player = entity;
  152. }
  153. if(player.hasMinigameId(player, script_id)) {
  154. ignoreGoto(event);
  155. }
  156. goto("wait");
  157. @block_click
  158. if(action == "RIGHT_CLICK_BLOCK") {
  159. block_type = block.getType(block);
  160. if(set.contains(player_blocks, block_type)) {
  161. goto("wait");
  162. }
  163. if(slot.isHand(hand)) {
  164. item_type = item.getType(living.getHand(player));
  165. } else {
  166. item_type = item.getType(living.getOffHand(player));
  167. }
  168. if(set.contains(player_blocks, item_type)) {
  169. goto("wait");
  170. }
  171. cancel = true;
  172. if(block_type == pumpkin_mat && item_type == shears_mat) {
  173. block_loc = block.getLocation(block);
  174. item.drop(carved_pumpkin, block_loc);
  175. }
  176. }
  177. goto("wait");
  178. @entity_damage
  179. if(isPlayer(entity)) {
  180. cancel = true;
  181. }
  182. goto("wait");
  183. @block_break
  184. cancel = false;
  185. block_type = block.getType(block);
  186. if(set.contains(player_blocks, block_type)) {
  187. goto("wait");
  188. }
  189. block_loc = block.getLocation(block);
  190. if(block.isLeaves(block)) {
  191. sapling = map.get(saplings, block_type);
  192. item.drop(sapling, block_loc);
  193. }
  194. if(block.isBisected(block)) {
  195. if(block.getBisectedHalf(block) == "BOTTOM") {
  196. b = block;
  197. b2 = block.mod(block, 0, 1, 0);
  198. } else {
  199. b = block.mod(block, 0, -1, 0);
  200. b2 = block;
  201. }
  202. list.add(resetlistdouble_data, block.getData(b));
  203. list.add(resetlistdouble_data_2, block.getData(b2));
  204. list.add(resetlistdouble_block, b);
  205. list.add(resetlistdouble_block2, b2);
  206. sgoto(2, "doubleresetblock");
  207. goto("wait");
  208. }
  209. if(block_type == vine_mat) {
  210. cancel = true;
  211. goto("wait");
  212. }
  213. if(block_type == sugar_cane_mat) {
  214. cancel = true;
  215. item.drop(sugar_cane, block_loc);
  216. goto("wait");
  217. }
  218. if(block_type == farmland_mat) {
  219. cancel = true;
  220. goto("wait");
  221. }
  222. if(list.contains(farmtypes, block_type)) {
  223. list.add(resetlist_data, block.getData(block));
  224. list.add(resetlist_block_2, block);
  225. sgoto(2, "resetblock_data");
  226. } else {
  227. list.add(resetlist_type, block_type);
  228. list.add(resetlist_block, block);
  229. sgoto(2, "resetblock");
  230. }
  231. goto("wait");
  232. @bucket_use
  233. cancel = true;
  234. goto("wait");
  235. @block_place
  236. cancel = true;
  237. block_type = block.getType(block);
  238. if(set.contains(player_blocks, block_type)) {
  239. cancel = false;
  240. set.add(player_blocks_placed, block);
  241. }
  242. goto("wait");
  243. @doubleresetblock
  244. bdata = list.getIndex(resetlistdouble_data, 0);
  245. bdata2 = list.getIndex(resetlistdouble_data_2, 0);
  246. b = list.getIndex(resetlistdouble_block, 0);
  247. b2 = list.getIndex(resetlistdouble_block2, 0);
  248. list.removeIndex(resetlistdouble_data, 0);
  249. list.removeIndex(resetlistdouble_data_2, 0);
  250. list.removeIndex(resetlistdouble_block, 0);
  251. list.removeIndex(resetlistdouble_block2, 0);
  252. block.setData(b, bdata);
  253. block.setData(b2, bdata2);
  254. goto("wait");
  255. @resetblock
  256. btype = list.getIndex(resetlist_type, 0);
  257. b = list.getIndex(resetlist_block, 0);
  258. list.removeIndex(resetlist_type, 0);
  259. list.removeIndex(resetlist_block, 0);
  260. if(list.contains(farmtypes, btype)) {
  261. block.setData(b, read.blockData(string.replace(string.blockData(btype), "age=.", "age=7")));
  262. } else {
  263. block.setMaterial(b, btype);
  264. }
  265. goto("wait");
  266. @resetblock_data
  267. bdata = list.getIndex(resetlist_data, 0);
  268. b = list.getIndex(resetlist_block_2, 0);
  269. list.removeIndex(resetlist_data, 0);
  270. list.removeIndex(resetlist_block_2, 0);
  271. block.setData(b, read.blockData(string.replace(string.blockData(bdata), "age=.", "age=7")));
  272. goto("wait");
  273. @tick
  274. if(sec == 0) {
  275. sec = 59;
  276. min--;
  277. if(min == -1) {
  278. goto("endgame");
  279. }
  280. } else {
  281. sec--;
  282. if(sec < 10) {
  283. minigame.displayAll(98, string.concat("§bTimer: §r", string.number(min), " min 0", string.number(sec), " s"));
  284. } else {
  285. minigame.displayAll(98, string.concat("§bTimer: §r", string.number(min), " min ", string.number(sec), " s"));
  286. }
  287. if(min == 0) {
  288. if(sec == 30) {
  289. minigame.speakAll(gamename, "30 seconds left!");
  290. } elseif(sec == 10) {
  291. minigame.speakAll(gamename, "10 seconds left!");
  292. } elseif(sec == 5) {
  293. minigame.speakAll(gamename, "5 seconds left!");
  294. }
  295. }
  296. }
  297. sgoto(20, "tick");
  298. goto("wait");
  299. @living_pickup
  300. item = item.entity.get(item_entity);
  301. @craft
  302. itype = item.getType(item);
  303. if(list.contains(nextitems, itype)) {
  304. list.add(founditems, itype);
  305. list.remove(nextitems, itype);
  306. minigame.displayAll(97, string.concat("§bFound Items: §r", string.number(list.getSize(founditems))));
  307. gosub("newitem");
  308. }
  309. goto("wait");
  310. @newitem
  311. if(min < 12) {
  312. if(step == 1) {
  313. for(i = 0; i < list.getSize(items2); i++) {
  314. list.add(items1, list.getIndex(items2, i));
  315. }
  316. step = 2;
  317. }
  318. if(min < 8) {
  319. if(step == 2) {
  320. for(i = 0; i < list.getSize(items3); i++) {
  321. list.add(items1, list.getIndex(items3, i));
  322. }
  323. step = 3;
  324. }
  325. if(min < 4) {
  326. if(step == 3) {
  327. for(i = 0; i < list.getSize(items4); i++) {
  328. list.add(items1, list.getIndex(items4, i));
  329. }
  330. step = 4;
  331. }
  332. }
  333. }
  334. }
  335. items1_size = list.getSize(items1);
  336. if(items1_size == 0) {
  337. return;
  338. }
  339. randomitemstring = list.getIndex(items1, math.random(0, items1_size - 1));
  340. list.remove(items1, randomitemstring);
  341. list.add(nextitems, material.get(randomitemstring));
  342. for(i = 0; i < list.getSize(nextitems); i++) {
  343. type_string = string(list.getIndex(nextitems, i));
  344. minigame.displayAll(95 - i, type_string);
  345. }
  346. return;
  347. @player_quit
  348. @player_giveup
  349. script = script.getFromId(script_id);
  350. minigame.kickplayer(script, player);
  351. if(list.getSize(player_list) == 0) {
  352. goto("endcore");
  353. }
  354. goto("wait");
  355. @endgame
  356. yetfound = list.getSize(founditems);
  357. script = script.getFromId(script_id);
  358. iter = iterator(player_list);
  359. while(hasNext(iter)) {
  360. player = player.get(next(iter));
  361. minigame.statsHeader(player, $gamename, "§e");
  362. minigame.statsLine(player, "§e", "Found Items", string.number(yetfound));
  363. }
  364. @endcore
  365. iter = iterator(player_blocks_placed);
  366. air = material.getAir();
  367. while(hasNext(iter)) {
  368. block.setMaterial(next(iter), air);
  369. }
  370. minigame.clearItems(middleloc, radius);
  371. minigame.kickAllPlayers(script);
  372. minigame.term(script, gamesignloc);
  373. term();