RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Dash Animation

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Dash Animation
Version: 1.0
Author: modern algebra
Date: August 11, 2008

Version History


  • <Version 1.0> Original Script

Description


This script allows you to set a dash sprite to your player character, so that when the player is dashing, the graphic changes to that new sprite.

Features

  • Automatically changes the graphic of the main character when dashing
  • Easy to customize which graphic it changes too - just the one with the same name as the current one with the addition of '_run' at the end of the name.

Screenshots

Not necessary or relevant as it is an action script.

Instructions

See inside script header.

Script


Code: [Select]
#==============================================================================
#  Dash Animation
#  Version 1.0
#  Author: modern algebra (rmrk.net)
#  Date: August 11, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to set a dash sprite to your player character, so
#   that when the player is dashing, the graphic changes to that new sprite.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    First, you will have to ensure that the character graphic you use for the
#   player must have a corresponding Character Set with the same name and _run
#   appended. So, if you are using the Character Set Actor1 for your main
#   character, you need to have his dash sprite in the corresponding index of
#   the graphic Actor1_run. It is necessary that a _run file exists for every
#   character that you will use as a lead character.
#
#    Simply scroll down to line 34 and set RUN_ANIM_SWITCH_ID to the ID of the
#   switch that you want to use as a toggle for this script. Then, to make it
#   so that your character set will change when you dash, all you need to do is
#   turn on that switch.
#==============================================================================
# ** Game_Character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new constant - RUN_ANIM_SWITCH_ID
#    aliased method - update_animation
#==============================================================================

class Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Constant
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  RUN_ANIM_SWITCH_ID = 1 # This sets a switch as a toggle for this script.
                         # A run animation will only be dispayed if the switch
                         # that you set is ON
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Animation
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_run_grphc_anim_upd_dash_rasta_md73 update_animation
  def update_animation
    # If the Switch is ON and
    if $game_switches[RUN_ANIM_SWITCH_ID]
      # Set a boolean to track when graphics are switched
      @chng_graf = true if @chng_graf.nil?
      if dash? # If dashing
        # Change Graphic once and only once
        if @chng_graf
          set_graphic (@character_name + "_run", @character_index)
        end
        @chng_graf = false
      elsif !@chng_graf # Change Graphic once and only once
        orig_name = @character_name[0, @character_name.size - 4]
        set_graphic (orig_name, @character_index)
        @chng_graf = true
      end
    end
    # Run Original Method
    modalg_run_grphc_anim_upd_dash_rasta_md73
  end
end

Credit


  • modern algebra

Support


Just post here for the swiftest response

Known Compatibility Issues

Not compatible with Composite Character Graphics script

Demo


Not necessary.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:44:57 PM by Modern Algebra »

**
Rep: +0/-0Level 84
hello, i was wondering will this script work with kylock's "8 dir movement + sprite support"?
and if it doesnt is there a way you can make it work with it?
if you'll be able to then it's awesome.

--Lomastul

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I do not know that script, however I would imagine the two would be compatible as long as his script requires all 8d to be on the same sprite sheet. If he switches sprite sheets too then it might be problematic.

You would of course need to make running animations for all directions.

**
Rep: +0/-0Level 84
here's the script bt kylock, and also a example sprite:
Spoiler for:
Code: [Select]
#==============================================================================
# 8 Way Directional Movement
#------------------------------------------------------------------------------
# Kylock
# 21.3.2008
# Version 1.1
#==============================================================================
# Special thanks to Arrow-1 for the script request and supplying sprites for
#   testing purposes.
#==============================================================================
# Instructions:
#    Add this script towards the top, since methods are rewritten and not
#      aliased.  Once you add it and run your game, the script will
#      automagically enable 8-way directional movement for your hero.
# Features:
#    * Added movement functionality to allow your hero to move in diagonal
#        directions
#    * Corrects directional issues resulting from trying to activate events
#        while facing a diaganol direction. (could be better implemented,
#        but does work as it is)
#==============================================================================
# Changelog
#   1.0 Initial Release
#   1.1 Added support for no custom sprites and added compatibility with
#         Anaryu's Anti-Lag script (must be loaded above the anti-lag script)
#==============================================================================

#==============================================================================
# ** Script Configuration
#==============================================================================
module KMDM
  DIRSPRITE = false          # set to true if you are using a custom
                             # character sprite for diagonal movement
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  rewrote def move_by-input to enable extra directions
#==============================================================================

class Game_Player < Game_Character
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
      when 1;  move_lower_left
      when 2;  move_down
      when 3;  move_lower_right
      when 4;  move_left
      when 7;  move_upper_left
      when 6;  move_right
      when 8;  move_up
      when 9;  move_upper_right
    end
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# Corrects direction so events will respond when hero is facing diagonal.
#  Modifies: def move_lower_left, def move_lower_right, def move_upper_left,
#            and def move_upper_right
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left(turn_ok = true)
    set_direction(5)
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      @x -= 1
      @y += 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right(turn_ok = true)
    set_direction(3)
    if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y+1))
      @x += 1
      @y += 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left(turn_ok = true)
    if KMDM::DIRSPRITE == true
      set_direction(7)
    else
      set_direction(8)
    end
    if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y-1))
      @x -= 1
      @y -= 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right(turn_ok = true)
    set_direction(9)
    if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y-1))
      @x += 1
      @y -= 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# Adds functionality for diagonal character sprites.
#  Modifies: def update_src_rect
#==============================================================================

class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Rectangle
  #--------------------------------------------------------------------------
  def update_src_rect
    if @tile_id == 0
      index = @character.character_index
      #if the character is facing diagonally, use the second spriteset
      if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
        index = @character.character_index + 1
      end
      pattern = @character.pattern < 3 ? @character.pattern : 1
      sx = (index % 4 * 3 + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
end

Spoiler for:

and here's a better example of it edited by me:

« Last Edit: October 18, 2008, 01:12:45 AM by lomastul »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, yeah, I imagine the two will work together. Why not just test them yourself?

**
Rep: +0/-0Level 84
umm... there is a problem with your script i think [or i hadnt activated it corretly]
it keeps updating making me to have to create infinite amount of spritesets:  it always ass "_run" to the name of the spriteset,
like if im useing a spriteset called "Actor5" and the running is "Actor5_run" so it says "unable to find graphic "Actor5_run_run" and so on and on no matter how many pic's i do.
can you fix it somehow?
« Last Edit: October 18, 2008, 01:25:49 AM by lomastul »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Odd.

I must've pasted in an incomplete version.

This:


      end
      @chng_graf = true

should've been:

        @chng_graf = true
      end

Replace what you have with:

Code: [Select]
#==============================================================================
#  Dash Animation
#  Version 1.0
#  Author: modern algebra (rmrk.net)
#  Date: August 11, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to set a dash sprite to your player character, so
#   that when the player is dashing, the graphic changes to that new sprite.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    First, you will have to ensure that the character graphic you use for the
#   player must have a corresponding Character Set with the same name and _run
#   appended. So, if you are using the Character Set Actor1 for your main
#   character, you need to have his dash sprite in the corresponding index of
#   the graphic Actor1_run. It is necessary that a _run file exists for every
#   character that you will use as a lead character.
#
#    Simply scroll down to line 34 and set RUN_ANIM_SWITCH_ID to the ID of the
#   switch that you want to use as a toggle for this script. Then, to make it
#   so that your character set will change when you dash, all you need to do is
#   turn on that switch.
#==============================================================================
# ** Game_Character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new constant - RUN_ANIM_SWITCH_ID
#    aliased method - update_animation
#==============================================================================

class Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Constant
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  RUN_ANIM_SWITCH_ID = 1 # This sets a switch as a toggle for this script.
                         # A run animation will only be dispayed if the switch
                         # that you set is ON
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Animation
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_run_grphc_anim_upd_dash_rasta_md73 update_animation
  def update_animation
    # If the Switch is ON and
    if $game_switches[RUN_ANIM_SWITCH_ID]
      # Set a boolean to track when graphics are switched
      @chng_graf = true if @chng_graf.nil?
      if dash? # If dashing
        # Change Graphic once and only once
        if @chng_graf
          set_graphic (@character_name + "_run", @character_index)
        end
        @chng_graf = false
      elsif !@chng_graf # Change Graphic once and only once
        orig_name = @character_name[0, @character_name.size - 4]
        set_graphic (orig_name, @character_index)
        @chng_graf = true
      end
    end
    # Run Original Method
    modalg_run_grphc_anim_upd_dash_rasta_md73
  end
end

**
Rep: +0/-0Level 84
thanks it's working now you are awesome :D

**
Rep:
Level 84
Hi i got a question, i am using your script but i would like to know if you could add support of the dashing to the caterpillar script. That way when ever another character in your party follows you, he or she will have a dashing animation too while the main character dashes. It would be great!

**
Rep:
Level 82
This is a super script and this 8 moving  :blizj: