Extending a hostile mob's "awareness"

Discussion in 'Plugin Development' started by AmoebaMan, Apr 17, 2012.

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


    Basically I've been working on a plugin that makes monsters generally more dangerous. However, it's being basically defeated by the fact that people can still just run away from the dopey things.

    How could I make a hostile mob able to acquire and track targets that are further than the default limit of 16 blocks?
  2. Offline


  3. Offline


    sd5 That code would set the creature's target, but it would still be limited by Minecraft's default monster behavior. That is, the instant the target is farther than 16 or so blocks away from the monster, it will forget the target and set its target to null.

    Obviously, this would have to be a workaround job, but it seems like it should be possible.
  4. Offline


    With some effort, research, and reflection you could modify a mob's AI behaviors.
  5. Offline


    Isn't it possible to use the org.bukkit.entity.Entity.getNearbyEntities() method then for each hostile creature in this list set it's target to the player?
    But as you'll have to check that for every player very often it might get ugly with many players or Entities
  6. Offline


    maxp0wer789 The problem is once again that monsters can't track targets outside of a 16 meter radius. If a monster's target is farther away than 16 blocks, it will forget about it, and the target will be set to null.
  7. Offline


    It's a problem I'm dealing with too...

    My solution (but it's not working yet) is to force given entities near the target to MOVE in direction of the target. But it's really hard and buggy.

    If you find a solution I'm very interested.
  8. Offline

    Father Of Time

    Just throwing random ideas out there, but have you played around with EntityTargetLivingEntityEvent?

    I would try putting in a check to see if the target the entity is changing to is null, if so and the target distance is less than that of your desired distance simply cancel the event (aka it doesn't set the target to null unless it's over X distance away).

    I have no idea if this event is called when a entity's target is changed from an entity to null, but it's worth trying.

    I hope this helps, good luck!
  9. Offline


    Like I said you would have to frequently check (maybe with a repeating task or your own async runnable) and set the target again. That might result in a strange mob movement though (dependig on the frequenzy of your check) and can be performance intensive
  10. Offline


    Right back maxp0wer789 as I said, this does not work. The problem is that the monster's target is instantly returned to null, and the mob takes no action.

    xUMi I'll look up on that, I think I actually recall seeing a thread about accessing a CraftBukkit method to make a mob move to a location. If that works, I'll post the code and tag you.
  11. Offline


    This has basic pathfinding for larger than default radius. By basic I mean really basic.
    It moves the zombies a bit around in the basic direction and, shortly after they fail to pathfind and reset to a default zombie. But as you can see it is possible to do it with bukkit.
    They do have a github if you want to see the code.
Thread Status:
Not open for further replies.

Share This Page