Paste #64575: Fall damage - by Soup Can#1789

Date: 2020/01/25 18:19:17 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


FallDamage:
  type: world
  debug: false
  events:
    on player walks:
    - define falldamage:<player.fall_distance.mul[1.25]>
    - define crushedentities:<context.new_location.find.entities.within[1.32].exclude[<player>]>
    - define crushedentities2:<player.location.find.entities.within[1.85].exclude[<player>]>
    #- actionbar <[falldamage]>

    - if <player.fall_distance> >= 4:
      - if <player.location.find.entities.within[1].size> >= 2 && <player.location.find.entities.within[1].size> < 98:
        - flag <player> squishing duration:1s
        - hurt <[falldamage]> <[crushedentities]> source:<player>
      - if <player.fall_distance> >= 98:
        - burn <player> duration:50t
        - flag <player> squishing duration:1s
        - hurt <[falldamage]> <[crushedentities2]> source:<player>
        - burn <[crushedentities2]> duration:50t
    on entity damaged by fall:
    - define falldamage:<context.entity.fall_distance.mul[1.25]>
    - define crushedentities:<context.entity.location.find.entities.within[1.32].exclude[<context.entity>]>
    - define crushedentities2:<context.entity.location.find.entities.within[1.85].exclude[<context.entity>]>
    #- actionbar <[falldamage]>

    - if <context.entity.fall_distance> >= 4:
      - if <context.entity.location.find.entities.within[1].size> >= 2 && <context.entity.location.find.entities.within[1].size> < 98:
        - flag <context.entity> squishing duration:1s
        - hurt <[falldamage]> <[crushedentities]> source:<context.entity>
      - if <context.entity.fall_distance> >= 98:
        - burn <context.entity> duration:250t
        - flag <context.entity> squishing duration:1s
        - hurt <[falldamage]> <[crushedentities2]> source:<context.entity>
        - burn <[crushedentities2]> duration:250t

    on entity dies:
    - if <context.cause||null> == ENTITY_ATTACK && <context.damager.has_flag[squishing]||false> != false:
      #- announce yeet
      - flag <player> squishing:!
      #- announce "<&d><context.entity.name> was squished by <context.damager.name>"
      - determine "<context.entity.name> was squished by <context.damager.name>"