Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Help with coding for walk animation, Implementing a 'standing' frame
Eggie
post Nov 2 2011, 05:37 AM
Post #1



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Beginner




Hey, I hate to come out of lurking just to make a 'help me' thread but I've been typing in search terms all day and I find find any one else who seems to want to do this.

Basically, if I have a sprite set which includes a 'standing' frame

(Example: )

Can I make it skip that frame when the character's walking.

I was previously just having it switch to a separate spritesheet when stationary but it all seemed pretty inefficient. I found the line of code that increases the pattern count
CODE
@pattern = (@pattern + 1) % 5

So if my Sherlock Holmes style deduction skills are correct there must be something else in the script which tells the animation which pattern to return to once the last frame is exceeded but I've been combing the scripts for ages now and I haven't found where it is.

Can anyone help?

This post has been edited by Eggie: Nov 2 2011, 11:33 AM
Go to the top of the page
 
+Quote Post
   
Donline
post Nov 2 2011, 12:46 PM
Post #2


Level 34
Group Icon

Group: Revolutionary
Posts: 845
Type: Artist
RM Skill: Masterful




yes Ive used a script like that in XP

but would it be slightly easier too just create a parallel process that detects 0 movement and switches the sprite accordingly smile.gif


__________________________
Tales Of Aria- My Earlier Epic Attempt (Action RPG) 2348 D/L!!
http://www.mediafire.com/?f44wmbt2m0m
Go to the top of the page
 
+Quote Post
   
Eggie
post Nov 2 2011, 02:00 PM
Post #3



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Beginner




I'd just rather not waste space by having this big spritesets that are only there to display one frame. I'm planning to have a game with things like costume changes and you can see how all the clutter of having two sheets per outfit could build up.

I had a little brainwave though, if I had the standing frame as the LAST frame instead of the first I could set the pattern command to "@pattern = (@pattern + 1) % 4" instead of 5 and that should mean the last frame won't get displayed...

Yes... yes. I am going to go try that...

...After I eat some toast...

EDIT: Okay no, that didn't work. She just vanishes when I try setting her to frame 5. Does anyone have other ideas?

This post has been edited by Eggie: Nov 2 2011, 03:19 PM
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Nov 3 2011, 02:53 AM
Post #4


Level 50
Group Icon

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




Give this script a try.
XP: Night_Runner's Stationary & Walking Character Sprites
CODE
#==============================================================================
# ** XP: Night_Runner's Stationary & Walking Character Sprites
#------------------------------------------------------------------------------
# History:
#  Date Created: 3/Sep/2011
#  Created for: Eggie
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=53800
#
# Description:
#  This script changes how RPG Maker XP handles character sprites, having
#  the first character as the stationary sprite, and uses 4 more sprites
#  for the walking animations, all in the one characterset
#
# How to Install:
#  Highlight and copy this entire script. In your game editor, select
#  Tools >> Script Editor.
#  Along the left, scroll all the way to the bottom, right click on
#  'Main' and select 'Insert'. Paste on the right.
#
# Customisation:
#  By default this script has 1 stopped animation, and 4 walking animations,
#  to get more walking animaitons search (Ctrl F) for #NREdit and change
#  any the reference of 4 to the number of walking animations, and the
#  references of 5 to the number of sprites across in the spriteset.
#==============================================================================



#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  Edited to have a walking pattern that skips the first frame
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Branch with jumping, moving, and stopping
    if jumping?
      update_jump
    elsif moving?
      update_move
    else
      update_stop
    end
    # If animation count exceeds maximum value
    # * Maximum value is move speed * 1 taken from basic value 18
    if @anime_count > 18 - @move_speed * 2
      # If stop animation is OFF when stopping
      if not @step_anime and @stop_count > 0
        # Return to original pattern
        @pattern = @original_pattern
      # If stop animation is ON when moving
      else
        # Update pattern
        @pattern = (@pattern) % 4 + 1 #NREdit
      end
      # Clear animation count
      @anime_count = 0
    end
    # If waiting
    if @wait_count > 0
      # Reduce wait count
      @wait_count -= 1
      return
    end
    # If move route is forced
    if @move_route_forcing
      # Custom move
      move_type_custom
      return
    end
    # When waiting for event execution or locked
    if @starting or lock?
      # Not moving by self
      return
    end
    # If stop count exceeds a certain value (computed from move frequency)
    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
      # Branch by move type
      case @move_type
      when 1  # Random
        move_type_random
      when 2  # Approach
        move_type_toward_player
      when 3  # Custom
        move_type_custom
      end
    end
  end
end



#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  Edited to have 5 frames across in the character sprite.
#==============================================================================

class Sprite_Character
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        self.bitmap = RPG::Cache.character(@character.character_name,
          @character.character_hue)
        @cw = bitmap.width / 5 #NREdit
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end



#==============================================================================
# ** End of 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
   
Eggie
post Nov 3 2011, 03:13 AM
Post #5



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Beginner




Holy God! Perfection itself! Thank you so much!
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 07:22 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker