[NMS] EntityPig to target last damager(player)

Discussion in 'Plugin Development' started by HeavyMine13, Jul 12, 2014.

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

    HeavyMine13

    Hello, I have (onEnable) a method that spawns an EntityPig that spawns at a rate of 5 min with a random location in a radius with the name "Fighter". Then, I have an EntityDamageByEntityEvent checking if the damaged is a pig and it has the name "Fighter", I want to make that EntityPig become enemy to that player and follow it and hit it. How can I make it happen? Shall I use Navigation? Shall I use .setGoalTarget? Thanks!
     
  2. Offline

    ResultStatic

    extend EntityPig. and find a tutorial on custom mob registering.
     
  3. Offline

    HeavyMine13

    Extend it?? Why? I have EntityPig p = //get the pig;
     
  4. Offline

    Deleted user

    HeavyMine13
    Extend it so you can modify the AI?
    Just a guess. I've never made angry pigs before.
     
  5. Offline

    unrealdesign

    HeavyMine13 My method:
    1. Set the pigs direction to the nearest player. (Note: I would make sure the pig can see the player and set a max radius for the pig to go to the player. If none of the requirements are met, then don't do anything with the pig)
    2. Make a cooldown length of attacks for the mob. Ie 2 seconds
    3. Make a boolean coolwown and set it to false.
    4. If cool down is equal to false, and the mob is within a certain distance of a player, manually attack that player.
    5. Set cooldown to true, and start a delayed task of you desired time length and set cooldown back to false after this time
    I hope you understand the process!
     
  6. Offline

    HeavyMine13

    How to do step 4? Isn't there a way with NMS to do this auto?
     
  7. Offline

    unrealdesign

    I don't use NMS, so I was just explaining a way to use my method. There could be a way to auto do that in NMS, but it might only be for certain entity types
     
  8. Offline

    Cirno

    Look into manipulating PathfinderGoals.
    To get you started off, you should use PathfinderGoalMeleeAttack and PathfinderGoalNearestAttackableTarget
     
  9. Offline

    HeavyMine13

    Wont that make it attack any player not ones who hit it?
     
  10. Offline

    HeavyMine13

Thread Status:
Not open for further replies.

Share This Page