Professional Documents
Culture Documents
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
#----------------------------------------------------------------------------
#==============================================================================
# ** 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
#==============================================================================
#==============================================================================
# ** Window_Set_EquipItem
#==============================================================================
#==============================================================================
# ** Window_Set_Class
#==============================================================================
#==============================================================================
# ** Window_Actor_Graphic
#==============================================================================
#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
# This window displays save files on the save and load screens.
#==============================================================================
#==============================================================================
# ** Scene_Name
#==============================================================================
class Scene_Name
#==============================================================================
# ** Scene_Save
#==============================================================================
#--------------------------------------------------------------------------
# * 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
#==============================================================================
#--------------------------------------------------------------------------
# * 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 @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