[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

    funkystudios

    Code:
    RemoteEntity entity = Stratus.getManager().createEntity(RemoteEntityType.Zombie, block.getLocation(), false);
    RemoteZombie rz = (RemoteZombie) entity;
    rz.attack(player);
    This should force the zombie to attack 'player'... correct? It doesn't seem to be working.
     
  2. The 'DesireAttackTarget' needs to be on the entity. Since you don't apply the default desires it doesn't have that desire.
     
  3. Offline

    lenis0012

    kumpelblase2

    in 1.4.6 if i try to spawn a RemoteEntity on a chunk or world that is not loaded yet, it does nto spawn it

    i am spawning RemoteEntities on enable but they dont get spawned, thats not the biggest issue though

    when i make the RemoteEntities statues and i rejoin or refresh the chunk it spawns the statue entity back but it also spawns a normal entity at the location of the statue one wiht the same type

    that is anoying me so bad :3

    using v1.4 latest developper build

    Edit one: also. hwo do you get the RemoteEntity's body to rotate to a custom yaw and pitch?

    Edit two: Fixed my first question by putting a ChunkLoad and ChunkUnload in adding and removing the entities
     
  4. Offline

    funkystudios

    kumpelblase2 Still no luck... The zombie just stands there with no movement.

    Code:
    RemoteZombie entity = (RemoteZombie) Stratus.getManager().createEntity(RemoteEntityType.Zombie, block.getLocation(), false);
    entity.getMind().addActionDesire(new DesireAttackTarget(entity, 48F, false, false), 50); // Which one do I use? Movement or action?
    entity.getMind().addMovementDesire(new DesireAttackTarget(entity, 48F, false, false), 50);
    entity.attack((LivingEntity) getGamer().getPlayer());
     
  5. Offline

    lenis0012

    Man i really cant get Player type NPC's to work D:
     
  6. Offline

    confuserr

    Code:
    RemoteZombie entity = (RemoteZombie) Stratus.getManager().createEntity(RemoteEntityType.Zombie, block.getLocation(), true);
    Set the last argument to true, that sets up the default goals.
     
  7. Offline

    lenis0012

    Its a hash error caused by SHA_256

    I dont know if they support Encryption converting???
    also, it should not happend for everyone, it could be a database or a Encryption mistake
    thats why i recomment MD5
     
  8. until the next snapshot: move(location with modified yaw and/or pitch) that should work
    after that: setYaw(float), setYaw(float, boolean), setPitch(float), lookAt(location), lookAt(entity)


    working on it.




    I'm gonna make a separate method to be able to force spawn them when the chunk is not loaded. Otherwise they'll get spawned as soon as the chunk gets loaded.

    I took a look at the default desires for zombie again, seems like you'll also need DesireAttackOnCollide as a movement desire. I'm gonna make to separate ones to make clear what they're doing.
    And DesireAttackTarget is only an action desire.

    I could be possible that 1.4.6 messed up the spawning, at least for players. Currently taking a look at it.
     
  9. Offline

    lenis0012

    doesn't work:

    loc = player.getLocation

    Code:
    RemoteEntity entity;
                if(this.isPlayer)
                    entity  = em.createNamedEntity(type, loc, name, false);
                else
                    entity = em.createEntity(type, loc, false);
                entity.setStationary(true);
                entity.setPushable(false);
                //entity.getMind().addActionDesire(new DesireLookAtNearest(entity, ClassNamer.ClassFromSuffix("EntityPlayer"), 8F), 1);
                entity.move(loc);
    
     
  10. If you want to. When you do that, would it be possible that you can invite me to it, so I could change things if they aren't correct? That would be nice.

    Well, I thought the spawn code was messed up but it actually was me. Spawning works fine, players and all other entities.



    P.S.: new snapshot is up.
     
    lenis0012 likes this.
  11. Offline

    Jumla

    How do I set their armor and item in hand? You appeared to have removed the code you exampled in 1.3....
     
  12. Offline

    confuserr

    Was removed in favour of bukkit's in built methods for setting armour/item in hand.
     
  13. Offline

    suckycomedian

    This is amazing.
     
  14. Offline

    lenis0012

  15. Offline

    Norbert

    is there any chance to add swinging arm to remote player?

    And why if humanNPC attacks me it doesn't take any damage?

    @EDIT: forgot to say I use 1.4 version
     
  16. Offline

    IDragonfire

    Any plugins that prevent pvp or protect players? Can you post some piece of code?

    Ps.: kumpelblase2:
    You have a message on bukkitdev ;)
     
  17. Offline

    Norbert

    Code:
    Location loc = player.getLocation();
    loc.setX(loc.getX() + 10);
    
    RemotePlayer attackEntity;
    attackEntity = (RemotePlayer) Plugin.EntityManager.createNamedEntity(RemoteEntityType.Human, loc, "attack", false);
    
    Mind mind = attackEntity.getMind();
    mind.addMovementDesire(new DesireSwim (attackEntity), 0);
    mind.addMovementDesire(new DesireAttackOnCollide (attackEntity, EntityHuman.class, false), 2);
    mind.addMovementDesire(new DesireMoveTowardsRestriction (attackEntity), 4);
    mind.addMovementDesire(new DesireWanderAround (attackEntity), 6);
    mind.addMovementDesire(new DesireLookAtNearest (attackEntity, EntityHuman.class, 8), 7);
    mind.addMovementDesire(new DesireLookRandomly (attackEntity), 7);
    mind.addActionDesire(new DesireAttackTarget (attackEntity, 16, false, false), 1);
    mind.addActionDesire(new DesireAttackNearest (attackEntity, EntityHuman.class, 16, false, true, 0), 2);
    
    loc.setX(loc.getX() + 3);
    Plugin.EntityManager.createNamedEntity(RemoteEntityType.Human, loc, "test", false);
    
     
  18. Offline

    IDragonfire

    With the newest snapshot the NPC follow me and attack me on collide, but I take no damage. Maybe kumpelblase2 forgot the change some nms functions.
    I compile the github version ... in these version the NPC ignore me :(
    The NPC detect the player correctly, that works.

    kumpelblase2:
    please update the github version ...
    one error:
    https://github.com/kumpelblase2/Rem.../remoteentities/CreateEntityContext.java#L240

    Best regards

    IDragonfire

    edit:
    Is there an easier solution?
    InventoryFeature doesn't work :(

    Code:java
    1. RemotePlayerEntity rp = (RemotePlayerEntity) attackEntity.getHandle();
    2. Player p = (Player) rp.getRemoteEntity().getBukkitEntity();
    3. // set armor
    4. p.getEquipment().setArmorContents(
    5. player.getEquipment().getArmorContents());
    6. // set inventory
    7. p.getInventory().setContents(player.getInventory().getContents());
    8.  
    9. // set correct item in the hand
    10. int itemindex = ((CraftInventoryPlayer) player.getInventory())
    11. .getInventory().itemInHandIndex;
    12. ItemStack oldHand = p.getItemInHand();
    13. p.setItemInHand(player.getItemInHand());
    14. p.getInventory().setItem(itemindex, oldHand);
     
  19. Hey guys, I've been quite busy the last days and I won't be here for the next couple of days either. I wish you some good days and a happy new year! See you then!

    The entity attacks are the worst to work with after movement. Could you create a ticket for this and the inventory thing, so I remember it when I get back?
    For the PR, see my comments on the individual commits.
     
  20. Offline

    ImTheFool

    I made an account just to post how cool this is. Just curious though.. how would I go about seeing how to code a behavior? I looked at the source and saw all the obfuscated methods like .e(); or aG();. How do I know what those do? I'm trying to make a DesireMoveToPosition behavior or something, but for now, I'm probably going to spawn an invisible NPC as the target and DesireMoveToTarget it.
     
  21. Offline

    IDragonfire

    The lib should hide these method, try to use the lib method. RemoteEntites have a move method, look at DesireWanderAround. In my opinion move to a positin is no desire.
     
  22. Offline

    Baba43

    This is not compatible with 1.4.6 is it?

     
  23. Offline

    ImTheFool


    Ah. Perhaps I should've explained myself better. I more meant a desire to stay inside an area (like an NPC's house), then if he gets pushed out of a certain radius of his original position by someone, say something like "Quit pushing me!", and walk back to his original spot. I considered DesireMoveIndoors, but I thought that may have a chance to move him to a place that wasn't his original position. I may consider DesireWanderAroundArea, but he may look silly (or it may cause extraneous resource usage) always walking.


    Are you using Bukkit 1.4.6-R0.1 or 1.4.6-R0.2? Works for me with R0.1; haven't tried R0.2 yet.
     
  24. Offline

    Baba43

    I get this error:
     
  25. Offline

    ImTheFool

    Which version of Bukkit are you using? R0.1 or R0.2?
     
  26. Offline

    aviator14

    That much shouldn't matter, he's trying to use a 1.4.5 version with a 1.4.6 Bukkit ;)

    You are using an outdated version of the lib. Update it or downgrade your Bukkit.
     
  27. Offline

    suckycomedian

    How do I set this up correctly?
    Code:
            EntityManager manager = RemoteEntities.createManager(this);
            public static EntityManager getManager(){
                return manager;
                }
    If i put it in my onEnable() It says "@ expected" for "public static EntityManager" and it won't let me call it in my other class. If I move "public static EntityManager getManager(){
    return manager;
    }" out of the onEnable(), I'm not sure how to have it return manager.
     
  28. Offline

    ImTheFool

    I think you could declare manager outside of onEnable, then initialize it inside of onEnable. Something like this:

    Code:
    private EntityManager manager;
     
    public void onEnable() {
        manager = RemoteEntities.createManager(this);
    }
     
    public static EntityManager getManager() {
        return manager;
    }
    
    Also, you might have to use try{} when you call createManager(); as it can throw an exception.
     
    kumpelblase2 and suckycomedian like this.
  29. Offline

    suckycomedian

    What about with this? I have it in an EntityTargetEvent so that if an entity targets me, the people I have tamed will attack it. It passes everything up to the point where it actually attacks the thing targeting me.
    Code:
    RemotePlayer rp = (RemotePlayer) entity;
    entity.getMind().addActionDesire(new DesireAttackTarget((RemoteEntity) rp, 5, false, true), 1);
    rp.attack((LivingEntity) event.getEntity());
    How do I make it target the event.getEntity()?

    Here's more of the code.
    Code:
        if(event.getTarget() instanceof Player){
                    List<RemoteEntity> e = RTS.getManager().getAllEntities();
                    for(RemoteEntity entity : e){
                        if(entity.getFeatures().hasFeature(RemoteTamingFeature.class)){
                            RemoteTamingFeature feature = entity.getFeatures().getFeature(RemoteTamingFeature.class);
                            if(event.getTarget() == feature.getTamer()){
                                Player player = feature.getTamer();
                                if(player.getNearbyEntities(5, 2, 5).contains(event.getEntity())){
                                    if(entity.getType() == RemoteEntityType.Human){
                                        RemotePlayer rp = (RemotePlayer) entity;
                                        rp.getMind().addActionDesire(new DesireAttackTarget(rp, 5, false, true), 1);
                                        rp.attack((LivingEntity) event.getEntity()); 
                                       //i had it return the target, but they only targeted the
                                       //entity when i punched it. Still didn't attack it though.
                                    }
                                }
                            }
                        }
                    }
                }    
     
  30. Offline

    suckycomedian

    Is there a way to check to see if the entity has moved to the location you sent it to? PlayerMoveEvent doesn't seem to work even for RemotePlayer.
     
Thread Status:
Not open for further replies.

Share This Page