[Need help] Attacker behind victim

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

Barbarx

Active Member
Feb 25, 2017
71
5
0
Hello. i wanted to create special damage from behind.
i found in http://skunity.com/search?search=behind something and i think i can create it but i dont know how can somebody help me? :emoji_grinning: i trying directions first time. Thanks for reading.
My idea:
code_language.skript:
On damage:
    if attacker is behind victim:
        set damage to damage  * 2
 
You can check the direction the attacker and the victim is looking. If the directions are the same the attacker is behind the victim (eg. NW = NW)
 
code_language.skript:
on damage of player:
    set {_loc} to location behind victim
    loop all entities in radius 3 around victim:
        if attacker is loop-entity:
            if distance between attacker and {_loc} <= 0.5:
                #This is your event
            stop #This is optional but speeds up checks
The 0.5 is a tight fit, they must be exactly in the block location behind the player. If you want a little bit of flexability I suggest changing the 0.5 to 1. Also I made it test if the victim was a player. You can remove on damage of player and change it back to on damage if you're checking entities.

Hope this helped. :emoji_slight_smile:
 
Status
Not open for further replies.