akon1248

Damage Indicators

Mar 15th, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. function displayHealth(p: player, e: living entity):
  2. set {_health} to tag "Health" of nbt of {_e}
  3. set {_health} to ceil({_health})
  4. set {_healthtext} to ""
  5. while {_health} >= 2:
  6. set {_healthtext} to "%{_healthtext}%&4❤"
  7. remove 2 from {_health}
  8. if {_health} is 1:
  9. set {_healthtext} to "%{_healthtext}%&c❤"
  10. set {_health} to tag "Health" of nbt of {_e}
  11. set {_currentdamage} to max health of {_e}-ceil(ceil({_health})/2)
  12. if {_currentdamage} > 0:
  13. loop {_currentdamage} times:
  14. set {_healthtext} to "%{_healthtext}%&7❤"
  15. set {_absorption} to tag "AbsorptionAmount" of nbt of {_e}
  16. set {_absorption} to ceil({_absorption})
  17. while {_absorption} >= 2:
  18. set {_healthtext} to "%{_healthtext}%&6❤"
  19. remove 2 from {_absorption}
  20. if {_absorption} is 1:
  21. set {_healthtext} to "%{_healthtext}%&e❤"
  22. if "%all active potion effects of {_e}%" contain "POISON":
  23. replace "&4" in {_healthtext} with "&2"
  24. replace "&c" in {_healthtext} with "&a"
  25. if "%all active potion effects of {_e}%" contain "WITHER":
  26. replace "&4" in {_healthtext} with "&0"
  27. replace "&c" in {_healthtext} with "&8"
  28. if {_e} is a player:
  29. set {_entityname} to "%{_e}%"
  30. else:
  31. set {_name} to tag "CustomName" of nbt of {_e}
  32. if {_name} is set:
  33. set {_entityname} to {_name}
  34. else if {_name} is not set:
  35. set {_entityname} to getMobTypeName({_e})
  36. send action bar from "&7%{_entityname}% %{_healthtext}%" to {_p}
  37. function getMobTypeName(e: entity) :: string:
  38. set {_name} to "%{_e}.getType()%" in lower case
  39. replace "_" in {_name} with " "
  40. set {_splits::*} to {_name} split by ""
  41. set {_size} to size of {_spilts::*}
  42. delete {_splits::%{_size}%}
  43. set {_splits::1} to {_splits::1} in upper case
  44. loop {_splits::*}:
  45. set {_num} to loop-index parsed as integer - 1
  46. {_splits::%{_num}%} is " "
  47. set {_splits::%loop-index%} to {_splits::%loop-index%} in upper case
  48. return join {_splits::*}
  49. on damage:
  50. attacker is a player
  51. victim is a living entity
  52. victim is not armor stand
  53. event is not cancelled
  54. wait 1 tick
  55. if max health of victim > 50:
  56. set {_health} to tag "Health" of nbt of victim
  57. set {_maxhealth} to max health of victim*2
  58. add tag "AbsorptionAmount" of nbt of victim to {_health}
  59. if name of victim is set:
  60. set {_entityname} to name of victim
  61. else if name of {_e} is not set:
  62. set {_entityname} to getMobTypeName(victim)
  63. send action bar from "&7%{_entityname}% &c%{_health}%&7/&a%{_maxhealth}%" to attacker
  64. else:
  65. displayHealth(attacker, victim)
  66. on damage:
  67. victim is a living entity
  68. victim is not armor stand
  69. set {_victimhealth} to tag "Health" of nbt of victim
  70. add tag "AbsorptionAmount" of nbt of victim to {_victimhealth}
  71. wait 1 tick
  72. set {_damagedhealth} to tag "Health" of nbt of victim
  73. add tag "AbsorptionAmount" of nbt of victim to {_damagedhealth}
  74. {_victimhealth}-{_damagedhealth} > 0
  75. set {_yaw} to random number between 0 and 360
  76. set {_pitch} to -60
  77. set {_loc} to location 1 meter above location of victim
  78. set yaw of {_loc} to {_yaw}
  79. set pitch of {_loc} to {_pitch}
  80. spawn an armor stand at {_loc}
  81. add "{CustomName:""&c%{_victimhealth}-{_damagedhealth}%"",CustomNameVisible:1b,Invisible:1b,Marker:1b,Small:1b,NoGravity:1b}" to nbt of last spawned armor stand
  82. set {_holo} to last spawned armor stand
  83. loop 10 times:
  84. remove 3 from {_pitch}
  85. set pitch of {_loc} to {_pitch}
  86. set {_loc} to location 0.15 meter forwards {_loc}
  87. teleport {_holo} to {_loc}
  88. wait 1 tick
  89. wait 5 tick
  90. kill {_holo}
  91. on heal:
  92. event-entity is a living entity
  93. event-entity is not armor stand
  94. set {_health} to tag "Health" of nbt of event-entity
  95. add tag "AbsorptionAmount" of nbt of event-entity to {_health}
  96. wait 1 tick
  97. set {_healedhealth} to tag "Health" of nbt of event-entity
  98. add tag "AbsorptionAmount" of nbt of event-entity to {_healedhealth}
  99. abs({_healedhealth}-{_health}) > 0
  100. set {_yaw} to random number between 0 and 360
  101. set {_pitch} to -60
  102. set {_loc} to location 1 meter above location of event-entity
  103. set yaw of {_loc} to {_yaw}
  104. set pitch of {_loc} to {_pitch}
  105. spawn an armor stand at {_loc}
  106. add "{CustomName:""&a%abs({_healedhealth}-{_health})%"",CustomNameVisible:1b,Invisible:1b,Marker:1b,Small:1b,NoGravity:1b}" to nbt of last spawned armor stand
  107. set {_holo} to last spawned armor stand
  108. loop 10 times:
  109. remove 3 from {_pitch}
  110. set pitch of {_loc} to {_pitch}
  111. set {_loc} to location 0.15 meter forwards {_loc}
  112. teleport {_holo} to {_loc}
  113. wait 1 tick
  114. wait 5 tick
  115. kill {_holo}
Advertisement
Add Comment
Please, Sign In to add comment