Paste #64572: High velocity damaging - By Soup Can#1789

Date: 2020/01/25 18:14:49 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


highvelocityhurting:
  type: world
  events:
    on player walks:
    # Definitions
    - define world:<player.location.world.name>
    - define velocityflag:<player.flag[velocity]>

    - define velocityx:<[velocityflag].x>
    - define velocityx2:<[velocityx].round_to[3]>

    - define velocityy:<[velocityflag].y.mul[0.37]>
    - define velocityy2:<[velocityy].round_to[3]>

    - define velocityz:<[velocityflag].z>
    - define velocityz2:<[velocityz].round_to[3]>

    - define velocity:<[velocityx]>,<[velocityy]>,<[velocityz]>,<[world]>
    - define velocityAdditions:<[velocityx].add[<[velocityy].add[<[velocityz]>]>]>
    - define velocityTotal:<[velocityx].add[<[velocityy].add[<[velocityz]>]>].abs>

    # Speed references:
    # < > Walking: 0.367 (x/z)
    # ^ v Three blocks fall: 0.614 (y)
    # << >> Running: 0.477  (x/z)
    # ^ v 30 blocks fall: 1.825 (y)
    # Knockback 5: 1.XXX for x,y,z
    # Sprint and jump: 0.6XX

    # Formula for damage:
    # If kb 5 should be 3.5 damage (1.XXX) and v = velocity:
    # v*3.5
    # But, checking if the velocity total is higher than 1

    # Define damage and entities near
    - define damage:<[velocitytotal].mul[3.5]>
    - define entities:<player.location.find.entities.within[1.18].exclude[<player>].filter[is_living]>
    # Actual script:
    - if <[velocitytotal]> >= 1 && <[entities].size> > 0:
      - hurt <[entities]> <[damage]> source:<player>
      - hurt <player> <[damage]> source:<player.location.find.entities.within[1.08].first||<player>>

    #-Test Messages-#
    #- actionbar targets:<player> "<[velocity]>"
    #- actionbar targets:<player> "<[velocityy2]>"
    #- actionbar targets:<player> "<[velocityx2]>"
    #- actionbar targets:<player> "<[velocityz2]>"
    #- actionbar targets:<player> "<[velocitytotal]>"
    #- actionbar targets:<player> "<[entities].size>"
    #- if <[velocitytotal]> >= 1.05:
    #  - actionbar targets:<player> "<&4>High <[velocitytotal]>"
    #- else:
    #  - actionbar targets:<player> "<&b>Low <[velocitytotal]>"