The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on April 22, 2010, 10:27:07 PM

Title: Mime Skill
Post by: modern algebra on April 22, 2010, 10:27:07 PM
Mime Skill
Version: 1.0
Author: modern algebra
Date: April 22, 2010

Version History



Description


This script allows you to make mime skills, meaning that the person using such a skill will perform the same action as the ally who went before him/her.

Features


Instructions

Paste the script in its own slot in the Script Editor, below Materials and above Main

Script


Code: [Select]
#==============================================================================
#    Mime Skill
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: April 22, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to make mime skills, meaning that the person using
#   such a skill will perform the same action as the ally who went before
#   him/her.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script below Materials and above Main in the Script Editor.
#
#    To set up a mime skill, just put the code: \mime in the notebox. It is
#   recommended that you set the scope to None, since the mime skill will
#   use the same targetting mechanism as the action it is miming.
#==============================================================================

#==============================================================================
# ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - mime?
#==============================================================================

class RPG::Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Mime Skill?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def mime?
    return self.note[/\\MIME/i] != nil
  end
end

#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    attr_accessor - km_override_mp_cost
#    attr_writer - action
#    aliased method - calc_mp_cost
#==============================================================================

class Game_Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :km_override_mp_cost
  attr_writer   :action
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calc MP Cost
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modlba_ken_calcmp_7ux1 calc_mp_cost
  def calc_mp_cost (*args)
    return @km_override_mp_cost unless @km_override_mp_cost.nil?
    return modlba_ken_calcmp_7ux1 (*args) # Run Original Method
  end
end

#==============================================================================
# ** Game Unit
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new attr_accessor :km_last_action
#==============================================================================

class Game_Unit
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :km_last_action
end

#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - execute_action
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Battle Actions
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_kntn_mimic_exact_6yh1 execute_action
  def execute_action (*args)
    # If using a mime skill
    if @active_battler.action.skill? && @active_battler.action.skill.mime?
      last_action = @active_battler.action.friends_unit.km_last_action.dup
      if last_action.nil? || (last_action.item? && !$game_party.has_item? (last_action.item))
        # Do nothing
        @active_battler.action.clear
        @active_battler.action.kind = 0
        @active_battler.action.basic = 3
      else
        # Do last action
        @active_battler.km_override_mp_cost = @active_battler.calc_mp_cost (@active_battler.action.skill)
        @active_battler.action = last_action
        @active_battler.action.battler = @active_battler
      end
    else
      # Set this action to the last action of this unit
      @active_battler.action.friends_unit.km_last_action = @active_battler.action.dup
    end
    ma_kntn_mimic_exact_6yh1 (*args) # Run Original Method
    if @active_battler.km_override_mp_cost
      @active_battler.mp -= @active_battler.km_override_mp_cost unless @active_battler.action.skill?
      @active_battler.km_override_mp_cost = nil
    end
  end
end

Credit



Thanks


Support


Please post in this topic at RMRK if you have any issues with the script.

Known Compatibility Issues

It will not work with some exotic battle systems, particularly ones that do not use a similar Scene_Battle script or execute actions quite differently.
Title: Re: Mime Skill
Post by: kentona on April 22, 2010, 10:47:42 PM
So I did some quick tests in a new project and I ran into some odd behaviour.  I used Mime every round (for the most part).

-In the first round of the battle, everything worked as expected.  The heroes executed their skills or attacks or guard and the Mime copied the last action.
-In the subsequent rounds, one of 2 things would happen:
1) Only 1 person would act and the rest of the party would do nothing.  The person was casting a Heal skill.
2) Everyone would mime the last action from the previous round.  So if the Mime guarded, everyone on the next round would guard (except for the person who was mimicked, I think).

On subsequent rounds, if the Mime did not use the Mimic skill (so he attacked or guarded or used an item) everyone behaved correctly.

EDIT:
When only 1 person acts, it always seems to be party member #3 (Bennett by default).
Title: Re: Mime Skill
Post by: modern algebra on April 23, 2010, 12:14:23 AM
Hmm, well I changed a few things in the code since I first posted it. Grab it and see if the issues still exist.

I can't guarantee that will fix it as I was unable to reproduce the error, but it might do the trick. If not, I will try again to see what's going wrong.
Title: Re: Mime Skill
Post by: kentona on April 23, 2010, 01:54:26 AM
I made a mistake when I was testing - I had Yanfly's Core Fixes script installed.  When I started a fresh game it seems to be working properly.

http://rpgmaker.net/users/kentona/locker/yanfly_core_fixes.txt

I will have to try to figure out where the conflict occurs  :-\

EDIT:
Okay, I can't recreate the error anymore.  I am not sure what is going on.

Thanks for the script!  I really appreciate it.

EDIT2:
I just noticed that you edited your post sometime ago and fixed up the script.  I guess it worked...?  :)
Title: Re: Mime Skill
Post by: modern algebra on April 23, 2010, 02:22:28 AM
good to hear! It was kind of a dumb error on my part I think.
Title: Re: Mime Skill
Post by: LuKo on April 23, 2010, 03:04:58 PM
The last mime script that I saw was a total fail.

But this one of yours work fine^^

Very nice job.

(maybe later you can upgrade it to make an mime in the opponent move^^)

See ya
Title: Re: Mime Skill
Post by: dezz123 on April 25, 2010, 08:21:00 PM
Hrmm... Does this script work with Tankentai SBS with ATB?
Title: Re: Mime Skill
Post by: modern algebra on April 25, 2010, 08:23:46 PM
I don't know. Maybe, but it depends on how much of the action execution was retained by it. Try it out and see.

@LuKo - I haven't tested it, but I don't see why it wouldn't also work for opponents. Unless you mean that a party member could mime the action of an opponent. I can do that if you want me to.
Title: Re: Mime Skill
Post by: Nathanael on April 27, 2010, 12:42:54 PM
This is amazing!
Title: Re: Mime Skill
Post by: RandSummers on August 29, 2011, 02:02:17 PM
Is there a way to set this up so that a user can select an enemy and mimic the last skill they had used?