Paste #109851: bounce bomb script

Date: 2023/05/16 08:19:09 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


item_bounce_bomb:
    type: item
    material: slime_ball
    display name: <&6><bold>Bounce Bomb
    debug: false
    lore:
        - <&b>This bomb can't stop bouncing!
        - <&b>Consumed on use.

bounce_bomb_ability:
    type: world
    debug: false
    events:
        on player left clicks block with:item_bounce_bomb:
            - define player <player>
            - playsound <[player].location> sound:ENTITY_EGG_THROW volume:1 pitch:1
            - shoot snowball origin:<[player].eye_location> destination:<[player].eye_location.add[<[player].velocity.mul[10]>].forward[10]> speed:3 shooter:<[player]> spread:0 save:bounce_bomb_proj
            - run bounce_bomb_task def.entity:<entry[bounce_bomb_proj].shot_entity>


bounce_bomb_task:
    type: task
    debug: false
    definitions: entity
    script:
        - adjust <[entity]> item:slime_ball
        - while <[entity].is_truthy>:
            - define velocity:<[entity].velocity>
            - define location:<[entity].location>
            - define forward:<[location].add[<[velocity]>]>
            - look <[entity]> <[location].add[<[velocity].mul[100]>]>
            - define location:<[entity].location>
            - wait 1t
            - playeffect effect:sneeze at:<[location]> visibility:200 quantity:5 offset:0.3
        - if <[location].y> < -128:
            - stop
        - if <[velocity].vector_length> < 0.6:
            - playeffect effect:EXPLOSION_HUGE at:<[location]> visibility:200 quantity:10 offset:2
            - explode power:5 location:<[location]>
            - stop
        - playsound <[location]> sound:BLOCK_SLIME_BLOCK_FALL volume:1 pitch:1
        - playeffect effect:slime at:<[location]> visibility:100 offset:0.3 quantity:100
        - define hit <[location].ray_trace[return=normal]||null>
        - repeat 2 as:i:
            - repeat 2 as:j:
                - define hit:->:<[location].rotate_pitch[<[i].mul[8].sub[12]>].rotate_yaw[<[j].mul[8].sub[12]>].ray_trace[return=normal]||null>
        - define velocity_y <[velocity].y>
        - define hit <[hit].exclude[null]>
        - foreach <[hit]> as:i:
            - define list:->:<[hit].count[<[i]>]>
        - define highest:<[list].highest>
        - foreach <[list]> as:i:
            - if <[i]> == <[highest]>:
                - define hit:<[hit].get[<[i]>]>
                - foreach stop
            - else:
                - foreach next
        - if <[hit].x.abs> > 0:
            - define velocity <[velocity].rotate_around_z[180]>
            - define velocity <[velocity].with_y[<[velocity_y]>]>
        - else if <[hit].z.abs> > 0:
            - define velocity <[velocity].rotate_around_x[180]>
            - define velocity <[velocity].with_y[<[velocity_y]>]>
        - else if <[hit].y.abs> > 0:
            - define velocity <[velocity].with_y[<[velocity].y.mul[-1]>]>

        - spawn snowball origin:<[location]> save:bounce_bomb_proj
        - define entity <entry[bounce_bomb_proj].spawned_entity>
        - adjust <[entity]> item:slime_ball
        - adjust <[entity]> velocity:<[velocity].mul[0.75]>
        - run bounce_bomb_task def.entity:<[entity]>