TheoAllen

Theo - Double Tap Dash (ENG)

May 8th, 2014
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.11 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 Language)
  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 allow you to activate running by double tap instead of shift
  18.   if you want to use shift for another function. However, you still could
  19.   keep the shift dash function
  20.  
  21.   How to use :
  22.   Put this script below material but above main
  23.   Edit the configuration if necessary
  24.  
  25.   Terms of use :
  26.   Credit me, TheoAllen. You are free to edit this script by your own. As long
  27.   as you don't claim it yours. For commercial purpose, don't forget to give me
  28.   a free copy of the game.
  29.  
  30. =end
  31. # =============================================================================
  32. # A few configurations
  33. # =============================================================================
  34.  
  35.   DashDelay_Duration = 60
  36.   # Set the maximum delay for double tap dash (entering 60 means 1 second)
  37.  
  38.   KeepShift = true
  39.   # Set to true if you still want to enable shift-dash
  40.  
  41. # =============================================================================
  42. # End of configurations. Editing below this line is your risk
  43. # =============================================================================
  44. class Game_Player < Game_Character
  45.  
  46.   alias theo_double_tap_init initialize
  47.   def initialize
  48.     theo_double_tap_init
  49.     init_tap_dash_member
  50.   end
  51.  
  52.   def init_tap_dash_member
  53.     @pending_dash = 0
  54.     @pending_dash2 = 0
  55.     @dash_delay = 0
  56.   end
  57.  
  58.   alias theo_double_tap_update update
  59.   def update
  60.     theo_double_tap_update
  61.     update_tap_dash
  62.   end
  63.  
  64.   def update_tap_dash
  65.     if !dash?
  66.       @dash_delay = [@dash_delay - 1,0].max
  67.     end
  68.     if (Input.dir4 == 0 && tap_dash?) || @dash_delay == 0
  69.       init_tap_dash_member
  70.     end
  71.     if input_arrow? && !dash_impossible? && !dash?
  72.       if @pending_dash == Input.dir4
  73.         @pending_dash2 = Input.dir4
  74.       else
  75.         @pending_dash = Input.dir4
  76.         @dash_delay = DashDelay_Duration
  77.       end
  78.     end
  79.   end
  80.  
  81.   def dash_impossible?
  82.     return @move_route_forcing || $game_map.disable_dash? || vehicle
  83.   end
  84.  
  85.   def input_arrow?
  86.     [:UP,:DOWN,:LEFT,:RIGHT].any? {|key| Input.trigger?(key)}
  87.   end
  88.  
  89.   def dash?
  90.     return false if @move_route_forcing
  91.     return false if $game_map.disable_dash?
  92.     return false if vehicle
  93.     return true if KeepShift ? Input.press?(:A) : false
  94.     return (Input.dir4 != 0 && tap_dash?)
  95.   end
  96.  
  97.   def tap_dash?
  98.     (@pending_dash2 == @pending_dash) && @pending_dash2 != 0
  99.   end
  100.  
  101. end
Advertisement
Add Comment
Please, Sign In to add comment