Boss HP updates

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Gameeer

Member
Jan 2, 2022
14
1
3
23
Hello, i have skripted a custom boss and i just wanted to know how i can display his health in his nametag. I tried some but it wouldent update. Thanks!

Code:
command /rstbs:
    permission: op
    trigger:
        set {alive} to false

every 1 second:
    if {alive} is false:
        spawn 1 adult zombie at location 110, 64, 101 in world "skyblock"
        equip last spawned zombie with iron chestplate of protection 4
        equip last spawned zombie with iron leggings of protection 4
        equip last spawned zombie with iron boots of protection 4
        set last spawned zombie's held item to iron sword of sharpness 4 and knockback 1
        set last spawned zombie's max health to 100
        set last spawned zombie's health to 100
        set display name of last spawned zombie to "&6Zombie King"
        set {alive} to true
        
on death:
    if display name of victim is "&6Zombie King":
        cancel drops
        set {loot} to 0
        chance of 2%:
            set {loot} to 1
        chance of 1%:
            set {loot} to 2
        send "&9Boss Down!" to attacker
        if {loot} is 1:
            play sound "block.note_block.harp" with pitch 1 to the attacker
            wait 0.2 seconds
            play sound "block.note_block.harp" with pitch 1.2 to the attacker
            wait 0.2 seconds
            play sound "block.note_block.harp" with pitch 1.4 to the attacker
            send "&l&3Boss Drop! &2Zombie Knight Chestplate &7(1/50 Drop!)" to attacker
            give attacker unbreakable gold chestplate named "&6Zombie Knight Chestplate" with lore "&3Gives Permenant Strength 1"
            
        if {loot} is 2:
            play sound "block.note_block.harp" with pitch 1 to the attacker
            wait 0.2 seconds
            play sound "block.note_block.harp" with pitch 1.2 to the attacker
            wait 0.2 seconds
            play sound "block.note_block.harp" with pitch 1.4 to the attacker
            send "&l&3Boss Drop! &2Zombie Knight Sword &7(1/100 Drop!)" to attacker
            give attacker unbreakable gold sword named "&6Zombie Knight Sword" with lore "&3+50 Damage"
        set {alive} to false
 
i tried just setting the name to “zombie name %health of last spawned entity%” but it just put the max health
 
i tried just setting the name to “zombie name %health of last spawned entity%” but it just put the max health
I did some research. Try this:

Code:
options:
    zombie: &6King Zombie

on damage:
    if victim is not a player:
        if victim's max health = 100:
            set {_h1} to victim's health
            set {_h2} to victim's max health
            set victim's display name to "{@zombie} %{_h1}%/%{_h2}%"