You are on page 1of 45

#==============================================================================

# Easy Character Creator


#==============================================================================
# Par : Kotfire
# Version: 2.0
# La traduction fran�aise � �t� faite par PK93
# Date: 18/11/06
#------------------------------------------------------------------------------
# Options
#------------------------------------------------------------------------------
module Options
module Chara_Creator
PATH = []
for i in 0..10
PATH[i] = ""
end
# ----------------- EDITABLE (�vitez de toucher au reste du script !!!
--------------------
FILE = "Chara_Creator" # Nom du dossier
# -------Dossiers personalis�s---------
PATH[0] = "Corps"
PATH[1] = "Yeux"
PATH[2] = "Cheveux"
PATH[3] = "Vetement_1"
PATH[4] = "Vetement_2"
PATH[5] = "Chaussures"
PATH[6] = "Armures"
PATH[7] = "Casques"
PATH[8] = "Accessoires"
PATH[9] = "Boucliers"
PATH[10] = "Armes"
# ---------Options--------------------
# Noms al�atoires
NAMES = ["Kain", "Silas", "Cecil", "Setzer", "Elissa", "Realm"]
MAX_CHAR = 9 # Nombre maximum de lettres pour les noms
# Classes disponibles {ID de la base de donn�e}
CLASSES = [1,2,3,4,5,6,7,8]
# Noms des genres
GENDER = ["Homme", "Femme"]
# Sorts
MAX_SKILLS = 9 # Nombre maximum de sorts !
SKILLS = [1,2,3,4,5,25,26,27,28,29,30,50,66,68,80] # Sorts disponibles {ID de
la base de donn�e}
# Armes disponibles {ID de la base de donn�e}
WEAPONS = [1]
# Armures disponibles {ID de la base de donn�e}
ARMORS = [1,5,7,13,14,21,33,34]
# --------Extraction de l'�quipementEquipement par Kotfire-------
Width = 128 # largeur
Height = 192 # hauteur
Frames = 4 # nombre de frames
Directions = 4 # Nombre de direction
# ---------- FIN DE L'EDITABLE --------------
#--------------------------------------------------------------------------
def self.get_file(gender, type, item_id)

id = type + 5
dir = "Graphics/Chara_Creator/#{gender}/"+ PATH[id]
case type
when 5
file_name = $data_weapons[item_id].name if item_id != 0
#---------------------------------------------------------
# Weapon = type 5
#---------------------------------------------------------
return ["#{gender}/"+PATH[id]+"/#{file_name}",0] if file_name != nil
else
file_name = $data_armors[item_id].name if item_id != 0
#---------------------------------------------------------
# Armors = type 0..4
#---------------------------------------------------------
return ["#{gender}/"+PATH[id]+"/#{file_name}",0] if file_name != nil
end
return false
end
#--------------------------------------------------------------------------
def self.get_itemid(order_i,actor)
return -1 if actor == nil
case order_i
when 0 # Skin
return actor.skin
when 1 # Body Armor
return actor.armor3_id
when 2 # Helmet
return actor.armor2_id
when 3 # Assesoiry
return actor.armor4_id
when 4 # Shield
return actor.armor1_id
when 5 # Weapon
return actor.weapon_id
end
end
end

end

#=============================================================================
# Read_Graphics
#=============================================================================

class Read_Graphics
#--------------------------------------------------------------------------
attr_reader :group
attr_reader :names
#--------------------------------------------------------------------------
def initialize(filename=nil)
@group = []
@names = []
@count = 0
@number = -1
read_file(filename) if filename != nil
end
#--------------------------------------------------------------------------
def read_file(filename)
lines = IO.readlines(filename)
loop do
break if lines[@count].include?("[End]")
if lines[@count].include?("[")
@names.push(lines[@count].delete("[]").split(" ")[0])
@number += 1
@group[@number] = []
break if @count >= lines.size - 1
loop do
@count += 1
break if lines[@count].include?("[")
@group[@number].push(lines[@count].split(" ")[0])
break if @count >= lines.size - 1
end
else
@count += 1
end
end
end
end

#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor < Game_Battler

#----------------------------------------------------------------------------
attr_accessor :skin
attr_accessor :gender
attr_accessor :skills
#----------------------------------------------------------------------------

alias kot_characreator_gameactor_setup setup


def setup(actor_id)
@skin = []
@gender = Options::Chara_Creator::GENDER[0]
kot_characreator_gameactor_setup(actor_id)
end
#--------------------------------------------------------------------------
# Id: 0 body
# 1 eyes
# 2 hair
# 3 underwear up
# 4 underwear down
# 5 foots
#--------------------------------------------------------------------------
def set_skin(id, value)
# If value is not the 'remove' code.
if value != nil and value != ''
# Put the filename into the body array.
if value.include?(Options::Chara_Creator::GENDER[0]) or
value.include?(Options::Chara_Creator::GENDER[1])
@skin[id] = value
else
@skin[id] = "#{@gender}/" + value
end
else
# Clear the filename in the body array.
@skin[id] = nil
end
end
#--------------------------------------------------------------------------
# * Get's the needed equipments / Also determines ordeR!
#--------------------------------------------------------------------------
def get_equipments
# Empty's equipments array for use
equipments = []
# Add the skin/default char and eyes to the array
equipments.push([@skin[0], @character_hue]) if @skin[0] != nil
equipments.push(["#Characters/#{@character_name}", @character_hue]) if
equipments.size != 1
equipments.push([@skin[3], @character_hue]) if @skin[3] != nil
equipments.push([@skin[4], @character_hue]) if @skin[4] != nil
equipments.push([@skin[5], @character_hue]) if @skin[5] != nil
equipments.push([@skin[1], @character_hue]) if @skin[1] != nil
# Add the hair to the array, if any is set
equipments.push([@skin[2], @character_hue]) if @skin[2] != nil
# Add the equipments, if there is a file for the equipments
for equipnumber in 1...6
# First, get the item_id of the equipment
item_id = Options::Chara_Creator.get_itemid(equipnumber, self)
# Second, get the filename and hue of the file attached to the id
item = Options::Chara_Creator.get_file(@gender, equipnumber, item_id)
# Put the item into the array if a file name was found
equipments.push(item) unless item == false or item == nil
end
# Return all the equipments
return equipments
end
#--------------------------------------------------------------------------
# * Get Class Name
#--------------------------------------------------------------------------
def class_name
return $data_classes[@class_id].name if @class_id != 1000
return "..."
end
#--------------------------------------------------------------------------
# * Change Class ID
# class_id : new class ID
#--------------------------------------------------------------------------
def class_id=(class_id)
if $data_classes[class_id] != nil
@class_id = class_id
# Remove items that are no longer equippable
unless equippable?($data_weapons[@weapon_id])
equip(0, 0)
end
unless equippable?($data_armors[@armor1_id])
equip(1, 0)
end
unless equippable?($data_armors[@armor2_id])
equip(2, 0)
end
unless equippable?($data_armors[@armor3_id])
equip(3, 0)
end
unless equippable?($data_armors[@armor4_id])
equip(4, 0)
end
end
if class_id == 1000
@class_id = class_id
end
end
#--------------------------------------------------------------------------
# * Set Equipment
# equip_type : type of equipment
# id : weapon or armor ID (If 0, remove equipment)
#--------------------------------------------------------------------------
def set_equip(equip_type, id)
case equip_type
when 0 # Weapon
@weapon_id = id
when 1 # Shield
update_auto_state($data_armors[@armor1_id], $data_armors[id])
@armor1_id = id
when 2 # Head
update_auto_state($data_armors[@armor2_id], $data_armors[id])
@armor2_id = id
when 3 # Body
update_auto_state($data_armors[@armor3_id], $data_armors[id])
@armor3_id = id
when 4 # Accessory
update_auto_state($data_armors[@armor4_id], $data_armors[id])
@armor4_id = id
end
end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Aliases
#--------------------------------------------------------------------------
alias kot_characreator_spritecharacter_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# character : character (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
# Make an body array
@skin_id = Array.new(6,nil)
# How many id's are there?
@equips_id = Array.new(5,0)
# What kind is the character?
if character.is_a?(Game_Player)
@actor = $game_party.actors[0]
else
@actor = nil
end
kot_characreator_spritecharacter_initialize(viewport, character)
end
#--------------------------------------------------------------------------
# * Did the equipment changed?
#--------------------------------------------------------------------------
def changed_equipment?
# According to the kind of the actor, the check is made...
if character.is_a?(Game_Player)
for equipment_id in 1...6
item_id = Options::Chara_Creator.get_itemid(equipment_id, @actor)
return true if @equips_id[equipment_id] != item_id
end
skin = Options::Chara_Creator.get_itemid(0, @actor)
for i in 0..5
return true if @skin_id[i] != skin[i]
end
else
return false
end
end
#--------------------------------------------------------------------------
# * Update known equipment
#--------------------------------------------------------------------------
def update_equipment
# Remember tile ID, file name and hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# If the actor isent supported, return immideatly
return if @actor == nil
# According to the kind of the actor, the update is made...
if character.is_a?(Game_Player)
for equipment in 1...6
@equips_id[equipment] == Options::Chara_Creator.get_itemid(equipment,
@actor)
end
skin = Options::Chara_Creator.get_itemid(0, @actor)
for bodypart in 0..5
@skin_id[bodypart] = skin[bodypart]
end
end
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
super()
# If something changed...
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue or
changed_equipment?
# First, update the information known
update_equipment
# Then update the graphics
update_tile
end
# Set visible situation
self.visible = (not @character.transparent)
# If graphic is character
if @tile_id == 0
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# Set sprite coordinates
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# Set opacity level, blend method, and bush depth
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# Animation
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
#--------------------------------------------------------------------------
# * Update Tile
#--------------------------------------------------------------------------
def update_tile
# If tile ID value is valid
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# If tile ID value is invalid (and thus a character is in that place ::))
else
# Create an Equpment awway
equips = []
# If handling the player
if @actor != nil and @actor != 'event'
equips = @actor.get_equipments
end
# Dispose old bitmap
self.bitmap.dispose unless self.bitmap == nil
# Draws the character bitmap
bmp = RPG::Cache.character(@character_name, @character_hue)
self.bitmap = Bitmap.new(bmp.width, bmp.height)
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
# If character fits the size
if equips.size > 0 and bmp.width == Options::Chara_Creator::Width and
bmp.height == Options::Chara_Creator::Height
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}",
graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
self.bitmap.blt(0, 0, graphic_equipment, src_rect, 255)
end
elsif equips.size > 0
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}",
graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
self.bitmap.blt(0, 0, graphic_equipment, src_rect, 255)
end
else
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
self.bitmap.blt(0, 0, bmp, src_rect, 255)
end
# Divide the drawings into pieces ^^
@cw = bitmap.width / Options::Chara_Creator::Frames
@ch = bitmap.height / Options::Chara_Creator::Directions
self.ox = @cw / 2
self.oy = @ch
end
end
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Draw Graphic
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
return if actor == nil
# Get the equipments
equips = actor.get_equipments
# Set the basement
bmp = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bmp.width / Options::Chara_Creator::Frames
ch = bmp.height / Options::Chara_Creator::Directions
src_rect = Rect.new(0, 0, cw, ch)
# Draw the equipments
if equips.size > 0 and bmp.width == Options::Chara_Creator::Width and
bmp.height == Options::Chara_Creator::Height
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}", graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
self.contents.blt(x - cw / 2, y - ch, graphic_equipment, src_rect, 255)
end
elsif equips.size > 0
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}", graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
self.contents.blt(x - cw / 2, y - ch, graphic_equipment, src_rect, 255)
end
else
src_rect = Rect.new(0, 0, bmp.width, bmp.height)
self.contents.blt(0, 0, bmp, src_rect, 255)
end
end
end

#==============================================================================
# Window Horizontal
#==============================================================================
class Window_HCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(commands, help = [], width = 640, height = 64)
super(0, 0, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = commands
@item_max = @commands.size
@column_max = @commands.size
@help_text = help
@finished = []
for i in 0..@item_max
@finished[i] = false
end
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color) if finished?(i-1)
disable_item(i) if !finished?(i-1)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
x = width / @item_max * index
w = width / @item_max - 32
self.contents.draw_text(x, 0, w, 32, @commands[index], 1)
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
def update_help
unless self.index > @help_text.size - 1
@help_window.set_text(@help_text[self.index])
else
@help_window.set_text("")
end
end
#--------------------------------------------------------------------------
def finished(index,value)
@finished[index] = value if value == true or value == false
end
#--------------------------------------------------------------------------
def finished?(index=self.index)
return true if @finished[index]
return true if index < 0
end
#--------------------------------------------------------------------------
def all_finished?
for i in 0...@commands.size
return false if !@finished[i]
end
return true
end
end
#==============================================================================
# Window IconCommand
#==============================================================================
class Window_IconCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(icon_names, align = "horizontal", size = 640)
super(200, 200, icon_names.size * 32 + 32, size) if align == "horizontal"
super(200, 200, size, icon_names.size * 32 + 32) if align == "vertical"
self.contents = Bitmap.new(self.width - 32, self.height - 32)
@icon_names = icon_names
@item_max = @icon_names.size
@column_max = 1 if align == "vertical"
@column_max = 2 if align == "horizontal"
self.visible = false
self.active = false
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
#--------------------------------------------------------------------------
def draw_item(index, color)
x = 4 + index % @column_max * 32
y = index / @column_max * 32
@bitmap = RPG::Cache.icon(@icon_names[index])
self.contents.blt(x, y + 4, @bitmap, Rect.new(0, 0, 24, 24))
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
def update_cursor_rect
cursor_width = @bitmap.width + 10
# Calculate cursor coordinates
x = @index % @column_max * 32
y = @index / @column_max * 32 - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, 32)
end
end

#==============================================================================
# ** Window_CreateParty
#==============================================================================

class Window_CreateParty < Window_Selectable


#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 88 * $game_party.actors.size)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 88
actor = $game_party.actors[i]
self.contents.font.color = system_color
text_width = self.contents.text_size("Nom: ").width
self.contents.draw_text(x, y, text_width, 32, "Nom: ")
text_width2 = self.contents.text_size("Classe: ").width
self.contents.draw_text(x, y + 25, text_width2, 32, "Classe: ")
text_width3 = self.contents.text_size("Genre: ").width
self.contents.draw_text(x + 250, y, text_width3, 32, "Genre: ")
self.contents.font.color = normal_color
draw_actor_graphic(actor, x - 40, y + 53)
draw_actor_name(actor, x + text_width, y)
draw_actor_class(actor, x + text_width2, y + 25)
bitmap = RPG::Cache.icon(actor.gender)
self.contents.blt(x + 250 + text_width3, y + 4, bitmap, Rect.new(0, 0, 24,
24))
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 88, self.width - 32, 56)
end
end
end

#==============================================================================
# ** Window_Set_EquipItem
#==============================================================================

class Window_Set_EquipItem < Window_Selectable


#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
# equip_type : equip region (0-3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 256, 640, 224)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add equippable weapons
if @equip_type == 0
weapon_set = Options::Chara_Creator::WEAPONS
for i in 1...$data_weapons.size
if weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# Add equippable armor
if @equip_type != 0
armor_set = Options::Chara_Creator::ARMORS
for i in 1...$data_armors.size
if armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# Add blank page
@data.push(nil)
# Make a bit map and draw all items
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_General
#==============================================================================
class Window_General < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(names)
super(160, 200, 250, names.size * 32 + 32)
@item_max = names.size
@names = names
@actor = $game_party.actors[0]
self.contents = Bitmap.new(self.width - 32, self.height - 32)
self.active = false
self.visible = false
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@commands = [@actor.name, @actor.class_name, @actor.gender]
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 = system_color
name_size = self.contents.text_size(@names[index]).width
self.contents.draw_text(4, 32 * index, name_size, 32, @names[index])
self.contents.font.color = color
command_size = self.contents.text_size(@commands[index]).width
rect = Rect.new(4 + name_size, 32 * index, command_size, 32)
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
#--------------------------------------------------------------------------
def set(actor_id)
@actor = $game_party.actors[actor_id]
refresh
end
#--------------------------------------------------------------------------
def set_actor(actor)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
def actor
return @actor
end
end

#==============================================================================
# ** Window_Set_Class
#==============================================================================

class Window_Set_Class < Window_Selectable


#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@class_id = commands
self.contents = Bitmap.new(self.width - 32, self.height - 32)
self.active = false
self.visible = false
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
if $data_classes[@class_id[index]] != nil
command = $data_classes[@class_id[index]].name
else
command = "None"
end
rect = Rect.new(4, 32 * index, self.contents.width, 32)
self.contents.draw_text(rect, command)
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
#--------------------------------------------------------------------------
def class_id
return @class_id[self.index]
end
end
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
# This window displays usable skills on the skill and battle screens.
#==============================================================================

class Window_Set_Skill < Window_Selectable


#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor, skills)
super(20, 100, 250, 352)
@actor = actor
@skills = skills
@skill_asigned = []
for i in 0...@skills.size
@skill_asigned[i] = false
end
@column_max = 1
refresh
self.index = 0
end
#--------------------------------------------------------------------------
def data
return @data
end
#--------------------------------------------------------------------------
# * Acquiring Skill
#--------------------------------------------------------------------------
def skill(index=self.index)
return @data[index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...@skills.size
skill = $data_skills[@skills[i]]
if skill != nil
@data.push(skill)
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
if @skill_asigned[i]
color = disabled_color
else
color = normal_color
end
draw_item(i, color)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
skill = @data[index]
x = 4 + index % @column_max
y = index / @column_max * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
end
#--------------------------------------------------------------------------
def skill_asigned(index, value)
@skill_asigned[index] = value if value == true or value == false
refresh
end
#--------------------------------------------------------------------------
def skill_asigned?(index = self.index)
return true if @skill_asigned[index]
end
end
#==============================================================================
# ** Window_Actor_Skill
#==============================================================================

class Window_Actor_Skill < Window_Base


#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor)
super(320, 64, 320, 64)
@actor = actor
@column_max = 9
@data = []
for i in 0...@actor.skills.size
skill = $data_skills[@actor.skills[i]]
if skill != nil
@data.push(skill)
end
end
update_actor_skills
refresh
end
#--------------------------------------------------------------------------
def update_actor_skills
@actor.skills = []
for skill in @data
@actor.skills.push(skill.id)
end
end
#--------------------------------------------------------------------------
def data
return @data
end
#--------------------------------------------------------------------------
# * Acquiring Skill
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.size
if @item_max > 0
max = (@item_max + @column_max - 1) / @column_max
self.height = 32 + max * 32
self.contents = Bitmap.new(width - 32, self.height - 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
self.contents.font.color = normal_color
x = 4 + index % @column_max * 32
y = index / @column_max * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
end
#--------------------------------------------------------------------------
def push_skill(skill)
if skill != nil
@data.push(skill)
update_actor_skills
refresh
end
end
#--------------------------------------------------------------------------
def delete_skill(skill)
if skill != nil
@data.delete(skill)
update_actor_skills
refresh
end
end
end
#==============================================================================
# ** Window_SkillStats
#==============================================================================

class Window_SkillStats < Window_Base


#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(skill)
super(0, 0, 320, 200)
self.contents = Bitmap.new(width - 32, height - 32)
@skill = skill
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @skill != nil
self.contents.font.color = system_color
name_size = self.contents.text_size("Nom: ").width
self.contents.draw_text(0, 0, name_size, 32, "Nom: ")
scope_size = self.contents.text_size("Cible: ").width
self.contents.draw_text(0, 32, scope_size, 32, "Cible: ")
use_size = self.contents.text_size("Utilisable: ").width
self.contents.draw_text(0, 64, use_size, 32, "Utilisable: ")
power_size = self.contents.text_size("Taux d'effet: ").width
self.contents.draw_text(0, 96, power_size, 32, "Taux d'effet: ")
spcost_size = self.contents.text_size("SP: ").width
power_textsize = self.contents.text_size("#{@skill.power}").width
self.contents.draw_text(10 + power_size + power_textsize, 96, spcost_size,
32, "SP: ")
self.contents.font.color = normal_color
self.contents.draw_text(name_size, 0, 170, 32, "#{@skill.name}")
case @skill.scope
when 0
scope_text = "..."
when 1
scope_text = "Enemis"
when 2
scope_text = "Tout les enemis"
when 3
scope_text = "Alli�"
when 4
scope_text = "Tout les alli�s"
when 5
scope_text = "Alli� mort"
when 6
scope_text = "Tout les alli�s morts"
when 7
scope_text = "H�ros"
end
self.contents.draw_text(scope_size, 32, 218, 32, scope_text)
case @skill.occasion
when 0
use_text = "Toujours"
when 1
use_text = "En combat"
when 2
use_text = "Dans le menu"
when 3
use_text = "Jamais"
end
self.contents.draw_text(use_size, 64, 218, 32, use_text)
self.contents.draw_text(power_size, 96, power_textsize, 32,
"#{@skill.power}")
x_spcost = 10 + power_size + power_textsize + spcost_size
spcost_textsize = self.contents.text_size("#{@skill.sp_cost}").width
self.contents.draw_text(x_spcost, 96, spcost_textsize, 32,
"#{@skill.sp_cost}")
self.contents.draw_text(0, 138, 320, 32, "#{@skill.description}")
if @skill.hit <= 25
color = knockout_color
elsif @skill.hit <= 50
color = crisis_color
elsif @skill.hit <= 75
color = normal_color
elsif @skill.hit > 75
color = Color.new(9,233,25)
end
self.contents.font.color = color
self.contents.draw_text(232, 96, 64, 32, "#{@skill.hit}%")
bitmap = RPG::Cache.icon(@skill.icon_name)
self.contents.blt(250, 4, bitmap, Rect.new(0, 0, 24, 24))
end
end
def set(skill)
if skill != @skill
@skill = skill
refresh
end
end
end
#==============================================================================
# ** Window_SkillNumber
#==============================================================================

class Window_SkillNumber < Window_Base


#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 132, 64)
self.contents = Bitmap.new(self.width - 32, self.height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
@text = "#{@actor.skills.size} / #{Options::Chara_Creator::MAX_SKILLS}"
@text_size = self.contents.text_size(@text).width
self.width = @text_size + 40
self.contents = Bitmap.new(@text_size + 8, self.height - 32)
self.contents.draw_text(4, 0, @text_size, 32, @text)
end
end
#==============================================================================
# ** Window_Object
#==============================================================================

class Window_Object < Window_Selectable


#--------------------------------------------------------------------------
# * Object Initialization
# actor : actor
#--------------------------------------------------------------------------
def initialize(actor, type)
super(20, 100, 320, 128)
@actor = actor
@type = type
@objects = Options::Chara_Creator::GRAPHICS.group[@type]
@path = Options::Chara_Creator::PATH[@type]
width = Options::Chara_Creator::Width / Options::Chara_Creator::Frames
@height = Options::Chara_Creator::Height / Options::Chara_Creator::Directions
self.height = [@height + (@height * 2), 170].min
@column_max = self.width / (width + 10)
refresh
self.index = 0
self.active = false
end
#--------------------------------------------------------------------------
def objects
return @objects
end
#--------------------------------------------------------------------------
def set(type)
@objects = Options::Chara_Creator::GRAPHICS.group[type]
@path = Options::Chara_Creator::PATH[type]
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# If item count is not 0, make a bit map and draw all items
@item_max = @objects.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * @height)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
file = "#{@actor.gender}/#{@path}/#{@objects[index]}"
bmp = RPG::Cache.equipment(file, @actor.character_hue)
@cw = bmp.width / Options::Chara_Creator::Frames
@ch = bmp.height / Options::Chara_Creator::Directions
src_rect = Rect.new(0, 0, @cw, @ch)
x = (@cw / 2) + index % @column_max * @cw
y = @ch + index / @column_max * @ch
self.contents.blt(x - @cw / 2, y - @ch, bmp, src_rect, 255)
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
cursor_width = @cw + 3
cursor_height = @ch + 3
# Calculate cursor coordinates
x = @index % @column_max * @cw
y = @index / @column_max * @ch - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, cursor_height)
end
end

#==============================================================================
# ** Window_Actor_Graphic
#==============================================================================

class Window_Actor_Graphic < Window_Base


#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 0, 150, 150)
w = Options::Chara_Creator::Width / Options::Chara_Creator::Frames
h = Options::Chara_Creator::Height / Options::Chara_Creator::Directions
self.width = [w * 4, 150].min
self.height = [h * 3, 200].min
self.contents = Bitmap.new(self.width - 32, self.height - 32)
@x = self.x + (self.width / 2) - (w / 2)
@y = self.y + (self.height / 2) + (h / 3)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_graphic(@actor, @x, @y)
end
end

#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================

class Window_SaveFile < Window_Base


#--------------------------------------------------------------------------
# * Object Initialization
# file_index : save file index (0-3)
# filename : file name
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(0, 64 + file_index % 4 * 104, 640, 104)
self.contents = Bitmap.new(width - 32, height - 32)
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@equipment = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw file number
self.contents.font.color = normal_color
name = "File#{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# If save file exists
if @file_exist
# Draw character
for i in 0...@equipment.size
# Get the equipments
equips = @equipment[i]
bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
cw = bitmap.rect.width / Options::Chara_Creator::Frames
ch = bitmap.rect.height / Options::Chara_Creator::Directions
x = 300 - @characters.size * 32 + i * 64 - cw / 2
y = 68
src_rect = Rect.new(0, 0, cw, ch)
# Draw the equipments
if equips.size > 0 and bitmap.width == Options::Chara_Creator::Width and
bitmap.height == Options::Chara_Creator::Height
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}",
graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
self.contents.blt(x - cw / 2, y - ch, graphic_equipment, src_rect,
255)
end
elsif equips.size > 0
for graphic in equips
next if graphic[0] == nil
if graphic[0].include?("#Characters/")
graphic_equipment = RPG::Cache.graphic("#{graphic[0]}",
graphic[1].to_i)
else
graphic_equipment = RPG::Cache.equipment("#{graphic[0]}",
graphic[1].to_i)
end
self.contents.blt(x - cw / 2, y - ch, graphic_equipment, src_rect,
255)
end
else
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(0, 0, bitmap, src_rect, 255)
end
end
# Draw play time
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 8, 600, 32, time_string, 2)
# Draw timestamp
self.contents.font.color = normal_color
time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(4, 40, 600, 32, time_string, 2)
end
end
end

#==============================================================================
# ** Scene_Name
#==============================================================================
class Scene_Name

def initialize(go_to = Scene_Map.new)


@go_to = go_to
end

alias kot_characreator_scenename_update update


def update
# If C button was pressed
if Input.trigger?(Input::C)
# If cursor position is at [OK]
if @input_window.character == nil
# If name is empty
if @edit_window.name == ""
# Return to default name
@edit_window.restore_default
# If name is empty
if @edit_window.name == ""
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
return
end
# Change actor name
@actor.name = @edit_window.name
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
$scene = @go_to
return
end
# If cursor position is at maximum
if @edit_window.index == $game_temp.name_max_char
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If text character is empty
if @input_window.character == ""
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Add text character
@edit_window.add(@input_window.character)
return
end
kot_characreator_scenename_update
end
end

#==============================================================================
# ** Scene_Save
#==============================================================================

class Scene_Save < Scene_File

#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
equipment = []
for j in 0...$game_party.actors.size
actor = $game_party.actors[j]
equipment.push(actor.get_equipments)
end
# Write character data for drawing save file
Marshal.dump(characters, file)
# Equipo
Marshal.dump(equipment, file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end

#==============================================================================
# ** Scene_Load
#==============================================================================

class Scene_Load < Scene_File

#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
# Read character data for drawing save file
characters = Marshal.load(file)
equipment = Marshal.load(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
# Read each type of game object
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
# Load map
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# Refresh party members
$game_party.refresh
end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title

#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
for actor in $game_party.actors
actor.name = ""
actor.class_id = 1000
actor.gender = ""
actor.set_graphic("None", actor.character_hue, actor.battler_name,
actor.battler_hue)
actor.skills = []
for i in 0..5
actor.set_equip(i, 0)
end
end
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update

# A Scene_Create
$scene = Scene_Create.new
end
end

#==============================================================================
# ** Scene_Set_Equip
#==============================================================================

class Scene_Set_Equip
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.actors[@actor_index]
# Make windows
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_Set_EquipItem.new(@actor, 0)
@item_window2 = Window_Set_EquipItem.new(@actor, 1)
@item_window3 = Window_Set_EquipItem.new(@actor, 2)
@item_window4 = Window_Set_EquipItem.new(@actor, 3)
@item_window5 = Window_Set_EquipItem.new(@actor, 4)
# Associate help window
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# Set cursor position
@right_window.index = @equip_index
refresh
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Set item window to visible
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# Get currently equipped item
item1 = @right_window.item
# Set current item window to @item_window
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# If right window is active
if @right_window.active
# Erase parameters for after equipment change
@left_window.set_new_parameters(nil, nil, nil)
end
# If item window is active
if @item_window.active
# Get currently selected item
item2 = @item_window.item
# Change equipment
last_hp = @actor.hp
last_sp = @actor.sp
@actor.set_equip(@right_window.index, item2 == nil ? 0 : item2.id)
# Get parameters for after equipment change
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
# Return equipment
@actor.set_equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# Draw in left window
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@left_window.update
@right_window.update
@item_window.update
refresh
# If right window is active: call update_right
if @right_window.active
update_right
return
end
# If item window is active: call update_item
if @item_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when right window is active)
#--------------------------------------------------------------------------
def update_right
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Create.new(3,2,@actor_index)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If equipment is fixed
if @actor.equip_fix?(@right_window.index)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Activate item window
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play equip SE
$game_system.se_play($data_system.equip_se)
# Get currently selected data on the item window
item = @item_window.item
# Change equipment
@actor.set_equip(@right_window.index, item == nil ? 0 : item.id)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
end
end
end

#==============================================================================
# ** Scene_Set_Skill
#==============================================================================

class Scene_Set_Skill
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.actors[@actor_index]
# Make windows
@help_window = Window_Help.new
@number_window = Window_SkillNumber.new(@actor)
@number_window.x = 640 - @number_window.width
@help_window.width = @help_window.width - @number_window.width
@help_window.contents = Bitmap.new(@help_window.width - 32,
@help_window.height - 32)
@help_window.set_text(" Ajouter/retirer un sort")
skills = Options::Chara_Creator::SKILLS
@skill_window = Window_Set_Skill.new(@actor, skills)
@actor_skills = Window_Actor_Skill.new(@actor)
@skill_stats = Window_SkillStats.new(@skill_window.skill)
@skill_stats.x = 630 - @skill_stats.width
@skill_stats.y = @actor_skills.y + @actor_skills.height + 30
@skill_stats.set(@skill_window.skill)
for skill in @actor_skills.data
@skill_window.skill_asigned(@skill_window.data.index(skill),true) if
@skill_window.data.include?(skill)
end
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@number_window.dispose
@help_window.dispose
@skill_window.dispose
@skill_stats.dispose
@actor_skills.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@number_window.x = 640 - @number_window.width
@help_window.width = @number_window.x
@skill_stats.y = @actor_skills.y + @actor_skills.height + 30
# Update windows
@number_window.update
@help_window.update
@skill_window.update
@skill_stats.update
@actor_skills.update
@skill_stats.set(@skill_window.skill)
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Create.new(2,2, @actor_index)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
if
@skill_window.skill_asigned?(@skill_window.data.index(@skill_window.skill))
$game_system.se_play($data_system.cancel_se)
@actor_skills.delete_skill(@skill_window.skill)
@skill_window.skill_asigned(@skill_window.data.index(@skill_window.skill),
false)
else
if @actor.skills.size >= Options::Chara_Creator::MAX_SKILLS
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@actor_skills.push_skill(@skill_window.skill)
@skill_window.skill_asigned(@skill_window.data.index(@skill_window.skill),
true)
end
@number_window.refresh
return
end
end

end

#==============================================================================
# ** Scene_Create
#==============================================================================

class Scene_Create
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0, phase = 0, phase_index = 0)
@menu_index = menu_index
@phase = phase
@phase_index = phase_index
read_graphic = Read_Graphics.new("#{Options::Chara_Creator::FILE}.ini")
Options::Chara_Creator.const_set("GRAPHICS", read_graphic) unless
Options::Chara_Creator.const_defined? "GRAPHICS"
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Commandos
s1 = "General"
s2 = "Apparence"
s3 = "Magie"
s4 = "Equipement"
s5 = "Commencer � jou� !"
#Texto de ayuda
h1 = " Informations g�n�rales"
h2 = " Apparence du h�ros"
h3 = " Choix des sorts"
h4 = " Choix de l'�quipement"
h5 = " Retour au jeu"
help = [h1, h2, h3, h4, h5]
@command_window = Window_HCommand.new([s1, s2, s3, s4, s5], help)
@command_window.index = @menu_index
@help_window = Window_Help.new
@command_window.help_window = @help_window
@command_window.help_window.y = 64
# If number of party members is 0
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
end
# Make status window
@status_window = Window_CreateParty.new
@status_window.x = 0
@status_window.y = 128
@general_window = Window_General.new(["Nom: ", "Classe: ", "Genre: "])
@general_window.z = @status_window.z + 2
i1 = Options::Chara_Creator::GENDER[0]
i2 = Options::Chara_Creator::GENDER[1]
@icon_command = Window_IconCommand.new([i1, i2], "horizontal", 64)
@icon_command.z = @general_window.z + 2
@icon_command.y = @general_window.y + @general_window.height - 64
classes = Options::Chara_Creator::CLASSES
@class_command = Window_Set_Class.new(160, classes)
@class_command.height = @general_window.height
@class_command.z = @icon_command.z + 2
@class_command.y = @general_window.y
@general_window.x = 320 - (@general_window.width + @class_command.width) / 2
@icon_command.x = @general_window.x + @general_window.width
@class_command.x = @general_window.x + @general_window.width
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@help_window.dispose
@status_window.dispose
@general_window.dispose
@icon_command.dispose
@class_command.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
actor_id = 0
unless @command_window.all_finished?
loop do
actor = $game_party.actors[actor_id]
if actor.name != "" && actor.class_id != 1000 && actor.gender != ""
if actor_id == $game_party.actors.size - 1
@command_window.finished(0, true)
@command_window.refresh
if actor.skin[0] != nil
@command_window.finished(1, true)
@command_window.finished(2, true)
@command_window.finished(3, true)
@command_window.refresh
end
actor_id = -1
break
else
if actor_id == $game_party.actors.size - 1
actor_id = -1
break
end
actor_id += 1
end
else
actor_id = 0
break
end
end
end
# Update windows
@command_window.update
@help_window.update
@status_window.update
@general_window.update
@icon_command.update
@class_command.update
case @phase
when 1
@command_window.active = false
@status_window.active = false
@status_window.index = $game_party.actors.index(@phase_index)
@general_window.set_actor(@phase_index)
@general_window.refresh
@general_window.active = true
@general_window.visible = true
@phase = 0
when 2
@command_window.active = false
@status_window.active = true
@status_window.index = 0
@status_window.index = @phase_index
@phase = 0
end

# If command window is active: call update_command


if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end

if @general_window.active
update_general
return
end

if @icon_command.active
update_icon_command
return
end

if @class_command.active
update_class
return
end

end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Title.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4 or
!@command_window.finished?(@command_window.index - 1)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # General
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 1 # Apariencia
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # Habilidades
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # Equipo
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # Aceptar
# Play cancel SE
$game_system.se_play($data_system.decision_se)
# Switch to map screen
#Empezar partida
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
case @command_window.index
when 0 # General
# Make status window active
@status_window.active = false
@general_window.active = true
@general_window.visible = true
@general_window.index = 0
@general_window.set(@status_window.index)
when 1 # Apariencia
$scene = Scene_Appearence.new(@status_window.index)
when 2 # Habilidades
$scene = Scene_Set_Skill.new(@status_window.index)
when 3 # Equipo
$scene = Scene_Set_Equip.new(@status_window.index)
end
return
end
if Input.trigger?(Input::SHIFT)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
actor = $game_party.actors[@status_window.index]
rand_name = rand(Options::Chara_Creator::NAMES.size)
actor.name = Options::Chara_Creator::NAMES[rand_name]
rand_class = rand(Options::Chara_Creator::CLASSES.size)
actor.class_id = Options::Chara_Creator::CLASSES[rand_class]
rand_gender = rand(Options::Chara_Creator::GENDER.size)
path = Options::Chara_Creator::GRAPHICS.names
file = Options::Chara_Creator::GRAPHICS.group
if actor.gender != rand_gender
if actor.gender == ""
actor.gender = Options::Chara_Creator::GENDER[rand_gender]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
else
actor.gender = Options::Chara_Creator::GENDER[rand_gender]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
for j in 3..5
actor.skin[j] = nil
end
end
end
@status_window.refresh
when 1
$game_system.se_play($data_system.decision_se)
path = Options::Chara_Creator::GRAPHICS.names
file = Options::Chara_Creator::GRAPHICS.group
actor = $game_party.actors[@status_window.index]
for i in 0..5
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
@status_window.refresh
when 2
$game_system.se_play($data_system.decision_se)
max = Options::Chara_Creator::MAX_SKILLS
skills = Options::Chara_Creator::SKILLS
actor = $game_party.actors[@status_window.index]
actor.skills = []
count = -1
for i in 0..max
rand_skill = rand(skills.size)
actor.skills.push(skills[rand_skill]) unless
actor.skills.include?(skills[rand_skill])
end
@status_window.refresh
when 3
$game_system.se_play($data_system.decision_se)
weapons = Options::Chara_Creator::WEAPONS
armors = Options::Chara_Creator::ARMORS
rand_weapon = rand(weapons.size)
actor = $game_party.actors[@status_window.index]
actor.set_equip(0, weapons[rand_weapon])
for i in 1..5
rand_armor = rand(armors.size)
if $data_armors[armors[rand_armor]].kind == i - 1
actor.set_equip(i, armors[rand_armor])
end
end
@status_window.refresh
end
return
end
end
#--------------------------------------------------------------------------
def update_general
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@status_window.active = true
@general_window.active = false
@general_window.visible = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @general_window.index
when 0 # Nombre
$game_system.se_play($data_system.decision_se)
$game_temp.name_actor_id = @general_window.actor.id
$game_temp.name_max_char = Options::Chara_Creator::MAX_CHAR
$scene = Scene_Name.new(Scene_Create.new(0,1,@general_window.actor))
when 1 # Profesi�n
$game_system.se_play($data_system.decision_se)
@class_command.active = true
@class_command.visible = true
@general_window.active = false
when 2 # Genero
$game_system.se_play($data_system.decision_se)
@icon_command.active = true
@icon_command.visible = true
@general_window.active = false
end
return
end
end
#--------------------------------------------------------------------------
def update_icon_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@general_window.active = true
@icon_command.active = false
@icon_command.visible = false
@general_window.refresh
@status_window.refresh
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @icon_command.index
when 0 # G�nero 1
$game_system.se_play($data_system.decision_se)
path = Options::Chara_Creator::GRAPHICS.names
file = Options::Chara_Creator::GRAPHICS.group
actor = $game_party.actors[@status_window.index]
if actor.gender != Options::Chara_Creator::GENDER[0]
if actor.gender == ""
@general_window.actor.gender = Options::Chara_Creator::GENDER[0]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
else
@general_window.actor.gender = Options::Chara_Creator::GENDER[0]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
for j in 3..5
actor.skin[j] = nil
end
end
end
@status_window.refresh
when 1 # G�nero 2
$game_system.se_play($data_system.decision_se)
path = Options::Chara_Creator::GRAPHICS.names
file = Options::Chara_Creator::GRAPHICS.group
actor = $game_party.actors[@status_window.index]
if actor.gender != Options::Chara_Creator::GENDER[1]
if actor.gender == ""
@general_window.actor.gender = Options::Chara_Creator::GENDER[1]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
else
@general_window.actor.gender = Options::Chara_Creator::GENDER[1]
for i in 0...3
rand_file = rand(file[i].size) if file[i] != nil
actor.set_skin(i, path[i]+"/"+file[i][rand_file]) if
file[i][rand_file] != nil
end
for j in 3..5
actor.skin[j] = nil
end
end
end
@status_window.refresh
end
@general_window.active = true
@icon_command.active = false
@icon_command.visible = false
@general_window.refresh
return
end
end
#--------------------------------------------------------------------------
def update_class
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@general_window.active = true
@class_command.active = false
@class_command.visible = false
@general_window.refresh
@status_window.refresh
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
$game_system.se_play($data_system.decision_se)
@general_window.actor.class_id = @class_command.class_id
@general_window.active = true
@class_command.active = false
@class_command.visible = false
@general_window.refresh
@status_window.refresh
return
end
end
end
#==============================================================================
# ** Scene_Appearence
#==============================================================================

class Scene_Appearence

def initialize(actor_id)
@actor_id = actor_id
end

#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@actor = $game_party.actors[@actor_id]
# Make command window
@commands = Options::Chara_Creator::GRAPHICS.names
@commands.insert(@commands.size, "OK") if !@commands.include?("OK")
@command_window = Window_Command.new(160, @commands)
@command_window.index = 0
@command_window.x = 40
@command_window.y = 160
# Ventana de Piezas disponibles
@object_window = Window_Object.new(@actor, @command_window.index)
@object_window.x = 600 - @object_window.width
@object_window.y = 460 - @object_window.height
# Ventana de nombre de las Piezas
@name_window = Window_Help.new
@name_window.x = @object_window.x
@name_window.y = @object_window.y - @name_window.height
@name_window.width = (@object_window.width / 3) + 32
@name_window.contents = Bitmap.new(@name_window.width - 32,
@name_window.height - 32)
# Ventana de ayuda
@help_window = Window_Help.new
h1 = " Choisissez un corps"
h2 = " Choisissez des yeux"
h3 = " Choisissez des cheveux"
h4 = " Choisissez des v�tements"
h5 = h4
h6 = " Choisissez des chaussures"
h7 = " Vous avez fini avec votre h�ro ?"
help_text = [h1,h2,h3,h4,h5,h6,h7]
@help_text = help_text
@actor_graphic = Window_Actor_Graphic.new(@actor)
@actor_graphic.y = @help_window.y + 80
@actor_graphic.x = 600 - @actor_graphic.width
@actor_name = Window_Base.new(0,0,160,64)
@actor_name.contents = Bitmap.new(128, 32)
@actor_name.contents.draw_text(0,0,128,32,"#{@actor.name}")
@actor_name.y = @command_window.y - @actor_name.height
@actor_name.x = @command_window.x
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@object_window.dispose
@name_window.dispose
@help_window.dispose
@actor_graphic.dispose
@actor_name.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@object_window.update
@name_window.update
@help_window.update
@actor_graphic.update
@help_window.set_text(@help_text[@command_window.index]) if
@help_text[@command_window.index] != nil
# If command window is active: call update_command
if @command_window.active
@name_window.set_text("")
@object_window.set(@command_window.index) if @command_window.index <
@commands.size - 1
update_command
return
end

if @object_window.active
@name_window.set_text(@object_window.objects[@object_window.index]) if
@object_window.objects[@object_window.index] != nil
update_object
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Create.new(1,2,@actor_id)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @command_window.index
when @commands.size - 1
$scene = Scene_Create.new(1,2,@actor_id)
else
@object_window.active = true
@command_window.active = false
end
return
end
end
#--------------------------------------------------------------------------
def update_object
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@object_window.active = false
@object_window.index = 0
return
end
# If C button was pressed
if Input.trigger?(Input::C)
if @object_window.objects[@object_window.index] == nil
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
path = Options::Chara_Creator::PATH[@command_window.index]
file = @object_window.objects[@object_window.index]
@actor.set_skin(@command_window.index,"#{path}/#{file}")
@actor_graphic.refresh
return
end
end
end

#==============================================================================
# *** module RPG
#==============================================================================
module RPG
#============================================================================
# *** moduel Cache
#============================================================================
module Cache
#--------------------------------------------------------------------------
# * Load equipment
#--------------------------------------------------------------------------
def self.equipment(filename, hue)
self.load_bitmap("Graphics/#{Options::Chara_Creator::FILE}/", filename, hue)
end
#--------------------------------------------------------------------------
# * Load graphic
#--------------------------------------------------------------------------
def self.graphic(filename, hue)
filename.slice!("#")
self.load_bitmap("Graphics/", filename, hue)
end
end
end

You might also like