# 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