Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: winkio on June 26, 2021, 11:57:45 am

Title: [XP] Simple Player Idle Sprites
Post by: winkio on June 26, 2021, 11:57:45 am
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.
Title: Re: [XP] Simple Player Idle Sprites
Post by: KK20 on June 27, 2021, 06:23:06 pm
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.