skills.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. //Hier werden alle Events abgefangen und beeinflusst, je nachdem ob ein Skill aktiv ist oder nicht
  2. //event.load("projectile_hit");
  3. event.load("living_death");
  4. event.load("block_break");
  5. //event.load("player_data_tick");
  6. event.load("snuvi_click");
  7. event.load("block_click");
  8. prefix_skill = "§2Skill";
  9. scroll_menu_item = customitem.create("SCROLL", 1, "§2Skills", null);
  10. setScriptVar("skills", list.new());
  11. //skill.add(skill_name, tech_name, item, description, cost, permanent, active, toggleable, cooldown, mana, time)
  12. skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 10, false, false, true, 0, 0, null);
  13. skill.add("Comeback", "skill.comeback", "minecraft:respawn_anchor", "Respawn at your death location with /comeback", 15, false, false, false, 0, 0, null);
  14. skill.add("Better_Ladder", "skill.bet_lad", "minecraft:ladder", "Allows to elongate ladders below or above oneself when sneaking", 2048, true, false, true, 0, 0, null);
  15. //skill.add("Head Hunter", "skill.head_human", "minecraft:player_head", "Drops a player's head with a 20% chance if you kill a player (5% if a staff member is killed)", 1000, true, false, false, 0, 0, null);
  16. //skill.add("Mobheads", "skill.head_monster", "minecraft:zombie_head", "Drops a mobs's head with a 20% chance (zombie / skeleton / creeper)", 500, true, false, false, 0, 0, null);
  17. //skill.add("Fly 10min", "skill.fly10min", "minecraft:elytra", "You can fly for 10 minutes", 500, false, true, false, 0, 0, 600);
  18. //skill.add("Grow", "skill.grow", "minecraft:farmland", "Grow seeds in radius 5", 25, false, true, false, 0, 0, null);
  19. //skill.add("Haste", "skill.haste", "minecraft:iron_pickaxe", "Haste for 2 minutes", 25, false, true, false, 0, 0, 120);
  20. //skill.add("Speed", "skill.speed", "minecraft:iron_boots", "Speed for 2 minutes", 25, false, true, false, 0, 0, 120);
  21. //skill.add("Jump Boost", "skill.jump_boost", "minecraft:rabbit_foot", "JumpBoost Lvl.2 for 2 minutes", 25, false, true, false, 0, 0, 120);
  22. //skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolphin for a minute", 25, false, true, false, 0, 0, 60);
  23. //skill.add("Block Up", "skill.block_up", "minecraft:diamond_pickaxe", "Break a block and the block above for a minute", 25, false, true, false, 0, 0, 60);
  24. //skill.add("Block Down", "skill.block_down", "minecraft:diamond_pickaxe", "Break a block and the block below for a minute", 25, false, true, false, 0, 0, 60);
  25. skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe", 4096, true, false, true, 0, 0, null);
  26. //skill.add("Fire Arrow", "skill.fire_arrow", "minecraft:arrow", "For a minute with an flame enchanted bow your arrows ignite hit blocks", 50, false, true, false, 0, 0, 60);
  27. //skill.add("Better Shears", "skill.better_shears", "minecraft:shears", "Sharpness enchanted shears increase the radius for destruction of leaves", 1024, true, false, true, 0, 0, null);
  28. //skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increase the radius for destruction of cobwebs", 250, true, false, true, 0, 0, null);
  29. death_loc_map = map.new();
  30. leaves_tag = block.getTag("minecraft:leaves");
  31. //prop_persistent = block.getProperty("persistent");
  32. air_mat = material.get("AIR");
  33. water_mat = material.get("WATER");
  34. ladder_mat = material.get("LADDER");
  35. msg("dev", text.new("§bSkills §rloaded."));
  36. @wait
  37. wait();
  38. //Wenn Event aus Survival-Welten, dann wird er verarbeitet
  39. if(event == "living_death") {
  40. loc = entity.getLocation(living_entity);
  41. } else {
  42. loc = entity.getLocation(player);
  43. }
  44. world_name = world.getName(loc.getWorld(loc));
  45. if(world.isSurvName(world_name)) {
  46. ignoreGoto(event);
  47. }
  48. goto("wait");
  49. @snuvi_click
  50. item = inv.getItem(inv, inv_slot);
  51. item.removeFlag(item, "HIDE_DESTROYS");
  52. title_string = string.text(inv_title);
  53. if(item == scroll_menu_item) {
  54. if(title_string == "Lumberjack") {
  55. if(!player.unlockedLumberjack(player)) {
  56. msg.prefix(player, prefix_skill, "Skillshop is locked. Do a quest first.");
  57. goto("wait");
  58. }
  59. skill.showShop(player, "skill.timber", "skill.bet_lad", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  60. goto("wait");
  61. }
  62. if(title_string == "Mage") {
  63. if(!player.unlockedMage(player)) {
  64. msg.prefix(player, prefix_skill, "Skillshop is locked. Do the 'Mage' quest at the 'Mage Guard' first.");
  65. goto("wait");
  66. }
  67. skill.showShop(player, "skill.subcu_inv", "skill.comeback", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  68. //skill.showShop(player, "skill.subcu_inv", "skill.comeback", "skill.head_human", "skill.head_monster", "skill.fly10min", "skill.grow", "skill.haste", "skill.speed", "skill.jump_boost", "skill.dolphin", "skill.block_up", "skill.block_down", "skill.fire_arrow", "skill.cobweb_miner", null, null, null, null);
  69. }
  70. goto("wait");
  71. }
  72. if(title_string == "Skillshop") {
  73. if(item == null) {
  74. goto("wait");
  75. }
  76. skill_name = string.removeFormat(string.text(item.getName(item)));
  77. if(skill_name == "") {
  78. goto("wait");
  79. }
  80. tech_name = skill.getTechName(skill_name);
  81. if(skill.isPermanent(tech_name)) {
  82. amount = skill.getAmount(player, tech_name);
  83. if(amount >= 1) {
  84. goto("wait");
  85. }
  86. }
  87. cost = skill.getCost(tech_name);
  88. if(!hasEnoughMoney(player, cost)) {
  89. msg.prefix(player, prefix_skill, "Not enough snuvis.");
  90. goto("wait");
  91. }
  92. money.sub(player, cost);
  93. skill.addAmount(player, tech_name, 1);
  94. inv.setItem(inv, inv_slot, skill.getShopItem(player, tech_name));
  95. }
  96. goto("wait");
  97. @player_data_tick
  98. if(var == "fly") {
  99. tpBottom(player);
  100. player.setFly(player, false);
  101. msg.prefix(player, prefix_skill, "Fly time is over.");
  102. }
  103. goto("wait");
  104. @projectile_hit
  105. if(!isPlayer(shooter)) {
  106. goto("wait");
  107. }
  108. player = shooter;
  109. duration = data.getTimer(player, "skill.fire_arrow");
  110. if(duration > 0) {
  111. if(loc_hit == null) {
  112. goto("wait");
  113. }
  114. flame = enchantment.getLevel(ench_flame, living.getHand(player));
  115. if(flame <= 0) {
  116. goto("wait");
  117. }
  118. if(!plot.check(loc_hit, player, 3, true) && !perm.has(player, "plot.bypass")) {
  119. msg.prefix(player, prefix_skill, "You have no permissions on this plot.");
  120. goto("wait");
  121. }
  122. ent_loc = entity.getLocation(projectile);
  123. if(block.isAir(ent_loc)){
  124. block.set(ent_loc, "minecraft:fire");
  125. }
  126. fire_ring(ent_loc, "minecraft:fire", 0);
  127. }
  128. goto("wait");
  129. @living_death
  130. if(isPlayer(living_entity)) {
  131. player = living_entity;
  132. loc = entity.getLocation(player);
  133. amount = skill.getAmount(player, "skill.subcu_inv");
  134. if(skill.isActivated(player, "skill.subcu_inv") && amount > 0) {
  135. new_amount = amount - 1;
  136. skill.setAmount(player, "skill.subcu_inv", new_amount);
  137. msg.prefix(player, prefix_skill, string.concat("Used Subcutaneous Inventory. New amount: ", string.number(new_amount)));
  138. } else {
  139. player.dropInventory(player, loc);
  140. }
  141. killer = player.getFromDamageSource(damage_source);
  142. if(isPlayer(killer)) {
  143. amount = skill.getAmount(player, "skill.head_human");
  144. if(amount >= 1) {
  145. if(perm.has(player, "isTeam")) {
  146. temp = math.random(1, 20);
  147. } else {
  148. temp = math.random(1, 5);
  149. }
  150. if(temp == 1) {
  151. item.drop(loc, player.getHead(player.getUuid(player), player.getName(player)));
  152. }
  153. }
  154. }
  155. goto("wait");
  156. }
  157. killer = player.getFromDamageSource(damage_source);
  158. if(isPlayer(killer)) {
  159. r = math.random(1, 20);
  160. if(r == 1) {
  161. amount = skill.getAmount(killer, "skill.head_monster");
  162. if(amount >= 1) {
  163. entity_type = entity.getType(living_entity);
  164. if(entity_type == "creeper") {
  165. item.drop(loc, read.item("minecraft:creeper_head"));
  166. goto("wait");
  167. }
  168. if(entity_type == "zombie") {
  169. item.drop(loc, read.item("minecraft:zombie_head"));
  170. goto("wait");
  171. }
  172. if(entity_type == "skeleton") {
  173. item.drop(loc, read.item("minecraft:skeleton_skull"));
  174. goto("wait");
  175. }
  176. }
  177. }
  178. }
  179. goto("wait");
  180. @block_break
  181. goto("wait");
  182. duration = data.getTimer(player, "block_down");
  183. if(duration > 0) {
  184. do = true;
  185. loc = loc.mod(block_loc, 0, -1, 0);
  186. b_type = block.getType(loc);
  187. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  188. do = false;
  189. }
  190. if(!plot.check(loc, player, 2, true)) {
  191. do = false;
  192. }
  193. if(do) {
  194. block.break(loc, player);
  195. }
  196. }
  197. duration = data.getTimer(player, "block_up");
  198. if(duration > 0) {
  199. do = true;
  200. loc = loc.mod(block_loc, 0, 1, 0);
  201. b_type = block.getType(loc);
  202. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  203. do = false;
  204. }
  205. if(!plot.check(loc, player, 2, true)) {
  206. do = false;
  207. }
  208. if(do) {
  209. block.break(loc, player);
  210. }
  211. }
  212. if(block_type == "minecraft:cobweb") {
  213. if(cancel) {
  214. goto("wait");
  215. }
  216. hand_item = living.getHand(player);
  217. if(!item.hasTag(hand_item, sword_tag)) { //TODO sword_tag (km:sword) no longer exists
  218. goto("wait");
  219. }
  220. amount = skill.getAmount(player, "skill.cobweb_miner");
  221. if(amount <= 0) {
  222. goto("wait");
  223. }
  224. if(!skill.isActivated(player, "skill.cobweb_miner")) {
  225. goto("wait");
  226. }
  227. location = loc.mod(block_loc, 0, 0, 0);
  228. cobweb_X = loc.getX(location);
  229. cobweb_Y = loc.getY(location);
  230. cobweb_Z = loc.getZ(location);
  231. cobweb_radius = 1;
  232. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  233. for(a = -cobweb_radius; a < cobweb_radius + 1; a++) {
  234. loc.setX(location, cobweb_X + a);
  235. for(b = -cobweb_radius; b < cobweb_radius + 1; b++) {
  236. loc.setY(location, cobweb_Y + b);
  237. for(c = -cobweb_radius; c < cobweb_radius + 1; c++) {
  238. loc.setZ(location, cobweb_Z + c);
  239. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < cobweb_radius + 2) {
  240. shear_cobweb(location, block_type, player, unbreaking_level);
  241. }
  242. }
  243. }
  244. }
  245. goto("wait");
  246. }
  247. if(block.isLeaves(block)) {
  248. if(cancel) {
  249. goto("wait");
  250. }
  251. hand_item = living.getHand(player);
  252. if(item.getType(hand_item) != "minecraft:shears") {
  253. goto("wait");
  254. }
  255. if(block.property.getValue(block_loc, prop_persistent)){
  256. goto("wait");
  257. }
  258. amount = skill.getAmount(player, "skill.better_shears");
  259. if(amount <= 0) {
  260. goto("wait");
  261. }
  262. if(!skill.isActivated(player, "skill.better_shears")) {
  263. goto("wait");
  264. }
  265. location = loc.mod(block_loc, 0, 0, 0);
  266. shears_X = loc.getX(location);
  267. shears_Y = loc.getY(location);
  268. shears_Z = loc.getZ(location);
  269. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  270. radius = enchantment.getLevel(ench_sharpness, hand_item);
  271. if(radius > 0) {
  272. cancel = true;
  273. }
  274. orig_item = block.toStack(location);
  275. for(a = -radius; a < radius + 1; a++){
  276. loc.setX(location, shears_X + a);
  277. for(b = -radius; b < radius + 1; b++){
  278. loc.setY(location, shears_Y + b);
  279. for(c = -radius; c < radius + 1; c++){
  280. loc.setZ(location, shears_Z + c);
  281. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < radius + 2) {
  282. shear_leave(location, block_type, orig_item, player, unbreaking_level);
  283. }
  284. }
  285. }
  286. }
  287. goto("wait");
  288. }
  289. goto("wait");
  290. @block_click
  291. if(skill.isActivated(player, "skill.bet_lad")){
  292. if (!player.isSneaking(player)){
  293. goto("wait");
  294. }
  295. if (action != "RIGHT_CLICK_BLOCK"){
  296. goto("wait");
  297. }
  298. mat = block.getType(block);
  299. item_mat = item.getType(living.getEquip(player, hand));
  300. if (mat != air_mat){
  301. if(item_mat != mat){
  302. goto("wait");
  303. }
  304. }
  305. look = entity.getLook(player);
  306. if(mat == ladder_mat){
  307. xyz = better_ladder.vertical_split(look);
  308. }
  309. elseif(false){//elseif(mat == chain_mat){
  310. if (!string.contains(string.blockData(block.getData(block)), "axis=y")){
  311. goto("wait");
  312. }
  313. //xyz = vertical_split(look);
  314. xyz = array.new(3);
  315. xyz[0] = 0;
  316. xyz[1] = -1;
  317. xyz[2] = 0;
  318. }
  319. elseif(false){//elseif(mat == rail_mat){
  320. xyz = better_ladder.horizontal_split(player);
  321. }
  322. elseif(false){//elseif(mat == vines_mat){
  323. xyz = array.new(3);
  324. xyz[0] = 0;
  325. xyz[1] = -1;
  326. xyz[2] = 0;
  327. }
  328. else{
  329. goto("wait");
  330. }
  331. better_ladder.continue_block(player, block, mat, xyz);
  332. cancel = true;
  333. }
  334. goto("wait");
  335. function shear_leave(block_loc, original_block_type, original_item, player, unbreaking_level){
  336. if(block.getType(block_loc) != original_block_type) {
  337. return;
  338. }
  339. if(block.property.getValue(block_loc, $prop_persistent)) {
  340. return;
  341. }
  342. block.set(block_loc, "minecraft:air");
  343. item.drop(block_loc, original_item);
  344. if(player.isSurvival(player)) {
  345. player.damageItem(player, 1);
  346. }
  347. }
  348. function shear_cobweb(block_loc, original_block_type, player, unbreaking_level) {
  349. if(block.getType(block_loc) != original_block_type) {
  350. return;
  351. }
  352. block.break(block_loc, player);
  353. if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
  354. player.damageItem(player, 1);
  355. }
  356. }
  357. function better_ladder.vertical_split(look){
  358. xyz = array.new(3);
  359. for (i = 0; i<3; i++){
  360. xyz[i] = 0;
  361. }
  362. if (look[1] > 0){
  363. xyz[1] = 1;
  364. }
  365. else{
  366. xyz[1] = -1;
  367. }
  368. return xyz;
  369. }
  370. function better_ladder.horizontal_split(player){
  371. xyz = array.new(3);
  372. for (i = 0; i<3; i++){
  373. xyz[i] = 0;
  374. }
  375. loc = entity.getLocation(player);
  376. yaw = loc.getYaw(loc);
  377. if (yaw < -135){
  378. xyz[2] = -1;
  379. }
  380. elseif (yaw < -45){
  381. xyz[0] = 1;
  382. }
  383. elseif (yaw < 45){
  384. xyz[2] = 1;
  385. }
  386. elseif (yaw < 135){
  387. xyz[0] = -1;
  388. }
  389. else{
  390. xyz[2] = -1;
  391. }
  392. return xyz;
  393. }
  394. function better_ladder.continue_block(player, block, of_mat, xyz){
  395. itemstack = item.new(of_mat, 1);
  396. b_loc = block.getLocation(block);
  397. set_water_logged = false;
  398. i = 0;
  399. while(true){
  400. loc.add(b_loc, xyz[0], xyz[1], xyz[2]);
  401. new_block = block.get(b_loc);
  402. if (!plot.check(b_loc, player, 23, true) || i >= 5){
  403. return;
  404. }
  405. mat = block.getType(new_block);
  406. if(mat == $air_mat){
  407. break;
  408. }
  409. elseif(mat == $water_mat){
  410. msg.dev(block.getData(new_block));
  411. if (string.contains(string.blockData(block.getData(new_block)), "falling=true")){
  412. break;
  413. }
  414. elseif(!string.contains(string.blockData(block.getData(new_block)), "level=0")){
  415. break;
  416. }
  417. elseif (block.canHaveWater(block)){
  418. set_water_logged = true;
  419. break;
  420. }
  421. else{
  422. return;
  423. }
  424. }
  425. elseif (mat != of_mat){
  426. return;
  427. }
  428. i += 1;
  429. }
  430. block.clone(block, b_loc, true);
  431. if (block.canHaveWater(block)){
  432. block.setWaterLogged(new_block, set_water_logged);
  433. }
  434. if (player.isSurvival(player)){
  435. player.removeItem(player, itemstack);
  436. }
  437. }