The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Infinate X on June 17, 2011, 10:33:19 PM

Title: [SOLVED] Actor Clones
Post by: Infinate X on June 17, 2011, 10:33:19 PM
dricc's actor clone script is a very awesome script however... I have some incompatability issues...

This is the error message:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi1085.photobucket.com%2Falbums%2Fj426%2FRPGMakerVX52%2FActorClonesError.png&hash=462f5a021cc54afce07ee13db4b2305b35c724c3)

Thanks to MA I have figured out which script is giving errors and it's the one I expected!

Here is Update Action Order:
[spoiler]
#-------------------------------------------------------------------------
#LoganForrests' Update Action Orders Per Action
#       For the Default Battle System (DBS) in RMVX
#
#   Date Created   : 18 April 2011
#   Date Finished  : 18 April 2011
#   Last Updated   : 24 April 2011
#   Latest Version : 1.0
#
#--------------------------------------------------------------------------
# Version History
#--------------------------------------------------------------------------
#
#   v 1.0
#       Original script: Action Turn Orders are redetermined each time a
#       battler executes their action.
#
#--------------------------------------------------------------------------
# Description
#--------------------------------------------------------------------------
# Forces the turn order to be redetermined each time a battler makes an action.
# Thus, speed changes (such as via Haste/Slow like skills) will affect the
# order a battler makes their action during the action order execution process.
#
# NOTE
# This script will very likely conflict with any Custom Battle System scripts.
# Please request a patch from me at rmrk.net if you want to use this with
# a CBS script (please also tell/provide me with the script so that I can make
# a patch quicker).
#
#--------------------------------------------------------------------------
# Directions On How To Implement
#--------------------------------------------------------------------------
# Nothing needed to do.
#
#--------------------------------------------------------------------------
# Script Installation
#--------------------------------------------------------------------------
#     In materials above Main, just below Materials and above all other
#     scripts.
#
#--------------------------------------------------------------------------
# Support
#--------------------------------------------------------------------------
# The script has been written and tested with no other scripts in place. As
# such, if you encounted any issues with regards to other scripts,
# first try to resolve the problem by moving this script around. If you are
# still unable to resolve the problem, feel free to contact me on rmrk.net
# under the name LoganForrests (no spaces involved) with the name of the
# script(s) you find no longer work when this script is included and the
# nature of the problem(s) so that I can begin to work on the problem(s)
# being caused.
#
# Scripts are made to be compatibile with my own scripts.
#-------------------------------------------------------------------------

$imported = {} if !$imported
$imported["LFUpdatedTurnsv1.0"] = true

class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # alias method: start
  #    set default @executed_order flag to false
  #--------------------------------------------------------------------------
  alias lf_uaoet_start_sb start
  def start
    #run original method
    lf_uaoet_start_sb
    @executed_order = false #turn order has not be executed
  end

  #--------------------------------------------------------------------------
  # overwrite method: update
  #    added code to call update_turn_order when @executed_order is true
  #--------------------------------------------------------------------------
  def update
    super
    update_basic(true)
    update_info_viewport                  # Update information viewport
    if $game_message.visible
      @info_viewport.visible = false
      @message_window.visible = true
    end
    unless $game_message.visible          # Unless displaying a message
      return if judge_win_loss            # Determine win/loss results
      update_scene_change
      if @target_enemy_window != nil
        update_target_enemy_selection     # Select target enemy
      elsif @target_actor_window != nil
        update_target_actor_selection     # Select target actor
      elsif @skill_window != nil
        update_skill_selection            # Select skill
      elsif @item_window != nil
        update_item_selection             # Select item
      elsif @party_command_window.active
        update_party_command_selection    # Select party command
      elsif @actor_command_window.active
        update_actor_command_selection    # Select actor command
      else
        update_turn_order if @executed_order # Redetermine turn orders if req.
        process_battle_event              # Battle event processing
        process_action                    # Battle action
        process_battle_event              # Battle event processing
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # alias method: start_main
  #     set @executed_order flag to true when actions begin processing
  #--------------------------------------------------------------------------
  alias lf_uaoet_start_main_sb start_main
  def start_main
    lf_uaoet_start_main_sb
    @executed_order = true #set executed orders to true
  end
 
  #--------------------------------------------------------------------------
  # new method: update_turn_order
  #    passes in remaining @action_battlers to make_action_orders
  #    sets @executed_order flag to false if all @action_battlers have had
  #      their turn
  #--------------------------------------------------------------------------
  def update_turn_order
    if @action_battlers == []
      @executed_order = false
      return
    end
    make_action_orders(@action_battlers)
  end
 
  #--------------------------------------------------------------------------
  # overwrite method: make_action_orders
  #    allow for passing in of action_battlers for redetermination)
  #--------------------------------------------------------------------------
  def make_action_orders(action_battlers_in = [])
    @action_battlers = action_battlers_in
    if @action_battlers == []
      unless $game_troop.surprise
        @action_battlers += $game_party.members
      end
      unless $game_troop.preemptive
        @action_battlers += $game_troop.members
      end
    end #if @action_battlers == []
    for battler in @action_battlers
      battler.action.make_speed
    end
    @action_battlers.sort! do |a,b|
      b.action.speed - a.action.speed
    end
  end
 
end

[/spoiler]


Here is Actor Clones:
[spoiler]

# actor clones
# par dricc
# http://www.rpgmakervx-fr.com/
# USAGE :
# Utiliser "Modifier l'équipe : ajouter un membre" normallement
# Mais au lieu de l'acteur correspondant , ce sera un clone qui sera ajouté .
# Du coup , vous pouvez ajouter plusieurs fois le meme acteur .
# use "Modify party : Add actor" as usual
# But instead of the actor itself , it is a copy that will be added to your party

# don't touch this !!
$imported = {} if $imported == nil
$imported["ActorClone"] = true
# end of don't touch this !! part

# Clone paramétrage : A vérifier avant usage !!
# Clone setup : check all these parameters before use !

module CLONE_SETUP
  # If true , the player will be asked to rename the clone
  RENAME_CLONE = true
  # if rename_clone at true , what is the max size for the name ?
  NAME_MAX_SIZE = 8
  # starting index for cloned actors
  ACTOR_CLONE_INDEX = 1000
  # the pattern to add to the name in the DB . add / before and after exemple : /<Pokemon>/
  # Note : if you put // , all actors will be cloned
  ACTOR_CLONE_PATTERN = /<model>/
  # the pattern to add to the name in the DB if you want the script to propose a name
  # don't remove the (\d+) : this is the pattern to replace by the index
  ACTOR_CLONE_PATTERN_NAME = /<model=(\d+)>/
  # id of the variable that stores the default level , put 0 if you want to use the default level set for the actor .
  DEFAULT_LEVEL_VAR=32
  ACTOR_NAMES_TAB = {}
  # male
  ACTOR_NAMES_TAB[1] = ['Roger','Bob','Paul','Terry','Louis','Ian','Henry','Gregor','Jon','Hero']
  # female
  ACTOR_NAMES_TAB[2] = ['Lise','Mary','Fixy','Astrie','July','Lili','Renee','Henriet','Polly']
  # monster
  ACTOR_NAMES_TAB[3] = ['Blob','Cricket','Juju','Newton','King','Prince','Frido','Gus','Medor']
end

# end setup
# fin paramétrage

# CODE

class Game_Actors
  attr_accessor :actor_clone_index
  alias dricc_initialize initialize
  def initialize
    @actor_clone_index = CLONE_SETUP::ACTOR_CLONE_INDEX
    dricc_initialize
  end
  def clone(actor_id_orig,actor_id_dest)
    @data[actor_id_dest] = Game_Actor.new(actor_id_dest,actor_id_orig)
  end
  def chg_name(actor_id,new_name)
    @data[actor_id].name = new_name
  end
end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :actor_model_id                # actor model ID
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def initialize(actor_id,actor_model_id=nil)
    super()
    setup(actor_id,actor_model_id)
    @last_skill_id = 0
  end
def setup(actor_id,actor_model_id=nil)
    @actor_model_id = actor_model_id if @actor_model_id == nil
    @actor_id = actor_id
    actor = $data_actors[actor_id]
    actor = $data_actors[@actor_model_id] if @actor_model_id != nil
    @name = actor.name
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id
    @level = actor.initial_level
    @level = $game_variables[CLONE_SETUP::DEFAULT_LEVEL_VAR] if @actor_model_id != nil and CLONE_SETUP::DEFAULT_LEVEL_VAR > 0 and $game_variables[CLONE_SETUP::DEFAULT_LEVEL_VAR] > 0
    @exp_list = Array.new(101)
    make_exp_list
    @exp = @exp_list[@level]
    @skills = []
    for i in self.class.learnings
      learn_skill(i.skill_id) if i.level <= @level
    end
    clear_extra_values
    recover_all
  end
    #--------------------------------------------------------------------------
  # * Get Actor Object
  #--------------------------------------------------------------------------
  def actor
    return $data_actors[@actor_model_id] if @actor_model_id != nil
    return $data_actors[@actor_id]
  end
end


class Game_Interpreter
#--------------------------------------------------------------------------
  # * Change Party Member
  #--------------------------------------------------------------------------
  alias dricc_command_129 command_129
  def command_129
    actor = $game_actors[@params[0]]
    pattern = actor.name =~ CLONE_SETUP::ACTOR_CLONE_PATTERN ? 0 : 1
    pattern2 = actor.name =~ CLONE_SETUP::ACTOR_CLONE_PATTERN_NAME ? $1.to_i : -1
    if pattern == 0 or pattern2 != -1
      if pattern2 != -1
        rand_index = rand(CLONE_SETUP::ACTOR_NAMES_TAB[pattern2].size)
        temp_name = CLONE_SETUP::ACTOR_NAMES_TAB[pattern2][rand_index]
      else
        temp_name = actor.name.gsub(CLONE_SETUP::ACTOR_CLONE_PATTERN) {nil}
      end
      if actor != nil
        if @params[1] == 0    # Add
# no initialize case in this script
#          if @params[2] == 1  # Initialize
            $game_actors.clone(@params[0],$game_actors.actor_clone_index)
            $game_actors.chg_name($game_actors.actor_clone_index,temp_name)
#$game_actors[@params[0]].setup(@params[0])
#          end
          $game_party.add_actor($game_actors.actor_clone_index)
          if CLONE_SETUP::RENAME_CLONE
            $game_temp.next_scene = "ask_name"
            $game_temp.name_actor_id = $game_actors.actor_clone_index
            $game_temp.name_max_char = CLONE_SETUP::NAME_MAX_SIZE
          end
          $game_actors.actor_clone_index+=1
        else                  # Remove
          $game_party.remove_actor(@params[0])
        end
        $game_map.need_refresh = true
      end
    else
       dricc_command_129
    end
    return true
  end
end


class Window_Ask_Clone < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x     : window X coordinate
  #     y     : window Y corrdinate
  #--------------------------------------------------------------------------
  def initialize(x, y,width)
    super(x, y, width, WLH * 2 + 32)
    refresh
    @column_max = 1
    @item_max=2
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
# here , you can change the text : Oui/Non ; Yes/No ....
    self.contents.draw_text(4, WLH * 0, 92, WLH, "Yes")
    self.contents.draw_text(4, WLH * 1, 92, WLH, "No")
  end
end

class Window_Ask_Clone_Up < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x     : window X coordinate
  #     y     : window Y corrdinate
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(x, y,width,actor_name)
    super(x, y, width, WLH * 2 + 32)
    @actor_name=actor_name
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
# here , you can change the text . @actor_name contains the name of the actor
    self.contents.draw_text(4, WLH * 0, 336, WLH,'You have captured a ' + @actor_name)
    self.contents.draw_text(4, WLH * 1, 336, WLH, 'Would you like to give it a name?')
  end
end

class Scene_Map < Scene_Base
alias dricc_update_scene_change update_scene_change
  alias dricc_call_name call_name
  #--------------------------------------------------------------------------
  # * Execute Screen Switch
  #--------------------------------------------------------------------------
  def update_scene_change
    return if $game_player.moving?    # Is player moving?
    case $game_temp.next_scene
    when "ask_name"
      call_ask_name
    else
      dricc_update_scene_change
    end
  end
  def call_ask_name
    $scene = Scene_Ask_Name.new
  end
end

class Scene_Ask_Name < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    @actor = $game_actors[$game_temp.name_actor_id]
    create_menu_background
    create_command_window             # Create command window
  end
  #--------------------------------------------------------------------------
  # * Post-Start Processing
  #--------------------------------------------------------------------------
  def post_start
    super
    open_command_window
  end
  #--------------------------------------------------------------------------
  # * Pre-termination Processing
  #--------------------------------------------------------------------------
  def pre_terminate
    super
    close_command_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    dispose_command_window
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window_up.update
    @command_window.update
    @status_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0    #Oui
          $game_temp.next_scene = "name"
          $scene = Scene_Map.new
      when 1    # Non
          $game_temp.next_scene = nil
          $scene = Scene_Map.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    @status_window = Window_Status.new(@actor)
    @command_window_up = Window_Ask_Clone_Up.new(210, 240,330,@actor.name)
    @command_window = Window_Ask_Clone.new(210, 320,330)
#    @command_window.x = (544 - @command_window.width) / 2
#   @command_window.y = 288
    @command_window.openness = 0
    @command_window.open
  end
  #--------------------------------------------------------------------------
  # * Dispose of Command Window
  #--------------------------------------------------------------------------
  def dispose_command_window
    @command_window.dispose
    @command_window_up.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Open Command Window
  #--------------------------------------------------------------------------
  def open_command_window
    @command_window.open
    @command_window_up.open
    @status_window.open
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 255
  end
  #--------------------------------------------------------------------------
  # * Close Command Window
  #--------------------------------------------------------------------------
  def close_command_window
    @command_window_up.close
    @command_window.close
    @status_window.close
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 0
  end
end


[/spoiler]
Title: Re: [SUPPORT] Actor Clones
Post by: modern algebra on June 17, 2011, 11:41:02 PM
Ummm, it's really hard to detect what scripts would be incompatible just from their names and without even an error message.

If you want someone to fix it, then just create a new project and recreate the conditions for that error. Then add each of your scripts into the project one by one, testing the game in between. Once the error occurs, the last script you added will likely be the incompatible one.

At the very least, give us some error messages.
Title: Re: [SUPPORT] Actor Clones
Post by: Infinate X on June 18, 2011, 01:25:51 AM
sorry I'll put it up!
Title: Re: [SUPPORT] Actor Clones
Post by: pacdiggity on June 18, 2011, 03:25:53 AM
Put Actor Clones as low as possible in the script editor; another of your scripts is most likely rewriting the setup method of Game_Actor.
The reason the error occurred is because dricc's script rewrites the setup method with two arguments, but the method is usually carried out with one. The script calls the setup method with the two arguments that dricc has made, but another script also rewrites setup with only one argument. That said, there will probably be an error even when you do move the script. If/when that error does occur, tell us and post the script that the error is in.
Title: Re: [SUPPORT] Actor Clones
Post by: Infinate X on June 18, 2011, 02:12:19 PM
Quote from: Pacman on June 18, 2011, 03:25:53 AM
Put Actor Clones as low as possible in the script editor; another of your scripts is most likely rewriting the setup method of Game_Actor.
The reason the error occurred is because dricc's script rewrites the setup method with two arguments, but the method is usually carried out with one. The script calls the setup method with the two arguments that dricc has made, but another script also rewrites setup with only one argument. That said, there will probably be an error even when you do move the script. If/when that error does occur, tell us and post the script that the error is in.

I already mentioned that it's Update Action Order and it was already below it so I don't see that working but I'll try.


EDIT: It worked! Now I've discovered a new problem with PECMS that's completly unrelated so if I can't fix it I'll post a new request!