This has been grinding my gears for months...

Discussion in 'Plugin Development' started by DrMedia, Dec 14, 2013.

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

    DrMedia

    Hi there, as some of you may be aware, I started work on an advanced killstreak system that implements Attack Dogs (http://dev.bukkit.org/bukkit-plugins/attack-dogs/). The only problem that I currently have is that I have been spending days and weeks trying to figure out how to make a dog attack another players. I have tried so many things I have nearly cried.

    Anyway, my goal of this is so the dogs that are spawned attack nearby players and despawn after 30 seconds. Only thing is, the dogs don't attack any players at all. Any help would be greatly appreciated :)

    Here's my code..
    PHP:
    private void summonDogs(Player player){
            
    Location loc = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
            List<
    Player> list = new ArrayList<Player>();
            for (
    Player p Bukkit.getOnlinePlayers()) {
                if (
    p.getLocation().distance(loc) < 20 && p!=player) {
                    list.
    add(p);
                }
            }   
            for(
    Player pl: list){
                if(
    pl instanceof Player){
                    final 
    Wolf dog = (Wolf)player.getLocation().getWorld().spawnEntity(locEntityType.WOLF);
                    
    dog.setTamed(true);
                    
    dog.setOwner(player);
                    
    dog.setCollarColor(DyeColor.GREEN);
                    
    dog.setCustomName(player.getName() + "'s Attack Dog");
                    for(
    Player p Bukkit.getServer().getOnlinePlayers()) dog.damage(1p);
                    
    dog.setVelocity(new Vector());
                    
    dog.setFallDistance(0);
                    
    dog.setHealth(10);
                    
    dog.setBreed(false);
                    new 
    BukkitRunnable()
                    {
                        @
    Override
                        
    public void run() {
                            
    dog.remove();
                            
    this.cancel();
                        }
                    }.
    runTaskTimer(this600L0L);
                }
            }
            if (list.
    isEmpty()) {
                
    player.sendMessage(ChatColor.RED "No nearby players. Attack dogs have retreated!");
            }   
        }
    chasechocolate
    Thought I would tahg you ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Offline

    Jozeth

  3. Offline

    DrMedia

    Jozeth
    Already tried that; no success.
     
  4. Offline

    slayr288

    DrMedia

    Try looking at the Mob Arena source code, I remember that plugin spawning wolves and attacking NPC's. Might be a simple change from that.
     
  5. Offline

    DrMedia

    Wolves don't attack players on spawn in mob arena; they have to hit them.
     
Thread Status:
Not open for further replies.

Share This Page