Player : Dash
Version: 3.5
By: Kain Nobel
Introduction
This is a running (or "dashing" if we may) system, requested by Reon-Eclispe, which allows the player to dash for a designated period of time until they've depleted their stamina. The settings are instances of Game_Player::Dash, meaning you'll be able to modify, save and load them between game sessions.
I hate to say it but the settings are a bit touchy, you might want to experiment with whatever is suitable for your game. However, I'm sure you'll enjoy it once you get the hang of it!
Features
Script
Instructions
Place below SDK/MACL and above Main! Setup is handled by the constants in the top of the script, if you have any questions or are confused don't hesitate to ask! This script uses the following method from MACL's "RGSS.Bitmap.gradient" library...
Bitmap.draw_seph_gradient_bar
Compatibility
Requires SDK stuffs, you can easily alias Game_Player::Dash.enabled? to allow other scripts to disable this system. This script is compatable with my Vehicles XP system (which I haven't released yet.)
Please note, this will corrupt old save files.
Credits and Thanks
Thanks to Reon-Eclispe for making the request, it was fun and I enjoyed doing this one!
Terms and Conditions
Free to use in commercial and non-commercial projects, please credit me for my work!
Version: 3.5
By: Kain Nobel
Introduction
This is a running (or "dashing" if we may) system, requested by Reon-Eclispe, which allows the player to dash for a designated period of time until they've depleted their stamina. The settings are instances of Game_Player::Dash, meaning you'll be able to modify, save and load them between game sessions.
I hate to say it but the settings are a bit touchy, you might want to experiment with whatever is suitable for your game. However, I'm sure you'll enjoy it once you get the hang of it!
Features
- One-button running feature!
- Easy to setup and control!
- Customizable speeds for different movement phases
- Player can be exhausted from running too much
- Compatable with my Vehicles XP (not yet released)
- Probably other stuff I'm too lazy to list right now
Script
Player : Dash
Spoiler
- #===============================================================================
- # ** Player : Dash
- #===============================================================================
- #-------------------------------------------------------------------------------
- # * SDK Log
- #-------------------------------------------------------------------------------
- SDK.log('Player.Dash', 'Kain Nobel ©', 3.5, '2009.06.17')
- #-------------------------------------------------------------------------------
- # * SDK Enabled Test : Begin
- #-------------------------------------------------------------------------------
- if SDK.enabled?('Player.Dash')
- #===============================================================================
- # ** Game_Player::Dash
- #===============================================================================
- class Game_Player::Dash
- #-----------------------------------------------------------------------------
- # * Switch which disables the dash system and HUD
- #-----------------------------------------------------------------------------
- Switch_Disable = 1
- #-----------------------------------------------------------------------------
- # * Switch which disables exhaustion
- #-----------------------------------------------------------------------------
- Switch_Exhaust = 2
- #-----------------------------------------------------------------------------
- # * Maps which disable the dash system and HUD
- #-----------------------------------------------------------------------------
- Maps_Disabled = []
- #-----------------------------------------------------------------------------
- # * Scenes which don't display dash HUD (alternate scenes with Spriteset_Map)
- #-----------------------------------------------------------------------------
- Scenes_Disabled = true
- #-----------------------------------------------------------------------------
- # * Button used for Dashning
- #-----------------------------------------------------------------------------
- Button = Input::C
- #-----------------------------------------------------------------------------
- # * Public Instance Variables
- #-----------------------------------------------------------------------------
- attr_accessor :slow_speed
- attr_accessor :walk_speed
- attr_accessor :dash_speed
- attr_accessor :stamina
- attr_accessor :points
- #-----------------------------------------------------------------------------
- # * Object Initialization
- #-----------------------------------------------------------------------------
- def initialize
- @slow_speed = 3 # Speed for when player is exhausted
- @walk_speed = 3.5 # Speed for when player is walking
- @dash_speed = 5 # Speed for when player is dashing
- @stamina = 1 # Steps player can take while dashing
- @stamina_rate = 0.01 # Frames that stamina is replenished
- @exhersion = @stamina / 8 # At the point where player exhausted
- @points = @stamina # Sets points to stamina (don't touch)
- end
- #-----------------------------------------------------------------------------
- # * Enabled?
- #-----------------------------------------------------------------------------
- def enabled?
- return false if $game_switches[Switch_Disable]
- return false if Maps_Disabled[$game_map.map_id]
- if Scenes_Disabled == true
- return false unless $scene.is_a?(Scene_Map)
- else
- return false if Scenes_Disabled.include?($scene.class.to_s)
- end
- return true
- end
- #-----------------------------------------------------------------------------
- # * Increase Points
- #-----------------------------------------------------------------------------
- def increase_points(n)
- @points = [[@points + n, @stamina].min, 0].max
- end
- #-----------------------------------------------------------------------------
- # * Decrease Points
- #-----------------------------------------------------------------------------
- def decrease_points(n)
- increase_points(-n)
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- def update
- unless enabled?
- update_disabled
- return
- end
- @disabled = false
- if idle?
- update_idle
- return
- elsif exhausted?
- update_exhausted
- return
- elsif walking?
- update_walking
- return
- elsif dashing?
- update_dashing
- return
- end
- end
- #-----------------------------------------------------------------------------
- # * Update Disabled
- #-----------------------------------------------------------------------------
- def update_disabled
- unless @disabled
- $game_player.move_speed = (Game_Player.new).move_speed
- @disabled = true
- end
- end
- #-----------------------------------------------------------------------------
- # * Idle?
- #-----------------------------------------------------------------------------
- def idle?
- !$game_player.moving?
- end
- #-----------------------------------------------------------------------------
- # * Exhausted?
- #-----------------------------------------------------------------------------
- def exhausted?
- @exhausted && !$game_switches[Switch_Exhaust]
- end
- #-----------------------------------------------------------------------------
- # * Walking?
- #-----------------------------------------------------------------------------
- def walking?
- return true if $game_player.move_route_forcing
- $game_player.moving? && !Input.press?(Button)
- end
- #-----------------------------------------------------------------------------
- # * Dashing?
- #-----------------------------------------------------------------------------
- def dashing?
- return false if $game_system.map_interpreter.running?
- return false if $game_temp.message_window_showing
- return false if $game_player.move_route_forcing
- $game_player.moving? && Input.press?(Button)
- end
- #-----------------------------------------------------------------------------
- # * Update Idle
- #-----------------------------------------------------------------------------
- def update_idle
- increase_points(exhausted? ? @stamina_rate * 0.5 : @stamina_rate)
- if @points > (@exhersion)
- @exhausted = false
- end
- end
- #-----------------------------------------------------------------------------
- # * Update Exhausted
- #-----------------------------------------------------------------------------
- def update_exhausted
- $game_player.move_speed = @slow_speed
- increase_points(@stamina_rate * 0.5)
- if @points > (@exhersion)
- @exhausted = false
- end
- end
- #-----------------------------------------------------------------------------
- # * Update Walking
- #-----------------------------------------------------------------------------
- def update_walking
- $game_player.move_speed = @walk_speed
- increase_points(@stamina_rate * 0.5)
- end
- #-----------------------------------------------------------------------------
- # * Update Dashing
- #-----------------------------------------------------------------------------
- def update_dashing
- unless $game_player.move_speed == @dash_speed
- $game_player.move_speed += (@dash_speed * 0.1)
- return
- end
- decrease_points(@stamina_rate * 2)
- if @points.zero?
- @exhausted = true
- end
- end
- #-----------------------------------------------------------------------------
- # * Last Move
- #-----------------------------------------------------------------------------
- def last_move
- return 0 if idle?
- return 1 if exhausted?
- return 2 if walking?
- return 3 if dashing?
- end
- end
- #===============================================================================
- # ** Game_Player
- #===============================================================================
- class Game_Player < Game_Character
- #-----------------------------------------------------------------------------
- # * Public Instance Variables
- #-----------------------------------------------------------------------------
- attr_accessor :move_speed
- #-----------------------------------------------------------------------------
- # * Alias Listings
- #-----------------------------------------------------------------------------
- alias_method :dashsystem_gmplayer_updateplayermove, :update_player_movement
- #-----------------------------------------------------------------------------
- # * Dash
- #-----------------------------------------------------------------------------
- def dash
- @dash ||= Game_Player::Dash.new
- @dash
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- def update_player_movement
- dashsystem_gmplayer_updateplayermove
- @dash.update
- end
- end
- #===============================================================================
- # ** Window_DashStamina
- #===============================================================================
- class Window_DashStamina < Window_Base
- #-----------------------------------------------------------------------------
- # * Object Initialization
- #-----------------------------------------------------------------------------
- def initialize
- super(0, 416, 160, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.opacity = 0
- refresh
- end
- #-----------------------------------------------------------------------------
- # * Refresh
- #-----------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @points = $game_player.dash.points
- @last_move = $game_player.dash.last_move
- self.contents.draw_seph_gradient_bar(0, 0, @points,
- $game_player.dash.stamina, 128)
- if $game_player.dash.idle?
- color = ($game_player.dash.exhausted? ? Color.new(255,0,0) : normal_color)
- self.contents.font.color = color
- self.contents.draw_text(0, 0, 128, 32, "Idle", 1)
- elsif $game_player.dash.exhausted?
- self.contents.font.color = Color.new(255,0,0)
- self.contents.draw_text(0, 0, 128, 32, "Exhausted", 1)
- elsif $game_player.dash.walking?
- self.contents.font.color = normal_color
- self.contents.draw_text(0, 0, 128, 32, "Walking", 1)
- elsif $game_player.dash.dashing?
- self.contents.font.color = system_color
- self.contents.draw_text(0, 0, 128, 32, "Dashing", 1)
- end
- end
- #-----------------------------------------------------------------------------
- # * Update?
- #-----------------------------------------------------------------------------
- def update?
- need_update = false
- need_update |= $game_player.dash.points != @points
- need_update |= $game_player.dash.last_move != @last_move
- (need_update && Graphics.frame_count % 4 == 1)
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- def update
- self.visible = $game_player.dash.enabled?
- if update?
- refresh
- end
- end
- end
- #===============================================================================
- # ** Spriteset_Map
- #===============================================================================
- class Spriteset_Map
- #-----------------------------------------------------------------------------
- # * Alias Lisitngs
- #-----------------------------------------------------------------------------
- alias_method :dashsystem_ssmap_initialize, :initialize
- alias_method :dashsystem_ssmap_update, :update
- alias_method :dashsystem_ssmap_dispose, :dispose
- #-----------------------------------------------------------------------------
- # * Object Initialization
- #-----------------------------------------------------------------------------
- def initialize
- @window_dashstamina = Window_DashStamina.new
- dashsystem_ssmap_initialize
- end
- #-----------------------------------------------------------------------------
- # * Update
- #-----------------------------------------------------------------------------
- def update
- @window_dashstamina.update
- dashsystem_ssmap_update
- end
- #-----------------------------------------------------------------------------
- # * Dispose
- #-----------------------------------------------------------------------------
- def dispose
- @window_dashstamina.dispose
- dashsystem_ssmap_dispose
- end
- end
- #-------------------------------------------------------------------------------
- # * SDK Enabled Test : End
- #-------------------------------------------------------------------------------
- end
Expand to see the code.
Instructions
Place below SDK/MACL and above Main! Setup is handled by the constants in the top of the script, if you have any questions or are confused don't hesitate to ask! This script uses the following method from MACL's "RGSS.Bitmap.gradient" library...
Bitmap.draw_seph_gradient_bar
Compatibility
Requires SDK stuffs, you can easily alias Game_Player::Dash.enabled? to allow other scripts to disable this system. This script is compatable with my Vehicles XP system (which I haven't released yet.)
Please note, this will corrupt old save files.
Credits and Thanks
Thanks to Reon-Eclispe for making the request, it was fun and I enjoyed doing this one!
Terms and Conditions
Free to use in commercial and non-commercial projects, please credit me for my work!