NpcSpawner lib - spawn basic NPCs

Discussion in 'Resources' started by Redecouverte, Feb 3, 2011.

  1. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @Duckdoom5 Yeeeaaahhhhh, you made my day :) Thank you soo much :)
  2. Offline

    Philipp15b

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Is there a Maven repo so that I can include it?
  3. Offline

    okami35

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hello, i have a little problem,
    How do you do to import your lib?
    Because i have downloaded the sources on github but when i import it in eclipse, i have many errors, do you have any ideas?

    Thank you for your help
  4. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @okami35 and all others who do not understand how to import

    1. Get the "com" folder out of the others, only the "com" folder is needed.
    2. Open Eclipse and drag the "com" folder into your "scr" folder.
    3. If you do not want to use Spout, comment the Spout import and the Spout-part in the HumanNPC.java
    4. It should work now :)
  5. Offline

    okami35

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thank you for your help, i have tried but it does not work, i have some errors

    maybe i must add a special external jar? (actually i juste have craftbukkit.jar)

    This post has been edited 1 time. It was last edited by okami35 Feb 24, 2012.
  6. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    No you must not add an external jar, hm, I do not understand why you have some errors... I cannot help you, sorry :(
  7. Offline

    okami35

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    For example i have an error on the type "Entity"...

    Thank you
  8. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You must have Bukkit and CraftBukkit
  9. Offline

    Philipp15b

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Is there also a possibility to require it with Maven? So it updates automatically and I can include it with Maven Shade?

    This post has been edited 2 times. It was last edited by Philipp15b May 5, 2012.
  10. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I have a problem with my code, please help! I am using the original code from Redecouverte for the EntityTargetEvent with CLOSEST_PLAYER, I added only a system.out.println(), but if I go close to my NPC, the message is coming once and if I come close again there is no message! It only comes once, never twice :( How could I fix that?
  11. Offline

    cheddar262

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Currently it seems there is an error with your reference to j.am() in the NPCManager, your createExplosion events in BWorld, and a(Packet packet) and a(Packet101CloseWindow packet101closewindow) in NPCNetHandler. Just thought I would point it out even though you probably know about it.
  12. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Yes, you are right, could anybody fix that please? Maybe @Top_Cat ?

    This post has been edited 1 time. It was last edited by Luloak2 Mar 9, 2012.
  13. Online

    Lolmewn BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    He never does until an RB comes out for some reason..
  14. Offline

    heisan213

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Wait... How do I download this? It isn't @ Github D:
  15. Offline

    Top_Cat

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Nah I'll update before RB just not pre-releases (which this isn't), I just have other things I've been busy with, should get this done soon.

    You download the source, it's a lib not a plugin
  16. Offline

    heisan213

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Haha, Im not an idiot :p I can't find it!
  17. Offline

    cheddar262

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  18. Offline

    Knuckles5577

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    How do I... download this? ( it has no download link) also, I'm new to plugins... so..
  19. Offline

    Top_Cat

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Click the link in the POST ABOVE YOURS then click downloads

    Also this is NOT a plugin
  20. Offline

    BloodShura

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    How to verify if a Entity (from e.getEntity() in a Listener) is a HumanNPC?

    Thanks.
  21. Offline

    Top_Cat

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    manager.isNPC(aBukkitEntity)
  22. Offline

    BloodShura

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Oh sorry, I writed wrong my question.

    I need to cast a entity or NPC, to HumanNPC.

    My code:
    Code:
        Player player = e.getPlayer();
        Entity ent = e.getRightClicked();
        NPCManager manager = new NPCManager(ShuraCore.plugin);
     
        if (manager.isNPC(ent)) {
          if (ShuraCore.plugin.lpCheck(player, "ShuraNPC.manager")) {
            if (player.isSneaking()) {
              NPC npc = manager.getNPC(manager.getNPCIdFromEntity(ent));
     
              Vars.NPCs.remove(player);
              Vars.NPCs.put(player, npc);
            }
          }
        }
    I need to cast the 'npc' to a HumanNPC. Is there a way to do it?

    Thanks.
  23. Offline

    ZNickq

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ((HumanNPC) npc)
    BloodShura likes this.
  24. Offline

    BloodShura

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  25. Offline

    Luloak2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    With the last Dev-Build, it is not working anymore, change this in the NPCManager.java to get it work:
    Code:
    public NPCManager(JavaPlugin plugin) {
            server = BServer.getInstance();
     
            npcNetworkManager = new NPCNetworkManager();
            NPCManager.plugin = plugin;
            taskid = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                @Override
                public void run() {
                    HashSet<String> toRemove = new HashSet<String>();
                    for (String i : npcs.keySet()) {
                        Entity j = npcs.get(i).getEntity();
                        j.aA();
                        if (j.dead) {
                            toRemove.add(i);
                        }
                    }
                    for (String n : toRemove) {
                        npcs.remove(n);
                    }
                }
            }, 1L, 1L);
            Bukkit.getServer().getPluginManager().registerEvents(new SL(), plugin);
            Bukkit.getServer().getPluginManager().registerEvents(new WL(), plugin);
        }
    The j.az(); in the old NPCManager.java is not working anymore, so it must be replaced with j.aA();


    @Top_Cat Maybe you could update it ;)

    This post has been edited 1 time. It was last edited by Luloak2 Mar 23, 2012.
  26. Offline

    kumpelblase2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm using this lib since about two days or so and most of the things do work and do work really well. There are still some things that I have a problem with:
    1) Setting the yaw does only rotate the body, not the head. Though changing the pitch does rotate it (up and down ofc.). See PR.
    2) (This might be spout related) I tried lots of things but nothing worked to set the skin. Neither getting the npc as a spout player nor setting it through a real player. Does somebody might have an idea?

    This post has been edited 2 times. It was last edited by kumpelblase2 Apr 4, 2012.
  27. Offline

    Trc202

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Pretty sure only spout clients can see the skin changes. The skins for a player are retrieved by the client.
  28. Offline

    kumpelblase2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I think I tested it with both, normal and spoutcraft, clients and neither worked. I'm gonna test the experimental builds for 1.2.5 from spout though.

    However, I have a new issue. NPC_BOUNCED does not get triggered at all. Maybe it isn't c() anymore?
  29. Offline

    Sir Savary

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    How can I get an NPC to attack an entity?
  30. Offline

    kumpelblase2

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You were correct, but it took me some time figuring out which method you need to use to get the skin right. It's not working for me using the code of post #336 because I don't have a player all the time. So using this code should do it:
    Code:
    SpoutPlayer sp = <HumanNPC>.getSpoutPlayer();
    sp.setSkin(url);
    Moreover I've a solution/workaround for the NPC_BOUNCED event, which is not working for me, because it doesn't get called. To make it working again you need to copy the code from the c() method in the a_() method and check if the (square)distance is 1 (you can adjust it to your liking). Basically you can use this:
    Code:
    if ((lastBounceId != entity.id || System.currentTimeMillis() - lastBounceTick > 1000) && entity.getBukkitEntity().getLocation().distanceSquared(getBukkitEntity().getLocation()) <= 1) {
        EntityTargetEvent event = new NpcEntityTargetEvent(getBukkitEntity(), entity.getBukkitEntity(), NpcEntityTargetEvent.NpcTargetReason.NPC_BOUNCED);
        CraftServer server = ((WorldServer) world).getServer();
        server.getPluginManager().callEvent(event);
     
        lastBounceTick = System.currentTimeMillis();
        lastBounceId = entity.id;
    }
    just put it somewhere in the a_() method.


    I don't think there's a method for that but maybe you want to make a scheduler that does the following:
    Code:
    if target is in range
        animate arm swing
        damage target
     
    else
        walk towards target

    This post has been edited 2 times. It was last edited by kumpelblase2 Apr 14, 2012.

Share This Page