Wolf max health

Discussion in 'Plugin Development' started by Hex_27, Dec 17, 2014.

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

    Hex_27

    When I tried to change the wolf's max health, it said that it can only vary from 0.0 to 0.8 on a console error. Is there a way to override this?
     
  2. Offline

    Webbeh

    It all depends on what you're trying to achieve.
     
  3. Offline

    Hex_27

    @Webbeh I'm trying to increase the wolf's base health for each "level" a player has.
     
  4. Offline

    Webbeh

    Couldn't you simply apply a division factor to the damage the player does to the wolf ?

    Let's assume wolf has a fixed life of 0.8. Assume that your sword deals 0.2 damage on each hit. If you listen to entitydamagebyentityevent, and get the level of the player and use it to reduce the damage given to the wolf, it WILL be simpler. That way, all wolves have equal life and multiple players could hit it at once, each one with the right damage.

    I believe it's the simplest way, but again it all depends on what you intend to do with your plugin.
     
  5. Offline

    Hex_27

    @Webbeh I can't do that. I need to fetch the wolf's health. And this health varies for different specified wolves.
     
  6. Offline

    Webbeh

    Well then you need to apply different factors to the different kind of wolves.
    It's a bit more complex than simply setting a wolf's health, but isn't that difficult either.

    Also it's not like you had the choice...
     
  7. Offline

    Hex_27

    @Webbeh is it a good idea to use a haspmap for <UUID> <Integer> to store health? And remove the hashes when the wolf dies? Its possible to increase a Player's health, so why not a wolf's?
     
  8. Offline

    Webbeh

    I guess you can do that. Just be sure to remove the wolf from the hashmap when it dies, and to cancel the entity damage events.
     
  9. Offline

    mythbusterma

    @Hex_27

    Dying is not the only case you have to worry about, the chunk said wolf is in may be unloaded, in which case, that would cause a memory leak.

    Does Damagable#setMaxHealth(double) not work?
     
  10. Offline

    Hex_27

    @mythbusterma it says the wolf's max health can't exceed 0.0 to 0.8 in the console error.

    Bump

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

    Hex_27

  12. Offline

    Webbeh

    Don't bump unnecessarily.

    You have the choice : use a divisor ratio (like I told you already) on the players' attacks, or use a hashmap on the mob to have the health. Or you can always create a new creature extending the wolf, but... that's a bit of an overkill.
     
Thread Status:
Not open for further replies.

Share This Page