Hostile allay

  • 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
17
1
3
23
Hey everyone im trying to create an allay that attacks players. Does anyone know what i could do for that
 
if you want only certain allays to attack you can repurpose ShaneBee's attack pig skript
code_language.skript:
# REQUIRES SkBEE
function spawnAttackAllay(l: location):
    spawn an allay at {_l}:
        set tag "custom;attackAllay" of nbt of entity to true
        set name of entity to "&cAttack Allay"

#! LISTENER !#
# Checks when entity is loaded and enables attack status
on entity added to world:
    wait 1 tick
    set {_e} to event-entity
    if type of {_e} = allay:
        if nbt of {_e} has tag "custom;attackAllay":
            while {_e} is alive:
                set {_p} to nearest player in radius 15 around {_e}
                if gamemode of {_p} = survival or adventure:
                    set path target of {_e} to {_p}
                    if distance between {_e} and {_p} < 1:
                        make {_e} damage {_p} by 1
                wait 5 ticks

#! COMMAND !#
# Spawn an attack allay
command /attackallay:
    trigger:
        set {_l} to location 0.5 above target block
        spawnAttackAllay({_l})