Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> [RMXP] StandWalkRun, Conversion of the RMVX Version
Ty
post Jul 16 2011, 10:32 PM
Post #1


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




Note: This is a two-minute conversion of the RMVX script of the same name.

Script Name: Stand/Walk/Run
Written By: Synthesize
Current Version: V.2.50 Final
RMVX Release Date: January 26, 2008
RMXP Release Date: July 17, 2011


What is this script?
This script adds running, idle animations, running animations and stamina to your projects. You run by pressing the 'A' key (By default, Shift), and your running time is limited by the amount of Run points, or Stamina you have.

Features:
- Allows you to have running animations
- Allows you to have idle animations
- Allows you to specify the time before the actor goes idle
- Allows you to have run points
- Allows you to customize how many run points are restored
- Turn everything ON/OFF

Can I increase/decrease/set my Stamina in-game?
Yes, simply use the following in a Call Script event command: $game_player.max_run_points += #
Where # is the value you wish to increase the max points by.

CODE

#===============================================================================
# Stand/Walk/Run Script --- RMXP Version
#===============================================================================
# Written by Synthesize
# Version 2.50
# January 26, 2008 (v1)
#     Revised: March 1, 2008 (v2)
#     Revised: September 4, 2010 (v2.5)
#===============================================================================
# Customization
#-------------------------------------------------------------------------------
module StandWalkRun
  Use_run = true   # Use Run Points?
  Use_run_sprite = true    # Use a Running sprite?
  Run_speed = 5   # Player speed while running
  Walk_speed = 4  # Player speed while walking
  Run_sprite_suffix = '_run'   # Running Sprite Suffix
  Run_points = 100   # The maximum amount of Run Points
  Run_points_restore = 20   # 1 Run Point is restored in X Frames
  Restore_run_while_walking = true   # Restore points while walking?
  Use_idle_sprite = true   # Use Idle Sprite?
  Idle_sprite_suffix = '_idle'   # idle Sprite Suffix
  Use_anime = true   # Animate your Idle Sprite?
  Idle_time = 240    # Time before sprite is animated
end
#-------------------------------------------------------------------------------
# Scene_Map:: The main functions of the script are here
#-------------------------------------------------------------------------------
class Scene_Map
  # Aliases
  alias syn_map_update update
  #-----------------------------------------------------------------------------
  # Initiate variables
  #-----------------------------------------------------------------------------
  def initialize
    if $game_player.old_character_name == nil
     $game_player.old_character_name = $game_player.character_name
    end
    @wait_time = 0
    @wait_time2 = 0
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #-----------------------------------------------------------------------------
  def update
    syn_map_update
    if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
      if $game_player.move_route_forcing == false
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"
      end
      restore_run if StandWalkRun::Use_run
      else
      $game_temp.syn_state = ""
      restore_run if StandWalkRun::Restore_run_while_walking
      call_idle($game_player.old_character_name, false) if $game_player.character_name != $game_player.old_character_name
      @wait_time = 0
      end
      if $game_temp.sprite_changed == true
      $game_player.old_character_name = $game_player.character_name
      $game_temp.sprite_changed = false
      end
    end
  #-----------------------------------------------------------------------------
  # Call_Idle:: Sets and animates the idle Sprite
  #-----------------------------------------------------------------------------
  def call_idle(sprite, anime)
    $game_player.set_step_anime(anime)
    $game_player.set_graphic(sprite)
  end
  #-----------------------------------------------------------------------------
  # Restore_Run: Restore Run Points
  #-----------------------------------------------------------------------------
  def restore_run
    if $game_player.run_points < $game_player.max_run_points
      wait(1, true)
      $game_player.run_points += 1 if @wait_time2 == StandWalkRun::Run_points_restore
      @wait_time2 = 0 if @wait_time2 == StandWalkRun::Run_points_restore
    end
  end
  #-----------------------------------------------------------------------------
  # Wait:: Allows Wait Times
  #-----------------------------------------------------------------------------
  def wait(duration, value)
    for i in 0...duration
      @wait_time += 1 if value == false
      @wait_time2 += 1 if value
      break if i >= duration / 2
    end
  end
end  
#-------------------------------------------------------------------------------
# Game_Temp:: Create current state
#-------------------------------------------------------------------------------
class Game_Temp
  attr_accessor :syn_state
  attr_accessor :sprite_changed
  alias syn_temp_init initialize
  def initialize
    @syn_state = ""
    @sprite_changed = false
    syn_temp_init
  end
end
#-------------------------------------------------------------------------------
# Game_Character:: Create the Change_Sprite method
#-------------------------------------------------------------------------------
class Game_Character
  # Attr(s)
  attr_accessor :old_character_name
  attr_accessor :run_points
  attr_accessor :max_run_points
  alias syn_ch_init initialize
  #-----------------------------------------------------------------------------
  # Initialize Variables
  #-----------------------------------------------------------------------------
  def initialize
    @run_points = StandWalkRun::Run_points
    @max_run_points = @run_points
    syn_ch_init
  end
  #-----------------------------------------------------------------------------
  # Set Setp Animation
  #-----------------------------------------------------------------------------
  def set_step_anime(value)
    @step_anime = value
    return @step_anime
  end
end
#-------------------------------------------------------------------------------
# Game_Player:: This handles the dash process
#-------------------------------------------------------------------------------
class Game_Player < Game_Character
  alias syn_player_update update
  def dash?
    return false if @run_points == 0 and StandWalkRun::Use_run
    return true if Input.press?(Input::A)
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #----------------------------------------------------------------------------
  def update
    if dash?
      if Input.dir4 == 0
        $game_player.set_graphic($game_player.old_character_name)
      end
      unless $game_temp.syn_state == "idle"
        set_graphic(@character_name + StandWalkRun::Run_sprite_suffix) if StandWalkRun::Use_run_sprite
        @move_speed = StandWalkRun::Run_speed
        @run_points -= 1
        syn_player_update
      end
    else
      @move_speed = StandWalkRun::Walk_speed
      syn_player_update
    end
  end
  def set_graphic(character_name)
    @tile_id = 0
    @character_name = character_name
  end
end
#-------------------------------------------------------------------------------
#            * This script is not compatible with RPG Maker XP *
#-------------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# Requested by Cerulean Sky
#===============================================================================
# Stand/Walk/Run   - RMXP Version
#===============================================================================


DEMO: (Slightly Outdated, copy/paste script above)
http://www.4shared.com/file/7puHxTuv/StandWalkRun.html


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
Biohazard
post Jul 20 2011, 10:25 AM
Post #2


Level 3
Group Icon

Group: Member
Posts: 42
Type: Writer
RM Skill: Skilled




Awesome script. I think I'll swap this in place of my eventing I did for my game to clean it up a bit, plus it let's me use an idle animation, which would be annoying to do through eventing if I had thought about it before this came out. Thanks =)

This post has been edited by Biohazard: Jul 20 2011, 10:26 AM


__________________________
I.R.S.: We've got what it takes to take what you've got!


Go to the top of the page
 
+Quote Post
   
neiljwd
post Jul 24 2011, 09:23 AM
Post #3


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




Hey I'm trying to download the demo, unfortunately the D/L is always a zero byte file, so er, no good.
Any fix?

The reason I wanted the demo is because The script wants some run graphic, I er don't know if I have any.


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
Yusshin
post Jul 24 2011, 01:42 PM
Post #4


In'shallah !
Group Icon

Group: Revolutionary
Posts: 282
Type: Writer
RM Skill: Beginner




I get a syntax error on Line 2 :S how do I fix it?

Only other scripts I have are The Law G14's equipment, skill, start, save, and item menus.


__________________________
Go to the top of the page
 
+Quote Post
   
neiljwd
post Jul 25 2011, 09:24 AM
Post #5


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




IS there a way to make this work in unison with mouse control?

http://www.fileden.com/files/2008/10/3/212...Demo/Mousie.zip

Currently if I put the this page's Run script above mousie scripts, then u can' run.
If you put it below the mouse script, then you can run... but only with the keyboard.

Pressing the run key jsut like, pauses the run you've set with your mouse click.


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
MarkHest
post Jul 27 2011, 03:22 PM
Post #6


Level 1
Group Icon

Group: Member
Posts: 11
Type: Musician
RM Skill: Skilled




I found an annoying bug with this (well, not a bug.. more a miss in the script happy.gif)

Whenever you use the "Move Route" event commant, the charakter moves around in its idle stance. (Makes the cutscenes look kinda awkward)

Is there a way to fix this? laugh.gif

This post has been edited by MarkHest: Jul 27 2011, 03:26 PM


__________________________
Video Game Music Composer
Go to the top of the page
 
+Quote Post
   
Ty
post Jul 27 2011, 04:38 PM
Post #7


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




QUOTE (neiljwd @ Jul 24 2011, 11:23 AM) *
Hey I'm trying to download the demo, unfortunately the D/L is always a zero byte file, so er, no good.
Any fix?

The reason I wanted the demo is because The script wants some run graphic, I er don't know if I have any.


The run file is simply a copy/pasted spritesheet I did, then added '_run' to the file name.
Example:
Actor1-01_run.png -- Will be the run file for the 'Actor1-01' graphic.

QUOTE (Yusshin @ Jul 24 2011, 03:42 PM) *
I get a syntax error on Line 2 :S how do I fix it?

Only other scripts I have are The Law G14's equipment, skill, start, save, and item menus.


It seems the code formatting got messed up when I posted it. Delete all of the lines at the TOP and BOTTOM of the script that look like this:
==============
Keep the ones that look like: (Note the '#')
#=============


QUOTE (neiljwd @ Jul 25 2011, 11:24 AM) *
IS there a way to make this work in unison with mouse control?

http://www.fileden.com/files/2008/10/3/212...Demo/Mousie.zip

Currently if I put the this page's Run script above mousie scripts, then u can' run.
If you put it below the mouse script, then you can run... but only with the keyboard.

Pressing the run key jsut like, pauses the run you've set with your mouse click.


The download link is broken, but you would have to modify how running works a bit. From lines 46 to 63 in 'def update' you will have to add a check to see if a mouse button is being pressed, and then enable running.

QUOTE (MarkHest @ Jul 27 2011, 05:22 PM) *
I found an annoying bug with this (well, not a bug.. more a miss in the script happy.gif )

Whenever you use the "Move Route" event commant, the charakter moves around in its idle stance. (Makes the cutscenes look kinda awkward)

Is there a way to fix this? laugh.gif


lol, I totally forgot about the move route command :V I added a fix to this. Copy/Paste the new script posted in the Original Post or just find this:
CODE
if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"

Replace with:
CODE
if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
      if $game_player.move_route_forcing == false
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"
      end


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
MarkHest
post Jul 28 2011, 05:48 AM
Post #8


Level 1
Group Icon

Group: Member
Posts: 11
Type: Musician
RM Skill: Skilled




It still didn't work for me O_o

I replaced the line in the script and the charakter still moves in idle state when using the Move Route command :S

Uppdate: It works if i the Event Command triggers before the sprite changes to the "_idle" sprite.

Maybe a code should be input to change back to the original sprite when using Move Route and then goes back to the _idle one when the Move Route is finnished. [Though i can't script so sorry if that sounded wrong, just thought it might be a solusion smile.gif]

Uppdate2: Or maybe turn off the _idle sprite when using the Move Route and then change back when the Move Route is finnished ^^

This post has been edited by MarkHest: Jul 28 2011, 06:07 AM


__________________________
Video Game Music Composer
Go to the top of the page
 
+Quote Post
   
Ty
post Jul 28 2011, 06:24 AM
Post #9


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




Find this line:
if $game_player.move_route_forcing == false
Change to something like:
if $game_player.move_route_forcing == false && $game_switches[switch_id]

Replace 'switch_id' with the ID value of an In-game switch, and that should solve the problem (Too lazy to add in a separate variable atm, will later, sleepy)


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
MarkHest
post Jul 28 2011, 08:19 AM
Post #10


Level 1
Group Icon

Group: Member
Posts: 11
Type: Musician
RM Skill: Skilled




Haha, still didn't solve a thing xD

I'll just be patient and wait for the fix later, no rush ^^


EDIT: Found another bug... this one shuts the game down.
If Idle is swiched on and you opens up the menu when your charakter stands in the "Idle" sprite the game will crash when you close the menu saying: Cannot find "sprite name"_Idle_Idle

It looks for another "_idle" after the first "_Idle"...

What chould be the cause of this?

This doesn't happen in your demo so i'm kinda confused.. i even tried it on different projects with both separate scripts and same scripts... still i get the error.


EDIT2: Actualy it DID happen in the demo as well. If you wait for your sprite to become the animeted sprite in the demo then opens the menu and then close it, then wait 250 frames the error will show up.

Apparently, making the Wait Time for the Sprite to show up shorter will make the error show up faster the more you wait after closing the menu.
Strange error... I have 10 frames untill the Idle sprite shows up in my game so i get the error instant after closing the menu.

And if you make the wait time longer and manages to open up the menu again before the error comes it will later if you wait after closing the menu say:

-Cannot find "SpriteName"_idle_idle_idle-

biggrin.gif


EDIT 3: I found ANOTHER bug.
This bug will not alow you to adjust the movement speed of your charakter. It's speed is "4(fast)" no matter what you do :/

This post has been edited by MarkHest: Jul 31 2011, 02:26 PM


__________________________
Video Game Music Composer
Go to the top of the page
 
+Quote Post
   
neiljwd
post Aug 1 2011, 04:42 AM
Post #11


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




Thanks for the reply TY.
I've zero scripting abilities so I'll hold off a while trying that myself. Maybe as the project nears completion its a thing I'll have to to devote to smile.gif
Unsure why the D/L doesn't work for you, it's off off this page http://houseslasher.com/index.php?showtopic=174

I really love this script btw, thanks for it smile.gif


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
neiljwd
post May 6 2012, 06:35 AM
Post #12


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




Me again.
If you ever get around to scrpting a compatability with Mousie that'd be top, but I have a new more pressing problem.

I can't chance my actors graphic, as soon as I move, it goes back to the 1 in the data base!
What do I have to change/delete to stop this please?

I don't care about the idle/dash animations, so I'm happy to lose them, just want to keep the DASH function itself.


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
Night_Runner
post May 7 2012, 05:04 AM
Post #13


Level 50
Group Icon

Group: +Gold Member
Posts: 1,525
Type: Scripter
RM Skill: Undisclosed




Hey neiljwd,

I've tweaked Ty's script to address the issue with changing the actor's graphic in the code below, hope it helps ^_^

CODE
#===============================================================================
# Stand/Walk/Run Script --- RMXP Version
#===============================================================================
# Written by Synthesize
# Version 2.50
# January 26, 2008 (v1)
#     Revised: March 1, 2008 (v2)
#     Revised: September 4, 2010 (v2.5)
#===============================================================================
# Customization
#-------------------------------------------------------------------------------
module StandWalkRun
  Use_run = true   # Use Run Points?
  Use_run_sprite = true    # Use a Running sprite?
  Run_speed = 5   # Player speed while running
  Walk_speed = 4  # Player speed while walking
  Run_sprite_suffix = '_run'   # Running Sprite Suffix
  Run_points = 100   # The maximum amount of Run Points
  Run_points_restore = 20   # 1 Run Point is restored in X Frames
  Restore_run_while_walking = true   # Restore points while walking?
  Use_idle_sprite = true   # Use Idle Sprite?
  Idle_sprite_suffix = '_idle'   # idle Sprite Suffix
  Use_anime = true   # Animate your Idle Sprite?
  Idle_time = 40    # Time before sprite is animated
end
#-------------------------------------------------------------------------------
# Scene_Map:: The main functions of the script are here
#-------------------------------------------------------------------------------
class Scene_Map
  # Aliases
  alias syn_map_update update
  #-----------------------------------------------------------------------------
  # Initiate variables
  #-----------------------------------------------------------------------------
  def initialize
    if $game_player.old_character_name == nil
     $game_player.old_character_name = $game_player.character_name
    end
    @wait_time = 0
    @wait_time2 = 0
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #-----------------------------------------------------------------------------
  def update
    syn_map_update
    if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
      if $game_player.move_route_forcing == false
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"
      end
      restore_run if StandWalkRun::Use_run
      else
      $game_temp.syn_state = ""
      restore_run if StandWalkRun::Restore_run_while_walking
      call_idle($game_player.old_character_name, false) if $game_player.character_name != $game_player.old_character_name
      @wait_time = 0
      end
      if $game_temp.sprite_changed == true
      $game_player.old_character_name = $game_player.character_name
      $game_temp.sprite_changed = false
      end
    end
  #-----------------------------------------------------------------------------
  # Call_Idle:: Sets and animates the idle Sprite
  #-----------------------------------------------------------------------------
  def call_idle(sprite, anime)
    $game_player.set_step_anime(anime)
    $game_player.set_graphic(sprite)
  end
  #-----------------------------------------------------------------------------
  # Restore_Run: Restore Run Points
  #-----------------------------------------------------------------------------
  def restore_run
    if $game_player.run_points < $game_player.max_run_points
      wait(1, true)
      $game_player.run_points += 1 if @wait_time2 == StandWalkRun::Run_points_restore
      @wait_time2 = 0 if @wait_time2 == StandWalkRun::Run_points_restore
    end
  end
  #-----------------------------------------------------------------------------
  # Wait:: Allows Wait Times
  #-----------------------------------------------------------------------------
  def wait(duration, value)
    for i in 0...duration
      @wait_time += 1 if value == false
      @wait_time2 += 1 if value
      break if i >= duration / 2
    end
  end
end  
#-------------------------------------------------------------------------------
# Game_Temp:: Create current state
#-------------------------------------------------------------------------------
class Game_Temp
  attr_accessor :syn_state
  attr_accessor :sprite_changed
  alias syn_temp_init initialize
  def initialize
    @syn_state = ""
    @sprite_changed = false
    syn_temp_init
  end
end
#-------------------------------------------------------------------------------
# Game_Character:: Create the Change_Sprite method
#-------------------------------------------------------------------------------
class Game_Character
  # Attr(s)
  attr_accessor :old_character_name
  attr_accessor :run_points
  attr_accessor :max_run_points
  alias syn_ch_init initialize
  #-----------------------------------------------------------------------------
  # Initialize Variables
  #-----------------------------------------------------------------------------
  def initialize
    @run_points = StandWalkRun::Run_points
    @max_run_points = @run_points
    syn_ch_init
  end
  #-----------------------------------------------------------------------------
  # Set Setp Animation
  #-----------------------------------------------------------------------------
  def set_step_anime(value)
    @step_anime = value
    return @step_anime
  end
end
#-------------------------------------------------------------------------------
# Game_Player:: This handles the dash process
#-------------------------------------------------------------------------------
class Game_Player < Game_Character
  alias syn_player_update update
  alias syn_player_move_type_custom move_type_custom
  def dash?
    return false if @run_points == 0 and StandWalkRun::Use_run
    return true if Input.press?(Input::A)
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #----------------------------------------------------------------------------
  def update
    if dash?
      if Input.dir4 == 0
        $game_player.set_graphic($game_player.old_character_name)
      end
      unless $game_temp.syn_state == "idle"
        set_graphic(@character_name + StandWalkRun::Run_sprite_suffix) if StandWalkRun::Use_run_sprite
        @move_speed = StandWalkRun::Run_speed
        @run_points -= 1
        syn_player_update
      end
    else
      @move_speed = StandWalkRun::Walk_speed
      syn_player_update
    end
  end
  def set_graphic(character_name)
    @tile_id = 0
    @character_name = character_name
  end
  #--------------------------------------------------------------------------
  # * Move Type : Custom
  #--------------------------------------------------------------------------
  def move_type_custom
    old_ch_name = @character_name
    syn_player_move_type_custom
    if old_ch_name != @character_name # Change Graphic
      self.old_character_name = @character_name
    end
  end
end
#-------------------------------------------------------------------------------
#            * This script is not compatible with RPG Maker XP *
#-------------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# Requested by Cerulean Sky
#===============================================================================
# Stand/Walk/Run   - RMXP Version
#===============================================================================



@> Ty;
Why does it mention not being compatible with RMXP in the comments at the end of this script?


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
neiljwd
post May 7 2012, 12:18 PM
Post #14


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




Hi Night_ Runner!
Appreciate you taking a shot at it. Scripting is such a hard unfathomable world for those unskilled at it.
So frustrating knowing it's probably a simple thing, but so beyond your own abilities.
So cheers for looking at it.

Sadly your script didn't work for me. I even looked for what you've done, seen the custom bit at the end so I've copied the right one (triple checked), but I'm at a loss.
Thanks for trying though.


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
Night_Runner
post May 8 2012, 04:20 AM
Post #15


Level 50
Group Icon

Group: +Gold Member
Posts: 1,525
Type: Scripter
RM Skill: Undisclosed




Are you using the 'Change Actor Graphic' command, or the 'set move route' command to change the graphic?

I just assumed that you were using the 'Set Move Route' > Player > Graphic, and made the fix for that method, I'm guessing that you're using the 'Change Actor Graphic'?

If so, that's even easier to get working happy.gif

CODE
#===============================================================================
# Stand/Walk/Run Script --- RMXP Version
#===============================================================================
# Written by Synthesize
# Version 2.50
# January 26, 2008 (v1)
#     Revised: March 1, 2008 (v2)
#     Revised: September 4, 2010 (v2.5)
#     Revised: 8 May, 2012 (2.6, NREdit)
#===============================================================================
# Customization
#-------------------------------------------------------------------------------
module StandWalkRun
  Use_run = true   # Use Run Points?
  Use_run_sprite = true    # Use a Running sprite?
  Run_speed = 5   # Player speed while running
  Walk_speed = 4  # Player speed while walking
  Run_sprite_suffix = '_run'   # Running Sprite Suffix
  Run_points = 100   # The maximum amount of Run Points
  Run_points_restore = 20   # 1 Run Point is restored in X Frames
  Restore_run_while_walking = true   # Restore points while walking?
  Use_idle_sprite = true   # Use Idle Sprite?
  Idle_sprite_suffix = '_idle'   # idle Sprite Suffix
  Use_anime = true   # Animate your Idle Sprite?
  Idle_time = 40    # Time before sprite is animated
end
#-------------------------------------------------------------------------------
# Scene_Map:: The main functions of the script are here
#-------------------------------------------------------------------------------
class Scene_Map
  # Aliases
  alias syn_map_update update
  #-----------------------------------------------------------------------------
  # Initiate variables
  #-----------------------------------------------------------------------------
  def initialize
    if $game_player.old_character_name == nil
     $game_player.old_character_name = $game_player.character_name
    end
    @wait_time = 0
    @wait_time2 = 0
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #-----------------------------------------------------------------------------
  def update
    syn_map_update
    if Input.dir4 == 0
      wait(1, false) if StandWalkRun::Use_idle_sprite
      if $game_player.move_route_forcing == false
        call_idle($game_player.character_name + StandWalkRun::Idle_sprite_suffix, StandWalkRun::Use_anime) if @wait_time == StandWalkRun::Idle_time
        $game_temp.syn_state = "idle"
      end
      restore_run if StandWalkRun::Use_run
      else
      $game_temp.syn_state = ""
      restore_run if StandWalkRun::Restore_run_while_walking
      call_idle($game_player.old_character_name, false) if $game_player.character_name != $game_player.old_character_name
      @wait_time = 0
      end
      if $game_temp.sprite_changed == true
      $game_player.old_character_name = $game_player.character_name
      $game_temp.sprite_changed = false
      end
    end
  #-----------------------------------------------------------------------------
  # Call_Idle:: Sets and animates the idle Sprite
  #-----------------------------------------------------------------------------
  def call_idle(sprite, anime)
    $game_player.set_step_anime(anime)
    $game_player.set_graphic(sprite)
  end
  #-----------------------------------------------------------------------------
  # Restore_Run: Restore Run Points
  #-----------------------------------------------------------------------------
  def restore_run
    if $game_player.run_points < $game_player.max_run_points
      wait(1, true)
      $game_player.run_points += 1 if @wait_time2 == StandWalkRun::Run_points_restore
      @wait_time2 = 0 if @wait_time2 == StandWalkRun::Run_points_restore
    end
  end
  #-----------------------------------------------------------------------------
  # Wait:: Allows Wait Times
  #-----------------------------------------------------------------------------
  def wait(duration, value)
    for i in 0...duration
      @wait_time += 1 if value == false
      @wait_time2 += 1 if value
      break if i >= duration / 2
    end
  end
end  
#-------------------------------------------------------------------------------
# Game_Temp:: Create current state
#-------------------------------------------------------------------------------
class Game_Temp
  attr_accessor :syn_state
  attr_accessor :sprite_changed
  alias syn_temp_init initialize
  def initialize
    @syn_state = ""
    @sprite_changed = false
    syn_temp_init
  end
end
#-------------------------------------------------------------------------------
# Game_Character:: Create the Change_Sprite method
#-------------------------------------------------------------------------------
class Game_Character
  # Attr(s)
  attr_accessor :old_character_name
  attr_accessor :run_points
  attr_accessor :max_run_points
  alias syn_ch_init initialize
  #-----------------------------------------------------------------------------
  # Initialize Variables
  #-----------------------------------------------------------------------------
  def initialize
    @run_points = StandWalkRun::Run_points
    @max_run_points = @run_points
    syn_ch_init
  end
  #-----------------------------------------------------------------------------
  # Set Setp Animation
  #-----------------------------------------------------------------------------
  def set_step_anime(value)
    @step_anime = value
    return @step_anime
  end
end
#-------------------------------------------------------------------------------
# Game_Player:: This handles the dash process
#-------------------------------------------------------------------------------
class Game_Player < Game_Character
  alias syn_player_update update
  alias syn_player_refresh  refresh
  alias syn_player_move_type_custom move_type_custom
  def dash?
    return false if @run_points == 0 and StandWalkRun::Use_run
    return true if Input.press?(Input::A)
  end
  def refresh
    syn_player_refresh
    self.old_character_name = @character_name
  end
  #-----------------------------------------------------------------------------
  # Update:: Update the scene
  #----------------------------------------------------------------------------
  def update
    if dash?
      if Input.dir4 == 0
        $game_player.set_graphic($game_player.old_character_name)
      end
      unless $game_temp.syn_state == "idle"
        set_graphic(@character_name + StandWalkRun::Run_sprite_suffix) if StandWalkRun::Use_run_sprite
        @move_speed = StandWalkRun::Run_speed
        @run_points -= 1
        syn_player_update
      end
    else
      @move_speed = StandWalkRun::Walk_speed
      syn_player_update
    end
  end
  def set_graphic(character_name)
    @tile_id = 0
    @character_name = character_name
  end
  #--------------------------------------------------------------------------
  # * Move Type : Custom
  #--------------------------------------------------------------------------
  def move_type_custom
    old_ch_name = @character_name
    syn_player_move_type_custom
    if old_ch_name != @character_name # Change Graphic
      self.old_character_name = @character_name
    end
  end
end
#-------------------------------------------------------------------------------
#            * This script is not compatible with RPG Maker XP *
#-------------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# Requested by Cerulean Sky
#===============================================================================
# Stand/Walk/Run   - RMXP Version
#===============================================================================


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
neiljwd
post May 8 2012, 08:34 AM
Post #16


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




So awesome. Thank you. I was indeed doing change actor graphic, not move route, works for both now anyway. Amazing work.

I looked at what you did, added that custom bit ofc, and a few lines after line 133, but still jsut doesn't compute in my brain.
Also you credited yourself with an edit this time, much deserved, good to see! Thank you sir!


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 06:52 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker