Paste #105488: Unnamed Denizen Script Paste

Date: 2023/01/18 09:08:10 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


shot_testgun:
    type: world
    events:
        on player right clicks block with:testgun:
            - define start_location <player.eye_location>
            - define target_location <[start_location].ray_trace[range=60;entities=*;ignore=<player>;fluids=true;nonsolids=true;default=air]>
            - playeffect effect:redstone at:<[start_location].points_between[<[target_location]>].distance[0.5]> quantity:1 offset:0 visibility:100 special_data:1|<red>
            - playsound sound:entity_firework_rocket_blast pitch:0 at:<[start_location]> effect:crit offset:0 visibility:1 volume:1
            - inject beshot_testgun
            - inject recoil
            - determine cancelled

beshot_testgun:
    type: task
    script:
        - define hit_location <player.precise_target_position.y>
        - define target <player.precise_target[60]>
        - if <[hit_location]> >= <player.target.eye_location.y.sub[0.05]> && <[hit_location]> <= <player.target.eye_location.y.add[0.70]>:
          - hurt 100 <[target]> source:<player>
        - else if <[hit_location]> <= <player.target.eye_location.y.sub[1.4]> && <[hit_location]> <= <player.target.eye_location.y.add[0.70]>:
          - hurt 1 <[target]> source:<player>
        - else:
          - hurt 10 <[target]> source:<player>

recoil:
    type: task
    script:
        - if <player.is_sneaking>:
          - define recoil <player.eye_location.forward[1000].up[<util.random.int[1].to[5]>].left[<util.random.int[-5].to[5]>]>
        - else:
          - define recoil <player.eye_location.forward[100].up[<util.random.int[1].to[5]>].left[<util.random.int[-5].to[5]>]>
        - look recoil



testgun:
    type: item
    material: wooden_hoe
    display name: <green>TestGun
    flags:
        gun:
            headdamage: 100
            bodydamage: 10
            feetdamage: 1
            range: 60
            maxbullet: 30
            currentbullet: 30
            recoil: 100
            sneakrecoil: 1000
            reloadrate: 2
            fireraterate: 0.3