[RMXP] Character Data V. 1.2

OP
Mensajes
17
Reacciones
1
Puntos
0
Bueno este script... esta sencillo tambien XD ya estoy trabajando en las nueva version n_n
Descripcion:

Character Data, muestra biografias de tus personajes jugables y NPC. Teniendo cupo virtualmente para n personajes. Aunque actualmente no he probado mas de 20 (son 10 por pagina).
  • Muestra Face, Battler, y/o character solo con unpequeño cambio de variable.
  • Puedes poner hasta n datos; claro hasta que se llegue a un punto donde su visualizacion parezca limitada.
  • Paginas de 10 Personajes, pudiendo tener n paginas.
  • Seactivan las biografias conun interruptor, que se pueden definir en el mismo script.
  • Tambien se pueden definir el titulo de la ventana.
  • Se pueden configurar personajes de la base de datos, y de este extrae su nombre, su battler ysu character.

Instrucciones:
  • Llenar los datos, la explicacion para llenar los datos viene dentro del script.
  • Meter en Pictures (en dado caso de que se quieran faces) , archivos con Face_[Nombre] donde nombre es el nombre del personaje.
  • Realmenta el llenadode los datos es un poco complicado por lo cual pegare el script entero con ejemplo y de igual manera subire una demo.
  • Se llama con el siguiente script: $scene = Scene_CharacterData.new
  • Para Definir a donde quieren que regrese cuando canceles ir a la linea 390 y cambiar Scene_Map.new por lo que se requiera como, por ejemplo, Scene_Menu.new(2)

Registro de Cambios:
Version 1.2
  • Principal Cambio forma de añadir datos, resulta mas practica y entendible (aunque un poco mas extensa de codigo) y tambien evita poner informacion inecesario cuando no se reuqiere (como los name = "" en los ue ya traen id).
  • Poder omitir el campo de interruptor aun cuando este encendida la validacion, haciendo esto quiere decir que el personaje no depende del interruptor y se muestra siempre.
  • En el script viene el mismo ejemplo de los pasados pero conel nuevoformato de llenado de datos, y un poco mas de explicacion n_n

Version 1.1
  • Añadido poder activar/desactivar la opcion para que tome en cuenta interruptores o no, con solo la siguiente opcion DataISwitchActive = false

Script:
Código:
#======================================================================#
#  Character Data V. 1.2                                               #
#  ****** By Midnight Mooon                               ******       #
# Descripcion: Script para RPG Maker XP, que muestra Datos de          #
#     Personajes al estilo agenda.                                     #
#======================================================================#
module ConfigCharacterData
#======================================================================#
DataITitulo = "Character Data" # Modificar este para cambiar el titulo de la pantalla
# Aqui se configuran los label de los datos. Para mejor Visualizacion
# no se recomienda que sean muchos datos.
# En Cualquier caso la Info se muestra hasta abajo.
DataILabelName = ["Name"]
DataILabel = ["Age", "Class", "Race", "City", "Other"]
# Configuramos Opciones, de mostrar imagen. En caso de que sea un Personaje jugable
# no es necesario meter ni Battler ni Character.
DataIShowFace = true # Meter en Pitures/ una Face de 100x100 con el nombre Face_[Nombre del Personaje]
DataIShowBattler = true # Meter en Battlers/ un Battler con el nombre Battler_[Nombre del Personaje]
DataIShowCharacter = false # Meter en Characters/ un Character con el nombre Character_[Nombre del Personaje]
# Asi que en su lugar solo dejar comillas vacias ""

# Configurar Interruptores y Opciones.
DataISwitchActive = true

# Aqui se configuran los datos, de cada Personaje.
# Solo se escribira ID, a los personajes que esten dentro de la Base.
# Los demas no llevaran ese campo, como son por ejemplo el PJ 2 de este ejemplo.
# Si se pone un numero que no este dentro de la base mandara error.
# De igual manera a los Personajes que se les ponga ID.
# No debe tener ni el campo "Name", "Battler", ni "Character".
# Los datos definidos por el usuario debende tener una etiqueta igual a las definidas
# en DataILabel.
# La Info de personaje, para que sea multilinea, escribir un texto hasta que abarque
# hasta el punto requerido, cerrar el texto poner , y escribir otra linea.
# Si alguien me dice como transformar el texto multilinea para perfecta visualizacion
# coorrectamente, se lo agradeceria mucho.
DataIPlayer = [
  {
    "ID" => 1,
    "Switch" => 1,
    # Etiquetas Definidas por el usuario
    "Age" => "18",
    "Class" => "Guerrero",
    "Race" => "Humano",
    "City" => "Ibarath",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Alexis es un guerrero noble, que luchara para proteger",
       "a todos sus amigos y familia. Odia la maldad."
    ]
  },
  {
    #"Switch" => 2,
    "Name" => "Marco",
    # Etiquetas Definidas por el usuario
    "Age" => "24",
    "Class" => "Mago",
    "Race" => "Humano",
    "City" => "Asgard",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Fuerte Guerrero que lucha por la paz."
    ],
    "Battler" => "020-Hunter01",
    "Character" => "020-Hunter01"
  },
  {
    "Switch" => 3,
    "Name" => "Danao",
    # Etiquetas Definidas por el usuario
    "Age" => "15",
    "Class" => "Chaman",
    "Race" => "Humano",
    "City" => "Monte Olimpo",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Tiene un Gran corazon y una valentia sin igual."
    ],
    "Battler" => "021-Hunter02",
    "Character" => "021-Hunter02"
  },
  {
    "ID" => 8,
    "Switch" => 4,
    # Etiquetas Definidas por el usuario
    "Age" => "43",
    "Class" => "Monje",
    "Race" => "Humano",
    "City" => "Ibarath",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "Switch" => 5,
    "Name" => "Cristobal",
    # Etiquetas Definidas por el usuario
    "Age" => "24",
    "Class" => "Picaro",
    "Race" => "Humano",
    "City" => "Asgard",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ],
    "Battler" => "022-Hunter03",
    "Character" => "022-Hunter03"
  },
  {
    "Switch" => 6,
    "Name" => "Kari",
    # Etiquetas Definidas por el usuario
    "Age" => "18",
    "Class" => "Guerrero",
    "Race" => "Humano",
    "City" => "Monte Olimpo",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ],
    "Battler" => "025-Cleric01",
    "Character" => "025-Cleric01"
  },
  {
    "Switch" => 7,
    "Name" => "Dante",
    # Etiquetas Definidas por el usuario
    "Age" => "24",
    "Class" => "Mago",
    "Race" => "Humano",
    "City" => "Ibarath",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ],
    "Battler" => "026-Cleric02",
    "Character" => "026-Cleric02"
  },
  {
    "ID" => 2,
    "Switch" => 8,
    # Etiquetas Definidas por el usuario
    "Age" => "15",
    "Class" => "Chaman",
    "Race" => "Humano",
    "City" => "Asgard",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "ID" => 3,
    "Switch" => 9,
    # Etiquetas Definidas por el usuario
    "Age" => "43",
    "Class" => "Monje",
    "Race" => "Humano",
    "City" => "Monte Olimpo",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "ID" => 4,
    "Switch" => 10,
    # Etiquetas Definidas por el usuario
    "Age" => "24",
    "Class" => "Guerrero",
    "Race" => "Humano",
    "City" => "Ibarath",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "Switch" => 11,
    "Name" => "Mary",
    # Etiquetas Definidas por el usuario
    "Age" => "18",
    "Class" => "Mago",
    "Race" => "Humano",
    "City" => "Asgard",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ],
    "Battler" => "027-Cleric03",
    "Character" => "026-Cleric03"
  },
  {
    "ID" => 7,
    "Switch" => 12,
    # Etiquetas Definidas por el usuario
    "Age" => "24",
    "Class" => "Chaman",
    "Race" => "Humano",
    "City" => "Monte Olimpo",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "ID" => 6,
    "Switch" => 13,
    # Etiquetas Definidas por el usuario
    "Age" => "15",
    "Class" => "Monje",
    "Race" => "Humano",
    "City" => "Ibarath",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  },
  {
    "ID" => 5,
    "Switch" => 14,
    # Etiquetas Definidas por el usuario
    "Age" => "43",
    "Class" => "Picaro",
    "Race" => "Humano",
    "City" => "Asgard",
    "Other" => "Nada que Comentar",
    # Fin de etiquetas definidas por el usuario
    "Info" => [
      "Informacion Desconocida."
    ]
  }
]
#======================================================================#
end
#======================================================================#
#==============================================================================
# ** Método para dibujar los elementos **                           
#==============================================================================
class Window_Base < Window
   def I_draw_actor_face (name, x, y)
    #bitmap = RPG::Cache.character('Faces/Face_' + name, 0)
    bitmap = RPG::Cache.picture('Face_' + name)
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x - bitmap.width / 2, y - bitmap.height, bitmap, src_rect)
  end
  def I_draw_actor_battler(index, x, y) 
    if ConfigCharacterData::DataIPlayer[index]["ID"] != nil
      actor = Game_Actor.new(ConfigCharacterData::DataIPlayer[index]["ID"])
      battler = RPG::Cache.battler(actor.character_name, actor.character_hue)
      fw = battler.width
      fh = battler.height
      src_rect = Rect.new(0, 0, fw, fh)
      self.contents.blt(x - fw / 23, y - fh, battler, src_rect)
    else
      if not (ConfigCharacterData::DataIPlayer[index]["Battler"].nil? || ConfigCharacterData::DataIPlayer[index]["Battler"] == "")
        battler = RPG::Cache.battler(ConfigCharacterData::DataIPlayer[index]["Battler"], 0)
        fw = battler.width
        fh = battler.height
        src_rect = Rect.new(0, 0, fw, fh)
         self.contents.blt(x - fw / 23, y - fh, battler, src_rect)
      end
    end
  end
  def I_draw_actor_graphic(index, x, y)
    if ConfigCharacterData::DataIPlayer[index]["ID"] != nil
      actor = Game_Actor.new(ConfigCharacterData::DataIPlayer[index]["ID"])
      bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
      cw = bitmap.width / 4
      ch = bitmap.height / 4
      src_rect = Rect.new(0, 0, cw, ch)
       self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
    else
      if not (ConfigCharacterData::DataIPlayer[index]["Character"].nil? || ConfigCharacterData::DataIPlayer[index]["Character"] == "")
        bitmap = RPG::Cache.character(ConfigCharacterData::DataIPlayer[index]["Character"], 0)
        cw = bitmap.width / 4
        ch = bitmap.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
      end
    end
  end
end

#==============================================================================
# ** Ventana superior **
#==============================================================================
class Window_Status0 < Window_Base
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    w = self.contents.text_size(ConfigCharacterData::DataITitulo.split("n")[0]).width
    x = (640 - w - 48) / 2
    self.contents.draw_text(x, 0, 200, 32, ConfigCharacterData::DataITitulo)
  end
end
#==============================================================================
# ** Ventana de Hoja **
#==============================================================================
class Window_Status1 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 192, 65)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    texto = $scene.actual.to_s + "/" + $scene.total.to_s
    w = self.contents.text_size(texto).width
    x = (160 / 2) - (w / 2)
    self.contents.draw_text(x, 0, 50, 32, texto)
  end
end
#==============================================================================
# ** Ventana de Bienvenida **
#==============================================================================
class Window_Status2 < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(index)
    @index = index
    super(0, 0, 448, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if @index == -1
      self.contents.font.color = system_color
      texto = "Seleccione un personaje para ver su Biografia."
      w = self.contents.text_size(texto).width
      x = (448 / 2) - (w / 2)
      y = (415 / 2) - 16
      self.contents.draw_text(x, y, w, 32, texto)
    else
      # En caso de existir,construimos el objeto actor.
      if ConfigCharacterData::DataIPlayer[@index]["ID"] != nil
        actor = Game_Actor.new(ConfigCharacterData::DataIPlayer[@index]["ID"])
      end
      # Obtenemos los Datos.
      if ConfigCharacterData::DataIPlayer[@index]["ID"] != nil
        nombre = actor.name
      else
        nombre = ConfigCharacterData::DataIPlayer[@index]["Name"]
      end
      i = 0
      for s in ConfigCharacterData::DataILabel
        self.contents.font.size = 18
        label = s + ":"
        valor = ConfigCharacterData::DataIPlayer[@index][s]
        self.contents.font.color = system_color
        if ConfigCharacterData::DataIShowFace == true
          if i < 4 
            self.contents.draw_text(4 + 120, 40 + (i * 24), 300, 32, label)
          else
            self.contents.draw_text(4, 40 + (i * 24), 300, 32, label)
          end
        else
          self.contents.draw_text(4, 40 + (i * 24), 300, 32, label)
        end
        self.contents.font.color = normal_color
        if ConfigCharacterData::DataIShowFace == true
          if i < 4 
            self.contents.draw_text(4 + 120 + 60, 40 + (i * 24), 300, 32, valor)
          else
            self.contents.draw_text(4 + 60, 40 + (i * 24), 300, 32, valor)
          end
        else
          self.contents.draw_text(4 + 60, 40 + (i * 24), 300, 32, valor)
        end
        i += 1
      end
      
      # Escribimos los Elementos.
      self.contents.font.color = system_color
      self.contents.font.size = 30
      self.contents.draw_text(4, 4, self.contents.text_size(nombre).width, 32, nombre)
      if ConfigCharacterData::DataIShowFace == true
        I_draw_actor_face (nombre, 54, 138)
      end
      if ConfigCharacterData::DataIShowBattler == true
        I_draw_actor_battler (@index, 300, 360)
      end
      if ConfigCharacterData::DataIShowCharacter == true
        I_draw_actor_graphic (@index, 360, 45)
      end
      self.contents.font.color = normal_color
      self.contents.font.size = 18
      i = 0
      for s in ConfigCharacterData::DataIPlayer[@index]["Info"]
        self.contents.draw_text(4, 230 + (32 * i), self.contents.text_size(s).width, 32, s)
        i += 1
      end
    end
  end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command0 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(commands)
    # Compute window height from command quantity
    super(0, 0, 192, 32 * 11)
    @item_max = commands[1].size
    @commands = commands[1]
    @ids = commands[0]
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    y = 32 * index
    height = 32
    x = 4
    width = self.contents.width - 8
    rect = Rect.new(x, y, width, height)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

class Scene_CharacterData
  attr_accessor :actual
  attr_accessor :total
  
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @page = 0
     @actual = @page + 1
    i = 0
    @total = 1
    if ConfigCharacterData::DataISwitchActive == true
      for s in ConfigCharacterData::DataIPlayer
        if s["Switch"].nil?
          i += 1
          if i == 10
            @total += 1
            i = 0
          end
        else
          if $game_switches[s["Switch"]] == true
            i += 1
            if i == 10
              @total += 1
              i = 0
            end
          end
        end
      end
    else
      for s in ConfigCharacterData::DataIPlayer
        i += 1
        if i == 10
          @total += 1
          i = 0
        end
      end
    end
    @datos = return_options
    @command_window0 = Window_Command0.new(@datos)
    @command_window0.y = 64
    @status_window0 = Window_Status0.new
    @status_window1 = Window_Status1.new
    @status_window1.y = 352 + 64
    @status_window2 = Window_Status2.new(-1)
    @status_window2.y = 64
    @status_window2.x = 192
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @status_window0.dispose
    @status_window1.dispose
    @status_window2.dispose
    @command_window0.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @command_window0.update
    if @command_window0.active
      update_command
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::RIGHT)
      if @actual == @total
        return
      else
        @page += 1
        @actual += 1
        @command_window0.dispose
        @status_window1.dispose
        @datos = return_options
        @command_window0 = Window_Command0.new(@datos)
        @command_window0.y = 64
        @status_window1 = Window_Status1.new
        @status_window1.y = 352 + 64
      end
    end
    if Input.trigger?(Input::LEFT)
      if @actual == 1
        return
      else
        @page -= 1
        @actual -= 1
        @command_window0.dispose
        @status_window1.dispose
        @datos = return_options
        @command_window0 = Window_Command0.new(@datos)
        @command_window0.y = 64
        @status_window1 = Window_Status1.new
        @status_window1.y = 352 + 64
      end
    end
    if Input.trigger?(Input::C)
      @status_window2.dispose
      @status_window2 = Window_Status2.new(@datos[0][@command_window0.index])
      @status_window2.y = 64
      @status_window2.x = 192
    end
  end
  # Clase que devuelve los nombres para el menu segun la pagina.
  def return_options
      arreglo = [[],[]]
      i = 0
      j = 0
      if ConfigCharacterData::DataISwitchActive == true
        desac = 0
        if @page != 0
          for s in ConfigCharacterData::DataIPlayer
            if((@page - 1) * 10) <= j
              if s["Switch"] != nil
                if $game_switches[s["Switch"]] == false
                  desac += 1
                end
              end
              i += 1
            end
            j += 1
            if i >= 10
              break
            end
          end
        end
        i = 0
        j = 0
        for s in ConfigCharacterData::DataIPlayer
          if (@page * 10) + desac <= j
            if s["Switch"] != nil
              if $game_switches[s["Switch"]] == true
                arreglo[0][i] = j
                if s["ID"] != nil
                  actor = Game_Actor.new(s["ID"])
                  arreglo[1][i] = actor.name
                else
                  arreglo[1][i] = s["Name"]
                end
                i += 1
              end
            else
              arreglo[0][i] = j
              if s["ID"] != nil
                actor = Game_Actor.new(s["ID"])
                arreglo[1][i] = actor.name
              else
                arreglo[1][i] = s["Name"]
              end
              i += 1
            end
          end
          j += 1
          if i >= 10
            break
          end
        end
      else
        i = 0
        j = 0
        for s in ConfigCharacterData::DataIPlayer
          if (@page * 10) <= j
            arreglo[0][i] = j
            if s["ID"] != nil
              actor = Game_Actor.new(s["ID"])
              arreglo[1][i] = actor.name
            else
              arreglo[1][i] = s["Name"]
            end
            i += 1
          end
          j += 1
          if i >= 10
            break
          end
        end
      end
      return arreglo
  end
end

Imagenes:

rjh63o.jpg

33uy8gl.jpg

30vj9xd.jpg

35k90kx.jpg



Demo:
V 1.1 y 1.2 - http://www.mediafire.com/?42a4kxvhzwqewci (Vienen las dos versiones la 1.1 y la 1.2, solamente copiar el que se desee al implementarlo XD)
SAYONARA
 
Arriba Pie