Bat Swarm help

Discussion in 'Plugin Development' started by glasseater, Sep 18, 2015.

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

    glasseater

    Hey guys.

    I am trying to make an ability for a kitpvp server. The ability is when they right click a piece of call, it swarms bats to the nearest entity, then removes them after 8 seconds. However, I cannot get two things to work. I can't get the going to the nearest entity, nor the removal part. This is what I use to spawn the bats.

    Code:
             Location bat2l = new Location(p.getWorld(), p.getLocation().getX() - 1.0D, p.getLocation().getY(), p.getLocation().getZ());
    
                    IntStream.range(0, 15).forEach(i -> {
                        Bat bat = (Bat) Bukkit.getWorld(p.getWorld().getName()).spawnEntity(bat2l, EntityType.BAT);
                        batIds.add(bat.getEntityId());
    
    
                    });
                }
            }
        }
    }
    If anyone knows how to accomplish these things there help would be greatly appreciated :D
     
  2. Offline

    Zombie_Striker

    @glasseater
    1. Create a Hashmap, where the key is a UUID (The player's/ entities UUID) and the value will be an Array of bats (all the bats that get spawned)
    2. Create an Arraylist for Bats (separate from the one above. This will store all the bats that should cause damage)
    3. When the bats are spawned, set their target destination to be that of where the entity is and add them to an Array (that way you can store all them in one collection)
    4. Make a delayed task that after ____ seconds, it takes the Players/entities UUID and finds the array of bats, loops through it, and remove the bats.
    5. Make the bats have some sort of metadata tag that such as "AttackBats.Target" or "AttackBats.Spawner" tos tore the entity that should/ should not be damaged
    6. Create a repeating task that loops through all the bats in the arraylist (#2) and check the nearest entities, and check whether of not they should damage those entities.
     
    Mr01Luki likes this.
  3. Offline

    glasseater

    @Zombie_Striker
    How would it get the nearest player though? Thats what I am not understanding I know I can set the target of the entities but it just targets me.
     
  4. Offline

    Zombie_Striker

    @glasseater
    Entity ent : Player.getNearestEntities(Distance,Distance,Distance);
    if(ent Instanceof Player && ent != Player )
     
Thread Status:
Not open for further replies.

Share This Page