Moving monsters with a certain speed

Discussion in 'Plugin Development' started by Jobi, Apr 9, 2013.

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

    Jobi

    In one of my current projects I have to move monsters to different waypoints and I am doing it like this:
    Code:
    Monster monster = creep.getMonster();
    EntityCreature ec = ((CraftCreature) monster).getHandle();
    Block to = creep.getWaypoint().getBlock();
    PathEntity pf = ((CraftWorld) to.getWorld()).getHandle().a(ec, to.getX(), to.getY(), to.getZ(), 16.0f, true, false, false, true);
    if(monster instanceof PigZombie || monster instanceof CaveSpider || monsterinstanceof Blaze || monster instanceof Enderman) {
        ec.setPathEntity(pf);
    }
    else {
        Navigation nav = ec.getNavigation();
        nav.a(pf, 0.2f);
    }
    But just giving them waypoints isn't enough, I want to set their speed too. For the "old" mobs the else part is working (nav.a(pf, 0.2f)), the "new" mobs just ignore this part and do nothing, but the old ones will move to the PathEntity (pf) with the speed 0.2. The only way I know to controll the new is ec.setPathEntity(pf), but I can't set a speed here. Does anyone know how give the "new" mobs a certain movement speed?

    Thanks for your help

    Joba
     
  2. what cass is the variable ec?
     
  3. Offline

    Jobi

    Sorry, I forgot to add this line... It's an EntityCreature
     
  4. Offline

    Jobi

    Bump

    Bump :(

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

    Jobi

    Bump...
     
  6. Offline

    Jobi

    one last bump
     
  7. Offline

    Hoolean

    I have some code for this, remind me later and I'll dig it up, I'm not at my coding computer right now :)
     
  8. Offline

    DSH105

    I wouldn't mind to see how this one is done too. I'm interested :)
     
  9. Offline

    Hoolean

    Code:java
    1. private boolean walkTo(LivingEntity livingEntity, Location l, float speed) {
    2. try {
    3. return ((org.bukkit.craftbukkit.v1_5_R2.entity.CraftLivingEntity) livingEntity)
    4. .getHandle().getNavigation()
    5. .a(l.getX(), l.getY(), l.getZ(), speed);
    6. } catch (Exception e) {
    7.  
    8. //do "OH GAWD WHY" stuff
    9.  
    10. }
    11. }


    Does this work? :)
     
  10. Offline

    DSH105

    I've already tried that before. Works on most mobs, but not all :\
     
  11. Offline

    Hoolean

    _DSH105_

    Dang. Well sorry about that D':
     
  12. Offline

    Jobi

    I guess it works for every mob except Pigman, Cavespides, Blazes and Enderman
     
  13. Offline

    nitrousspark

    just use the CreatureSpawnEvent, then give them a speed potion
     
  14. Offline

    Jobi

    Speed potions are not accurate enough, but maby changing the Velocity of the mobs when they are moving could work.

    There is still some hope! (bump)

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

    DSH105

    Jobi
    Use the velocity method you suggested earlier. It's possible to simulate a player flying without actually activating it, so it should be possible to simulate a monster moving to a certain extent.
     
Thread Status:
Not open for further replies.

Share This Page