[Not Resolved]Percentage of Damage

Discussion in 'Plugin Development' started by messageofdeath, Sep 7, 2013.

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


    How would I find the percentage of damage on someone by multiple people. I already have the whole system up and saving the damage and subtracting of Regeneration. Just on the hitting it runs the event and it doesn't remove health sometimes, but it runs the event. So it runs my thing to high numbers then I do this to it.

    1. percentage = (int) ((double)this.damagers.get(0).getDamageDone() / (double)20 * (double)100);

    Depending on how fast you hit someone with a diamond sword it gives you around 250-400 % damage. If you punch someone the entire time you get over 1000 to 3000 % damage. How do I fix this?
  2. That just sounds like you are not resetting the damage, So it keeps adding up
  3. Offline


    You like KitPvP the damage system. I'm trying to accomplish that but for a different reason. Trying to find out the damager with the largest percent so he gets the kill.
  4. Offline


    Just a tip, you have some unnecessary casts, change it to this:

    1. percentage = (int) (this.damagers.get(0).getDamageDone() / (20 * 100));
  5. Offline


    Thanks for the tip, do you know a way to help with my problem?
  6. Offline


    messageofdeath you should be dividing the player's damage dealt by the total damage dealt, and then multiplying that by 100 to get it to percent.
  7. Offline


    Total Damage Delt meaning everyone's damage added up?

    chasechocolate Thanks so much

    new code percentage = (int) ((this.damagers.get(0).getDamageDone() / this.getTotalDamage()) * 100);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page