eugene222

Dash Addon

Jul 22nd, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.75 KB | None | 0 0
  1. #===============================================================================
  2. # ** Dash Addon **
  3. #
  4. # Author:   Evgenij
  5. # Version:  1.0
  6. # Date:     20.07.2014
  7. #
  8. #===============================================================================
  9. # Description:
  10. #  With this small script it is possible to turn the dashing on and off with a
  11. #  scriptcall. You can also make no dash states. This means if an actor in the
  12. #  party have a no dash state the dashing will be also deactivated.
  13. #
  14. # Scriptcalls:
  15. #
  16. #  - dash_on                  # Turn on dashing
  17. #  - dash_off                 # Turn off dashing
  18. #
  19. #  - $game_player.real_dash?  # Returns true if the player is really dashing.
  20. #                             # The method .dash? returns already true when
  21. #                             # the player just hits the dash button.
  22. #                             # This new method checks if the player is moving
  23. #                             # also before returning true
  24. # State Notetags:
  25. #
  26. # <block_dash>   # blocks dash if any of the actors have this state.
  27. #
  28. #===============================================================================
  29. class RPG::State
  30.   #-----------------------------------------------------------------------------
  31.   def dash_blocked?
  32.     return @note.include?("<block_dash>")
  33.   end
  34.   #-----------------------------------------------------------------------------
  35. end
  36. #===============================================================================
  37. class Game_Actors
  38.   #-----------------------------------------------------------------------------
  39.   def any?(*args, &block)
  40.     @data.compact.any?(*args, &block)
  41.   end
  42.   #-----------------------------------------------------------------------------
  43. end
  44. #===============================================================================
  45. class Game_Player
  46.   attr_accessor   :dash_flag
  47.   #-----------------------------------------------------------------------------
  48.   alias :evg_gp_initialize_dash_addon   :initialize
  49.   #-----------------------------------------------------------------------------
  50.   def initialize
  51.     @dash_flag = true
  52.     evg_gp_initialize_dash_addon
  53.   end
  54.   #-----------------------------------------------------------------------------
  55.   alias :evg_gp_dash_addon        :dash?
  56.   #-----------------------------------------------------------------------------
  57.   def dash?
  58.     return evg_gp_dash_addon && @dash_flag && !no_dash_state?
  59.   end
  60.   #-----------------------------------------------------------------------------
  61.   def no_dash_state?
  62.     return $game_actors.any?(&:dash_blocked?)
  63.   end
  64.   #-----------------------------------------------------------------------------
  65.   def real_dash?
  66.     dash? && moving?
  67.   end
  68.   #-----------------------------------------------------------------------------
  69. end
  70. #===============================================================================
  71. class Game_Actor
  72.   #-----------------------------------------------------------------------------
  73.   def dash_blocked?
  74.     states.any?(&:dash_blocked?)
  75.   end
  76.   #-----------------------------------------------------------------------------
  77. end
  78. #===============================================================================
  79. class Game_Interpreter
  80.   #-----------------------------------------------------------------------------
  81.   def dash_on
  82.     $game_player.dash_flag = true
  83.   end
  84.   #-----------------------------------------------------------------------------
  85.   def dash_off
  86.     $game_player.dash_flag = false
  87.   end
  88.   #-----------------------------------------------------------------------------
  89. end
  90. #===============================================================================
  91. # SCRIPT END
  92. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment