123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- event.load("player_move");
- event.load("living_death");
- event.load("entity_join");
- x1 = 1000;
- y1 = 0;
- z1 = 1000;
- x2 = 1153;
- y2 = 56;
- z2 = 1129;
- overworld = world.getOverworld();
- loc1 = loc.new(overworld, x1, y1, z1);
- loc2 = loc.new(overworld, x2, y2, z2);
- cooldown = 400; //3 exe per minute
- arena_id = event.addMoveData(loc1, loc2, cooldown, -1);
- spawns = list.new();
- list.add(spawns, loc.new(overworld, 1030, 20, 1039));
- list.add(spawns, loc.new(overworld, 1051, 28, 1083));
- list.add(spawns, loc.new(overworld, 1008, 23, 1092));
- list.add(spawns, loc.new(overworld, 1082, 25, 1118));
- list.add(spawns, loc.new(overworld, 1087, 21, 1050));
- list.add(spawns, loc.new(overworld, 1072, 23, 1021));
- list.add(spawns, loc.new(overworld, 1135, 21, 1071));
- list.add(spawns, loc.new(overworld, 1125, 21, 1088));
- bosses = list.new();
- list.add(bosses, "zombie");
- list.add(bosses, "spider");
- list.add(bosses, "cave_spider");
- list.add(bosses, "wither_skeleton");
- list.add(bosses, "rabbit");
- list.add(bosses, "magma_cube");
- entities_list = list.new();
- iron_sword = read.item("minecraft:iron_sword");
- copper_coin = read.item("km:coin_copper");
- silver_coin = read.item("km:coin_silver");
- ruby = item.getRuby();
- msg("dev", "§bMobarena §rloaded.");
- @main
- wait();
- if(event == "player_move") {
- if(id == arena_id) {
- spawnArenaMob();
- }
- goto("main");
- }
- if(event == "living_death") {
- player = player.getFromDamageSource(damage_source);
- if(player == null) {
- goto("main");
- }
- ent_loc = entity.getLocation(living_entity);
- world_name = world.getName(loc.getWorld(ent_loc));
- if(world_name != "overworld") {
- goto("main");
- }
- x = loc.getX(ent_loc);
- z = loc.getZ(ent_loc);
- if(x < x1 || x > x2) {
- goto("main");
- }
- if(z < z1 || z > z2) {
- goto("main");
- }
- r = math.random(1, 200);
- if(r == 1) {
- item.drop(ent_loc, ruby);
- }
- if(entity.hasTag(living_entity, "mod_spawned")) {
- item.drop(ent_loc, silver_coin);
- } else {
- item.drop(ent_loc, copper_coin);
- }
- goto("main");
- }
- if(event == "entity_join") {
- if(!isLiving(entity)) {
- goto("main");
- }
- entity_type = entity.getType(entity);
- if(entity_type != "creeper") {
- goto("main");
- }
- ent_loc = entity.getLocation(entity);
- world_name = world.getName(loc.getWorld(ent_loc));
- if(world_name != "overworld") {
- goto("main");
- }
- x = loc.getX(ent_loc);
- y = loc.getY(ent_loc);
- z = loc.getZ(ent_loc);
- if(x < x1 || x > x2) {
- goto("main");
- }
- if(y < y1 || y > y2) {
- goto("main");
- }
- if(z < z1 || z > z2) {
- goto("main");
- }
- cancel = true;
- goto("main");
- }
- goto("main");
- function spawnArenaMob() {
- loc = getRandomLoc();
- boss = getRandomBoss();
- if(boss == "rabbit") {
- entity = entity.spawn(boss, loc, "{RabbitType:99}");
- } else {
- entity = entity.spawn(boss, loc);
- }
- if(boss == "zombie") {
- living.setPersistentMaxHealth(entity, 200);
- living.setHealth(entity, 200);
- living.setPersistentAttackDamage(entity, 10);
- living.setEquip(entity, "hand", $iron_sword);
- living.setPersistentKnockbackResistance(entity, 3);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 10);
- }
- elseif(boss == "wither_skeleton") {
- living.setPersistentMaxHealth(entity, 250);
- living.setHealth(entity, 250);
- living.setPersistentAttackDamage(entity, 15);
- living.setEquip(entity, "hand", $iron_sword);
- living.setPersistentKnockbackResistance(entity, 3);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 10);
- }
- elseif(boss == "spider") {
- living.setPersistentMaxHealth(entity, 150);
- living.setHealth(entity, 150);
- living.setPersistentAttackDamage(entity, 8);
- living.setPersistentKnockbackResistance(entity, 2);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 5);
- }
- elseif(boss == "cave_spider") {
- living.setPersistentMaxHealth(entity, 100);
- living.setHealth(entity, 100);
- living.setPersistentAttackDamage(entity, 7);
- living.setPersistentKnockbackResistance(entity, 2);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 5);
- }
- elseif(boss == "rabbit") {
- living.setPersistentMaxHealth(entity, 50);
- living.setHealth(entity, 50);
- living.setPersistentAttackDamage(entity, 6);
- living.setPersistentKnockbackResistance(entity, 2);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 5);
- }
- elseif(boss == "magma_cube") {
- living.setPersistentMaxHealth(entity, 50);
- living.setHealth(entity, 50);
- living.setPersistentAttackDamage(entity, 6);
- living.setPersistentKnockbackResistance(entity, 2);
- living.setPersistentFollowRange(entity, 50);
- living.setPersistentAttackKnockback(entity, 5);
- }
- list.add($entities_list, entity);
- sgoto(2, "sgoto_updateEntityName");
- //living.setEquip(entity, );
- //living.setMaxHealth(entity, );
- //living.setAttackKnockback(entity, );
- //living.setAttackDamage(entity, );
- //living.setAttackSpeed(entity, );
- //living.setFollowRange(entity, );
- //living.setArmor(entity, );
- //living.setArmorThoughness(entity, );
- //living.setMovementSpeed(entity, );
- //living.setKnockbackResistance(entity, );
- }
- @sgoto_updateEntityName
- iter = list.iterator(entities_list);
- while(hasNext(iter)) {
- updateEntityName(next(iter));
- }
- list.clear(entities_list);
- goto("main");
- function getRandomLoc() {
- index = math.random(0, list.getSize($spawns) - 1);
- return list.getIndex($spawns, index);
- }
- function getRandomBoss() {
- index = math.random(0, list.getSize($bosses) - 1);
- return list.getIndex($bosses, index);
- }
- function updateEntityName(living_entity) {
- entity_name = entity.getName(living_entity);
- max_health = living.getMaxHealth(living_entity);
- health = text.number(math.round(living.getHealth(living_entity)));
- max_health = text.number(math.roundComma(max_health, 1));
-
- heart_index = text.indexOf(entity_name, "❤", 0);
- if(heart_index == -1) {
- //Kein Herz gefunden
- setEntityName(living_entity, health, max_health, entity_name);
- return;
- }
-
- next_new_line = text.indexOf(entity_name, "\n", heart_index);
- if(next_new_line == -1) {
- //Rechts vom Herz keine New-Line gefunden
- setEntityName(living_entity, health, max_health, null);
- return;
- }
- entity_name = text.subString(entity_name, next_new_line + 1, text.length(entity_name));
- setEntityName(living_entity, health, max_health, entity_name);
- }
- function setEntityName(living_entity, health, max_health, entity_name) {
- if(entity_name == null) {
- entity.setName(living_entity, concat(health, "/", max_health, " §c❤"), false);
- return;
- }
- entity.setName(living_entity, concat(health, "/", max_health, " §c❤\n", entity_name), false);
- }
|