mobs (hard to explain here)

  • 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!

shakyslime

Member
Jul 20, 2024
3
1
3
24
so i am testing all sorts of swords and enchants yk, so when i am struggling with finding which sword is better, i look online but cant find anything now. i need code that will give the player a spawn egg that has 20hp like the player and that it will have his hp ontop and will show hjow much damage it does, optionally, it could have a command that can heal the certain mob.
 
Try this:
Code:
command /spawntestmob:
    trigger:
        spawn 1 zombie at player's location
        set {_mob} to last spawned entity
        set max health of {_mob} to 20
        set health of {_mob} to 20
        set name of {_mob} to "&cTest Mob - 20HP"
        set display name of {_mob} to "&a%health of {_mob}% HP"
        send "&aSpawned a Test Mob with 20 HP!" to player

on damage:
    if victim is a zombie named "&cTest Mob - 20HP":
        set display name of victim to "&a%health of victim% HP"

command /healtestmob:
    trigger:
        loop all zombies in world of player:
            if name of loop-entity is "&cTest Mob - 20HP":
                set health of loop-entity to 20
                set display name of loop-entity to "&a20 HP"
                send "&aThe Test Mob has been healed to full health!" to player
                stop
        send "&cNo Test Mob found to heal!" to player
 
Try this:
Code:
command /spawntestmob:
    trigger:
        spawn 1 zombie at player's location
        set {_mob} to last spawned entity
        set max health of {_mob} to 20
        set health of {_mob} to 20
        set name of {_mob} to "&cTest Mob - 20HP"
        set display name of {_mob} to "&a%health of {_mob}% HP"
        send "&aSpawned a Test Mob with 20 HP!" to player

on damage:
    if victim is a zombie named "&cTest Mob - 20HP":
        set display name of victim to "&a%health of victim% HP"

command /healtestmob:
    trigger:
        loop all zombies in world of player:
            if name of loop-entity is "&cTest Mob - 20HP":
                set health of loop-entity to 20
                set display name of loop-entity to "&a20 HP"
                send "&aThe Test Mob has been healed to full health!" to player
                stop
        send "&cNo Test Mob found to heal!" to player

Looping all the zombies in the world seems a bit excessive if you're only trying to heal one entity. Wouldn't it be better to loop all entities within a 10-20 block radius of the player?