[LIB] [1.7] Remote entities - Next generation NPC library [No support]

Discussion in 'Resources' started by kumpelblase2, Nov 10, 2012.

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

    bob7

    This is awesome! Were do i donate?!

    Quick question, how do i make the entity not attack certain entities? I tried setting the desire priority to 0

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

    lenis0012

    Im working on a zombie survival server and i want to spawn fast running zombies with higher health and with custom armour and such.

    Ill go have to look at the path finding
     
  3. Offline

    Jamboozlez

    Right, so now I have another problem creating a serializer:
    [​IMG]
    Where it is highlighted in red, what exactly do I put here? The JavaDocs said something about org.bukkit.plugin (something like that) so I guess I have to put my plugin name here, but it's still highlighted in red.
    The error says: 'AdvancedVillagers could not be resolved as a variable'.

    Sorry if I'm not making any sense or I have missed something really obvious out.
     
  4. bob7 If you want to donate you can click on the link in my signature (see first post).
    Changing the priority to 0 might not change anything. Do you want to let your desire execute or do you want another desire not to execute?

    lenis0012 I'm gonna make a separate branch for it when I can so you put some input into it.

    Jamboozlez Use the instance of your plugin not the class itself.
     
  5. Offline

    bob7

    I want iron golems to befriend zombies, I've tried to remove desires (didn't work). I may have to override EntityIronGolem to do this. Oh btw, the range thing doesn't seem to be working on numbers larger then 50 (Probably because of the new AI)

    Oh also, there appears to be a HUGE leak when spawning player based NPC's. [​IMG]


    Is there a way to maybe unload them when a player walks away?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  6. Offline

    TeeePeee

    Is it possible to make mobs move faster when they have a target? Then slower again when they lose their target?
     
  7. TeeePeee Certain attacking desires have the possibility to pass over a speed value in the constructor, e.g. DesireAttackOnCollide.

    bob7 They *should* get despawned once their chunk unloads and respawn when the chunk is available again.
    What do you mean by the range? Like the movement range?
    Have you tried both to remove from both target and movement desires?
     
  8. Offline

    Jamboozlez

    I'm sorry, but could you show me an example?
     
  9. Offline

    TeeePeee

    kumpelblase2 Sorry, what I meant was for a remote entity to acquire a target with speed at the mob default speed but once a target has been naturally acquired, the entity should change to (n) speed.
     
  10. Offline

    russjr08

    Where you have "AdvanceVillagers", try inserting "this" (without quotes) instead. That means it'll use an instance of the class that code is in, which extends JavaPlugin.
     
    Jamboozlez likes this.
  11. TeeePeee And that's exactly what they do.
     
  12. Offline

    Jamboozlez

    Yep, that worked. Thanks alot ;)
     
  13. Offline

    TeeePeee

    kumpelblase2 Okay but an example would be very helpful... I currently have this:

    Code:
    public static void attractZombies(Player p) {
            if (p.getGameMode() == GameMode.CREATIVE) { return; }
     
            int distance = visibilityRange(p);
            final Location l = p.getLocation();
     
            for (RemoteEntity e : m.getNpcManager().getAllEntities()) {
                if (e instanceof RemoteZombie || e instanceof RemotePigmen) {
                    if (e.getBukkitEntity().getLocation().distance(l) <= distance) {
                        speed(e);
                        e.getMind().addMovementDesire(new DesireMoveToLocation(e, l) {
                            @Override
                            public boolean canContinue() {
                                boolean b = (this.m_entity.getBukkitEntity().getLocation().distance(l) <= 1);
                                if (b) {
                                    unspeed(this.m_entity);
                                }
                                return !b;
                            }
                        }, 100);
                    }
                }
            }
        }
     
        public static int visibilityRange(Player p) {
            return 4 + (int) (p.getExp() * 9);
        }
    And it doesn't seem to do the trick...
     
  14. Offline

    russjr08

    kumpelblase2
    I'm trying to get a zombie to help attack (or protect its owner), and I'm getting confused if I should use addMovementDesire or addTargetingDesire, as they both seem to not get the mob to help attack.

    Code:
    entity.getMind().addMovementDesire(new DesireFollowTamer(entity, 5F, 10F), 2 );
     
            entity.getMind().addMovementDesire(new DesireSwim(entity), 100);
     
            entity.getMind().addMovementDesire(new DesireAvoidSun(entity), 10);
     
            entity.getMind().addTargetingDesire(new DesireHelpAttacking(entity, 5F, true), 1);
    The Zombie doesn't help attack whatever I attack, any clues as to what might be wrong?
     
  15. TeeePeee Well, when a path is set, the speed when setting it saved and the entity uses the same speed from that point. This is how the nms pathfinder does it, not really much I can do about that until custom pathfinding is out. Instead of adding a DesireMoveToLocation add a DesireAttackOnCollide (you can pass in the speed in the constructor) and set the target to the player. The zombies will now move with the given speed to the player.

    russjr08 When I have time to I would really like to sit down and write some javadocs about how to use which desire and when it is necessary and certainly also think about renaming some desires. This is one of those renaming cases. HelpAttacking does only target the owners target, nothing more than that. What you need as well now is a desire that actually attacks, like the AttackOnCollide.
     
  16. Offline

    russjr08

    Ah! Okay that makes more sense. The AttackOnCollide Desire wants an Entity Class in its constructor, does it use that as a sort of "list" of entities it can attack?

    Edit: Yep! That's the behaviour, very nice!
     
  17. Offline

    Fell

    Am I doing something wrong, or does this just not work?

    Code:
            minion.getMinion().getMind().addBehaviour(new DamageBehavior(minion.getMinion()) {
                @Override
                public void onDamage(EntityDamageEvent entityDamageEvent) {
                    System.out.println("Getting hurt");
                }
            });
    Also, this? I added that last line to try and force it to execute. I know that the location is right, but the NPCs just don't move.

    Code:
     minion.getMinion().getMind().addMovementDesire(new DesireMoveToLocation(minion.getMinion(),
                    Util.parseLocationString(plugin.getConfig().getStringList(minion.getTeam().getTeam() + ".navpoint." + minion.getSide()).get(0))), 1);
            minion.getMinion().getMind().getMovementDesires().get(0).getDesire().startExecuting();
     
  18. Offline

    lenis0012

    kumpelblase2
    I would love to do that :)

    Btw, you have such a nice server.
     
  19. Offline

    tebeix

    Hi,

    I tried to make basic zombie, but I ended up with
    using code from example:

    Code:
            EntityManager npcManager = RemoteEntities.createManager(this.plugin);
            RemoteEntity entity = npcManager.createNamedEntity(RemoteEntityType.Human, event.getPlayer().getLocation(), "test");
            TamingFeature feature = new RemoteTamingFeature(entity);
            feature.tame(event.getPlayer());
            entity.getFeatures().addFeature(feature);
            try {
     
                entity.getMind().addMovementDesire(new DesireFollowTamer(entity, 5, 15), entity.getMind().getHighestMovementPriority() + 1);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
    I have libraries bukkit 1.5.1 r.02, craftbukkit bukkit 1.5.1 r.02 and remoteentities 1.5.1 in project and on server I have craftbukkit r0.2

    What`s wrong there? :(
     
  20. Offline

    confuserr

    Zombies aren't tameable, use the DesireFollowSpecific desire instead
     
  21. Using the TamingFreature everything should be tameable, that's why it's there.

    However, I can't really tell why it doesn't work. I'll spend more time on it.
     
  22. Offline

    tebeix

    kumpelblase2 Have you found out anything? It`s quite important for me :(
     
  23. Offline

    Rprrr

    kumpelblase2
    Will you update this to 1.5.2? Would be great! :D
     
  24. Offline

    Rprrr

    kumpelblase2
    Oops, sorry! :p Thanks a bunch, it's a great library! :)
     
  25. Finally a new snapshot. This will, if no new issues occur, be the next release. Changelog so far:
    Show Spoiler

    Code:
    - Updated to minecraft 1.5.2 . https://github.com/kumpelblase2/Remote-Entities/commit/8b1ded5c5175d31170b2e8615c2e1ddfdfbfc54d
     
    - Added ability to fix head yaw. https://github.com/kumpelblase2/Remote-Entities/commit/d7903f4f9376d3778e3597604a1ba0939636dce3
    - Added ability to get default desires for entities. https://github.com/kumpelblase2/Remote-Entities/commit/f44549b8a6f9e1e9604fc36f4c9784ab9c0cadbc
    - Added ability to save entities automatically when all get despawned. https://github.com/kumpelblase2/Remote-Entities/commit/e3f98e3655076a5aecef1871805f0bd2be2b6d6c
    - Added custom pathfinding, but it is not in use yet and thus not even documented
    - Changed how types of desires work. They are now represented by an enum which makes it easier to understand. https://github.com/kumpelblase2/Remote-Entities/commit/9a997595a6a60e301e6990b9340a882435cdcac4
    - Some internal cleanup.
    - Fixed DesireKillTarget and DesireAttackOnCollide not working properly. https://github.com/kumpelblase2/Remote-Entities/commit/38ce4b86d9b658b56016ebfcb03c2ec5baa26165
    - Fixed not calling onAdd and onRemove for behaviors. https://github.com/kumpelblase2/Remote-Entities/commit/faa715ab458d663624109501366a421a05c276be
    - Fixed DamageBehavior. https://github.com/kumpelblase2/Remote-Entities/commit/4c37cf334c207048a99748f7c99b391be9ef62a5
    - Fixed default size of RemoteInventoryFeature. https://github.com/kumpelblase2/Remote-Entities/commit/1c07238af189efbbc73f2b86b3344b4d6e8cbfae
    - Fixed issue in DesireFollowTamer. https://github.com/kumpelblase2/Remote-Entities/commit/63c31c73349b7ef9efb754f34a0d1380258da056
    - Fixed not applying default desires sometimes. https://github.com/kumpelblase2/Remote-Entities/commit/42a5944a26f4334326ef926f296301fbae903a42
    - Fixed not despawning entities when RemoteEntities gets disabled. https://github.com/kumpelblase2/Remote-Entities/commit/22b4ea1e38b0e4c94b4e7a9e0c93f9782f974580
    - Fixed a concurrent exception when working with OneTimeDesires. https://github.com/kumpelblase2/Remote-Entities/commit/1f4557e767d631a683a90ba6c813cafceea97f0b
    - Fixed IgnoreSerialization annotation. https://github.com/kumpelblase2/Remote-Entities/commit/f7b3d4f96c07cac85cd1325496923c366951175f
    - Fixed some serialization issues. https://github.com/kumpelblase2/Remote-Entities/commit/ed56ae8b0be9619ad488c845d4807bb865acece4
     
  26. Ok 1.6 is now pushed to the maven repo!

    Changes: see post above or first post.
    Have fun!



    P.S.: If anyone wants to help out, I'll gladly get in contact with you!
     
  27. Offline

    LazyLemons

    kumpelblase2 I've noticed that whenever I spawn an entity, it doesn't spawn in the exact location, until I rejoin the server. Any way around this?
     
  28. Offline

    Quaro

    Code:
    package de.kumpelblase2.remoteentities.examples;
     
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import de.kumpelblase2.remoteentities.EntityManager;
    import de.kumpelblase2.remoteentities.RemoteEntities;
    import de.kumpelblase2.remoteentities.api.RemoteEntity;
    import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    import de.kumpelblase2.remoteentities.api.features.RemoteTamingFeature;
    import de.kumpelblase2.remoteentities.api.features.TamingFeature;
    import de.kumpelblase2.remoteentities.api.thinking.goals.DesireFollowTamer;
     
    public class ExampleMain extends JavaPlugin implements Listener
    {
        private EntityManager npcManager;
     
        public void onEnable()
        {
            Bukkit.getPluginManager().registerEvents(this, this);
            this.npcManager = RemoteEntities.createManager(this);
        }
     
        @EventHandler
        public void onJoin(PlayerJoinEvent inEvent) throws Exception
        {
            RemoteEntity entity = npcManager.createNamedEntity(RemoteEntityType.Human, inEvent.getPlayer().getLocation(), "test");
            TamingFeature feature = new RemoteTamingFeature(entity);
            feature.tame(inEvent.getPlayer());
            entity.getFeatures().addFeature(feature);
            entity.getMind().addMovementDesire(new DesireFollowTamer(entity, 5, 15), entity.getMind().getHighestMovementPriority() + 1);
        }
    }
    Code:
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: de/kum
    pelblase2/remoteentities/api/features/TamingFeature
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:184)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.loadPlugins(CraftServer.ja
    va:239)
            at org.bukkit.craftbukkit.v1_5_R3.CraftServer.<init>(CraftServer.java:21
    7)
            at net.minecraft.server.v1_5_R3.PlayerList.<init>(PlayerList.java:55)
            at net.minecraft.server.v1_5_R3.DedicatedPlayerList.<init>(SourceFile:11
    )
            at net.minecraft.server.v1_5_R3.DedicatedServer.init(DedicatedServer.jav
    a:106)
            at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java
    :382)
            at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: java.lang.NoClassDefFoundError: de/kumpelblase2/remoteentities/api/fe
    atures/TamingFeature
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:173)
            ... 9 more
    Caused by: java.lang.ClassNotFoundException: de.kumpelblase2.remoteentities.api.
    features.TamingFeature
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader
    .java:80)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:53)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
     
Thread Status:
Not open for further replies.

Share This Page