Paste #12330: Edit of P#12318 Double Jump

Date: 2014/12/28 16:39:05 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
#                           D o u b l e   J u m p e r                          |
#                                                                              |
#                       Let your players do double jumps                       |
#                                                                              |
#                                                                              |
#   Author: |Anthony|                                                          |
#   Version: 0.2                                                               |
#   dScript Version: 0.9.6-b1546                                               |
#                                                                              |
# ---------------------------------------------------------------------------- #
#                                                                              |
#                                                                              |
# ABOUT:                                                                       |
#                                                                              |
#       Players will be able to do double jumps. You can set a flag to let     |
#     some folks actually fly.                                                 |
#     - flag <player> fly_enabled                                              |
#                                                                              |
#                                                                              |
# ---------------------------------------------------------------------------- #

DoubleJump:
  type: world
  debug: false
  speed: 0
  events:
    on player joins:
    - wait 1t
    - adjust <player> can_fly:true

    on player changes gamemode:
    - wait 1t
    - adjust <player> can_fly:true

    on player walks:
    - if <c.new_location.y.is[LESS].than[<c.old_location.y>]||false> {
#      - narrate "Down"
      - if <c.new_location.sub[0,0.1,0].material.is_solid||false> {
        - queue clear
        }
      - if <player.has_flag[falling]||false> {
        - queue clear
        }
      - flag <player> falling:<c.old_location>
      - if <player.has_flag[jumping]||false> {
        - event "player jump|player stops jumping" context:state|stop|to_location|<c.old_location>|from_location|<player.flag[jumping]>
        - flag <player> jumping:!
        }
      - event "player fall|player starts falling" context:state|start|from_location|<c.old_location>
      - while <player.location.sub[0,0.1,0].material.is_solid.not||false> {
        - if <player.is_online.not> {
          - while stop
          }
        - wait 1t
        }
      - event "player fall|player stops falling" context:state|stop|to_location|<player.location.simple.as_location>|from_location|<player.flag[falling].as_location>
      - flag <player> falling:!
      - queue clear
      }

    - if <c.new_location.y.is[MORE].than[<c.old_location.y>]||false> {
#      - narrate "Up"
      - if <c.new_location.y.sub[<c.old_location.y>].is[==].to[0.5]> {
        - queue clear
        }
      - if <c.new_location.sub[0,0.1,0].material.is_solid||false> {
        - queue clear
        }
      - if <player.has_flag[jumping]||false> {
        - queue clear
        }
      - if <player.has_flag[falling]||false> {
        - queue clear
        }
      - flag <player> jumping:<c.old_location>
      - event "player jump|player starts jumping" context:state|start|from_location|<c.old_location>
      - queue clear
      }


    on player stops falling:
      - define fallDistance '<c.from_location.y.sub[<c.to_location.y>]||0>'
      - if <player.has_flag[launched]||false> {
        - queue clear
        }
      - if <player.has_flag[doublejump]> {
        - adjust <player> can_fly:false
        - adjust <player> 'fall_distance:<def[fallDistance].mul[0.70].sub[3]>'
        - wait 1t
        - adjust <player> can_fly:true
        - flag player doublejump:!
        }
        else {
        - adjust <player> can_fly:false
        - adjust <player> 'fall_distance:%fallDistance%'
        - wait 1t
        - adjust <player> can_fly:true
        }


    on player starts flying:
    - if <player.has_flag[doublejump]> {
      - determine CANCELLED
      }
    - if <player.has_flag[fly_enabled]||false>
      || <player.gamemode.id.is[==].to[1]> {
      - queue clear
      }
    - flag player doublejump
    - shoot <player> 'o:<player>' 'destination:<player.location.cursor_on[<player.flag[double_jump_multiplier].as_int||10>]>' no_rotate
    - wait 5t
    - adjust <player> can_fly:false
    - adjust <player> 'fall_distance:0'
    - wait 5t
    - adjust <player> can_fly:true

#