Zombie setTargetEntity?

Discussion in 'Plugin Development' started by Komak57, May 7, 2012.

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

    Komak57

    Code:
    package pkg;
     
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.CreatureSpawnEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
     
    @SuppressWarnings("unused")
    public class EntityHandler implements Listener {
        private Main plugin;
        public EntityHandler(Main plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
            this.plugin = plugin;
        }
        @EventHandler
        public void EntitySpawn(CreatureSpawnEvent event) {
            if (plugin.eclipse) {
                LivingEntity Zombie = event.getEntity();
                if (Zombie.getType() == EntityType.ZOMBIE) {
                    // set Zombie's target
                    //Zombie.
                }
            }
        }
    }
    
    Need the command interfaces needed to set a Zombie's target to a player (I'll pick which player later in the coding) and let Bukkit take care of getting there? I could only find a getTargetBlock() function and etcs...

    More specifically, I'm working on a special event plugin and once the event starts, zombies will be summoned, then have a random online-player selected as a target, then let the zombie look for the player (with some bonus effects of course).
     
  2. setTargetEntity() is part of Creature class, you can cast your LivingEntity to Creature, Monster or Zombie (they extend Creature) to access that method.
     
  3. Offline

    DrBowe

    It's also worth noting that there is a range limit to this function, that isn't particularly emphasized in the docs if I recall correctly. For example, setting a zombie's target to a player that is 100 some odd blocks away does not mean the zombie will endure a great exodus to find his one true meal. Just something to keep in mind, regardless of what your intent is.
     
  4. Offline

    Komak57

    Indeed I have read into the difficulties on distance and I've already thought of a solution. Any idea if this ranged limit still happens if the player moves OUT of this so-called range? Let's say for instance that the target is aquired, the zombie starts moving towards target, target moves out of, say, 32 block range. Does the zombie stop tracking and begin scanning for a new target?
     
Thread Status:
Not open for further replies.

Share This Page