TheoAllen

Theo - Double Tap Dash (ENG)

Aug 12th, 2013
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.08 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Double Tap Dash
  3. # Version : 1.1
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (English Documentation)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_DoubleTapDash] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.08.15 - Add option to keep shift as dash trigger
  12. # 2013.08.13 - Finished script
  13. # =============================================================================
  14. =begin
  15.  
  16.   Introduction :
  17.   This script will make dash activated by double tap instead of pressing shift.
  18.   In case if you want to use shift button for another thing
  19.  
  20.   Cara penggunaan :
  21.   Put the script below material but above main
  22.   Edit the configuration if necessary
  23.  
  24.   Terms of use :
  25.   Credit me, TheoAllen. You are free to edit this script by your own. As long
  26.   as you don't claim it yours. For commercial purpose, don't forget to give me
  27.   a free copy of the game.
  28.  
  29. =end
  30. # =============================================================================
  31. # Little Configuration :
  32. # =============================================================================
  33.  
  34.   DashDelay_Duration = 15
  35.   # Set double tap maximal delay duration here (60 = one second)
  36.  
  37.   KeepShift = true
  38.   # Set true if you still want to use shift as dash trigger
  39.  
  40. # =============================================================================
  41. # End of config. Do not touch anything pass this line or the risk is yours
  42. # =============================================================================
  43. class Game_Player < Game_Character
  44.  
  45.   alias theo_double_tap_init initialize
  46.   def initialize
  47.     theo_double_tap_init
  48.     init_tap_dash_member
  49.   end
  50.  
  51.   def init_tap_dash_member
  52.     @pending_dash = 0
  53.     @pending_dash2 = 0
  54.     @dash_delay = 0
  55.   end
  56.  
  57.   alias theo_double_tap_update update
  58.   def update
  59.     theo_double_tap_update
  60.     update_tap_dash
  61.   end
  62.  
  63.   def update_tap_dash
  64.     if !dash?
  65.       @dash_delay = [@dash_delay - 1,0].max
  66.     end
  67.     if (Input.dir4 == 0 && tap_dash?) || @dash_delay == 0
  68.       init_tap_dash_member
  69.     end
  70.     if input_arrow? && !dash_impossible? && !dash?
  71.       if @pending_dash == Input.dir4
  72.         @pending_dash2 = Input.dir4
  73.       else
  74.         @pending_dash = Input.dir4
  75.         @dash_delay = DashDelay_Duration
  76.       end
  77.     end
  78.   end
  79.  
  80.   def dash_impossible?
  81.     return @move_route_forcing || $game_map.disable_dash? || vehicle
  82.   end
  83.  
  84.   def input_arrow?
  85.     [:UP,:DOWN,:LEFT,:RIGHT].any? {|key| Input.trigger?(key)}
  86.   end
  87.  
  88.   def dash?
  89.     return false if @move_route_forcing
  90.     return false if $game_map.disable_dash?
  91.     return false if vehicle
  92.     return true if KeepShift ? Input.press?(:A) : false
  93.     return Input.dir4 != 0 && tap_dash?
  94.   end
  95.  
  96.   def tap_dash?
  97.     (@pending_dash2 == @pending_dash) && @pending_dash2 != 0
  98.   end
  99.  
  100. end
Advertisement
Add Comment
Please, Sign In to add comment