Actor Exclusive Animation ADD ON - Actor + State Exclusive Animation

Hello everyone.

I was hoping to seek your aid in this matter. I remember that you have been kind to me and made this "actor excluvise animation" script which was very useful for me! Now, I was hoping that you could help me expand this script so that not only I could have the a different animation for a skill not only exclusive to an actor but also a different animation if that very same actor is under a certain state

Is this possible to achieve?

Here is the original script.

=begin
#==============================================================================#
# AMN Actor Animations
# Version 1.01
# Author: AMoonlessNight
# Date: 24 Dec 2018
# Latest: 24 Dec 2018
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 24 Dec 2018 - created the script
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use
# - Contact for commercial use
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script makes it so that you can give items and skills different animation
IDs for different actors.

Use the following notetag in skills and items:

<actor ani: X Y>

where X is the ID of the actor and Y is the ID of the animation.

=end

#==============================================================================
# Please do not edit below this point unless you know what you are doing.
#==============================================================================

class RPG::UsableItem
attr_reader :actor_ani

def load_notetags_actor_ani
@actor_ani = {}
self.note.split(/[\r\n]+/).each { |line|
case line
when /<actor[ -_]+ani:*\s+(\d+)\s+(\d+)>/i
@actor_ani[$1.to_i] = $2.to_i
end
}
end

end

module DataManager
class << self; alias :amn_ani_datamanager_loaddatabase :load_database; end

def self.load_database
amn_ani_datamanager_loaddatabase
load_notetags_actor_ani
end

def self.load_notetags_actor_ani
for group in [$data_skills, $data_items]
for obj in group
next if obj.nil?
obj.load_notetags_actor_ani
end
end
end
end

class Scene_Battle < Scene_Base
alias amn_ani_scenebattle_shownormalanimation show_normal_animation
def show_normal_animation(targets, animation_id, mirror = false)
if @subject && @subject.is_a?(Game_Actor) && @subject.current_action && @subject.current_action.item
if @subject.current_action.item.actor_ani.key?(@subject.id)
animation_id = @subject.current_action.item.actor_ani[@subject.id]
end
end
amn_ani_scenebattle_shownormalanimation(targets, animation_id, mirror)
end
end
Here:
Code:
#===============================================================================
#
# Extention script for AMoonlessNight's AMN Actor Animations
# Author: vFoggy
# Description:
#   Now items and skills can have a different animation if a specific actor is
#   using it while under a specific state.
#   
#   Notetag:
#   <actor ani: actor_id animation_id state_id>
#   Using the above tag, when the actor with id actor_id uses the item/skill
#   and has a state with id state_id, the animation with id animation_id will
#   play instead.
#
#===============================================================================
class RPG::UsableItem
  attr_reader :actor_state_ani

  def load_notetags_state_ani
    @actor_state_ani = {}
    note.split(/[\r\n]+/).each do |line|
      case line
      when /<actor[ -_]+ani:*\s+(\d+)\s+(\d+)(?:\s+(\d+))?>/i
        @actor_state_ani[$1.to_i] = [$2.to_i, $3.to_i]
      end
    end
  end
 
  alias fog_lnaa load_notetags_actor_ani
  def load_notetags_actor_ani
    fog_lnaa
    load_notetags_state_ani
  end
end


class Scene_Battle < Scene_Base
  alias fog_sna show_normal_animation
  def show_normal_animation(targets, animation_id, mirror = false)
    if @subject && @subject.is_a?(Game_Actor) && @subject.current_action && @subject.current_action.item
      item = @subject.current_action.item
      # if item/skill has a state animation for the user and
      # the required state is applied on the user
      if item.actor_state_ani.key?(@subject.id) &&
        [email protected]{|s| s.id == item.actor_state_ani[@subject.id][1] }.nil?
          animation_id = subjects_state_ani[0]
      elsif item.actor_ani.key?(@subject.id)
        # check for just actor animation (script's default behaviour)
        animation_id = @subject.current_action.item.actor_ani[@subject.id]
      end
    end
    amn_ani_scenebattle_shownormalanimation(targets, animation_id, mirror)
  end
end

Paste it after the original script.
Priority is given to the state animation.
I wonder if I'm doing something wrong...
I wonder if I'm doing something wrong...
No, it was my mistake.
Change that line with this one:
Code:
animation_id = item.actor_state_ani[@subject.id][0]
YOOOO, It worked.

Now I can make different animations for my characters when they equip a new weapon because they get a passive state that will change the animation graphic showing their new weapon!

Thanks alot, you will definitely be credited.
YOOOO, It worked.

Now I can make different animations for my characters when they equip a new weapon because they get a passive state that will change the animation graphic showing their new weapon!

Thanks alot, you will definitely be credited.
Thank you. Good luck with your project 🙂

Original thread: https://forums.rpgmakerweb.com/threads/actor-exclusive-animation-add-on-actor-state-exclusive-animation.112739/