Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. local totalDamageOut, totalDamageIn, totalHealing = 0.1, 0.1, 0.1 -- avoid dividing by zero
  2.  
  3. local scores = {}
  4. local info = globalBosses[bossId]
  5. local damageMap = creature:getDamageMap()
  6.  
  7. for guid, stats in pairs(info) do
  8. local player = Player(stats.playerId)
  9. local part = damageMap[stats.playerId]
  10. local damageOut, damageIn, healing = (stats.damageOut or 0) + (part and part.total or 0), stats.damageIn or 0, stats.healing or 0
  11.  
  12. totalDamageOut = totalDamageOut + damageOut
  13. totalDamageIn = totalDamageIn + damageIn
  14. totalHealing = totalHealing + healing
  15.  
  16. table.insert(scores, {
  17. player = player,
  18. guid = guid,
  19. damageOut = damageOut,
  20. damageIn = damageIn,
  21. healing = healing,
  22. })
  23. end
  24.  
  25. local participants = 0
  26. for _, con in ipairs(scores) do
  27. local score = (con.damageOut / totalDamageOut) + (con.damageIn / totalDamageIn) + (con.healing / totalHealing)
  28. con.score = score / 3 -- normalize to 0-1
  29. if score ~= 0 then
  30. participants = participants + 1
  31. end
  32. end
  33. table.sort(scores, function(a, b) return a.score > b.score end)
  34.  
  35. local expectedScore = 1 / participants
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement