How to give players EXP based on damage dealt

Discussion in 'Tutorials' started by jaylawl, Mar 4, 2016.

  1. jaylawl

    jaylawl Community Manager
    Super Moderator Supporter Premium Supporter Quality Assurance

    Joined:
    Sep 16, 2015
    Messages:
    1,763
    Likes Received:
    171
    Requirements:
    - MythicMobs 2.3 or later
    - Spigot 1.8 or later


    This config (http://hastebin.com/ahadevutor.xml) will do the trick. It's noteworthy that i haven't been able to test if this is going to work accurately, because you obviously need multiple players to test this. Would be grateful if somebody could take care of the task.

    The "modifytargetscore" included in this config will automatically create the scoreboard dubbed "damagescore". However it will not automatically remove/cleanup that scoreboard after the mob has died. That is why the additional modifytargetscore is needed with the ~onSpawn trigger.

    The command-mechanic triggered ~onDeath will distribute EXP points to all players automatically, based on how often they attacked the mob multiplied by 5.

    This system is not suited for mobs that have multiple instances of them spawned at the same time.
    Code:
    epic_raid_boss:
      Type: giant
      Display: 'such epic'
      Skills:
      - modifytargetscore{o=damagescore;a=set;v=0} @server ~onSpawn
      - modifytargetscore{o=damagescore;a=add;v=5} @trigger ~onDamaged
      - command{c="minecraft:xp <target.score.damagescore> <target.name>"} @a[r=100,score_damagescore_min=0] ~onDeath
     
    #1
  2. Awesome_Dante

    Awesome_Dante Contributor
    Supporter Quality Assurance Moderator

    Joined:
    May 26, 2016
    Messages:
    712
    Likes Received:
    247
    Does the scoreboard automatically cleanup now? It seems to work just fine in my bandit and I don't believe I set the score back, just let it die
     
    #2
  3. NNemo

    NNemo New Member

    Joined:
    Feb 19, 2017
    Messages:
    3
    Likes Received:
    0
    Nice it works, can this be used to distribute money too? like eco give
     
    #3
  4. bloodmasked

    bloodmasked New Member

    Joined:
    Jul 18, 2017
    Messages:
    4
    Likes Received:
    0
    damage dealt or number of hits im confused
     
    #4
  5. iccf1289

    iccf1289 New Member

    Joined:
    Jan 12, 2018
    Messages:
    2
    Likes Received:
    0
    Bump please, damage dealt or hits?
     
    #5
  6. Awesome_Dante

    Awesome_Dante Contributor
    Supporter Quality Assurance Moderator

    Joined:
    May 26, 2016
    Messages:
    712
    Likes Received:
    247
    Hits multiplied by 5 gives you that much XP. Not actual damage dealth.
     
    #6
  7. Buguser

    Buguser Active Member
    Supporter

    Joined:
    Oct 11, 2016
    Messages:
    127
    Likes Received:
    46
    What if you convert the current HP into points of a scoreboard when spawning the mob, then subtract it with the HP after the mob was attacked? The current HP of the mob is then loaded back into the scoreboard and subtracted with the HP after the attack. Thus, after each hit, the points of the DMG scoreboard could be attributed to the trigger as damage deal.

    For example:

    The mob has 200HP
    The monster is attacked by player A, who deals 14 damage to the mob, and now the 186HP remaining will be deducted from the 200HP as points in the scoreboard. Player A receives 14 points in the DMG scoreboard.
    Player B attacks the monster and deals 56 damage. 130 points are now deducted from the remaining 186 points, player B receives 56 points in the DMG scoreboard.

    The points received can be paid out directly or if the mob is dead.

    Sounds simple in theory, but variable ones have never worked for me as value in a scoreboard.

    Maybe I will find a solution to this problem in the near future, but maybe someone will find a solution sooner.

    Have a nice evening :p
     
    #7
  8. Awesome_Dante

    Awesome_Dante Contributor
    Supporter Quality Assurance Moderator

    Joined:
    May 26, 2016
    Messages:
    712
    Likes Received:
    247
    It's a great idea. I used used it some time ago, but I was under NDA. Couldn't say anything. I'm glad you did. Now it's somewhat public domain hahaha
     
    #8
    Buguser likes this.
  9. Awesome_Dante

    Awesome_Dante Contributor
    Supporter Quality Assurance Moderator

    Joined:
    May 26, 2016
    Messages:
    712
    Likes Received:
    247
    Gotta be careful which plugins you do this method through. It won't work for all. Awarding money in this manner for example will NOT work in essentials
     
    #9
    Buguser likes this.
  10. Michael Strast

    Joined:
    Feb 18, 2018
    Messages:
    30
    Likes Received:
    16
    This is so awesome haha! You guys are great!
     
    #10
    Awesome_Dante likes this.
  11. Darkweasam

    Darkweasam Member

    Joined:
    Nov 29, 2017
    Messages:
    30
    Likes Received:
    0
    How to do this? I like this idea
     
    #11
  12. Buguser

    Buguser Active Member
    Supporter

    Joined:
    Oct 11, 2016
    Messages:
    127
    Likes Received:
    46
    #12
    Darkweasam likes this.

Share This Page