Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Dragon324

Same joy old scripting problems again

Question

Here is a piece of a side view battle system I'm having problems with.
[spoiler]#==============================================================================
# Sideview Battle System Version 2.2xp
#==============================================================================
#==============================================================================
# ■ Atoa Module
#==============================================================================
$atoa_script = {} if $atoa_script.nil?
$atoa_script["SBS Tankentai"] = true

#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
attr_accessor :spriteset
#--------------------------------------------------------------------------
def main
fix_weapon_init
start
create_viewport
process_transition
update_battle
terminate
fix_weapon_end
end
#--------------------------------------------------------------------------
def start
@battle_start = true
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
$game_system.battle_interpreter.setup(nil, 0)
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
for enemy in $game_troop.enemies
enemy.true_immortal = enemy.immortal
end
end
#--------------------------------------------------------------------------
def create_viewport
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@active_battler_window = Window_NameCommand.new(@active_battler, 240, 64)
@active_battler_window.visible = false
@status_window = Window_BattleStatus.new
[b] @message_window = Window_Message.new[/b] (Here is the Trouble maker I get Argument Error occurred wrong number of arguments( 0 for 1))
@spriteset = Spriteset_Battle.new
@wait_count, @escape_ratio = 0, 50
end
#--------------------------------------------------------------------------
def process_transition
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
end
start_phase1
end
#--------------------------------------------------------------------------
def update_battle
loop do
Graphics.update
Input.update
update
break if $scene != self
end
end
#--------------------------------------------------------------------------
def terminate
$game_map.refresh
Graphics.freeze
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
@skill_window.dispose if @skill_window != nil
@item_window.dispose if @item_window != nil
@result_window.dispose if @result_window != nil
@spriteset.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
$scene = nil if $BTEST and not $scene.is_a?(Scene_Gameover)
end
#--------------------------------------------------------------------------
def fix_weapon_init
for member in $game_party.actors
if member.weapons[0] == nil and member.weapons[1] != nil
weapon_to_equip = member.armor1_id
member.equip(1, 0)
member.equip(0, weapon_to_equip)
member.two_swords_change = true
end
end
end
#--------------------------------------------------------------------------
def fix_weapon_end
for member in $game_party.actors
if member.two_swords_change
weapon_to_re_equip = member.weapon_id
member.equip(0, 0)
member.equip(1, weapon_to_re_equip)
member.two_swords_change = false
end
end
end
#--------------------------------------------------------------------------
def update_basic
Graphics.update
Input.update
$game_system.update
$game_screen.update
@spriteset.update
end
#--------------------------------------------------------------------------
def update_effects
for battler in $game_party.actors + $game_troop.enemies
if battler.exist?
battler_sprite = @spriteset.actor_sprites[battler.index] if battler.actor?
battler_sprite = @spriteset.enemy_sprites[battler.index] if battler.is_a?(Game_Enemy)
battler_sprite.effects_update
end
end
end
#--------------------------------------------------------------------------
def wait(duration)
for i in 0...duration
update_basic
end
end
#--------------------------------------------------------------------------
def pop_help(obj)
@help_window.set_text(obj, 1)
loop do
update_basic
break @help_window.visible = false if Input.trigger?(Input::C)
end
end
#--------------------------------------------------------------------------
alias start_phase1_n01 start_phase1
def start_phase1
for member in $game_party.actors + $game_troop.enemies
member.dead_anim = member.dead? ? true : false
@spriteset.set_stand_by_action(member.actor?, member.index) unless member.dead_anim
end
start_phase1_n01
$clear_enemies_actions = false
if $preemptive
pop_help(PREEMPTIVE_ALERT)
$clear_enemies_actions = true
end
@battle_start = false unless $back_attack
return unless $back_attack
pop_help(BACK_ATTACK_ALERT)
@battle_start = false
$game_party.clear_actions
start_phase4
end
#--------------------------------------------------------------------------
alias start_phase4_n01 start_phase4
def start_phase4
start_phase4_n01
@active_battler_window.visible = false
if $clear_enemies_actions
$clear_enemies_actions = false
$game_troop.clear_actions
end
end
#--------------------------------------------------------------------------
def judge
if $game_party.all_dead? or $game_party.actors.size == 0
if $game_temp.battle_can_lose
$game_system.bgm_play($game_temp.map_bgm)
battle_end(2)
return true
end
$game_temp.gameover = true
return true
end
for enemy in $game_troop.enemies
return false if enemy.exist?
end
process_victory
return true
end
#--------------------------------------------------------------------------
def update_phase2_escape
enemies_agi = enemies_number = 0
for enemy in $game_troop.enemies
if enemy.exist?
enemies_agi += enemy.agi
enemies_number += 1
end
end
enemies_agi /= [enemies_number, 1].max
actors_agi = actors_number = 0
for actor in $game_party.actors
if actor.exist?
actors_agi += actor.agi
actors_number += 1
end
end
actors_agi /= [actors_number, 1].max
@success = rand(100) < @escape_ratio * actors_agi / enemies_agi
@party_command_window.visible = false
@party_command_window.active = false
wait(2)
if @success
$game_system.se_play($data_system.escape_se)
for actor in $game_party.actors
unless actor.dead?
@spriteset.set_action(true, actor.index, actor.run_success)
end
end
pop_help(ESCAPE_SUCCESS)
$game_system.bgm_play($game_temp.map_bgm)
battle_end(1)
else
@escape_ratio += 5
$game_party.clear_actions
$game_system.se_play($data_system.escape_se)
for actor in $game_party.actors
unless actor.dead?
@spriteset.set_action(true, actor.index,actor.run_ng)
end
end
pop_help(ESCAPE_FAIL)
start_phase4
end
end
#--------------------------------------------------------------------------
def process_victory
for enemy in $game_troop.enemies
break boss_wait = true if enemy.collapse_type == 3
end
wait(440) if boss_wait
wait(WIN_WAIT) unless boss_wait
for actor in $game_party.actors
unless actor.restriction == 4
@spriteset.set_action(true, actor.index,actor.win)
end
end
start_phase5
end
#--------------------------------------------------------------------------
def start_phase5
@phase = 5
$game_system.me_play($game_system.battle_end_me)
$game_system.bgm_play($game_temp.map_bgm)
treasures = []
for enemy in $game_troop.enemies
gold = gold.nil? ? enemy.gold : gold + enemy.gold
treasures << treasure_drop(enemy) unless enemy.hidden
end
exp = gain_exp
treasures = treasures.compact
$game_party.gain_gold(gold)
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
@result_window = Window_BattleResult.new(exp, gold, treasures)
@result_window.add_multi_drops if $atoa_script['Multi Drop']
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
def treasure_drop(enemy)
if rand(100) < enemy.treasure_prob
treasure = $data_items[enemy.item_id] if enemy.item_id > 0
treasure = $data_weapons[enemy.weapon_id] if enemy.weapon_id > 0
treasure = $data_armors[enemy.armor_id] if enemy.armor_id > 0
end
return treasure
end
#--------------------------------------------------------------------------
def gain_exp
exp = exp_gained
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
return exp
end
#--------------------------------------------------------------------------
def exp_gained
for enemy in $game_troop.enemies
exp = exp.nil? ? enemy.exp : exp + enemy.exp
end
if EXP_SHARE
actor_number = 0
for actor in $game_party.actors
actor_number += 1 unless actor.cant_get_exp?
end
exp = exp / [actor_number, 1].max
end
return exp
end
#--------------------------------------------------------------------------
alias acbs_update_phase5 update_phase5
def update_phase5
@result_window.update
acbs_update_phase5
end
#--------------------------------------------------------------------------
alias phase3_next_actor_n01 phase3_next_actor
def phase3_next_actor
if @active_battler != nil && @active_battler.inputable?
@spriteset.set_action(true, @actor_index, @active_battler.command_a)
end
@wait_count = 32 if @actor_index == $game_party.actors.size-1
phase3_next_actor_n01
if @active_battler != nil && @active_battler.inputable?
@spriteset.set_action(true, @actor_index,@active_battler.command_b)
end
end
#--------------------------------------------------------------------------
alias phase3_prior_actor_n01 phase3_prior_actor
def phase3_prior_actor
if @active_battler != nil && @active_battler.inputable?
@active_battler.current_action.clear
@spriteset.set_action(true, @actor_index,@active_battler.command_a)
end
phase3_prior_actor_n01
if @active_battler != nil && @active_battler.inputable?
@active_battler.current_action.clear
@spriteset.set_action(true, @actor_index,@active_battler.command_b)
end
end
#--------------------------------------------------------------------------
alias start_phase2_n01 start_phase2
def start_phase2
@active_battler_window.visible = false
start_phase2_n01
end
#--------------------------------------------------------------------------
alias phase3_setup_command_window_n01 phase3_setup_command_window
def phase3_setup_command_window
phase3_setup_command_window_n01
@actor_command_window.x = COMMAND_WINDOW_POSITION[0]
@actor_command_window.y = COMMAND_WINDOW_POSITION[1]
@actor_command_window.z = 2000
@actor_command_window.index = 0
@actor_command_window.back_opacity = COMMAND_OPACITY
@active_battler_window.refresh(@active_battler)
@active_battler_window.visible = true if BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
alias acbs_update_phase3_basic_command_scenebattle update_phase3_basic_command
def update_phase3_basic_command
if Input.trigger?(Input::C)
case @actor_command_window.commands[@actor_command_window.index]
when $data_system.words.attack
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
@actor_command_window.active = false
@actor_command_window.visible = false
start_enemy_select
return
when $data_system.words.item
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 2
start_item_select
return
when $data_system.words.guard
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
phase3_next_actor
return
end
end
acbs_update_phase3_basic_command_scenebattle
end
#--------------------------------------------------------------------------
def now_action(battler = @active_battler)
return if battler.nil?
@now_action = nil
case battler.current_action.kind
when 0
@now_action = $data_weapons[battler.weapon_id] if battler.current_action.basic == 0
when 1
@now_action = $data_skills[battler.current_action.skill_id]
when 2
@now_action = $data_items[battler.current_action.item_id]
end
end
#--------------------------------------------------------------------------
def start_enemy_select
now_action
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
@enemy_arrow.help_window = @help_window
@actor_command_window.active = false
@actor_command_window.visible = false
@active_battler_window.visible = false
@status_window.visible = true
end
#--------------------------------------------------------------------------
alias start_actor_select_n01 start_actor_select
def start_actor_select
now_action
start_actor_select_n01
@status_window.visible = true
@active_battler_window.visible = false
@actor_arrow.input_right if @now_action.extension.include?("OTHERS")
end
#--------------------------------------------------------------------------
alias update_phase3_actor_select_n01 update_phase3_actor_select
def update_phase3_actor_select
@actor_arrow.input_update_target if @now_action.extension.include?("OTHERS") and @actor_arrow.index == @active_battler.index
update_phase3_actor_select_n01
end
#--------------------------------------------------------------------------
alias update_phase3_n01 update_phase3
def update_phase3
if @enemy_arrow_all != nil
update_phase3_select_all_enemies
return
elsif @actor_arrow_all != nil
update_phase3_select_all_actors
return
elsif @battler_arrow_all != nil
update_phase3_select_all_battlers
return
end
update_phase3_n01
end
#--------------------------------------------------------------------------
alias update_phase3_skill_select_n01 update_phase3_skill_select
def update_phase3_skill_select
@status_window.visible = false if HIDE_WINDOW
if Input.trigger?(Input::C)
@skill = @skill_window.skill
if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
$game_system.se_play($data_system.buzzer_se)
return
end
@active_battler.current_action.skill_id = @skill.id
@skill_window.visible = false
if @skill.extension.include?("TARGETALL")
$game_system.se_play($data_system.decision_se)
start_select_all_battlers
return
end
if (@skill.extension.include?("RANDOMTARGET") and @skill.scope <= 2) or @skill.scope == 2
$game_system.se_play($data_system.decision_se)
start_select_all_enemies
return
end
if (@skill.extension.include?("RANDOMTARGET") and @skill.scope > 2) or @skill.scope == 4
$game_system.se_play($data_system.decision_se)
start_select_all_actors
return
end
end
update_phase3_skill_select_n01
end
#--------------------------------------------------------------------------
alias update_phase3_item_select_n01 update_phase3_item_select
def update_phase3_item_select
@status_window.visible = false if HIDE_WINDOW
if Input.trigger?(Input::C)
@item = @item_window.item
if @item == nil or not $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
@active_battler.current_action.item_id = @item.id
@item_window.visible = false
if @item.extension.include?("TARGETALL")
$game_system.se_play($data_system.decision_se)
start_select_all_battlers
return
end
if @item.extension.include?("RANDOMTARGET") and @item.scope <= 2 or @item.scope == 2
$game_system.se_play($data_system.decision_se)
start_select_all_enemies
return
end
if (@item.extension.include?("RANDOMTARGET") and @item.scope > 2) or @item.scope == 4
$game_system.se_play($data_system.decision_se)
start_select_all_actors
return
end
end
update_phase3_item_select_n01
end
#--------------------------------------------------------------------------
def update_phase3_select_all_enemies
@enemy_arrow_all.update_multi_arrow
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
end_select_all_enemies
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @skill_window != nil
end_skill_select
end
if @item_window != nil
end_item_select
end
end_select_all_enemies
phase3_next_actor
return
end
end
#--------------------------------------------------------------------------
def update_phase3_select_all_actors
@actor_arrow_all.update_multi_arrow
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
end_select_all_actors
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @skill_window != nil
end_skill_select
end
if @item_window != nil
end_item_select
end
end_select_all_actors
phase3_next_actor
return
end
end
#--------------------------------------------------------------------------
def update_phase3_select_all_battlers
@battler_arrow_all.update_multi_arrow
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
end_select_all_battlers
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @skill_window != nil
end_skill_select
end
if @item_window != nil
end_item_select
end
end_select_all_battlers
phase3_next_actor
return
end
end
#--------------------------------------------------------------------------
def start_select_all_enemies
now_action
@status_window.visible = true
@active_battler_window.visible = false
@enemy_arrow_all = Arrow_Enemy_All.new(@spriteset.viewport2)
end
#--------------------------------------------------------------------------
def start_select_all_actors
now_action
@status_window.visible = true
@active_battler_window.visible = false
@actor_arrow_all = Arrow_Actor_All.new(@spriteset.viewport2)
end
#--------------------------------------------------------------------------
def start_select_all_battlers
now_action
@status_window.visible = true
@active_battler_window.visible = false
@battler_arrow_all = Arrow_Battler_All.new(@spriteset.viewport2)
end
#--------------------------------------------------------------------------
def end_select_all_actors
@actor_arrow_all.dispose_multi_arrow
@actor_arrow_all = nil
@active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
def end_select_all_enemies
@enemy_arrow_all.dispose_multi_arrow
@enemy_arrow_all = nil
@active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
def end_select_all_battlers
@battler_arrow_all.dispose_multi_arrow
@battler_arrow_all = nil
@active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
alias end_enemy_select_n01 end_enemy_select
def end_enemy_select
end_enemy_select_n01
@active_battler_window.visible = true if @actor_command_window.index == 0 and BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
alias start_skill_select_n01 start_skill_select
def start_skill_select
start_skill_select_n01
@status_window.visible = false if HIDE_WINDOW
@active_battler_window.visible = false
end
#--------------------------------------------------------------------------
alias end_skill_select_n01 end_skill_select
def end_skill_select
end_skill_select_n01
@status_window.visible = true
@active_battler_window.visible = true if BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
alias start_item_select_n01 start_item_select
def start_item_select
start_item_select_n01
@status_window.visible = false if HIDE_WINDOW
@active_battler_window.visible = false
end
#--------------------------------------------------------------------------
alias end_item_select_n01 end_item_select
def end_item_select
end_item_select_n01
@status_window.visible = true
@active_battler_window.visible = true if BATTLER_NAME_WINDOW
end
#--------------------------------------------------------------------------
alias make_action_orders_n01 make_action_orders
def make_action_orders
make_action_orders_n01
for battler in @action_battlers
skill_id = battler.current_action.skill_id
item_id = battler.current_action.item_id
next if battler.current_action.kind == 0
extension = $data_skills[skill_id].extension if skill_id != 0
extension = $data_items[item_id].extension if item_id != 0
battler.current_action.speed = 9999 if extension.include?("FAST")
battler.current_action.speed = -1 if extension.include?("SLOW")
end
@action_battlers.sort! {|a,b|
b.current_action.speed - a.current_action.speed }
for enemy in $game_troop.enemies
if enemy.action_time[0] != 1
action_time = 0
for i in 1...enemy.action_time[0]
action_time += 1 if rand(100) < enemy.action_time[1]
end
enemy.act_time = action_time
action_time.times do
enemy_order_time(enemy)
action_time -= 1
break if action_time == 0
end
enemy.adj_speed = nil
end
end
end
#--------------------------------------------------------------------------
def enemy_order_time(enemy)
enemy.make_action_speed2(enemy.action_time[2])
select_time = 0
for member in @action_battlers
select_time += 1
break @action_battlers.push(enemy) if member.current_action.speed < enemy.adj_speed
break @action_battlers.push(enemy) if select_time == @action_battlers.size
end
end
#--------------------------------------------------------------------------
def update_phase4_step1
return if @spriteset.effect?
return @wait_count -= 1 if @wait_count > 0
@help_window.visible = false
return if judge
if $game_temp.forcing_battler == nil
setup_battle_event
return if $game_system.battle_interpreter.running?
end
if $game_temp.forcing_battler != nil
@action_battlers.delete($game_temp.forcing_battler)
@action_battlers.unshift($game_temp.forcing_battler)
end
if @action_battlers.size == 0
turn_ending
start_phase2
return
end
@animation1_id = 0
@animation2_id = 0
@common_event_id = 0
@active_battler = @action_battlers.shift
return if @active_battler.index == nil
@active_battler.remove_states_auto
@status_window.refresh
@phase4_step = 2
end
#--------------------------------------------------------------------------
def turn_ending
for member in $game_party.actors + $game_troop.enemies
member.current_action.clear
next unless member.exist?
member.slip_damage = false
actor = member.actor?
for state in member.battler_states
member.remove_state(state.id) if state.extension.include?("ZEROTURNLIFT")
end
damage = 0
for state in member.battler_states
next unless state.extension.include?("SLIPDAMAGE")
for ext in state.slip_extension
if ext[0] == "hp"
base_damage = ext[1] + member.maxhp * ext[2] / 100
damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
slip_pop = ext[3]
slip_dead = ext[4]
slip_damage_flug = true
member.slip_damage = true
end
end
end
if member.slip_damage && member.exist? && !slip_damage_flug
damage += member.apply_variance(member.maxhp / 10, 10)
slip_dead = false
slip_pop = true
slip_damage_flug = true
member.slip_damage = true
end
damage = member.hp - 1 if damage >= member.hp && slip_dead = false
member.hp -= damage
member.damage = damage if damage > 0
member.perform_collapse if member.dead? && member.slip_damage
@spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
@spriteset.set_stand_by_action(actor, member.index) if member.hp <= 0 and not member.dead_anim
member.dead_anim = member.dead? ? true : false
end
@status_window.refresh
wait(DMG_DURATION / 2) if slip_damage_flug
slip_damage_flug = false
for member in $game_party.actors + $game_troop.enemies
next unless member.exist?
actor = member.actor?
damage = 0
for state in member.battler_states
next unless state.extension.include?("SLIPDAMAGE")
for ext in state.slip_extension
if ext[0] == "mp"
base_damage = ext[1] + member.maxsp * ext[2] / 100
damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
slip_pop = ext[3]
slip_damage_flug = true
end
end
member.sp_damage = true
member.sp -= damage
member.damage = damage if damage > 0
@spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
end
end
@status_window.refresh
wait(DMG_DURATION / 2) if slip_damage_flug
for member in $game_party.actors + $game_troop.enemies
next unless member.exist?
actor = member.actor?
damage = 0
for state in member.battler_states
next unless state.extension.include?("REGENERATION")
for ext in state.slip_extension
if ext[0] == "hp"
base_damage = ext[1] + member.maxhp * ext[2] / 100
damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
slip_pop = ext[3]
slip_damage_flug = true
end
end
member.hp -= damage
member.damage = damage if damage < 0
@spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
end
end
@status_window.refresh
wait(DMG_DURATION / 2) if slip_damage_flug
for member in $game_party.actors + $game_troop.enemies
next unless member.exist?
actor = member.actor?
damage = 0
for state in member.battler_states
next unless state.extension.include?("REGENERATION")
for ext in state.slip_extension
if ext[0] == "mp"
base_damage = ext[1] + member.maxhp * ext[2] / 100
damage += base_damage + base_damage * (rand(5) - rand(5)) / 100
slip_pop = ext[3]
slip_damage_flug = true
end
end
member.sp_damage = true
member.sp -= damage
member.damage = damage if damage < 0
@spriteset.set_damage_pop(actor, member.index, damage) if slip_pop
end
end
@status_window.refresh
wait(DMG_DURATION / 2) if slip_damage_flug
end
#--------------------------------------------------------------------------
alias update_phase4_step2_n01 update_phase4_step2
def update_phase4_step2
for member in $game_party.actors + $game_troop.enemies
member.dead_anim = member.dead? ? true : false
end
if @active_battler.current_action.kind != 0
obj = $data_skills[@active_battler.current_action.skill_id] if @active_battler.current_action.kind == 1
obj = $data_items[@active_battler.current_action.item_id] if @active_battler.current_action.kind == 2
@active_battler.white_flash = false if obj != nil &&obj.extension.include?("NOFLASH")
end
@active_battler.active = true
update_phase4_step2_n01
if @active_battler != nil && @active_battler.derivation != 0
@active_battler.current_action.kind = 1
@active_battler.current_action.skill_id = @active_battler.derivation
@action_battlers.unshift(@active_battler)
end
if @active_battler != nil && !@active_battler.actor? && @active_battler.act_time != 0
@active_battler.make_action
@active_battler.act_time -= 1
end
update_phase4_step6
end
#--------------------------------------------------------------------------
alias update_phase4_step6_n01 update_phase4_step6
def update_phase4_step6
update_phase4_step6_n01
@active_battler.active = false if @active_battler != nil
end
#--------------------------------------------------------------------------
def make_basic_action_result
if @active_battler.current_action.basic == 0
execute_action_attack
return
end
if @active_battler.current_action.basic == 1
@help_window.set_text("#{@active_battler.name} defends", 1)
@help_window.visible = true
@active_battler.active = false
@active_battler.defense_pose = true
@spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
wait(45)
@help_window.visible = false
return
end
if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2
@spriteset.set_action(false, @active_battler.index, @active_battler.run_success)
$game_system.se_play($data_system.escape_se)
@active_battler.escape
pop_help("#{@active_battler.name} escaped...")
return
end
if @active_battler.current_action.basic == 3
@active_battler.active = false
$game_temp.forcing_battler = nil
@phase4_step = 1
return
end
end
#--------------------------------------------------------------------------
def execute_action_attack
if @active_battler.actor?
if @active_battler.weapon_id == 0
action = @active_battler.non_weapon
immortaling
else
action = $data_weapons[@active_battler.weapon_id].base_action
if $data_weapons[@active_battler.weapon_id].plus_state_set.include?(1)
for member in $game_party.actors + $game_troop.enemies
next if member.immortal
next if member.dead?
member.dying = true
end
else
immortaling
end
end
else
if @active_battler.weapon == 0
action = @active_battler.base_action
immortaling
else
action = $data_weapons[@active_battler.weapon].base_action
if $data_weapons[@active_battler.weapon].plus_state_set.include?(1)
for member in $game_party.actors + $game_troop.enemies
next if member.immortal
next if member.dead?
member.dying = true
end
else
immortaling
end
end
end
target_decision
@spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
playing_action
end
#--------------------------------------------------------------------------
def make_attack_targets
@target_battlers = []
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
if @active_battler.actor?
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
@target_battlers = [target]
return @target_battlers
end
#--------------------------------------------------------------------------
def make_skill_action_result
skill = $data_skills[@active_battler.current_action.skill_id]
if skill.plus_state_set.include?(1)
for member in $game_party.actors + $game_troop.enemies
next if member.immortal
next if member.dead?
member.dying = true
end
else
immortaling
end
return unless @active_battler.skill_can_use?(skill.id)
target_decision(skill)
@active_battler.consum_skill_cost(skill)
@status_window.refresh
@spriteset.set_action(@active_battler.actor?, @active_battler.index, skill.base_action)
@help_window.set_text(skill.name, 1) unless skill.extension.include?("HELPHIDE")
playing_action
@common_event_id = skill.common_event_id
end
#--------------------------------------------------------------------------
def make_item_action_result
item = $data_items[@active_battler.current_action.item_id]
unless $game_party.item_can_use?(item.id)
@phase4_step = 1
return
end
if @item.consumable
$game_party.lose_item(item.id, 1)
end
immortaling
target_decision(item)
@spriteset.set_action(@active_battler.actor?, @active_battler.index, item.base_action)
@help_window.set_text(item.name, 1) unless item.extension.include?("HELPHIDE")
playing_action
@common_event_id = item.common_event_id
end
#--------------------------------------------------------------------------
def target_decision(obj = nil)
if obj != nil
set_target_battlers(obj.scope)
if obj.extension.include?("TARGETALL")
@target_battlers = []
if obj.scope != 5 or obj.scope != 6
for target in $game_troop.enemies + $game_party.actors
@target_battlers.push(target) if target.exist?
end
else
for target in $game_troop.enemies + $game_party.actors
@target_battlers.push(target) if target != nil && target.hp0?
end
end
end
@target_battlers.delete(@active_battler) if obj.extension.include?("OTHERS")
if obj.extension.include?("RANDOMTARGET")
randum_targets = @target_battlers.dup
@target_battlers = [randum_targets[rand(randum_targets.size)]]
end
else
@target_battlers = make_attack_targets
end
if @target_battlers.size == 0
action = @active_battler.recover_action
@spriteset.set_action(@active_battler.actor?, @active_battler.index, action)
end
@spriteset.set_target(@active_battler.actor?, @active_battler.index, @target_battlers)
end
#--------------------------------------------------------------------------
def playing_action
loop do
update_basic
update_effects
action = @active_battler.play
next if action == 0
@active_battler.play = 0
if action[0] == "Individual"
individual
elsif action == "Can Collapse"
unimmortaling
elsif action == "Cancel Action"
break action_end
elsif action == "End"
break action_end
elsif action[0] == "OBJ_ANIM"
damage_action(action[1])
end
end
end
#--------------------------------------------------------------------------
def individual
@individual_target = @target_battlers
@stand_by_target = @target_battlers.dup
end
#--------------------------------------------------------------------------
def immortaling
for member in $game_party.actors + $game_troop.enemies
member.immortal = true unless member.dead?
end
end
#--------------------------------------------------------------------------
def unimmortaling
return if @active_battler.individual
for member in $game_party.actors + $game_troop.enemies
member.immortal = false
member.add_state(1) if member.dead?
if member.dead? and not member.dead_anim
member.perform_collapse
@spriteset.set_stand_by_action(member.actor?, member.index)
end
member.dead_anim = member.dead? ? true : false
next unless member.dead?
resurrection(member)
end
update_basic
@status_window.refresh
end
#--------------------------------------------------------------------------
def resurrection(target)
for state in target.battler_states
for ext in state.extension
name = ext.split('')
next unless name[0] == "A"
wait(25)
name = name.join
name.slice!("AUTOLIFE/")
target.hp = target.maxhp * name.to_i / 100
target.remove_state(1)
target.remove_state(state.id)
target.animation_id = RESURRECTION
target.animation_hit = true
target.anime_mirror = true if $back_attack
@status_window.refresh
wait($data_animations[RESURRECTION].frame_max * 2)
end
end
end
#--------------------------------------------------------------------------
def magic_reflection(target, obj)
return if obj != nil and $data_skills[@active_battler.current_action.skill_id].int_f == 0
for state in target.battler_states
for ext in state.extension
name = ext.split('')
next unless name[0] == "M"
if name[3] == "R"
name = name.join
name.slice!("MAGREFLECT/")
target.animation_id = name.to_i
target.animation_hit = true
target.anime_mirror = true if $back_attack
@reflection = true
else
name = name.join
name.slice!("MAGNULL/")
target.animation_id = name.to_i
target.animation_hit = true
target.anime_mirror = true if $back_attack
@invalid = true
end
end
end
end
#--------------------------------------------------------------------------
def physics_reflection(target, obj)
return if obj != nil && $data_skills[@active_battler.current_action.skill_id].str_f == 0
for state in target.battler_states
for ext in state.extension
name = ext.split('')
next unless name[0] == "P"
if name[3] == "R"
name = name.join
name.slice!("PHYREFLECT/")
target.animation_id = name.to_i
target.animation_hit = true
target.anime_mirror = true if $back_attack
@reflection = true
else
name = name.join
name.slice!("PHYNULL/")
target.animation_id = name.to_i
target.animation_hit = true
target.anime_mirror = true if $back_attack
@invalid = true
end
end
end
end
#--------------------------------------------------------------------------
def absorb_cost(target, obj)
for state in target.battler_states
if state.extension.include?("COSTABSORB")
cost = @active_battler.calc_sp_cost(@active_battler, obj)
return target.hp += cost if obj.extension.include?("HPCONSUME")
return target.mp += cost
end
end
end
#--------------------------------------------------------------------------
def absorb_attack(obj, target, index, actor)
for ext in obj.extension
return if target.evaded or target.missed or target.damage == 0 or target.damage == nil
name = ext.split('')
next unless name[3] == "G" and name[1] == "D"
name = name.join
name.slice!("%DMGABSORB/")
kind = "hp" unless target.sp_damage
kind = "sp" if target.sp_damage
absorb = target.damage * name.to_i / 100
@wide_attack = true if obj.scope == 2 or obj.scope == 4 or obj.scope == 6 or obj.extension.include?("TARGETALL")
if @wide_attack && @absorb == nil && @target_battlers.size != 1
@absorb = absorb
@absorb_target_size = @target_battlers.size - 2
elsif @absorb != nil && @absorb_target_size > 0
@absorb += absorb
@absorb_target_size -= 1
elsif @absorb != nil
@absorb += absorb
absorb_action = ["absorb", nil, kind, @absorb]
@spriteset.set_damage_action(actor, index, absorb_action)
@absorb = nil
@absorb_target_size = nil
@active_battler.perform_collapse
else
absorb_action = ["absorb", nil, kind, absorb]
@spriteset.set_damage_action(actor, index, absorb_action)
@active_battler.perform_collapse
end
end
end
#--------------------------------------------------------------------------
def action_end
@individual_target = nil
@help_window.visible = false if @help_window != nil && @help_window.visible
@active_battler.active = false
unimmortaling
for member in $game_troop.enemies
member.non_dead = false if member.non_dead
end
if @active_battler.reflex != nil
if @active_battler.current_action.kind == 1
obj = $data_skills[@active_battler.current_action.skill_id]
@active_battler.perfect_skill_effect(@active_battler, obj)
elsif @active_battler.current_action.kind == 2
obj = $data_items[@active_battler.current_action.item_id]
@active_battler.item_effect(@active_battler, obj)
else
@active_battler.perfect_attack_effect(@active_battler)
end
pop_damage(@active_battler, obj, @active_battler.reflex)
@active_battler.perform_collapse
@active_battler.reflex = nil
wait(COLLAPSE_WAIT)
end
if @active_battler.derivation != 0
@active_battler.current_action.skill_id = @active_battler.derivation
@active_battler.current_action.kind = 1
@active_battler.derivation = 0
@action_battlers.unshift(@active_battler)
else
@spriteset.set_stand_by_action(@active_battler.actor?, @active_battler.index)
wait(ACTION_WAIT + 20)
end
end
#--------------------------------------------------------------------------
def damage_action(action)
@target_battlers = [@individual_target.shift] if @active_battler.individual
if @active_battler.current_action.kind == 1
obj = $data_skills[@active_battler.current_action.skill_id]
for target in @target_battlers
return if target == nil
if obj.scope == 5 or obj.scope == 6
return unless target.dead?
else
return if target.dead?
end
if target.hp == 0 && obj.scope != 5 && obj.scope != 6
target.perfect_skill_effect(@active_battler, obj)
elsif obj.extension.include?("NOEVADE")
target.perfect_skill_effect(@active_battler, obj)
else
magic_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
physics_reflection(target, obj) unless obj.extension.include?("IGNOREREFLECT")
target.skill_effect(@active_battler, obj) unless @reflection or @invalid
end
pop_damage(target, obj, action) unless @reflection or @invalid
absorb_cost(target, obj)
@active_battler.reflex = action if @reflection
@reflection = false
@invalid = false
end
elsif @active_battler.current_action.kind == 2
obj = $data_items[@active_battler.current_action.item_id]
for target in @target_battlers
return if target == nil
if obj.scope == 5 or obj.scope == 6
return unless target.dead?
else
return if target.dead?
end
target.revival = true if obj.scope == 5 or obj.scope == 6
target.item_effect(obj)
pop_damage(target, obj, action)
end
else
for target in @target_battlers
return if target == nil or target.dead?
physics_reflection(target, nil)
target.perfect_attack_effect(@active_battler) if target.hp <= 0
target.attack_effect(@active_battler) unless target.hp <= 0 unless @reflection or @invalid
pop_damage(target, obj, action) unless @reflection or @invalid
@active_battler.reflex = action if @reflection
@reflection = false
@invalid = false
end
end
return if obj == nil
target_decision(obj) if obj.extension.include?("RANDOMTARGET")
end
#--------------------------------------------------------------------------
def pop_damage(target, obj, action)
index = @active_battler.index
actor = @active_battler.actor?
if obj != nil && obj.extension.size != 0
absorb_attack(obj, target, index, actor)
action[2] = false if obj.extension.include?("NOOVERKILL")
end
@spriteset.set_damage_action(target.actor?, target.index, action)
@status_window.refresh
end
end

#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
alias call_battle_n01 call_battle
#--------------------------------------------------------------------------
def call_battle
$back_attack = $preemptive = false
preemptive_or_back_attack
call_battle_n01
end
#--------------------------------------------------------------------------
def preemptive_or_back_attack
enemies_agi = 0
for enemy in $game_troop.enemies
enemies_agi += enemy.agi
end
enemies_agi /= [$game_troop.enemies.size, 1].max
actors_agi = 0
for actor in $game_party.actors
actors_agi += actor.agi
end
actors_agi /= [$game_party.actors.size, 1].max
preemptive_plus
if actors_agi >= enemies_agi
percent_preemptive = PREEMPTIVE_RATE * ($preemptive_plus ? 3 : 1)
percent_back_attack = BACK_ATTACK_RATE / 2
else
percent_preemptive = (PREEMPTIVE_RATE / 2) * ($preemptive_plus ? 3 : 1)
percent_back_attack = BACK_ATTACK_RATE
end
if rand(100) < percent_preemptive
$preemptive = true
elsif rand(100) < percent_back_attack
$back_attack = true
end
special_back_attack_conditions
special_preemptive_conditions
$preemptive = false if $back_attack or !PREEMPTIVE
$back_attack = false if !BACK_ATTACK
end
#--------------------------------------------------------------------------
def special_back_attack_conditions
for i in 0...BACK_ATTACK_SWITCH.size
return $back_attack = true if $game_switches[BACK_ATTACK_SWITCH[i]]
end
for i in 0...NO_BACK_ATTACK_SWITCH.size
return $back_attack = false if $game_switches[NON_BACK_ATTACK_SWITCH[i]]
end
for actor in $game_party.actors
return $back_attack = false if NON_BACK_ATTACK_WEAPONS.include?(actor.weapon_id)
return $back_attack = false if NON_BACK_ATTACK_ARMOR1.include?(actor.armor1_id)
return $back_attack = false if NON_BACK_ATTACK_ARMOR2.include?(actor.armor2_id)
return $back_attack = false if NON_BACK_ATTACK_ARMOR3.include?(actor.armor3_id)
return $back_attack = false if NON_BACK_ATTACK_ARMOR4.include?(actor.armor4_id)
for i in 0...NON_BACK_ATTACK_SKILLS.size
return $back_attack = false if actor.skill_id_learn?(NON_BACK_ATTACK_SKILLS[i])
end
end
end
#--------------------------------------------------------------------------
def special_preemptive_conditions
for i in 0...PREEMPTIVE_SWITCH.size
return $preemptive = true if $game_switches[PREEMPTIVE_SWITCH[i]]
end
for i in 0...NO_PREEMPTIVE_SWITCH.size
return $preemptive = false if $game_switches[NON_PREEMPTIVE_SWITCH[i]]
end
end
#--------------------------------------------------------------------------
def preemptive_plus
$preemptive_plus = false
for actor in $game_party.actors
return $preemptive_plus = true if PREEMPTIVE_WEAPONS.include?(actor.weapon_id)
return $preemptive_plus = true if PREEMPTIVE_ARMOR1.include?(actor.armor1_id)
return $preemptive_plus = true if PREEMPTIVE_ARMOR2.include?(actor.armor2_id)
return $preemptive_plus = true if PREEMPTIVE_ARMOR3.include?(actor.armor3_id)
return $preemptive_plus = true if PREEMPTIVE_ARMOR4.include?(actor.armor4_id)
for i in 0...PREEMPTIVE_SKILLS.size
return $preemptive_plus = true if actor.skill_id_learn?(PREEMPTIVE_SKILLS[i])
end
end
end
end

#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
attr_reader :viewport1
attr_reader :viewport2
attr_accessor :actor_sprites
attr_accessor :enemy_sprites
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def initialize
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
@battleback_sprite = Sprite.new(@viewport1)
@battleback_sprite.mirror = true if $back_attack && BACK_ATTACK_BATTLE_BACK_MIRROR
@enemy_sprites = []
for enemy in $game_troop.enemies
@enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
end
@actor_sprites = []
for i in 0...$game_party.actors.size
@actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
end
@weather = RPG::Weather.new(@viewport1)
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i]))
end
@timer_sprite = Sprite_Timer.new
update
end
#--------------------------------------------------------------------------
def update
if $game_party.actors.size > @actor_sprites.size
for i in @actor_sprites.size...$game_party.actors.size
@actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
end
elsif @actor_sprites.size > $game_party.actors.size
for i in 0...@actor_sprites.size
@actor_sprites[i].dispose
end
@actor_sprites = []
for i in 0...$game_party.actors.size
@actor_sprites.push(Sprite_Battler.new(@viewport2, $game_party.actors[i]))
end
end
for i in 0...$game_party.actors.size
@actor_sprites[i].battler = $game_party.actors[i]
end
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 480)
end
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
for sprite in @picture_sprites
sprite.update
end
@timer_sprite.update
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
@viewport2.tone = $game_screen.tone
@viewport2.ox = $game_screen.shake
@viewport4.color = $game_screen.flash_color
@viewport1.update
@viewport2.update
@viewport4.update
end
#--------------------------------------------------------------------------
def set_damage_action(actor, index, action)
return if index.nil?
@actor_sprites[index].damage_action(action) if actor
@enemy_sprites[index].damage_action(action) unless actor
end
#--------------------------------------------------------------------------
def set_damage_pop(actor, index, damage)
return if index.nil?
@actor_sprites[index].damage_pop if actor
@enemy_sprites[index].damage_pop unless actor
end
#--------------------------------------------------------------------------
def set_target(actor, index, target)
return if index.nil?
@actor_sprites[index].get_target(target) if actor
@enemy_sprites[index].get_target(target) unless actor
end
#--------------------------------------------------------------------------
def set_action(actor, index, kind)
return if index.nil?
@actor_sprites[index].start_action(kind) if actor
@enemy_sprites[index].start_action(kind) unless actor
end
#--------------------------------------------------------------------------
def set_stand_by_action(actor, index)
return if index.nil?
@actor_sprites[index].push_stand_by if actor
@enemy_sprites[index].push_stand_by unless actor
end
end

#==============================================================================
# ■ Sprite_MoveAnime
#==============================================================================
class Sprite_MoveAnime < RPG::Sprite
#--------------------------------------------------------------------------
attr_accessor :battler
attr_accessor :base_x
attr_accessor :base_y
#--------------------------------------------------------------------------
def initialize(viewport,battler = nil)
super(viewport)
@battler = battler
self.visible = false
@base_x = 0
@base_y = 0
@move_x = 0
@move_y = 0
@moving_x = 0
@moving_y = 0
@orbit = 0
@orbit_plus = 0
@orbit_time = 0
@through = false
@finish = false
@time = 0
@angle = 0
@angling = 0
end
#--------------------------------------------------------------------------
def anime_action(id,mirror,distanse_x,distanse_y,type,speed,orbit,weapon,icon_index,icon_weapon)
@time = speed
@moving_x = distanse_x / speed
@moving_y = distanse_y / speed
@through = true if type == 1
@orbit_plus = orbit
@orbit_time = @time
if weapon != ""
action = ANIME[weapon].dup
@angle = action[0]
end_angle = action[1]
time = action[2]
@angling = (end_angle - @angle)/ time
self.angle = @angle
self.mirror = mirror
if icon_weapon
self.bitmap = RPG::Cache.icon(icon_index)
self.ox = 12
self.oy = 12
else
self.bitmap = RPG::Cache.character(icon_index, 0)
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height / 2
end
self.visible = true
self.z = 1000
end
self.x = @base_x + @move_x
self.y = @base_y + @move_y + @orbit
if id != 0 && !icon_weapon
animation($data_animations[id],true)
elsif id != 0 && icon_weapon
loop_animation($data_animations[id])
end
end
#--------------------------------------------------------------------------
def action_reset
@moving_x = @moving_y = @move_x = @move_y = @base_x = @base_y = @orbit = 0
@orbit_time = @angling = @angle = 0
@through = self.visible = @finish = false
dispose_animation
end
#--------------------------------------------------------------------------
def finish?
return @finish
end
#--------------------------------------------------------------------------
def update
super
@time -= 1
if @time >= 0
@move_x += @moving_x
@move_y += @moving_y
if @time < @orbit_time / 2
@orbit_plus = @orbit_plus * 5 / 4
elsif @time == @orbit_time / 2
@orbit_plus *= -1
else
@orbit_plus = @orbit_plus * 2 / 3
end
@orbit += @orbit_plus
end
@time = 100 if @time < 0 && @through
@finish = true if @time < 0 && !@through
self.x = @base_x + @move_x
self.y = @base_y + @move_y + @orbit
if self.x < -200 or self.x > 840 or self.y < -200 or self.y > 680
@finish = true
end
if self.visible
@angle += @angling
self.angle = @angle
end
end
end

#==============================================================================
# ■ Sprite_Weapon
#==============================================================================
class Sprite_Weapon < RPG::Sprite
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
def initialize(viewport,battler = nil)
super(viewport)
@battler = battler
@action = []
@move_x = 0
@move_y = 0
@move_z = 0
@plus_x = 0
@plus_y = 0
@angle = 0
@zoom_x = 1
@zoom_y = 1
@moving_x = 0
@moving_y = 0
@angling = 0
@zooming_x = 1
@zooming_y = 1
@freeze = -1
@mirroring = false
@time = ANIME_PATTERN + 1
weapon_graphics
end
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose if self.bitmap != nil
super
end
#--------------------------------------------------------------------------
def weapon_graphics(left = false)
if @battler.actor?
weapon = @battler.weapons[0] unless left
weapon = @battler.weapons[1] if left
else
weapon = $data_weapons[@battler.weapon]
@mirroring = true if @battler.action_mirror
end
return if weapon == nil
if weapon.graphic == ""
self.bitmap = RPG::Cache.icon(weapon.icon_name)
@weapon_width = @weapon_height = 24
else
self.bitmap = RPG::Cache.icon(weapon.graphic)
@weapon_width = self.bitmap.width
@weapon_height = self.bitmap.height
end
end
#--------------------------------------------------------------------------
def freeze(action)
@freeze = action
end
#--------------------------------------------------------------------------
def weapon_action(action,loop)
if action == ""
self.visible = false
elsif @weapon_id == 0
self.visible = false
else
@action = ANIME[action]
act0 = @action[0]
act1 = @action[1]
act2 = @action[2]
act3 = @action[3]
act4 = @action[4]
act5 = @action[5]
act6 = @action[6]
act7 = @action[7]
act8 = @action[8]
act9 = @action[9]
act10 = @action[10]
if @mirroring
act0 *= -1
act3 *= -1
act4 *= -1
act9 *= -1
end
if $back_attack && BACK_ATTACK
act0 *= -1
act3 *= -1
act4 *= -1
act9 *= -1
end
time = ANIME_PATTERN
if act2
self.z = @battler.position_z + 1
else
self.z = @battler.position_z - 1
end
if act6
if self.mirror
self.mirror = false
else
self.mirror = true
end
end
if @mirroring
if self.mirror
self.mirror = false
else
self.mirror = true
end
end
if $back_attack && BACK_ATTACK
if self.mirror
self.mirror = false
else
self.mirror = true
end
end
@moving_x = act0 / time
@moving_y = act1 / time
@angle = act3
self.angle = @angle
@angling = (act4 - act3)/ time
@angle += (act4 - act3) % time
@zooming_x = (1 - act7) / time
@zooming_y = (1 - act8) / time
if self.mirror
case act5
when 1
act5 = 2
when 2
act5 = 1
when 3
act5 = 4
when 4
act5 = 3
end
end
case act5
when 0
self.ox = @weapon_width / 2
self.oy = @weapon_height / 2
when 1
self.ox = 0
self.oy = 0
when 2
self.ox = @weapon_width
self.oy = 0
when 3
self.ox = 0
self.oy = @weapon_height
when 4
self.ox = @weapon_width
self.oy = @weapon_height
end
@plus_x = act9
@plus_y = act10
@loop = true if loop == 0
@angle -= @angling
@zoom_x -= @zooming_x
@zoom_y -= @zooming_y
@move_x -= @moving_x
@move_y -= @moving_y
@move_z = 1000 if act2
if @freeze != -1
for i in 0..@freeze + 1
@angle += @angling
@zoom_x += @zooming_x
@zoom_y += @zooming_y
@move_x += @moving_x
@move_y += @moving_y
end
@angling = 0
@zooming_x = 0
@zooming_y = 0
@moving_x = 0
@moving_y = 0
end
self.visible = true
end
end
#--------------------------------------------------------------------------
def action_reset
@moving_x = @moving_y = @move_x = @move_y = @plus_x = @plus_y = 0
@angling = @zooming_x = @zooming_y = @angle = self.angle = @move_z = 0
@zoom_x = @zoom_y = self.zoom_x = self.zoom_y = 1
self.mirror = self.visible = @loop = false
@freeze = -1
@action = []
@time = ANIME_PATTERN + 1
end
#--------------------------------------------------------------------------
def action_loop
@angling *= -1
@zooming_x *= -1
@zooming_y *= -1
@moving_x *= -1
@moving_y *= -1
end
#--------------------------------------------------------------------------
def mirroring
return @mirroring = false if @mirroring
@mirroring = true
end
#--------------------------------------------------------------------------
def action
return if @time <= 0
@time -= 1
@angle += @angling
@zoom_x += @zooming_x
@zoom_y += @zooming_y
@move_x += @moving_x
@move_y += @moving_y
if @loop && @time == 0
@time = ANIME_PATTERN + 1
action_loop
end
end
#--------------------------------------------------------------------------
def update
super
self.angle = @angle
self.zoom_x = @zoom_x
self.zoom_y = @zoom_y
self.x = @battler.position_x + @move_x + @plus_x
self.y = @battler.position_y + @move_y + @plus_y
self.z = @battler.position_z + @move_z - 1
end
end

#==============================================================================
# Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def add_actor(actor_id)
actor = $game_actors[actor_id]
if @actors.size < MAX_MEMBER and not @actors.include?(actor)
@actors.push(actor)
$game_player.refresh
end
end
end

#==============================================================================
# ■ RPG::Weapon
#==============================================================================
class RPG::Weapon
#--------------------------------------------------------------------------
def magic?
return false
end
end

#==============================================================================
# ■ RPG::Skill
#==============================================================================
class RPG::Skill
#--------------------------------------------------------------------------
def magic?
return @atk_f == 0 ? true : false
end
end

#==============================================================================
# ■ RPG::Item
#==============================================================================
class RPG::Item
#--------------------------------------------------------------------------
def magic?
return false
end
end

#==============================================================================
# ■ RPG::Cache
#==============================================================================
module RPG::Cache
def self.faces(filename, hue = 0)
self.load_bitmap('Graphics/Faces/', filename, hue)
end
end

#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
attr_accessor :sp_damage
attr_accessor :collapse
attr_accessor :move_x
attr_accessor :move_y
attr_accessor :move_z
attr_accessor :jump
attr_accessor :active
attr_accessor :non_dead
attr_accessor :slip_damage
attr_accessor :derivation
attr_accessor :individual
attr_accessor :play
attr_accessor :force_action
attr_accessor :force_target
attr_accessor :revival
attr_accessor :reflex
attr_accessor :absorb
attr_accessor :anime_mirror
attr_accessor :dying
attr_accessor :state_animation_id
attr_accessor :dead_anim
attr_accessor :missed
attr_accessor :evaded
attr_accessor :true_immortal
attr_accessor :defense_pose
attr_reader :base_position_x
attr_reader :base_position_y
attr_reader :base_height
#--------------------------------------------------------------------------
alias initialize_n01 initialize
def initialize
initialize_n01
@move_x = @move_y = @move_z = @plus_y = @jump = @derivation = @act_time = 0
@force_action = @force_target = @base_position_x = @base_position_y = 0
@absorb = @play = @now_state = @state_frame = @state_animation_id = 0
@active = @non_dead = @individual = @slip_damage = @revival = false
@collapse = @sp_damage = @anime_mirror = @dying = false
@evaded = @missed = false
@anim_states = []
end
#--------------------------------------------------------------------------
def state_id
return @states[@states.size - 1]
end
#--------------------------------------------------------------------------
def in_danger
return @hp <= self.maxhp / 4
end
#--------------------------------------------------------------------------
def battler_states
bat_states = []
for i in self.states
bat_states.push($data_states[i])
end
return bat_states
end
#--------------------------------------------------------------------------
def apply_variance(damage, variance)
if damage != 0
amp = [damage.abs * variance / 100, 0].max
damage += rand(amp+1) + rand(amp+1) - amp
end
return damage
end
#--------------------------------------------------------------------------
def state_animation_id
return 0 if @states.empty?
return 0 if @states.include?(1)
@state_frame -= 1 if @state_frame > 0
return @state_animation_id if @state_frame > 0
if @anim_states.empty?
for state in @states
@anim_states << state if $data_states[state].animation_id > 0
end
end
now_state = @anim_states.shift
return 0 if now_state.nil?
@state_animation_id = $data_states[now_state].animation_id
return 0 if $data_animations[@state_animation_id].nil?
@state_frame = $data_animations[@state_animation_id].frame_max * STATE_CYCLE_TIME * 2
return @state_animation_id
end
#--------------------------------------------------------------------------
def skill_can_use?(skill_id)
skill = $data_skills[skill_id]
if skill.extension.include?("CONSUMEHP")
return false if calc_sp_cost(self, skill) >= self.hp
else
return false if calc_sp_cost(self, skill) > self.sp
end
return false if dead?
return false if skill.atk_f == 0 and self.restriction == 1
occasion = skill.occasion
return (occasion == 0 or occasion == 1) if $game_temp.in_battle
return (occasion == 0 or occasion == 2)
end
#--------------------------------------------------------------------------
def calc_sp_cost(user, skill)
cost = skill.sp_cost
if skill.extension.include?("%COSTMAX")
return user.maxhp * cost / 100 if skill.extension.include?("CONSUMEHP")
return user.maxsp * cost / 100
elsif skill.extension.include?("%COSTNOW")
return user.hp * cost / 100 if skill.extension.include?("CONSUMEHP")
return user.sp * cost / 100
end
return cost
end
#--------------------------------------------------------------------------
def consum_skill_cost(skill)
return false unless skill_can_use?(skill.id)
cost = calc_sp_cost(self, skill)
return self.hp -= cost if skill.extension.include?("CONSUMEHP")
return self.sp -= cost
end
#--------------------------------------------------------------------------
def attack_effect(attacker)
self.critical = @evaded = @missed = false
hit_result = (rand(100) < attacker.hit)
set_attack_result(attacker) if hit_result
weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
if hit_result
set_attack_state_change(attacker)
else
self.critical = false
@missed = true
end
self.damage = POP_EVA if @evaded
self.damage = POP_MISS if @missed
return true
end
#--------------------------------------------------------------------------
def perfect_attack_effect(attacker)
self.critical = @evaded = @missed = false
set_attack_result(attacker)
weapon = attacker.actor? ? $data_weapons[attacker.weapon_id] : nil
set_attack_state_change(attacker)
return true
end
#--------------------------------------------------------------------------
def set_attack_result(attacker)
set_attack_damage_value(attacker)
if self.damage > 0
self.damage /= 2 if self.guarding?
set_attack_critical(attacker)
set_critical_damage(attacker) if self.critical
end
apply_variance(15) if self.damage.abs > 0
set_attack_hit_value(attacker)
end
#--------------------------------------------------------------------------
def set_attack_damage_value(attacker)
case DAMAGE_ALGORITHM_TYPE
when 0
atk = [attacker.atk - (self.pdef / 2), 0].max
str = [20 + attacker.str, 0].max
when 1
atk = [attacker.atk - ((attacker.atk * self.pdef) / 1000), 0].max
str = [20 + attacker.str, 0].max
when 2
atk = 20
str = [(attacker.str * 4) - (self.dex * 2) , 0].max
when 3
atk = [(10 + attacker.atk) - (self.pdef / 2), 0].max
str = [(20 + attacker.str) - (self.dex / 2), 0].max
end
self.damage = atk * str / 20
self.damage = 1 if self.damage == 0 and (rand(100) > 40)
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
end
#--------------------------------------------------------------------------
def apply_variance(variance)
amp = [self.damage.abs * variance / 100, 1].max
self.damage += rand(amp + 1) + rand(amp + 1) - amp
end
#--------------------------------------------------------------------------
def set_attack_hit_value(attacker)
atk_hit = DAMAGE_ALGORITHM_TYPE > 1 ? attacker.agi : attacker.dex
eva = (8 * self.agi / atk_hit) + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
@evaded = true unless hit_result
end
#--------------------------------------------------------------------------
def set_attack_critical(attacker)
atk_crt = DAMAGE_ALGORITHM_TYPE > 1 ? attacker.agi : attacker.dex
self.critical = rand(100) < 5 * atk_crt / self.agi
end
#--------------------------------------------------------------------------
def set_critical_damage(attacker)
self.damage += self.damage
end
#--------------------------------------------------------------------------
def set_attack_state_change(attacker)
remove_states_shock
effective = apply_damage(attacker)
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
return effective
end
#--------------------------------------------------------------------------
def skill_effect(user, skill)
self.critical = @evaded = @missed = false
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
effective = false
effective |= skill.common_event_id > 0
hit = skill.hit
hit *= set_skill_hit(user, skill)
hit_result = (rand(100) < hit)
effective |= hit < 100
effective |= set_skill_result(user, skill, effective) if hit_result
if hit_result
effective |= set_skill_state_change(user, skill, effective)
else
@missed = true unless @evaded
end
self.damage = nil unless $game_temp.in_battle
self.damage = POP_EVA if @evaded
self.damage = POP_MISS if @missed
return effective
end
#--------------------------------------------------------------------------
def perfect_skill_effect(user, skill)
self.critical = @evaded = @missed = false
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
effective = false
effective |= skill.common_event_id > 0
effective |= set_skill_result(user, skill, effective)
effective |= set_skill_state_change(user, skill, effective)
self.damage = nil unless $game_temp.in_battle
return effective
end
#--------------------------------------------------------------------------
def set_skill_hit(user, skill)
if skill.magic?
return 1
else
return user.hit / 100
end
end
#--------------------------------------------------------------------------
def set_skill_result(user, skill, effective)
set_skill_damage_value(user, skill)
if self.damage > 0
self.damage /= 2 if self.guarding?
end
apply_variance(skill.variance) if skill.variance > 0 and self.damage.abs > 0
effective |= set_skill_hit_value(user, skill, effective)
return effective
end
#--------------------------------------------------------------------------
def set_skill_damage_value(user, skill)
power = set_skill_power(user, skill)
if power > 0
case DAMAGE_ALGORITHM_TYPE
when 0,3
power -= (self.pdef * skill.pdef_f) / 200
power -= (self.mdef * skill.mdef_f) / 200
when 1
power -= (power * (self.pdef * skill.pdef_f)) / 100000
power -= (power * (self.mdef * skill.mdef_f)) / 100000
when 2
power -= ((self.dex * 2 * skill.pdef_f) / 100)
power -= ((self.int * 1 * skill.mdef_f) / 100)
end
power = [power, 0].max
end
rate = set_skill_rate(user, skill) unless DAMAGE_ALGORITHM_TYPE == 2
rate = [rate, 0].max
self.damage = power * rate / 20
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
end
#--------------------------------------------------------------------------
def set_skill_power(user, skill)
case DAMAGE_ALGORITHM_TYPE
when 0,1,3
power = skill.power + ((user.atk * skill.atk_f) / 100)
when 2
user_str = (user.str * 4 * skill.str_f / 100)
user_int = (user.int * 2 * skill.int_f / 100)
if skill.power > 0
power = skill.power + user_str + user_int
else
power = skill.power - user_str - user_int
end
end
return power
end
#--------------------------------------------------------------------------
def set_skill_rate(user, skill)
case DAMAGE_ALGORITHM_TYPE
when 0,1,2
rate = 20
when 3
rate = 40
rate -= (self.dex / 2 * skill.pdef_f / 200)
rate -= ((self.dex + self.int)/ 4 * skill.mdef_f / 200)
end
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
return rate
end
#--------------------------------------------------------------------------
def set_skill_hit_value(user, skill, effective)
atk_hit = DAMAGE_ALGORITHM_TYPE > 1 ? user.agi : user.dex
eva = 8 * self.agi / atk_hit + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
@evaded = true unless hit_result
effective |= hit < 100
return effective
end
#--------------------------------------------------------------------------
def set_skill_state_change(user, skill, effective = false)
if skill.power != 0 and not skill.magic?
remove_states_shock
effective = true
end
effective |= apply_damage(user)
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
if skill.power == 0
self.damage = ""
@missed = true unless @state_changed
end
return effective
end
#--------------------------------------------------------------------------
def apply_damage(user)
return true if @evaded or @missed or not self.damage.is_a?(Numeric)
if self.sp_damage
last_sp = self.sp
self.sp -= self.damage
effective = self.sp != last_sp
else
last_hp = self.hp
self.hp -= self.damage
effective = self.hp != last_hp
end
return effective
end
#--------------------------------------------------------------------------
def item_effect(item)
self.critical = @evaded = @missed = false
if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
((item.scope == 5 or item.scope == 6) and self.hp >= 1)
return false
end
effective = false
effective |= item.common_event_id > 0
hit_result = (rand(100) < item.hit)
@missed = true unless hit_result
effective |= item.hit < 100
if hit_result == true
effective |= make_item_damage_value(item)
else
@missed = true
end
self.damage = nil unless $game_temp.in_battle
self.damage = POP_MISS if @missed
return effective
end
#--------------------------------------------------------------------------
def perfect_item_effect(item)
self.critical = @evaded = @missed = false
if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
((item.scope == 5 or item.scope == 6) and self.hp >= 1)
return false
end
effective = false
effective |= item.common_event_id > 0
effective |= item.hit < 100
effective |= make_item_damage_value(item)
self.damage = nil unless $game_temp.in_battle
self.damage = POP_MISS if @missed
return effective
end
#--------------------------------------------------------------------------
def make_item_damage_value(item)
recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
if recover_hp < 0
recover_hp += self.pdef * item.pdef_f / 20
recover_hp += self.mdef * item.mdef_f / 20
recover_hp = [recover_hp, 0].min
end
recover_hp *= elements_correct(item.element_set)
recover_hp /= 100
recover_sp *= elements_correct(item.element_set)
recover_sp /= 100
if item.variance > 0 and recover_hp.abs > 0
amp = [recover_hp.abs * item.variance / 100, 1].max
recover_hp += rand(amp+1) + rand(amp+1) - amp
end
if item.variance > 0 and recover_sp.abs > 0
amp = [recover_sp.abs * item.variance / 100, 1].max
recover_sp += rand(amp+1) + rand(amp+1) - amp
end
recover_hp /= 2 if recover_hp < 0 and self.guarding?
self.damage = -recover_hp
last_hp = self.hp
last_sp = self.sp
self.hp += recover_hp
self.sp += recover_sp
effective |= self.hp != last_hp
effective |= self.sp != last_sp
@state_changed = false
effective |= states_plus(item.plus_state_set)
effective |= states_minus(item.minus_state_set)
if item.parameter_type > 0 and item.parameter_points != 0
case item.parameter_type
when 1
@maxhp_plus += item.parameter_points
when 2
@maxsp_plus += item.parameter_points
when 3
@str_plus += item.parameter_points
when 4
@dex_plus += item.parameter_points
when 5
@agi_plus += item.parameter_points
when 6
@int_plus += item.parameter_points
end
effective = true
end
if item.recover_hp_rate == 0 and item.recover_hp == 0
self.damage = ""
if item.recover_sp_rate == 0 and item.recover_sp == 0 and
(item.parameter_type == 0 or item.parameter_points == 0)
unless @state_changed
@missed = true
end
end
end
return effective
end
#--------------------------------------------------------------------------
alias skill_effect_n01 skill_effect
def skill_effect(user, skill)
now_hp = self.hp
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
effective = skill_effect_n01(user, skill)
return if effective == false
check_extension(skill)
if @ratio_maxdamage != nil
self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
end
if @ratio_nowdamage != nil
self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
end
if @cost_damage
cost = calc_sp_cost(user, skill)
if skill.extension.include?("CONSUMEHP")
self.damage = self.damage * cost / user.maxhp
else
self.damage = self.damage * cost / user.maxsp
end
end
self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
if @sp_damage
self.hp = now_hp
self.sp -= self.damage
elsif @extension
self.hp = now_hp
self.hp -= self.damage
end
return true
end
#--------------------------------------------------------------------------
alias perfect_skill_effect_n01 perfect_skill_effect
def perfect_skill_effect(user, skill)
now_hp = self.hp
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
effective = perfect_skill_effect_n01(user, skill)
return if effective == false
check_extension(skill)
if @ratio_maxdamage != nil
self.damage = self.maxhp * @ratio_maxdamage / 100 unless @sp_damage
self.damage = self.maxsp * @ratio_maxdamage / 100 if @sp_damage
end
if @ratio_nowdamage != nil
self.damage = self.hp * @ratio_nowdamage / 100 unless @sp_damage
self.damage = self.sp * @ratio_nowdamage / 100 if @sp_damage
end
if @cost_damage
cost = calc_sp_cost(user, skill)
if skill.extension.include?("CONSUMEHP")
self.damage = self.damage * cost / user.maxhp
else
self.damage = self.damage * cost / user.maxsp
end
end
self.damage = self.damage * user.hp / user.maxhp if @nowhp_damage
self.damage = self.damage * user.sp / user.maxsp if @nowsp_damage
if @sp_damage
self.hp = now_hp
self.sp -= self.damage
elsif @extension
self.hp = now_hp
self.hp -= self.damage
end
return true
end
#--------------------------------------------------------------------------
def check_extension(skill)
@extension = false
@sp_damage = false
@cost_damage = false
@nowhp_damage = false
@nowsp_damage = false
@ratio_maxdamage = nil
@ratio_nowdamage = nil
for ext in skill.extension
break if self.damage == "Errou!" or self.damage == "" or self.damage == 0
if ext == "SPDAMAGE"
next @sp_damage = true
elsif ext == "COSTPOWER"
@extension = true
next @cost_damage = true
elsif ext == "HPNOWPOWER"
@extension = true
next @nowhp_damage = true
elsif ext == "MPNOWPOWER"
@extension = true
next @nowsp_damage = true
else
name = ext.split('')
if name[7] == "M"
name = name.join
name.slice!("%DAMAGEMAX/")
@extension = true
next @ratio_maxdamage = name.to_i
elsif name[7] == "N"
name = name.join
name.slice!("%DAMAGENOW/")
@extension = true
next @ratio_nowdamage = name.to_i
end
end
end
end
#--------------------------------------------------------------------------
def change_base_position(x, y)
@base_position_x = x
@base_position_y = y
end
#--------------------------------------------------------------------------
def reset_coordinate
@move_x = @move_y = @move_z = @jump = @derivation = 0
@active = @non_dead = @individual = false
end
end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
attr_reader :armor5_id
attr_reader :armor6_id
attr_reader :armor7_id
attr_accessor :actor_height
attr_accessor :two_swords_change
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def actor?
return true
end
#--------------------------------------------------------------------------
def weapons
return [$data_weapons[@weapon_id]]
end
#--------------------------------------------------------------------------
def armors
result = []
result << $data_armors[@armor1_id]
result << $data_armors[@armor2_id]
result << $data_armors[@armor3_id]
result << $data_armors[@armor4_id]
return result
end
#--------------------------------------------------------------------------
def equips
return weapons + armors
end
#--------------------------------------------------------------------------
def skill_id_learn?(skill_id)
return @skills.include?(skill_id)
end
#--------------------------------------------------------------------------
def exp=(exp)
@exp = [exp, 0].max
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
while @exp < @exp_list[@level]
@level -= 1
end
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
def base_atk
n = 0
for item in weapons.compact do n += item.atk end
n = UNARMED_ATTACK if weapons[0] == nil and weapons[1] == nil
return n
end
#--------------------------------------------------------------------------
def base_pdef
n = 0
for item in equips.compact do n += item.pdef end
return n
end
#--------------------------------------------------------------------------
def base_mdef
n = 0
for item in equips.compact do n += item.mdef end
return n
end
#--------------------------------------------------------------------------
def base_eva
n = 0
for item in armors.compact do n += item.eva end
return n
end
#--------------------------------------------------------------------------
def graphic_change(character_name)
@character_name = character_name
end
#--------------------------------------------------------------------------
def perform_collapse
$game_system.se_play($data_system.actor_collapse_se) if $game_temp.in_battle and dead?
end
#--------------------------------------------------------------------------
def base_position
base = ACTOR_POSITION[self.index]
@base_position_x = base[0]
@base_position_y = base[1]
@base_position_x = 640 - base[0] if $back_attack and BACK_ATTACK_MIRROR
end
#--------------------------------------------------------------------------
def actor_height
@base_height = 0 if CURSOR_TYPE != 1
@base_height = 72 if CURSOR_TYPE == 1
return @base_height
end
#--------------------------------------------------------------------------
def position_x
return 0 if self.index == nil
return @base_position_x + @move_x
end
#--------------------------------------------------------------------------
def position_y
return 0 if self.index == nil
return @base_position_y + @move_y + @jump
end
#--------------------------------------------------------------------------
def position_z
return 0 if self.index == nil
return position_y + @move_z - @jump + 200
end
end

#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
attr_accessor :adj_speed
attr_accessor :act_time
#--------------------------------------------------------------------------
def actor?
return false
end
#--------------------------------------------------------------------------
def make_action_speed2(adj)
@adj_speed = @current_action.speed if @adj_speed == nil
@adj_speed = @adj_speed * adj / 100
end
#--------------------------------------------------------------------------
def perform_collapse
@force_action = ["N01collapse"] if $game_temp.in_battle and dead?
end
#--------------------------------------------------------------------------
def element_set2
return []
end
#--------------------------------------------------------------------------
def base_position
return if self.index == nil
bitmap = Bitmap.new("Graphics/Battlers/" + @battler_name) if !self.anime_on
bitmap = Bitmap.new("Graphics/Characters/" + @battler_name) if self.anime_on && WALK_ANIME
bitmap = Bitmap.new("Graphics/Characters/" + @battler_name + "_1") if self.anime_on && !WALK_ANIME
height = bitmap.height
@base_position_x = self.screen_x + self.position_plus[0]
@base_position_y = self.screen_y + self.position_plus[1] - height / 3 + 32
@base_position_x = 640 - self.screen_x - self.position_plus[0] if $back_attack and BACK_ATTACK_MIRROR
@base_height = 0 if CURSOR_TYPE == 0
@base_height = height / 3 + 64 if CURSOR_TYPE == 1 if !self.anime_on
@base_height = height /12 + 64 if CURSOR_TYPE == 1 if self.anime_on
@base_height = -(height / 3) if CURSOR_TYPE == 2 if !self.anime_on
@base_height = -(height /12) if CURSOR_TYPE == 2 if self.anime_on
bitmap.dispose
end
#--------------------------------------------------------------------------
def enemy_height
return @base_height
end
#--------------------------------------------------------------------------
def position_x
return @base_position_x - @move_x
end
#--------------------------------------------------------------------------
def position_y
return @base_position_y + @move_y + @jump
end
#--------------------------------------------------------------------------
def position_z
return position_y + @move_z - @jump + 200
end
end

#==============================================================================
# Arrow_Base
#==============================================================================
class Arrow_Base < Sprite
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def update_multi_arrow
return if @arrows == nil or @arrows == []
for i in 0...@arrows.size
@blink_count = (@blink_count + 1) % 40
if @blink_count < 20
@arrows[i].src_rect.set(128, 96, 32, 32) if @arrows[i] != nil
else
@arrows[i].src_rect.set(160, 96, 32, 32) if @arrows[i] != nil
end
end
end
#--------------------------------------------------------------------------
def dispose_multi_arrow
for i in 0...@arrows.size
@arrows[i].dispose if @arrows[i] != nil
end
end
end

#==============================================================================
# Arrow_Enemy_All
#==============================================================================
class Arrow_Enemy_All < Arrow_Base
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@arrows = []
for battler in $game_troop.enemies
if battler.exist?
@arrows[battler.index] = Arrow_Enemy.new(viewport)
@arrows[battler.index].index = battler.index
end
end
end
#--------------------------------------------------------------------------
def update_multi_arrow
super
for i in 0...@arrows.size
enemy = $game_troop.enemies[i]
if enemy != nil && @arrows[i] != nil && @arrows[i].enemy != nil
@arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
@arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
end
end
end
end

#==============================================================================
# Arrow_Actor_All
#==============================================================================
class Arrow_Actor_All < Arrow_Base
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@arrows = []
for battler in $game_party.actors
if battler.exist?
@arrows[battler.index] = Arrow_Actor.new(viewport)
@arrows[battler.index].index = battler.index
end
end
end
#--------------------------------------------------------------------------
def update_multi_arrow
super
for i in 0...@arrows.size
actor = $game_party.actors[i]
if actor != nil && @arrows[i] != nil && @arrows[i].actor != nil
@arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
@arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
end
end
end
end

#==============================================================================
# Arrow_Battler_All
#==============================================================================
class Arrow_Battler_All < Arrow_Base
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
@arrows = []
s = 0
for battler in $game_party.actors + $game_troop.enemies
@arrows[s] = Arrow_Actor.new(viewport) if battler.actor?
@arrows[s] = Arrow_Enemy.new(viewport) if battler.is_a?(Game_Enemy)
@arrows[s].index = battler.index
s += 1
end
end
#--------------------------------------------------------------------------
def update_multi_arrow
super
s = 0
for i in 0...@arrows.size
if @arrows[i].is_a?(Arrow_Actor)
actor = $game_party.actors[i]
if @arrows[i].actor != nil
@arrows[i].x = @arrows[i].actor.position_x + CURSOR_POSITION[0]
@arrows[i].y = @arrows[i].actor.position_y + CURSOR_POSITION[1] + actor.actor_height
s += 1
end
elsif @arrows[i].is_a?(Arrow_Enemy)
enemy = $game_troop.enemies[i - s]
if @arrows[i].enemy != nil or @arrows[i] != nil
@arrows[i].x = @arrows[i].enemy.position_x + CURSOR_POSITION[0]
@arrows[i].y = @arrows[i].enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
end
end
end
end
end

#==============================================================================
# ■ Arrow_Enemy
#==============================================================================
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
def update
super
$game_troop.enemies.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.enemies.size
end
if Input.repeat?(Input::RIGHT)
cursor_up if $back_attack
cursor_down unless $back_attack
end
if Input.repeat?(Input::LEFT)
cursor_up unless $back_attack
cursor_down if $back_attack
end
if Input.repeat?(Input::UP)
cursor_down
end
if Input.repeat?(Input::DOWN)
cursor_up
end
if self.enemy != nil
self.x = self.enemy.position_x + CURSOR_POSITION[0]
self.y = self.enemy.position_y + CURSOR_POSITION[1] + enemy.enemy_height
end
end
#--------------------------------------------------------------------------
def cursor_up
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
#--------------------------------------------------------------------------
def cursor_down
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
end

#==============================================================================
# ■ Arrow_Actor
#==============================================================================
class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
def update
super
if Input.repeat?(Input::RIGHT)
cursor_up if $back_attack
cursor_down unless $back_attack
end
if Input.repeat?(Input::LEFT)
cursor_up unless $back_attack
cursor_down if $back_attack
end
if Input.repeat?(Input::UP)
cursor_up
end
if Input.repeat?(Input::DOWN)
cursor_down
end
if self.actor != nil
self.x = self.actor.position_x + CURSOR_POSITION[0]
self.y = self.actor.position_y + CURSOR_POSITION[1] + actor.actor_height
end
end
#--------------------------------------------------------------------------
def cursor_up
$game_system.se_play($data_system.cursor_se)
@index += $game_party.actors.size - 1
@index %= $game_party.actors.size
end
#--------------------------------------------------------------------------
def cursor_down
$game_system.se_play($data_system.cursor_se)
@index += 1
@index %= $game_party.actors.size
end
#--------------------------------------------------------------------------
def input_right
@index += 1
@index %= $game_party.actors.size
end
#--------------------------------------------------------------------------
def input_update_target
if Input.repeat?(Input::RIGHT)
if @index == self.actor.index
cursor_up if $back_attack
cursor_down unless $back_attack
end
end
if Input.repeat?(Input::LEFT)
if @index == self.actor.index
cursor_up unless $back_attack
cursor_down if $back_attack
end
end
if Input.repeat?(Input::UP)
cursor_up if @index == self.actor.index
end
if Input.repeat?(Input::DOWN)
cursor_down if @index == self.actor.index
end
if self.actor != nil
self.x = self.actor.screen_x
self.y = self.actor.screen_y
end
end
end

#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop
def clear_actions
for enemies in @enemies
enemies.current_action.clear
end
end
end

#==============================================================================
# ■ Window_Command
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
attr_accessor :commands
end

#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 0)
status_icon = []
for i in actor.states
if $data_states[i].rating >= 1
begin
status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
break if status_icon.size > (Icon_max - 1)
rescue
end
end
end
for icon in status_icon
self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
x += Icon_X + 2
end
end
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = $data_system.words.atk
parameter_value = actor.atk
when 1
parameter_name = $data_system.words.pdef
parameter_value = actor.pdef
when 2
parameter_name = $data_system.words.mdef
parameter_value = actor.mdef
when 3
parameter_name = $data_system.words.str
parameter_value = actor.str
when 4
parameter_name = (DAMAGE_ALGORITHM_TYPE == 0 ? STAT_VIT : $data_system.words.dex)
parameter_value = actor.dex
when 5
parameter_name = $data_system.words.agi
parameter_value = actor.agi
when 6
parameter_name = $data_system.words.int
parameter_value = actor.int
when 7
parameter_name = STAT_EVA
parameter_value = actor.eva
end
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
end

#==============================================================================
# ■ Window_Help
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.z = 2000 if $game_temp.in_battle
self.back_opacity = HELP_OPACITY if $game_temp.in_battle
end
#--------------------------------------------------------------------------
def set_text_update(text, align = 0)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
self.visible = true
end
#--------------------------------------------------------------------------
def set_enemy(enemy)
text = enemy.name
set_text_update(text, 1)
text_width = self.contents.text_size(text).width
x = (text_width + self.width)/2
status_icon = []
for i in enemy.states
if $data_states[i].rating >= 1
begin
status_icon.push(RPG::Cache.icon($data_states[i].name + "_st"))
break if status_icon.size > (Icon_max - 1)
rescue
end
end
end
for icon in status_icon
self.contents.blt(x + X_Adjust, y + Y_Adjust + 4, icon, Rect.new(0, 0, Icon_X, Icon_Y), 255)
x += Icon_X + 2
end
end
end

#==============================================================================
# ■ Window_Skill
#==============================================================================
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 128, 640, 352)
@actor = actor
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 320
self.height = 160
self.z = 2100
self.back_opacity = MENU_OPACITY
end
end
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
cost = @actor.calc_sp_cost(@actor, skill)
self.contents.draw_text(x + 232, y, 48, 32, cost.to_s, 2)
end
end

#==============================================================================
# ■ Window_Item
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 320
self.height = 160
self.z = 2100
self.back_opacity = MENU_OPACITY
end
end
end

#==============================================================================
# ■ Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Selectable
#--------------------------------------------------------------------------
alias initialize_n01 initialize
#--------------------------------------------------------------------------
def initialize
initialize_n01
self.z = 2000
end
end

#==============================================================================
# ■ Window_BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = []
for i in 0...$game_party.actors.size
@level_up_flags.push(false)
end
self.z = 2000
self.opacity = STATUS_OPACITY
refresh
end
#--------------------------------------------------------------------------
def update
super
end
end

#==============================================================================
# ■ Window_NameCommand
#==============================================================================
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
super(160, 0, 320, @treasures.size * 32 + 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 160 - height / 2
self.back_opacity = 160
self.z = 2000
self.visible = false
refresh
end
end

#==============================================================================
# ■ Window_NameCommand
#==============================================================================
class Window_NameCommand < Window_Base
#--------------------------------------------------------------------------
def initialize(actor, x, y)
super(x, y, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Font.default_name
self.z = 2000
self.back_opacity = COMMAND_OPACITY
refresh(actor)
end
#--------------------------------------------------------------------------
def refresh(actor)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, 128, 32, actor.name, 1) if actor != nil
end
end

#==============================================================================
# ■ RPG::Sprite
#==============================================================================
class RPG::Sprite < ::Sprite
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage_duration = 0
@_animation_duration = 0
@_blink = false
@_damage_durations = []
@time = 0
end
#--------------------------------------------------------------------------
def appear
end
#--------------------------------------------------------------------------
def escape
end
#--------------------------------------------------------------------------
def collapse
end
#--------------------------------------------------------------------------
def damage(value, critical, sp_damage = nil)
dispose_damage(0...@_damage_durations.size)
@_damage_sprites = []
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
@damage_size = 1 if !MULTI_POP
@damage_size = damage_string.size if MULTI_POP
for i in 0...@damage_size
letter = damage_string[i..i] if MULTI_POP
letter = damage_string if !MULTI_POP
bitmap = Bitmap.new(160, 48)
bitmap.font.name = DAMAGE_FONT
bitmap.font.size = DMG_F_SIZE
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1,160, 36, letter, 1)
bitmap.draw_text(+1, 12-1,160, 36, letter, 1)
bitmap.draw_text(-1, 12+1,160, 36, letter, 1)
bitmap.draw_text(+1, 12+1,160, 36, letter, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(HP_REC_COLOR[0],HP_REC_COLOR[1],HP_REC_COLOR[2]) if !sp_damage
bitmap.font.color.set(SP_REC_COLOR[0],SP_REC_COLOR[1],SP_REC_COLOR[2]) if sp_damage
else
bitmap.font.color.set(HP_DMG_COLOR[0],HP_DMG_COLOR[1],HP_DMG_COLOR[2]) if !sp_damage
bitmap.font.color.set(SP_DMG_COLOR[0],SP_DMG_COLOR[1],SP_DMG_COLOR[2]) if sp_damage
bitmap.font.color.set(CRT_DMG_COLOR[0],CRT_DMG_COLOR[1],CRT_DMG_COLOR[2]) if critical
end
bitmap.draw_text(0, 12,160, 36, letter, 1)
if critical and CRITIC_TEXT and i == 0
x_pop = (MULTI_POP ? (damage_string.size - 1) * (DMG_SPACE / 2) : 0)
bitmap.font.size = ((DMG_F_SIZE * 2) / 3).to_i
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1 + x_pop, -1, 160, 20, POP_CRI, 1)
bitmap.draw_text(+1 + x_pop, -1, 160, 20, POP_CRI, 1)
bitmap.draw_text(-1 + x_pop, +1, 160, 20, POP_CRI, 1)
bitmap.draw_text(+1 + x_pop, +1, 160, 20, POP_CRI, 1)
bitmap.font.color.set(CRT_TXT_COLOR[0],CRT_TXT_COLOR[1],CRT_TXT_COLOR[2]) if critical
bitmap.draw_text(0 + x_pop, 0, 160, 20, POP_CRI, 1)
end
if critical and CRITIC_FLASH
$game_screen.start_flash(Color.new(255, 255, 255, 255),10)
end
@_damage_sprites[i] = ::Sprite.new(self.viewport)
@_damage_sprites[i].bitmap = bitmap
@_damage_sprites[i].ox = 80
@_damage_sprites[i].oy = 20
@_damage_sprites[i].x = self.x + i * DMG_SPACE
@_damage_sprites[i].y = self.y - self.oy / 2
@_damage_sprites[i].z = DMG_DURATION + 3000 + i * 2
end
end
#--------------------------------------------------------------------------
def dispose
dispose_damage(0...@_damage_durations.size)
dispose_animation
dispose_loop_animation
if @damage_sprites != nil
for damage_sprite in @damage_sprites
damage_sprite.dispose
end
end
super
end
#--------------------------------------------------------------------------
def update
super
@damage_sprites = [] if @damage_sprites.nil?
@damage_durations = [] if @damage_durations.nil?
if @_damage_sprites != nil
for sprite in @_damage_sprites
if sprite != nil and sprite.visible
x = DMG_X_MOVE
y = DMG_Y_MOVE
d = sprite.z - 3000
m = self.mirror
@damage_sprites.push(Sprite_Damage.new(sprite, x, y, d, m))
sprite.visible = false
end
end
end
for damage_sprite in @damage_sprites
damage_sprite.update
end
for i in 0...@damage_sprites.size
@damage_sprites[i] = nil if @damage_sprites[i].disposed?
end
@damage_sprites.compact!
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_animation != nil and (Graphics.frame_count % 2 == 0)
@_animation_duration -= 1
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
#--------------------------------------------------------------------------
def dispose_damage(index)
return if @_damage_sprites == nil
if @_damage_sprites[index].is_a?(::Sprite) and @_damage_sprites[index].bitmap != nil
@_damage_sprites[index].bitmap.dispose
@_damage_sprites[index].dispose
@_damage_durations[index] = 0
end
end
#--------------------------------------------------------------------------
def dispose_animation
if @_animation_sprites != nil
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @_animation_sprites
sprite.dispose
end
@_animation_sprites = nil
@_animation = nil
end
@mirror = false
end
#--------------------------------------------------------------------------
def animation_mirror(mirror_effect)
@mirror = mirror_effect
end
#--------------------------------------------------------------------------
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x - self.ox + self.src_rect.width / 2
sprite.y = self.y - self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
if @mirror
sprite.ox = 88
else
sprite.ox = 104
end
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
if @mirror
if sprite.mirror
sprite.mirror = false
else
sprite.mirror = true
end
end
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end

#==============================================================================
# ■ Sprite_Damage
#==============================================================================
class Sprite_Damage < Sprite
#--------------------------------------------------------------------------
include N01
#--------------------------------------------------------------------------
def initialize(sprite, init_x_speed, init_y_speed, duration, mirror)
super(nil)
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = 255
self.x = sprite.x
self.y = sprite.y
self.z = 3000
self.ox = sprite.ox
self.oy = sprite.oy
@damage_mirror = mirror
@now_x_speed = init_x_speed
@now_y_speed = init_y_speed
@potential_x_energy = 0.0
@potential_y_energy = 0.0
@duration = duration
end
#--------------------------------------------------------------------------
def update
@duration -= 1
return unless @duration <= DMG_DURATION
super
n = self.oy + @now_y_speed
if n <= 0
@now_y_speed *= -1
@now_y_speed /= 2
@now_x_speed /= 2
end
self.oy = [n, 0].max
@potential_y_energy += DMG_GRAVITY
speed = @potential_y_energy.floor
@now_y_speed -= speed
@potential_y_energy -= speed
@potential_x_energy += @now_x_speed if @damage_mirror if POP_MOVE
@potential_x_energy -= @now_x_speed if !@damage_mirror if POP_MOVE
speed = @potential_x_energy.floor
self.ox += speed
@potential_x_energy -= speed
case @duration
when 1..10
self.opacity -= 25
when 0
self.dispose
end
end
end[/spoiler]
So I remove that section and I get this on a different script
Scene_Battle1
[spoiler]#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Initialize each kind of temporary battle data
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# Initialize battle event interpreter
$game_system.battle_interpreter.setup(nil, 0)
# Prepare troop
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
# Make actor command window
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# Make other windows
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
#--------------------------------------------------------------------------
@message_window = [] # Zer0 edit
@message_window[0] = Window_Message.new(0)
#--------------------------------------------------------------------------
# Make sprite set
@spriteset = Spriteset_Battle.new
# Initialize wait count
@wait_count = 0
# Execute transition
if $data_system.battle_transition == ''
Graphics.transition(20)
else
Graphics.transition(40, 'Graphics/Transitions/' +
$data_system.battle_transition)
end
# Start pre-battle phase
start_phase1
# Main loop
loop {
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
}
# Refresh map
$game_map.refresh
# Prepare for transition
Graphics.freeze
# Dispose of windows
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
#--------------------------------------------------------------------------
@message_window.each {|mw| mw.dispose} # Zer0 edit
#--------------------------------------------------------------------------
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# Dispose of sprite set
@spriteset.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
# If switching from battle test to any screen other than game over screen
if $BTEST && !$scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#--------------------------------------------------------------------------
# * Determine Battle Win/Loss Results
#--------------------------------------------------------------------------
def judge
# If all dead determinant is true, or number of members in party is 0
if $game_party.all_dead? || $game_party.actors.size == 0
# If possible to lose
if $game_temp.battle_can_lose
# Return to BGM before battle starts
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(2)
else
# Set game over flag
$game_temp.gameover = true
end
# Return true
return true
end
# Return false if even 1 enemy exists
if $game_troop.enemies.any? {|enemy| enemy.exist?}
return false
end
# Start after battle phase (win)
start_phase5
# Return true
return true
end
#--------------------------------------------------------------------------
# * Battle Ends
# result : results (0:win 1:lose 2:escape)
#--------------------------------------------------------------------------
def battle_end(result)
# Clear in battle flag
$game_temp.in_battle = false
# Clear entire party actions flag
$game_party.clear_actions
# Remove battle states
$game_party.actors.each {|actor| actor.remove_states_battle}
# Clear enemies
$game_troop.enemies.clear
# Call battle callback
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Battle Event Setup
#--------------------------------------------------------------------------
def setup_battle_event
# If battle event is running
if $game_system.battle_interpreter.running?
return
end
# Search for all battle event pages
$data_troops[@troop_id].pages.each_index {|index|
# Get event pages
page = $data_troops[@troop_id].pages[index]
# Make event conditions possible for reference with c
c = page.condition
# Go to next page if no conditions are appointed
unless c.turn_valid || c.enemy_valid || c.actor_valid || c.switch_valid
next
end
# Go to next page if action has been completed
if $game_temp.battle_event_flags[index]
next
end
# Confirm turn conditions
if c.turn_valid
n = $game_temp.battle_turn
a = c.turn_a
b = c.turn_b
if b == 0 && n != a || b > 0 && (n < 1 || n < a || n % b != a % b)
next
end
end
# Confirm enemy conditions
if c.enemy_valid
enemy = $game_troop.enemies[c.enemy_index]
if enemy == nil || enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
next
end
end
# Confirm actor conditions
if c.actor_valid
actor = $game_actors[c.actor_id]
if actor == nil || actor.hp * 100.0 / actor.maxhp > c.actor_hp
next
end
end
# Confirm switch conditions
if c.switch_valid && !$game_switches[c.switch_id]
next
end
# Set up event
$game_system.battle_interpreter.setup(page.list, 0)
# If this page span is [battle] or [turn]
if page.span <= 1
# Set action completed flag
$game_temp.battle_event_flags[index] = true
end
return
}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# If battle event is running
if $game_system.battle_interpreter.running?
# Update interpreter
$game_system.battle_interpreter.update
# If a battler which is forcing actions doesn't exist
if $game_temp.forcing_battler == nil
# If battle event has finished running and battle continues
unless $game_system.battle_interpreter.running? || judge
# Rerun battle event set up
setup_battle_event
end
# If not after battle phase and status window needs refreshing
if @phase != 5 && @status_window.need_refresh
# Refresh status window
@status_window.refresh
end
end
end
# Update system (timer) and screen
$game_system.update
$game_screen.update
# If timer has reached 0
if $game_system.timer_working && $game_system.timer == 0
# Abort battle
$game_temp.battle_abort = true
end
# Update windows
@help_window.update
@party_command_window.update
@actor_command_window.update
@status_window.update
#--------------------------------------------------------------------------
[b] @message_window.each {|mw| mw.update} # Zer0 edit[/b] (Culprit number two gives me NoMethodError occurred undefined method each for nil:NilClass)
#--------------------------------------------------------------------------
# Update sprite set
@spriteset.update
# If transition is processing
if $game_temp.transition_processing
# Clear transition processing flag
$game_temp.transition_processing = false
# Execute transition
if $game_temp.transition_name == ''
Graphics.transition(20)
else
Graphics.transition(40, 'Graphics/Transitions/' +
$game_temp.transition_name)
end
end
# If message window is showing or effect is showing
if $game_temp.message_window_showing || @spriteset.effect?
return
end
# If game over
if $game_temp.gameover
# Switch to game over screen
$scene = Scene_Gameover.new
# If returning to title screen
elsif $game_temp.to_title
# Switch to title screen
$scene = Scene_Title.new
# If battle is aborted
elsif $game_temp.battle_abort
# Return to BGM used before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(1)
# If waiting
elsif @wait_count > 0
# Decrease wait count
@wait_count -= 1
# If battler forcing an action exists or
# battle event is not running
elsif $game_temp.forcing_battler != nil ||
!$game_system.battle_interpreter.running?
# Branch according to phase
case @phase
when 1 # pre-battle phase
update_phase1
when 2 # party command phase
update_phase2
when 3 # actor command phase
update_phase3
when 4 # main phase
update_phase4
when 5 # after battle phase
update_phase5
end
end
end
end
[/spoiler]
Lastly I had to add that in order to use this Multiple Message Window Script here
[spoiler]#==============================================================================
# ** Multiple Message Windows
#------------------------------------------------------------------------------
# Originally written by Wachunga
# Optimized and De-SDK'ed by ForeverZer0
# 1.5
# 2006-11-17
#==============================================================================
=begin

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

- Credit for the original script is 100% Wachunga. Original map and events
are also Wachunga's original.

- Edits have been made by ForeverZer0 to eliminate the SDK requirement
and improve coding and performance
- I have added a compatibility switch for Blizzard's simple shaded text if you
are you using that, because it doesn't look right with message text. The
switch will disable it whenever a message is showing, but otherwise will
shade everything else.
- This script must be placed below Blizzard's Tons-of-Add-ons if you are
using it. If you don't you will get an error. It has something to do with
the Lagless HUD script. Some bug I couldn't isolate... If you find it, let
me know, else just keep it under Tons.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

This custom message system adds numerous features on top of the default
message system, the most notable being the ability to have multiple message
windows open at once. The included features are mostly themed around turning
messages into speech (and thought) balloons, but default-style messages are
of course still possible.

Note:
This version of the script uses the SDK, available from:
http://www.rmxp.org/forums/showthread.php?t=1802

FEATURES

New in 1.5:
* \C[#ffffff] for hexadecimal color
* \C for return to default color
* display name of item, weapon, armor or skill
* \N[In] = display name of item with id n (note the "I")
* \N[Wn] = display name of weapon with id n (note the "W")
* \N[An] = display name of armor with id n (note the "A")
* \N[Sn] = display name of skill with id n (note the "S")
* display icon of item, weapon, armor or skill
* \I[In] = display icon of item with id n (note the "I")
* \I[Wn] = display icon of weapon with id n (note the "W")
* \I[An] = display icon of armor with id n (note the "A")
* \I[Sn] = display icon of skill with id n (note the "S")
* display icon and name of item, weapon, armor or skill
* \I&N[In] = display icon and name of item with id n (note the "I")
* \I&N[Wn] = display icon and name of weapon with id n (note the "W")
* \I&N[An] = display icon and name of armor with id n (note the "A")
* \I&N[Sn] = display icon and name of skill with id n (note the "S")
* new windowskins available
* speech windowskin now definable separately from default windowskin
* fixed bold bug where degree sign would occasionally appear
* input number window now shares parent window's font
* changed \Var[n] back to default of \V[n]

New in 1.1:
* message.autocenter for automatically centering text within messages
* \N[en] for displaying name of enemy with id n (note the "e")
* \MAP for displaying the name of the current map

At a glance:
* multiple message windows
* speech balloons
* position over player/event (follows movement and scrolling)
* optional message tail (for speech or thought balloons)
* can specify location relative to player/event (up, down, left, right)
* thought balloons
* can use different windowskin, message tail and font color
* letter-by-letter mode
* variable speed (and delays)
* skippable on button press
* autoresize messages
* player movement allowed during messages
* if speaker moves offscreen, message closes (like ChronoTrigger)
* everything also works during battle
* settings configurable at anytime

Full list of options:

(Note that all are case *insensitive*.)

=============================================================================
Local (specified in message itself and resets at message end)
=============================================================================
- \L = letter-by-letter mode toggle
- \S[n] = set speed at which text appears in letter-by-letter mode
- \D[n] = set delay (in frames) before next text appears
- \P[n] = position message over event with id n
* use n=0 for player
* in battle, use n=a,b,c,d for actors (e.g. \P[a] for first actor)
and n=1,...,n for enemies (e.g. \P[1] for first enemy)
where order is actually the reverse of troop order (in database)
- \P = position message over current event (default for floating messages)
- \^ = message appears directly over its event
- \v = message appears directly below its event
- \< = message appears directly to the left of its event
- \> = message appears directly to the right of its event
- \B = bold text
- \I = italic text
- \C[#xxxxxx] = change to color specified by hexadecimal (eg. ffffff = white)
- \C = change color back to default
- \! = message autoclose
- \? = wait for user input before continuing
- \+ = make message appear at same time as preceding one
* note: must be at the start of message to work
- \@ = thought balloon
- \N[En] = display name of enemy with id n (note the "E")
- \N[In] = display name of item with id n (note the "I")
- \N[Wn] = display name of weapon with id n (note the "W")
- \N[An] = display name of armor with id n (note the "A")
- \N[Sn] = display name of skill with id n (note the "S")
- \I[In] = display icon of item with id n (note the "I")
- \I[Wn] = display icon of weapon with id n (note the "W")
- \I[An] = display icon of armor with id n (note the "A")
- \I[Sn] = display icon of skill with id n (note the "S")
- \I&N[In] = display icon and name of item with id n (note the "I")
- \I&N[Wn] = display icon and name of weapon with id n (note the "W")
- \I&N[An] = display icon and name of armor with id n (note the "A")
- \I&N[Sn] = display icon and name of skill with id n (note the "S")
- \MAP = display the name of the current map

These are, of course, in addition to the default options:
- \V[n] = display value of variable n
- \N[n] = display name of actor with id n
- \C[n] = change color to n
- \G = display gold window
- \\ = show the '\' character

=============================================================================
Global (specified below or by Call Script and persist until changed)
=============================================================================

Zer0 Note:
If you use any of these in another script, etc. and not a script call, you
will need to place "$game_system." before each command.

Miscellaneous:
- message.move_during = true/false
* allow/disallow player to move during messages
- message.show_pause = true/false
* show/hide "waiting for player" pause graphic
- message.autocenter = true/false
* enable/disable automatically centering text within messages

Speech/thought balloon related:
- message.resize = true/false
* enable/disable automatic resizing of messages (only as big as necessary)
- message.floating = true/false
* enable/disable positioning messages above current event by default
(i.e. equivalent to including \P in every message)
- message.location = TOP, BOTTOM, LEFT or RIGHT
* set default location for floating messages relative to their event
- message.show_tail = true/false
* show/hide message tail for speech/thought balloons

Letter-by-letter related:
- message.letter_by_letter = true/false
* enable/disable letter-by-letter mode (globally)
- message.text_speed = 0-20
* set speed at which text appears in letter-by-letter mode (globally)
- message.skippable = true/false
* allow/disallow player to skip to end of message with button press

Font:
- message.font_name = font
* set font to use for text, overriding all defaults
(font can be any TrueType from Windows/Fonts folder)
- message.font_size = size
* set size of text (default 22), overriding all defaults
- message.font_color = color
* set color of text, overriding all defaults
* you can use same 0-7 as for \C[n] or "#xxxxxx" for hexadecimal

Note that the default thought and shout balloon windowskins don't
stretch to four lines very well (unfortunately).

Thanks:
XRXS code for self-close and wait for input
Slipknot for a convenient approach to altering settings in-game
SephirothSpawn for bitmap rotate method

=end

#==============================================================================
# Settings
#==============================================================================

# Zer0 Edit. Blizzard's Simple Shaded Text just looks kinda funny when used
# on black text (which is default for MMS). If you are using Shaded Text and
# do not want it to display for the message windows, set this to true. It will
# still show for everything else.

Blizzard_Shaded_Text_Fix = true

#----------------------------------------------------------------------------
# Windowskins
#----------------------------------------------------------------------------
# Note: all files must be in the Graphics/Windowskins/ folder
# Tip: tails don't look right on windowskins with gradient backgrounds

# filenames of tail and windowskin used for speech balloons
FILENAME_SPEECH_TAIL = 'white-tail_speech.png'
FILENAME_SPEECH_WINDOWSKIN = 'WS1'

# filenames of tail and windowskin used for thought balloons
FILENAME_THOUGHT_TAIL = 'white-tail_thought.png'
FILENAME_THOUGHT_WINDOWSKIN = 'white-windowskin_thought.png'

#----------------------------------------------------------------------------
# Fonts
#----------------------------------------------------------------------------
# Note: if floating or resize (i.e. 'speech balloons') are disabled,
# Font.default_name, Font.default_size and Font.default_color are used
# (you can change these in Main)
# During gameplay, you can use message.font_name etc to override all defaults

# defaults for speech text
SPEECH_FONT_COLOR = "#000000"
SPEECH_FONT_NAME = ['Comic Sans MS', 'Arial']
SPEECH_FONT_SIZE = 20

# defaults for thought text
THOUGHT_FONT_COLOR = "#000000"
THOUGHT_FONT_NAME = ['Comic Sans MS', 'Arial']
THOUGHT_FONT_SIZE = 20

# note that you can use an array of fonts for SPEECH_FONT_NAME, etc.
# e.g. ['Verdana', 'MS PGothic']
# (if Verdana is not available, MS PGothic will be used instead)

#----------------------------------------------------------------------------
# Misc
#----------------------------------------------------------------------------
# If using a specialty windowskin (e.g. the default thought balloon one),
# you can force the window width to always be a multiple of the number
# specified in this constant (even when using the resize feature).
# This allows, for example, the windowskin frame to be designed to
# repeat every 16 pixels so that the frame never looks cut off.
THOUGHT_WIDTH_MULTIPLE = 16
# (set to 0 if you're not using any such windowskins)

class Game_Message

# Any of the below can be changed by a Call Script event during gameplay.
# E.g. turn letter-by-letter mode off with: message.letter_by_letter = false

attr_accessor :move_during
attr_accessor :letter_by_letter
attr_accessor :text_speed
attr_accessor :skippable
attr_accessor :resize
attr_accessor :floating
attr_accessor :autocenter
attr_accessor :show_tail
attr_accessor :show_pause
attr_accessor :location
attr_accessor :font_name
attr_accessor :font_size
attr_accessor :font_color

def initialize
# whether or not messages appear one letter at a time
@letter_by_letter = true
# note: can also change within a single message with \L

# the default speed at which text appears in letter-by-letter mode
@text_speed = 0
# note: can also change within a single message with \S[n]

# whether or not players can skip to the end of (letter-by-letter) messages
@skippable = false

# whether or not messages are automatically resized based on the message
@resize = true

# whether or not message windows are positioned above
# characters/events by default, i.e. without needing \P every message
# (only works if resize messages enabled -- otherwise would look very odd)
@floating = false

# whether or not to automatically center lines within the message
@autocenter = true

# whether or not event-positioned messages have a tail(for speech balloons)
# (only works if floating and resized messages enabled -- otherwise would
# look very odd indeed)
@show_tail = true

# whether or not to display "waiting for user input" pause graphic
# (probably want this disabled for speech balloons)
@show_pause = false

# whether the player is permitted to move while messages are displayed
@move_during = false

# the default location for floating messages (relative to the event)
# note that an off-screen message will be "flipped" automatically
@location = TOP

# font details
# overrides all defaults; leave nil to just use defaults (e.g. as above)
@font_name = nil
@font_size = 24
@font_color = 8
end
end

#==============================================================================
# Private constants (don't edit)
#==============================================================================

# used for message.location
TOP = 8
BOTTOM = 2
LEFT = 4
RIGHT = 6

#------------------------------------------------------------------------------

class Window_Message < Window_Selectable

def initialize(msgindex)
super(80, 304, 480, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.visible = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
self.z = 9000 + msgindex * 5 # permits messages to overlap legibly
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
@fade_in = false
@fade_out = false
@contents_showing = false
@cursor_width = 0
self.active = false
self.index = -1
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
@msgindex = msgindex
@tail = Sprite.new
@tail.bitmap =
if @msgindex == 0
RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
else
# don't use cached version or else all tails
# are rotated when multiple are visible at once
Bitmap.new('Graphics/Windowskins/'+FILENAME_SPEECH_TAIL)
end
# keep track of orientation of tail bitmap
if @tail.bitmap.orientation == nil
@tail.bitmap.orientation = 0
end
# make origin the center, not top left corner
@tail.ox = @tail.bitmap.width/2
@tail.oy = @tail.bitmap.height/2
@tail.z = 9999
@tail.visible = false
if $game_system.message.floating && $game_system.message.resize
@windowskin = FILENAME_SPEECH_WINDOWSKIN
else
# use windowskin specified in database
@windowskin = $game_system.windowskin_name
end
if $game_system.message.floating && $game_system.message.resize
# if used as speech balloons, use constants
@font_name = SPEECH_FONT_NAME
@font_color = check_color(SPEECH_FONT_COLOR)
@font_size = SPEECH_FONT_SIZE
else
# use defaults
@font_name = Font.default_name
@font_color = Font.default_color
@font_size = Font.default_size
end
# override defaults if necessary
if $game_system.message.font_name != nil
@font_name = $game_system.message.font_name
end
if $game_system.message.font_color != nil
@font_color = check_color($game_system.message.font_color)
end
if $game_system.message.font_size != nil
@font_size = $game_system.message.font_size
end
@update_text = true
@letter_by_letter = $game_system.message.letter_by_letter
@text_speed = $game_system.message.text_speed
# id of character for speech balloons
@float_id = nil
# location of box relative to speaker
@location = $game_system.message.location
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end

def dispose
terminate_message
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# have to check all windows before claiming that no window is showing
if $game_temp.message_text.compact.empty?
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
$game_temp.message_window_showing = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
if @input_number_window != nil
@input_number_window.dispose
end
super
end

def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
# Clear showing flag
@contents_showing = false

# Clear variables related to text, choices, and number input
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
@tail.visible = false
# note that these variables are now indexed arrays
$game_temp.message_text[@msgindex] = nil
# Call message callback
if $game_temp.message_proc[@msgindex] != nil
# make sure no message boxes are displaying
if $game_temp.message_text.compact.empty?
$game_temp.message_proc[@msgindex].call
end
$game_temp.message_proc[@msgindex] = nil
end
@update_text = true
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
# Open gold window
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
end

def refresh
self.contents.clear
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
@x = @y = 0 # now instance variables
@float_id = nil
@location = $game_system.message.location
if $game_system.message.floating && $game_system.message.resize
@windowskin = FILENAME_SPEECH_WINDOWSKIN
else
# use windowskin specified in database
@windowskin = $game_system.windowskin_name
end
if $game_system.message.floating && $game_system.message.resize
# if used as speech balloons, use constants
@font_name = SPEECH_FONT_NAME
@font_color = check_color(SPEECH_FONT_COLOR)
@font_size = SPEECH_FONT_SIZE
else
# use default font
@font_name = Font.default_name
@font_color = Font.default_color
@font_size = Font.default_size
end
# override font defaults
if $game_system.message.font_name != nil
@font_name = $game_system.message.font_name
end
if $game_system.message.font_color != nil
@font_color = check_color($game_system.message.font_color)
end
if $game_system.message.font_size != nil
@font_size = $game_system.message.font_size
end
@line_widths = nil
@wait_for_input = false
@tail.bitmap =
if @msgindex == 0
RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
else
Bitmap.new('Graphics/Windowskins/'+FILENAME_SPEECH_TAIL)
end
RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
@tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
@text_speed = $game_system.message.text_speed
@letter_by_letter = $game_system.message.letter_by_letter
@delay = @text_speed
@player_skip = false
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
@x = 8
end
# If waiting for a message to be displayed
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
if $game_temp.message_text[@msgindex] != nil
@text = $game_temp.message_text[@msgindex] # now an instance variable
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
# Control text processing
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) {
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ''
}
# Change "\\\\" to "\000" for convenience
@text.gsub!(/\\\\/) { "\000" }
@text.gsub!(/\\[Gg]/) { "\002" }
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# display icon of item, weapon, armor or skill
@text.gsub!(/\\[Ii]\[([IiWwAaSs][0-9]+)\]/) { "\013[#{$1}]" }
# display name of enemy, item, weapon, armor or skill
@text.gsub!(/\\[Nn]\[([EeIiWwAaSs])([0-9]+)\]/) {
case $1.downcase
when 'e'
entity = $data_enemies[$2.to_i]
when 'i'
entity = $data_items[$2.to_i]
when 'w'
entity = $data_weapons[$2.to_i]
when 'a'
entity = $data_armors[$2.to_i]
when 's'
entity = $data_skills[$2.to_i]
end
entity != nil ? entity.name : ''
}
# display icon and name of item, weapon, armor or skill
@text.gsub!(/\\[Ii]&[Nn]\[([IiWwAaSs])([0-9]+)\]/) {
case $1.downcase
when 'e'
entity = $data_enemies[$2.to_i]
when 'i'
entity = $data_items[$2.to_i]
when 'w'
entity = $data_weapons[$2.to_i]
when 'a'
entity = $data_armors[$2.to_i]
when 's'
entity = $data_skills[$2.to_i]
end
entity != nil ? "\013[#{$1+$2}] " + entity.name : ''
}
# display name of current map
@text.gsub!(/\\[Mm][Aa][Pp]/) { $game_map.name }
# change font color
@text.gsub!(/\\[Cc]\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/) { "\001[#{$1}]" }
# return to default color
@text.gsub!(/\\[Cc]/) { "\001" }
# toggle letter-by-letter mode
@text.gsub!(/\\[Ll]/) { "\003" }
# change text speed (for letter-by-letter)
@text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\004[#{$1}]" }
# insert delay
@text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\005[#{$1}]" }
# self close message
@text.gsub!(/\\[!]/) { "\006" }
# wait for button input
@text.gsub!(/\\[?]/) { "\007" }
# bold
@text.gsub!(/\\[Bb]/) { "\010" }
# italic
@text.gsub!(/\\[Ii]/) { "\011" }
# thought balloon
if @text.gsub!(/\\[@]/, '') != nil
@windowskin = FILENAME_THOUGHT_WINDOWSKIN
@font_name = THOUGHT_FONT_NAME
@font_size = THOUGHT_FONT_SIZE
@font_color = check_color(THOUGHT_FONT_COLOR)
@tail.bitmap =
if @msgindex == 0
RPG::Cache.windowskin(FILENAME_THOUGHT_TAIL)
else
Bitmap.new('Graphics/Windowskins/'+FILENAME_THOUGHT_TAIL)
end
@tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
end
# Get rid of "\\+" (multiple messages)
@text.gsub!(/\\[+]/, '')
# Get rid of "\\^", "\\v", "\\<", "\\>" (relative message location)
if @text.gsub!(/\\\^/, '') != nil
@location = 8
elsif @text.gsub!(/\\[Vv]/, '') != nil
@location = 2
elsif @text.gsub!(/\\[<]/, '') != nil
@location = 4
elsif @text.gsub!(/\\[>]/, '') != nil
@location = 6
end
# Get rid of "\\P" (position window to given character)
if @text.gsub!(/\\[Pp]\[([0-9]+)\]/, '') != nil
@float_id = $1.to_i
elsif @text.gsub!(/\\[Pp]\[([a-zA-Z])\]/, '') != nil &&
$game_temp.in_battle
@float_id = $1.downcase
elsif @text.gsub!(/\\[Pp]/, '') != nil ||
($game_system.message.floating && $game_system.message.resize) &&
!$game_temp.in_battle
@float_id = $game_system.map_interpreter.event_id
end
if $game_system.message.resize || $game_system.message.autocenter
# calculate length of lines
text = @text.clone
temp_bitmap = Bitmap.new(1,1)
temp_bitmap.font.name = @font_name
temp_bitmap.font.size = @font_size
@line_widths = [0,0,0,0]
(0..3).each do |i|
line = text.split(/\n/)[3-i]
if line == nil
next
end
line.gsub!(/[\001-\007](\[[#A-Fa-f0-9]+\])?/, '')
line.gsub!(/\013\[[IiWwAaSs][0-9]+\]/, "\013")
line.chomp.split(//).each do |c|
case c
when "\000"
c = "\\"
when "\010"
# bold
temp_bitmap.font.bold = !temp_bitmap.font.bold
next
when "\011"
# italics
temp_bitmap.font.italic = !temp_bitmap.font.italic
next
when "\013"
# icon
@line_widths[3-i] += 24
next
end
@line_widths[3-i] += temp_bitmap.text_size(c).width
end
if (3-i) >= $game_temp.choice_start
# account for indenting
@line_widths[3-i] += 8 unless $game_system.message.autocenter
end
end
if $game_temp.num_input_variable_id > 0
# determine cursor_width as in Window_InputNumber
# (can't get from @input_number_window because it doesn't exist yet)
cursor_width = temp_bitmap.text_size('0').width + 8
# use this width to calculate line width (+8 for indent)
input_number_width = cursor_width*$game_temp.num_input_digits_max
input_number_width += 8 unless $game_system.message.autocenter
@line_widths[$game_temp.num_input_start] = input_number_width
end
temp_bitmap.dispose
end
resize
reposition if @float_id != nil
self.contents.font.name = @font_name
self.contents.font.size = @font_size
self.contents.font.color = @font_color
self.windowskin = RPG::Cache.windowskin(@windowskin)
# autocenter first line if enabled
# (subsequent lines are done as "\n" is encountered)
if $game_system.message.autocenter && @text != ''
@x = (self.width-40)/2 - @line_widths[0]/2
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
end

#--------------------------------------------------------------------------
# * Resize Window
#--------------------------------------------------------------------------
def resize
if !$game_system.message.resize
# reset to defaults
self.width = 480
self.height = 160
self.contents = Bitmap.new(width - 32, height - 32)
self.x = 80 # undo any centering
return
end
max_x = @line_widths.max
max_y = 4
@line_widths.each {|line| max_y -= 1 if line == 0 && max_y > 1}
if $game_temp.choice_max > 0
# account for indenting
max_x += 8 unless $game_system.message.autocenter
end
new_width = max_x + 40
if @windowskin == FILENAME_THOUGHT_WINDOWSKIN && THOUGHT_WIDTH_MULTIPLE >0
# force window width to be a multiple of THOUGHT_WIDTH_MULTIPLE
# so that specialty windowskins (e.g. thought balloon) look right
if new_width % THOUGHT_WIDTH_MULTIPLE != 0
new_width += THOUGHT_WIDTH_MULTIPLE-(new_width%THOUGHT_WIDTH_MULTIPLE)
end
end
self.width = new_width
self.height = max_y * 32 + 32
self.contents = Bitmap.new(width - 32, height - 32)
self.x = 320 - (self.width/2) # center
end

#--------------------------------------------------------------------------
# * Reposition Window
#--------------------------------------------------------------------------
def reposition
if $game_temp.in_battle
if 'abcd'.include?(@float_id) # must be between a and d
@float_id = @float_id[0] - 97 # a = 0, b = 1, c = 2, d = 3
return if $scene.spriteset.actor_sprites[@float_id] == nil
sprite = $scene.spriteset.actor_sprites[@float_id]
else
@float_id -= 1 # account for, e.g., player entering 1 for index 0
return if $scene.spriteset.enemy_sprites[@float_id] == nil
sprite = $scene.spriteset.enemy_sprites[@float_id]
end
char_height = sprite.height
char_width = sprite.width
char_x = sprite.x
char_y = sprite.y - char_height/2
else # not in battle...
char = (@float_id == 0 ? $game_player : $game_map.events[@float_id])
if char == nil
# no such character
@float_id = nil
return
end
# close message (and stop event processing) if speaker is off-screen
if char.screen_x <= 0 || char.screen_x >= 640 ||
char.screen_y <= 0 || char.screen_y > 480
terminate_message
$game_system.map_interpreter.command_115
return
end
char_height = RPG::Cache.character(char.character_name,0).height / 4
char_width = RPG::Cache.character(char.character_name,0).width / 4
# record coords of character's center
char_x = char.screen_x
char_y = char.screen_y - char_height/2
end
params = [char_height, char_width, char_x, char_y]
# position window and message tail
vars = new_position(params)
x = vars[0]
y = vars[1]
# check if any window locations need to be "flipped"
if @location == 4 && x < 0
# switch to right
@location = 6
vars = new_position(params)
x = vars[0]
if (x + self.width) > 640
# right is no good either...
if y >= 0
# switch to top
@location = 8
vars = new_position(params)
else
# switch to bottom
@location = 2
vars = new_position(params)
end
end
elsif @location == 6 && (x + self.width) > 640
# switch to left
@location = 4
vars = new_position(params)
x = vars[0]
if x < 0
# left is no good either...
if y >= 0
# switch to top
@location = 8
vars = new_position(params)
else
# switch to bottom
@location = 2
vars = new_position(params)
end
end
elsif @location == 8 && y < 0
# switch to bottom
@location = 2
vars = new_position(params)
y = vars[1]
if (y + self.height) > 480
# bottom is no good either...
# note: this will probably never occur given only 3 lines of text
x = vars[0]
if x >= 0
# switch to left
@location = 4
vars = new_position(params)
else
# switch to right
@location = 6
vars = new_position(params)
end
end
elsif @location == 2 && (y + self.height) > 480
# switch to top
@location = 8
vars = new_position(params)
y = vars[1]
if y < 0
# top is no good either...
# note: this will probably never occur given only 3 lines of text
x = vars[0]
if x >= 0
# switch to left
@location = 4
vars = new_position(params)
else
# switch to right
@location = 6
vars = new_position(params)
end
end
end
x = vars[0]
y = vars[1]
tail_x = vars[2]
tail_y = vars[3]
# adjust windows if near edge of screen
if x < 0
x = 0
elsif (x + self.width) > 640
x = 640 - self.width
end
if y < 0
y = 0
elsif (y + self.height) > 480
y = 480 - self.height
elsif $game_temp.in_battle && @location == 2 && (y > (320 - self.height))
# when in battle, prevent enemy messages from overlapping battle status
# (note that it could still happen from actor messages, though)
y = 320 - self.height
tail_y = y
end
# finalize positions
self.x = x
self.y = y
@tail.x = tail_x
@tail.y = tail_y
end

#--------------------------------------------------------------------------
# * Determine New Window Position
#--------------------------------------------------------------------------
def new_position(params)
char_height = params[0]
char_width = params[1]
char_x = params[2]
char_y = params[3]
if @location == 8
# top
x = char_x - self.width/2
y = char_y - char_height/2 - self.height - @tail.bitmap.height/2
@tail.bitmap.rotation(0)
tail_x = x + self.width/2
tail_y = y + self.height
elsif @location == 2
# bottom
x = char_x - self.width/2
y = char_y + char_height/2 + @tail.bitmap.height/2
@tail.bitmap.rotation(180)
tail_x = x + self.width/2
tail_y = y
elsif @location == 4
# left
x = char_x - char_width/2 - self.width - @tail.bitmap.width/2
y = char_y - self.height/2
@tail.bitmap.rotation(270)
tail_x = x + self.width
tail_y = y + self.height/2
elsif @location == 6
# right
x = char_x + char_width/2 + @tail.bitmap.width/2
y = char_y - self.height/2
@tail.bitmap.rotation(90)
tail_x = x
tail_y = y + self.height/2
end
return [x,y,tail_x,tail_y]
end

#--------------------------------------------------------------------------
# * Update Text
#--------------------------------------------------------------------------
def update_text
if @text != nil
# Get 1 text character in c (loop until unable to get text)
while ((c = @text.slice!(/./m)) != nil)
# If \\
if c == "\000"
# Return to original text
c = "\\"
end
# If \C[n] or \C[#xxxxxx] or \C
if c == "\001"
# Change text color
@text.sub!(/\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/, '')
if $1 != nil
self.contents.font.color = check_color($1)
else
# return to default color
if $game_system.message.font_color != nil
color = check_color($game_system.message.font_color)
elsif $game_system.message.floating && $game_system.message.resize
color = check_color(SPEECH_FONT_COLOR)
else
# use defaults
color = Font.default_color
end
self.contents.font.color = color
end
# go to next text
next
end
# If \G
if c == "\002"
# Make gold window
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# go to next text
next
end
# If \L
if c == "\003"
# toggle letter-by-letter mode
@letter_by_letter = !@letter_by_letter
# go to next text
next
end
# If \S[n]
if c == "\004"
@text.sub!(/\[([0-9]+)\]/, '')
speed = $1.to_i
if speed >= 0
@text_speed = speed
# reset player skip after text speed change
@player_skip = false
end
return
end
# If \D[n]
if c == "\005"
@text.sub!(/\[([0-9]+)\]/, '')
delay = $1.to_i
if delay >= 0
@delay += delay
# reset player skip after delay
@player_skip = false
end
return
end
# If \!
if c == "\006"
# close message and return from method
terminate_message
return
end
# If \?
if c == "\007"
@wait_for_input = true
return
end
if c == "\010"
# bold
self.contents.font.bold = !self.contents.font.bold
return
end
if c == "\011"
# italics
self.contents.font.italic = !self.contents.font.italic
return
end
if c == "\013"
# display icon of item, weapon, armor or skill
@text.sub!(/\[([IiWwAaSs])([0-9]+)\]/, '')
case $1.downcase
when 'i'
item = $data_items[$2.to_i]
when 'w'
item = $data_weapons[$2.to_i]
when 'a'
item = $data_armors[$2.to_i]
when 's'
item = $data_skills[$2.to_i]
end
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(4+@x, 32*@y+4, bitmap, Rect.new(0, 0, 24, 24))
@x += 24
#self.contents.draw_text(x + 28, y, 212, 32, item.name)
return
end
# If new line text
if c == "\n"
# Update cursor width if choice
if @y >= $game_temp.choice_start
width = $game_system.message.autocenter ? @line_widths[@y]+8 : @x
@cursor_width = [@cursor_width, width].max
end
# Add 1 to y
@y += 1
if $game_system.message.autocenter && @text != ''
@x = (self.width-40)/2 - @line_widths[@y]/2
else
@x = 0
# Indent if choice
if @y >= $game_temp.choice_start
@x = 8
end
end
# go to next text
next
end
# Draw text
self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
# Add x to drawn text width
@x += self.contents.text_size( c ).width
# add text speed to time to display next character
@delay += @text_speed unless !@letter_by_letter || @player_skip
return if @letter_by_letter && !@player_skip
end
end
# If choice
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# If number input
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.set_font(@font_name, @font_size, @font_color)
@input_number_window.number = number
@input_number_window.x =
if $game_system.message.autocenter
offset = (self.width-40)/2-@line_widths[$game_temp.num_input_start]/2
self.x + offset + 4
else
self.x + 8
end
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
@update_text = false
end

def reset_window
if $game_temp.in_battle
self.y = 16
else
case $game_system.message_position
when 0 # up
self.y = 16
when 1 # middle
self.y = 160
when 2 # down
self.y = 304
end
end
if $game_system.message_frame == 0
self.opacity = 255
else
self.opacity = 0
end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# transparent speech balloons don't look right, so keep opacity at 255
# self.back_opacity = 160
@tail.opacity = 255
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end

def update
super
# If fade in
if @fade_in
self.contents_opacity += 24
if @input_number_window != nil
@input_number_window.contents_opacity += 24
end
if self.contents_opacity == 255
@fade_in = false
end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# return
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
# If inputting number
if @input_number_window != nil
@input_number_window.update
# Confirm
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[$game_temp.num_input_variable_id] =
@input_number_window.number
$game_map.need_refresh = true
# Dispose of number input window
@input_number_window.dispose
@input_number_window = nil
terminate_message
end
return
end
# If message is being displayed
if @contents_showing
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# Confirm or cancel finishes waiting for input or message
if Input.trigger?(Input::C) || Input.trigger?(Input::B)
if @wait_for_input
@wait_for_input = false
self.pause = false
elsif $game_system.message.skippable
@player_skip = true
end
end
if need_reposition?
reposition # update message position for character/screen movement
if @contents_showing == false
# i.e. if char moved off screen
return
end
end
if @update_text && !@wait_for_input
if @delay == 0
update_text
else
@delay -= 1
end
return
end

# If choice isn't being displayed, show pause sign
if !self.pause && ($game_temp.choice_max == 0 || @wait_for_input)
self.pause = true unless !$game_system.message.show_pause
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
# Cancel
if Input.trigger?(Input::B)
if $game_temp.choice_max > 0 && $game_temp.choice_cancel_type > 0
$game_system.se_play($data_system.cancel_se)
$game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
terminate_message
end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# personal preference: cancel button should also continue
terminate_message
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
# Confirm
if Input.trigger?(Input::C)
if $game_temp.choice_max > 0
$game_system.se_play($data_system.decision_se)
$game_temp.choice_proc.call(self.index)
end
terminate_message
end
return
end
# If display wait message or choice exists when not fading out
if @fade_out == false && $game_temp.message_text[@msgindex] != nil
@contents_showing = true
$game_temp.message_window_showing = true
reset_window
refresh
Graphics.frame_reset
self.visible = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
if show_message_tail?
@tail.visible = true
elsif @tail.visible
@tail.visible = false
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
self.contents_opacity = 0
if @input_number_window != nil
@input_number_window.contents_opacity = 0
end
@fade_in = true
return
end
# If message which should be displayed is not shown, but window is visible
if self.visible
@fade_out = true
self.opacity -= 96
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
@tail.opacity -= 96 if @tail.opacity > 0
if need_reposition?
reposition # update message position for character/screen movement
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
if self.opacity == 0
self.visible = false
@fade_out = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
@tail.visible = false if @tail.visible
# have to check all windows before claiming that no window is showing
if $game_temp.message_text.compact.empty?
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
$game_temp.message_window_showing = false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
return
end
end

#--------------------------------------------------------------------------
# * Repositioning Determination
#--------------------------------------------------------------------------
def need_reposition?
if !$game_temp.in_battle && $game_system.message.floating &&
$game_system.message.resize && @float_id != nil
if $game_system.message.move_during && @float_id == 0 &&
(($game_player.last_real_x != $game_player.real_x) ||
($game_player.last_real_y != $game_player.real_y))
# player with floating message moved
# (note that relying on moving? leads to "jumpy" message boxes)
return true
elsif ($game_map.last_display_y != $game_map.display_y) ||
($game_map.last_display_x != $game_map.display_x)
# player movement or scroll event caused the screen to scroll
return true
else
char = $game_map.events[@float_id]
if char != nil &&
((char.last_real_x != char.real_x) ||
(char.last_real_y != char.real_y))
# character moved
return true
end
end
end
return false
end

#--------------------------------------------------------------------------
# * Show Message Tail Determination
#--------------------------------------------------------------------------
def show_message_tail?
if $game_system.message.show_tail && $game_system.message.floating &&
$game_system.message.resize && $game_system.message_frame == 0 &&
@float_id != nil
return true
end
return false
end

def update_cursor_rect
if @index >= 0
n = $game_temp.choice_start + @index
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
if $game_system.message.autocenter
x = 4 + (self.width-40)/2 - @cursor_width/2
else
x = 8
end
self.cursor_rect.set(x, n * 32, @cursor_width, 32)
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
else
self.cursor_rect.empty
end
end

end

#------------------------------------------------------------------------------

class Game_Character
attr_reader :last_real_x # last map x-coordinate
attr_reader :last_real_y # last map y-coordinate
alias wachunga_game_char_update update
def update
@last_real_x = @real_x
@last_real_y = @real_y
wachunga_game_char_update
end
end

#------------------------------------------------------------------------------

class Game_Temp
alias wachunga_mmw_game_temp_initialize initialize
def initialize
wachunga_mmw_game_temp_initialize
@message_text = []
@message_proc = []
end
end

#------------------------------------------------------------------------------

class Sprite_Battler < RPG::Sprite
# necessary for positioning messages relative to battlers
attr_reader :height
attr_reader :width
end

#------------------------------------------------------------------------------

class Scene_Battle
# necessary for accessing actor/enemy sprites in battle
attr_reader :spriteset
end

#------------------------------------------------------------------------------

class Spriteset_Battle
# necessary for accessing actor/enemy sprites in battle
attr_reader :actor_sprites
attr_reader :enemy_sprites
end

#------------------------------------------------------------------------------

class Scene_Map

#--------------------------------------------------------------------------
# * New Message Window Addition
#--------------------------------------------------------------------------
def new_message_window(index)
if @message_window[index] != nil
# clear message windows at and after this index
last_index = @message_window.size - 1
last_index.downto(index) { |i|
if @message_window[i] != nil
@message_window[i].dispose
@message_window[i] = nil
end
}
@message_window.compact!
end
@message_window.push(Window_Message.new(index))
end

end

#------------------------------------------------------------------------------

class Scene_Battle

#--------------------------------------------------------------------------
# * New Message Window Addition
#--------------------------------------------------------------------------
def new_message_window(index)
if @message_window[index] != nil
# clear message windows at and after this index
last_index = @message_window.size - 1
last_index.downto(index) { |i|
if @message_window[i] != nil
@message_window[i].dispose
@message_window[i] = nil
end
}
@message_window.compact!
end
@message_window.push(Window_Message.new(index))
end

end

#------------------------------------------------------------------------------

class Game_System
attr_reader :message

alias wachunga_mmw_game_system_init initialize
def initialize
wachunga_mmw_game_system_init
@message = Game_Message.new
end

# Zer0 Edit
alias zer0_shaded_text_fix_upd update
def update
zer0_shaded_text_fix_upd
if @SHADED_TEXT != nil && Blizzard_Shaded_Text_Fix == true
if $game_temp.message_window_showing
@SHADED_TEXT = false
else
@SHADED_TEXT = true
end
end
end
end

#------------------------------------------------------------------------------

class Game_Player < Game_Character # Zer0 edit

# Redefines the update method
def update
# Remember whether or not moving in local variables
last_moving = moving?
# If moving, event running, move route forcing, and message window
# display are all not occurring
unless moving? ||
@move_route_forcing ||
($game_system.map_interpreter.running? &&
!$game_temp.message_window_showing) ||
($game_temp.message_window_showing &&
!$game_system.message.move_during) ||
($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0)
# Move player in the direction the directional button is being pressed
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# Remember coordinates in local variables
last_real_x = @real_x
last_real_y = @real_y
super
# If character moves down and is positioned lower than the center
# of the screen
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Scroll map down
$game_map.scroll_down(@real_y - last_real_y)
end
# If character moves left and is positioned more let on-screen than
# center
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Scroll map left
$game_map.scroll_left(last_real_x - @real_x)
end
# If character moves right and is positioned more right on-screen than
# center
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Scroll map right
$game_map.scroll_right(@real_x - last_real_x)
end
# If character moves up and is positioned higher than the center
# of the screen
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Scroll map up
$game_map.scroll_up(last_real_y - @real_y)
end
# If not moving
unless moving?
# If player was moving last time
if last_moving
# Event determinant is via touch of same position event
result = check_event_trigger_here([1,2])
# If event which started does not exist
if result == false
# Disregard if debug mode is ON and ctrl key was pressed
unless $DEBUG and Input.press?(Input::CTRL)
# Encounter countdown
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# If C button was pressed
if Input.trigger?(Input::C)
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end

#--------------------------------------------------------------------------
# * Touch Event Starting Determinant
#--------------------------------------------------------------------------
# This is a fix if Blizzard's Optimized default scripts are being used

def check_event_trigger_touch(x, y)
result = false # <--------- MOVED from....
# If event is running
if $game_system.map_interpreter.running?
return result
end
#result = false # <--------- ...HERE
# All event loops
$game_map.events.each_value {|event|
# If event coordinates and triggers are consistent
if event.x == x && event.y == y && [1,2].include?(event.trigger)
# If starting determinant is front event (other than jumping)
if !event.jumping? && !event.over_trigger?
event.start
result = true
end
end
}
return result
end

end

#------------------------------------------------------------------------------
class Interpreter
attr_reader :event_id

alias wachunga_mmw_interp_setup setup
def setup(list, event_id)
wachunga_mmw_interp_setup(list, event_id)
# index of window for the message
@msgindex = 0
# whether multiple messages are displaying
@multi_message = false
end

def setup_choices(parameters)
# Set choice item count to choice_max
$game_temp.choice_max = parameters[0].size
# Set choice to message_text
parameters[0].each {|text| $game_temp.message_text[@msgindex] += text + "\n"}
# Set cancel processing
$game_temp.choice_cancel_type = parameters[1]
# Set callback
current_indent = @list[@index].indent
$game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
end

#--------------------------------------------------------------------------
# * Show Text
#--------------------------------------------------------------------------
def command_101
# If other text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
if $game_temp.message_text[@msgindex] != nil
if @multi_message
@msgindex += 1
$scene.new_message_window(@msgindex)
else
# End
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
return false
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
end
@msgindex = 0 if !@multi_message
@multi_message = false
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
# Set message end waiting flag and callback
@message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# just adding indexes
$game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
# Set message text on first line
$game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
line_count = 1
# Loop
loop do
# If next event command text is on the second line or after
if @list[@index+1].code == 401
# Add the second line or after to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# just adding index
$game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
line_count += 1
# If event command is not on the second line or after
else
# If next event command is show choices
if @list[@index+1].code == 102
# If choices fit on screen
if @list[@index+1].parameters[0].size <= 4 - line_count
# Advance index
@index += 1
# Choices setup
$game_temp.choice_start = line_count
setup_choices(@list[@index].parameters)
end
# If next event command is input number
elsif @list[@index+1].code == 103
# If number input window fits on screen
if line_count < 4
# Advance index
@index += 1
# Number input setup
$game_temp.num_input_start = line_count
$game_temp.num_input_variable_id = @list[@index].parameters[0]
$game_temp.num_input_digits_max = @list[@index].parameters[1]
end
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# start multimessage if next line is "Show Text" starting with "\\+"
elsif @list[@index+1].code == 101
if @list[@index+1].parameters[0][0..1]=="\\+"
@multi_message = true
@message_waiting = false
end
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
end
# Continue
return true
end
# Advance index
@index += 1
end
end

#--------------------------------------------------------------------------
# * Show Choices
#--------------------------------------------------------------------------
def command_102
# If text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# just adding index
if $game_temp.message_text[@msgindex] != nil
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
# End
return false
end
# Set message end waiting flag and callback
@message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# adding more indexes
$game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
# Choices setup
$game_temp.message_text[@msgindex] = ''
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
$game_temp.choice_start = 0
setup_choices(@parameters)
# Continue
return true
end

#--------------------------------------------------------------------------
# * Input Number
#--------------------------------------------------------------------------
def command_103
# If text has been set to message_text
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# just adding index
if $game_temp.message_text[@msgindex] != nil
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
# End
return false
end
# Set message end waiting flag and callback
@message_waiting = true
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
# adding more indexes
$game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
# Number input setup
$game_temp.message_text[@msgindex] = ''
#------------------------------------------------------------------------------
# End Multiple Message Windows Edit
#------------------------------------------------------------------------------
$game_temp.num_input_start = 0
$game_temp.num_input_variable_id = @parameters[0]
$game_temp.num_input_digits_max = @parameters[1]
# Continue
return true
end

#--------------------------------------------------------------------------
# * Script
#--------------------------------------------------------------------------
# Fix for RMXP bug: call script boxes that return false hang the game
# See, e.g., http://rmxp.org/forums/showthread.php?p=106639
#--------------------------------------------------------------------------
def command_355
# Set first line to script
script = @list[@index].parameters[0] + "\n"
# Loop
loop do
# If next event command is second line of script or after
if @list[@index+1].code == 655
# Add second line or after to script
script += @list[@index+1].parameters[0] + "\n"
# If event command is not second line or after
else
# Abort loop
break
end
# Advance index
@index += 1
end
# Evaluation
result = eval(script)
# If return value is false
if result == false
# End
#------------------------------------------------------------------------------
# Begin Edit
#------------------------------------------------------------------------------
#return false
#------------------------------------------------------------------------------
# End Edit
#------------------------------------------------------------------------------
end
# Continue
return true
end

def message
message = $game_system.message if $game_system != nil
end

end

#------------------------------------------------------------------------------

class Game_Map
attr_accessor :last_display_x # last display x-coord * 128
attr_accessor :last_display_y # last display y-coord * 128

alias wachunga_mmw_game_map_update update
def update
@last_display_x = @display_x
@last_display_y = @display_y
wachunga_mmw_game_map_update
end

def name
return load_data('Data/MapInfos.rxdata')[@map_id].name
end
end

#------------------------------------------------------------------------------

class Bitmap

attr_accessor :orientation

#--------------------------------------------------------------------------
# * Rotation Calculation
#--------------------------------------------------------------------------
def rotation(target)
return if not [0, 90, 180, 270].include?(target) # invalid orientation
if @rotation != target
degrees = target - @orientation
if degrees < 0
degrees += 360
end
rotate(degrees)
end
end

#--------------------------------------------------------------------------
# * Rotate Square (Clockwise)
#--------------------------------------------------------------------------
def rotate(degrees = 90)
# method originally by SephirothSpawn
# would just use Sprite.angle but its rotation is buggy
# (see http://www.rmxp.org/forums/showthread.php?t=12044)
return if not [90, 180, 270].include?(degrees)
copy = self.clone
if degrees == 90
# Passes Through all Pixels on Dummy Bitmap
(0...self.height).each {|i|
(0...self.width).each {|j|
self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))
}
}
elsif degrees == 180
(0...self.height).each {|i|
(0...self.width).each {|j|
self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))
}
}
elsif degrees == 270
(0...self.height).each {|i|
(0...self.width).each {|j|
self.set_pixel(i, height - j - 1, copy.get_pixel(j, i))
}
}
end
@orientation = (@orientation + degrees) % 360
end

end

#------------------------------------------------------------------------------

class Window_Base

#--------------------------------------------------------------------------
# * Check Color
# color : color to check
#--------------------------------------------------------------------------
def check_color(color)
if color.type == Color
# already a Color object
return color
elsif color[0].chr == "#"
# specified as hexadecimal
r = color[1..2].hex
g = color[3..4].hex
b = color[5..6].hex
return Color.new(r,g,b)
else
# specified as integer (0-7)
color = color.to_i
if color >= 0 && color <= 7
return text_color(color)
end
end
return normal_color
end

end

#------------------------------------------------------------------------------

class Window_InputNumber < Window_Base

def set_font(fname, fsize, fcolor)
return if fname == nil && fsize == nil && fcolor == nil
# Calculate cursor width from number width
dummy_bitmap = Bitmap.new(32, 32)
dummy_bitmap.font.name = fname
dummy_bitmap.font.size = fsize
@cursor_width = dummy_bitmap.text_size('0').width + 8
dummy_bitmap.dispose
self.width = @cursor_width * @digits_max + 32
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = fname
self.contents.font.size = fsize
self.contents.font.color = check_color(fcolor)
refresh
update_cursor_rect
end

def refresh
self.contents.clear
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
#self.contents.font.color = normal_color
#------------------------------------------------------------------------------
# Begin Multiple Message Windows Edit
#------------------------------------------------------------------------------
s = sprintf("%0*d", @digits_max, @number)
(0...@digits_max).each {|i|
self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
}
end

end
[/spoiler]
Basically I enter a battle and then these errors pop up I would appreciate any help.

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 0

I am confused; did you change your battle system script or try to mix and match battle system scripts? (if you tried to mix and match, I hate to tell you, but it unfortunately will not work like that...well there is a possibility but the chances are slim to none....and most likely none)

 

However if that is NOT the case, what are the errors that pop up? Script error messages can generally tell you exactly what is wrong.

Share this post


Link to post
Share on other sites
  • 0

I am confused; did you change your battle system script or try to mix and match battle system scripts? (if you tried to mix and match, I hate to tell you, but it unfortunately will not work like that...well there is a possibility but the chances are slim to none....and most likely none)

 

However if that is NOT the case, what are the errors that pop up? Script error messages can generally tell you exactly what is wrong.

 

No I did not try to mix and match and the errors are posted inside the spoilers next to the bolded line(s) that the thing says is giving me the error. I believe the problem is something to do with the messages both scripts are trying to create different types of messages and therefore I'm getting an error. I was wondering how can I fix that so only 1 shows which I tried to do but then got an error on the second script I posted which had changes to it because of the third script I posted.

 

Does that clarify some?

Share this post


Link to post
Share on other sites
  • 0

Try changing this line in the first script

 

@message_window = Window_Message.new

 

to

 

@message_window = Window_Message.new(0)

 

 

The multiple message window requires an index number as an argument

 

EDIT: yea sorry I never realized you put the error messages in the scripts XD

 

lemme know how it works

Share this post


Link to post
Share on other sites
  • 0

Try changing this line in the first script

 

@message_window = Window_Message.new

 

to

 

@message_window = Window_Message.new(0)

 

 

The multiple message window requires an index number as an argument

 

EDIT: yea sorry I never realized you put the error messages in the scripts XD

 

lemme know how it works

 

Script Scene Battle 1 line 249 (This is the same line that had the second problem in the second script I posted) NoMethodError occured.

undefined method each for #< Window_Mesage0x987b0e8>.

No problem I should a mentioned they were in there and thanks for helping.

Edited by Dragon324

Share this post


Link to post
Share on other sites
  • 0

Not this again!!!! Why me!? lol Anyway I'm getting this now in Scene_Battle1:

Script Scene Battle1 line 229 NoMethodError occurred

undefined method 'need refresh' for #<Window_Battle Status0x9e3c610>

Line 229= if @phase != 5 && @status_window.need_refresh

Note I only get this error when there is text during a battle which I need to be able to do for tutorial and story line purposes.

Edited by Dragon324

Share this post


Link to post
Share on other sites
  • 0

Well, I can tell you exactly WHY you are getting this error:

Window_BattleStatus (default script) DOES NOT, have a need_refresh method; and as far as I can see, none of your scripts overwrite that class to add that method.

Why that is there? I have NO idea (did you put that there or did that just come with the script you are using?). just delete that part of the if statement.

sooo

if @phase != 5 && @status_window.need_refresh

becomes

if @phase != 5

Share this post


Link to post
Share on other sites
  • 0

Well, I can tell you exactly WHY you are getting this error:

Window_BattleStatus (default script) DOES NOT, have a need_refresh method; and as far as I can see, none of your scripts overwrite that class to add that method.

Why that is there? I have NO idea (did you put that there or did that just come with the script you are using?). just delete that part of the if statement.

sooo

if @phase != 5 && @status_window.need_refresh

becomes

if @phase != 5

Yea that fixed it thanks I'll post any more problems I get (Bound to be some) and no I did not put that there it musta came with the changes I had to make because of that other script. Well thanks again until next time :P.

Share this post


Link to post
Share on other sites
  • 0

cool no worries :)

 

Although I wonder why whoever made the changes thought to do that...no existing battle status windows (well within your scripts at least) have a flag to see if it needs refreshing. The only place I have seen something like that in is the default Game_Map class :/

 

It should probably be fine, but if you come across anymore just post em :P

Share this post


Link to post
Share on other sites
  • 0

cool no worries :)

 

Although I wonder why whoever made the changes thought to do that...no existing battle status windows (well within your scripts at least) have a flag to see if it needs refreshing. The only place I have seen something like that in is the default Game_Map class :/

 

It should probably be fine, but if you come across anymore just post em :P

Ohh kell lol theres another freaking problem.

Script Sideview2 line93: NoMethodError occured.

undefined method 'dispose' for

[#<Windows_Message0x63ec100>]: Array

Here is line 93: @message_window.dispose

Told you there would be more problems lol.

Share this post


Link to post
Share on other sites
  • 0

Ohh kell lol theres another freaking problem.

Script Sideview2 line93: NoMethodError occured.

undefined method 'dispose' for

[#<Windows_Message0x63ec100>]: Array

Here is line 93: @message_window.dispose

Told you there would be more problems lol.

 

Read the instructions for the MMS script. The edits made there that you are supposed to apply to your Scene_Map and Scene_Battle class must be applied to any script that overwrites them. Just find the same lines in your Sideview script that are in the default scripts and change them like what is explained.

Share this post


Link to post
Share on other sites
  • 0

Read the instructions for the MMS script. The edits made there that you are supposed to apply to your Scene_Map and Scene_Battle class must be applied to any script that overwrites them. Just find the same lines in your Sideview script that are in the default scripts and change them like what is explained.

Yea I read that it kind of confused me and so didn't what you just posted. I'm not that smart when it comes to scripts but I will try what you suggested thanks.

Share this post


Link to post
Share on other sites
  • 0

Never mind the way it was worded in the file was confusing but when I add it to what you just said it makes perfect sense thanks.

Solved.

Share this post


Link to post
Share on other sites
  • 0
Ok So I have decided to add a bestiary into my game the only problem is 2 that I found wont work. I did find one now yay, but the only problem is it seems to have a glitch with in its self of something? Anyway after I finish a battle even when the item rate is set to %100 success rate I dont get it but the funny thing is it says I did when I look inside the bestiary ( It seems to make it read of off the default in the database). To make things worse even though it says keep under other scripts I for a test moved it to the very top, it finally gave me an item but then the bestiary doesn't work?
Code 1 that is not the bestiary but is required for it.
[spoiler]################################################################################
################################################################################
########################### Cold Module ########################################
################################################################################
################################################################################
#===============================================================================
# By Cold Strong
#===============================================================================
# Cold Module
#-------------------------------------------------------------------------------
# This script count some functions used by my scripts
# Obs: It is some imcomplete...
#===============================================================================

class Customs_Data

attr_accessor :actors
attr_accessor :classes
attr_accessor :skills
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
attr_accessor :enemies
attr_accessor :troops
attr_accessor :states
attr_accessor :animations
attr_accessor :tilesets
attr_accessor :common_events
attr_accessor :system
attr_accessor :map_infos
attr_accessor :maps

def initialize
@actors = load_data("Data/Actors.rxdata")
@classes = load_data("Data/Classes.rxdata")
@skills = load_data("Data/Skills.rxdata")
@items = load_data("Data/Items.rxdata")
@weapons = load_data("Data/Weapons.rxdata")
@armors = load_data("Data/Armors.rxdata")
@enemies = load_data("Data/Enemies.rxdata")
@troops = load_data("Data/Troops.rxdata")
@states = load_data("Data/States.rxdata")
@animations = load_data("Data/Animations.rxdata")
@tilesets = load_data("Data/Tilesets.rxdata")
@common_events = load_data("Data/CommonEvents.rxdata")
@system = load_data("Data/System.rxdata")
@maps = {}
for i in 1..999
number = sprintf("%03d", i)
if FileTest.exist?("Data/Map#{number}.rxdata")
@maps[i] = load_data("Data/Map#{number}.rxdata")
else
break
end
end
@map_infos = load_data("Data/MapInfos.rxdata")
end

def [](str)
return @customs_data[str]
end

end

module Cold

$data = Customs_Data.new

end

class Window_Base < Window


#--------------------------------------------------------------------------
# - Desenhar Gráfico
#
# t : Texto a ser feita as linhas
# width : Largura máxima da linha
#
# - Ele retorna uma array, em que cada elemento é uma string
# com a largura desejada.
#--------------------------------------------------------------------------

def lines(t, width)
text = t.clone
x = self.contents.text_size(text).width / width
x += 1 if self.contents.text_size(text).width % width > 0
texts = []
for i in 0...x
texts.push("")
end
for i in 0...texts.size
words = text.split(" ")
return_text = ""
for w in 0...words.size
word = words[w]
x = "!@$%¨&*()"
return_text += word + x + " "
return_text2 = return_text.gsub(x,"")
t_width = self.contents.text_size(return_text2).width
if t_width > width
texts[i] = return_text.gsub(" "+word+x, "")
text.gsub!(texts[i], "")
break
elsif w == words.size - 1
texts[i] = return_text.gsub(x+" ", "")
text.gsub!(texts[i], "")
break
else
return_text.gsub!(word+x, word)
end
end
end
return texts
end

def draw_text_in_lines(x, y_initial, width, height, text)
lines = lines(text, width)
y = y_initial
for text_line in lines
self.contents.draw_text(x, y, width, height, text_line)
y += height
end
end

end[/spoiler]
Code that is the actual bestiary
[spoiler]################################################################################
################################################################################
######################## Cold Books System #####################################
################################################################################
################################################################################
#===============================================================================
# By Cold Strong
#===============================================================================
# Bestiary and Item Book Script
#-------------------------------------------------------------------------------
# ***Necessary Cold Module
#===============================================================================
# How to use:
# To call the Items Menu:
# - $scene = Scene_ItemsBook.new
# To call the Bestiary Menu:
# - $scene = Bestiary.new
#-------------------------------------------------------------------------------
# Bugs: cold.strong@hotmail.com
#===============================================================================

$ColdScript ||= {}
$ColdScript["Books System"] = true

if $ColdScript["Books System"]
#===============================================================================
# Overall Customization
#===============================================================================
module Options
#-----------------------------------------------------------------------------
# Scope Information
#-----------------------------------------------------------------------------
SCOPE_INFO = ["Nothing", "Enemies", "All Enemies", "Ally", "All Alies",
"Ally (HP 0)", "All Allies (HP 0)", "Hero"]
#-----------------------------------------------------------------------------
# Treasure System Active? It's important that you disable if you'll not use it.
#-----------------------------------------------------------------------------
TREASURE_ACTIVE = true
#-----------------------------------------------------------------------------
# Name of the Atribute that the Treasure item have to has.
#-----------------------------------------------------------------------------
TREASURE_ATRIBUTE = "Treasure"
#-----------------------------------------------------------------------------
# Animated Background Picture (It must be in past: Graphics/Pictures)
#-----------------------------------------------------------------------------
COLD_MENU_PLANE = "title"

#=============================================================================
# Don't touch here
ENEMY_ITEMS = []
for i in 1...$data.enemies.size
ENEMY_ITEMS[i] = []
end
#=============================================================================

#-----------------------------------------------------------------------------
# Items dropped by monsters, to add a new item you have
# to use this code:
# Enemy_items[enemy_id].push([type, id, prob])
# -------------------------------
# enemy_id : ID of the enemy
# type : Kind of item (0:Item, 1:Weapon, 2:Armor)
# id : ID of the item
# prob : Probability of being dropped (%)
#-----------------------------------------------------------------------------
ENEMY_ITEMS[1].push( [0, 1, 100] )

#=============================================================================
# Don't touch here
ENEMY_DESCRIPTION = []
for i in 1...$data.enemies.size
ENEMY_DESCRIPTION[i] = ""
end
#=============================================================================

#-----------------------------------------------------------------------------
# Enemy Description, to customize:
# ENEMY_DESCRIPTION[enemy_id] = description
# -------------------------------
# enemy_id : ID of the enemy
# description : String with the description
#-----------------------------------------------------------------------------
ENEMY_DESCRIPTION[1] = "Regular Unexperienced soilders, mainly used for distractions."
ENEMY_DESCRIPTION[2] = "Regular slime. They can be found in many places."
#=============================================================================
# CUSTOMIZATION END
#=============================================================================
ENEMIES_ORDER = {}
ENEMIES_ORDER["By type"] = []
for i in 1...$data.enemies.size
ENEMIES_ORDER["By type"].push(i)
end
order = []
for i in 1...$data.enemies.size
order.push($data.enemies[i].name)
end
ENEMIES_ORDER["Alphabetical"] = order.sort
for i in 0...ENEMIES_ORDER["Alphabetical"].size
ENEMIES_ORDER["Alphabetical"][i] = order.index(ENEMIES_ORDER["Alphabetical"][i]) + 1
end
ITEMS_ORDER = {}
order = []
t_order = []
for i in 1...$data.items.size
t_order.push([0,i])
order.push($data.items[i].name)
end
for i in 1...$data.weapons.size
t_order.push([1,i])
order.push($data.weapons[i].name)
end
for i in 1...$data.armors.size
t_order.push([2,i])
order.push($data.armors[i].name)
end
ITEMS_ORDER["By type"] = t_order
order_i = order.sort
for i in 0...order_i.size
index = order.index(order_i[i])
if index >= $data.items.size + $data.weapons.size - 2
type = 2
id = order.index(order_i[i]) + 3 - $data.items.size - $data.weapons.size
elsif index >= $data.items.size - 1
type = 1
id = order.index(order_i[i]) + 2 - $data.items.size
else
type = 0
id = order.index(order_i[i]) + 1
end
order[order.index(order_i[i])] = "nil!@$%"
order_i[i] = [type,id]
end
ITEMS_ORDER["Alphabetical"] = order_i
LAYOUTB = true
end

#==============================================================================
# Modulo RPG
#==============================================================================

module RPG

class Item
def treasure
treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
if @element_set.include?(treasure_i)
return true
end
return false
end
end

class Weapon
def treasure
treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
if @element_set.include?(treasure_i)
return true
end
return false
end
end

class Armor
def treasure
treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
if @guard_element_set.include?(treasure_i)
return true
end
return false
end
end

class Enemy
def items
@items ||= []
return @items
end
end

end

#==============================================================================
# Modulo Opções
#==============================================================================

module Options

for i in 1...$data.enemies.size
if $data.enemies[i].item_id > 0
item_id = $data.enemies[i].item_id
prob = $data.enemies[i].treasure_prob
$data.enemies[i].items.push([0,item_id,prob])
end
if $data.enemies[i].weapon_id > 0
item_id = $data.enemies[i].weapon_id
prob = $data.enemies[i].treasure_prob
$data.enemies[i].items.push([1,item_id,prob])
end
if $data.enemies[i].armor_id > 0
item_id = $data.enemies[i].armor_id
prob = $data.enemies[i].treasure_prob
$data.enemies[i].items.push([1,item_id,prob])
end
unless ENEMY_ITEMS[i].nil?
for item in ENEMY_ITEMS[i]
$data.enemies[i].items.push(item)
end
end
end

end

#==============================================================================
# Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler

#--------------------------------------------------------------------------
# - Selecionar items que podem dropar
#--------------------------------------------------------------------------

def items
return $data.enemies[@enemy_id].items
end

#--------------------------------------------------------------------------
# - Informação para o Bestiário
#--------------------------------------------------------------------------

def info
if @info.new
@info = Game_Info_Enemy.new(id)
end
end
end

#==============================================================================
# Window_BattleResult
#------------------------------------------------------------------------------
# Esta janela exibe os tesouros e o dinheiro ganho após uma batalha.
#==============================================================================

class Window_BattleResult < Window_Base

#--------------------------------------------------------------------------
# - Inicialização dos Objetos
#
# exp : EXP
# gold : quantidade de dinheiro
# treasures : tesouros
#--------------------------------------------------------------------------

def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
x = treasures.uniq
super(0, 0, 320, [x.size, 7].min * 32 + 64)
self.width = [(x.size + 7) / 7 * 320, 640].min
self.x = (640 - self.width) / 2
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 160 - height / 2
self.back_opacity = 160
self.visible = false
refresh
end

#--------------------------------------------------------------------------
# - Atualização
#--------------------------------------------------------------------------

def refresh
self.contents.clear
x = ((self.width - 32) - 246) / 2
self.contents.font.color = normal_color
cx = contents.text_size(@exp.to_s).width
self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
x += cx + 4
self.contents.font.color = system_color
cx = contents.text_size("EXP").width
self.contents.draw_text(x, 0, 64, 32, "EXP")
x += cx + 16
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = system_color
self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
i = 0
t = @treasures.uniq
for item in t
number = @treasures.rindex(item) + 1
@treasures.delete(item)
x = i / 7 * (320 - 16) + 4
y = i % 7 * 32 + 32
draw_item_name(item, x, y)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
i += 1
end
end
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle

#--------------------------------------------------------------------------
# - Processamento Principal
#--------------------------------------------------------------------------

alias cold_menu_main main
def main
troop = $data.troops[$game_temp.battle_troop_id]
map_name = $data.map_infos[$game_map.map_id].name
$game_system.maps_battled.push(map_name)
for enemy in troop.members
$game_system.info_enemy(enemy.enemy_id).battled += 1
unless $game_system.info_enemy(enemy.enemy_id).habitat.include?(map_name)
$game_system.info_enemy(enemy.enemy_id).habitat.push(map_name)
end
end
cold_menu_main
end

#--------------------------------------------------------------------------
# - Fim da Batalha
#
# result : resultado (0=vitória, 1=derrota e 2=fuga)
#--------------------------------------------------------------------------

alias cold_menu_battle_end battle_end
def battle_end(result)
for enemy in $game_troop.enemies
if enemy.dead?
$game_system.info_enemy(enemy.id).killed += 1
end
end
$actor_index = nil
cold_menu_battle_end(result)
end

#--------------------------------------------------------------------------
# - Atualização do Frame
#--------------------------------------------------------------------------

alias cold_menu_update update
def update
$actor_index = @actor_index
unless @active_battler.nil?
$actor_index = @active_battler.index
end
cold_menu_update
end

#--------------------------------------------------------------------------
# - Atualização do Frame (Fase de Pós-Batalha)
#--------------------------------------------------------------------------

def start_phase5
# Alternar para a fase 5
@phase = 5
# Reproduzir ME de fim de Batalha
$game_system.me_play($game_system.battle_end_me)
# Retornar para BGM de antes da Batalha ser iniciada
$game_system.bgm_play($game_temp.map_bgm)
# Inicializar EXP, quantidade de dinheiro e tesouros
exp = 0
gold = 0
treasures = []
# Loop
for enemy in $game_troop.enemies
# Se o Inimigo não estiver escondido
unless enemy.hidden
# Adicionar a EXP e a quantidade de dinheiro obtidos
exp += enemy.exp
gold += enemy.gold
# Determinar se aparece algum tesouro
for item in enemy.items
if rand(100) < item[2]
case item[0]
when 0
treasures.push($data_items[item[1]])
$game_system.info_enemy(enemy.id).gained_item(item[1])
when 1
treasures.push($data_weapons[item[1]])
$game_system.info_enemy(enemy.id).gained_weapon(item[1])
when 2
treasures.push($data_armors[item[1]])
$game_system.info_enemy(enemy.id).gained_armor(item[1])
end
end
end
end
end
old_treasures = [] + treasures
treasures.clear
i = 0
for treasure in old_treasures
treasures[i] = Array.new(old_treasures.rindex(treasure), treasure)
old_treasures.delete(treasure)
i += 1
end
# o Limite de tesouros é de 14 Itens
treasures = treasures[0..13]
treasures.flatten!
# Obtendo a EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# Obtendo o dinheiro
$game_party.gain_gold(gold)
# Obtendo os tesouros
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# Criar janela de resultado de Batalha
@result_window = Window_BattleResult.new(exp, gold, treasures)
# Definir Espera
@phase5_wait_count = 100
end
end

#==============================================================================
# Game_Info_Enemy
#==============================================================================

class Game_Info_Enemy

attr_accessor :battled
attr_accessor :killed
attr_reader :id
attr_reader :name
attr_reader :items
attr_reader :armors
attr_reader :weapons
attr_accessor :habitat
attr_reader :description

def initialize(id)
@battled = 0
@killed = 0
@enemy = $data_enemies[id]
@name = @enemy.name
@id = id
@items = {}
for i in 1...$data.items.size
@items[i] = 0
end
@weapons = {}
for i in 1...$data.weapons.size
@weapons[i] = 0
end
@armors = {}
for i in 1...$data.armors.size
@armors[i] = 0
end
@habitat = []
end

def exp
return @enemy.exp if @killed
end

def gold
return @enemy.gold if @killed
end

def gained_item(id)
@items[id] = @items[id] + 1
end

def gained_weapon(id)
@weapons[id] = @weapons[id] + 1
end

def gained_armor(id)
@armors[id] = @armors[id] + 1
end
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System

#--------------------------------------------------------------------------
# - Mapas que ocorreram batalhas
#--------------------------------------------------------------------------

def maps_battled
@maps_battled ||= []
return @maps_battled
end

#--------------------------------------------------------------------------
# - info_enemy(id)
#
# retorna as informações de um inimigo para ser usado no bestiario.
#--------------------------------------------------------------------------

def info_enemy(id)
if id > 999 or $data_enemies[id].nil?
return nil
end
@info_enemies ||= []
if @info_enemies[id].nil?
@info_enemies[id] = Game_Info_Enemy.new(id)
end
return @info_enemies[id]
end

#--------------------------------------------------------------------------
# - Item Obtidos
#--------------------------------------------------------------------------

def items_obtained
if @items_obtained.nil?
@items_obtained = []
for i in 1...$data_items.size
@items_obtained[i] = false
end
end
return @items_obtained
end

#--------------------------------------------------------------------------
# - Equipamentos de def. obtidos
#--------------------------------------------------------------------------

def armors_obtained
if @armors_obtained.nil?
@armors_obtained = []
for i in 1...$data_armors.size
@armors_obtained[i] = false
end
end
return @armors_obtained
end

#--------------------------------------------------------------------------
# - Armas obtidas
#--------------------------------------------------------------------------

def weapons_obtained
if @weapons_obtained.nil?
@weapons_obtained = []
for i in 1...$data_weapons.size
@weapons_obtained[i] = false
end
end
return @weapons_obtained
end

#--------------------------------------------------------------------------
# - Hash para armazenar dados
#--------------------------------------------------------------------------

def save_hash
@save_hash ||= {}
return @save_hash
end
end

#==============================================================================
# Game_Party
#==============================================================================

class Game_Party

alias cold_bs_gain_item gain_item
def gain_item(id, n)
$game_system.items_obtained[id] = true
cold_bs_gain_item(id, n)
end

alias cold_bs_gain_armor gain_armor
def gain_armor(id, n)
$game_system.armors_obtained[id] = true
cold_bs_gain_armor(id, n)
end

alias cold_bs_gain_weapon gain_weapon
def gain_weapon(id, n)
$game_system.weapons_obtained[id] = true
cold_bs_gain_weapon(id, n)
end
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor

alias cold_bs_setup setup
def setup(id)
cold_bs_setup(id)
$game_system.weapons_obtained[@weapon_id] = true
$game_system.armors_obtained[armor1_id] = true
$game_system.armors_obtained[armor2_id] = true
$game_system.armors_obtained[armor3_id] = true
$game_system.armors_obtained[armor4_id] = true
end

end

#==============================================================================
# Window_BookCommand
#==============================================================================

class Window_BookCommand < Window_Base

attr_reader :index

def initialize
super(0,0,128+32,64)
self.contents = Bitmap.new(640-32,480-32)
self.contents.font.size = 14
self.contents.font.color = normal_color
self.z = 999999
self.opacity = 0
@line_max = 12
@column_max = 2
@index = 0
@type_index = 0
@item_max = 0
@type_max = 0
end

def command
return @commands[@index]
end

def type
return @types[@type_index]
end

def refresh(text,types, commands)
self.contents.clear
self.height = commands.size*22 + 86 + 24
self.x = (640-self.width)/2
if Options::LAYOUTB
self.y = 50+48
else
self.y = (480-self.height)/2
end
self.contents = Bitmap.new(128, commands.size*22+54+24)
self.contents.font.size = 14
self.contents.font.color = normal_color
@types = types
@commands = commands
@item_max = commands.size
@type_max = types.size
for i in 0...commands.size
x = 0
y = i * 22 + 32 + 24
self.contents.draw_text(x,y,128,22,@commands[i],1)
end
width = define_width(@types)
x = (128-width)/2
self.contents.draw_text(x-22, 24, 14, 22, "??")
self.contents.draw_text(x+width+8, 24, 14, 22, "??")
self.contents.draw_text(x-22, 0, width - 20, 24, text,2)
draw_type
end

def define_width(array)
contents = Bitmap.new(640,480)
contents.font.size = 14
width = 0
for command in array
p_width = contents.text_size(command).width
if p_width > width
width = p_width
end
end
return [width, 128-44].max
end

def draw_type
if @type_index != @last_t_index
@last_t_index = @type_index
width = define_width(@types)
x = (128-width)/2
rect = Rect.new(x, 24, width, 22)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @types[@type_index],1)
end
end

def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if Input.trigger?(Input::DOWN) or @index < @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @item_max
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index >= 1
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1 + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@type_index = (@type_index + 1) % @type_max
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@type_index = (@type_index - 1) % @type_max
end
end
draw_type
update_cursor_rect
end

def update_cursor_rect
if @index < 0
self.cursor_rect.clear
return
end
y = @index * 22 + 32 + 24
self.cursor_rect.set(0, y, self.width-32, 22)
end
end

#==============================================================================
# Window_Book
#==============================================================================

class Window_Book < Window_Base

attr_reader :index

def initialize
super(0,0,160*2+32,12*22+37+32)
self.contents = Bitmap.new(640-32,480-32)
self.contents.font.size = 14
self.contents.font.color = normal_color
self.opacity = 0
self.x = (640 - self.width) / 2
self.y = (480 - (12*22+32)) / 2
self.z = 999999
self.active = false
self.visible = false
@line_max = 12
@column_max = 2
@item_max = 1
@page = 0
self.index = 0
commands = []
for i in 1..500
if $data.items[i].nil?
commands.push("???")
else
commands.push($data.items[i].name)
end
end
#refresh(commands)
end

def define_width(array)
contents = Bitmap.new(640,480)
contents.font.size = 14
width = 0
for command in array
p_width = contents.text_size(command).width
if p_width > width
width = p_width
end
end
return [width, 128-44].max
end

def index=(index)
@index = index
self.page = (@index/item_max_per_pag) if index >= 0
self.page = 0 if index < 0
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end

def page=(page)
@page = page
end

def page_max
page = (@item_max / (@column_max * @line_max))
page += 1 if (@item_max % (@column_max * @line_max)) > 0
return page
end

def item_max_per_pag
return (@column_max * @line_max)
end

def column_total
column_total = (@column_max * (page_max - 1))
i = [@item_max - item_max_per_pag, @column_max].min
column_total += i
return column_total
end

def show_page
self.ox = @page * (self.width - 32)
end

def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end

def refresh(commands)
self.contents.clear
@commands = commands
@item_max = commands.size
self.contents = Bitmap.new(160*2*[page_max, 1].max,height-32)
self.contents.font.size = 14
self.contents.font.color = normal_color
for i in 0...commands.size
x = i / 12 * 160
y = i % 12 * 22
self.contents.draw_text(x+4,y+4,160,18,@commands[i])
end
for pag in 0...page_max
rect = Rect.new(pag*320, 22*12+4, 320, 1)
self.contents.fill_rect(rect, normal_color)
x = (self.width-32)/2 + pag*320
y = 22*12+5
self.contents.draw_text(x-28-22, y, 14, 32, "??")
self.contents.draw_text(x+28, y, 14, 32, "??")
p = pag + 1
text = "Pag " + p.to_s + "/" + page_max.to_s
self.contents.draw_text(x-32, y, 56, 32, text, 1)
end
end

def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
show_page
x = @index / 12 * 160 - self.ox
y = @index % 12 * 22
self.cursor_rect.set(x, y, 160, 22)
end

def update
super
if self.active and @item_max > 0 and @index >= 0
x = @index - ((item_max_per_pag) * @page)
if Input.repeat?(Input::DOWN)
if @index % @line_max < @line_max - 1 and
@index + 1 < @item_max
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
if Input.repeat?(Input::UP)
if @index > 0 and @index % @line_max > 0
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
if Input.repeat?(Input::RIGHT)
if @index + @line_max < (@page+1) * item_max_per_pag and
@index / 24 == @page and @index + @line_max < @item_max
$game_system.se_play($data_system.cursor_se)
@index += @line_max
elsif ((@index / @line_max) % @column_max == @column_max - 1 and Input.trigger?(Input::RIGHT)) or
((@index / @line_max) % @column_max == @column_max - 1 and @page < page_max - 1)
$game_system.se_play($data_system.cursor_se)
if @page == page_max - 1
self.index = (@index + item_max_per_pag) % (page_max * item_max_per_pag)
else
self.index = [@index + item_max_per_pag, @item_max-1].min
end
end
end
if Input.repeat?(Input::LEFT)
if @index - @line_max >= @page * item_max_per_pag
$game_system.se_play($data_system.cursor_se)
@index -= @line_max
elsif ((@index / @line_max) % @column_max == 0 and Input.trigger?(Input::LEFT)) or
((@index / @line_max) % @column_max == 0 and @page > 0)
$game_system.se_play($data_system.cursor_se)
if @page == 0
#x = @index - 24
self.index = [@index + ((page_max - 1) * item_max_per_pag), @item_max-1].min
#self.index = [(page_max - 1) * item_max_per_pag - x, @item_max-1].min
else
self.index = [@index - item_max_per_pag, 0].max
end
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end

#==============================================================================
# Window_Enemy
#==============================================================================

class Window_Enemy < Window_Base

attr_reader :enemy_id

def initialize(enemy_id)
super(124,52,416,398-32)
self.opacity = 0
self.z = 1000
@self_active = true
self.active = false
self.visible = false
refresh(enemy_id)
end

def need_refresh?(killed)
return (@need_refresh[0] != killed)
end

def visible=(value)
super(value)
@view.visible = value unless @view.nil?
end

def dispose
super
@view.dispose = value unless @view.nil?
end

def refresh(enemy_id)
@enemy_id = enemy_id
@enemy = $game_system.info_enemy(enemy_id)
@index = 0
@items = []
for i in 1...$data.items.size
if @enemy.items[i] > 0
@items.push($data_items[i])
end
end
for i in 1...$data.weapons.size
if @enemy.weapons[i] > 0
@items.push($data_weapons[i])
end
end
for i in 1...$data.armors.size
if @enemy.armors[i] > 0
@items.push($data_armors[i])
end
end
@maps = @enemy.habitat
i_m = [@items.size, 6 - [@maps.size, 3].min].min
@max_items = [[[@items.size, 0].max, 6].min - @maps.size, i_m].max
m_m = [@maps.size, 6 - @max_items].min
@max_maps = [[[@maps.size, 0].max, 6].min - @items.size, m_m].max
@need_refresh = [0 + @enemy.killed,0 + @enemy.battled]
self.contents = Bitmap.new(416-32,398-64)
self.contents.font.size = 14
self.contents.font.color = normal_color
draw_name(0, 0)
draw_battler(0,22)
draw_exp(260, 22)
draw_gold(260, 44)
draw_killed(260, 66)
self.contents.draw_text(260, 88, 124, 18, "Obtained Items :")
rect = Rect.new(256,106,130,1)
self.contents.fill_rect(rect, normal_color)
draw_items(256, 107)
i_size = @max_items*21
self.contents.draw_text(260, 110+i_size, 124, 18, "Habitat:")
rect = Rect.new(256,128+i_size,130,1)
self.contents.fill_rect(rect, normal_color)
draw_maps(256, 129+i_size)
y = 67+67+23+23+88+4
if Options::ENEMY_DESCRIPTION[@enemy.id] != ""
self.contents.draw_text(4, y-20, 68, 22, "Description:")
rect = Rect.new(0, y-1, 68, 1)
self.contents.fill_rect(rect, normal_color)
end
draw_description(0,y)
end

def draw_name(x,y)
id = sprintf("%03d", @enemy.id.to_s)
name = id + ": " + @enemy.name
width = self.contents.text_size(name).width
self.contents.draw_text(x + 4, y, width, 22, name)
rect = Rect.new(x,y+19,width+8,1)
self.contents.fill_rect(rect, normal_color)
end

def draw_exp(x,y)
self.contents.draw_text(x, y, 64, 22, "Exp: ")
if @enemy.killed > 0
exp = @enemy.exp.to_s
self.contents.draw_text(x + 64, y, 60, 22, exp, 2)
else
self.contents.draw_text(x + 64, y, 60, 22, "???", 2)
end
end

def draw_gold(x,y)
g = $data_system.words.gold
self.contents.draw_text(x, y, 64, 22, g)
if @enemy.killed > 0
gold = @enemy.gold.to_s
self.contents.draw_text(x + 64, y, 60, 22, gold, 2)
else
self.contents.draw_text(x + 64, y, 60, 22, "???", 2)
end
end

def draw_killed(x,y)
self.contents.draw_text(x, y, 64, 22, "Defeated:")
#if @enemy.killed > 0
self.contents.draw_text(x + 64, y, 60, 22, @enemy.killed.to_s, 2)
#end
end

def draw_items(x,y)
@items_x = x
@items_y = y
@items_index = 0
@items_active = false
@items_oy = 0
y2 = 0
z = [@items.size * 21, (@max_items - 1)*21].min
for item in @items
if y2.between?(@items_oy, z)
draw_item(item, x+4, y + y2)
y2 += 21
end
end
end

def draw_item(item, x, y)
rect = Rect.new(x, y, 124, 21)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
name = item.name
self.contents.draw_text(x+2, y, 100, 20, name)
case item
when RPG::Item
number = @enemy.items[item.id]
when RPG::Weapon
number = @enemy.weapons[item.id]
when RPG::Armor
number = @enemy.armors[item.id]
end
self.contents.draw_text(x+104, y, 18, 20, number.to_s, 2)
rect = Rect.new(x, y + 20, 124, 1)
self.contents.fill_rect(rect, normal_color)
end

def refresh_items
row = @items_index
if row < @items_oy / 21
@items_oy = self.top_row(row, @items.size)
end
if row > @items_oy / 21 + (@max_items - 1)
@items_oy = self.top_row(row - (@max_items - 1), @items.size)
end
x = @items_x
y = @items_y
y2 = 0
y3 = 0
z = [@items.size * 21, (@max_items - 1)*21].min + @items_oy
for item in @items
if y2.between?(@items_oy, z)
draw_item(item, x+4, y + y3)
y3 += 21
end
y2 += 21
end
end

def draw_maps(x,y)
@maps_x = x
@maps_y = y
@maps_index = 0
@maps_active = false
@maps_oy = 0
y2 = 0
z = [@maps.size * 21, (@max_maps - 1)*21].min
for map in @maps
if y2.between?(@maps_oy, z)
draw_map(map, x, y + y2)
y2 += 21
end
end
end

def draw_map(map, x, y)
rect = Rect.new(x + 4, y, 124, 21)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(x + 6, y, 122, 20, map)
rect = Rect.new(x + 4, y + 20, 124, 1)
self.contents.fill_rect(rect, normal_color)
end

def refresh_maps
row = @maps_index
if row < @maps_oy / 21
@maps_oy = self.top_row(row, @maps.size)
end
if row > @maps_oy / 21 + (@max_maps - 1)
@maps_oy = self.top_row(row - (@max_maps - 1), @maps.size)
end
x = @maps_x
y = @maps_y
y2 = 0
y3 = 0
z = [@maps.size * 21, (@max_maps - 1)*21].min + @maps_oy
for map in @maps
if y2.between?(@maps_oy, z)
draw_map(map, x, y + y3)
y3 += 21
end
y2 += 21
end
end

def draw_description(x, y)
e_description = Options::ENEMY_DESCRIPTION[@enemy.id]
description = lines(e_description, self.width - 32)
for i in 0...description.size
self.contents.draw_text(x+4, y+2+i*20, self.width - 32, 20, description[i])
end
end

def line(text)
words = text.split(" ")
return_text = ""
for word in words
x = "!@$%¨&*()"
return_text += word + x + " "
return_text2 = return_text.gsub(x,"")
t_width = self.contents.text_size(return_text2).width
if t_width > self.width - 32
return return_text.gsub(" "+word+x, "")
else
return_text.gsub!(word+x, word)
end
end
end

def draw_battler(x, y)
enemy = $data.enemies[@enemy.id]
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
@view = Viewport.new(0, 0, 640, 480)
@view.z = self.z - 10
@view.visible = self.visible
@sprite = Sprite.new(@view)
@sprite.bitmap = bitmap
w = bitmap.width
h = bitmap.height
@sprite.x = x + (256 - w)/2 + self.x + 16
@sprite.y = y + (256 - h)/2 + self.y + 16
end

def update
super
if @self_active and self.active
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % 2
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1 + 2) % 2
end
if Input.repeat?(Input::RIGHT)
case @index
when 0
if @items.size > 0
$game_system.se_play($data_system.cursor_se)
@self_active = false
@items_active = true
end
when 1
if @maps.size > 0
$game_system.se_play($data_system.cursor_se)
@self_active = false
@maps_active = true
end
end
end
elsif @items_active and self.active and @items.size > 0
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@items_index = (@items_index + 1) % @items.size
refresh_items
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@items_index = (@items_index - 1 + @items.size) % @items.size
refresh_items
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@self_active = true
@items_active = false
end
elsif @maps_active and self.active and @maps.size > 0
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@maps_index = (@maps_index + 1) % @maps.size
refresh_maps
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@maps_index = (@maps_index - 1 + @maps.size) % @maps.size
refresh_maps
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@self_active = true
@maps_active = false
end
end
update_cursor
end

def update_cursor
if @self_active and self.active
i_size = @max_items * 21 + 22
y = 88 + i_size * @index
self.cursor_rect.set(256, y, 128, 18)
elsif @items_active and self.active
y = 88 + 21*@items_index + 19 - @items_oy
self.cursor_rect.set(260, y, 124, 20)
elsif @maps_active and self.active
i_size = @max_items * 21 + 22
y = 88 + 21*@maps_index + 19 - @maps_oy + i_size
self.cursor_rect.set(260, y, 124, 20)
elsif !self.active
self.cursor_rect.empty
end
end

def top_row(row, row_max)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
return row * 21
end
end


#==============================================================================
# Window_Enemies
#==============================================================================

class Window_Enemies

attr_accessor :active

def initialize
@index = 0
@windows = []
@last_index = 0
@active = false
self.visible = false
end

def visible=(value)
@visible = value
@windows[@index].visible = value if @windows[@index].is_a?(Window)
end

def refresh(windows)
@windows[@index].visible = false if @windows[@index].is_a?(Window)
@windows[@index].active = false if @windows[@index].is_a?(Window)
@windows = windows
@index = 0
@windows[@index].visible = true if @windows[@index].is_a?(Window)
end

def index=(i)
@windows[@index].visible = false
@windows[@index].active = false
@index = i % @windows.size
@windows[@index].visible = true
end

def update
for window in @windows
window.update if window.is_a?(Window)
end
if self.active and !@windows[@index].active
if Input.repeat?(Input::RIGHT)
if Input.trigger?(Input::RIGHT) or @index + 1 < @windows.size
$game_system.se_play($data_system.cursor_se)
@windows[@index].visible = false
@windows[@index].active = false
@index = (@index + 1) % @windows.size
@windows[@index].visible = true
end
end
if Input.repeat?(Input::LEFT)
if Input.trigger?(Input::LEFT) or @index > 0
$game_system.se_play($data_system.cursor_se)
@windows[@index].visible = false
@windows[@index].active = false
@index = (@index - 1 + @windows.size) % @windows.size
@windows[@index].visible = true
end
end
if Input.repeat?(Input::C)
$game_system.se_play($data_system.decision_se)
@windows[@index].active = true
end
elsif self.active and @windows[@index].active
if Input.repeat?(Input::B)
$game_system.se_play($data_system.cancel_se)
@windows[@index].active = false
end
end
end

def window
return @windows[@index]
end
end

#==============================================================================
# Window_BookItem
#==============================================================================

class Window_BookItem < Window_Base

def initialize(item)
super(116, 0, 408, 100)
@item = item
self.visible = false
self.contents = Bitmap.new(188*2, 68)
self.contents.font.size = 14
self.contents.font.color = normal_color
refresh
end

def item_id
return @item.id
end

def all_opacity=(value)
self.contents_opacity = value
self.opacity = value
end

def refresh
# Desenhar nome do item
name = @item.name
self.contents.draw_text(41, 1, 256-32-68-12, 22, name)
bitmap = RPG::Cache.icon(@item.icon_name)
self.contents.blt(8, 11, bitmap, Rect.new(0, 0, 24, 24))
rect = Rect.new(36, 4, 1, 38)
self.contents.fill_rect(rect ,normal_color)
rect = Rect.new(0, 45, 376, 1)
self.contents.fill_rect(rect ,normal_color)
if @item.price > 0
draw_price(300, 0)
end
x = 41
if @item.treasure
self.contents.draw_text(x, 22, 72, 22, "Important Item")
x += 76
end
if !@item.is_a?(RPG::Item)
if @item.is_a?(RPG::Weapon) and @item.atk > 0
x += draw_atk(x, 22)
end
if @item.pdef > 0
x += draw_pdef(x, 22)
end
if @item.mdef > 0
x += draw_mdef(x, 22)
end
if @item.is_a?(RPG::Armor) and @item.eva > 0
x += draw_eva(x, 22)
end
if @item.str_plus > 0
x += draw_for(x, 22)
end
if @item.dex_plus > 0
x += draw_dex(x, 22)
end
if @item.agi_plus > 0
x += draw_agi(x, 22)
end
if @item.int_plus > 0
draw_int(x, 22)
end
else
if @item.scope > 0
x += draw_scope(x, 22)
end
if @item.recover_hp_rate > 0
x += draw_rec_hp(x, 22, true)
elsif @item.recover_hp > 0
x += draw_rec_hp(x, 22)
end
if @item.recover_sp_rate > 0
x += draw_rec_sp(x, 22, true)
elsif @item.recover_sp > 0
x += draw_rec_sp(x, 22)
end
if @item.parameter_type > 0 and @item.parameter_points > 0
x += draw_parameter(x, 22)
end
if @item.pdef_f > 0
x += draw_pdef_f(x, 22)
end
if @item.mdef_f > 0
x += draw_mdef_f(x, 22)
end
end
self.contents.font.color = normal_color
self.contents.draw_text(4, 68-22, 368, 22, @item.description, 0)
end

def draw_price(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 34, 22, "Price: ")
self.contents.font.color = normal_color
self.contents.draw_text(x + 34, y, 42, 22, @item.price.to_s, 2)
end

def draw_atk(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 22, 22, "Atk:")
self.contents.font.color = normal_color
w = @item.atk.to_s.size * 6
self.contents.draw_text(x + 22, y, w, 22, @item.atk.to_s, 2)
return 22 + w + 4
end

def draw_pdef(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 33, 22, "P. Def:")
self.contents.font.color = normal_color
w = @item.pdef.to_s.size * 6
self.contents.draw_text(x + 33, y, w, 22, @item.pdef.to_s, 2)
return 33 + w + 4
end

def draw_mdef(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 35, 22, "M. Def:")
self.contents.font.color = normal_color
w = @item.mdef.to_s.size * 6
self.contents.draw_text(x + 35, y, w, 22, @item.mdef.to_s, 2)
return 35 + w + 4
end

def draw_slots(x, y)
y_slot = (y) + ((5 - @item.slot) * 5/2)
for i in 0...@item.slot
bitmap = RPG::Cache.picture("empty_slot")
self.contents.blt(x , y_slot + (i*5), bitmap, Rect.new(0, 0, 4, 4))
end
end

def draw_eva(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 23, 22, "Eva:")
self.contents.font.color = normal_color
w = @item.eva.to_s.size * 6
self.contents.draw_text(x + 23, y, w, 22, @item.eva.to_s, 2)
return 23 + w + 4
end

def draw_for(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 24, 22, "Str:")
self.contents.font.color = normal_color
w = @item.str_plus.to_s.size * 6
self.contents.draw_text(x + 21, y, w, 22, @item.str_plus.to_s, 2)
return 25 + w
end

def draw_dex(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 25, 22, "Dex:")
self.contents.font.color = normal_color
w = @item.dex_plus.to_s.size * 6
self.contents.draw_text(x + 25, y, w, 22, @item.dex_plus.to_s, 2)
return 29 + w
end

def draw_agi(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 22, 22, "Agi:")
self.contents.font.color = normal_color
w = @item.agi_plus.to_s.size * 6
self.contents.draw_text(x + 22, y, w, 22, @item.agi_plus.to_s, 2)
return 26 + w
end

def draw_int(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 18, 22, "Int:")
self.contents.font.color = normal_color
w = @item.int_plus.to_s.size * 6
self.contents.draw_text(x + 16, y, w, 22, @item.int_plus.to_s, 2)
return w + 29
end

def draw_scope(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 35, 22, "Affect:")
self.contents.font.color = normal_color
w = self.contents.text_size(Options::SCOPE_INFO[@item.scope]).width
self.contents.draw_text(x + 35, y, w, 22, Options::SCOPE_INFO[@item.scope], 2)
return w + 39
end

def draw_rec_hp(x, y, rate=false)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 41, 22, "Rec. HP:")
self.contents.font.color = normal_color
if rate
w = self.contents.text_size(@item.recover_hp_rate.to_s + "%").width
self.contents.draw_text(x + 43, y, w, 22, @item.recover_hp_rate.to_s + "%", 2)
return w + 47
elsif @item.recover_hp >= 9999
w = self.contents.text_size("100%").width
self.contents.draw_text(x + 43, y, w, 22, "100%", 2)
return w + 47
else
w = @item.recover_hp.to_s.size * 6
self.contents.draw_text(x + 43, y, w, 22, @item.recover_hp.to_s, 2)
return w + 47
end
end

def draw_rec_sp(x, y, rate=false)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 41, 22, "Rec. SP:")
self.contents.font.color = normal_color
if rate
w = self.contents.text_size(@item.recover_sp_rate.to_s + "%").width
self.contents.draw_text(x + 43, y, w, 22, @item.recover_sp_rate.to_s + "%", 2)
return w + 47
elsif @item.recover_sp >= 9999
w = self.contents.text_size("100%").width
self.contents.draw_text(x + 43, y, w, 22, "100%", 2)
return w + 47
else
w = @item.recover_sp.to_s.size * 6
self.contents.draw_text(x + 43, y, w, 22, @item.recover_sp.to_s, 2)
return w + 47
end
end

def draw_parameter(x, y)
text_parameter = ["", "HP Max:", "SP Max:", "Str:", "Dex:", "Agi:", "Int:"]
w1 = self.contents.text_size(text_parameter[@item.parameter_type]).width
self.contents.font.color = system_color
self.contents.draw_text(x, y, w1, 22, text_parameter[@item.parameter_type])
self.contents.font.color = normal_color
w2 = self.contents.text_size("+" + @item.parameter_points.to_s).width
self.contents.draw_text(x + w1 + 2, y, w2, 22, "+" + @item.parameter_points.to_s, 2)
return w2 + w1 + 6
end

def draw_mdef_f(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 33, 22, "M. Def:")
self.contents.font.color = normal_color
w = self.contents.text_size("+" + @item.mdef_f.to_s).width
self.contents.draw_text(x + 33, y, w, 22, "+" + @item.mdef_f.to_s, 2)
return w + 37
end

def draw_pdef_f(x,y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 31, 22, "P. Def:")
self.contents.font.color = normal_color
w = self.contents.text_size("+" + @item.pdef_f.to_s).width
self.contents.draw_text(x + 31, y, w, 22, "+" + @item.pdef_f.to_s, 2)
return w + 35
end
end

#==============================================================================
# Window_Items
#==============================================================================

class Window_Items

attr_accessor :index
attr_accessor :active
attr_reader :visible

def initialize
@index = -1
@windows = []
@row = 0
@windows_visible = []
@active = false
@sprite = Sprite.new
@sprite.visible = false
@sprite.bitmap = Bitmap.new(640, 480)
self.visible = false
end

def visible=(value)
for window in @windows_visible
window.visible = value if window.is_a?(Window)
end
#@sprite.visible = value
@visible = value
end

def refresh(windows)
#if @windows =! windows
for window in @windows_visible
window.visible = false if window.is_a?(Window)
end
@index = 0
@windows = windows
update_show
#end
end

def dispose
for window in @windows
window.dispose
end
end

def update
for window in @windows
window.update
end
if self.active
if Input.repeat?(Input::DOWN)
if Input.trigger?(Input::DOWN) or @index + 1 < @windows.size
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @windows.size
end
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index > 0
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1 + @windows.size) % @windows.size
end
end
end
update_show
end

def row_max
return @windows.size
end

def top_row
return @row
end

def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
@row = [row, 0].max
end

def page_row_max
return 3
end

def page_item_max
return page_row_max
end

def update_show
if @index != @last_index
row = @index
if row <= self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
new_windows_visible = [@windows[@row], @windows[@row+1], @windows[@row+2]]
windows_visiblefalse = @windows_visible - new_windows_visible
for window in windows_visiblefalse
window.visible = false if window.is_a?(Window)
end
@windows_visible = new_windows_visible
for i in 0...@windows_visible.size
next if @windows_visible[i].nil?
@windows_visible[i].y = 66 + i*116 + 8
@windows_visible[i].visible = self.visible
if @windows_visible[i] == @windows[@index]
@windows_visible[i].all_opacity = 255
else
@windows_visible[i].all_opacity = 128
end
end
@last_index = @index
update_row
end
end

def update_row
@sprite.bitmap.clear
return if @sprite.visible
x = 540
y = 66 + 8
width = 4
height = 116*3 - 16
rect = Rect.new(x, y, width, height)
@sprite.bitmap.fill_rect(rect, Color.new(255, 255, 255, 255))
rect = Rect.new(x+1, y+1, width-2, height-2)
@sprite.bitmap.fill_rect(rect, Color.new(0, 0, 0, 0))
oy = (height - 2) / [@windows.size, 1].max
rect = Rect.new(x+1, y + 1 + oy*@row, width-2, oy*3)
@sprite.bitmap.fill_rect(rect, Color.new(192, 224, 255, 255))
end

end

#==============================================================================
# Scene_Bestiary
#==============================================================================

class Scene_Bestiary

def main
view = Viewport.new(0, 0, 640, 480)
view.z = -500
@plane = Plane.new(view)
@plane.bitmap = RPG::Cache.picture(Options::COLD_MENU_PLANE)
@base = Window_Base.new(32,32,640-64,480-64)
@base.contents = Bitmap.new(640-96,480-96)
@base.contents.font.size = 14
@command_window = Window_BookCommand.new
@cw_types = Options::ENEMIES_ORDER.keys.reverse
@cw_commands = ["All", "By habitat"]
@command_window.refresh("Order:",@cw_types,@cw_commands)
$game_system.save_hash["Bestiary Windows"] ||= []
@enemy_windows = $game_system.save_hash["Bestiary Windows"]
for i in 1...$data_enemies.size
if @enemy_windows[i].is_a?(Window_Enemy)
if @enemy_windows[i].need_refresh?($game_system.info_enemy(i).killed)
@enemy_windows[i].refresh(i)
end
next
end
if $game_system.info_enemy(i).battled > 0
@enemy_windows[i] = Window_Enemy.new(i)
end
end
@enemies = []
draw_base_book
@enemies_window = Window_Enemies.new

@book_enemies = Window_Book.new
@maps_window = Window_Book.new

Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze

@base.dispose
@command_window.dispose
@book_enemies.dispose
@maps_window.dispose
@plane.dispose
end

def update
@plane.ox -= 2
@plane.oy -= 2
#update_draw_enemy_window
@base.update
@command_window.update
@book_enemies.update
can_update_ew = !@enemies_window.window.active if !@enemies_window.window.nil?
@enemies_window.update
@maps_window.update
if @command_window.active
update_command
return
end
if @book_enemies.active
update_book_enemies
return
end
if @enemies_window.active and can_update_ew
update_enemies
return
end
if @maps_window.active
update_maps
return
end
end

def update_command
if Input.trigger?(Input::B)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.command
when @cw_commands[0]
$game_system.se_play($data_system.decision_se)
@command_window.visible = false
@command_window.active = false
@enemies = []
@enemies_names = []
for i in Options::ENEMIES_ORDER[@command_window.type]
if $game_system.info_enemy(i).battled > 0
@enemies.push(i)
@enemies_names.push($data_enemies[i].name)
else
@enemies_names.push("???")
@enemies.push(i)
end
end
draw_base_text("Show All Monsters")
@book_enemies.refresh(@enemies_names)
@book_enemies.index = 0
@book_enemies.active = true
@book_enemies.visible = true
when @cw_commands[1]
if $game_system.maps_battled.size > 0
$game_system.se_play($data_system.decision_se)
@command_window.visible = false
@command_window.active = false
@maps_window.refresh($game_system.maps_battled)
@maps_window.active = true
@maps_window.visible = true
@maps_window.index = 0
draw_base_text("Select the map which you want to see the monsters")
else
$game_system.se_play($data_system.buzzer_se)
end
end
return
end
end

def update_book_enemies
if Input.trigger?(Input::B)
case @command_window.command
when @cw_commands[0]
$game_system.se_play($data_system.cancel_se)
@base.contents.clear
@book_enemies.visible = false
@book_enemies.active = false
@command_window.active = true
@command_window.visible = true
draw_base_book
return
when @cw_commands[1]
$game_system.se_play($data_system.cancel_se)
@base.contents.clear
@book_enemies.visible = false
@book_enemies.active = false
@maps_window.visible = true
@maps_window.active = true
draw_base_text("Select the map which you want to see monsters")
return
end
return
end
if Input.trigger?(Input::C)
index = @enemies[@book_enemies.index]
if @enemies_names[@book_enemies.index] == "???"
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@e_windows = []
for i in Options::ENEMIES_ORDER[@command_window.type]#1...$data_enemies.size
unless @map.nil?
next unless $game_system.info_enemy(i).habitat.include?(@map)
end
if $game_system.info_enemy(i).battled > 0
@e_windows.push(@enemy_windows[i])
end
end
@enemies_window.refresh(@e_windows)
@enemies_window.index = @e_windows.index(@enemy_windows[index])
@book_enemies.visible = false
@book_enemies.active = false
@base.contents.clear
@enemies_window.visible = true
@enemies_window.active = true
return
end
end

def update_enemies
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@enemies_window.visible = false
@enemies_window.active = false
case @command_window.command
when @cw_commands[0]
@book_enemies.visible = true
@book_enemies.active = true
draw_base_text("Show All Monsters")
when @cw_commands[1]
@book_enemies.visible = true
@book_enemies.active = true
draw_base_text(@map_text)
end
return
end
end

def update_maps
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@base.contents.clear
@maps_window.visible = false
@maps_window.active = false
@command_window.active = true
@command_window.visible = true
@map = nil
draw_base_book
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@maps_window.visible = false
@maps_window.active = false
@enemies = []
@enemies_names = []
ind = @maps_window.index
for i in Options::ENEMIES_ORDER[@command_window.type]#1...$data_enemies.size
next unless $game_system.info_enemy(i).habitat.include?($game_system.maps_battled[ind])
if $game_system.info_enemy(i).battled > 0
@enemies.push(i)
@enemies_names.push($data_enemies[i].name)
else
@enemies.push(i)
@enemies_names.push("???")
end
end
@map = $game_system.maps_battled[ind]
@map_text = "Monsters that live #{@map}"
draw_base_text(@map_text)
@book_enemies.refresh(@enemies_names.compact)
@book_enemies.index = 0
@book_enemies.active = true
@book_enemies.visible = true
return
end
end

def draw_base_text(text)
@base.contents.clear
x = (640 - 352) / 2 - 48 + 16
y = (480 - (12*22+32)) / 2 - 48 + 16 - 5
@base.contents.draw_text(x, y - 23, 320, 22, text, 1)
rect = Rect.new(x, y - 1, 320, 1)
@base.contents.fill_rect(rect, @base.normal_color)
end

def draw_base_book
if Options::LAYOUTB
@base.contents.clear
x = (640-96-128) / 2
y = 40
@base.contents.font.size = 14
@base.contents.font.bold = false
@base.contents.draw_text(x, y, 128, 18, "Bestiary", 1)
rect = Rect.new(x - 2, y + 17, 132, 1)
@base.contents.fill_rect(rect, @base.normal_color)
total = $data_enemies.size - 1
sub_total = @enemy_windows.compact.size
number = sub_total.to_s + "/" + total.to_s
@base.contents.font.color = @base.system_color
@base.contents.draw_text(544-114-24, 380-38-24, 114, 22, "Monsters found:")
@base.contents.font.color = @base.normal_color
@base.contents.draw_text(544-114-24, 380-22-24, 114, 22, number, 2)
rect = Rect.new(544-114-28, 380-24-3, 122, 1)
@base.contents.fill_rect(rect, @base.normal_color)
end
end
end

#==============================================================================
# Scene_ItemsBook
#------------------------------------------------------------------------------
# Esta classe processa a Tela do livro de itens
#==============================================================================

class Scene_ItemsBook

#--------------------------------------------------------------------------
# - Processamento Principal
#--------------------------------------------------------------------------

def main
# Criar plano de fundo
view = Viewport.new(0, 0, 640, 480)
view.z = -500
@plane = Plane.new(view)
@plane.bitmap = RPG::Cache.picture(Options::COLD_MENU_PLANE)
# Janela Base
@base = Window_Base.new(32,32,640-64,480-64)
@base.contents = Bitmap.new(640-96,480-96)
@base.contents.font.size = 14
@base.z = -10
# Menu de opções
@command_window = Window_BookCommand.new
# Ordens
@cw_types = Options::ITEMS_ORDER.keys.reverse
# Tipos de itens
@cw_commands = ["All"]
@cw_commands[1] = $data_system.words.weapon + "s"
@cw_commands[2] = $data_system.words.armor1 + "s"
@cw_commands[3] = $data_system.words.armor2 + "s"
@cw_commands[4] = $data_system.words.armor3 + "s"
@cw_commands[5] = $data_system.words.armor4 + "s"
@cw_commands[6] = $data_system.words.item + "s"
@cw_commands[7] = "Important " + $data_system.words.item + "s" if Options::TREASURE_ACTIVE
# Refrescar menu de opções
@command_window.refresh("Order:",@cw_types,@cw_commands)
# Janelas dos itens
$game_system.save_hash["Book Item Windows"] ||= []
@items_windows = $game_system.save_hash["Book Item Windows"]
for i in 1...$data_items.size
next if !@items_windows[i].nil?
if $game_system.items_obtained[i]
@items_windows[i] = Window_BookItem.new($data_items[i])
end
end
for i in 1...$data_weapons.size
next if !@items_windows[i + $data_items.size].nil?
if $game_system.weapons_obtained[i]
w_item = Window_BookItem.new($data_weapons[i])
@items_windows[i + $data_items.size] = w_item
end
end
for i in 1...$data_armors.size
next if !@items_windows[i + $data_items.size + $data_weapons.size].nil?
if $game_system.armors_obtained[i]
w_item = Window_BookItem.new($data_armors[i])
@items_windows[i + $data_items.size + $data_weapons.size] = w_item
end
end
draw_base_book
# Janela para escolha do item
@book_items = Window_Book.new
# Janela que mostra as janelas do items
@items_window = Window_Items.new
# Executar transição
Graphics.transition
# Loop principal
loop do
# Atualizar a tela de jogo
Graphics.update
# Atualizar a entrada de informações
Input.update
# Atualizar Frame
update
# Abortar loop se a tela for alterada
if $scene != self
break
end
end
# Preparar para transição
Graphics.freeze
# Exibição das janelas
@base.dispose
@command_window.dispose
@book_items.dispose
@items_window.visible = false
@plane.dispose
end

#--------------------------------------------------------------------------
# - Atualização do Frame
#--------------------------------------------------------------------------

def update
# Atualizar fundo
@plane.ox -= 2
@plane.oy -= 2
# Atualizar janelas
@command_window.update
@book_items.update
@items_window.update
# Se a janela de Menu das opções estiver ativa
if @command_window.active
update_command
return
end
# Se a janela para escolha dos itens estiver ativa
if @book_items.active
update_book
return
end
# Se a janela que processa as janelas de itens estiver ativa
if @items_window.active
update_items
return
end
end

#--------------------------------------------------------------------------
# - Atualização do Frame (Quando a janela de Menu das opções estiver ativa)
#--------------------------------------------------------------------------

def update_command
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Alternar para a tela do menu
$scene = Scene_Map.new
return
end
# Se o botão C for pressionado
if Input.trigger?(Input::C)
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
# Ramificação por posição do cursor na janela de comandos
case @command_window.command
when @cw_commands[0] # Quando for 0
# Todos itens
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Todos items
for item in Options::ITEMS_ORDER[@command_window.type]
case item[0] # Ramitificação do tipo de item
when 0 # Quando for item
# Se item já foi obtido
if $game_system.items_obtained[item[1]]
@item_names.push($data_items[item[1]].name)
@item_index.push(item[1])
else
@item_names.push("???")
@item_index.push(nil)
end
when 1 # Quando for arma
# Se arma já foi obtida
if $game_system.weapons_obtained[item[1]]
@item_names.push($data_weapons[item[1]].name)
@item_index.push(item[1] + $data_items.size)
else
@item_names.push("???")
@item_index.push(nil)
end
when 2 # Quando for equip. de def.
# Se equip. de def. já foi obtido
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show All Items")
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[1] # Quando for 1
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas armas
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 1
if $game_system.weapons_obtained[item[1]]
@item_names.push($data_weapons[item[1]].name)
@item_index.push(item[1] + $data_items.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[2] # Quando for 2
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas escudos
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 2
next if $data_armors[item[1]].kind != 0
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[3] # Quando for 3
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas elmos
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 2
next if $data_armors[item[1]].kind != 1
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[4] # Quando for 4
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas armaduras
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 2
next if $data_armors[item[1]].kind != 2
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[5] # Quando for 5
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas acessorios
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 2
next if $data_armors[item[1]].kind != 3
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[6] # Quando for 6
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas items
for item in Options::ITEMS_ORDER[@command_window.type]
if item[0] == 0
if $game_system.items_obtained[item[1]]
@item_names.push($data_items[item[1]].name)
@item_index.push(item[1])
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
when @cw_commands[7] # Quando for 8
# Apenas treasures
@item_index = [] # Index daa janela dos itens
@item_names = [] # Nome dos items
# Apenas treasures
for item in Options::ITEMS_ORDER[@command_window.type]
case item[0] # Ramitificação do tipo de item
when 0 # Quando for item
next if !$data_items[item[1]].treasure
# Se item já foi obtido
if $game_system.items_obtained[item[1]]
@item_names.push($data_items[item[1]].name)
@item_index.push(item[1])
else
@item_names.push("???")
@item_index.push(nil)
end
when 1 # Quando for arma
next if !$data_weapons[item[1]].treasure
# Se arma já foi obtida
if $game_system.weapons_obtained[item[1]]
@item_names.push($data_weapons[item[1]].name)
@item_index.push(item[1] + $data_items.size)
else
@item_names.push("???")
@item_index.push(nil)
end
when 2 # Quando for equip. de def.
next if !$data_armors[item[1]].treasure
# Se equip. de def. já foi obtido
if $game_system.armors_obtained[item[1]]
@item_names.push($data_armors[item[1]].name)
@item_index.push(item[1] + $data_items.size + $data_weapons.size)
else
@item_names.push("???")
@item_index.push(nil)
end
end
end
draw_base_text("Show Only " + @cw_commands[@command_window.index])
@book_items.refresh(@item_names)
# Ativar janela para escolha do item
@command_window.active = false
@command_window.visible = false
@book_items.active = true
@book_items.visible = true
@book_items.index = 0
end
end
end

#--------------------------------------------------------------------------
# - Atualização do Frame
#--------------------------------------------------------------------------

def update_book
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Ativar menu de opções
@book_items.active = false
@book_items.visible = false
@command_window.active = true
@command_window.visible = true
@base.contents.clear
draw_base_book
return
end
# Se o botão C for pressionado
if Input.trigger?(Input::C)
# Verificar se o item foi obtido
if @item_index[@book_items.index] == nil
# Reproduzir SE de erro
$game_system.se_play($data_system.buzzer_se)
return
end
# Reproduzir SE de OK
$game_system.se_play($data_system.decision_se)
@i_windows = []
for i in @item_index#0...@items_windows.size
if !i.nil?#@item_index.include?(i)
@i_windows.push(@items_windows[i])
end
end
@base.visible = false
@book_items.active = false
@book_items.visible = false
@items_window.refresh(@i_windows)
ind = @i_windows.index(@items_windows[@item_index[@book_items.index]])
@items_window.index = ind + 1
@items_window.update_show
@items_window.index = ind
@items_window.active = true
@items_window.visible = true
end
end

#--------------------------------------------------------------------------
# - Atualização do Frame
#--------------------------------------------------------------------------

def update_items
# Se o botão B for pressionado
if Input.trigger?(Input::B)
# Reproduzir SE de cancelamento
$game_system.se_play($data_system.cancel_se)
# Ativar menu de opções
@items_window.active = false
@items_window.visible = false
@base.visible = true
@book_items.active = true
@book_items.visible = true
return
end
end

#--------------------------------------------------------------------------
# - Mostrar texto na janela base
#--------------------------------------------------------------------------

def draw_base_text(text)
@base.contents.clear
x = (640 - 352) / 2 - 48 + 16
y = (480 - (12*22+32)) / 2 - 48 + 16 - 5
@base.contents.font.size = 14
@base.contents.font.bold = false
@base.contents.draw_text(x, y - 23, 320, 22, text, 1)
rect = Rect.new(x, y - 1, 320, 1)
@base.contents.fill_rect(rect, @base.normal_color)
end

def draw_base_book
if Options::LAYOUTB
@base.contents.clear
x = (640-96-128) / 2
y = 40
@base.contents.font.size = 14
@base.contents.font.bold = false
@base.contents.draw_text(x, y, 128, 18, "Items Book", 1)
rect = Rect.new(x - 2, y + 17, 132, 1)
@base.contents.fill_rect(rect, @base.normal_color)
total = $data_items.size + $data_weapons.size + $data_armors.size - 3
sub_total = @items_windows.compact.size
number = sub_total.to_s + "/" + total.to_s
@base.contents.font.color = @base.system_color
@base.contents.draw_text(544-96-24, 380-38-24, 96, 22, "Known Items:")
@base.contents.font.color = @base.normal_color
@base.contents.draw_text(544-96-24, 380-22-24, 96, 22, number, 2)
rect = Rect.new(544-96-28, 380-24-3, 100, 1)
@base.contents.fill_rect(rect, @base.normal_color)
end
end

end
end[/spoiler]
I can probably use the database but I was hoping to be able to do multi-drops, for some creatures, thanks again :sweatdrop:

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...