[XP] Simple Player Idle Sprites

Started by winkio, June 26, 2021, 11:57:45 am

Previous topic - Next topic

winkio

June 26, 2021, 11:57:45 am Last Edit: June 27, 2021, 06:26:36 pm by KK20
Simple Player Idle Sprites
Authors: winkio
Version: 1.0
Type: Animation System
Key Term: Environment Add-on

Introduction

This script was created from a simple request to have idle animations for player characters in this thread: https://forum.chaos-project.com/index.php/topic,2653.0.html

There are many scripts out there that have more fully featured implementations of idle sprites, but this one is intended to be minimalistic - just a single idle sprite per character.

Script

SIMPLE PLAYER IDLE SPRITES: ShowHide
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  With idle sprites.  name the idle sprites the same as their normal ones
#  except with '_idl' on the end (before the extension)
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :character_name_org       # original character file name
  attr_reader   :current_sprite           # current sprite suffix
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_idlesprites_before initialize
  def initialize
    initialize_idlesprites_before
    # set original character name
    @character_name_org = @character_name
    # set current sprite
    @current_sprite = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_idlesprites_before update
  def update
    update_idlesprites_before
    update_idlesprites
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias refresh_idlesprites_before refresh
  def refresh
    refresh_idlesprites_before
    update_idlesprites
  end
  #--------------------------------------------------------------------------
  # * update_idlesprites
  # Updates idle sprites of the player
  #--------------------------------------------------------------------------
  def update_idlesprites
    if @character_name != ""
      if moving?
        if @current_sprite != ''
          @step_anime = false
          @character_name = @character_name_org
          @current_sprite = ''
        end
      elsif Input.dir4 == 0
        if @current_sprite != '_idl'
          @character_name_org = @character_name
          @step_anime = true
          @character_name += '_idl'
          @current_sprite = '_idl'
        end
      end
    end
  end
 
end


SIMPLE CATERPILLAR IDLE SPRITES (FOR USE WITH TONS OF ADDONS): ShowHide
#==============================================================================
# ** Game_Member
#------------------------------------------------------------------------------
#  With idle sprites.  name the idle sprites the same as their normal ones
#  except with '_idl' on the end (before the extension)
#==============================================================================

class Game_Member < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :character_name_org       # original character file name
  attr_reader   :current_sprite           # current sprite suffix
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_idlesprites_before initialize
  def initialize(index)
    initialize_idlesprites_before(index)
    # set original character name
    @character_name_org = @character_name
    # set current sprite
    @current_sprite = ""
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_idlesprites_before update
  def update
    update_idlesprites_before
    update_idlesprites
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias refresh_idlesprites_before refresh
  def refresh
    refresh_idlesprites_before
    update_idlesprites
  end
  #--------------------------------------------------------------------------
  # * update_idlesprites
  # Updates idle sprites of the party member in the caterpillar
  #--------------------------------------------------------------------------
  def update_idlesprites
    if @character_name != ""
      if moving?
        if @current_sprite != ''
          @step_anime = false
          @character_name = @character_name_org
          @current_sprite = ''
        end
      elsif Input.dir4 == 0 && @buffer.size <= @index && @force_movement <= 0
        if @current_sprite != '_idl' || @character_name[-4, 4] != @current_sprite
          @character_name_org = @character_name
          @step_anime = true
          @character_name += '_idl'
          @current_sprite = '_idl'
        end
      end
    end
  end
 
end



Instructions

Place the Simple Player Idle Sprites script below the default scripts, above main, and above any other custom scripts you may be using.

If you are using the Tons of Addons script and want caterpillar heroes to have idle sprites as well, you must also place the Simple Caterpillar Idle Sprites script below Tons of Addons.

Idle sprites should be named after the original sprite with '_idl' at the end, for example if your player sprite is named 'MainGuy.png', then the idle sprite should be named 'MainGuy_idl.png'

Compatibility

Made compatible with Tons of Add-ons, including when Caterpillar option is turned on.
May not be compatible with larger scripts and ABS battle systems.

KK20

June 27, 2021, 06:23:06 pm #1 Last Edit: June 27, 2021, 06:27:32 pm by KK20
winkio returns briefly from retirement :o

*fixes topic header so it can be added to the database*

EDIT: yo wut, the scripts disappeared after my edit. Good thing I still had a tab open to the original post.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!