Paste #117436: My Script

Date: 2023/11/11 09:27:03 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#The problem with the script now is that when a player takes damage multiple times, multiple while loops affect the player.
#Things can get pretty scary, and the player can be launched like a missile.

OnDamageEvent:
  type: world
  debug: false
  events:
    on player damaged:
#DamageFlagPart
      - flag <player> GetDamagedin5s expire:5s
      - inject ElytraDamagedSlowDown if:<player.gliding>

StartGlidingCheck:
  type: world
  debug: false
  events:
    after player starts gliding:
    - inject ElytraDamagedSlowDown

ElytraDamagedSlowDown:
  type: task
  debug: false
  script:
  - define reduction 0.5
  - while <player.gliding.if_null[false]> && <player.has_flag[GetDamagedin5s].if_null[false]>:
    - define total_velocity <player.velocity.x.abs.add[<player.velocity.y.abs>].add[<player.velocity.z.abs>]>
    - define reduction <[reduction].add[0.005]>
    - if <[total_velocity]> >= <[reduction]>:
      - adjust <player> velocity:<player.velocity.mul[<[reduction]>]>
    - wait 1t