RPG Mob's behavior

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

Status
Not open for further replies.

Turb032

Active Member
Jan 16, 2020
109
0
16
22
Hi guys, i'm tryna make RPG mobs: When i hit a mob (zombie) it will check if the player is near or far from the damaged mob. When it checks that, if the attacker is in an area of 5 blocks around victim, it'll be the same thing (the mob hits the attacker) but, if the player is 5 blocks far from the victim, the mob's target will be cleared.
Let me know if you did understand it, Thank you!
Code:
on entity target:
    if event-entity is zombie:
        cancel event

on damage:
    if victim = zombie:
        if attacker = player:
            if victim is alive:
                loop 1000 times:
                    loop all entities in radius 5 around victim:
                        if attacker is loop-entity:
                            set victim's target to attacker
                        if attacker isn't loop-entity:
                            clear victim's target
[doublepost=1612088775,1611850257][/doublepost]anyone?
 
Status
Not open for further replies.