Zombie Waves!!!

Discussion in 'Plugin Development' started by slater96, Jun 17, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    slater96

    Hi, I'm trying to get it so around the spawn point, say like a radius of 20 max away from that point (configurable), waves of zombies will spawn every minute for example (also configurable). I've started it, but not sure how to do the radius bit. I've used this before in another plugin I have for a player but don't know how to implement it into my code.
    Code:
    double radius = getConfig().getInt("Radius");
                    Location spawn = Bukkit.getServer().getWorld(getConfig().getString("World")).getSpawnLocation().add((2*Math.random() - 1)*radius, 0.0, (2*Math.random() - 1)*radius);
                    player.teleport(spawn);
    Also, is it possible to make the zombies increase by say 5 each time every x minutes.
    Thanks, here's the code I have up to now.
    Code:
        @EventHandler
        public void onZombieSpawn(CreatureSpawnEvent event) {
            final Player p = (Player) event.getEntity();
            if (plugin.Zombies.contains(p)) {
                long zombiespawn = plugin.getConfig().getLong("ZombieSpawn_Delay");
                plugin.getConfig().getString("Spawn_Zombies");
                String[] spawnzombies = plugin.getConfig().getString("Spawn_Zombies.Loc").split(",");
                double x = Double.parseDouble(spawnzombies[0]);
                double y = Double.parseDouble(spawnzombies[1]);
                double z = Double.parseDouble(spawnzombies[2]);
                String newWorld = plugin.getConfig().getString("Spawn_Zombies.World");
                final Location zombies = new Location(p.getServer().getWorld(newWorld), x, y, z);
                zombies.setPitch(p.getLocation().getPitch());
                zombies.setYaw(p.getLocation().getYaw());
                zombies.add(0.5, 0, 0.5);
                p.teleport(zombies);
                plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
                    public void run() {
                        p.getWorld().spawnCreature(zombies, EntityType.ZOMBIE);                 
                    }
                }, 0L, zombiespawn*20*60);
            }
        }
    }
     
  2. so you need 1 point thats is inside the radius from the player?
    I would do this:
    Code:java
    1. int x = playerX +((random.nextBoolean() ?-1:1)*random.nextInt(radius));
    2. int y = playerY +((random.nextBoolean() ?-1:1)*random.nextInt(radius));
    3. int z = playerZ +((random.nextBoolean() ?-1:1)*random.nextInt(radius));[syntax][/syntax]
     
  3. Offline

    slater96

     
  4. I think you forgot the text?
    EDIT, huh, now I see it?
    EDIT 2:http://dev.bukkit.org/paste/5587/
     
    slater96 likes this.
  5. Offline

    slater96

    Ok, thanks, do you know how to do the bukkit scheduler to add more zombies each time. Mine just does one atm:(

    Sorry added it in the quote :eek:
     
Thread Status:
Not open for further replies.

Share This Page