RPG Maker Forums

Hi Everyone,


I found this great script made by Jet, that allows you to change the actor face, depending on how much hp or mp they've lost or what state is applied to them.


Unfortunately it only works with RPG Maker VX. I was wondering if someone could edit the script so it would work with RPG Maker VX ACE?


Here's a link to Jet's website:


http://jetruby.blogspot.co.uk/2011/07/dynamic-face-changing.html


Here's the script:

#===============================================================================
# Dynamic Face Changing
# By Jet10985 (Jet)
# Request By: Kyriaki
#===============================================================================
# This script will allow you to set up conditions for an actors face to be
# changed automatically.
# This script has: 1 customization option.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_System: initialize
#===============================================================================
=begin
To lock an actor's face:

To lock an actor's face, which means none of the below conditionals will be
checked, so the face will appear as whatever was last set by an event, use
this in an Event Script... command

lock_actor_face(actor_id)

actor_id should be the database id of the actor whose face should be locked.
--------------------------------------------------------------------------------
To unlock an actor's face:

Follow the same instructions as above, but with this command instead:

unlock_actor_face(actor_id)

=end

module JetDynamicFaces

#=============================================================================
# How to configure:
#=============================================================================
# Follow this format: actor_id => ["Face Name", index, :type, condition]
#-----------------------------------------------------------------------------
# actor_id is the database id of the actor in the database.
# More than 1 condition can be used per actor, you should NOT use the same
# id in the config more than once.
#-----------------------------------------------------------------------------
# "Face name" is the name of the face file in the Graphic/Faces folder
# You may also use :face instead, which will use their currently set face,
# as set by the database or event.
#-----------------------------------------------------------------------------
# index is the index of the face in the picture above
#-----------------------------------------------------------------------------
# :type is the type of conditional that it will check for. It can be:
# :hp which will check if their hp is below a percentage.
# :mp which will check if their mp is below a percentage.
# :state which will check if a state is applied to the actor.
#-----------------------------------------------------------------------------
# condition is what should be checked from the :type
# If type is :hp or :mp, this should be the percentage to check.
# If type is :state, this should be the id of the state to check for.
#-----------------------------------------------------------------------------
# Please note, the order of the conditionals will determine priority.
# The face will be from whichever conditional is matched last, so low
# priority conditions should be first.
#-----------------------------------------------------------------------------

ACTOR_DYNAMIC_FACES_CONDITIONS = {

1 => [["People1", 2, :hp, 75], ["People1", 1, :hp, 50], ["People1", 0, :hp, 25]],
2 => [[:face, 0, :mp, 25], [:face, 1, :state, 1]]

}

end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Game_System

attr_accessor :locked_actor_faces

alias jet1280_initialize initialize unless $@
def initialize(*args, &block)
@locked_actor_faces = []
jet1280_initialize(*args, &block)
end
end

class Game_Actor

def face_name
return @face_name if $game_system.locked_actor_faces.include?(self.id)
if JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS.keys.include?(self.id)
jet_face_name = @face_name
for cond in JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS[self.id]
case cond[2]
when :hp
if self.hp.to_f / self.maxhp <= cond[3] / 100.0
jet_face_name = cond[0] == :face ? @face_name : cond[0]
end
when :mp
if self.mp.to_f / self.maxmp <= cond[3] / 100.0
jet_face_name = cond[0] == :face ? @face_name : cond[0]
end
when :state
if self.state?(cond[3])
jet_face_name = cond[0] == :face ? @face_name : cond[0]
end
end
end
return jet_face_name
else
return @face_name
end
end

def face_index
return @face_index if $game_system.locked_actor_faces.include?(self.id)
if JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS.keys.include?(self.id)
jet_face_index = @face_index
for cond in JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS[self.id]
case cond[2]
when :hp
if self.hp.to_f / self.maxhp <= cond[3] / 100.0
jet_face_index = cond[1]
end
when :mp
if self.mp.to_f / self.maxmp <= cond[3] / 100.0
jet_face_index = cond[1]
end
when :state
if self.state?(cond[3])
jet_face_index = cond[1]
end
end
end
return jet_face_index
else
return @face_index
end
end
end

class Game_Interpreter

def lock_actor_face(id)
unless $game_system.locked_actor_faces.include?(id)
$game_system.locked_actor_faces.push(id)
end
end

def unlock_actor_face(id)
if $game_system.locked_actor_faces.include?(id)
$game_system.locked_actor_faces.delete(id)
end
end
end



**EDIT**


Problem solved. Thank you Soulpour777 for editing this script for me. :) I'll leave the edited script here in case anyone else wants to use it.

Code:
#===============================================================================
# Dynamic Face Changing
# By Jet10985 (Jet)
# Request By: Kyriaki
#===============================================================================
# This script will allow you to set up conditions for an actors face to be
# changed automatically.
# This script has: 1 customization option.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_System: initialize
#===============================================================================
=begin
To lock an actor's face:
To lock an actor's face, which means none of the below conditionals will be
checked, so the face will appear as whatever was last set by an event, use
this in an Event Script... command
lock_actor_face(actor_id)
actor_id should be the database id of the actor whose face should be locked.
--------------------------------------------------------------------------------
To unlock an actor's face:
Follow the same instructions as above, but with this command instead:
unlock_actor_face(actor_id)
=end
module JetDynamicFaces
 
  #=============================================================================
  # How to configure:
  #=============================================================================
  # Follow this format: actor_id => ["Face Name", index, :type, condition]
  #-----------------------------------------------------------------------------
  # actor_id is the database id of the actor in the database.
  # More than 1 condition can be used per actor, you should NOT use the same
  # id in the config more than once.
  #-----------------------------------------------------------------------------
  # "Face name" is the name of the face file in the Graphic/Faces folder
  # You may also use :face instead, which will use their currently set face,
  # as set by the database or event.
  #-----------------------------------------------------------------------------
  # index is the index of the face in the picture above
  #-----------------------------------------------------------------------------
  # :type is the type of conditional that it will check for. It can be:
  # :hp which will check if their hp is below a percentage.
  # :mp which will check if their mp is below a percentage.
  # :state which will check if a state is applied to the actor.
  #-----------------------------------------------------------------------------
  # condition is what should be checked from the :type
  # If type is :hp or :mp, this should be the percentage to check.
  # If type is :state, this should be the id of the state to check for.
  #-----------------------------------------------------------------------------
  # Please note, the order of the conditionals will determine priority.
  # The face will be from whichever conditional is matched last, so low
  # priority conditions should be first.
  #-----------------------------------------------------------------------------
 
  ACTOR_DYNAMIC_FACES_CONDITIONS = {
 
  1 => [["People1", 2, :hp, 75], ["People1", 1, :hp, 50], ["People1", 0, :hp, 25]],
  2 => [[:face, 0, :mp, 25], [:face, 1, :state, 1]]
 
  }
 
end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Game_System
 
  attr_accessor :locked_actor_faces
 
  alias jet1280_initialize initialize unless $@
  def initialize(*args, &block)
    @locked_actor_faces = []
    jet1280_initialize(*args, &block)
  end
end
class Game_Actor
 
  def face_name
    return @face_name if $game_system.locked_actor_faces.include?(self.id)
    if JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS.keys.include?(self.id)
      jet_face_name = @face_name
      for cond in JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS[self.id]
        case cond[2]
        when :hp
          if self.hp.to_f / self.mhp <= cond[3] / 100.0
            jet_face_name = cond[0] == :face ? @face_name : cond[0]
          end
        when :mp
          if self.mp.to_f / self.mmp <= cond[3] / 100.0
            jet_face_name = cond[0] == :face ? @face_name : cond[0]
          end
        when :state
          if self.state?(cond[3])
            jet_face_name = cond[0] == :face ? @face_name : cond[0]
          end
        end
      end
      return jet_face_name
    else
      return @face_name
    end
  end
 
  def face_index
    return @face_index if $game_system.locked_actor_faces.include?(self.id)
    if JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS.keys.include?(self.id)
      jet_face_index = @face_index
      for cond in JetDynamicFaces::ACTOR_DYNAMIC_FACES_CONDITIONS[self.id]
        case cond[2]
        when :hp
          if self.hp.to_f / self.mhp <= cond[3] / 100.0
            jet_face_index = cond[1]
          end
        when :mp
          if self.mp.to_f / self.mmp <= cond[3] / 100.0
            jet_face_index = cond[1]
          end
        when :state
          if self.state?(cond[3])
            jet_face_index = cond[1]
          end
        end
      end
      return jet_face_index
    else
      return @face_index
    end
  end
end
class Game_Interpreter
 
  def lock_actor_face(id)
    unless $game_system.locked_actor_faces.include?(id)
      $game_system.locked_actor_faces.push(id)
    end
  end
 
  def unlock_actor_face(id)
    if $game_system.locked_actor_faces.include?(id)
      $game_system.locked_actor_faces.delete(id)
    end
  end
end 

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top