Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Dash script help

Kelg

Member

The script itself works just fine, but I am requesting help to make it so that the dashing graphic only shows while the player is moving...

Super simple dash script by Brewmeister
#
# Super Simple Dash - V3
#
# Hold the "Z" key to make the player run
#
# paste in a new script above main
#
# Brewmeister - 12Jan09
# Zeriab - change Filetest to Cache.character to see if file exists.
# Seph - modify the attr_reader method character name instead of
# directly changing the instance variable. (safer)
#
# ADDED: Change character set when running.
# create a running character set. Add "_dash" to the filename.
# e.g. 001-Fighter01.png & 001-Fighter01_dash.png
# checks for file, so it will work without one.

class Game_Character
alias_method :brew_dashing_gmchr_cn, :character_name
def character_name
s = brew_dashing_gmchr_cn.to_s
s += '_dash' if dashing?
return s
end
def dashing?
return @dashing
end
end

class Game_Player

attr_accessor :current_speed

alias brew_dash_init initialize
alias brew_dash_update update

def initialize
@current_speed = 4
brew_dash_init
end

def update
if Input.press?(Input::A)
@move_speed = 5 #set the fast speed here
if @move_speed != @current_speed
#check to see if dash file exists
begin
# Check that the graphics for the new character name actually exists
RPG::Cache.character(@character_name + "_dash", 0)
# Change it now that we know it exists
@dashing = true
rescue
# The dash graphics does not exist.
end
@current_speed = @move_speed
end
else
@move_speed = 4 #set the normal speed here
if @move_speed != @current_speed
#remove _dash from the graphic name if it exists
@dashing = false
@current_speed = @move_speed
end
end
brew_dash_update
end
end

Also, is there a way to temporarily disable a script such as this?(For availability on certain maps, and so that it doesn't mess up event move routes.)
 
It seems (unless I missread your code) you systematically uses the dashing graphics each time the speed changes. Perhaps you should define the graphix used for each speed and pick the proper one each time the speed changes.

To disable a script map by map, I usually define an array of prohibited or allowed maps in a module or constant, and then test the inclusion to the current map before exiting the script or executing the main part.

EDIT : ooops... seems I missuderstood the questions. Perhaps you should test the moving? method and reset the graphics whennot moving (although I am not ABSOLUTELY certain of the meanig of the 'moving?' method)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top