Solved Making Mobs Deaggro Based on Full Set of Armor

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

    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.

Skzen

Member
Jun 15, 2017
15
1
0
Hi, I'm trying to make it so when if I have a full set of armor that contains the lore undead,
it makes it so mobs do not attack me unless I attack them.

I've gotten the messages to print and variables to work before, but I can't seem to make it so
mobs only do not hit the players in the full set. I have to remove the conditions on in entity target for it to work.

Code:
function contains(list: objects, check: object) :: boolean:
    loop {_list::*}:
        if loop-value is {_check}:
            return true
    return false

on armor equip:
    wait 10 ticks
    if "%lore of player's helmet%" contains "Undead":
        if "%lore of player's chestplate%" contains "Undead":
            if "%lore of player's leggings%" contains "Undead":
                if "%lore of player's boots%" contains "Undead":
                    add "%player%" to {_Undead::*}
                    send {_Undead::*} to player
                    send "&e&l(!) &r&eYou now have the &nUndead Set Bonus!&r &eRegular hostile mobs will no longer attack you." to player


on entity target:
    if entity's target is a player:
        if contains({_Undead::*}, "%player%") is true:
            send {_Undead::*} to player
            cancel event



on armor unequip:
    if "%lore of player's helmet%" contains "Undead":
        if "%lore of player's chestplate%" contains "Undead":
            if "%lore of player's leggings%" contains "Undead":
                if "%lore of player's boots%" contains "Undead":
                    remove "%player%" from {_Undead::*}
                    send {_Undead::*} to player
                    send "&c&l(!) &r&cYou no longer have the &e&nUndead Set Bonus!" to player
 
Hi, I'm trying to make it so when if I have a full set of armor that contains the lore undead,
it makes it so mobs do not attack me unless I attack them.

I've gotten the messages to print and variables to work before, but I can't seem to make it so
mobs only do not hit the players in the full set. I have to remove the conditions on in entity target for it to work.

Code:
function contains(list: objects, check: object) :: boolean:
    loop {_list::*}:
        if loop-value is {_check}:
            return true
    return false

on armor equip:
    wait 10 ticks
    if "%lore of player's helmet%" contains "Undead":
        if "%lore of player's chestplate%" contains "Undead":
            if "%lore of player's leggings%" contains "Undead":
                if "%lore of player's boots%" contains "Undead":
                    add "%player%" to {_Undead::*}
                    send {_Undead::*} to player
                    send "&e&l(!) &r&eYou now have the &nUndead Set Bonus!&r &eRegular hostile mobs will no longer attack you." to player


on entity target:
    if entity's target is a player:
        if contains({_Undead::*}, "%player%") is true:
            send {_Undead::*} to player
            cancel event



on armor unequip:
    if "%lore of player's helmet%" contains "Undead":
        if "%lore of player's chestplate%" contains "Undead":
            if "%lore of player's leggings%" contains "Undead":
                if "%lore of player's boots%" contains "Undead":
                    remove "%player%" from {_Undead::*}
                    send {_Undead::*} to player
                    send "&c&l(!) &r&cYou no longer have the &e&nUndead Set Bonus!" to player

It seems like u don't understand or forgot about the difference of local and global variables.

A global variable looks like this:

{Undead::*}

a local variables looks like this:

{_Undead::*}


Global variables can be reached by any trigger/script on the server.

This isn't the case for local variables.

A local variable only remains available in that current trigger.

Triggers:
Function, Command, event

Example local vs global:

Code:
#Trigger 1
command /sethome:
    trigger:
        set {_home} to location of player
        set {home} to location of player
        send "local: %{_home}%" #returns location beeing set by any player
        send "global: %{home}%" #returns location beeing set by any player
#End trigger 1 local variables get dropped

#Trigger 2
command /home:
    trigger:
        send "local: %{_home}%" #returns <None>
        send "global: %{home}%" #returns location last beeing set by any player
#End trigger 2 local variables get dropped (wich is none bc none have been set)

A trigger is also only for that executer so if 2 players would execute it add the exact same time the local variable is still only available for that executer.

But using variables here is totaly not needed

Typing that now...
 
It seems like u don't understand or forgot about the difference of local and global variables.

A global variable looks like this:

{Undead::*}

a local variables looks like this:

{_Undead::*}


Global variables can be reached by any trigger/script on the server.

This isn't the case for local variables.

A local variable only remains available in that current trigger.

Triggers:
Function, Command, event

Example local vs global:

Code:
#Trigger 1
command /sethome:
    trigger:
        set {_home} to location of player
        set {home} to location of player
        send "local: %{_home}%" #returns location beeing set by any player
        send "global: %{home}%" #returns location beeing set by any player
#End trigger 1 local variables get dropped

#Trigger 2
command /home:
    trigger:
        send "local: %{_home}%" #returns <None>
        send "global: %{home}%" #returns location last beeing set by any player
#End trigger 2 local variables get dropped (wich is none bc none have been set)

A trigger is also only for that executer so if 2 players would execute it add the exact same time the local variable is still only available for that executer.

But using variables here is totaly not needed

Typing that now...
Thanks for the reply. How would I write this in a way where I dont have to use variables? Also, how would i make it so the mob could attack the player back when the player attacks the mob? Thanks again
 
Thanks for the reply. How would I write this in a way where I dont have to use variables? Also, how would i make it so the mob could attack the player back when the player attacks the mob? Thanks again

just so i know u happen to use sk-mirror?
[doublepost=1587027380,1587026394][/doublepost]
Thanks for the reply. How would I write this in a way where I dont have to use variables? Also, how would i make it so the mob could attack the player back when the player attacks the mob? Thanks again
Code:
function checkequipment(p: player) :: boolean:
    set {_items::*} to helmet of {_p}, chestplate of {_p}, leggings of {_p} and boots of {_p}
    loop {_items::*}:
        delete {_lores::*}
        set {_lores::*} to lore of loop-value
        loop {_lores::*}:
            if loop-value-2 contains "Undead":
                add 1 to {_undead}
                exit 1 loop
    if {_undead} >= 4:       
        return true
    return false

on join:
    delete {HitExcempt::%uuid of player%::*}

on quit:
    delete {HitExcempt::%uuid of player%::*}

on entity target:
    if target entity is a player:
        if {HitExcempt::%uuid of target entity%::%uuid of event-entity%} is not set:
            if checkequipment(target entity) = true:
                cancel event
        else:
            delete {HitExcempt::%uuid of target entity%::%uuid of event-entity%}
   
on damage:
    if {HitExcempt::%uuid of attacker%::%uuid of victim%} is not set:
        set {HitExcempt::%uuid of attacker%::%uuid of victim%} to true
        set target of victim to attacker
 
  • Like
Reactions: Skzen
Status
Not open for further replies.