League of Legends Towers

Discussion in 'Spigot Plugin Development' started by DasDarki, May 29, 2016.

  1. I want to make Lol Towers that makes 5 Hearts damage when you come in the radius of 7 Blocks but i want it so that you can spawn a tower from a schematic. Maybe i can spawn a armorstand in the middle of the tower that testfor players and shoot something?!
  2. You could try something like this:
    Code (Text):

    int radius = 5;
    for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
       if (!(entity instanceof Block)) {
       } else {
          ArmorStand stand = (ArmorStand) entity;
          if (!(stand.isVisible()) && (stand.isCustomNameVisible())) {
             //Your code
    I havent tested this so far, so i dont know if this works. Im using it in my plugin, to test, if a player is in range of an ArmorStand.
  3. There are a few options here.

    1. Use a BukkitRunnable, check for nearby players every X tick(s), and damage them.

    2. Place Guardian's with a special name or metadata in the towers, and let them attack the players. Listen for EntityDamageByEntityEvent, check if they were attacked by the guardians, if so set the damage.

    3. Use the PlayerMoveEvent, check if they are near a tower, if so damage them. (Down side to this is that they won't get damaged when they are standing still, so not recommended!)
    • Agree Agree x 1
  4. Can I change the damage and the cooldown of the Guardian
  5. The cooldown probably requires some NMS.
    You can alter the damage in an event.
  6. Hmmm....-.-...NMS I hate it. Ok, not so bad. How can I do it with NMS?
  7. I don't know, I'm not good with NMS. I suggest looking at the methods, maybe pathfinder goals.
  8. yeah ok....I will try it on my own
  9. Blocks aren't entities.
    You could most likely store your own cooldowns, and cancel the EntityDamageEntityEvents and EntityTargetEvents accordingly.
    • Agree Agree x 1
  10. I think he means the fire time of the guardian.
  11. Code (Text):
        if damager is a guardian:
               add guardian to a cooldown
               set target to null

       if entity is a guardian:
           if guardian is on cooldown:
                set target to null
  12. It takes quite some time before the guardian's beam deals damage. The guardian also already has a cooldown by himself. What if he doesn't want a cooldown?
  13. The time between each guardian hit can be timed and returned, and with a little bit of work you can make an all version compatible plugin. If he doesn't want cooldowns (which he said a few posts above that he did want them), he can have fun poking around the NMS class for the guardian for every version. That's his call, I was just trying to offer an NMS-free version, less hassle. I've been working with a lot of NMS lately for my employer, and it's not something that's too enjoyable after searching through the obfuscated blob of fields in every class from one package.
  14. Hint: if you are trying to use nms, have a look at the int field "b" in "EntityGuardian#PathfinderGoalGuardianAttack". It handles the ticks and so the cooldown when the guardian attacks.
    Edit: by default it has a 10 ticks of warmup and 60 ticks of cooldown if elder and 80 ticks if not.
    #14 Grimerlin, May 30, 2016
    Last edited: May 30, 2016
  15. Ok now I looked into NMS.
    Well, where can I find this packet?! I cant find it in this wiki: http://wiki.vg/Protocol
  16. It's not a packet and you can't find it anywhere but decompiling the spigot.jar file and looking for the class I above mentioned in the net.minecraft.server package
    If you don't know what nms is or never done anything like that before I suggest you to find another way as @Msrules123 suggested.