Faces Animated with Stated???

Hello!!!


I wanted to know if anyone knows of a way or a script where characters can change their faces with states and animations.


that is to say


if character x

suffers from the Y status effect

Your face will be changed by other faces

For example

face 1 to face2


and in addition to that being able to place more faces


if the character suffers from x status effect

Your face will change to face 2 and face 3 repeatedly.

and in this way making an animation.




I managed to do this with a modification of the himu script.



However, the "animation" only works when I move the selector.

Here I leave an example video



I don't know how to fix this.


I have a script called

scroll states

where the states slide like a carousel and achieve it in a way outside the interface.

However, it is too advanced to understand how it works.


Below I leave himu's script

=begin
#===============================================================================
Title: State Faces
Author: Hime
Date: Sep 6, 2015
--------------------------------------------------------------------------------
** Change log
Sep 6, 2015
- supports class note-tag
Mar 30, 2013
- Initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Description

This script allows you to setup "state faces" for each actor.

A state face is just a face picture that will be used when a certain state has
been applied.

When the state is removed, the face picture also reverts to the original (or
maybe another state face, depending on how many states are applied).

--------------------------------------------------------------------------------
** Installation

Place this below Materials and above Main.

--------------------------------------------------------------------------------
** Usage

Note-tag your actors or classes with

<state face: id name index1 index2 index3>

Where
`id` is the state ID that this face will apply to
`name` is the name of the face, in the Graphics/Faces folder
`index1`, `index2`, `index3` are the indices of the faces for the three frames.

You will need to index the face sheets appropriately.

0 1 2 3
4 5 6 7

If you are using one face per sheet, it is just 0.

Note that state priority determines which face will be shown if multiple
states are applied. States with higher priorities will be shown over states
with lower priorities. In the case of a tie, the state that was first applied
will be used.
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_StateFaces"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module State_Faces

# state ID, face name, face indices (3 frames)
Regex = /<state face:\s*(\d+)\s*(\w+)\s*(\d+)\s*(\d+)\s*(\d+)>/i
end
end

module RPG
class BaseItem

def state_faces
return @state_faces unless @state_faces.nil?
load_notetag_state_faces
return @state_faces
end

def state_face_list
return @state_face_list unless @state_face_list.nil?
load_notetag_state_faces
return @state_face_list
end

def load_notetag_state_faces
@state_faces = {}
res = self.note.scan(TH::State_Faces::Regex)
unless res.empty?
res.each do |(state_id, face_name, index1, index2, index3)|
@state_faces[state_id.to_i] = [face_name, index1.to_i, index2.to_i, index3.to_i]
end
end
@state_face_list = @state_faces.keys
end
end
end

class Game_Actor < Game_Battler

alias :th_state_faces_face_name :face_name
def face_name
@state_actor_face = nil
@state_class_face = nil
name = states.detect {|state| actor.state_face_list.include?(state.id)}
if name
@state_actor_face = name
return actor.state_faces[@state_actor_face.id][0]
else
name = states.detect {|state| self.class.state_face_list.include?(state.id)}
if name
@state_class_face = name
return self.class.state_faces[@state_class_face.id][0]
else
return th_state_faces_face_name
end
end
end

alias :th_state_faces_face_index :face_index
def face_index
if @state_actor_face
indices = actor.state_faces[@state_actor_face.id][1..3]
elsif @state_class_face
indices = self.class.state_faces[@state_class_face.id][1..3]
else
return th_state_faces_face_index
end

# Implement animation logic here (use indices for frames)
frame = (Graphics.frame_count % 60) / 20 # Change every 20 frames
return indices[frame]
end
end

Original thread: https://forums.rpgmakerweb.com/threads/faces-animated-with-stated.165066/