- Joined
- May 4, 2014
- Messages
- 3
- Reaction score
- 0
- First Language
- Italian
- Primarily Uses
The first script is:
And the error is:
And I found it HERE
The second script is:
And the error is:
The last script is:
And the error is: "Unable to find file: Graphic/System/Back_96"
I've "downloaded" it HERE
Can someone help me? (I added the scripts in "Script editor-->Materials")
And teach me how to add scripts and how to create scripts?
Thanks to all!
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Animated Battlers
# Author: Kread-EX
# Version 1.08
# Release date: 28/11/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#------------------------------------------------------------------------------
# ▼ UPDATES
#------------------------------------------------------------------------------
# # 07/04/2013. Added option for linking animations during skill use.
# # 04/04/2013. Fixed a bug with guarding.
# # 18/02/2013. Fixed another bug with Dual Wielding.
# # 16/02/2013. Fixed a bug with Dual Wielding.
# # 15/02/2013. Compatibility with Symphony.
# # 15/02/2013. Added state animations and a few other options.
# # 15/02/2013. Compatibility with modern algebra's Flash Enemy.
# # 05/01/2013. Compatibility with Banish Skills.
#------------------------------------------------------------------------------
# ▼ INTRODUCTION
#------------------------------------------------------------------------------
# # This script will allow you to use battle animations as animation battlers.
# # It sounds simple enough but please read the instructions.
# #
# # DON'T ASK ME FOR A DEMO. PLEASE.
#------------------------------------------------------------------------------
# ▼ INSTRUCTIONS
#------------------------------------------------------------------------------
# # I direct you to this page: http://wp.me/P22oyp-ca
#------------------------------------------------------------------------------
# ▼ TERMS OF USAGE
#------------------------------------------------------------------------------
# # You are free to adapt this work to suit your needs.
# # You can use this work for commercial purposes if you like it.
# # Credit is appreciated.
# #
# # For support:
# # grimoirecastle.wordpress.com
# # rpgmakerweb.com
#------------------------------------------------------------------------------
# ▼ COMPATIBILITY
#------------------------------------------------------------------------------
# # Works with the DBS and Ace Battle Engine.
# # List of aliases and overwrites:
# #
# # DataManager
# # load_database (alias)
# # load_aniB_notetags (new method)
# #
# # BattleManager
# # process_victory (alias)
# #
# # RPG::Actor, RPG::Class, RPG::Enemy
# # load_aniB_notetags (new method)
# # animation_data (new method)
# #
# # RPG::UsableItem
# # load_aniB_notetags (new method)
# # battler_anim_id (new attr method)
# # move_to_target (new attr method)
# #
# # Game_Battler
# # skill_pose_active (new attr method)
# # item_pose_active (new attr method)
# # x_destination (new attr method)
# # y_destination (new attr method)
# # movement_type (new attr method)
# # animation_data (new method)
# # skill_battler_anim (new method)
# # item_battler_anim (new method)
# # on_action_end (alias)
# # is_moving? (new method)
# #
# # Game_Actor
# # victory_pose (new attr method)
# # perform_collapse_effect (alias)
# # screen_x (overwrite)
# # screen_y (overwrite)
# # screen_z (overwrite)
# # use_sprite? (overwrite)
# #
# # Sprite_Battler
# # screen_x (new attr method)
# # screen_y (new attr method)
# # initialize (alias)
# # update (alias)
# # update_bitmap (overwrite)
# # update_position (overwrite)
# # update_movement (new method)
# # update_battler_poses (new method)
# # animation? (overwrite)
# # battler_animation? (new method)
# # start_battler_animation (new method)
# # load_battler_animation_bitmap (new method)
# # make_battler_animation_sprites (new method)
# # set_battler_animation_origin (new method)
# # move_battler_animation (new method)
# # dispose_battler_animation (new method)
# # update_battler_animation (new method)
# # battler_animation_set_sprites (new method)
# # battler_animation_process_timing (new method)
# # get_current_pose (new method)
# # update_collapse (alias)
# # update_boss_collapse (overwrite)
# #
# # Window_BattleActor
# # update (alias)
# #
# # Scene_Battle
# # execute_action (alias)
# # move_to_target (new method)
# # move_back_to_pos (new method)
#------------------------------------------------------------------------------
($imported ||= {})['KRX-AnimatedBattlers'] = true
#puts 'Load: Animated Battlers v1.08 by Kread-EX'
module KRX
#===========================================================================
# ■ CONFIGURATION
#===========================================================================
ACTOR_POSITIONS = [[400, 300], [460, 320], [520, 340], [580, 360]]
VICTORY_DELAY = 30
MAX_SPRITES = 16
MOVEMENT_Y_OFFSET = 64
# Set this to true to make the attack anim play twice for dual wielders.
DUAL_WIELDING = false
#===========================================================================
# ■ CONFIGURATION ENDS HERE
#===========================================================================
module REGEXP
ANIM_TAG_START = //i
ANIM_TAG_END = /<\/animation_block>/i
ANIM_STANDING = /standing:[ ]*(\d+)/i
ANIM_DANGER = /danger:[ ]*(\d+)/i
ANIM_HIT = /hit:[ ]*(\d+)/i
ANIM_DEAD = /dead:[ ]*(\d+)/i
ANIM_VICTORY = /victory:[ ]*(\d+)/i
ANIM_ITEM_DEFAULT = /item_default:[ ]*(\d+)/i
ANIM_SKILL_DEFAULT = /skill_default:[ ]*(\d+)/i
ANIM_ITEM = /item:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_SKILL = /skill:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_STATE = /state:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_MOV_F = /move_f:[ ]*(\d+)/
ANIM_MOV_B = /move_b:[ ]*(\d+)/
ANIM_MIRROR = /mirror/i
ANIM_GUARD = /guard:[ ]*(\d+)/i
ANIM_ON_ITEM = //i
ANIM_TO_TARGET = //i
end
end
#===========================================================================
# ■ DataManager
#===========================================================================
module DataManager
#--------------------------------------------------------------------------
# ● Loads the database
#--------------------------------------------------------------------------
class << self; alias_method
krx_aniB_dm_ld, :load_database); end
def self.load_database
krx_aniB_dm_ld
load_aniB_notetags
end
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def self.load_aniB_notetags
groups = [$data_skills, $data_items, $data_actors, $data_classes,
$data_enemies]
for group in groups
for obj in group
next if obj.nil?
obj.load_aniB_notetags
end
end
#puts "Read: Animated Battlers Notetags"
end
end
#===========================================================================
# ■ BattleManager
#===========================================================================
module BattleManager
#--------------------------------------------------------------------------
# ● Process the battle victory
#--------------------------------------------------------------------------
class << self; alias_method
krx_aniB_bm_pv,
rocess_victory); end
def self.process_victory
$game_party.members.each {|m| m.victory_pose = true}
KRX::VICTORY_DELAY.times {SceneManager.scene.update_basic}
krx_aniB_bm_pv
$game_party.members.each {|m| m.victory_pose = false}
end
end
#===========================================================================
# ■ RPG::Actor, RPG::Class, RPG::Enemy
#===========================================================================
module KRX
module ANIMATED_BATTLERS
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def load_aniB_notetags
@animation_data = {}
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::ANIM_TAG_START
@enable_aniB_tags = true
when KRX::REGEXP::ANIM_TAG_END
@enable_aniB_tags = false
when KRX::REGEXP::ANIM_STANDING
@animation_data[:stand] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_DANGER
@animation_data[:danger] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_HIT
@animation_data[:hit] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_DEAD
@animation_data[:dead] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_VICTORY
@animation_data[:victory] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_ITEM_DEFAULT
@animation_data[:dflt_item] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_SKILL_DEFAULT
@animation_data[:dflt_skill] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MIRROR
@animation_data[:mirror] = true if @enable_aniB_tags
when KRX::REGEXP::ANIM_GUARD
@animation_data[:guard] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MOV_F
@animation_data[:move_f] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MOV_B
@animation_data[:move_b] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_ITEM
if @enable_aniB_tags
@animation_data[:item] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:item].push(i.to_i)}
end
when KRX::REGEXP::ANIM_SKILL
if @enable_aniB_tags
@animation_data[:skill] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:skill].push(i.to_i)}
end
when KRX::REGEXP::ANIM_STATE
if @enable_aniB_tags
@animation_data[:states] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:states].push(i.to_i)}
end
end
end
end
#--------------------------------------------------------------------------
# ● Returns the animation settings
#--------------------------------------------------------------------------
def animation_data(key)
@animation_data[key]
end
end
end
class RPG::Actor < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
class RPG::Class < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
class RPG::Enemy < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
#===========================================================================
# ■ RPG::UsableItem
#===========================================================================
class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_reader :battler_anim_id
attr_reader :move_to_target
attr_reader :move_direction
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def load_aniB_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::ANIM_ON_ITEM
@battler_anim_id = $1.to_i
when KRX::REGEXP::ANIM_TO_TARGET
@move_to_target = true
@move_direction = $1.to_i
@move_direction ||= 0
end
end
end
end
#===========================================================================
# ■ Game_Battler
#===========================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_accessor :skill_pose_active
attr_accessor :item_pose_active
attr_accessor :x_destination
attr_accessor :y_destination
attr_accessor :movement_type
#--------------------------------------------------------------------------
# ● Returns the battler animation data
#--------------------------------------------------------------------------
def animation_data(key)
if actor?
if actor.animation_data(key).nil?
self.class.animation_data(key)
else
actor.animation_data(key)
end
else
enemy.animation_data(key)
end
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific skill
#--------------------------------------------------------------------------
def skill_battler_anim(id)
data = animation_data
skill) || []
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
$data_skills[id].battler_anim_id ? $data_skills[id].battler_anim_id :
animation_data
dflt_skill)
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific item
#--------------------------------------------------------------------------
def item_battler_anim(id)
data = animation_data
item) || []
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
$data_items[id].battler_anim_id ? $data_items[id].battler_anim_id :
animation_data
dflt_item)
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific state
#--------------------------------------------------------------------------
def state_battler_anim(id)
data = animation_data
states) || []
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
nil
end
#--------------------------------------------------------------------------
# ● Clears the action data
#--------------------------------------------------------------------------
alias_method
krx_aniB_gb_oae,
n_action_end)
def on_action_end
krx_aniB_gb_oae
@skill_pose_active = false
@item_pose_active = false
end
#--------------------------------------------------------------------------
# ● Determine if the battler is moving on the battle screen
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def is_moving?
((@x_destination || 0) > 0) || ((@y_destination || 0) > 0)
end
end
#--------------------------------------------------------------------------
# ● Update movement (Symphony)
#--------------------------------------------------------------------------
if $imported["YES-BattleSymphony"]
def update_movement
return unless self.is_moving?
@move_x_rate = 0 if @screen_x == @destination_x || @move_x_rate.nil?
@move_y_rate = 0 if @screen_y == @destination_y || @move_y_rate.nil?
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
ofx = (@destination_x > @screen_x) ? value : -value
@screen_x += (@destination_x > @screen_x) ? value : -value
value = [(@screen_y - @destination_y).abs, @move_y_rate].min
ofy = (@destination_y > @screen_y) ? value : -value
@screen_y += (@destination_y > @screen_y) ? value : -value
sprite.move_battler_animation(ofx, ofy)
end
#--------------------------------------------------------------------------
# ● Update jump (Symphony)
#--------------------------------------------------------------------------
def update_jump
return unless self.is_moving?
#---
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
@screen_x += (@destination_x > @screen_x) ? value : -value
ofx = (@destination_x > @screen_x) ? value : -value
@parabola[:x] += value
@screen_y -= @arc_y
#---
if @destination_x == @screen_x
@screen_y = @destination_y
@arc_y = 0
@arc = 0
else
a = (2.0*(@parabola[:y0]+@parabola[:y1])-4*@parabola[:h])/(@parabola[
]**2)
b = (@parabola[:y1]-@parabola[:y0]-a*(@parabola[
]**2))/@parabola[
]
@arc_y = a * @parabola[:x] * @parabola[:x] + b * @parabola[:x] + @parabola[:y0]
end
#---
@screen_y += @arc_y
@move_x_rate = 0 if @screen_x == @destination_x
@move_y_rate = 0 if @screen_y == @destination_y
sprite.move_battler_animation(ofx, @arc_y)
end
end
end
#===========================================================================
# ■ Game_Actor
#===========================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_accessor :victory_pose
#--------------------------------------------------------------------------
# ● Perform the collapse effect if dead
#--------------------------------------------------------------------------
alias_method
krx_aniB_ga_pce,
erform_collapse_effect)
def perform_collapse_effect
return if animation_data
dead) != nil
krx_aniB_ga_pce
end
#--------------------------------------------------------------------------
# ● Return x coordinates on battle screen
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def screen_x
KRX::ACTOR_POSITIONS[index][0]
end
#--------------------------------------------------------------------------
# ● Return y coordinates on battle screen
#--------------------------------------------------------------------------
def screen_y
KRX::ACTOR_POSITIONS[index][1]
end
end
#--------------------------------------------------------------------------
# ● Return z coordinates on battle screen
#--------------------------------------------------------------------------
def screen_z
return 100
end
#--------------------------------------------------------------------------
# ● The actors will use a sprite
#--------------------------------------------------------------------------
def use_sprite?
return true
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_reader :screen_x
attr_reader :screen_y
#--------------------------------------------------------------------------
# ● Object Initialize
#--------------------------------------------------------------------------
alias_method
krx_aniB_sb_init, :initialize)
def initialize(viewport, battler = nil)
krx_aniB_sb_init(viewport, battler)
@battler_ani_duration = 0
@blank_bitmap = Bitmap.new(48, 48)
end
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
krx_abiB_sb_update, :update)
def update
dispose_battler_animation unless @battler || !battler_animation?
krx_abiB_sb_update
update_movement
@charset_shadow.visible = false if $imported["YES-BattleSymphony"]
end
#--------------------------------------------------------------------------
# ● Updates the initial bitmap
#--------------------------------------------------------------------------
def update_bitmap
self.bitmap = @blank_bitmap if self.bitmap != @blank_bitmap
update_battler_poses
update_flash_and_whiten
end
#--------------------------------------------------------------------------
# ● Updates the coordinates
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def update_position
self.x = @screen_x || @battler.screen_x
self.y = @screen_y || @battler.screen_y
self.z = @battler.screen_z
end
end
#--------------------------------------------------------------------------
# ● Updates the movement positions
#--------------------------------------------------------------------------
def update_movement
return unless @battler
return if $imported["YES-BattleSymphony"]
@battler.x_destination ||= 0
@battler.y_destination ||= 0
@screen_x ||= @battler.screen_x
@screen_y ||= @battler.screen_y
if @battler.x_destination != 0
sx, dx = @screen_x, @battler.x_destination
@screen_x = sx > dx ? [sx-16, dx].max : [sx+16, dx].min
mx = @screen_x - sx
move_battler_animation(mx, 0)
if @screen_x == dx
@battler.x_destination = 0
update_position
end
end
if @battler.y_destination != 0
sy, dy = @screen_y, @battler.y_destination
@screen_y = sy > dy ? [sy-8, dy].max : [sy+8, dy].min
my = @screen_y - sy
move_battler_animation(0, my)
if @screen_y == dy
@battler.y_destination = 0
update_position
end
end
end
#--------------------------------------------------------------------------
# ● Updates the battler poses
#--------------------------------------------------------------------------
def update_battler_poses
update_battler_animation
return if @battler.nil? || !@battler_visible
battler_anim_id = get_current_pose
return if battler_animation? || @no_loop
return if battler_anim_id.nil?
animation = $data_animations[battler_anim_id]
mirror = @battler.animation_data
mirror)
if @battler.dual_wield? && @start_dual_wielding
@dual_wielding_done = true
@start_dual_wielding = false
end
start_battler_animation(animation, mirror)
end
#--------------------------------------------------------------------------
# ● Updates the flash and whiten effects
#--------------------------------------------------------------------------
def update_flash_and_whiten
unless @battler_ani_sprites.nil?
if @flash_color && @flash_duration > 0
d = @flash_duration
r, g, b = @flash_color.red, @flash_color.green, @flash_color.blue
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
end
@battler_ani_sprites.each do |sprite|
if @flash_color && @flash_duration > 0
sprite.color.set(r, g, b, @flash_color.alpha)
end
if @effect_type == :whiten
sprite.color.set(255, 255, 255, 0)
sprite.color.alpha = 128 - (16 - @effect_duration) * 10
end
end
@flash_duration -= 1 if @flash_duration
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Flash (modern algebra Flash Selected Enemy)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_fse_flash
unless @battler_ani_sprites.nil?
@battler_ani_sprites.each do |sprite|
sprite.color.set(*FSE_FLASH_COLOUR)
if @effect_duration > (FSE_FLASH_DURATION / 2)
sprite.color.alpha =
(FSE_FLASH_DURATION - @effect_duration) * @fse_flash_mod
else
sprite.color.alpha = @effect_duration * @fse_flash_mod
end
end
end
end
#--------------------------------------------------------------------------
# ● Determine if an anim is playing
#--------------------------------------------------------------------------
def animation?
@animation != nil || @banim_wait
end
#--------------------------------------------------------------------------
# ● Determine if a battler anim is playing
#--------------------------------------------------------------------------
def battler_animation?
@battler_animation != nil
end
#--------------------------------------------------------------------------
# ● Start the battler animation
#--------------------------------------------------------------------------
def start_battler_animation(animation, mirror)
dispose_battler_animation
@battler_animation = animation
@battler_mirror = mirror
if @battler_animation
set_animation_rate
@battler_ani_duration = @battler_animation.frame_max * @ani_rate + 1
load_battler_animation_bitmap
make_battler_animation_sprites
set_battler_animation_origin
update_battler_animation
end
end
#--------------------------------------------------------------------------
# ● Construct the animation bitmaps
#--------------------------------------------------------------------------
def load_battler_animation_bitmap
animation1_name = @battler_animation.animation1_name
animation1_hue = @battler_animation.animation1_hue
animation2_name = @battler_animation.animation2_name
animation2_hue = @battler_animation.animation2_hue
@battler_ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@battler_ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@battler_ani_bitmap1)
@@_reference_count[@battler_ani_bitmap1] += 1
else
@@_reference_count[@battler_ani_bitmap1] = 1
end
if @@_reference_count.include?(@battler_ani_bitmap2)
@@_reference_count[@battler_ani_bitmap2] += 1
else
@@_reference_count[@battler_ani_bitmap2] = 1
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ● Construct the animation sprites to hold the bitmaps
#--------------------------------------------------------------------------
def make_battler_animation_sprites
@battler_ani_sprites = []
if @use_sprite && !@@ani_spr_checker.include?(@battler_animation)
KRX::MAX_SPRITES.times do
sprite = ::Sprite.new(viewport)
sprite.visible = false
@battler_ani_sprites.push(sprite)
end
end
@battler_ani_duplicated = @@ani_checker.include?(@battler_animation)
end
#--------------------------------------------------------------------------
# ● Pinpoint the animation origin values
#--------------------------------------------------------------------------
def set_battler_animation_origin
@battler_ani_ox = x - ox + width / 2
@battler_ani_oy = y - oy + height / 2
if @battler_animation.position == 0
@battler_ani_oy -= height / 2
elsif @battler_animation.position == 2 || @battler_animation.position == 3
@battler_ani_oy += height / 2
end
end
#--------------------------------------------------------------------------
# ● Move the animation
#--------------------------------------------------------------------------
def move_battler_animation(dx, dy)
if @battler_ani_sprites
@battler_ani_ox += dx
@battler_ani_oy += dy
@battler_ani_sprites.each do |sprite|
sprite.x += dx
sprite.y += dy
end
end
end
#--------------------------------------------------------------------------
# ● Free the animation
#--------------------------------------------------------------------------
def dispose_battler_animation
if @battler_ani_bitmap1
@@_reference_count[@battler_ani_bitmap1] -= 1
if @@_reference_count[@battler_ani_bitmap1] == 0
@battler_ani_bitmap1.dispose
end
end
if @battler_ani_bitmap2
@@_reference_count[@battler_ani_bitmap2] -= 1
if @@_reference_count[@battler_ani_bitmap2] == 0
@battler_ani_bitmap2.dispose
end
end
if @battler_ani_sprites
@battler_ani_sprites.each {|sprite| sprite.dispose }
@battler_ani_sprites = nil
@battler_animation = nil
end
@battler_ani_bitmap1 = nil
@battler_ani_bitmap2 = nil
@flash_color = @flash_duration = nil
end
#--------------------------------------------------------------------------
# ● Update the animation
#--------------------------------------------------------------------------
def update_battler_animation
return unless battler_animation?
@battler_ani_duration -= 1
if @battler_ani_duration % @ani_rate == 0
if @battler_ani_duration > 0
frame_index = @battler_animation.frame_max
frame_index -= (@battler_ani_duration + @ani_rate - 1) / @ani_rate
@last_frame = frame_index
battler_animation_set_sprites(@battler_animation.frames[frame_index])
@battler_animation.timings.each do |timing|
battler_animation_process_timing(timing) if timing.frame == frame_index
end
else
@battler_animation = nil
end
end
end
#--------------------------------------------------------------------------
# ● Set the animation sprites' coordinates
#--------------------------------------------------------------------------
def battler_animation_set_sprites(frame)
cell_data = frame.cell_data
@battler_ani_sprites.each_with_index do |sprite, i|
next unless sprite
pattern = cell_data[i, 0]
if !pattern || pattern < 0
sprite.visible = false
next
end
sprite.bitmap = pattern < 100 ? @battler_ani_bitmap1 :
@battler_ani_bitmap2
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @battler_mirror
sprite.x = @battler_ani_ox - cell_data[i, 1]
sprite.y = @battler_ani_oy + cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = @battler_ani_ox + cell_data[i, 1]
sprite.y = @battler_ani_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = @battler.is_moving? ? self.z + 60 : self.z + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
#--------------------------------------------------------------------------
# ● Plays sounds and flash effects
#--------------------------------------------------------------------------
def battler_animation_process_timing(timing)
timing.se.play unless @battler_ani_duplicated
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
when 2
if viewport && !@battler_ani_duplicated
viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
end
when 3
self.flash(nil, timing.flash_duration * @ani_rate)
end
end
#--------------------------------------------------------------------------
# ● Determine which pose should be used right now
#--------------------------------------------------------------------------
def get_current_pose
return unless @battler
# Standing
new_pose = @battler.animation_data
stand)
# Dead
if @battler.dead?
new_pose = @battler.animation_data
dead)
# Victory
elsif @battler.is_a?(Game_Actor) && @battler.victory_pose
new_pose = @battler.animation_data
victory)
# Moving toward target
elsif @battler.is_moving? && @battler.movement_type == 0
new_pose = @battler.animation_data
move_f)
# Moving back to initial position
elsif @battler.is_moving? && @battler.movement_type == 1
new_pose = @battler.animation_data
move_ 
# Guarding
elsif @battler.guard?
new_pose = @battler.animation_data
guard)
# Skill
elsif @battler.skill_pose_active
new_pose = @battler.skill_battler_anim(@battler.current_action.item.id)
# Item
elsif @battler.item_pose_active
new_pose = @battler.item_battler_anim(@battler.current_action.item.id)
# Being hit
elsif @battler.result.hp_damage > 0 && @battler.result.added_states.size == 0
new_pose = @battler.animation_data
hit)
elsif @battler.states.size > 0 || @battler.result.added_states.size > 0
new_pose = @battler.animation_data
stand)
@battler.sort_states.each do |state|
if @battler.state_battler_anim(state)
new_pose = @battler.state_battler_anim(state)
break
end
end
elsif @battler.hp_rate < 0.5
new_pose = @battler.animation_data
danger)
end
# Saved pose
@next_pose = nil unless @battler.skill_pose_active
new_pose = @next_pose if @next_pose
# Failsafe: use hit animation if no other one is found
new_pose = @battler.animation_data
hit) if new_pose.nil?
# Failsafe: and in last resort, use standing anim
new_pose = @battler.animation_data
stand) if new_pose.nil?
# Animation loops unless specified otherwise
if @last_pose == new_pose
@no_loop = !($data_animations[new_pose].name =~ /no[_|\s]loop/i).nil?
end
# Forces 1 loop for dual wielding animation
if KRX:
UAL_WIELDING
if @battler.dual_wield? && @battler.weapons.size == 2
if @battler.current_action && @battler.current_action.item
if @battler.current_action.item.id == @battler.attack_skill_id
@start_dual_wielding = true unless @dual_wielding_done
@no_loop = false unless @dual_wielding_done
end
end
end; end
# Manage wait flag
fmax = $data_animations[new_pose].frame_max
@banim_wait = !($data_animations[new_pose].name =~ /wait/i).nil?
@banim_wait = false if @last_frame == fmax - 1 if @banim_wait
if @last_frame == fmax - 1
switch_to = $data_animations[new_pose].name.match(/To(\d+)/i)
id = switch_to[1] if switch_to
@next_pose = id.to_i if id
end
# Update animation
if new_pose != @last_pose
@last_pose = new_pose
@battler_animation = nil
@no_loop = false
@start_dual_wielding = false
@dual_wielding_done = false
end
new_pose
end
#--------------------------------------------------------------------------
# ● Performs the collapse effect
#--------------------------------------------------------------------------
alias_method
krx_aniB_sb_uc, :update_collapse)
def update_collapse
krx_aniB_sb_uc
@battler_ani_sprites.each do |spr|
spr.blend_type = 1
spr.color.set(255, 128, 128, 128)
spr.opacity = 256 - (48 - @effect_duration) * 6
end
end
#--------------------------------------------------------------------------
# ● Performs the boss collapse effect
#--------------------------------------------------------------------------
def update_boss_collapse
@effect_duration = @battler_ani_duration
end
#--------------------------------------------------------------------------
# ● Mimics the flash effect
#--------------------------------------------------------------------------
def flash(color, duration)
@flash_color = color.dup
@flash_duration = duration
end
end
# Ignore in YEA Battle Engine
unless $imported["YEA-BattleEngine"]
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
krx_aniB_wbe_update, :update)
def update
enemy.sprite_effect_type = :whiten if active
krx_aniB_wbe_update
end
end
end
# End of YEA Battle Engine check
# Flash Selected Enemy compat.
if $imported[:"FlashSelectedEnemy 1.0.0"]
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
def update
super
end
end
end
# End of Flash Selected Enemy check
#==============================================================================
# ■ Window_BattleActor
#==============================================================================
class Window_BattleActor < Window_BattleStatus
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
krx_aniB_wba_update, :update)
def update
$game_party.battle_members[index].sprite_effect_type = :whiten if active
krx_aniB_wba_update
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Execute the action previously selected
#--------------------------------------------------------------------------
alias_method
krx_aniB_sb_ea, :execute_action)
def execute_action
move_to_target
if @subject.current_action.item.is_a?(RPG::Skill)
@subject.skill_pose_active = true
wait_for_animation
elsif @subject.current_action.item.is_a?(RPG::Item)
@subject.item_pose_active = true
end
krx_aniB_sb_ea
move_back_to_pos
end
#--------------------------------------------------------------------------
# ● Moves the battler towards the target
#--------------------------------------------------------------------------
def move_to_target
@subject.movement_type = 2
return unless @subject.current_action.item.move_to_target
target = @subject.current_action.make_targets.compact[0]
ctx = @subject.screen_x > target.screen_x ? 96 : -96
cty = KRX::MOVEMENT_Y_OFFSET * @subject.current_action.item.move_direction
@subject.x_destination = target.screen_x + ctx
@subject.y_destination = target.screen_y + cty
@subject.movement_type = 0
update_basic while @subject.is_moving?
end
#--------------------------------------------------------------------------
# ● Moves the battler back to where they started
#--------------------------------------------------------------------------
def move_back_to_pos
return unless @subject.movement_type == 0
@subject.x_destination = @subject.screen_x
@subject.y_destination = @subject.screen_y
@subject.movement_type = 1
update_basic while @subject.is_moving?
end
#--------------------------------------------------------------------------
# ● Use a Banish skill
#--------------------------------------------------------------------------
if $imported['KRX-BanishSkills']
def use_banish_skill(target, orig_item, skill_id)
@log_window.display_use_item(@subject, orig_item)
@subject.use_item(orig_item)
@log_window.display_banish(orig_item, target)
item = $data_skills[skill_id]
@log_window.display_use_item(target, item)
target.actions << Game_Action.new(self)
target.current_action.set_skill(item.id)
target.skill_pose_active = true
wait_for_animation
target.use_item(item)
target.remove_banish_state
refresh_status
show_animation([@subject], item.animation_id)
item.repeats.times do
@subject.item_apply(target, item)
refresh_status
@log_window.display_action_results(@subject, item)
end
target.skill_pose_active = false
target.actions.clear
end; end
end
if $imported["YES-BattleSymphony"]
#===========================================================================
# ■ Spriteset_Battle
#===========================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
def update_actors
@actor_sprites.each_with_index do |sprite, i|
party_member = $game_party.battle_members
if party_member != sprite.battler
sprite.battler = $game_party.battle_members
#---
if party_member
party_member.reset_position
party_member.correct_origin_position
party_member.break_pose if party_member.dead?
end
end
sprite.update
end
end
end
#===========================================================================
# ■ Game_Actor
#===========================================================================
class Game_Actor
#--------------------------------------------------------------------------
def use_charset?
return false
end
end
end
# ▼ Animated Battlers
# Author: Kread-EX
# Version 1.08
# Release date: 28/11/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#------------------------------------------------------------------------------
# ▼ UPDATES
#------------------------------------------------------------------------------
# # 07/04/2013. Added option for linking animations during skill use.
# # 04/04/2013. Fixed a bug with guarding.
# # 18/02/2013. Fixed another bug with Dual Wielding.
# # 16/02/2013. Fixed a bug with Dual Wielding.
# # 15/02/2013. Compatibility with Symphony.
# # 15/02/2013. Added state animations and a few other options.
# # 15/02/2013. Compatibility with modern algebra's Flash Enemy.
# # 05/01/2013. Compatibility with Banish Skills.
#------------------------------------------------------------------------------
# ▼ INTRODUCTION
#------------------------------------------------------------------------------
# # This script will allow you to use battle animations as animation battlers.
# # It sounds simple enough but please read the instructions.
# #
# # DON'T ASK ME FOR A DEMO. PLEASE.
#------------------------------------------------------------------------------
# ▼ INSTRUCTIONS
#------------------------------------------------------------------------------
# # I direct you to this page: http://wp.me/P22oyp-ca
#------------------------------------------------------------------------------
# ▼ TERMS OF USAGE
#------------------------------------------------------------------------------
# # You are free to adapt this work to suit your needs.
# # You can use this work for commercial purposes if you like it.
# # Credit is appreciated.
# #
# # For support:
# # grimoirecastle.wordpress.com
# # rpgmakerweb.com
#------------------------------------------------------------------------------
# ▼ COMPATIBILITY
#------------------------------------------------------------------------------
# # Works with the DBS and Ace Battle Engine.
# # List of aliases and overwrites:
# #
# # DataManager
# # load_database (alias)
# # load_aniB_notetags (new method)
# #
# # BattleManager
# # process_victory (alias)
# #
# # RPG::Actor, RPG::Class, RPG::Enemy
# # load_aniB_notetags (new method)
# # animation_data (new method)
# #
# # RPG::UsableItem
# # load_aniB_notetags (new method)
# # battler_anim_id (new attr method)
# # move_to_target (new attr method)
# #
# # Game_Battler
# # skill_pose_active (new attr method)
# # item_pose_active (new attr method)
# # x_destination (new attr method)
# # y_destination (new attr method)
# # movement_type (new attr method)
# # animation_data (new method)
# # skill_battler_anim (new method)
# # item_battler_anim (new method)
# # on_action_end (alias)
# # is_moving? (new method)
# #
# # Game_Actor
# # victory_pose (new attr method)
# # perform_collapse_effect (alias)
# # screen_x (overwrite)
# # screen_y (overwrite)
# # screen_z (overwrite)
# # use_sprite? (overwrite)
# #
# # Sprite_Battler
# # screen_x (new attr method)
# # screen_y (new attr method)
# # initialize (alias)
# # update (alias)
# # update_bitmap (overwrite)
# # update_position (overwrite)
# # update_movement (new method)
# # update_battler_poses (new method)
# # animation? (overwrite)
# # battler_animation? (new method)
# # start_battler_animation (new method)
# # load_battler_animation_bitmap (new method)
# # make_battler_animation_sprites (new method)
# # set_battler_animation_origin (new method)
# # move_battler_animation (new method)
# # dispose_battler_animation (new method)
# # update_battler_animation (new method)
# # battler_animation_set_sprites (new method)
# # battler_animation_process_timing (new method)
# # get_current_pose (new method)
# # update_collapse (alias)
# # update_boss_collapse (overwrite)
# #
# # Window_BattleActor
# # update (alias)
# #
# # Scene_Battle
# # execute_action (alias)
# # move_to_target (new method)
# # move_back_to_pos (new method)
#------------------------------------------------------------------------------
($imported ||= {})['KRX-AnimatedBattlers'] = true
#puts 'Load: Animated Battlers v1.08 by Kread-EX'
module KRX
#===========================================================================
# ■ CONFIGURATION
#===========================================================================
ACTOR_POSITIONS = [[400, 300], [460, 320], [520, 340], [580, 360]]
VICTORY_DELAY = 30
MAX_SPRITES = 16
MOVEMENT_Y_OFFSET = 64
# Set this to true to make the attack anim play twice for dual wielders.
DUAL_WIELDING = false
#===========================================================================
# ■ CONFIGURATION ENDS HERE
#===========================================================================
module REGEXP
ANIM_TAG_START = //i
ANIM_TAG_END = /<\/animation_block>/i
ANIM_STANDING = /standing:[ ]*(\d+)/i
ANIM_DANGER = /danger:[ ]*(\d+)/i
ANIM_HIT = /hit:[ ]*(\d+)/i
ANIM_DEAD = /dead:[ ]*(\d+)/i
ANIM_VICTORY = /victory:[ ]*(\d+)/i
ANIM_ITEM_DEFAULT = /item_default:[ ]*(\d+)/i
ANIM_SKILL_DEFAULT = /skill_default:[ ]*(\d+)/i
ANIM_ITEM = /item:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_SKILL = /skill:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_STATE = /state:[ ]*(\d+(?:\s*,\s*\d+*)*)/i
ANIM_MOV_F = /move_f:[ ]*(\d+)/
ANIM_MOV_B = /move_b:[ ]*(\d+)/
ANIM_MIRROR = /mirror/i
ANIM_GUARD = /guard:[ ]*(\d+)/i
ANIM_ON_ITEM = //i
ANIM_TO_TARGET = //i
end
end
#===========================================================================
# ■ DataManager
#===========================================================================
module DataManager
#--------------------------------------------------------------------------
# ● Loads the database
#--------------------------------------------------------------------------
class << self; alias_method
def self.load_database
krx_aniB_dm_ld
load_aniB_notetags
end
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def self.load_aniB_notetags
groups = [$data_skills, $data_items, $data_actors, $data_classes,
$data_enemies]
for group in groups
for obj in group
next if obj.nil?
obj.load_aniB_notetags
end
end
#puts "Read: Animated Battlers Notetags"
end
end
#===========================================================================
# ■ BattleManager
#===========================================================================
module BattleManager
#--------------------------------------------------------------------------
# ● Process the battle victory
#--------------------------------------------------------------------------
class << self; alias_method
def self.process_victory
$game_party.members.each {|m| m.victory_pose = true}
KRX::VICTORY_DELAY.times {SceneManager.scene.update_basic}
krx_aniB_bm_pv
$game_party.members.each {|m| m.victory_pose = false}
end
end
#===========================================================================
# ■ RPG::Actor, RPG::Class, RPG::Enemy
#===========================================================================
module KRX
module ANIMATED_BATTLERS
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def load_aniB_notetags
@animation_data = {}
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::ANIM_TAG_START
@enable_aniB_tags = true
when KRX::REGEXP::ANIM_TAG_END
@enable_aniB_tags = false
when KRX::REGEXP::ANIM_STANDING
@animation_data[:stand] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_DANGER
@animation_data[:danger] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_HIT
@animation_data[:hit] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_DEAD
@animation_data[:dead] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_VICTORY
@animation_data[:victory] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_ITEM_DEFAULT
@animation_data[:dflt_item] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_SKILL_DEFAULT
@animation_data[:dflt_skill] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MIRROR
@animation_data[:mirror] = true if @enable_aniB_tags
when KRX::REGEXP::ANIM_GUARD
@animation_data[:guard] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MOV_F
@animation_data[:move_f] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_MOV_B
@animation_data[:move_b] = $1.to_i if @enable_aniB_tags
when KRX::REGEXP::ANIM_ITEM
if @enable_aniB_tags
@animation_data[:item] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:item].push(i.to_i)}
end
when KRX::REGEXP::ANIM_SKILL
if @enable_aniB_tags
@animation_data[:skill] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:skill].push(i.to_i)}
end
when KRX::REGEXP::ANIM_STATE
if @enable_aniB_tags
@animation_data[:states] ||= []
$1.scan(/\d+/).each {|i| @animation_data[:states].push(i.to_i)}
end
end
end
end
#--------------------------------------------------------------------------
# ● Returns the animation settings
#--------------------------------------------------------------------------
def animation_data(key)
@animation_data[key]
end
end
end
class RPG::Actor < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
class RPG::Class < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
class RPG::Enemy < RPG::BaseItem
include KRX::ANIMATED_BATTLERS
end
#===========================================================================
# ■ RPG::UsableItem
#===========================================================================
class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_reader :battler_anim_id
attr_reader :move_to_target
attr_reader :move_direction
#--------------------------------------------------------------------------
# ● Loads the note tags
#--------------------------------------------------------------------------
def load_aniB_notetags
@note.split(/[\r\n]+/).each do |line|
case line
when KRX::REGEXP::ANIM_ON_ITEM
@battler_anim_id = $1.to_i
when KRX::REGEXP::ANIM_TO_TARGET
@move_to_target = true
@move_direction = $1.to_i
@move_direction ||= 0
end
end
end
end
#===========================================================================
# ■ Game_Battler
#===========================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_accessor :skill_pose_active
attr_accessor :item_pose_active
attr_accessor :x_destination
attr_accessor :y_destination
attr_accessor :movement_type
#--------------------------------------------------------------------------
# ● Returns the battler animation data
#--------------------------------------------------------------------------
def animation_data(key)
if actor?
if actor.animation_data(key).nil?
self.class.animation_data(key)
else
actor.animation_data(key)
end
else
enemy.animation_data(key)
end
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific skill
#--------------------------------------------------------------------------
def skill_battler_anim(id)
data = animation_data
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
$data_skills[id].battler_anim_id ? $data_skills[id].battler_anim_id :
animation_data
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific item
#--------------------------------------------------------------------------
def item_battler_anim(id)
data = animation_data
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
$data_items[id].battler_anim_id ? $data_items[id].battler_anim_id :
animation_data
end
#--------------------------------------------------------------------------
# ● Returns the battler animation ID for a specific state
#--------------------------------------------------------------------------
def state_battler_anim(id)
data = animation_data
data.each_index do |i|
next if i % 2 != 0
return data[i+1] if data == id
end
nil
end
#--------------------------------------------------------------------------
# ● Clears the action data
#--------------------------------------------------------------------------
alias_method
def on_action_end
krx_aniB_gb_oae
@skill_pose_active = false
@item_pose_active = false
end
#--------------------------------------------------------------------------
# ● Determine if the battler is moving on the battle screen
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def is_moving?
((@x_destination || 0) > 0) || ((@y_destination || 0) > 0)
end
end
#--------------------------------------------------------------------------
# ● Update movement (Symphony)
#--------------------------------------------------------------------------
if $imported["YES-BattleSymphony"]
def update_movement
return unless self.is_moving?
@move_x_rate = 0 if @screen_x == @destination_x || @move_x_rate.nil?
@move_y_rate = 0 if @screen_y == @destination_y || @move_y_rate.nil?
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
ofx = (@destination_x > @screen_x) ? value : -value
@screen_x += (@destination_x > @screen_x) ? value : -value
value = [(@screen_y - @destination_y).abs, @move_y_rate].min
ofy = (@destination_y > @screen_y) ? value : -value
@screen_y += (@destination_y > @screen_y) ? value : -value
sprite.move_battler_animation(ofx, ofy)
end
#--------------------------------------------------------------------------
# ● Update jump (Symphony)
#--------------------------------------------------------------------------
def update_jump
return unless self.is_moving?
#---
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
@screen_x += (@destination_x > @screen_x) ? value : -value
ofx = (@destination_x > @screen_x) ? value : -value
@parabola[:x] += value
@screen_y -= @arc_y
#---
if @destination_x == @screen_x
@screen_y = @destination_y
@arc_y = 0
@arc = 0
else
a = (2.0*(@parabola[:y0]+@parabola[:y1])-4*@parabola[:h])/(@parabola[
b = (@parabola[:y1]-@parabola[:y0]-a*(@parabola[
@arc_y = a * @parabola[:x] * @parabola[:x] + b * @parabola[:x] + @parabola[:y0]
end
#---
@screen_y += @arc_y
@move_x_rate = 0 if @screen_x == @destination_x
@move_y_rate = 0 if @screen_y == @destination_y
sprite.move_battler_animation(ofx, @arc_y)
end
end
end
#===========================================================================
# ■ Game_Actor
#===========================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_accessor :victory_pose
#--------------------------------------------------------------------------
# ● Perform the collapse effect if dead
#--------------------------------------------------------------------------
alias_method
def perform_collapse_effect
return if animation_data
krx_aniB_ga_pce
end
#--------------------------------------------------------------------------
# ● Return x coordinates on battle screen
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def screen_x
KRX::ACTOR_POSITIONS[index][0]
end
#--------------------------------------------------------------------------
# ● Return y coordinates on battle screen
#--------------------------------------------------------------------------
def screen_y
KRX::ACTOR_POSITIONS[index][1]
end
end
#--------------------------------------------------------------------------
# ● Return z coordinates on battle screen
#--------------------------------------------------------------------------
def screen_z
return 100
end
#--------------------------------------------------------------------------
# ● The actors will use a sprite
#--------------------------------------------------------------------------
def use_sprite?
return true
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Public instance variables
#--------------------------------------------------------------------------
attr_reader :screen_x
attr_reader :screen_y
#--------------------------------------------------------------------------
# ● Object Initialize
#--------------------------------------------------------------------------
alias_method
def initialize(viewport, battler = nil)
krx_aniB_sb_init(viewport, battler)
@battler_ani_duration = 0
@blank_bitmap = Bitmap.new(48, 48)
end
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
def update
dispose_battler_animation unless @battler || !battler_animation?
krx_abiB_sb_update
update_movement
@charset_shadow.visible = false if $imported["YES-BattleSymphony"]
end
#--------------------------------------------------------------------------
# ● Updates the initial bitmap
#--------------------------------------------------------------------------
def update_bitmap
self.bitmap = @blank_bitmap if self.bitmap != @blank_bitmap
update_battler_poses
update_flash_and_whiten
end
#--------------------------------------------------------------------------
# ● Updates the coordinates
#--------------------------------------------------------------------------
unless $imported["YES-BattleSymphony"]
def update_position
self.x = @screen_x || @battler.screen_x
self.y = @screen_y || @battler.screen_y
self.z = @battler.screen_z
end
end
#--------------------------------------------------------------------------
# ● Updates the movement positions
#--------------------------------------------------------------------------
def update_movement
return unless @battler
return if $imported["YES-BattleSymphony"]
@battler.x_destination ||= 0
@battler.y_destination ||= 0
@screen_x ||= @battler.screen_x
@screen_y ||= @battler.screen_y
if @battler.x_destination != 0
sx, dx = @screen_x, @battler.x_destination
@screen_x = sx > dx ? [sx-16, dx].max : [sx+16, dx].min
mx = @screen_x - sx
move_battler_animation(mx, 0)
if @screen_x == dx
@battler.x_destination = 0
update_position
end
end
if @battler.y_destination != 0
sy, dy = @screen_y, @battler.y_destination
@screen_y = sy > dy ? [sy-8, dy].max : [sy+8, dy].min
my = @screen_y - sy
move_battler_animation(0, my)
if @screen_y == dy
@battler.y_destination = 0
update_position
end
end
end
#--------------------------------------------------------------------------
# ● Updates the battler poses
#--------------------------------------------------------------------------
def update_battler_poses
update_battler_animation
return if @battler.nil? || !@battler_visible
battler_anim_id = get_current_pose
return if battler_animation? || @no_loop
return if battler_anim_id.nil?
animation = $data_animations[battler_anim_id]
mirror = @battler.animation_data
if @battler.dual_wield? && @start_dual_wielding
@dual_wielding_done = true
@start_dual_wielding = false
end
start_battler_animation(animation, mirror)
end
#--------------------------------------------------------------------------
# ● Updates the flash and whiten effects
#--------------------------------------------------------------------------
def update_flash_and_whiten
unless @battler_ani_sprites.nil?
if @flash_color && @flash_duration > 0
d = @flash_duration
r, g, b = @flash_color.red, @flash_color.green, @flash_color.blue
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
end
@battler_ani_sprites.each do |sprite|
if @flash_color && @flash_duration > 0
sprite.color.set(r, g, b, @flash_color.alpha)
end
if @effect_type == :whiten
sprite.color.set(255, 255, 255, 0)
sprite.color.alpha = 128 - (16 - @effect_duration) * 10
end
end
@flash_duration -= 1 if @flash_duration
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Flash (modern algebra Flash Selected Enemy)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_fse_flash
unless @battler_ani_sprites.nil?
@battler_ani_sprites.each do |sprite|
sprite.color.set(*FSE_FLASH_COLOUR)
if @effect_duration > (FSE_FLASH_DURATION / 2)
sprite.color.alpha =
(FSE_FLASH_DURATION - @effect_duration) * @fse_flash_mod
else
sprite.color.alpha = @effect_duration * @fse_flash_mod
end
end
end
end
#--------------------------------------------------------------------------
# ● Determine if an anim is playing
#--------------------------------------------------------------------------
def animation?
@animation != nil || @banim_wait
end
#--------------------------------------------------------------------------
# ● Determine if a battler anim is playing
#--------------------------------------------------------------------------
def battler_animation?
@battler_animation != nil
end
#--------------------------------------------------------------------------
# ● Start the battler animation
#--------------------------------------------------------------------------
def start_battler_animation(animation, mirror)
dispose_battler_animation
@battler_animation = animation
@battler_mirror = mirror
if @battler_animation
set_animation_rate
@battler_ani_duration = @battler_animation.frame_max * @ani_rate + 1
load_battler_animation_bitmap
make_battler_animation_sprites
set_battler_animation_origin
update_battler_animation
end
end
#--------------------------------------------------------------------------
# ● Construct the animation bitmaps
#--------------------------------------------------------------------------
def load_battler_animation_bitmap
animation1_name = @battler_animation.animation1_name
animation1_hue = @battler_animation.animation1_hue
animation2_name = @battler_animation.animation2_name
animation2_hue = @battler_animation.animation2_hue
@battler_ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
@battler_ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
if @@_reference_count.include?(@battler_ani_bitmap1)
@@_reference_count[@battler_ani_bitmap1] += 1
else
@@_reference_count[@battler_ani_bitmap1] = 1
end
if @@_reference_count.include?(@battler_ani_bitmap2)
@@_reference_count[@battler_ani_bitmap2] += 1
else
@@_reference_count[@battler_ani_bitmap2] = 1
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ● Construct the animation sprites to hold the bitmaps
#--------------------------------------------------------------------------
def make_battler_animation_sprites
@battler_ani_sprites = []
if @use_sprite && !@@ani_spr_checker.include?(@battler_animation)
KRX::MAX_SPRITES.times do
sprite = ::Sprite.new(viewport)
sprite.visible = false
@battler_ani_sprites.push(sprite)
end
end
@battler_ani_duplicated = @@ani_checker.include?(@battler_animation)
end
#--------------------------------------------------------------------------
# ● Pinpoint the animation origin values
#--------------------------------------------------------------------------
def set_battler_animation_origin
@battler_ani_ox = x - ox + width / 2
@battler_ani_oy = y - oy + height / 2
if @battler_animation.position == 0
@battler_ani_oy -= height / 2
elsif @battler_animation.position == 2 || @battler_animation.position == 3
@battler_ani_oy += height / 2
end
end
#--------------------------------------------------------------------------
# ● Move the animation
#--------------------------------------------------------------------------
def move_battler_animation(dx, dy)
if @battler_ani_sprites
@battler_ani_ox += dx
@battler_ani_oy += dy
@battler_ani_sprites.each do |sprite|
sprite.x += dx
sprite.y += dy
end
end
end
#--------------------------------------------------------------------------
# ● Free the animation
#--------------------------------------------------------------------------
def dispose_battler_animation
if @battler_ani_bitmap1
@@_reference_count[@battler_ani_bitmap1] -= 1
if @@_reference_count[@battler_ani_bitmap1] == 0
@battler_ani_bitmap1.dispose
end
end
if @battler_ani_bitmap2
@@_reference_count[@battler_ani_bitmap2] -= 1
if @@_reference_count[@battler_ani_bitmap2] == 0
@battler_ani_bitmap2.dispose
end
end
if @battler_ani_sprites
@battler_ani_sprites.each {|sprite| sprite.dispose }
@battler_ani_sprites = nil
@battler_animation = nil
end
@battler_ani_bitmap1 = nil
@battler_ani_bitmap2 = nil
@flash_color = @flash_duration = nil
end
#--------------------------------------------------------------------------
# ● Update the animation
#--------------------------------------------------------------------------
def update_battler_animation
return unless battler_animation?
@battler_ani_duration -= 1
if @battler_ani_duration % @ani_rate == 0
if @battler_ani_duration > 0
frame_index = @battler_animation.frame_max
frame_index -= (@battler_ani_duration + @ani_rate - 1) / @ani_rate
@last_frame = frame_index
battler_animation_set_sprites(@battler_animation.frames[frame_index])
@battler_animation.timings.each do |timing|
battler_animation_process_timing(timing) if timing.frame == frame_index
end
else
@battler_animation = nil
end
end
end
#--------------------------------------------------------------------------
# ● Set the animation sprites' coordinates
#--------------------------------------------------------------------------
def battler_animation_set_sprites(frame)
cell_data = frame.cell_data
@battler_ani_sprites.each_with_index do |sprite, i|
next unless sprite
pattern = cell_data[i, 0]
if !pattern || pattern < 0
sprite.visible = false
next
end
sprite.bitmap = pattern < 100 ? @battler_ani_bitmap1 :
@battler_ani_bitmap2
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @battler_mirror
sprite.x = @battler_ani_ox - cell_data[i, 1]
sprite.y = @battler_ani_oy + cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = @battler_ani_ox + cell_data[i, 1]
sprite.y = @battler_ani_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = @battler.is_moving? ? self.z + 60 : self.z + i
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
#--------------------------------------------------------------------------
# ● Plays sounds and flash effects
#--------------------------------------------------------------------------
def battler_animation_process_timing(timing)
timing.se.play unless @battler_ani_duplicated
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
when 2
if viewport && !@battler_ani_duplicated
viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
end
when 3
self.flash(nil, timing.flash_duration * @ani_rate)
end
end
#--------------------------------------------------------------------------
# ● Determine which pose should be used right now
#--------------------------------------------------------------------------
def get_current_pose
return unless @battler
# Standing
new_pose = @battler.animation_data
# Dead
if @battler.dead?
new_pose = @battler.animation_data
# Victory
elsif @battler.is_a?(Game_Actor) && @battler.victory_pose
new_pose = @battler.animation_data
# Moving toward target
elsif @battler.is_moving? && @battler.movement_type == 0
new_pose = @battler.animation_data
# Moving back to initial position
elsif @battler.is_moving? && @battler.movement_type == 1
new_pose = @battler.animation_data
# Guarding
elsif @battler.guard?
new_pose = @battler.animation_data
# Skill
elsif @battler.skill_pose_active
new_pose = @battler.skill_battler_anim(@battler.current_action.item.id)
# Item
elsif @battler.item_pose_active
new_pose = @battler.item_battler_anim(@battler.current_action.item.id)
# Being hit
elsif @battler.result.hp_damage > 0 && @battler.result.added_states.size == 0
new_pose = @battler.animation_data
elsif @battler.states.size > 0 || @battler.result.added_states.size > 0
new_pose = @battler.animation_data
@battler.sort_states.each do |state|
if @battler.state_battler_anim(state)
new_pose = @battler.state_battler_anim(state)
break
end
end
elsif @battler.hp_rate < 0.5
new_pose = @battler.animation_data
end
# Saved pose
@next_pose = nil unless @battler.skill_pose_active
new_pose = @next_pose if @next_pose
# Failsafe: use hit animation if no other one is found
new_pose = @battler.animation_data
# Failsafe: and in last resort, use standing anim
new_pose = @battler.animation_data
# Animation loops unless specified otherwise
if @last_pose == new_pose
@no_loop = !($data_animations[new_pose].name =~ /no[_|\s]loop/i).nil?
end
# Forces 1 loop for dual wielding animation
if KRX:
if @battler.dual_wield? && @battler.weapons.size == 2
if @battler.current_action && @battler.current_action.item
if @battler.current_action.item.id == @battler.attack_skill_id
@start_dual_wielding = true unless @dual_wielding_done
@no_loop = false unless @dual_wielding_done
end
end
end; end
# Manage wait flag
fmax = $data_animations[new_pose].frame_max
@banim_wait = !($data_animations[new_pose].name =~ /wait/i).nil?
@banim_wait = false if @last_frame == fmax - 1 if @banim_wait
if @last_frame == fmax - 1
switch_to = $data_animations[new_pose].name.match(/To(\d+)/i)
id = switch_to[1] if switch_to
@next_pose = id.to_i if id
end
# Update animation
if new_pose != @last_pose
@last_pose = new_pose
@battler_animation = nil
@no_loop = false
@start_dual_wielding = false
@dual_wielding_done = false
end
new_pose
end
#--------------------------------------------------------------------------
# ● Performs the collapse effect
#--------------------------------------------------------------------------
alias_method
def update_collapse
krx_aniB_sb_uc
@battler_ani_sprites.each do |spr|
spr.blend_type = 1
spr.color.set(255, 128, 128, 128)
spr.opacity = 256 - (48 - @effect_duration) * 6
end
end
#--------------------------------------------------------------------------
# ● Performs the boss collapse effect
#--------------------------------------------------------------------------
def update_boss_collapse
@effect_duration = @battler_ani_duration
end
#--------------------------------------------------------------------------
# ● Mimics the flash effect
#--------------------------------------------------------------------------
def flash(color, duration)
@flash_color = color.dup
@flash_duration = duration
end
end
# Ignore in YEA Battle Engine
unless $imported["YEA-BattleEngine"]
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
def update
enemy.sprite_effect_type = :whiten if active
krx_aniB_wbe_update
end
end
end
# End of YEA Battle Engine check
# Flash Selected Enemy compat.
if $imported[:"FlashSelectedEnemy 1.0.0"]
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
def update
super
end
end
end
# End of Flash Selected Enemy check
#==============================================================================
# ■ Window_BattleActor
#==============================================================================
class Window_BattleActor < Window_BattleStatus
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
alias_method
def update
$game_party.battle_members[index].sprite_effect_type = :whiten if active
krx_aniB_wba_update
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Execute the action previously selected
#--------------------------------------------------------------------------
alias_method
def execute_action
move_to_target
if @subject.current_action.item.is_a?(RPG::Skill)
@subject.skill_pose_active = true
wait_for_animation
elsif @subject.current_action.item.is_a?(RPG::Item)
@subject.item_pose_active = true
end
krx_aniB_sb_ea
move_back_to_pos
end
#--------------------------------------------------------------------------
# ● Moves the battler towards the target
#--------------------------------------------------------------------------
def move_to_target
@subject.movement_type = 2
return unless @subject.current_action.item.move_to_target
target = @subject.current_action.make_targets.compact[0]
ctx = @subject.screen_x > target.screen_x ? 96 : -96
cty = KRX::MOVEMENT_Y_OFFSET * @subject.current_action.item.move_direction
@subject.x_destination = target.screen_x + ctx
@subject.y_destination = target.screen_y + cty
@subject.movement_type = 0
update_basic while @subject.is_moving?
end
#--------------------------------------------------------------------------
# ● Moves the battler back to where they started
#--------------------------------------------------------------------------
def move_back_to_pos
return unless @subject.movement_type == 0
@subject.x_destination = @subject.screen_x
@subject.y_destination = @subject.screen_y
@subject.movement_type = 1
update_basic while @subject.is_moving?
end
#--------------------------------------------------------------------------
# ● Use a Banish skill
#--------------------------------------------------------------------------
if $imported['KRX-BanishSkills']
def use_banish_skill(target, orig_item, skill_id)
@log_window.display_use_item(@subject, orig_item)
@subject.use_item(orig_item)
@log_window.display_banish(orig_item, target)
item = $data_skills[skill_id]
@log_window.display_use_item(target, item)
target.actions << Game_Action.new(self)
target.current_action.set_skill(item.id)
target.skill_pose_active = true
wait_for_animation
target.use_item(item)
target.remove_banish_state
refresh_status
show_animation([@subject], item.animation_id)
item.repeats.times do
@subject.item_apply(target, item)
refresh_status
@log_window.display_action_results(@subject, item)
end
target.skill_pose_active = false
target.actions.clear
end; end
end
if $imported["YES-BattleSymphony"]
#===========================================================================
# ■ Spriteset_Battle
#===========================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
def update_actors
@actor_sprites.each_with_index do |sprite, i|
party_member = $game_party.battle_members
if party_member != sprite.battler
sprite.battler = $game_party.battle_members
#---
if party_member
party_member.reset_position
party_member.correct_origin_position
party_member.break_pose if party_member.dead?
end
end
sprite.update
end
end
end
#===========================================================================
# ■ Game_Actor
#===========================================================================
class Game_Actor
#--------------------------------------------------------------------------
def use_charset?
return false
end
end
end
And the error is:
"Script 'Animated Battlers' line 851: TypeError occurred. no implicit conversion from nil to integer".
And I found it HERE
The second script is:
##----------------------------------------------------------------------------##
## Composite Character v2.1
## Created by Neon Black
##
## Only for non-commercial use. See full terms of use and contact info at:
## http://cphouseset.wordpress.com/liscense-and-terms-of-use/
##----------------------------------------------------------------------------##
##
##----------------------------------------------------------------------------##
## Revision Info:
## V2.1 - 2.12.2013
## Added new script calls
## V2.0 - 1.24.2013
## Rewrote entire script from scratch
## V1.0 - 10.17.2012
## Wrote and debugged main script
##----------------------------------------------------------------------------##
##
$imported = {} if $imported.nil? ##
$imported["COMPOSITE"] = 2.1 ##
##
##----------------------------------------------------------------------------##
## Instructions:
## Place this script in the "Materials" section of the scripts above "Main".
## To use this script you must have additional composite graphics in a folder
## for characters and a folder for faces. Charactersets will use composites
## based on their names in the NAMES setting. Some layers of the composite
## may also change based on the equipped items on the actor associated with
## file name. There are several tags that work with both actors and equips.
##
## Tags:
## tag init[Handler, hue]
## - Can only be tagged in actors. Changes composite layer :tag to handler
## "Handler" with the defined hue. Do not use colons for layer names or
## quotes for file handler names.
## gender[male]
## - Sets the character's initial gender to "male" or "female" depending on
## which you place in the brackets. This can only tag actors.
## alt name[Christopher]
## - Sets the character's name for the opposite gender. If the player changes
## the gender in the GUI and has not changed the name, the new name will be
## displayed. The name "Christopher" here can be any name you desire.
## tag image[Handler, hue]
## - Changes the default images for layer :tag to file handler "Handler".
##
## Script Calls:
## The character creation screen can be called with either of these two script
## calls from an event. Other script calls also exist.
##
## creation(id) -or- creation(id, array)
## - The value "id" can be either the actor's ID or the name of the character
## set to modify. The "array" value does not need to be used ever. This is
## the array of handlers from "GUI_LISTS" to use. If no array is defined,
## "BASE_GUI" is used instead.
## composite_custom(id, handler, name, hue)
## - Changes composite "id"'s layer "handler" into file "name" with a hue of
## "hue". This occurs on the same priority level as the character creation
## screen, so it is covered by armour and can be modified by the player.
## "id" must be a value from NAMES, "handler" a layer from COMPOSITE, "name"
## a file from FILE_HANDLERS, and "hue" a number from 0 to 255.
## composite_force(id, handler, name, hue)
## - Similar to the command above, but this takes the highest priority when
## being drawn and cannot be changed by the player.
## composite_reset(id)
## - Removes all layers added using the "composite_force" script call.
##
## Special Layers:
## In order to allow a slight bit more customization, there are 3 types of
## special layers that link directly to other layers. These layers end with
## "Back", "Hueless", and "All".
##
## Back Layers
## - These layers do not actually need to be behind the normal layer. They
## are simply a second layer with all the same properties of the parent
## layer. An example would be :hairRear which would be a rear layer of
## :hair.
## Hueless Layers
## - These layers ignore the changed hue values. The main use of these would
## be objects with skin tone or perhaps objects that you only want to change
## part of the colour on. The only object that uses this in the example
## is :eyesHueless which is a hueless layer of :eyes.
## All Layers
## - These are special layers on the character. They are a layer that appears
## on the character no matter what the player does. The file that appears
## is still linked to the file part it is attatched to for the sake of hue.
## The file that appears for one of these layers is defined in the hash
## GUI_OPTIONS.
##----------------------------------------------------------------------------##
##
module CP # Do not touch ##
module COMPOSITE # these lines. ##
##
##----------------------------------------------------------------------------##
## Config:
## The config options are below. You can set these depending on the flavour of
## your game. Each option is explained in a bit more detail above it.
##
##------
# The folders containing the composite parts for characters and for facesets.
CHAR_FOLDER = "Graphics/Composite/Charas/"
FACE_FOLDER = "Graphics/Composite/Faces/"
# Determines if the creation screen uses face sets are not. Set to false if
# you do not want a faceset displayed.
USE_FACESETS = true
# The width and height of the character window in the creation screen. The
# character in the screen is zoomed in to 200%.
WINDOW_WIDTH = 90
WINDOW_HEIGHT = 112
# The text options for the character selection GUI. EMPTY_TEXT refers to an
# option which is blank for some reason.
GUI_CLOSE = "Finish Editing"
EMPTY_TEXT = "None"
# The number of allowed character spaces for names when input from the editor.
CHARACTERS = 6
# Names for the male and female genders.
GENDER_NAMES = ["Male", "Female"]
# Determines if male undefined characters start out as male characters.
MALE_DEFAULT = true
##------
# Determine the files that are recognized as composite images and the actor
# they are linked to, for the sake of armour, storage, etc.
NAMES ={
"$Hero1" => 11,
"$Hero2" => 12,
}
# The switches related to characters. A switch is turned ON when the character
# is male and OFF when the character is female.
SWITCHES ={
11 => 72,
12 => 73,
}
# The order for composite layers. The first layer is the lowest layer.
COMPOSITE =[
:hairRear,
:cape,
:armorRear,
:headAll,
:head,
:eyes,
:eyesAll,
:eyesHueless,
:armor,
:hair,
:glasses,
:helmet,
]
# These are the handlers for all files in the composite folders. Actor and
# equip tags as well as GUI options point to a handler and the handler
# determines the male and female files to look up. Make sure every handler
# has a different name.
FILE_HANDLERS ={
# "Handler" => ["Male_File", "Female_File"],
"Shaggy" => ["Hair1M", nil],
"Slick" => ["Hair2M", nil],
"Spiked" => ["Hair3M", nil],
"Fancy" => ["Hair4M", nil],
"Stylish" => [nil, "Hair1F"],
"Waist Length" => [nil, "Hair2F"],
"Curled" => [nil, "Hair3F"],
"Pigtails" => [nil, "Hair4F"],
"Short" => ["Hair1U", "Hair1U"],
"Long" => ["Hair2U", "Hair2U"],
"Observant" => ["Eye1M", "Eye1F"],
"Closed" => ["Eye2M", "Eye2F"],
"Intent" => ["Eye3M", "Eye3F"],
"HeadBase" => ["HeadAll", "HeadAll"],
"FaceBase" => ["FaceM", "FaceF"],
"BodyBase" => ["BaseM", "BaseF"],
"Clothes" => ["ClothesM", "ClothesF"],
"Cloth" => ["ClothM", "ClothF"],
"Armor" => ["ArmourM", "ArmourF"],
"Glasses" => ["Glasses", "Glasses"],
"Sunglasses" => ["Sunglasses", "Sunglasses"],
"Goggles" => ["Goggles", "Goggles"],
}
# Standard handlers. These are default handlers of certain layers.
STANDARD ={
:headAll => "HeadBase",
:head => "FaceBase",
:armor => "BodyBase",
}
# The GUI options that may be called from an array. If the "Name" field is set
# to a :symbol like the :barber example, it will point back to another option
# and use that option's name and layer. The point is simply to link different
# handlers to it as well as giving it different colour options. The colorize?
# option can be set to a value of 0, 1, or 2 depending on the style of hue bar
# you would like displayed. If it is set to 0, no bar will be displayed.
GUI_OPTIONS ={
# :handler => ["Name", colorize?, "AllFile"],
:Name => ["Name", 0, nil],
:Gender => ["Gender", 0, nil],
:hair => ["Hair", 1, nil],
:eyes => ["Eyes", 1, "EyeAll"],
:barber => [:hair, true, nil],
}
# These are the basic options to use in the GUI if no array is defined.
BASE_GUI = [:Name, :Gender, :hair, :eyes]
# These are the lists that refer to the options. Male and Female only options
# are automatically filtered depending on the character's gender.
GUI_LISTS ={
:hair => ["Shaggy", "Slick", "Spiked", "Fancy", "Stylish", "Waist Length",
"Curled", "Pigtails"],
:eyes => ["Observant", "Intent", "Closed"],
:barber => ["Shaggy", "Slick", "Spiked", "Fancy", "Stylish", "Waist Length",
"Curled", "Pigtails", "Short", "Long"],
}
##----------------------------------------------------------------------------##
##
##
##----------------------------------------------------------------------------##
## The following lines are the actual core code of the script. While you are
## certainly invited to look, modifying it may result in undesirable results.
## Modify at your own risk!
###----------------------------------------------------------------------------
end
nd
odule Cache
class << self ## Alias for the used methods in this module.
alias cp_cm_character character
alias cp_cm_face face
alias cp_cm_clear clear
end
def self.character(*args) ## Checks if the file is a composite.
return cp_cm_character(*args) unless Composites.include?(args[0])
create_composite(args[0], "Graphics/Characters/")
hue = args[1] ? args[1] : 0
load_bitmap("Graphics/Characters/", args[0], hue)
end
def self.face(*args) ## Checks if the face is a composite.
return cp_cm_face(*args) unless Composites.include?(args[0])
create_composite(args[0], "Graphics/Faces/")
hue = args[1] ? args[1] : 0
load_bitmap("Graphics/Faces/", args[0], hue)
end
def self.need_comp_ref?(file, path) ## Checks refresh status.
return true if Composites.refresh?(file)
return true if @cache[path].nil? || @cache[path].disposed?
return false
end
def self.create_composite(file, folder) ## Find and create the composite.
path = "#{folder}#{file}"
return unless need_comp_ref?(file, path)
foldrs = ["Graphics/Characters/", "Graphics/Faces/"]
Composites.constants.each_with_index do |fld, i|
paths = "#{foldrs}#{file}"
array = Composites.images(file)
Composites.layers do |i|
image = array
unless @temp
@temp = Bitmap.new("#{fld}#{image}") rescue next
@temp.hue_change(Composites.hues(file)) unless Composites.hues(file).nil?
else
t = Bitmap.new("#{fld}#{image}") rescue next
t.hue_change(Composites.hues(file)) unless Composites.hues(file).nil?
@temp.blt(0, 0, t, t.rect)
t.dispose; t = nil
end
end
@temp = Bitmap.new unless @temp
Composites.refreshed(file)
@cache[paths] = Bitmap.new(@temp.width, @temp.height)
@cache[paths].blt(0, 0, @temp, @temp.rect)
@temp.dispose; @temp = nil
end
Composites.remove_temp_layers(file)
end
def self.clear ## Reset the composite cache.
cp_cm_clear
Composites.clear
end
nd
odule Composites
def self.include?(file) ## Checks if a file is a composite.
return CP::COMPOSITE::NAMES.include?(file)
end
def self.options ## Easy access of the options hash.
return CP::COMPOSITE::GUI_OPTIONS
end
def self.lists ## Easy access of the gui lists hash.
return CP::COMPOSITE::GUI_LISTS
end
def self.list_by_block(handler, block) ## Returns a list based on gender.
return [] unless [0, 1].include?(block) && lists.include?(handler)
return lists[handler].select {|a| !files[a][block].nil?}
end
def self.layers ## Gets each layer key one at a time.
CP::COMPOSITE::COMPOSITE.each do |key|
yield key
end
end
def self.constants ## Gets the folder constants.
if CP::COMPOSITE::USE_FACESETS
return [CP::COMPOSITE::CHAR_FOLDER, CP::COMPOSITE::FACE_FOLDER]
else
return [CP::COMPOSITE::CHAR_FOLDER]
end
end
def self.files ## Gets the file handler hash.
return CP::COMPOSITE::FILE_HANDLERS
end
def self.include_block?(block, handler) ## Checks gender blocks to handlers.
return false unless files.include?(handler)
return !files[handler][block].nil?
end
def self.standard ## Gets the standard GUI display.
return CP::COMPOSITE::STANDARD
end
def self.get_first_handler(block, key) ## Gets the init files based on block.
return nil if ![0, 1].include?(block) || !lists.include?(key)
lists[key].each do |handler|
next unless files.include?(handler)
return handler unless files[handler][block].nil?
end
return nil
end
def self.n(file) ## Returns a number from a file.
return CP::COMPOSITE::NAMES[file]
end
def self.refreshed(file) ## Resets a file's refresh status.
return unless n(file)
actor(file).composite_refresh = false
end
def self.images(file) ## Get all images of a file.
return @temp_images[file] if @temp_images && @temp_images[file]
return actor(file).composite_images
end
def self.hues(file) ## Get all hues of a file.
return @temp_hues[file] if @temp_hues && @temp_hues[file]
return actor(file).composite_hues
end
def self.remove_temp_layers(file) ## Removes temporary (save) layers.
@temp_images.delete(file) if @temp_images
@temp_hues.delete(file) if @temp_hues
end
def self.make_temp_file(file, handlers) ## Create a new temp of a file.
@temp_images = {} if @temp_images.nil?; @temp_hues = {} if @temp_hues.nil?
@temp_images[file] = {}; @temp_hues[file] = {}
handlers.each do |key, array|
@temp_images[file][key] = array[0]
@temp_hues[file][key] = array[1]
end
end
def self.refresh?(file) ## Check if a file needs refreshing.
return false unless n(file) ## Includes temp file checking.
return true if @temp_images && @temp_images.include?(file)
return actor(file).composite_refresh
end
def self.actor(file) ## Gets a game actor from a file name.
return $game_actors[n(file)]
end
def self.clear ## Allows forced reset of each file.
CP::COMPOSITE::NAMES.keys.each do |file|
actor(file).composite_refresh = true
end
end
nd
lass Game_Actor < Game_Battler
attr_accessor :composite_refresh
alias cp_cmpst_init initialize
def initialize(*args) ## Sets the initial values for composites.
cp_cmpst_init(*args)
@composite_refresh = true
@editor_changes = {}
@editor_hues = {}
@forced_composites = {}
end
def composite_images ## Returns the composite images for an actor.
make_composite_lists if @composite_refresh
return @composite_images
end
def composite_hues ## Returns the composite hues.
make_composite_lists if @composite_refresh
return @composite_hues
end
def edd_additions(hueless, rear) ## Make a new filename based on layers.
a = ""
b = hueless ? "#{a}Hueless" : a
c = rear ? "#{b}Rear" : b
return c
end
def get_composite_lists ## Gets a composite list for save files.
return {} unless Composites.include?(character_name)
make_composite_lists
r = {}
@composite_images.each {|k, v| r[k] = [v, @composite_hues[k]]}
return r
end
def make_composite_lists ## Makes the list of composites and hues.
@composite_images = {}
@composite_hues = {}
@composite_male = get_base_gender ## Sets gender.
if CP::COMPOSITE::SWITCHES.include?(@actor_id) ## Sets a gender switch.
$game_switches[CP::COMPOSITE::SWITCHES[@actor_id]] = @composite_male
end
block = @composite_male ? 0 : 1
make_equip_hashes(block) ## Ensures equips are set up.
Composites.layers do |key| ## Check each layer.
@composite_hues[key] = 0 ## Gets init values for variables.
name = nil
string = key.to_s
hueless = string.include?("Hueless")
rear = string.include?("Rear")
all = string.include?("All")
string.gsub!(/(Hueless|All|Rear)/, '')
edd = edd_additions(hueless, rear)
line = CP::COMPOSITE::GUI_OPTIONS[string.to_sym]
handler = get_composite_handler(key)
parent = get_composite_handler(string.to_sym)
hues = get_composite_hue(key)
if all && !line.nil? ## Determines the needed value.
name = line[2]
elsif handler && Composites.files.include?(handler) &&
Composites.files[handler][block]
name = "#{Composites.files[handler][block]}#{edd}"
elsif parent && Composites.files.include?(parent) &&
Composites.files[parent][block] && (rear || hueless)
name = "#{Composites.files[parent][block]}#{edd}"
elsif Composites.standard.include?(key)
name = Composites.files[Composites.standard[key]][block]
end
next unless name ## Skips if there is no name.
@composite_images[key] = name ## Creates the hashes.
@composite_hues[key] = hueless ? 0 : hues
end
end
def get_base_gender ## Gets the gender.
return @editor_changes[:Gender] if @editor_changes.include?
Gender)
return actor.gender_base
end
def get_composite_handler(key) ## Complex method to find the file handler.
block = @composite_male ? 0 : 1
if @forced_composites.include?(key) && Composites.include_block?(block,
@forced_composites[key][0])
hues = @forced_composites[key][0]
elsif @equip_hashes.include?(key) && Composites.include_block?(block,
@equip_hashes[key][0])
handler = @equip_hashes[key][0]
elsif @editor_changes.include?(key) && Composites.include_block?(block,
@editor_changes[key])
handler = @editor_changes[key]
elsif actor.composite_init.include?(key) && Composites.include_block?(block,
actor.composite_init[key][0])
handler = actor.composite_init[key][0]
elsif Composites.get_first_handler(block, key)
handler = Composites.get_first_handler(block, key)
else
handler = nil
end
return handler
end
def get_composite_hue(key) ## Same as above but for hues.
block = @composite_male ? 0 : 1
if @forced_composites.include?(key) && Composites.include_block?(block,
@forced_composites[key][0])
hues = @forced_composites[key][1]
elsif @equip_hashes.include?(key) && Composites.include_block?(block,
@equip_hashes[key][0])
hues = @equip_hashes[key][1]
elsif @editor_changes.include?(key) && Composites.include_block?(block,
@editor_changes[key])
hues = @editor_hues[key]
elsif actor.composite_init.include?(key) && Composites.include_block?(block,
actor.composite_init[key][0])
hues = actor.composite_init[key][1]
else
hues = 0
end
return hues
end
def make_equip_hashes(block) ## Makes the handler hash for equips.
@equip_hashes = {}
equips.each do |eq|
next unless eq
eq.composite_hash.each do |key, array|
next if Composites.files[array[0]][male? ? 0 : 1].nil?
@equip_hashes[key] = array
end
end
end
alias cp_composite_change_eq change_equip
def change_equip(*args) ## Ensures refreshing on equip change.
cp_composite_change_eq(*args)
@composite_refresh = true
end
def change_composite(hand, value = nil, hue = nil)
array = ["#{hand}".to_sym, "#{hand}Rear".to_sym, "#{hand}Hueless".to_sym,
"#{hand}All".to_sym]
array.each do |handler| ## Changes values for a layer and sublayers.
unless value.nil?
@editor_changes[handler] = value
@editor_hues[handler] = hue if hue
else
@editor_changes.delete(handler)
@editor_hues.delete(handler)
end
end
@composite_refresh = true
end
def force_composite(hand, value = nil, hue = nil)
array = ["#{hand}".to_sym, "#{hand}Rear".to_sym, "#{hand}Hueless".to_sym,
"#{hand}All".to_sym]
array.each do |handler| ## Changes values for a layer and sublayers.
unless value.nil?
@forced_composites[handler] = []
@forced_composites[handler][0] = value
@forced_composites[handler][1] = hue if hue
else
@forced_composites.delete(handler)
end
end
@composite_refresh = true
end
def reset_composite
@forced_composites = {}
@composite_refresh = true
end
def reset_name ## Changes the name to a default name.
return if actor.alt_name.empty?
@composite_male = get_base_gender
if @composite_male == actor.gender_base
@name = actor.name if @name == actor.alt_name
else
@name = actor.alt_name if @name == actor.name
end
end
def male? ## Check if the actor is male.
return @composite_male
end
nd
lass Window_SaveFile < Window_Base
def draw_party_characters(x, y) ## Creates a temp array for the save file.
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
Composites.make_temp_file(data[0], data[2])
draw_character(data[0], data[1], x + i * 48, y)
end
end
nd
lass Game_Party < Game_Unit
def characters_for_savefile ## Adds the composite arrays to a save file.
battle_members.collect do |actor|
[actor.character_name, actor.character_index, actor.get_composite_lists]
end
end
nd
lass Scene_Load < Scene_File ## Clears the composites on a load.
alias cp_comp_load_succ on_load_success
def on_load_success
Composites.clear
cp_comp_load_succ
end
nd
lass Scene_Save < Scene_File ## Clears the composites on save.
alias cp_comp_save_ok on_savefile_ok
def on_savefile_ok
Composites.clear
cp_comp_save_ok
end
nd
lass Bitmap
def draw_rainbow(*args) ## Draws a rainbow rectangle.
case args.size
when 1
rect = args[0].clone
when 4
rect = Rect.new(args[0], args[1], args[2], args[3])
end
ca = rainbow_colours
6.times do |i|
wv = rect.width / (6 - i)
n = i == 5 ? 0 : 1
r2 = Rect.new(rect.x, rect.y, wv + n, rect.height)
self.gradient_fill_rect(r2, ca, ca[(i + 1) % 6])
rect.width -= wv
rect.x += wv
end
end
def rainbow_colours ## Colours for the rectangle.
c1 = Color.new(255, 0, 0); c2 = Color.new(255, 255, 0)
c3 = Color.new( 0, 255, 0); c4 = Color.new( 0, 255, 255)
c5 = Color.new( 0, 0, 255); c6 = Color.new(255, 0, 255)
return [c1, c2, c3, c4, c5, c6]
end
@@wheel = Bitmap.new(360, 1)
@@wheel.draw_rainbow(0, 0, 360, 1)
def self.hue_colour_wheel(hue) ## Show the new hue colour.
if @@wheel.disposed?
@@wheel = Bitmap.new(360, 1)
@@wheel.draw_rainbow(0, 0, 360, 1)
end
return @@wheel.get_pixel(hue % 360, 0)
end
nd
# The core bits of the script scene are below.
lass Window_CCFace < Window_Base
def initialize(actor, input)
super(0, 0, 120, 120)
self.visible = CP::COMPOSITE::USE_FACESETS
@input_window = input
self.y = @input_window.y
self.x = @input_window.x - (self.width + 8)
@actor = $data_actors[actor]
refresh
end
def refresh
contents.clear
draw_face(@actor.face_name, @actor.face_index, 0, 0)
end
nd
lass Window_CCCharacter < Window_Base
def initialize(actor, input)
super(0, 0, CP::COMPOSITE::WINDOW_WIDTH, CP::COMPOSITE::WINDOW_HEIGHT)
@input_window = input
self.y = @input_window.y
self.x = @input_window.x + @input_window.width + 8
@actor = $data_actors[actor]
@ticker = 10
@last_frame = 1
@frame = 1
refresh
end
def update
@ticker += 1
@frame = (@ticker % 40) / 10; @frame = 1 if @frame == 3
return if @frame == @last_frame
@last_frame = @frame
refresh
end
def refresh
contents.clear
x = contents.width / 2
y = contents.height - 6
draw_character(@actor.character_name, @actor.character_index, x, y, @frame)
end
def draw_character(character_name, character_index, x, y, frame = 1)
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+frame)*cw, (n/4*4)*ch, cw, ch)
ret_rect = Rect.new(x - cw, y - cw * 2, cw * 2, ch * 2)
contents.stretch_blt(ret_rect, bitmap, src_rect)
end
nd
lass Window_CCGui < Window_Selectable
def initialize(file, list)
@list = list
extra_width = CP::COMPOSITE::WINDOW_WIDTH + 8
extra_width += 128 if CP::COMPOSITE::USE_FACESETS
x = (Graphics.width - (180 + extra_width)) / 2
x += 128 if CP::COMPOSITE::USE_FACESETS
y = (Graphics.height - window_height) / 2
h = window_height
super(x, y, 180, h)
@file = file
refresh
end
def window_height
[fitting_height(item_max * 2), Graphics.height].min
end
def item_max
@list.size + 1
end
def contents_height
(item_max * 2) * line_height
end
def item_height
line_height * 2
end
def refresh
contents.clear
draw_all_items
end
def data
@list[@index]
end
def adj_data
if Composites.options[data][0].is_a?(Symbol)
return Composites.options[data][0]
else
return data
end
end
def draw_item(index)
rect = item_rect(index)
lh = line_height
if index == @list.size
text = CP::COMPOSITE::GUI_CLOSE
change_color(normal_color)
draw_text(rect.x + 2, rect.y + lh / 2, rect.width - 4, lh, text, 1)
else
block = Composites.options[@list[index]]
if block[0].is_a?(Symbol)
title = Composites.options[block[0]][0]
else
title = block[0]
end
value = (CP::COMPOSITE::COMPOSITE.include?(@list[index]) ||
@list[index] == :Gender || @list[index] == :Name)
sym = value ? @list[index] : block[0]
change_color(system_color)
draw_text(rect.x + 2, rect.y, rect.width - 4, lh, title)
case sym
when :Gender
na = CP::COMPOSITE::GENDER_NAMES
name = Composites.actor(@file).male? ? na[0] : na[1]
when :Name
name = Composites.actor(@file).name
else
name = Composites.actor(@file).get_composite_handler(sym)
name = CP::COMPOSITE::EMPTY_TEXT if name.nil?
hue = Composites.actor(@file).get_composite_hue(sym)
if block[1]
c1 = Bitmap.hue_colour_wheel(hue)
c2 = Color.new(c1.red, c1.green, c1.blue, 0)
r2 = contents.text_size(name).width
hr = Rect.new(contents.width - (r2 + 6), rect.y + lh + 3, r2 + 1, lh - 6)
contents.gradient_fill_rect(hr, c2, c1)
end
end
change_color(normal_color)
draw_text(rect.x + 2, rect.y + lh, rect.width - 6, lh, name, 2)
end
end
nd
lass Window_CCSelect < Window_Selectable
attr_reader :hue
def initialize(file, input)
super(0, 0, 160, 0)
@input_window = input
@file = file
@data = nil
@hue = 0
end
def item_max
return 1 if @data.nil? || @data.empty?
return @data.size
end
def refresh
contents.clear
draw_all_items
draw_hue_wheel
end
def draw_item(index)
rect = item_rect(index); rect.x += 2; rect.width -= 4
change_color(normal_color)
draw_text(rect, @data[index])
end
def draw_hue_wheel
rect = item_rect(item_max); contents.clear_rect(rect)
rect.y += 4; rect.height -= 8; rect.x += 8; rect.width -= 16
ind = Composites.options[@input_window.data]
return if !ind || ind[1] == 0
if ind[1] == 2
value = @hue >= 180 ? @hue - 360 : @hue
rect.height /= 2; rect.height -= 1; rect.x -= 60
contents.draw_rainbow(rect)
rect.y += (rect.height + 1); rect.x -= value / 3
contents.draw_rainbow(rect)
rect.x += 119
contents.draw_rainbow(rect)
rect.y -= (rect.height + 1); rect.x += value / 3
contents.draw_rainbow(rect)
bitmap2 = Bitmap.new(10, 19)
bitmap2.fill_rect(0, 0, 10, 19, Color.new(255, 255, 255))
c1 = Bitmap.hue_colour_wheel(0)
c2 = Bitmap.hue_colour_wheel(@hue)
bitmap2.gradient_fill_rect(1, 1, 8, 17, c1, c2, true)
rect = item_rect(item_max)
contents.blt((rect.width - 10) / 2, rect.y + 2, bitmap2, bitmap2.rect)
rect.width = 10
contents.clear_rect(rect)
rect.x = contents.width - rect.width
contents.clear_rect(rect)
elsif ind[1] == 1
contents.draw_rainbow(rect)
bitmap2 = Bitmap.new(7, 20)
bitmap2.fill_rect(0, 0, 7, 20, Color.new(255, 255, 255))
bitmap2.fill_rect(1, 2, 5, 16, Bitmap.hue_colour_wheel(@hue))
off = @hue / 3
contents.blt(rect.x - 3 + off, rect.y - 2, bitmap2, bitmap2.rect)
end
end
def show
val = @input_window.adj_data
ind = @input_window.data
actor = Composites.actor(@file)
block = Composites.actor(@file).male? ? 0 : 1
@name = Composites.list_by_block(ind, block).index(actor.get_composite_handler(val))
@index = val != :Gender ? @name : Composites.actor(@file).male? ? 0 : 1
@index = 0 if @index.nil?
@hue = actor.get_composite_hue(val) unless val == :Gender
cont = Composites.options[ind]
if val == :Gender
@data = CP::COMPOSITE::GENDER_NAMES
else
@data = Composites.list_by_block(ind, block)
end
add = Composites.options[ind][1] ? 1 : 0
add = 0 if val == :Gender
self.height = fitting_height(@data.size + add)
create_contents
refresh
self.x = @input_window.x + 16
iw = @input_window
self.y = iw.y + iw.standard_padding + (iw.index * (iw.line_height * 2)) - iw.oy + 28
self.y = Graphics.height - self.height if y + height > Graphics.height
super
activate
end
def cursor_right(wrap)
return if Composites.options.include?(@input_window.data) &&
!Composites.options[@input_window.data][1]
@hue /= 12; @hue *= 12
@hue += 12; @hue -= 360 if @hue >= 360
draw_hue_wheel
end
def cursor_left(wrap)
return if Composites.options.include?(@input_window.data) &&
!Composites.options[@input_window.data][1]
@hue /= 12; @hue *= 12
@hue -= 12; @hue += 360 if @hue < 0
draw_hue_wheel
end
nd
lass Game_Interpreter
def creation(char, list = nil) ## Allows for easy calling of the scene.
return if $game_party.in_battle
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
char = CP::COMPOSITE::NAMES.index(char)
else
return unless Composites.include?(char)
end
list = CP::COMPOSITE::BASE_GUI if list.nil?
return unless list.is_a?(Array)
SceneManager.call(Scene_CharacterCreation)
SceneManager.scene.prepare(char, list)
Fiber.yield
end
def composite_force(char, handler, name, hue = 0)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].force_composite(handler, name, hue)
end
def composite_custom(char, handler, name, hue = 0)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].change_composite(handler, name, hue)
end
def composite_reset(char)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].reset_composite
end
nd
lass Scene_CharacterCreation < Scene_MenuBase
def prepare(file, list)
@file = file
@list = list
end
def start
super
@actor = Composites.actor(@file)
create_windows
end
def create_windows
@input_window = Window_CCGui.new(@file, @list)
@input_window.set_handler
ok, method
gui_ok))
@input_window.set_handler
cancel, method
gui_cancel))
@select_window = Window_CCSelect.new(@file, @input_window)
@select_window.set_handler
ok, method
select_ok))
@select_window.set_handler
cancel, method
select_cancel))
@chara_window = Window_CCCharacter.new(@actor.id, @input_window)
@face_window = Window_CCFace.new(@actor.id, @input_window)
@input_window.activate.select(0)
@select_window.hide
end
def gui_ok
val = @input_window.data
if val == :Name
SceneManager.call(Scene_Name)
SceneManager.scene.prepare(Composites.actor(@file).id, CP::COMPOSITE::CHARACTERS)
@input_window.refresh
elsif val == nil
return_scene
else
@select_window.show
end
end
def gui_cancel
@input_window.activate.select(@input_window.item_max - 1)
end
def select_ok
val = @input_window.data
adj = @input_window.adj_data
id = @select_window.index
if adj == :Gender
if id == 0
Composites.actor(@file).change_composite
Gender, true)
Composites.actor(@file).reset_name
elsif id == 1
Composites.actor(@file).change_composite
Gender, false)
Composites.actor(@file).reset_name
end
else
block = Composites.actor(@file).male? ? 0 : 1
handler = Composites.list_by_block(val, block)[@select_window.index]
hue = @select_window.hue
Composites.actor(@file).change_composite(adj, handler, hue)
end
@select_window.hide
@chara_window.refresh
@face_window.refresh
@input_window.activate.refresh
end
def select_cancel
@select_window.hide
@input_window.activate
end
nd
lass RPG::BaseItem
def composite_hash
add_composite_data if @composite_hash.nil?
return @composite_hash
end
def composite_init
add_composite_data if @composite_init.nil?
return @composite_init
end
def gender_base
add_composite_data if @gender_base.nil?
return @gender_base
end
def alt_name
add_composite_data if @alt_name.nil?
return @alt_name
end
INITI_RE = /(.+) init\[(.+)[,]\s*(\d+)\]/i
IMAGE_RE = /(.+) image\[(.+)[,]\s*(\d+)\]/i
GENDER_RE = /gender\[(male|female)\]/i
ALT_NAME = /alt name\[(.+)\]/i
def add_composite_data
@gender_base = CP::COMPOSITE::MALE_DEFAULT
@composite_hash = {}; @composite_init = {}; @alt_name = ""
self.note.split(/[\r\n]+/).each do |line|
case line
when INITI_RE
@composite_init[$1.to_sym] = [$2.to_s, $3.to_i]
@composite_init["#{$1.to_s}Rear".to_sym] = [$2.to_s, $3.to_i]
@composite_init["#{$1.to_s}Hueless".to_sym] = [$2.to_s, 0]
@composite_init["#{$1.to_s}All".to_sym] = [$2.to_s, $3.to_i]
when IMAGE_RE
@composite_hash[$1.to_sym] = [$2.to_s, $3.to_i]
@composite_hash["#{$1.to_s}Rear".to_sym] = [$2.to_s, $3.to_i]
@composite_hash["#{$1.to_s}Hueless".to_sym] = [$2.to_s, 0]
@composite_hash["#{$1.to_s}All".to_sym] = [$2.to_s, $3.to_i]
when GENDER_RE
@gender_base = true if $1.to_s.downcase == "male"
@gender_base = false if $1.to_s.downcase == "female"
when ALT_NAME
@alt_name = $1.to_s
end
end
end
nd
##--------------------------------------------------------------------------###
End of script. #
##--------------------------------------------------------------------------###
## Composite Character v2.1
## Created by Neon Black
##
## Only for non-commercial use. See full terms of use and contact info at:
## http://cphouseset.wordpress.com/liscense-and-terms-of-use/
##----------------------------------------------------------------------------##
##
##----------------------------------------------------------------------------##
## Revision Info:
## V2.1 - 2.12.2013
## Added new script calls
## V2.0 - 1.24.2013
## Rewrote entire script from scratch
## V1.0 - 10.17.2012
## Wrote and debugged main script
##----------------------------------------------------------------------------##
##
$imported = {} if $imported.nil? ##
$imported["COMPOSITE"] = 2.1 ##
##
##----------------------------------------------------------------------------##
## Instructions:
## Place this script in the "Materials" section of the scripts above "Main".
## To use this script you must have additional composite graphics in a folder
## for characters and a folder for faces. Charactersets will use composites
## based on their names in the NAMES setting. Some layers of the composite
## may also change based on the equipped items on the actor associated with
## file name. There are several tags that work with both actors and equips.
##
## Tags:
## tag init[Handler, hue]
## - Can only be tagged in actors. Changes composite layer :tag to handler
## "Handler" with the defined hue. Do not use colons for layer names or
## quotes for file handler names.
## gender[male]
## - Sets the character's initial gender to "male" or "female" depending on
## which you place in the brackets. This can only tag actors.
## alt name[Christopher]
## - Sets the character's name for the opposite gender. If the player changes
## the gender in the GUI and has not changed the name, the new name will be
## displayed. The name "Christopher" here can be any name you desire.
## tag image[Handler, hue]
## - Changes the default images for layer :tag to file handler "Handler".
##
## Script Calls:
## The character creation screen can be called with either of these two script
## calls from an event. Other script calls also exist.
##
## creation(id) -or- creation(id, array)
## - The value "id" can be either the actor's ID or the name of the character
## set to modify. The "array" value does not need to be used ever. This is
## the array of handlers from "GUI_LISTS" to use. If no array is defined,
## "BASE_GUI" is used instead.
## composite_custom(id, handler, name, hue)
## - Changes composite "id"'s layer "handler" into file "name" with a hue of
## "hue". This occurs on the same priority level as the character creation
## screen, so it is covered by armour and can be modified by the player.
## "id" must be a value from NAMES, "handler" a layer from COMPOSITE, "name"
## a file from FILE_HANDLERS, and "hue" a number from 0 to 255.
## composite_force(id, handler, name, hue)
## - Similar to the command above, but this takes the highest priority when
## being drawn and cannot be changed by the player.
## composite_reset(id)
## - Removes all layers added using the "composite_force" script call.
##
## Special Layers:
## In order to allow a slight bit more customization, there are 3 types of
## special layers that link directly to other layers. These layers end with
## "Back", "Hueless", and "All".
##
## Back Layers
## - These layers do not actually need to be behind the normal layer. They
## are simply a second layer with all the same properties of the parent
## layer. An example would be :hairRear which would be a rear layer of
## :hair.
## Hueless Layers
## - These layers ignore the changed hue values. The main use of these would
## be objects with skin tone or perhaps objects that you only want to change
## part of the colour on. The only object that uses this in the example
## is :eyesHueless which is a hueless layer of :eyes.
## All Layers
## - These are special layers on the character. They are a layer that appears
## on the character no matter what the player does. The file that appears
## is still linked to the file part it is attatched to for the sake of hue.
## The file that appears for one of these layers is defined in the hash
## GUI_OPTIONS.
##----------------------------------------------------------------------------##
##
module CP # Do not touch ##
module COMPOSITE # these lines. ##
##
##----------------------------------------------------------------------------##
## Config:
## The config options are below. You can set these depending on the flavour of
## your game. Each option is explained in a bit more detail above it.
##
##------
# The folders containing the composite parts for characters and for facesets.
CHAR_FOLDER = "Graphics/Composite/Charas/"
FACE_FOLDER = "Graphics/Composite/Faces/"
# Determines if the creation screen uses face sets are not. Set to false if
# you do not want a faceset displayed.
USE_FACESETS = true
# The width and height of the character window in the creation screen. The
# character in the screen is zoomed in to 200%.
WINDOW_WIDTH = 90
WINDOW_HEIGHT = 112
# The text options for the character selection GUI. EMPTY_TEXT refers to an
# option which is blank for some reason.
GUI_CLOSE = "Finish Editing"
EMPTY_TEXT = "None"
# The number of allowed character spaces for names when input from the editor.
CHARACTERS = 6
# Names for the male and female genders.
GENDER_NAMES = ["Male", "Female"]
# Determines if male undefined characters start out as male characters.
MALE_DEFAULT = true
##------
# Determine the files that are recognized as composite images and the actor
# they are linked to, for the sake of armour, storage, etc.
NAMES ={
"$Hero1" => 11,
"$Hero2" => 12,
}
# The switches related to characters. A switch is turned ON when the character
# is male and OFF when the character is female.
SWITCHES ={
11 => 72,
12 => 73,
}
# The order for composite layers. The first layer is the lowest layer.
COMPOSITE =[
:hairRear,
:cape,
:armorRear,
:headAll,
:head,
:eyes,
:eyesAll,
:eyesHueless,
:armor,
:hair,
:glasses,
:helmet,
]
# These are the handlers for all files in the composite folders. Actor and
# equip tags as well as GUI options point to a handler and the handler
# determines the male and female files to look up. Make sure every handler
# has a different name.
FILE_HANDLERS ={
# "Handler" => ["Male_File", "Female_File"],
"Shaggy" => ["Hair1M", nil],
"Slick" => ["Hair2M", nil],
"Spiked" => ["Hair3M", nil],
"Fancy" => ["Hair4M", nil],
"Stylish" => [nil, "Hair1F"],
"Waist Length" => [nil, "Hair2F"],
"Curled" => [nil, "Hair3F"],
"Pigtails" => [nil, "Hair4F"],
"Short" => ["Hair1U", "Hair1U"],
"Long" => ["Hair2U", "Hair2U"],
"Observant" => ["Eye1M", "Eye1F"],
"Closed" => ["Eye2M", "Eye2F"],
"Intent" => ["Eye3M", "Eye3F"],
"HeadBase" => ["HeadAll", "HeadAll"],
"FaceBase" => ["FaceM", "FaceF"],
"BodyBase" => ["BaseM", "BaseF"],
"Clothes" => ["ClothesM", "ClothesF"],
"Cloth" => ["ClothM", "ClothF"],
"Armor" => ["ArmourM", "ArmourF"],
"Glasses" => ["Glasses", "Glasses"],
"Sunglasses" => ["Sunglasses", "Sunglasses"],
"Goggles" => ["Goggles", "Goggles"],
}
# Standard handlers. These are default handlers of certain layers.
STANDARD ={
:headAll => "HeadBase",
:head => "FaceBase",
:armor => "BodyBase",
}
# The GUI options that may be called from an array. If the "Name" field is set
# to a :symbol like the :barber example, it will point back to another option
# and use that option's name and layer. The point is simply to link different
# handlers to it as well as giving it different colour options. The colorize?
# option can be set to a value of 0, 1, or 2 depending on the style of hue bar
# you would like displayed. If it is set to 0, no bar will be displayed.
GUI_OPTIONS ={
# :handler => ["Name", colorize?, "AllFile"],
:Name => ["Name", 0, nil],
:Gender => ["Gender", 0, nil],
:hair => ["Hair", 1, nil],
:eyes => ["Eyes", 1, "EyeAll"],
:barber => [:hair, true, nil],
}
# These are the basic options to use in the GUI if no array is defined.
BASE_GUI = [:Name, :Gender, :hair, :eyes]
# These are the lists that refer to the options. Male and Female only options
# are automatically filtered depending on the character's gender.
GUI_LISTS ={
:hair => ["Shaggy", "Slick", "Spiked", "Fancy", "Stylish", "Waist Length",
"Curled", "Pigtails"],
:eyes => ["Observant", "Intent", "Closed"],
:barber => ["Shaggy", "Slick", "Spiked", "Fancy", "Stylish", "Waist Length",
"Curled", "Pigtails", "Short", "Long"],
}
##----------------------------------------------------------------------------##
##
##
##----------------------------------------------------------------------------##
## The following lines are the actual core code of the script. While you are
## certainly invited to look, modifying it may result in undesirable results.
## Modify at your own risk!
###----------------------------------------------------------------------------
end
nd
odule Cache
class << self ## Alias for the used methods in this module.
alias cp_cm_character character
alias cp_cm_face face
alias cp_cm_clear clear
end
def self.character(*args) ## Checks if the file is a composite.
return cp_cm_character(*args) unless Composites.include?(args[0])
create_composite(args[0], "Graphics/Characters/")
hue = args[1] ? args[1] : 0
load_bitmap("Graphics/Characters/", args[0], hue)
end
def self.face(*args) ## Checks if the face is a composite.
return cp_cm_face(*args) unless Composites.include?(args[0])
create_composite(args[0], "Graphics/Faces/")
hue = args[1] ? args[1] : 0
load_bitmap("Graphics/Faces/", args[0], hue)
end
def self.need_comp_ref?(file, path) ## Checks refresh status.
return true if Composites.refresh?(file)
return true if @cache[path].nil? || @cache[path].disposed?
return false
end
def self.create_composite(file, folder) ## Find and create the composite.
path = "#{folder}#{file}"
return unless need_comp_ref?(file, path)
foldrs = ["Graphics/Characters/", "Graphics/Faces/"]
Composites.constants.each_with_index do |fld, i|
paths = "#{foldrs}#{file}"
array = Composites.images(file)
Composites.layers do |i|
image = array
unless @temp
@temp = Bitmap.new("#{fld}#{image}") rescue next
@temp.hue_change(Composites.hues(file)) unless Composites.hues(file).nil?
else
t = Bitmap.new("#{fld}#{image}") rescue next
t.hue_change(Composites.hues(file)) unless Composites.hues(file).nil?
@temp.blt(0, 0, t, t.rect)
t.dispose; t = nil
end
end
@temp = Bitmap.new unless @temp
Composites.refreshed(file)
@cache[paths] = Bitmap.new(@temp.width, @temp.height)
@cache[paths].blt(0, 0, @temp, @temp.rect)
@temp.dispose; @temp = nil
end
Composites.remove_temp_layers(file)
end
def self.clear ## Reset the composite cache.
cp_cm_clear
Composites.clear
end
nd
odule Composites
def self.include?(file) ## Checks if a file is a composite.
return CP::COMPOSITE::NAMES.include?(file)
end
def self.options ## Easy access of the options hash.
return CP::COMPOSITE::GUI_OPTIONS
end
def self.lists ## Easy access of the gui lists hash.
return CP::COMPOSITE::GUI_LISTS
end
def self.list_by_block(handler, block) ## Returns a list based on gender.
return [] unless [0, 1].include?(block) && lists.include?(handler)
return lists[handler].select {|a| !files[a][block].nil?}
end
def self.layers ## Gets each layer key one at a time.
CP::COMPOSITE::COMPOSITE.each do |key|
yield key
end
end
def self.constants ## Gets the folder constants.
if CP::COMPOSITE::USE_FACESETS
return [CP::COMPOSITE::CHAR_FOLDER, CP::COMPOSITE::FACE_FOLDER]
else
return [CP::COMPOSITE::CHAR_FOLDER]
end
end
def self.files ## Gets the file handler hash.
return CP::COMPOSITE::FILE_HANDLERS
end
def self.include_block?(block, handler) ## Checks gender blocks to handlers.
return false unless files.include?(handler)
return !files[handler][block].nil?
end
def self.standard ## Gets the standard GUI display.
return CP::COMPOSITE::STANDARD
end
def self.get_first_handler(block, key) ## Gets the init files based on block.
return nil if ![0, 1].include?(block) || !lists.include?(key)
lists[key].each do |handler|
next unless files.include?(handler)
return handler unless files[handler][block].nil?
end
return nil
end
def self.n(file) ## Returns a number from a file.
return CP::COMPOSITE::NAMES[file]
end
def self.refreshed(file) ## Resets a file's refresh status.
return unless n(file)
actor(file).composite_refresh = false
end
def self.images(file) ## Get all images of a file.
return @temp_images[file] if @temp_images && @temp_images[file]
return actor(file).composite_images
end
def self.hues(file) ## Get all hues of a file.
return @temp_hues[file] if @temp_hues && @temp_hues[file]
return actor(file).composite_hues
end
def self.remove_temp_layers(file) ## Removes temporary (save) layers.
@temp_images.delete(file) if @temp_images
@temp_hues.delete(file) if @temp_hues
end
def self.make_temp_file(file, handlers) ## Create a new temp of a file.
@temp_images = {} if @temp_images.nil?; @temp_hues = {} if @temp_hues.nil?
@temp_images[file] = {}; @temp_hues[file] = {}
handlers.each do |key, array|
@temp_images[file][key] = array[0]
@temp_hues[file][key] = array[1]
end
end
def self.refresh?(file) ## Check if a file needs refreshing.
return false unless n(file) ## Includes temp file checking.
return true if @temp_images && @temp_images.include?(file)
return actor(file).composite_refresh
end
def self.actor(file) ## Gets a game actor from a file name.
return $game_actors[n(file)]
end
def self.clear ## Allows forced reset of each file.
CP::COMPOSITE::NAMES.keys.each do |file|
actor(file).composite_refresh = true
end
end
nd
lass Game_Actor < Game_Battler
attr_accessor :composite_refresh
alias cp_cmpst_init initialize
def initialize(*args) ## Sets the initial values for composites.
cp_cmpst_init(*args)
@composite_refresh = true
@editor_changes = {}
@editor_hues = {}
@forced_composites = {}
end
def composite_images ## Returns the composite images for an actor.
make_composite_lists if @composite_refresh
return @composite_images
end
def composite_hues ## Returns the composite hues.
make_composite_lists if @composite_refresh
return @composite_hues
end
def edd_additions(hueless, rear) ## Make a new filename based on layers.
a = ""
b = hueless ? "#{a}Hueless" : a
c = rear ? "#{b}Rear" : b
return c
end
def get_composite_lists ## Gets a composite list for save files.
return {} unless Composites.include?(character_name)
make_composite_lists
r = {}
@composite_images.each {|k, v| r[k] = [v, @composite_hues[k]]}
return r
end
def make_composite_lists ## Makes the list of composites and hues.
@composite_images = {}
@composite_hues = {}
@composite_male = get_base_gender ## Sets gender.
if CP::COMPOSITE::SWITCHES.include?(@actor_id) ## Sets a gender switch.
$game_switches[CP::COMPOSITE::SWITCHES[@actor_id]] = @composite_male
end
block = @composite_male ? 0 : 1
make_equip_hashes(block) ## Ensures equips are set up.
Composites.layers do |key| ## Check each layer.
@composite_hues[key] = 0 ## Gets init values for variables.
name = nil
string = key.to_s
hueless = string.include?("Hueless")
rear = string.include?("Rear")
all = string.include?("All")
string.gsub!(/(Hueless|All|Rear)/, '')
edd = edd_additions(hueless, rear)
line = CP::COMPOSITE::GUI_OPTIONS[string.to_sym]
handler = get_composite_handler(key)
parent = get_composite_handler(string.to_sym)
hues = get_composite_hue(key)
if all && !line.nil? ## Determines the needed value.
name = line[2]
elsif handler && Composites.files.include?(handler) &&
Composites.files[handler][block]
name = "#{Composites.files[handler][block]}#{edd}"
elsif parent && Composites.files.include?(parent) &&
Composites.files[parent][block] && (rear || hueless)
name = "#{Composites.files[parent][block]}#{edd}"
elsif Composites.standard.include?(key)
name = Composites.files[Composites.standard[key]][block]
end
next unless name ## Skips if there is no name.
@composite_images[key] = name ## Creates the hashes.
@composite_hues[key] = hueless ? 0 : hues
end
end
def get_base_gender ## Gets the gender.
return @editor_changes[:Gender] if @editor_changes.include?
return actor.gender_base
end
def get_composite_handler(key) ## Complex method to find the file handler.
block = @composite_male ? 0 : 1
if @forced_composites.include?(key) && Composites.include_block?(block,
@forced_composites[key][0])
hues = @forced_composites[key][0]
elsif @equip_hashes.include?(key) && Composites.include_block?(block,
@equip_hashes[key][0])
handler = @equip_hashes[key][0]
elsif @editor_changes.include?(key) && Composites.include_block?(block,
@editor_changes[key])
handler = @editor_changes[key]
elsif actor.composite_init.include?(key) && Composites.include_block?(block,
actor.composite_init[key][0])
handler = actor.composite_init[key][0]
elsif Composites.get_first_handler(block, key)
handler = Composites.get_first_handler(block, key)
else
handler = nil
end
return handler
end
def get_composite_hue(key) ## Same as above but for hues.
block = @composite_male ? 0 : 1
if @forced_composites.include?(key) && Composites.include_block?(block,
@forced_composites[key][0])
hues = @forced_composites[key][1]
elsif @equip_hashes.include?(key) && Composites.include_block?(block,
@equip_hashes[key][0])
hues = @equip_hashes[key][1]
elsif @editor_changes.include?(key) && Composites.include_block?(block,
@editor_changes[key])
hues = @editor_hues[key]
elsif actor.composite_init.include?(key) && Composites.include_block?(block,
actor.composite_init[key][0])
hues = actor.composite_init[key][1]
else
hues = 0
end
return hues
end
def make_equip_hashes(block) ## Makes the handler hash for equips.
@equip_hashes = {}
equips.each do |eq|
next unless eq
eq.composite_hash.each do |key, array|
next if Composites.files[array[0]][male? ? 0 : 1].nil?
@equip_hashes[key] = array
end
end
end
alias cp_composite_change_eq change_equip
def change_equip(*args) ## Ensures refreshing on equip change.
cp_composite_change_eq(*args)
@composite_refresh = true
end
def change_composite(hand, value = nil, hue = nil)
array = ["#{hand}".to_sym, "#{hand}Rear".to_sym, "#{hand}Hueless".to_sym,
"#{hand}All".to_sym]
array.each do |handler| ## Changes values for a layer and sublayers.
unless value.nil?
@editor_changes[handler] = value
@editor_hues[handler] = hue if hue
else
@editor_changes.delete(handler)
@editor_hues.delete(handler)
end
end
@composite_refresh = true
end
def force_composite(hand, value = nil, hue = nil)
array = ["#{hand}".to_sym, "#{hand}Rear".to_sym, "#{hand}Hueless".to_sym,
"#{hand}All".to_sym]
array.each do |handler| ## Changes values for a layer and sublayers.
unless value.nil?
@forced_composites[handler] = []
@forced_composites[handler][0] = value
@forced_composites[handler][1] = hue if hue
else
@forced_composites.delete(handler)
end
end
@composite_refresh = true
end
def reset_composite
@forced_composites = {}
@composite_refresh = true
end
def reset_name ## Changes the name to a default name.
return if actor.alt_name.empty?
@composite_male = get_base_gender
if @composite_male == actor.gender_base
@name = actor.name if @name == actor.alt_name
else
@name = actor.alt_name if @name == actor.name
end
end
def male? ## Check if the actor is male.
return @composite_male
end
nd
lass Window_SaveFile < Window_Base
def draw_party_characters(x, y) ## Creates a temp array for the save file.
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
Composites.make_temp_file(data[0], data[2])
draw_character(data[0], data[1], x + i * 48, y)
end
end
nd
lass Game_Party < Game_Unit
def characters_for_savefile ## Adds the composite arrays to a save file.
battle_members.collect do |actor|
[actor.character_name, actor.character_index, actor.get_composite_lists]
end
end
nd
lass Scene_Load < Scene_File ## Clears the composites on a load.
alias cp_comp_load_succ on_load_success
def on_load_success
Composites.clear
cp_comp_load_succ
end
nd
lass Scene_Save < Scene_File ## Clears the composites on save.
alias cp_comp_save_ok on_savefile_ok
def on_savefile_ok
Composites.clear
cp_comp_save_ok
end
nd
lass Bitmap
def draw_rainbow(*args) ## Draws a rainbow rectangle.
case args.size
when 1
rect = args[0].clone
when 4
rect = Rect.new(args[0], args[1], args[2], args[3])
end
ca = rainbow_colours
6.times do |i|
wv = rect.width / (6 - i)
n = i == 5 ? 0 : 1
r2 = Rect.new(rect.x, rect.y, wv + n, rect.height)
self.gradient_fill_rect(r2, ca, ca[(i + 1) % 6])
rect.width -= wv
rect.x += wv
end
end
def rainbow_colours ## Colours for the rectangle.
c1 = Color.new(255, 0, 0); c2 = Color.new(255, 255, 0)
c3 = Color.new( 0, 255, 0); c4 = Color.new( 0, 255, 255)
c5 = Color.new( 0, 0, 255); c6 = Color.new(255, 0, 255)
return [c1, c2, c3, c4, c5, c6]
end
@@wheel = Bitmap.new(360, 1)
@@wheel.draw_rainbow(0, 0, 360, 1)
def self.hue_colour_wheel(hue) ## Show the new hue colour.
if @@wheel.disposed?
@@wheel = Bitmap.new(360, 1)
@@wheel.draw_rainbow(0, 0, 360, 1)
end
return @@wheel.get_pixel(hue % 360, 0)
end
nd
# The core bits of the script scene are below.
lass Window_CCFace < Window_Base
def initialize(actor, input)
super(0, 0, 120, 120)
self.visible = CP::COMPOSITE::USE_FACESETS
@input_window = input
self.y = @input_window.y
self.x = @input_window.x - (self.width + 8)
@actor = $data_actors[actor]
refresh
end
def refresh
contents.clear
draw_face(@actor.face_name, @actor.face_index, 0, 0)
end
nd
lass Window_CCCharacter < Window_Base
def initialize(actor, input)
super(0, 0, CP::COMPOSITE::WINDOW_WIDTH, CP::COMPOSITE::WINDOW_HEIGHT)
@input_window = input
self.y = @input_window.y
self.x = @input_window.x + @input_window.width + 8
@actor = $data_actors[actor]
@ticker = 10
@last_frame = 1
@frame = 1
refresh
end
def update
@ticker += 1
@frame = (@ticker % 40) / 10; @frame = 1 if @frame == 3
return if @frame == @last_frame
@last_frame = @frame
refresh
end
def refresh
contents.clear
x = contents.width / 2
y = contents.height - 6
draw_character(@actor.character_name, @actor.character_index, x, y, @frame)
end
def draw_character(character_name, character_index, x, y, frame = 1)
return unless character_name
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign && sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+frame)*cw, (n/4*4)*ch, cw, ch)
ret_rect = Rect.new(x - cw, y - cw * 2, cw * 2, ch * 2)
contents.stretch_blt(ret_rect, bitmap, src_rect)
end
nd
lass Window_CCGui < Window_Selectable
def initialize(file, list)
@list = list
extra_width = CP::COMPOSITE::WINDOW_WIDTH + 8
extra_width += 128 if CP::COMPOSITE::USE_FACESETS
x = (Graphics.width - (180 + extra_width)) / 2
x += 128 if CP::COMPOSITE::USE_FACESETS
y = (Graphics.height - window_height) / 2
h = window_height
super(x, y, 180, h)
@file = file
refresh
end
def window_height
[fitting_height(item_max * 2), Graphics.height].min
end
def item_max
@list.size + 1
end
def contents_height
(item_max * 2) * line_height
end
def item_height
line_height * 2
end
def refresh
contents.clear
draw_all_items
end
def data
@list[@index]
end
def adj_data
if Composites.options[data][0].is_a?(Symbol)
return Composites.options[data][0]
else
return data
end
end
def draw_item(index)
rect = item_rect(index)
lh = line_height
if index == @list.size
text = CP::COMPOSITE::GUI_CLOSE
change_color(normal_color)
draw_text(rect.x + 2, rect.y + lh / 2, rect.width - 4, lh, text, 1)
else
block = Composites.options[@list[index]]
if block[0].is_a?(Symbol)
title = Composites.options[block[0]][0]
else
title = block[0]
end
value = (CP::COMPOSITE::COMPOSITE.include?(@list[index]) ||
@list[index] == :Gender || @list[index] == :Name)
sym = value ? @list[index] : block[0]
change_color(system_color)
draw_text(rect.x + 2, rect.y, rect.width - 4, lh, title)
case sym
when :Gender
na = CP::COMPOSITE::GENDER_NAMES
name = Composites.actor(@file).male? ? na[0] : na[1]
when :Name
name = Composites.actor(@file).name
else
name = Composites.actor(@file).get_composite_handler(sym)
name = CP::COMPOSITE::EMPTY_TEXT if name.nil?
hue = Composites.actor(@file).get_composite_hue(sym)
if block[1]
c1 = Bitmap.hue_colour_wheel(hue)
c2 = Color.new(c1.red, c1.green, c1.blue, 0)
r2 = contents.text_size(name).width
hr = Rect.new(contents.width - (r2 + 6), rect.y + lh + 3, r2 + 1, lh - 6)
contents.gradient_fill_rect(hr, c2, c1)
end
end
change_color(normal_color)
draw_text(rect.x + 2, rect.y + lh, rect.width - 6, lh, name, 2)
end
end
nd
lass Window_CCSelect < Window_Selectable
attr_reader :hue
def initialize(file, input)
super(0, 0, 160, 0)
@input_window = input
@file = file
@data = nil
@hue = 0
end
def item_max
return 1 if @data.nil? || @data.empty?
return @data.size
end
def refresh
contents.clear
draw_all_items
draw_hue_wheel
end
def draw_item(index)
rect = item_rect(index); rect.x += 2; rect.width -= 4
change_color(normal_color)
draw_text(rect, @data[index])
end
def draw_hue_wheel
rect = item_rect(item_max); contents.clear_rect(rect)
rect.y += 4; rect.height -= 8; rect.x += 8; rect.width -= 16
ind = Composites.options[@input_window.data]
return if !ind || ind[1] == 0
if ind[1] == 2
value = @hue >= 180 ? @hue - 360 : @hue
rect.height /= 2; rect.height -= 1; rect.x -= 60
contents.draw_rainbow(rect)
rect.y += (rect.height + 1); rect.x -= value / 3
contents.draw_rainbow(rect)
rect.x += 119
contents.draw_rainbow(rect)
rect.y -= (rect.height + 1); rect.x += value / 3
contents.draw_rainbow(rect)
bitmap2 = Bitmap.new(10, 19)
bitmap2.fill_rect(0, 0, 10, 19, Color.new(255, 255, 255))
c1 = Bitmap.hue_colour_wheel(0)
c2 = Bitmap.hue_colour_wheel(@hue)
bitmap2.gradient_fill_rect(1, 1, 8, 17, c1, c2, true)
rect = item_rect(item_max)
contents.blt((rect.width - 10) / 2, rect.y + 2, bitmap2, bitmap2.rect)
rect.width = 10
contents.clear_rect(rect)
rect.x = contents.width - rect.width
contents.clear_rect(rect)
elsif ind[1] == 1
contents.draw_rainbow(rect)
bitmap2 = Bitmap.new(7, 20)
bitmap2.fill_rect(0, 0, 7, 20, Color.new(255, 255, 255))
bitmap2.fill_rect(1, 2, 5, 16, Bitmap.hue_colour_wheel(@hue))
off = @hue / 3
contents.blt(rect.x - 3 + off, rect.y - 2, bitmap2, bitmap2.rect)
end
end
def show
val = @input_window.adj_data
ind = @input_window.data
actor = Composites.actor(@file)
block = Composites.actor(@file).male? ? 0 : 1
@name = Composites.list_by_block(ind, block).index(actor.get_composite_handler(val))
@index = val != :Gender ? @name : Composites.actor(@file).male? ? 0 : 1
@index = 0 if @index.nil?
@hue = actor.get_composite_hue(val) unless val == :Gender
cont = Composites.options[ind]
if val == :Gender
@data = CP::COMPOSITE::GENDER_NAMES
else
@data = Composites.list_by_block(ind, block)
end
add = Composites.options[ind][1] ? 1 : 0
add = 0 if val == :Gender
self.height = fitting_height(@data.size + add)
create_contents
refresh
self.x = @input_window.x + 16
iw = @input_window
self.y = iw.y + iw.standard_padding + (iw.index * (iw.line_height * 2)) - iw.oy + 28
self.y = Graphics.height - self.height if y + height > Graphics.height
super
activate
end
def cursor_right(wrap)
return if Composites.options.include?(@input_window.data) &&
!Composites.options[@input_window.data][1]
@hue /= 12; @hue *= 12
@hue += 12; @hue -= 360 if @hue >= 360
draw_hue_wheel
end
def cursor_left(wrap)
return if Composites.options.include?(@input_window.data) &&
!Composites.options[@input_window.data][1]
@hue /= 12; @hue *= 12
@hue -= 12; @hue += 360 if @hue < 0
draw_hue_wheel
end
nd
lass Game_Interpreter
def creation(char, list = nil) ## Allows for easy calling of the scene.
return if $game_party.in_battle
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
char = CP::COMPOSITE::NAMES.index(char)
else
return unless Composites.include?(char)
end
list = CP::COMPOSITE::BASE_GUI if list.nil?
return unless list.is_a?(Array)
SceneManager.call(Scene_CharacterCreation)
SceneManager.scene.prepare(char, list)
Fiber.yield
end
def composite_force(char, handler, name, hue = 0)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].force_composite(handler, name, hue)
end
def composite_custom(char, handler, name, hue = 0)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].change_composite(handler, name, hue)
end
def composite_reset(char)
if char.is_a?(Integer)
return unless CP::COMPOSITE::NAMES.has_value?(char)
else
return unless Composites.include?(char)
char = CP::COMPOSITE::NAMES[char]
end
$game_actors[char].reset_composite
end
nd
lass Scene_CharacterCreation < Scene_MenuBase
def prepare(file, list)
@file = file
@list = list
end
def start
super
@actor = Composites.actor(@file)
create_windows
end
def create_windows
@input_window = Window_CCGui.new(@file, @list)
@input_window.set_handler
@input_window.set_handler
@select_window = Window_CCSelect.new(@file, @input_window)
@select_window.set_handler
@select_window.set_handler
@chara_window = Window_CCCharacter.new(@actor.id, @input_window)
@face_window = Window_CCFace.new(@actor.id, @input_window)
@input_window.activate.select(0)
@select_window.hide
end
def gui_ok
val = @input_window.data
if val == :Name
SceneManager.call(Scene_Name)
SceneManager.scene.prepare(Composites.actor(@file).id, CP::COMPOSITE::CHARACTERS)
@input_window.refresh
elsif val == nil
return_scene
else
@select_window.show
end
end
def gui_cancel
@input_window.activate.select(@input_window.item_max - 1)
end
def select_ok
val = @input_window.data
adj = @input_window.adj_data
id = @select_window.index
if adj == :Gender
if id == 0
Composites.actor(@file).change_composite
Composites.actor(@file).reset_name
elsif id == 1
Composites.actor(@file).change_composite
Composites.actor(@file).reset_name
end
else
block = Composites.actor(@file).male? ? 0 : 1
handler = Composites.list_by_block(val, block)[@select_window.index]
hue = @select_window.hue
Composites.actor(@file).change_composite(adj, handler, hue)
end
@select_window.hide
@chara_window.refresh
@face_window.refresh
@input_window.activate.refresh
end
def select_cancel
@select_window.hide
@input_window.activate
end
nd
lass RPG::BaseItem
def composite_hash
add_composite_data if @composite_hash.nil?
return @composite_hash
end
def composite_init
add_composite_data if @composite_init.nil?
return @composite_init
end
def gender_base
add_composite_data if @gender_base.nil?
return @gender_base
end
def alt_name
add_composite_data if @alt_name.nil?
return @alt_name
end
INITI_RE = /(.+) init\[(.+)[,]\s*(\d+)\]/i
IMAGE_RE = /(.+) image\[(.+)[,]\s*(\d+)\]/i
GENDER_RE = /gender\[(male|female)\]/i
ALT_NAME = /alt name\[(.+)\]/i
def add_composite_data
@gender_base = CP::COMPOSITE::MALE_DEFAULT
@composite_hash = {}; @composite_init = {}; @alt_name = ""
self.note.split(/[\r\n]+/).each do |line|
case line
when INITI_RE
@composite_init[$1.to_sym] = [$2.to_s, $3.to_i]
@composite_init["#{$1.to_s}Rear".to_sym] = [$2.to_s, $3.to_i]
@composite_init["#{$1.to_s}Hueless".to_sym] = [$2.to_s, 0]
@composite_init["#{$1.to_s}All".to_sym] = [$2.to_s, $3.to_i]
when IMAGE_RE
@composite_hash[$1.to_sym] = [$2.to_s, $3.to_i]
@composite_hash["#{$1.to_s}Rear".to_sym] = [$2.to_s, $3.to_i]
@composite_hash["#{$1.to_s}Hueless".to_sym] = [$2.to_s, 0]
@composite_hash["#{$1.to_s}All".to_sym] = [$2.to_s, $3.to_i]
when GENDER_RE
@gender_base = true if $1.to_s.downcase == "male"
@gender_base = false if $1.to_s.downcase == "female"
when ALT_NAME
@alt_name = $1.to_s
end
end
end
nd
##--------------------------------------------------------------------------###
End of script. #
##--------------------------------------------------------------------------###
And the error is:
"Script 'In Game Character Creation' line 1091: SyntaxError occurred. unexpected $end"
I've "downloaded" this script HEREThe last script is:
#==============================================================================#
# **SheolShade Minimap** #
#------------------------------------------------------------------------------#
# ** Autor: SheolShade #
# ** Versão: 1.0b #
# ** Data: 24/12/2012 #
#------------------------------------------------------------------------------#
# - Descrição: #
# Este script adiciona um mini mapa circular no jogo. #
# - Utilização: #
# Cole este script na seção "Scripts Adicionais". #
#==============================================================================#
#==============================================================================#
# ** Configuração #
#------------------------------------------------------------------------------#
# TileSize -> linha: 99
# Define o tamanho do tile utilizado no minimapa.
#
# MapOffset -> linha: 100
# Dependendo do tamanho do tile utilizado será necessário ajustar a
# posição do minimapa.
#
# PlayerColor -> linha: 101
# Define a cor do jogador mostrada no mapa.
#
# ObjectColor -> linha: 102
# Permite definir uma cor pra cada tipo de objeto no mapa, como
# NPCS, teletranportes, baús e etc, usando comenta´rios nos eventos.
# Use a seguinte sintaxe dentro do {}, separado por vírgulas:
#
# "comentário" => Color.new(R, G,
.invert
# R = valor RGB para vermelho;
# G = valor RGB para verde;
# B = valor RGB para azul;
#
# BorderColor -> linha: 104
# Define a cor do contorno dos eventos e jogador.
#
# ObjectLayerOpacity -> linha: 105
# Define a transparencia da camada de eventos.
#
# MiniMapCorner -> linha: 106
# Define a posção do mini mapa.
# 1 = Canto superior esquerdo;
# 2 = Canto superior direito;
# 3 = Canto inferior esquerdo;
# 4 = Canto inferior direito;
#
# MapColor -> linha: 107
# Define a cor da parte não passável do mapa.
#
# MapBorderColor -> linha: 108
# Define a cor do contorno das areas não passávies.
#
# BorderName -> linha: 109
# Nome do arquivo de imagem para a borda do mini mapa. Na pasta System.
#
# BackTextureName -> linha: 110
# Nome do arquivo de imagem para a textura de fundo. Na pasta System.
#
# ClearOutsideArea -> linha: 111
# Permite preeencher com uma cor as area fora do mapa ao invez de usar
# a textura. true ou false
#
# ClearOutsideColor -> linha: 112
# Se ClearoutsideArea for true, utilizará a cor definida aqui para
# preencher a area externa.
#
# OutlineMapArea -> linha: 113
# Permite definir um contorno demarcando o limite do mapa. true ou false
#
# OutlineMapColor -> linha: 114
# Se OutlineMapArea for true, utilizará a cor definida aqui para
# o contorno.
#
# EnableSwitchID
# Define a id do switch usado para ligar ou desligar o mini mapa.
#==============================================================================#
#==============================================================================#
# ** Classe Color
#==============================================================================#
class Color
#-----------------------------------------------------------------------------
# * Inverte o valor das cores
#-----------------------------------------------------------------------------
def invert
r = 255 - self.red
g = 255 - self.green
b = 255 - self.blue
a = self.alpha
self.set(r, g, b, a)
end
end
#==============================================================================#
# ** Modulo SheolShade
#==============================================================================#
module SheolShade
module MiniMap
#Inicio da configuração#
TileSize = 8
MapOffset = -4
PlayerColor = Color.new(255,0,0).invert
ObjectColor = {"npc" => Color.new(0,255,0).invert,
"door" => Color.new(0,0,255).invert,
"chest" => Color.new(100,100,100).invert}
BorderColor = Color.new(0,0,0).invert
ObjectLayerOpacity = 255
MiniMapCorner = 2
MapColor = Color.new(200,150,150).invert
MapBorderColor = Color.new(50,50,50).invert
BorderName = "Border"
BackTextureName = "OldPaper"
ClearOutsideArea = false
ClearOutsideColor = Color.new(0,0,0).invert
OutlineMapArea = true
OutlineMapColor = Color.new(0,0,0).invert
EnableSwitchId = 1
#Fim da configuração#
MiniMapCoords = {1 => [0,0,112,112],
2 => [Graphics.width - 112,0,112,112],
3 => [0,Graphics.height - 112,112,112],
4 => [Graphics.width - 112,Graphics.height - 112,112,112]}
end
end
#==============================================================================#
# ** Classe Mini Map
#==============================================================================#
class MiniMap
include SheolShade::MiniMap
def initialize(viewport)
@viewport = viewport
refresh
end
def refresh
@backmask = Sprite.new(@viewport)
@backmask.bitmap = Cache::system("Back_96")
@backmask.x = @backmask.y = 8
@backtile = Sprite.new(@viewport)
@backtile.blend_type = 2
@backtile.z = 1
@backtile.x = @backtile.y = -100
@map = Sprite.new(@viewport)
@map.z = 2
@map.blend_type = 2
@object_layer = Sprite.new(@viewport)
@object_layer.z = 3
@object_layer.blend_type = 2
@object_layer.bitmap = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize + 112)
@object_layer.opacity = ObjectLayerOpacity
@border = Sprite.new(@viewport)
@border.bitmap = Cache::system(BorderName)
@border.z = 4
@border.opacity = 255
@mask = Cache::system("Mask")
draw_back
draw_map
end
def visible
$game_switches[EnableSwitchId]
end
def draw_map
front = make_map_bitmap(MapColor)
border = make_map_bitmap(MapBorderColor)
result = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize+ 112)
result.blt(-1, 0, border, border.rect)
result.blt(1, 0, border, border.rect)
result.blt(0, -1, border, border.rect)
result.blt(0, 1, border, border.rect)
result.blt(0, 0, front, front.rect)
@mapbitmap = result
end
def draw_back
bitmap = Bitmap.new($game_map.width*TileSize+112,
$game_map.height*TileSize+112)
bit = Cache::system(BackTextureName)
bitmap.stretch_blt(bitmap.rect, bit, bit.rect)
if ClearOutsideArea
bitmap.fill_rect(0,0,bitmap.width, 56, ClearOutsideColor)
bitmap.fill_rect(0,0,56, bitmap.height, ClearOutsideColor)
bitmap.fill_rect(0,bitmap.height-56,bitmap.width, 56, ClearOutsideColor)
bitmap.fill_rect(bitmap.width-56,0,56, bitmap.height, ClearOutsideColor)
elsif OutlineMapArea
bitmap.fill_rect(56,55,bitmap.width-112,1,OutlineMapColor)
bitmap.fill_rect(55,56,1,bitmap.height-112,OutlineMapColor)
bitmap.fill_rect(bitmap.width-56,55,1,bitmap.height-112,OutlineMapColor)
bitmap.fill_rect(56,bitmap.height-56,bitmap.width-112,1,OutlineMapColor)
end
@backtilebitmap = bitmap
end
def draw_object_layer
for event in $game_map.events.keys
if $game_map.events[event].list.size >= 0
for item in $game_map.events[event].list
if item.code == 108 or item.code == 408
if ObjectColor.has_key?(item.parameters[0])
draw_object($game_map.events[event].real_x*TileSize+56,
$game_map.events[event].real_y*TileSize+56,
ObjectColor[item.parameters[0]])
end
end
end
end
end
draw_object($game_player.real_x*TileSize+56, $game_player.real_y*TileSize+56, PlayerColor)
end
def draw_object(x, y, color)
@object_layer.bitmap.fill_rect(x, y, TileSize, TileSize, BorderColor)
@object_layer.bitmap.fill_rect(x+1, y+1, TileSize-2, TileSize-2, color)
@object_layer.bitmap.clear_rect(x,y,1,1)
@object_layer.bitmap.clear_rect(x,y+TileSize-1,1,1)
@object_layer.bitmap.clear_rect(x+TileSize-1,y,1,1)
@object_layer.bitmap.clear_rect(x+TileSize-1,y+TileSize-1,1,1)
end
def make_map_bitmap(color)
bitmap = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize + 112)
for x in 0..$game_map.width - 1
for y in 0..$game_map.height - 1
if $game_map.airship_land_ok?(x, y)
next
end
bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
end
end
bitmap
end
def update_object_layer
@object_layer.bitmap.clear
draw_object_layer
end
def dispose
@backmask.dispose
@backtile.dispose
@map.dispose
@object_layer.dispose
@border.dispose
end
def update
@backmask.visible = visible
@backtile.visible = visible
@map.visible = visible
@object_layer.visible = visible
@border.visible = visible
if visible
@map.bitmap = @mapbitmap.dup
@backtile.bitmap = @backtilebitmap.dup
sx = $game_player.real_x * (TileSize * -1) + MapOffset
sy = $game_player.real_y * (TileSize * -1) + MapOffset
update_object_layer
@map.x = @backtile.x = @object_layer.x = sx
@map.y = @backtile.y = @object_layer.y = sy
@backtile.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
@map.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
@object_layer.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
end
end
end
#==============================================================================#
# ** Classe Spriteset_Map
#==============================================================================#
class Spriteset_Map
alias old_init initialize
alias old_updt update
alias old_disp dispose
include SheolShade::MiniMap
def initialize
viewport = Viewport.new(Graphics.width - 112,0,112,112)
viewport.rect.set(MiniMapCoords[MiniMapCorner][0],
MiniMapCoords[MiniMapCorner][1],
MiniMapCoords[MiniMapCorner][2],
MiniMapCoords[MiniMapCorner][3])
viewport.z = 500
@minimapa = MiniMap.new(viewport)
old_init
end
def dispose
old_disp
@minimapa.dispose
end
def update
old_updt
@minimapa.update
end
end
#==============================================================================#
# ** Fim do Script
#==============================================================================#
# **SheolShade Minimap** #
#------------------------------------------------------------------------------#
# ** Autor: SheolShade #
# ** Versão: 1.0b #
# ** Data: 24/12/2012 #
#------------------------------------------------------------------------------#
# - Descrição: #
# Este script adiciona um mini mapa circular no jogo. #
# - Utilização: #
# Cole este script na seção "Scripts Adicionais". #
#==============================================================================#
#==============================================================================#
# ** Configuração #
#------------------------------------------------------------------------------#
# TileSize -> linha: 99
# Define o tamanho do tile utilizado no minimapa.
#
# MapOffset -> linha: 100
# Dependendo do tamanho do tile utilizado será necessário ajustar a
# posição do minimapa.
#
# PlayerColor -> linha: 101
# Define a cor do jogador mostrada no mapa.
#
# ObjectColor -> linha: 102
# Permite definir uma cor pra cada tipo de objeto no mapa, como
# NPCS, teletranportes, baús e etc, usando comenta´rios nos eventos.
# Use a seguinte sintaxe dentro do {}, separado por vírgulas:
#
# "comentário" => Color.new(R, G,
# R = valor RGB para vermelho;
# G = valor RGB para verde;
# B = valor RGB para azul;
#
# BorderColor -> linha: 104
# Define a cor do contorno dos eventos e jogador.
#
# ObjectLayerOpacity -> linha: 105
# Define a transparencia da camada de eventos.
#
# MiniMapCorner -> linha: 106
# Define a posção do mini mapa.
# 1 = Canto superior esquerdo;
# 2 = Canto superior direito;
# 3 = Canto inferior esquerdo;
# 4 = Canto inferior direito;
#
# MapColor -> linha: 107
# Define a cor da parte não passável do mapa.
#
# MapBorderColor -> linha: 108
# Define a cor do contorno das areas não passávies.
#
# BorderName -> linha: 109
# Nome do arquivo de imagem para a borda do mini mapa. Na pasta System.
#
# BackTextureName -> linha: 110
# Nome do arquivo de imagem para a textura de fundo. Na pasta System.
#
# ClearOutsideArea -> linha: 111
# Permite preeencher com uma cor as area fora do mapa ao invez de usar
# a textura. true ou false
#
# ClearOutsideColor -> linha: 112
# Se ClearoutsideArea for true, utilizará a cor definida aqui para
# preencher a area externa.
#
# OutlineMapArea -> linha: 113
# Permite definir um contorno demarcando o limite do mapa. true ou false
#
# OutlineMapColor -> linha: 114
# Se OutlineMapArea for true, utilizará a cor definida aqui para
# o contorno.
#
# EnableSwitchID
# Define a id do switch usado para ligar ou desligar o mini mapa.
#==============================================================================#
#==============================================================================#
# ** Classe Color
#==============================================================================#
class Color
#-----------------------------------------------------------------------------
# * Inverte o valor das cores
#-----------------------------------------------------------------------------
def invert
r = 255 - self.red
g = 255 - self.green
b = 255 - self.blue
a = self.alpha
self.set(r, g, b, a)
end
end
#==============================================================================#
# ** Modulo SheolShade
#==============================================================================#
module SheolShade
module MiniMap
#Inicio da configuração#
TileSize = 8
MapOffset = -4
PlayerColor = Color.new(255,0,0).invert
ObjectColor = {"npc" => Color.new(0,255,0).invert,
"door" => Color.new(0,0,255).invert,
"chest" => Color.new(100,100,100).invert}
BorderColor = Color.new(0,0,0).invert
ObjectLayerOpacity = 255
MiniMapCorner = 2
MapColor = Color.new(200,150,150).invert
MapBorderColor = Color.new(50,50,50).invert
BorderName = "Border"
BackTextureName = "OldPaper"
ClearOutsideArea = false
ClearOutsideColor = Color.new(0,0,0).invert
OutlineMapArea = true
OutlineMapColor = Color.new(0,0,0).invert
EnableSwitchId = 1
#Fim da configuração#
MiniMapCoords = {1 => [0,0,112,112],
2 => [Graphics.width - 112,0,112,112],
3 => [0,Graphics.height - 112,112,112],
4 => [Graphics.width - 112,Graphics.height - 112,112,112]}
end
end
#==============================================================================#
# ** Classe Mini Map
#==============================================================================#
class MiniMap
include SheolShade::MiniMap
def initialize(viewport)
@viewport = viewport
refresh
end
def refresh
@backmask = Sprite.new(@viewport)
@backmask.bitmap = Cache::system("Back_96")
@backmask.x = @backmask.y = 8
@backtile = Sprite.new(@viewport)
@backtile.blend_type = 2
@backtile.z = 1
@backtile.x = @backtile.y = -100
@map = Sprite.new(@viewport)
@map.z = 2
@map.blend_type = 2
@object_layer = Sprite.new(@viewport)
@object_layer.z = 3
@object_layer.blend_type = 2
@object_layer.bitmap = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize + 112)
@object_layer.opacity = ObjectLayerOpacity
@border = Sprite.new(@viewport)
@border.bitmap = Cache::system(BorderName)
@border.z = 4
@border.opacity = 255
@mask = Cache::system("Mask")
draw_back
draw_map
end
def visible
$game_switches[EnableSwitchId]
end
def draw_map
front = make_map_bitmap(MapColor)
border = make_map_bitmap(MapBorderColor)
result = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize+ 112)
result.blt(-1, 0, border, border.rect)
result.blt(1, 0, border, border.rect)
result.blt(0, -1, border, border.rect)
result.blt(0, 1, border, border.rect)
result.blt(0, 0, front, front.rect)
@mapbitmap = result
end
def draw_back
bitmap = Bitmap.new($game_map.width*TileSize+112,
$game_map.height*TileSize+112)
bit = Cache::system(BackTextureName)
bitmap.stretch_blt(bitmap.rect, bit, bit.rect)
if ClearOutsideArea
bitmap.fill_rect(0,0,bitmap.width, 56, ClearOutsideColor)
bitmap.fill_rect(0,0,56, bitmap.height, ClearOutsideColor)
bitmap.fill_rect(0,bitmap.height-56,bitmap.width, 56, ClearOutsideColor)
bitmap.fill_rect(bitmap.width-56,0,56, bitmap.height, ClearOutsideColor)
elsif OutlineMapArea
bitmap.fill_rect(56,55,bitmap.width-112,1,OutlineMapColor)
bitmap.fill_rect(55,56,1,bitmap.height-112,OutlineMapColor)
bitmap.fill_rect(bitmap.width-56,55,1,bitmap.height-112,OutlineMapColor)
bitmap.fill_rect(56,bitmap.height-56,bitmap.width-112,1,OutlineMapColor)
end
@backtilebitmap = bitmap
end
def draw_object_layer
for event in $game_map.events.keys
if $game_map.events[event].list.size >= 0
for item in $game_map.events[event].list
if item.code == 108 or item.code == 408
if ObjectColor.has_key?(item.parameters[0])
draw_object($game_map.events[event].real_x*TileSize+56,
$game_map.events[event].real_y*TileSize+56,
ObjectColor[item.parameters[0]])
end
end
end
end
end
draw_object($game_player.real_x*TileSize+56, $game_player.real_y*TileSize+56, PlayerColor)
end
def draw_object(x, y, color)
@object_layer.bitmap.fill_rect(x, y, TileSize, TileSize, BorderColor)
@object_layer.bitmap.fill_rect(x+1, y+1, TileSize-2, TileSize-2, color)
@object_layer.bitmap.clear_rect(x,y,1,1)
@object_layer.bitmap.clear_rect(x,y+TileSize-1,1,1)
@object_layer.bitmap.clear_rect(x+TileSize-1,y,1,1)
@object_layer.bitmap.clear_rect(x+TileSize-1,y+TileSize-1,1,1)
end
def make_map_bitmap(color)
bitmap = Bitmap.new($game_map.width*TileSize + 112,
$game_map.height*TileSize + 112)
for x in 0..$game_map.width - 1
for y in 0..$game_map.height - 1
if $game_map.airship_land_ok?(x, y)
next
end
bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
end
end
bitmap
end
def update_object_layer
@object_layer.bitmap.clear
draw_object_layer
end
def dispose
@backmask.dispose
@backtile.dispose
@map.dispose
@object_layer.dispose
@border.dispose
end
def update
@backmask.visible = visible
@backtile.visible = visible
@map.visible = visible
@object_layer.visible = visible
@border.visible = visible
if visible
@map.bitmap = @mapbitmap.dup
@backtile.bitmap = @backtilebitmap.dup
sx = $game_player.real_x * (TileSize * -1) + MapOffset
sy = $game_player.real_y * (TileSize * -1) + MapOffset
update_object_layer
@map.x = @backtile.x = @object_layer.x = sx
@map.y = @backtile.y = @object_layer.y = sy
@backtile.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
@map.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
@object_layer.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
end
end
end
#==============================================================================#
# ** Classe Spriteset_Map
#==============================================================================#
class Spriteset_Map
alias old_init initialize
alias old_updt update
alias old_disp dispose
include SheolShade::MiniMap
def initialize
viewport = Viewport.new(Graphics.width - 112,0,112,112)
viewport.rect.set(MiniMapCoords[MiniMapCorner][0],
MiniMapCoords[MiniMapCorner][1],
MiniMapCoords[MiniMapCorner][2],
MiniMapCoords[MiniMapCorner][3])
viewport.z = 500
@minimapa = MiniMap.new(viewport)
old_init
end
def dispose
old_disp
@minimapa.dispose
end
def update
old_updt
@minimapa.update
end
end
#==============================================================================#
# ** Fim do Script
#==============================================================================#
And the error is: "Unable to find file: Graphic/System/Back_96"
I've "downloaded" it HERE
Can someone help me? (I added the scripts in "Script editor-->Materials")
And teach me how to add scripts and how to create scripts?
Thanks to all!

