Le Deal du moment : -39%
Ordinateur portable ASUS Chromebook Vibe CX34 Flip
Voir le deal
399 €

Aller en bas
dricc
dricc
Membre

Nombre de messages : 2760
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

Clonage d'acteur Empty Clonage d'acteur

Mar 29 Mar 2011 - 12:40
Suite à plusieurs demandes semblables , je me suis décidé à trouver un systeme permettant d'avoir plusieurs heros identiques . Ces héros ayant bien entendu chacun leur équipement , leur XPs , leurs PV/PM ... mais duplicable quasi à l'infini .
Comme dans les pokemons , si vous voulez (quoiqu'il n'y a pas de mécanisme de boite ici) .

Je vous conseille de reserver une plage d'acteur (disons de 1 à 100) qui seront vos modeles .
Puis juste aprés , une plage d'acteur qui seront vraiment les heros qui s'ajouteront à votre équipe .

utilisez une variable pour stocker l'identifiant de la deuxieme plage en cours (appelons la 299 au hasard) . Cette variable commence à 101 dans mon cas puis s'incrémentera .

Imaginons que vous rencontrez un personnage qui veux veux vous donner deux heros qui correspondent à l'ID 32

Eh bien , mettez ceci dans votre evenement :
Condition : Si variable 299 == 0 Alors : variable 299 = 101 fin condition
Appeler script : $game_actors.clone(32,$game_variables[299])
Appeler script : $game_party.add_actor($game_variables[299])
Opération : variable 299 : +1
Appeler script : $game_actors.clone(32,$game_variables[299])
Appeler script : $game_party.add_actor($game_variables[299])
Opération : variable 299 : +1

En jouant sur les variables et en utilisant des evenements communs , vous pourrez faire à peu prés tout ce que vous voudrez .

Par ailleurs , ce script est compatible avec le script "reserve party" de modern algebra (J'ai mis 4 ralph dans mon équipe sans aucuns problemes) . Meme si je vous deconseille d'utiliser les mécanismes de verrouillage de ce script (car difficile à gérer) .

Mettre ce code en dessous de "materials" et avant "main" :

Code:

# actor clones
# par dricc
# http://rpgmakervx.1fr1.net/
# USAGE :
# dans un evenement , faites :
# appeler script : $game_actors.clone(1,10)
# et l'acteur 1 au niveau initial sera copié dans l'acteur 10 .
# vous pouvez aussi utiliser des variables :
# appeler script : $game_actors.clone($game_variables[1],$game_variables[2])
#  => copie l'acteur dont l'id sotcké dans la variable 1 dans l'acteur dont l'id est sotcké dans la variable 2

class Game_Actors
  def clone(actor_id_orig,actor_id_dest)
    @data[actor_id_dest] = Game_Actor.new(actor_id_dest,actor_id_orig)
  end
end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader  :actor_model_id                # accessory 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
    @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

Explication du script :
On peux trouver surprenant que je ne touche pas à "game_party" . En fait , ce n'est pas necessaire car game_party ne stocke que peu d'informations sur le personnage (PV/PM actuel par exemple mais pas PV/PM maximum) et reference plutot game_actors .
La premiere classe modifiée est donc game_actors . C'est le tableau de tout les acteurs et c'est une des classe qui fait partie de la sauvegarde (donc si vous sauvez , vous retrouverez bien vos clones dans l'équipe en rechargeant plus tard) .
On modifie game_actor aussi . l'opération importante est d'ajouter une propriété "actor_model_id" qui est l'id de l'acteur modele utilisé . Toutes les methodes modifiées dans cette classe servent à utiliser cet ID pour ramener les informations du modele depuis $data_actors .
dricc
dricc
Membre

Nombre de messages : 2760
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

Clonage d'acteur Empty Re: Clonage d'acteur

Lun 16 Mai 2011 - 12:16
Version 2.0 !!!

Cette fois-ci , c'est beaucoup plus simple à utiliser .
Donner comme nom à votre acteur :
Code:
Squelette<model>
On fait simplement : Ajouter à l'équipe : --le nom de l'acteur-- dans un evenement .
Vous verrez alors apparaitre la fenetre de statut avec une question : voulez-vous renommer ?
Si vous répondez oui, vous pourrez donner un nom à votre squelette nouvellement recruté .
Si votre acteur d'appele juste "Ralph" , le script ne se declenche pas et vous obtenez l'acteur unique .
IMPORTANT : le niveau par défaut du clone recruté est dans une variable (32 pour le script en dessous) . N'oubliez pas de lui affecter une valeur avant d'jouter le membre à l'équipe .

Je cherche des idées d'amélioration . si vous en avez , hesitez pas .
Je pense en particulier à proposer un nom par défaut .

Code:

# actor clones
# par dricc
# http://rpgmakervx.1fr1.net/
# 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>/
  # 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
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                # accessory 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
    if pattern == 0
      temp_name = actor.name.gsub(CLONE_SETUP::ACTOR_CLONE_PATTERN) {nil}
      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, "Oui")
    self.contents.draw_text(4, WLH * 1, 92, WLH, "Non")
  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, 'Un ' + @actor_name + ' rejoint votre équipe')
    self.contents.draw_text(4, WLH * 1, 336, WLH, 'Voulez-vous lui donner un nom ?')
  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

Update 18/5 :
Démo
http://www.mediafire.com/?vz90uuvw2s32g69
dricc
dricc
Membre

Nombre de messages : 2760
Localisation : Lille
Distinction : Altruiste - Incarnation de la Patience [Mist']
Date d'inscription : 10/08/2009

Clonage d'acteur Empty Re: Clonage d'acteur

Jeu 26 Mai 2011 - 17:08
Et allez , encore une nouvelle version .

Cette fois , vous pouvez en plus choisir de "recolorier" l'acteur cloné . Et en passant , recolorier n'importe quelle acteur .
Pour savoir comment ça marche , allez voir dans la base de données , onglet "ennemis" . Si vous essayez de changer l'image du battler , vous apercevrez une barre "teinte" en bas . J'ai juste adapté ça aux acteurs .

Voila ce que ça peux donner :
Clonage d'acteur Dricc_12[/url]
Pauvre ralph , le voila devenu hulk Smile

C'est juste un add-on , si vous ne voulez pas utiliser le recoloriage , vous pouvez juste supprimer le 2éme script (pour éviter des problemes d'incompatibilité en particulier)

Demo :
http://www.mediafire.com/?r7cq71e972bwi93
Contenu sponsorisé

Clonage d'acteur Empty Re: Clonage d'acteur

Revenir en haut
Sujets similaires
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum