Give Player Reach

Discussion in 'Skript' started by SteveRaft, Jan 19, 2020.

  1. Hello! I am currently attempting to code a troll plugin. One of the things I am planning to add is unlimited reach, but I do not know how to do so. If anybody can hint me or give me documentation relating to this, that would be great!
    • Agree Agree x 1
    • Useful Useful x 1
  2. How would I begin doing that? Sorry, I am a beginner at skripting.
  3. well, a simple way would be to use "target player" (that is like skript's built-in detection of at what entity you are looking at, but note that target player will ignore entities inbetween, so may be better to use "target entity") and then scan blocks between players to ensure that the player isn't behind blocks, you could also use skript-mirror and then use hasLineOfSight from spigot api, which may remove the need of block scanning for better performance
    • Like Like x 1
  4. Using the addon skript-mirror you could use this:
    The value "128" is the maximum distance you want for this raytrace. This value should not be higher than the render distance (render distance * 16), otherwise the raytrace might load chunks.
    Code (Text):

    on left click:
        set {_l} to event-player.getEyeLocation()
        set {_v} to vector from yaw {_l}.getYaw() and pitch {_l}.getPitch()

        set {_raytraceresult} to {_l}.getWorld().rayTrace({_l}, {_v}, 128, FluidCollisionMode.NEVER!, true, 0, null)
        set {_victim} to {_raytraceresult}.getHitEntity()
        {_victim} is set:
            {_victim} = a player # condition to check if victim is a player
            {_victim}.damage(10, event-player) #applies 10 damage to the hit player with event player as cause
    Overall this will shoot a raycast from the player's eyes in the exact direction the player is facing
    • Like Like x 1
    • Useful Useful x 1