Swordhunter
Member
I want some one to edit this script so that is shown when you start a new game
and it should have only 'male/female'. After you done with it, it changes to other screen there you pick the hair, skin etc.
Akraintkos said he has no time to do that:'(
the script:
and it should have only 'male/female'. After you done with it, it changes to other screen there you pick the hair, skin etc.
Akraintkos said he has no time to do that:'(
the script:
#==============================================================================
# Easy Character Creator
#==============================================================================
# By: Kotfire
# Version: 2.0
# Date: 18/11/06
#------------------------------------------------------------------------------
# Thanks
# - Me for Visual Equipment
#==============================================================================
# Instructions
#------------------------------------------------------------------------------
# Paste it over main
# Add and edit FILE.ini
# Edit the options (module Options / Chara_Creator)
# Create a new folder with FILE's name and inside this one two folders with
# GENDER[0,1] name and inside each one subfolders PATH[0 .. 10] name
# The images put in his respective folders with the same name that in data base
# in case of the equipment and with the same name that in the file FILE
# in case of the aspect
# Enjoy!
# More information and more detailed Info.txt
#==============================================================================
# Opciones
#------------------------------------------------------------------------------
module Options
module Chara_Creator
PATH = []
for i in 0..10
PATH = ""
end
# ----------------- EDITABLE --------------------
FILE = "Chara_Creator" # Name of the folder and the file "mother"
# -------Personalized folders here---------
PATH[0] = "Body"
PATH[1] = "Eyes"
PATH[2] = "Hair"
PATH[3] = "Underwear1"
PATH[4] = "Underwear2"
PATH[5] = "Shoes"
PATH[6] = "Armors"
PATH[7] = "Helmets"
PATH[8] = "Accessories"
PATH[9] = "Shields"
PATH[10] = "Weapons"
# ---------Available options--------------------
# Random names
NAMES = ["Kain", "Silas", "Cecil", "Setzer", "Elissa", "Realm"]
MAX_CHAR = 10 # Maximum Letters for the names
# Classes availables{ID data base}
CLASSES = [1,2,3,4,5,6,7,8]
# Gender names
GENDER = ["Male", "Female"]
# Skills
MAX_SKILLS = 10 # Maximum skills
SKILLS = [1,2,3,4,5,25,26,27,28,29,30,50,66,68,80] # availables {ID data base}
# Weapons availables {ID en la base de datos}
WEAPONS = [1]
# Armors availables {ID data base}
ARMORS = [1,2,3,4,5,6,7,8]
# --------Extracted of Visual_Equipment by Me-------
Width = 128 # Size of width of the images
Height = 218 # Size of height of the images
Frames = 4 # Frames of the images
Directions = 4 # Directions of the images
# ---------- END OF 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 "None"
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 != skin
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 = 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
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
self.contents.font.color = system_color
text_width = self.contents.text_size("Name: ").width
self.contents.draw_text(x, y, text_width, 32, "Name: ")
text_width2 = self.contents.text_size("Class: ").width
self.contents.draw_text(x, y + 25, text_width2, 32, "Class: ")
text_width3 = self.contents.text_size("Gender: ").width
self.contents.draw_text(x + 250, y, text_width3, 32, "Gender: ")
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)
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.kind == @equip_type-1
@data.push($data_armors)
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 = 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]
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
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]
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("Name: ").width
self.contents.draw_text(0, 0, name_size, 32, "Name: ")
scope_size = self.contents.text_size("Scope: ").width
self.contents.draw_text(0, 32, scope_size, 32, "Scope: ")
use_size = self.contents.text_size("Use: ").width
self.contents.draw_text(0, 64, use_size, 32, "Use: ")
power_size = self.contents.text_size("Power: ").width
self.contents.draw_text(0, 96, power_size, 32, "Power: ")
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 = "None"
when 1
scope_text = "Enemy"
when 2
scope_text = "All enemies"
when 3
scope_text = "Ally"
when 4
scope_text = "All allies"
when 5
scope_text = "Dead Ally"
when 6
scope_text = "All dead allies"
when 7
scope_text = "User"
end
self.contents.draw_text(scope_size, 32, 218, 32, scope_text)
case @skill.occasion
when 0
use_text = "Always"
when 1
use_text = "Battle"
when 2
use_text = "Menu"
when 3
use_text = "Never"
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
bitmap = RPG::Cache.character(@characters[0], @characters[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
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
#----------------------------------------
# Easy Character Creator
#==============================================================================
# By: Kotfire
# Version: 2.0
# Date: 18/11/06
#------------------------------------------------------------------------------
# Thanks
# - Me for Visual Equipment
#==============================================================================
# Instructions
#------------------------------------------------------------------------------
# Paste it over main
# Add and edit FILE.ini
# Edit the options (module Options / Chara_Creator)
# Create a new folder with FILE's name and inside this one two folders with
# GENDER[0,1] name and inside each one subfolders PATH[0 .. 10] name
# The images put in his respective folders with the same name that in data base
# in case of the equipment and with the same name that in the file FILE
# in case of the aspect
# Enjoy!
# More information and more detailed Info.txt
#==============================================================================
# Opciones
#------------------------------------------------------------------------------
module Options
module Chara_Creator
PATH = []
for i in 0..10
PATH = ""
end
# ----------------- EDITABLE --------------------
FILE = "Chara_Creator" # Name of the folder and the file "mother"
# -------Personalized folders here---------
PATH[0] = "Body"
PATH[1] = "Eyes"
PATH[2] = "Hair"
PATH[3] = "Underwear1"
PATH[4] = "Underwear2"
PATH[5] = "Shoes"
PATH[6] = "Armors"
PATH[7] = "Helmets"
PATH[8] = "Accessories"
PATH[9] = "Shields"
PATH[10] = "Weapons"
# ---------Available options--------------------
# Random names
NAMES = ["Kain", "Silas", "Cecil", "Setzer", "Elissa", "Realm"]
MAX_CHAR = 10 # Maximum Letters for the names
# Classes availables{ID data base}
CLASSES = [1,2,3,4,5,6,7,8]
# Gender names
GENDER = ["Male", "Female"]
# Skills
MAX_SKILLS = 10 # Maximum skills
SKILLS = [1,2,3,4,5,25,26,27,28,29,30,50,66,68,80] # availables {ID data base}
# Weapons availables {ID en la base de datos}
WEAPONS = [1]
# Armors availables {ID data base}
ARMORS = [1,2,3,4,5,6,7,8]
# --------Extracted of Visual_Equipment by Me-------
Width = 128 # Size of width of the images
Height = 218 # Size of height of the images
Frames = 4 # Frames of the images
Directions = 4 # Directions of the images
# ---------- END OF 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 "None"
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 != skin
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 = 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
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
self.contents.font.color = system_color
text_width = self.contents.text_size("Name: ").width
self.contents.draw_text(x, y, text_width, 32, "Name: ")
text_width2 = self.contents.text_size("Class: ").width
self.contents.draw_text(x, y + 25, text_width2, 32, "Class: ")
text_width3 = self.contents.text_size("Gender: ").width
self.contents.draw_text(x + 250, y, text_width3, 32, "Gender: ")
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)
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.kind == @equip_type-1
@data.push($data_armors)
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 = 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]
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
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]
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("Name: ").width
self.contents.draw_text(0, 0, name_size, 32, "Name: ")
scope_size = self.contents.text_size("Scope: ").width
self.contents.draw_text(0, 32, scope_size, 32, "Scope: ")
use_size = self.contents.text_size("Use: ").width
self.contents.draw_text(0, 64, use_size, 32, "Use: ")
power_size = self.contents.text_size("Power: ").width
self.contents.draw_text(0, 96, power_size, 32, "Power: ")
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 = "None"
when 1
scope_text = "Enemy"
when 2
scope_text = "All enemies"
when 3
scope_text = "Ally"
when 4
scope_text = "All allies"
when 5
scope_text = "Dead Ally"
when 6
scope_text = "All dead allies"
when 7
scope_text = "User"
end
self.contents.draw_text(scope_size, 32, 218, 32, scope_text)
case @skill.occasion
when 0
use_text = "Always"
when 1
use_text = "Battle"
when 2
use_text = "Menu"
when 3
use_text = "Never"
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
bitmap = RPG::Cache.character(@characters[0], @characters[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
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
#----------------------------------------