#===============================================================================
#
# Yanfly Engine Zealous - Battle Engine Zealous
# Last Date Updated: 2009.12.31
# Level: Normal, Hard, Lunatic
#
# Battle Engine Zealous rewrites a lot of the default battle system to allow for
# a more controlled battle structure. While the default battle system was great
# on its own, it was particularly lacking in the aspect that it provided little
# flexibility on behalf of the player's actions and information. Battle Engine
# Zealous will expand upon that in addition to providing other features. Here
# is a list of the features you can find in Battle Engine Zealous:
#
# Message Window Moved
# During the battle phase, messages are now displayed at the top of the screen
# instead of obscuring the party's status window at the bottom of the screen.
# Lots of unnecessary text has also been removed, although the option to turn
# them back on is also included.
#
# Party Window Changes
# Having a top-down list of the party is rather impractical with a front view
# battle system so it has been revamped. Not only does the new party system
# display the actors in a horizontal fashion, more data can be revealed with
# the positioning such as more states, actions, and more.
#
# Turn Phase Changes
# When selecting actions for your party members, you can now switch amongst
# them by pressing left and right. After the actions have been selected, you
# must confirm one last time to enter the battle phase. Once the next turn
# phase comes up, you can perform the same actions again through Execute since
# last turn's action data has been saved.
#
# Routine Common Events
# Now, common events can occur at the beginning of a battle, end of a battle,
# at the start of a turn, or when the turn ends. These common events can be
# selected or disabled in the script depending on you.
#
# Attack Animations
# Now, animations will be shown on your party members when enemies attack or
# use skills on them. Default attack animations can be changed via a simple
# notebox tag, too, so you can give your enemies a different flavour. The area
# of attack on the party members will directly reflect on the actor's position
# in the party window.
#
# Popup Numbers and Values
# When enemies receive damage or take on new status effects, popups will appear
# instead of text. These popups will apear somewhere above the enemy's head and
# fly upward for a little bit. Popups are completely customizable, too, as far
# as colours, font, size, and even how far they fly up. When enemies are struck
# with an elemental weakness or are resistant to something, that, too, will
# appear above the enemy.
#
# Smaller Skill and Item Windows
# They are now fitted to appear at the bottom of screen instead of obscuring
# the enemy view. This is mostly done for visual purposes, but also allowing
# you to look past the skill/item windows at the same time to see what enemies
# you're facing. This feature can be disabled.
#
# In Battle Options Menu
# Now, you can adjust various aspects of your ingame options in battle. These
# options include enabling skill help so that the skill description will appear
# when a battler uses a skill, automatic cursor memory, disabling and enabling
# battle animations, and adjusting sound volume.
#
# Estimated Turn Order Menu
# The estimated turn order menu will show the player a forecast of the action
# order for the turn in relation to the actions they've chosen. Although the
# action order is subjected to change, it can still give the player a general
# understanding of what will occur when.
#
# In Battle Status Menu
# In the event the player wishes to view the status of a party member, the
# status menu option will provide almost all of the necessary battle-related
# information to the player. This includes element affinities, status weakness,
# changed stats, and a list of status effects. Though the party window displays
# only the icons of the status effects present on the party member, it only
# displays the icon and not the name. The status window has a scrollable status
# effect list that includes both the name and icon of all the states present
# on the party member.
#
# And that's all for the new features implemented with Battle Engine Zealous.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2009.12.31 - SORT_LEFT_TO_RIGHT option for enemies under ZEALOUS.
# o 2009.12.29 - Prevented L and R scrolling for command windows.
# o 2009.12.27 - Weapon Mastery Skills Compatibility.
# o 2009.12.24 - Party Selection System Compatibility.
# o 2009.12.18 - Custom Status Properties Compatibility.
# o 2009.12.16 - Class Stat: DUR Compatibility.
# - Class Stat: LUK Compatibility.
# - Efficiency update.
# - Weakness popup bug fixed.
# o 2009.12.14 - Formation Macros Compatibility.
# - Options Window Change
# - Revealed and Concealed Actions states added.
# - Smart indexing added for party and execute windows.
# - Status Window changed icons to percentages.
# o 2009.12.10 - Compatibility update for Custom Skill Effects.
# - Bugfixes, drawing fixes, and efficiency updates.
# o 2009.12.06 - Finished Script.
# o 2009.11.27 - Started Script.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Enemy Tags - Insert the following tags into Enemy noteboxes.
# -----------------------------------------------------------------------------
# <attack animation n>
# You can change the attack animation for an enemy with this tag. n is the
# animation ID used. The default animation ID is the ENEMY_ATTACK_ANI value.
#
# -----------------------------------------------------------------------------
# State Tags - Insert the following tags into State noteboxes.
# -----------------------------------------------------------------------------
# <popup add rule: phrase> <popup hide add>
# <popup rem rule: phrase> <popup hide rem>
# <popup dur rule: phrase> <popup hide dur>
# These tags will allow you to change the popup rules for various states or
# hide them entirely. The phrase entered has to match the cases under RULES
# in the POPUP section of the module. The phrase used is also case sensitive.
#
# <revealed actions>
# Enemies inflicted with a state that has this tag will have their actions
# viewable in the turn orders window if the option to not originally be able
# to see them if off.
#
# <concealed actions>
# Enemies inflicted with a state that has this tag will conceal their actions
# regardless of how many states with the <revealed actions> tag they have on.
# This will occur even if actions are originally viewable by default.
#
# -----------------------------------------------------------------------------
# Debug Shortcuts - Only during $TEST and $BTEST mode
# -----------------------------------------------------------------------------
# During testplay mode, pressing F5 during the party, actor, or perform windows
# recover all members or the selected member. Pressing F9 will drop all enemies
# to 0 HP. Will not kill them if they are immortal for the sake of testing
# purposes and not messing up the flow.
#
#===============================================================================
# Note: This script does not work well with auto-battlers. Please refrain from
# using them in your game.
# Note: This script may not work with former Yanfly Engine ReDux scripts.
# Use Yanfly Engine Zealous scripts to work with this if available.
#===============================================================================

$imported = {} if $imported == nil
$imported = true

module YEZ
module BATTLE
module ZEALOUS

#=========================================================================
# Zealous Message Window
# ------------------------------------------------------------------------
# Battle Engine Zealous is more or less designed for this aspect of the
# the default battle engine. Zealous effect will move the battle message
# window from obscuring the party status window in order to allow the
# player to have a more onboard view of what's going on and skip any of
# the messages the creator desires.
#=========================================================================

# This will allow you to determine which messages you want shown or not.
# set them to true to show them and false to hide them.
SHOWN_MESSAGES ={
# Situation => True/False
:enemy_appear => false, # Start message of which enemies appeared.
:advantage => true, # Whether or not party has advantage.
:currentstate => false, # Display active battler's current state.
:action_atk => true, # Message when battler attacks.
:action_guard => true, # Message when battler guards.
:action_wait => true, # Message when battler waits.
:action_skill => true, # Message when battler uses a skill.
:action_item => true, # Message when battler uses an item.
:critical_hit => false, # Display critical action message.
:display_miss => false, # Display missed action message.
:display_eva => false, # Display evaded action message.
:display_fail => false, # Display failed action message.
:damage_hp => false, # Message when battler is HP damage/healed.
:damage_mp => false, # Message when battler is MP damage/healed.
:state_change => false, # Message when battler gains/loses states.
} # Do not remove this.

# This will determine which common events will run universally amongst
# all battles. To not use the common events, set them to nil.
COMMON_EVENTS ={
:battle_start => 2, # Common event at the start of battle.
:turn_start => 3, # Common event at the start of each turn.
:turn_end => 4, # Common event at the end of each turn.
:battle_end => 5, # Common event at the end of battle.
} # Do not remove this.

# The following values determine the battle message box's new settings as
# it is now displayed at the top of the screen rather than the bottom.
MSG_GRADIENT1 = Color.new(0,0,0,196)
MSG_GRADIENT2 = Color.new(0,0,0,96)
MSG_GRADIENTW = 544
MSG_OPACITY = 96
MSG_FONT_SIZE = 20

# This will allow you to set whether or not you wish for the battle to
# have a fast forward option. If allowed, holding down Input A or C will
# trigger the battles to flow faster.
ALLOW_FAST_FORWARD = true

# This will allow you to sort enemies from left to right screen position
# or from right to left screen position. Set to true for left to right
# and false for right to left.
SORT_LEFT_TO_RIGHT = false

end # ZEALOUS
module PARTY_WINDOW

#=========================================================================
# Party Window
# ------------------------------------------------------------------------
# The Zealous Party Window will be one of the few things you cannot turn
# off for the sake of letting this script function properly & effectively.
# Here, you can adjust the individual commands for each window. The party
# window is the one that appears on the left. The perform window is the
# one that appears on the right. Here's a list of the actions you can use
# for each window.
# Party Window Perform Window
# :actions :perform
# :execute :turns
# :tactics :status
# :party :options
# :options
# :escape
#=========================================================================

# The following is a list of the commands used for the party window.
PARTY_COMMANDS = # Do not remove this.

# The following is a list of the commands used for the perform window.
PERFORM_COMMANDS = # Do not remove this.

# This is the command used to end the action selection phase and enter
# the combat phase. The vocabulary here will also be used for the perform
# window after selecting all of your commands.
VOCAB = {
#command =>
:actions => "Action",
:escape => "Escape",
:options => "Option",
:execute => "Execute",
:perform => "Perform",
:turns => "Orders",
:status => "Status",
} # Do not remove this.

# This will adjust the opacity used for the faces in battle. Set it to 0
# to make it completely transparent and 255 to make it completely opaque.
FACE_OPACITY = 128

# The maximum number of states shown per party member. This is best kept
# at four to show the most amount of states for the party member. Reduce
# if you have intentions of editting this script to fit more members.
MAX_STATES_SHOWN = 4

# This will adjust the size of the fonts used for the various stats shown
# in the party window.
NAME_SIZE = 16
STAT_SIZE = 16

# This will determine the icons used for the each actor's battle actions.
# There will be a few actions that won't use icons. They are as follows:
# - Attack - Uses weapon icon. If no weapon, uses the :noweapon icon.
# - Skills - Uses the skill's icon.
# - Items - Uses the used item's icon.
BATTLE_ACTION_ICONS ={
:noaction => 98,
:noweapon => 132,
:guard => 52,
} # Do not remove this.

# The following will allow you to adjust how you would like for HP and MP
# to appear. The following will explain how each type formats HP and MP:
# - Type 1: Current
# - Type 2: Current / Max
# - Type 3: Percent
SHOWN_HP_TYPE = 1
SHOWN_MP_TYPE = 1

# Animations will now be played on the actors' respective location in
# the Party Window box now. Use the following hash to determine where
# they are relative to the Party Window's X location. You should only
# really change these values if you modified your game to have more than
# four maximum party members.
ACTOR_COORDINATES ={ # Do not remove Index -1.
# Index =>
-1 => ,
0 => ,
1 => ,
2 => ,
3 => ,
} # Do not remove this.

# Since enemies don't have a default attack animation, this animation
# will be used unless they have a <attack animation n> tag.
ENEMY_ATTACK_ANI = 36

# This will determine whether or not the screen will shake upon battlers
# receiving any HP damage.
DMG_SHAKE_SCREEN = false

end # PARTY_WINDOW
module POPUP

#=========================================================================
# Popups
# ------------------------------------------------------------------------
# Numbers, states, and other effects will pop up over the battlers when
# they take damage, heal, receive status changes, etc. This section is
# fully customizable and you may even change the way certain popups will
# appear in battle.
#=========================================================================

# The following hash determines the various rules popups will follow when
# they are to appear. Use this to govern the way you want popups to flow.
SETTINGS ={
# Rule => Effect
:width => 140, # Maximum width of a popup.
:offset => -12, # Height offset of a popup.
:fade => 24, # Fade rate of a popup.
:full => 36, # Frames before a popup fades.
:hp_dmg => "%s", # SprintF for HP damage.
:hp_heal => "+%s", # SprintF for HP healing.
:mp_dmg => "%s MP", # SprintF for MP damage.
:mp_heal => "+%s MP", # SprintF for MP healing.
:dmg100k => "%sK", # SprintF for 100k+ damage.
:dmg100m => "%sM", # SprintF for 100m+ damage.
:dmg100b => "%sB", # SprintF for 100b+ damage.
:dmg100t => "%sT", # SprintF for 100t+ damage.
:drained => "DRAIN", # Text display for draining HP/MP.
:critical => "CRITICAL!", # Text display for critical hit.
:missed => "MISS", # Text display for missed attack.
:evaded => "EVADE!", # Text display for evaded attack.
:nulled => "NULLED", # Text display for nulled attack.
:failed => "FAILED", # Text display for a failed attack.
:add_state => "+%s", # SprintF for added states.
:rem_state => "-%s", # SprintF for removed states.
:dur_state => "%s", # SprintF for during states.
:ele_rates => true, # This will display elemental affinities.
:ele_wait => 20, # This is how many frames will wait.
:weakpoint => "WEAKPOINT", # Appears if foe is weak to element.
:immune => "IMMUNE", # Appears if foe is immune to element.
:resistant => "RESISTANT", # Appears if foe is resistant to element.
:absorbed => "ABSORBED", # Appears if foe can absorb the element.
} # Do not remove this.

# The following hash determines all of the rules popups will follow. You
# may even make up your own rules.
RULES ={ # Do not remove the DEFAULT pop up.
# Type =>
"DEFAULT" => ,
"CRITICAL" => ,
"HP_DMG" => ,
"HP_HEAL" => ,
"MP_DMG" => ,
"MP_HEAL" => ,
"ADDSTATE" => ,
"REMSTATE" => ,
"DURSTATE" => ,
"DRAIN" => ,
"POSITIVE" => ,
"NEGATIVE" => ,
"WEAK_ELE" => ,
"IMMU_ELE" => ,
"REST_ELE" => ,
"ABSB_ELE" => ,
} # Do not remove this.

end # POPUP
module OBJ_WINDOW

#=========================================================================
# Object Window
# ------------------------------------------------------------------------
# The object window will shrink down the size of both the skill and item
# windows as so it will not obscure the view of the enemies.
#=========================================================================

# Set this to true to enable smaller object windows for both skills and
# items. This will also cause some other YEZ windows to become smaller.
SMALLER_WINDOW = true

end # OBJ_WINDOW
module OPTIONS

#=========================================================================
# Option Window
# ------------------------------------------------------------------------
# The Option Window allows you to adjust things such as sound, volume,
# battle speed, animations, etc. in the middle of battle. The following
# is the index to command list reference guide.
# :blank
# :volume_bgm
# :volume_bgs
# :volume_sfx
# :animations
# :autocursor
# :skill_help
# :next_actor
#=========================================================================

# Use this to order the command list for the Options Window.
COMMANDS = # Do not remove this.

# The follow is a list of how you want the vocabulary to appear for each
# of the individual options commands.
VOCAB ={ # This is a list of the various actions.
:bgm_volume => "BGM Volume",
:bgs_volume => "BGS Volume",
:sfx_volume => "SFX Volume",
:percent => "Audio %d%%",
:mute => "Mute",
:sound_des => "Adjusts audio volume. L/R to Mute and Unmute.",
:animations => "Animations",
:ani_hide => "Hide",
:ani_show => "Show",
:ani_des => "Enables/Disables battle animations.",
:cursor_mem => "AutoCursor",
:curmem_on => "Memory",
:curmem_off => "Reset",
:cur_des => "Enables/Disables cursor memory for actions.",
:skill_help => "Skill Help",
:skhelp_on => "Enabled",
:skhelp_off => "Disable",
:skhelp_des => "Display skill descriptions during battle phase.",
:auto_next => "Next Actor",
:next_on => "Auto",
:next_off => "Manual",
:next_des => "Move to next actor after selecting commands",
} # Do not remove this.

# The following are the variable ID's used to adjust audio volume.
BGM_VOLUME_VARIABLE = 21
BGS_VOLUME_VARIABLE = 22
SFX_VOLUME_VARIABLE = 23

# The following are the switch ID's used to adjust various options.
MUTE_BGM_SWITCH = 21
MUTE_BGS_SWITCH = 22
MUTE_SFX_SWITCH = 23
DISABLE_ANI_SWITCH = 24
AUTO_CURSOR_SWITCH = 25
SKILL_HELP_SWITCH = 26
NEXT_ACTOR_SWITCH = 27

end # OPTIONS
module TURN_ORDERS

#=========================================================================
# Turn Orders Window
# ------------------------------------------------------------------------
# This window gives the player a forecast of the upcoming battle phase.
# The forecast lists the action order between the enemies and actors. The
# forecast is not 100% accurate and does not stay consistent as various
# factors during the battle phase can reorder the way the participants
# will perform. This window also provides a ground for debugging, too.
#=========================================================================

# This is the text that will appear at the top for the turn order window.
DESCRIPTION = "Estimated Battle Phase Turn Order"

# In $TEST and $BTEST mode, the battler's speed will be shown at the very
# bottom of the window.
DEBUG_SHOW_SPEED = true

# The following will allow you to decide whether or not you wish for the
# display window to list the enemy's action. Debug mode will show the
# enemy action underneath if needed.
DISPLAY_ENEMY_ACTION = false
DEBUG_ENEMY_ACTION = false

# The following hash determines which name are associated with regular
# and basic actions if they are drawn. Otherwise, skills and items will
# display their normal icons and names.
VOCAB ={
# Action => Description
:unknown => "Unknown",
:attack => "Attack",
:guard => "Defend",
:escape => "Escape",
:nothing => "Nothing",
} # Do not remove this.

end # TURN_ORDERS
module STATUS

#=========================================================================
# Status Window
# ------------------------------------------------------------------------
# When looking up information on a battler, a miniature version of their
# status window will appear to display helpful information regarding the
# battler. This information will include stats, elemental affinities,
# status resistances, and more. Adjust the following settings accordingly.
#=========================================================================

# The following determines the elements shown in the status window and
# the icons associated with the elements. Icons have to be manually added
# due to the fact that elements don't initially have any icons.
SHOWN_ELEMENTS =
ELEMENT_ICONS = {
# ID => Icon
11 => 132,
12 => 104,
13 => 105,
14 => 106,
15 => 108,
16 => 107,
17 => 109,
18 => 110,
19 => 111,
20 => 128,
} # Do not remove this.

# The following determines what states will be shown on the battler's
# resistance to them.
SHOWN_STATES =

# The following will determine what icon is used to show the affinity
# towards an element or what resistance towardss a state for the battler.
AFFINITY_RANKS ={
:up => 142,
:down => 143,
} # Do not remove this.

# The rank colour adjusts the different colours used for each milestone
# percentile achieved by the actor. Values below are text colours.
RANK_COLOUR = {
:srank => 2,
:arank => 2,
:brank => 21,
:crank => 6,
:drank => 24,
:erank => 4,
:frank => 5,
} # Do not remove this.
# This determines the font size used for the ranks numbers.
RANK_FONT_SIZE = 12

# This is for actors only, but this is the order of stats shown for the
# ally status window. Note that if you don't have the appropiate YEZ
# script, the stat will be skipped over and the next stat will be drawn
# in its previous place.
SHOWN_STATS =

end # STATUS
end # BATTLE
end # YEZ

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

module YEZ
module REGEXP
module ENEMY

ATTACK_ANIMATION = /<(?:ATTACK_ANIMATION|attack animation)*(\d+)>/i

end # ENEMY
module STATE

POPUP_ADD = /^<(?:POPUP_ADD_RULE|popup add rule|popup add):(.*)>/i
POPUP_REM = /^<(?:POPUP_REM_RULE|popup rem rule|popup rem):(.*)>/i
POPUP_DUR = /^<(?:POPUP_DUR_RULE|popup dur rule|popup dur):(.*)>/i

HIDE_ADD = /<(?:POPUP_HIDE_ADD|popup hide add|hide add)>/i
HIDE_REM = /<(?:POPUP_HIDE_REM|popup hide rem|hide rem)>/i
HIDE_DUR = /<(?:POPUP_HIDE_DUR|popup hide dur|hide dur)>/i

REVEALED = /<(?:REVEALED_ACTIONS|revealed actions|reveal actions)>/i
CONCEALED = /<(?:CONCEALED_ACTIONS|concealed actions|conceal actions)>/i

end # STATE
end # REGEXP
end # YEZ

module Vocab
def self.hit; return "HIT"; end
def self.eva; return "EVA"; end
def self.cri; return "CRI"; end
def self.odds;return "AGR"; end
end # Vocab

module RPG
class BGM < AudioFile
def play
if @name.empty?
Audio.bgm_stop
@@last = BGM.new
else
vol = @volume
if $game_variables != nil
vol *= 100 - $game_variables
vol /= 100
vol = [.max, 100].min
vol = 0 if $game_switches
end
Audio.bgm_play("Audio/BGM/" + @name, vol, @pitch)
@@last = self
end
end #Play
end # BGM
class ME < AudioFile
def play
if @name.empty?
Audio.me_stop
else
vol = @volume
if $game_variables != nil
vol *= 100 - $game_variables
vol /= 100
vol = [.max, 100].min
vol = 0 if $game_switches
end
Audio.me_play("Audio/ME/" + @name, vol, @pitch)
end
end
end # ME
class SE < AudioFile
def play
unless @name.empty?
vol = @volume
if $game_variables != nil
vol *= 100 - $game_variables
vol /= 100
vol = [.max, 100].min
vol = 0 if $game_switches
end
Audio.se_play("Audio/SE/" + @name, vol, @pitch)
end
end
def self.stop
Audio.se_stop
end
end # SE

class BGS < AudioFile
def play
if @name.empty?
Audio.bgs_stop
@@last = BGS.new
else
vol = @volume
if $game_variables != nil
vol *= 100 - $game_variables
vol /= 100
vol = [.max, 100].min
vol = 0 if $game_switches
end
Audio.bgs_play("Audio/BGS/" + @name, vol, @pitch)
@@last = self
end
end
end # BGS
end # RPG

#===============================================================================
# RPG::Enemy
#===============================================================================

class RPG::Enemy

#--------------------------------------------------------------------------
# common cache: yez_cache_enemy_bez
#--------------------------------------------------------------------------
def yez_cache_enemy_bez
@attack_animation = YEZ::BATTLE::PARTY_WINDOW::ENEMY_ATTACK_ANI

self.note.split(/+/).each { |line|
case line
when YEZ::REGEXP::ENEMY::ATTACK_ANIMATION
@attack_animation = $1.to_i
end
} # end self.note.split
end # yez_cache_enemy_bez

#--------------------------------------------------------------------------
# definitions
#--------------------------------------------------------------------------
def attack_animation
yez_cache_enemy_bez if @attack_animation == nil
return @attack_animation
end

end # RPG::Enemy

#===============================================================================
# RPG::State
#===============================================================================

class RPG::State

#--------------------------------------------------------------------------
# common cache: yez_cache_state_bez
#--------------------------------------------------------------------------
def yez_cache_state_bez
@popup_rules = {:add => "ADDSTATE", :rem => "REMSTATE", :dur => nil }
@revealed_actions = false; @concealed_actions = false

self.note.split(/+/).each { |line|
case line
#---
when YEZ::REGEXP::STATE::POPUP_ADD
@popup_rules = $1.to_s
when YEZ::REGEXP::STATE::POPUP_REM
@popup_rules = $1.to_s
when YEZ::REGEXP::STATE::POPUP_DUR
@popup_rules = $1.to_s
when YEZ::REGEXP::STATE::HIDE_ADD
@popup_rules = nil
when YEZ::REGEXP::STATE::HIDE_REM
@popup_rules = nil
when YEZ::REGEXP::STATE::HIDE_DUR
@popup_rules = nil
#---
when YEZ::REGEXP::STATE::REVEALED
@revealed_actions = true
when YEZ::REGEXP::STATE::CONCEALED
@concealed_actions = true
#---
end
} # end self.note.split
end # yez_cache_state_bez

#--------------------------------------------------------------------------
# new method: popup_rules
#--------------------------------------------------------------------------
def popup_rules
yez_cache_state_bez if @popup_rules == nil
return @popup_rules
end

#--------------------------------------------------------------------------
# new method: revealed_actions
#--------------------------------------------------------------------------
def revealed_actions
yez_cache_state_bez if @revealed_actions == nil
return @revealed_actions
end

#--------------------------------------------------------------------------
# new method: concealed_actions
#--------------------------------------------------------------------------
def concealed_actions
yez_cache_state_bez if @concealed_actions == nil
return @concealed_actions
end

end # RPG::State

#===============================================================================
# Game_Battler
#===============================================================================

class Game_Battler

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :action
attr_accessor :last_action
attr_accessor :popup_rules
attr_accessor :popup_value
attr_accessor :saved_cmd_index

#--------------------------------------------------------------------------
# new method: last_action
#--------------------------------------------------------------------------
def last_action
@last_action = Game_BattleAction.new(self) if @last_action == nil
return @last_action
end

#--------------------------------------------------------------------------
# new method: saved_cmd_index
#--------------------------------------------------------------------------
def saved_cmd_index
@saved_cmd_index = 0 if @saved_cmd_index == nil
return @saved_cmd_index
end

#--------------------------------------------------------------------------
# alias method: clear sprite effects
#--------------------------------------------------------------------------
alias clear_sprite_effects_bez clear_sprite_effects unless $@
def clear_sprite_effects
clear_sprite_effects_bez
@popup_rules = "DEFAULT"
@popup_value = nil
end

#--------------------------------------------------------------------------
# alias method: elements_max_rate
#--------------------------------------------------------------------------
alias elements_max_rate_bez elements_max_rate unless $@
def elements_max_rate(element_set)
n = elements_max_rate_bez(element_set)
if $scene.is_a?(Scene_Battle) and YEZ::BATTLE::POPUP::SETTINGS and
$scene.last_target != self and $scene.battle_phase
if n > 100
@popup_rules = "WEAK_ELE"
@popup_value = YEZ::BATTLE::POPUP::SETTINGS
$scene.wait(YEZ::BATTLE::POPUP::SETTINGS)
elsif n == 100
@popup_rules = "DEFAULT"
@popup_value = nil
elsif n > 0
@popup_rules = "REST_ELE"
@popup_value = YEZ::BATTLE::POPUP::SETTINGS
$scene.wait(YEZ::BATTLE::POPUP::SETTINGS)
elsif n == 0
@popup_rules = "IMMU_ELE"
@popup_value = YEZ::BATTLE::POPUP::SETTINGS
$scene.wait(YEZ::BATTLE::POPUP::SETTINGS)
elsif n < 0
@popup_rules = "ABSB_ELE"
@popup_value = YEZ::BATTLE::POPUP::SETTINGS
$scene.wait(YEZ::BATTLE::POPUP::SETTINGS)
end
end
return n
end

end # Game_Battler

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

class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# quick methods: use_sprite? screen_z battler_name battler_hue
#--------------------------------------------------------------------------
def use_sprite?; return true; end
def battler_name; return ""; end
def battler_hue; return 0; end
def screen_z; return 0; end

#--------------------------------------------------------------------------
# new method: screen_x
#--------------------------------------------------------------------------
def screen_x
if YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES.include?(self.index)
n = YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES
else
n = YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES
end
n -= $scene.info_viewport.ox if $scene.info_viewport != nil
n += 128
return n
end

#--------------------------------------------------------------------------
# new method: screen_y
#--------------------------------------------------------------------------
def screen_y
if YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES.include?(self.index)
n = YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES
else
n = YEZ::BATTLE::PARTY_WINDOW::ACTOR_COORDINATES
end
return n
end

#--------------------------------------------------------------------------
# revealed_actions
#--------------------------------------------------------------------------
def revealed_actions
return true
end

#--------------------------------------------------------------------------
# new method: total_skills
#--------------------------------------------------------------------------
def total_skills; return skills; end

end # Game_Actor

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

class Game_Enemy < Game_Battler

#--------------------------------------------------------------------------
# revealed_actions
#--------------------------------------------------------------------------
def revealed_actions
for state in states
return false if state.concealed_actions
return true if state.revealed_actions
end
return false
end

#--------------------------------------------------------------------------
# concealed_actions
#--------------------------------------------------------------------------
def concealed_actions
for state in states
return true if state.concealed_actions
end
return false
end

end # Game_Enemy

#===============================================================================
# Sprite_Battler
#===============================================================================

class Sprite_Battler < Sprite_Base

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias initialize_sprite_bez initialize unless $@
def initialize(viewport, battler = nil)
initialize_sprite_bez(viewport, battler)
@popup_update = 0
@popup_tally = 0
end

#--------------------------------------------------------------------------
# alias method: update
#--------------------------------------------------------------------------
alias update_sprite_bez update unless $@
def update
update_sprite_bez
if @popup_update > 0
update_popup
end
end

#--------------------------------------------------------------------------
# new method: update popup
#--------------------------------------------------------------------------
def update_popup
@popup_update -= 1
for key in @popup_sprite
key = key
next if @popup_sprite == nil
fade_rate = YEZ::BATTLE::POPUP::SETTINGS
@popup_duration -= 1
if @popup_duration <= 0
@popup_sprite.opacity -= YEZ::BATTLE::POPUP::SETTINGS
end
if @popup_height >= 0
@popup_height -= 1
@popup_sprite.oy += 1
end
if @popup_sprite.opacity <= 0
@popup_sprite.bitmap.dispose
@popup_sprite.dispose
@popup_sprite = nil
end
end
end

#--------------------------------------------------------------------------
# new method: create popup
#--------------------------------------------------------------------------
def create_popup(value, popup_rules = "DEFAULT")
rules = YEZ::BATTLE::POPUP::RULES
settings = YEZ::BATTLE::POPUP::SETTINGS
unless rules.include?(popup_rules)
popup_rules = "DEFAULT"
end
array = YEZ::BATTLE::POPUP::RULES
return unless array
@popup_height = {} if @popup_height == nil
bw = settings
bh = Integer(array * 2)
bitmap = Bitmap.new(bw, bh)
bitmap.font.name = array
bitmap.font.size = array
bitmap.font.bold = array
bitmap.font.italic = array
bitmap.font.shadow = false
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(0+1, 12-1, bw, bh, value, 1)
bitmap.draw_text(0+1, 12+1, bw, bh, value, 1)
bitmap.draw_text(0-1, 12-1, bw, bh, value, 1)
bitmap.draw_text(0-1, 12+1, bw, bh, value, 1)
bitmap.font.color.set(array, array, array)
bitmap.draw_text(0, 12, bw, bh, value, 1)
@popup_sprite = {} if @popup_sprite == nil
@popup_duration = {} if @popup_duration == nil
i = @popup_tally
@popup_height = array
@popup_sprite = ::Sprite.new(self.viewport)
@popup_sprite.bitmap = bitmap
@popup_sprite.ox = bw / 2
@popup_sprite.oy = bh / 2
@popup_sprite.x = self.x
@popup_sprite.y = (self.y - self.oy / 2) + settings
@popup_sprite.z = 9000
@popup_sprite.opacity = 256
@popup_duration = settings
@popup_update += settings + (256 / settings)
@popup_tally += 1
end

#--------------------------------------------------------------------------
# alias setup_new_effect
#--------------------------------------------------------------------------
alias setup_new_effect_battlerd setup_new_effect unless $@
def setup_new_effect
setup_new_effect_battlerd
if @battler.popup_value != nil
value = @battler.popup_value
rules = @battler.popup_rules
create_popup(value, rules)
@battler.popup_value = nil
@battler.popup_rules = nil
end
end

end # Sprite_Battler

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

lass Scene_Battle < Scene_Base

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :active_battler
attr_accessor :action_battlers
attr_accessor :actor_index
attr_accessor :battle_phase
attr_accessor :info_viewport
attr_accessor :last_target
attr_accessor :message_window
attr_accessor :status_window
attr_accessor :smaller_obj_window

#--------------------------------------------------------------------------
# overwrite method: start
#--------------------------------------------------------------------------
def start
super
$game_temp.in_battle = true
@battle_phase = false
@spriteset = Spriteset_Battle.new
@message_window = Window_BattleMessageZealous.new
@action_battlers =
create_info_viewport
@smaller_obj_window = YEZ::BATTLE::OBJ_WINDOW::SMALLER_WINDOW
end

#--------------------------------------------------------------------------
# overwrite show_fast?
#--------------------------------------------------------------------------
def show_fast?
return false unless YEZ::BATTLE::ZEALOUS::ALLOW_FAST_FORWARD
return (Input.press?(Input::A) or Input.press?(Input::C))
end

#--------------------------------------------------------------------------
# alias method: create_info_viewport
#--------------------------------------------------------------------------
alias create_info_viewport_bez create_info_viewport unless $@
def create_info_viewport
create_info_viewport_bez
@perform_command_window = Window_PerformCommand.new
@perform_command_window.viewport = @info_viewport
@perform_command_window.x = 544
@perform_command_window.visible = false
@info_viewport.visible = true
@performed_actors =
@party_command_window.index = 0
@perform_command_window.index = 0
@status_window.refresh
end

#--------------------------------------------------------------------------
# alias method: dispose_info_viewport
#--------------------------------------------------------------------------
alias dispose_info_viewport_bez dispose_info_viewport unless $@
def dispose_info_viewport
@perform_command_window.dispose
dispose_info_viewport_bez
end

#--------------------------------------------------------------------------
# alias method: update_info_viewport
#--------------------------------------------------------------------------
alias update_info_viewport_bez update_info_viewport unless $@
def update_info_viewport
return if @options_window != nil
@perform_command_window.update
update_info_viewport_bez
if @perform_command_window.active and @info_viewport.ox < 128
@info_viewport.ox += 16
end
end

#--------------------------------------------------------------------------
# overwrite method: process_battle_start
#--------------------------------------------------------------------------
def process_battle_start
@message_window.clear
wait(10)
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
for name in $game_troop.enemy_names
text = sprintf(Vocab::Emerge, name)
$game_message.texts.push(text)
end
end
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
if $game_troop.preemptive
text = sprintf(Vocab::Preemptive, $game_party.name)
$game_message.texts.push(text)
elsif $game_troop.surprise
text = sprintf(Vocab::Surprise, $game_party.name)
$game_message.texts.push(text)
end
end
wait_for_message
@message_window.clear
make_escape_ratio
if YEZ::BATTLE::ZEALOUS::COMMON_EVENTS != nil
$game_temp.common_event_id = YEZ::BATTLE::ZEALOUS::COMMON_EVENTS
end
$game_troop.make_actions
process_battle_event
start_party_command_selection
end

#--------------------------------------------------------------------------
# overwrite method: update
#--------------------------------------------------------------------------
def update
super
update_basic(true)
update_info_viewport
if $game_message.visible
@info_viewport.visible = false
@message_window.visible = true
end
unless $game_message.visible
return if judge_win_loss
update_scene_change
if @target_enemy_window != nil
update_target_enemy_selection
elsif @ally_query_window != nil
update_ally_status_selection
elsif @target_actor_window != nil
update_target_actor_selection
elsif @skill_window != nil
update_skill_selection
elsif @item_window != nil
update_item_selection
elsif @options_window != nil
update_options_selection
elsif @turn_orders_window != nil
update_turn_orders
elsif @party_command_window.active
update_party_command_selection
elsif @actor_command_window.active
update_actor_command_selection
elsif @perform_command_window.active
update_perform_command_selection
else
process_battle_event
process_action
process_battle_event
end
end
end

#--------------------------------------------------------------------------
# overwrite method: process_escape
#--------------------------------------------------------------------------
def process_escape
@message_window.visible = true
text = sprintf(Vocab::EscapeStart, $game_party.name)
$game_message.texts.push(text)
if $game_troop.preemptive
success = true
else
success = (rand(100) < @escape_ratio)
end
Sound.play_escape
if success
wait_for_message
battle_end(1)
else
@escape_ratio += 10
$game_message.texts.push('\.' + Vocab::EscapeFailure)
wait_for_message
$game_party.clear_actions
start_main
end
end

#--------------------------------------------------------------------------
# overwrite method: process victory
#--------------------------------------------------------------------------
def process_victory
@message_window.visible = true
RPG::BGM.stop
$game_system.battle_end_me.play
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
display_exp_and_gold
display_drop_items
display_level_up
battle_end(0)
if YEZ::BATTLE::ZEALOUS::COMMON_EVENTS != nil
$game_temp.common_event_id = YEZ::BATTLE::ZEALOUS::COMMON_EVENTS
end
end

#--------------------------------------------------------------------------
# overwrite method: process_defeat
#--------------------------------------------------------------------------
def process_defeat
@message_window.visible = true
text = sprintf(Vocab::Defeat, $game_party.name)
$game_message.texts.push(text)
wait_for_message
battle_end(2)
end

#--------------------------------------------------------------------------
# overwrite method: start_party_command_selection
#--------------------------------------------------------------------------
def start_party_command_selection
if $game_temp.in_battle
@status_window.index = @actor_index = -1
if @party_command_window.openness == 0
@party_command_window.openness = 128
@actor_command_window.openness = 128
@perform_command_window.openness = 128
end
@party_command_window.open
@actor_command_window.open
@perform_command_window.open
loop {
break if @info_viewport.ox == 0
update_basic
@party_command_window.update
@actor_command_window.update
@perform_command_window.update
@info_viewport.ox -= 16 }
@active_battler = nil
@info_viewport.visible = true
@message_window.visible = false
@party_command_window.active = true
@actor_command_window.active = false
start_main if $game_troop.surprise or !$game_party.inputable?
end
end

#--------------------------------------------------------------------------
# overwrite method: update_party_command_selection
#--------------------------------------------------------------------------
def update_party_command_selection
if Input.trigger?(Input::C)
case @party_command_window.command
when :actions
Sound.play_decision
@status_window.index = @actor_index = -1
next_actor
when :execute
Sound.play_decision
@party_command_window.active = false
@actor_index = $game_party.members.size - 1
next_actor
when :tactics
if $game_switches
Sound.play_decision
start_macro_selection
else
Sound.play_buzzer
end
when :party
Sound.play_decision
Graphics.freeze
@info_viewport.visible = false
snapshot_for_background
$scene = Scene_Party.new(0, Scene_Party::HOST_BATTLE)
$scene.main
$scene = self
@status_window.refresh
@info_viewport.visible = true
perform_transition
when :options
Sound.play_decision
start_options_selection(1)
when :escape
if $game_troop.can_escape == false
Sound.play_buzzer
return
end
Sound.play_decision
process_escape
end
elsif Input.trigger?(Input::RIGHT)
Sound.play_cursor
@status_window.index = @actor_index = -1
next_actor
elsif Input.trigger?(Input::R)
Sound.play_decision
@party_command_window.active = false
@actor_index = $game_party.members.size - 1
next_actor
# --- Debug Only Commands ---
elsif ($TEST or $BTEST) and Input.trigger?(Input::F9)
for enemy in $game_troop.existing_members
enemy.hp = 0
enemy.perform_collapse
end
elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
Sound.play_recovery
for member in $game_party.members
member.hp = member.maxhp
member.mp = member.maxmp
member.rage += 100 if $imported
end
@status_window.refresh
# --- End Debug Commands ---
end
end

#--------------------------------------------------------------------------
# alias method: start_actor_command_selection
#--------------------------------------------------------------------------
alias start_actor_command_selection_bez start_actor_command_selection unless $@
def start_actor_command_selection
start_actor_command_selection_bez
if !$game_switches
@actor_command_window.index = @active_battler.saved_cmd_index
end
end

#--------------------------------------------------------------------------
# overwrite method: battle_end
#--------------------------------------------------------------------------
def battle_end(result)
@battle_phase = false
if result == 2 and not $game_troop.can_lose
call_gameover
else
$game_party.remove_states_battle
$game_troop.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
$scene = Scene_Map.new
@message_window.clear
Graphics.fadeout(30)
end
$game_temp.in_battle = false
end

#--------------------------------------------------------------------------
# overwrite method: next_actor
#--------------------------------------------------------------------------
def next_actor
loop do
if @actor_index == $game_party.members.size - 1
start_perform_command_selection
return
end
@status_window.draw_item(@active_battler.index) if @active_battler != nil
@status_window.index = @actor_index += 1
@active_battler = $game_party.members
#if @active_battler.auto_battle
# @active_battler.make_action
# next
#end
break if @active_battler.inputable?
end
start_actor_command_selection
end

#--------------------------------------------------------------------------
# overwrite method: prior_actor
#--------------------------------------------------------------------------
def prior_actor
loop do
if @actor_index == 0
start_party_command_selection
return
end
@status_window.draw_item(@active_battler.index) if @active_battler != nil
@status_window.index = @actor_index -= 1
@active_battler = $game_party.members
#next if @active_battler.auto_battle
break if @active_battler.inputable?
end
start_actor_command_selection
end

#--------------------------------------------------------------------------
# new method: start_perform_command_selection
#--------------------------------------------------------------------------
def start_perform_command_selection
@status_window.index = @actor_index = -3
@active_battler = nil
@info_viewport.visible = true
@message_window.visible = false
@perform_command_window.visible = true
@perform_command_window.active = true
@actor_command_window.visible = false
@actor_command_window.active = false
end

#--------------------------------------------------------------------------
# new method: update_perform_command_selection
#--------------------------------------------------------------------------
def update_perform_command_selection
if Input.trigger?(Input::C)
case @perform_command_window.command
when :perform
Sound.play_decision
@perform_command_window.active = false
@perform_command_window.visible = false
@actor_command_window.visible = true
start_main
when :turns
Sound.play_decision
start_turn_orders
when :options
Sound.play_decision
start_options_selection(2)
when :status
Sound.play_decision
start_ally_status_selection
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
@actor_index = $game_party.members.size
@perform_command_window.active = false
@perform_command_window.visible = false
@actor_command_window.active = true
@actor_command_window.visible = true
prior_actor
elsif Input.trigger?(Input::LEFT)
Sound.play_cursor
@actor_index = $game_party.members.size
@perform_command_window.active = false
@perform_command_window.visible = false
@actor_command_window.active = true
@actor_command_window.visible = true
prior_actor
elsif Input.trigger?(Input::L)
Sound.play_decision
@actor_index = 0
@perform_command_window.active = false
@perform_command_window.visible = false
@actor_command_window.active = true
@actor_command_window.visible = true
start_party_command_selection
# --- Debug Only Commands ---
elsif ($TEST or $BTEST) and Input.trigger?(Input::F9)
for enemy in $game_troop.existing_members
enemy.hp = 0
enemy.perform_collapse
end
elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
Sound.play_recovery
for member in $game_party.members
member.hp = member.maxhp
member.mp = member.maxmp
member.rage += 100 if $imported
end
@status_window.refresh
# --- End Debug Commands ---
end
end

#--------------------------------------------------------------------------
# new method: start_options_selection
#--------------------------------------------------------------------------
def start_options_selection(options_type)
@options_type = options_type
@options_window = Window_Battle_Option.new
@options_window.active = true
@help_window = Window_Help.new
@options_window.help_window = @help_window
@party_command_window.active = false
@perform_command_window.active = false
end

#--------------------------------------------------------------------------
# new method: end_options_selection
#--------------------------------------------------------------------------
def end_options_selection
if @options_type == 1
@party_command_window.active = true
else
@perform_command_window.active = true
end
@options_window.dispose
@options_window = nil
@help_window.dispose
@help_window = nil
end

#--------------------------------------------------------------------------
# new method: update_options_selection
#--------------------------------------------------------------------------
def update_options_selection
@options_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
end_options_selection
elsif Input.repeat?(Input::LEFT)
options_input_left
elsif Input.repeat?(Input::RIGHT)
options_input_right
elsif Input.trigger?(Input::L)
options_input_l
elsif Input.trigger?(Input::R)
options_input_r
end
end

#--------------------------------------------------------------------------
# new method: options_input_left
#--------------------------------------------------------------------------
def options_input_left
case @options_window.item
when :volume_bgm # BGM Volume
variable = YEZ::BATTLE::OPTIONS::BGM_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables >= 100
$game_variables += Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)
RPG::BGM::last.play

when :volume_bgs # BGS Volume
variable = YEZ::BATTLE::OPTIONS::BGS_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables >= 100
$game_variables += Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)
RPG::BGS::last.play

when :volume_sfx # SFX Volume
variable = YEZ::BATTLE::OPTIONS::SFX_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables >= 100
$game_variables += Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)

when :animations # Disable Animations
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :autocursor # Disable Cursor Memory
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :skill_help # Skill Help
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :next_actor # Next Actor
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

end
end

#--------------------------------------------------------------------------
# new method: options_input_right
#--------------------------------------------------------------------------
def options_input_right
case @options_window.item
when :volume_bgm # BGM Volume
variable = YEZ::BATTLE::OPTIONS::BGM_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables <= 0
$game_variables -= Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)
RPG::BGM::last.play

when :volume_bgs # BGS Volume
variable = YEZ::BATTLE::OPTIONS::BGS_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables <= 0
$game_variables -= Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)
RPG::BGS::last.play

when :volume_sfx # SFX Volume
variable = YEZ::BATTLE::OPTIONS::SFX_VOLUME_VARIABLE
Sound.play_cursor unless $game_variables <= 0
$game_variables -= Input.press?(Input::SHIFT) ? 10 : 1
$game_variables = [[$game_variables, 0].max, 100].min
@options_window.draw_item(@options_window.index)

when :animations # Disable Animations
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :autocursor # Disable Cursor Memory
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :skill_help # Skill Help
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :next_actor # Next Actor
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

end
end

#--------------------------------------------------------------------------
# new method: options_input_l
#--------------------------------------------------------------------------
def options_input_l
case @options_window.item
when :volume_bgm # BGM Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_BGM_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)
RPG::BGM::last.play

when :volume_bgs # BGS Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_BGS_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)
RPG::BGS::last.play

when :volume_sfx # SFX Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_SFX_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)

when :animations # Disable Animations
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :autocursor # Disable Cursor Memory
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :skill_help # Skill Help
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :next_actor # Next Actor
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

end
end

#--------------------------------------------------------------------------
# new method: options_input_r
#--------------------------------------------------------------------------
def options_input_r
case @options_window.item
when :volume_bgm # BGM Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_BGM_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)
RPG::BGM::last.play

when :volume_bgs # BGS Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_BGS_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)
RPG::BGS::last.play

when :volume_sfx # SFX Volume
Sound.play_decision
switch = YEZ::BATTLE::OPTIONS::MUTE_SFX_SWITCH
$game_switches = !$game_switches
@options_window.draw_item(@options_window.index)

when :animations # Disable Animations
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :autocursor # Disable Cursor Memory
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

when :skill_help # Skill Help
if $game_switches
Sound.play_decision
$game_switches = false
@options_window.draw_item(@options_window.index)
end

when :next_actor # Next Actor
if !$game_switches
Sound.play_decision
$game_switches = true
@options_window.draw_item(@options_window.index)
end

end
end

#--------------------------------------------------------------------------
# new method: start_turn_orders
#--------------------------------------------------------------------------
def start_turn_orders
make_action_orders
@turn_orders_window = Window_Turn_Orders.new
@order_image_window = Window_Order_Image.new(@turn_orders_window.item)
@help_window = Window_Help.new
@help_window.set_text(YEZ::BATTLE::TURN_ORDERS::DESCRIPTION,1)
@party_command_window.active = false
@perform_command_window.active = false
@last_index = 0
end

#--------------------------------------------------------------------------
# new method: end_turn_orders
#--------------------------------------------------------------------------
def end_turn_orders
@perform_command_window.active = true
@turn_orders_window.dispose
@turn_orders_window = nil
@order_image_window.dispose
@order_image_window = nil
@help_window.dispose
@help_window = nil
end

#--------------------------------------------------------------------------
# new method: update_turn_orders
#--------------------------------------------------------------------------
def update_turn_orders
@turn_orders_window.update
if @last_index != @turn_orders_window.index
@last_index = @turn_orders_window.index
@order_image_window.refresh(@turn_orders_window.item)
end
if Input.trigger?(Input::B)
Sound.play_cancel
end_turn_orders
end
end

#--------------------------------------------------------------------------
# new method: start_ally_status_selection
#--------------------------------------------------------------------------
def start_ally_status_selection
@status_window.index = 0
@status_window.active = true
@last_index = 0
@ally_query_window = Window_AllyQuery.new
@status_query_window = Window_StatusQuery.new
@perform_command_window.active = false
end

#--------------------------------------------------------------------------
# new method: end_ally_status_selection
#--------------------------------------------------------------------------
def end_ally_status_selection
@perform_command_window.active = true
@status_window.active = false
@status_window.index = -1
@ally_query_window.dispose
@ally_query_window = nil
@status_query_window.dispose
@status_query_window = nil
end

#--------------------------------------------------------------------------
# new method: update_ally_status_selection
#--------------------------------------------------------------------------
def update_ally_status_selection
@status_query_window.update
if @last_index != @status_window.index
@last_index = @status_window.index
@ally_query_window.refresh(@status_window.index)
@status_query_window.refresh(@status_window.index)
end
if Input.trigger?(Input::B)
Sound.play_cancel
@status_window.visible = true
end_ally_status_selection
end
end

#--------------------------------------------------------------------------
# new method: confirm_action
#--------------------------------------------------------------------------
def confirm_action
@status_window.draw_item(@active_battler.index)
@active_battler.saved_cmd_index = @actor_command_window.index
if !$game_switches
next_actor
elsif $imported and instant_cast_skill?
next_actor
end
end

#--------------------------------------------------------------------------
# new method: cancel_action
#--------------------------------------------------------------------------
def cancel_action
@active_battler.action.kind = 0
@active_battler.action.basic = 3
@active_battler.last_action = Game_BattleAction.new(@active_battler)
@status_window.draw_item(@active_battler.index)
@mini_window.refresh if @mini_window != nil
if !$game_switches and
@actor_command_window.active
prior_actor
end
end

#--------------------------------------------------------------------------
# overwrite method: start_target_enemy_selection
#--------------------------------------------------------------------------
def start_target_enemy_selection
@target_enemy_window = Window_TargetEnemy.new
@target_enemy_window.y = -2 * @target_enemy_window.height
@actor_command_window.active = false
if !YEZ::BATTLE::ZEALOUS::SORT_LEFT_TO_RIGHT
@target_enemy_window.index = @target_enemy_window.item_max - 1
end
@target_help_window = Window_TargetHelp.new(@target_enemy_window)
@last_index = @target_enemy_window.index
@help_window.visible = false unless @help_window == nil
@mini_window.refresh if @mini_window != nil
hide_smaller_obj_window unless @smaller_obj_window
end

#--------------------------------------------------------------------------
# overwrite method: end_target_enemy_selection
#--------------------------------------------------------------------------
def end_target_enemy_selection
@target_enemy_window.dispose
@target_enemy_window = nil
@target_help_window.dispose
@target_help_window = nil
if @actor_command_window.index == 0
@actor_command_window.active = true
end
@help_window.visible = true unless @help_window == nil
show_smaller_obj_window unless @smaller_obj_window
end

#--------------------------------------------------------------------------
# overwrite method: update_target_enemy_selection
#--------------------------------------------------------------------------
def update_target_enemy_selection
@target_enemy_window.update
@target_enemy_window.enemy.white_flash = true if @target_enemy_window != nil
if @last_index != @target_enemy_window.index
@last_index = @target_enemy_window.index
@target_help_window.refresh(@last_index) if @target_help_window != nil
end
if Input.trigger?(Input::B)
Sound.play_cancel
cancel_action
end_target_enemy_selection
elsif Input.trigger?(Input::C)
Sound.play_decision
@active_battler.action.target_index = @target_enemy_window.enemy.index
end_target_enemy_selection
end_skill_selection
end_item_selection
confirm_action
end
end

#--------------------------------------------------------------------------
# alias method: start_target_actor_selection
#--------------------------------------------------------------------------
alias start_target_actor_selection_bez start_target_actor_selection unless $@
def start_target_actor_selection
start_target_actor_selection_bez
@mini_window.refresh if @mini_window != nil
@help_window.visible = false
@target_help_window = Window_TargetHelp.new(@target_actor_window)
@last_index = 0
hide_smaller_obj_window if @smaller_obj_window
end

#--------------------------------------------------------------------------
# alias method: end_target_actor_selection
#--------------------------------------------------------------------------
alias end_target_actor_selection_bez end_target_actor_selection unless $@
def end_target_actor_selection
@help_window.visible = true
end_target_actor_selection_bez
@target_help_window.dispose
@target_help_window = nil
show_smaller_obj_window if @smaller_obj_window
end

#--------------------------------------------------------------------------
# overwrite update_target_actor_selection
#--------------------------------------------------------------------------
def update_target_actor_selection
@target_actor_window.update
if @last_index != @target_actor_window.index
@last_index = @target_actor_window.index
@target_help_window.refresh(@last_index) if @target_help_window != nil
end
if Input.trigger?(Input::B)
Sound.play_cancel
cancel_action
end_target_actor_selection
elsif Input.trigger?(Input::C)
Sound.play_decision
@active_battler.action.target_index = @target_actor_window.index
end_target_actor_selection
end_skill_selection
end_item_selection
confirm_action
end
end

#--------------------------------------------------------------------------
# overwrite method: update_actor_command_selection
#--------------------------------------------------------------------------
def update_actor_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
cancel_action
elsif Input.trigger?(Input::C)
case @actor_command_window.index
when 0 # Attack
Sound.play_decision
@active_battler.action.set_attack
@status_window.draw_item(@active_battler.index)
start_target_enemy_selection
when 1 # Skill
Sound.play_decision
start_skill_selection
when 2 # Guard
Sound.play_decision
@active_battler.action.set_guard
confirm_action
when 3 # Item
Sound.play_decision
start_item_selection
end
elsif Input.trigger?(Input::L)
Sound.play_decision
@actor_index = 0
prior_actor
elsif Input.trigger?(Input::R)
Sound.play_decision
@party_command_window.active = false
@actor_index = $game_party.members.size - 1
next_actor
elsif Input.repeat?(Input::LEFT)
Sound.play_cursor
prior_actor
elsif Input.repeat?(Input::RIGHT)
Sound.play_cursor
next_actor
# --- Debug Only Commands ---
elsif ($TEST or $BTEST) and Input.trigger?(Input::F9)
for enemy in $game_troop.existing_members
enemy.hp = 0
enemy.perform_collapse
end
elsif ($TEST or $BTEST) and Input.trigger?(Input::F5)
Sound.play_recovery
@active_battler.hp = @active_battler.maxhp
@active_battler.mp = @active_battler.maxmp
@active_battler.rage += 100 if $imported
@status_window.draw_item(@active_battler.index)
# --- End Debug Commands ---
end
end

#--------------------------------------------------------------------------
# new method: start_smaller_obj_window
#--------------------------------------------------------------------------
def start_smaller_obj_window
@info_viewport.oy = 128
@mini_window = Window_BattleMini.new
end

#--------------------------------------------------------------------------
# new method: hide_smaller_obj_window
#--------------------------------------------------------------------------
def hide_smaller_obj_window
@status_window.draw_item(@active_battler.index)
@skill_window.visible = false if @skill_window != nil
@item_window.visible = false if @item_window != nil
end

#--------------------------------------------------------------------------
# new method: show_smaller_obj_window
#--------------------------------------------------------------------------
def show_smaller_obj_window
@info_viewport.oy = 128
@skill_window.visible = true if @skill_window != nil
@item_window.visible = true if @item_window != nil
end

#--------------------------------------------------------------------------
# new method: end_smaller_obj_window
#--------------------------------------------------------------------------
def end_smaller_obj_window
@info_viewport.oy = 0
@status_window.draw_item(@active_battler.index)
if @mini_window != nil
@mini_window.dispose
@mini_window = nil
end
end

#--------------------------------------------------------------------------
# overwrite method: determine_skill
#--------------------------------------------------------------------------
def determine_skill
@active_battler.action.set_skill(@skill.id)
@skill_window.active = false
if @skill.need_selection?
if @skill.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_skill_selection
confirm_action
end
end

#--------------------------------------------------------------------------
# overwrite method: start_skill_selection
#--------------------------------------------------------------------------
def start_skill_selection
@help_window = Window_Help.new
if @smaller_obj_window
@skill_window = Window_Skill.new(0, 288, 416, 128, @active_battler)
start_smaller_obj_window
else
@skill_window = Window_Skill.new(0, 56, 544, 232, @active_battler)
end
@skill_window.help_window = @help_window
@actor_command_window.active = false
end

#--------------------------------------------------------------------------
# alias method: end_skill_selection
#--------------------------------------------------------------------------
alias end_skill_selection_bez end_skill_selection unless $@
def end_skill_selection
end_smaller_obj_window if @smaller_obj_window
end_skill_selection_bez
end

#--------------------------------------------------------------------------
# overwrite method: determine_item
#--------------------------------------------------------------------------
def determine_item
@active_battler.action.set_item(@item.id)
@item_window.active = false
if @item.need_selection?
if @item.for_opponent?
start_target_enemy_selection
else
start_target_actor_selection
end
else
end_item_selection
confirm_action
end
end

#--------------------------------------------------------------------------
# overwrite method: start_item_selection
#--------------------------------------------------------------------------
def start_item_selection
@help_window = Window_Help.new
if @smaller_obj_window
@item_window = Window_Item.new(0, 288, 416, 128)
start_smaller_obj_window
else
@item_window = Window_Item.new(0, 56, 544, 232)
end
@item_window.help_window = @help_window
@actor_command_window.active = false
end
#--------------------------------------------------------------------------
# alias method: end_item_selection
#--------------------------------------------------------------------------
alias end_item_selection_bez end_item_selection unless $@
def end_item_selection
end_smaller_obj_window if @smaller_obj_window
end_item_selection_bez
end

#--------------------------------------------------------------------------
# overwrite method: start_main
#--------------------------------------------------------------------------
def start_main
if YEZ::BATTLE::ZEALOUS::COMMON_EVENTS != nil
$game_temp.common_event_id = YEZ::BATTLE::ZEALOUS::COMMON_EVENTS
end
@status_window.refresh
$game_troop.increase_turn
@status_window.index = @actor_index = -1
@party_command_window.openness = 128
@party_command_window.close
@actor_command_window.openness = 128
@actor_command_window.close
@perform_command_window.openness = 128
@perform_command_window.close
loop {
update_basic
@party_command_window.update
@actor_command_window.update
@perform_command_window.update
break if @info_viewport.ox == 64
if @info_viewport.ox > 64
@info_viewport.ox -= 16
else
@info_viewport.ox += 16
end }
@message_window.visible = true
@party_command_window.active = false
@perform_command_window.active = false
@active_battler = nil
@message_window.clear
@performed_actors =
make_action_orders
wait(20)
end

#--------------------------------------------------------------------------
# overwrite turn end
#--------------------------------------------------------------------------
def turn_end
if YEZ::BATTLE::ZEALOUS::COMMON_EVENTS != nil
$game_temp.common_event_id = YEZ::BATTLE::ZEALOUS::COMMON_EVENTS
end
$game_troop.turn_ending = true
$game_party.slip_damage_effect
$game_troop.slip_damage_effect
$game_party.do_auto_recovery
$game_troop.preemptive = false
$game_troop.surprise = false
$game_troop.make_actions
process_battle_event
$game_troop.turn_ending = false
@status_window.refresh
start_party_command_selection
end

#--------------------------------------------------------------------------
# overwrite method: set_next_active_battler
#--------------------------------------------------------------------------
def set_next_active_battler
@performed_actors = if @performed_actors == nil
loop do
if $game_troop.forcing_battler != nil
@active_battler = $game_troop.forcing_battler
@action_battlers.delete(@active_battler)
$game_troop.forcing_battler = nil
else
make_action_orders
@action_battlers -= @performed_actors
@active_battler = @action_battlers.shift
end
@performed_actors.push(@active_battler) unless @active_battler == nil
return if @active_battler == nil
return if @active_battler.index != nil
end
end

#--------------------------------------------------------------------------
# overwrite method: display_current_state
#--------------------------------------------------------------------------
def display_current_state
return unless YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
state_text = @active_battler.most_important_state_text
unless state_text.empty?
wait(5)
text = @active_battler.name + state_text
@message_window.add_instant_text(text)
wait(45)
@message_window.clear
end
end

#--------------------------------------------------------------------------
# new method: sort_targets
#--------------------------------------------------------------------------
def sort_targets(targets)
if YEZ::BATTLE::ZEALOUS::SORT_LEFT_TO_RIGHT
targets.sort! { |a,b| a.screen_x <=> b.screen_x }
else
targets.sort! { |a,b| b.screen_x <=> a.screen_x }
end
return targets
end

#--------------------------------------------------------------------------
# alias method: execute_action
#--------------------------------------------------------------------------
alias execute_action_bez execute_action unless $@
def execute_action
@battle_phase = true
if !@active_battler.action.forcing
@active_battler.last_action = @active_battler.action.clone
end
execute_action_bez
if @active_battler.action.forcing
@active_battler.action = @active_battler.last_action
end
@battle_phase = false
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_attack
#--------------------------------------------------------------------------
def execute_action_attack
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
text = sprintf(Vocab::DoAttack, @active_battler.name)
@message_window.add_instant_text(text)
end
targets = @active_battler.action.make_targets
targets = sort_targets(targets)
display_attack_animation(targets)
wait(20)
for target in targets
target.attack_effect(@active_battler)
display_action_effects(target)
target.perform_collapse
end
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_guard
#--------------------------------------------------------------------------
def execute_action_guard
return unless YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
text = sprintf(Vocab::DoGuard, @active_battler.name)
@message_window.add_instant_text(text)
wait(45)
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_escape
#--------------------------------------------------------------------------
def execute_action_escape
text = sprintf(Vocab::DoEscape, @active_battler.name)
@message_window.add_instant_text(text)
@active_battler.escape
Sound.play_escape
wait(45)
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_wait
#--------------------------------------------------------------------------
def execute_action_wait
return unless YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
text = sprintf(Vocab::DoWait, @active_battler.name)
@message_window.add_instant_text(text)
wait(45)
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_skill
#--------------------------------------------------------------------------
unless $imported
def execute_action_skill
skill = @active_battler.action.skill
zealous_skill_message(skill)
targets = @active_battler.action.make_targets
targets = sort_targets(targets)
display_animation(targets, skill.animation_id)
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
$game_temp.common_event_id = skill.common_event_id
@last_target = nil
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
target.perform_collapse
@last_target = target
end
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end
end

#--------------------------------------------------------------------------
# new method: zealous_skill_message
#--------------------------------------------------------------------------
def zealous_skill_message(skill)
if !skill.message1.empty? and YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
text = @active_battler.name + skill.message1
@message_window.add_instant_text(text)
end
if !skill.message2.empty? and YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
wait(10) unless skill.message1.empty?
@message_window.add_instant_text(skill.message2)
end
if $game_switches and
!skill.description.empty?
wait(10) if !skill.message1.empty? or !skill.message2.empty?
text = skill.description
text.gsub!(/\\V\[(+)\]/i) { $game_variables }
text.gsub!(/\\V\[(+)\]/i) { $game_variables }
text.gsub!(/\\N\/i) { @active_battler.name }
text.gsub!(/\\N\[(+)\]/i) { $game_actors.name }
@message_window.add_instant_text(text)
end
end

#--------------------------------------------------------------------------
# overwrite method: execute_action_item
#--------------------------------------------------------------------------
def execute_action_item
item = @active_battler.action.item
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
@message_window.add_instant_text(text)
end
targets = @active_battler.action.make_targets
targets = sort_targets(targets)
display_animation(targets, item.animation_id)
$game_party.consume_item(item)
$game_temp.common_event_id = item.common_event_id
@last_target = nil
for target in targets
target.item_effect(@active_battler, item)
display_action_effects(target, item)
target.perform_collapse
@last_target = target
end
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end

#--------------------------------------------------------------------------
# overwrite method: display_attack_animation
#--------------------------------------------------------------------------
def display_attack_animation(targets)
if @active_battler.is_a?(Game_Enemy)
aid1 = @active_battler.enemy.attack_animation
display_normal_animation(targets, aid1, false)
else
aid1 = @active_battler.atk_animation_id
aid2 = @active_battler.atk_animation_id2
display_normal_animation(targets, aid1, false)
display_normal_animation(targets, aid2, true)
end
wait_for_animation
end

#--------------------------------------------------------------------------
# alias method: display_normal_animation
#--------------------------------------------------------------------------
alias display_normal_animation_bez display_normal_animation unless $@
def display_normal_animation(targets, animation_id, mirror = false)
return if $game_switches
display_normal_animation_bez(targets, animation_id, mirror)
end

#--------------------------------------------------------------------------
# overwrite method: display_critical
#--------------------------------------------------------------------------
def display_critical(target, obj = nil)
if target.critical
target.popup_rules = "CRITICAL"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
if target.actor?
text = Vocab::CriticalToActor
else
text = Vocab::CriticalToEnemy
end
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text(text)
end
wait(20)
end
end

#--------------------------------------------------------------------------
# overwrite method: display_miss
#--------------------------------------------------------------------------
def display_miss(target, obj = nil)
Sound.play_miss
target.popup_rules = "DEFAULT"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
if obj == nil or obj.physical_attack
if target.actor?
text = sprintf(Vocab::ActorNoHit, target.name)
else
text = sprintf(Vocab::EnemyNoHit, target.name)
end
else
text = sprintf(Vocab::ActionFailure, target.name)
end
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text(text)
end
wait(30)
end

#--------------------------------------------------------------------------
# overwrite method: display_evasion
#--------------------------------------------------------------------------
def display_evasion(target, obj = nil)
Sound.play_evasion
target.popup_rules = "DEFAULT"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
if target.actor?
text = sprintf(Vocab::ActorEvasion, target.name)
else
text = sprintf(Vocab::EnemyEvasion, target.name)
end
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text(text)
end
wait(30)
end

#--------------------------------------------------------------------------
# overwrite method: display_failure
#--------------------------------------------------------------------------
def display_failure(target, obj)
return unless YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
target.popup_rules = YEZ::BATTLE::POPUP::RULES
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
text = sprintf(Vocab::ActionFailure, target.name)
@message_window.add_instant_text(text)
wait(20)
end

#--------------------------------------------------------------------------
# new method: popup_convert_number
#--------------------------------------------------------------------------
def popup_convert_number(value)
settings = YEZ::BATTLE::POPUP::SETTINGS
value = value.abs
if value.is_a?(Integer)
if value >= 100000000000000
value = sprintf(settings, value / 1000000000000)
elsif value >= 100000000000
value = sprintf(settings, value / 1000000000)
elsif value >= 100000000
value = sprintf(settings, value / 1000000)
elsif value >= 100000
value = sprintf(settings, value / 1000)
end
end
return value
end

#--------------------------------------------------------------------------
# overwrite method: display_hp_damage
#--------------------------------------------------------------------------
def display_hp_damage(target, obj = nil)
if target.hp_damage == 0
return if obj != nil and obj.damage_to_mp
return if obj != nil and obj.base_damage == 0
fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
text = sprintf(fmt, target.name)
elsif target.absorbed
fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
elsif target.hp_damage > 0
if target.actor?
text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
Sound.play_actor_damage
if YEZ::BATTLE::PARTY_WINDOW::DMG_SHAKE_SCREEN
$game_troop.screen.start_shake(5, 5, 10)
end
else
text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
Sound.play_enemy_damage
target.blink = true
end
else
fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
Sound.play_recovery
end
#---
value = popup_convert_number(target.hp_damage)
if target.hp_damage == 0
target.popup_rules = "DEFAULT"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
elsif target.hp_damage > 0
if target.absorbed
target.popup_rules = "DRAIN"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
wait(20)
@active_battler.popup_rules = "HP_HEAL"
@active_battler.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end
target.popup_rules = "HP_DMG"
target.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
else
if target.absorbed
@active_battler.popup_rules = "HP_DMG"
@active_battler.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end
target.popup_rules = "HP_HEAL"
target.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
end
#---
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text(text)
end
wait(30)
end

#--------------------------------------------------------------------------
# overwrite method: display_mp_damage
#--------------------------------------------------------------------------
def display_mp_damage(target, obj = nil)
return if target.dead?
return if target.mp_damage == 0
if target.absorbed
fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
elsif target.mp_damage > 0
fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
else
fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
text = sprintf(fmt, target.name, Vocab::mp, -target.mp_damage)
Sound.play_recovery
end
#---
value = popup_convert_number(target.mp_damage)
if target.mp_damage > 0
if target.absorbed
target.popup_rules = "DRAIN"
target.popup_value = YEZ::BATTLE::POPUP::SETTINGS
wait(20)
@active_battler.popup_rules = "MP_HEAL"
@active_battler.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end
target.popup_rules = "MP_DMG"
target.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
else
if target.absorbed
@active_battler.popup_rules = "MP_DMG"
@active_battler.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
@status_window.draw_item(@active_battler.index) if @active_battler.actor?
end
target.popup_rules = "MP_HEAL"
target.popup_value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, value)
end
#---
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text(text)
end
wait(30)
end

#--------------------------------------------------------------------------
# overwrite method: display_state_changes
#--------------------------------------------------------------------------
def display_state_changes(target, obj = nil)
return if target.missed or target.evaded
return unless target.states_active?
if @message_window.line_number < 4 and YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.add_instant_text("")
end
display_added_states(target, obj)
display_removed_states(target, obj)
display_remained_states(target, obj)
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES and
@message_window.last_instant_text.empty?
@message_window.back_one
else
wait(10)
end
end

#--------------------------------------------------------------------------
# overwrite method: display_added_states
#--------------------------------------------------------------------------
def display_added_states(target, obj = nil)
for state in target.added_states
next if state == nil
next if state.name == ""
text = ""
if state.popup_rules != nil
target.popup_rules = state.popup_rules
value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, state.name)
target.popup_value = value
end
if target.actor? and !state.message1.empty?
text = target.name + state.message1
elsif !state.message2.empty?
text = target.name + state.message2
end
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.replace_instant_text(text) unless text == ""
end
wait(20) unless state.popup_rules == nil and
!YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
end
end

#--------------------------------------------------------------------------
# overwrite method: display_removed_states
#--------------------------------------------------------------------------
def display_removed_states(target, obj = nil)
for state in target.removed_states
next if state == nil
next if state.name == ""
text = ""
if state.popup_rules != nil
target.popup_rules = state.popup_rules
value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, state.name)
target.popup_value = value
end
text = target.name + state.message4 unless state.message4.empty?
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.replace_instant_text(text) unless text == ""
end
wait(20) unless state.popup_rules == nil and
!YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
end
end

#--------------------------------------------------------------------------
# overwrite method: display_remained_states
#--------------------------------------------------------------------------
def display_remained_states(target, obj = nil)
for state in target.remained_states
next if state == nil
next if state.name == ""
text = ""
if state.popup_rules != nil
target.popup_rules = state.popup_rules
value = sprintf(YEZ::BATTLE::POPUP::SETTINGS, state.name)
target.popup_value = value
elsif state.message3.empty?
next
end
text = target.name + state.message3 unless state.message3.empty?
@status_window.draw_item(target.index) if target.actor?
if YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
@message_window.replace_instant_text(text) unless text == ""
end
wait(20) unless state.popup_rules == nil and
!YEZ::BATTLE::ZEALOUS::SHOWN_MESSAGES
end
end

end # Scene_Battle

#===============================================================================
# Window_Base
#===============================================================================

class Window_Base < Window

#--------------------------------------------------------------------------
# alias method: draw_item_name
#--------------------------------------------------------------------------
alias draw_item_name_winbase_bez draw_item_name unless $@
def draw_item_name(item, x, y, enabled = true)
if $scene.is_a?(Scene_Battle) and $scene.smaller_obj_window
return unless item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 120, WLH, item.name, 0)
else
draw_item_name_winbase_bez(item, x, y, enabled)
end
end

end # Window_Base

#===============================================================================
# Window_Item
#===============================================================================

class Window_Item < Window_Selectable

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data
return if item == nil
number = $game_party.item_number(item)
enabled = enable?(item)
if ($scene.is_a?(Scene_Battle) and $scene.smaller_obj_window)
rect.width -= 28
draw_item_name(item, rect.x, rect.y, enabled)
dx = rect.x + rect.width - 4
dw = ($scene.is_a?(Scene_Battle) and $scene.smaller_obj_window) ? 24 : 80
self.contents.draw_text(dx, rect.y, dw, WLH, sprintf(":%2d", number), 2)
else
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end

end # Window_Item

#===============================================================================
# Window_Skill
#===============================================================================

class Window_Skill < Window_Selectable

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
unless $imported
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data
return if skill == nil
enabled = @actor.skill_can_use?(skill)
if ($scene.is_a?(Scene_Battle) and $scene.smaller_obj_window)
rect.width -= 28
draw_item_name(skill, rect.x, rect.y, enabled)
dx = rect.x + rect.width - 4
dw = 24
self.contents.draw_text(dx, rect.y, dw, WLH, @actor.calc_mp_cost(skill), 2)
else
rect.width -= 4
draw_item_name(skill, rect.x, rect.y, enabled)
self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
end
end
end

end # Window_Skill

#===============================================================================
# Window_BattleMessageZealous
#===============================================================================

class Window_BattleMessageZealous < Window_BattleMessage

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.x = 0
self.y = 0
self.back_opacity = 0
self.opacity = 0
self.contents.font.size = YEZ::BATTLE::ZEALOUS::MSG_FONT_SIZE
@sprite = Sprite.new(self.viewport)
gw = YEZ::BATTLE::ZEALOUS::MSG_GRADIENTW
g1 = YEZ::BATTLE::ZEALOUS::MSG_GRADIENT1
g2 = YEZ::BATTLE::ZEALOUS::MSG_GRADIENT2
bitmap = Bitmap.new(gw, 96 + 16)
bitmap.gradient_fill_rect(0, 16, gw, 96, g1, g2)
@sprite.bitmap = bitmap
@sprite.x = self.x
@sprite.y = self.y
@sprite.src_rect.height = 16
@sprite.opacity = 0
end

#--------------------------------------------------------------------------
# dispose
#--------------------------------------------------------------------------
def dispose
super
@sprite.bitmap.dispose
@sprite.dispose
end

#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
if self.visible and (@lines.size > 0) or
(@text != nil or self.pause or @index > -1)
@sprite.opacity += YEZ::BATTLE::ZEALOUS::MSG_OPACITY
dh = @sprite.src_rect.height
if @text != nil
lines = 4
else
unless self.pause or @index > -1
lines = @lines.size
else
lines = 4
end
end
@sprite.src_rect.height = 16 + (lines * 24)
else
@sprite.opacity -= YEZ::BATTLE::ZEALOUS::MSG_OPACITY if !self.visible
end
end

end # Window_BattleMessageZealous

#==============================================================================
# Window_TargetHelp
#==============================================================================

class Window_TargetHelp < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(window)
super(0, 0, 544, WLH + 32)
@active_battler = $scene.active_battler
@window = window
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(index = 0)
self.contents.clear
self.contents.font.color = normal_color
sw = self.width - 32
if @window.is_a?(Window_TargetEnemy)
text = @window.enemy.name
else
text = $game_party.members.name
end
self.contents.draw_text(0, 0, sw, WLH, text, 1)
if $imported and YEZ::STAT::DISPLAY_ENEMY_DUR and
@window.is_a?(Window_TargetEnemy)
dx = sw/2 - (contents.text_size(text).width / 2 + 24)
draw_stun_indicator(dx, 0, @window.enemy)
end
end


end # Window_TargetHelp

#==============================================================================
# Window_TargetEnemy
#==============================================================================

class Window_TargetEnemy < Window_Command

#--------------------------------------------------------------------------
# overwrite initialize
#--------------------------------------------------------------------------
def initialize
commands =
@enemies =
for enemy in $game_troop.members
next unless enemy.exist?
@enemies.push(enemy)
end
@enemies.sort! { |a,b| a.screen_x <=> b.screen_x }
for enemy in @enemies
commands.push(enemy.name)
end
super(416, commands, 8, 4)
end

end # Window_TargetEnemy

#===============================================================================
# Window_PartyCommand
#===============================================================================

class Window_PartyCommand < Window_Command

#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize
@data =
for command in YEZ::BATTLE::PARTY_WINDOW::PARTY_COMMANDS
case command
when :actions
@data.push(command)
when :execute
@data.push(command)
when :tactics
next unless $imported
@data.push(command)
when :party
next unless $imported
next unless $game_switches
next unless $game_party.members.size > 1
@data.push(command)
when :options
@data.push(command)
when :escape
@data.push(command)
else; next
end
end
super(128, @data, 1, 4)
create_contents
for i in 0..@data.size
draw_item(i)
end
self.active = false
end

#--------------------------------------------------------------------------
# new method: command
#--------------------------------------------------------------------------
def command; return @data; end

#--------------------------------------------------------------------------
# new method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
item = @data
return if item == nil
case item
when :actions
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :execute
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :tactics
if $game_switches
text = YEZ::MACRO::VOCAB
else
text = YEZ::MACRO::VOCAB
enabled = false
end
when :party
text = YEZ::PARTY::TITLE
when :options
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :escape
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
enabled = $game_troop.can_escape
else; return
end
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, text, 1)
end

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
super if !Input.repeat?(Input::L) and !Input.repeat?(Input::R)
end

end # Window_PartyCommand

#===============================================================================
# Window_PerformCommand
#===============================================================================

class Window_PerformCommand < Window_Command

#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize
@data =
for command in YEZ::BATTLE::PARTY_WINDOW::PERFORM_COMMANDS
case command
when :perform
@data.push(command)
when :turns
@data.push(command)
when :status
@data.push(command)
when :options
@data.push(command)
else; next
end
end
super(128, @data, 1, 4)
create_contents
for i in 0..@data.size
draw_item(i)
end
self.active = false
end

#--------------------------------------------------------------------------
# new method: command
#--------------------------------------------------------------------------
def command; return @data; end

#--------------------------------------------------------------------------
# new method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
item = @data
return if item == nil
case item
when :perform
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :turns
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :options
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
when :status
text = YEZ::BATTLE::PARTY_WINDOW::VOCAB
else; return
end
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, text, 1)
end

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
super if !Input.repeat?(Input::L) and !Input.repeat?(Input::R)
end

end # Window_PartyCommand

#===============================================================================
# Window_ActorCommand
#===============================================================================

class Window_ActorCommand < Window_Command

#--------------------------------------------------------------------------
# new method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands, 1)
end

#--------------------------------------------------------------------------
# new method: update
#--------------------------------------------------------------------------
def update
super if !Input.repeat?(Input::L) and !Input.repeat?(Input::R)
end

end # Window_ActorCommand

#===============================================================================
# Window_Battle_Option
#===============================================================================

class Window_Battle_Option < Window_Selectable

#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 56, 544, 232)
@column_max = 1
self.index = 0
self.active = true
refresh
end

#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
@data =
for i in YEZ::BATTLE::OPTIONS::COMMANDS
@data.push(i)
end
@item_max = @data.size
self.contents.clear
create_contents
for i in 0..@item_max
self.contents.font.color.alpha = 255
draw_item(i)
end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
item = @data
sw = self.width - 32
dx = 4
dy = WLH * index
dw = sw - 8
case item
#---
when :volume_bgm # BGM Volume
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
number = 100 - $game_variables
text = sprintf(YEZ::BATTLE::OPTIONS::VOCAB, number)
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :volume_bgs # BGS Volume
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
number = 100 - $game_variables
text = sprintf(YEZ::BATTLE::OPTIONS::VOCAB, number)
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :volume_sfx # SFX Volume
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
number = 100 - $game_variables
text = sprintf(YEZ::BATTLE::OPTIONS::VOCAB, number)
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :animations # Disable Animation
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
enabled = !$game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :autocursor # Cursor Memory
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
enabled = !$game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :skill_help # Skill Help
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = !$game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

when :next_actor # Next Actor
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dx, dy, dw/2, WLH, text, 1)
enabled = !$game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw/2, dy, dw/4, WLH, text, 1)
enabled = $game_switches
self.contents.font.color.alpha = enabled ? 255 : 128
text = YEZ::BATTLE::OPTIONS::VOCAB
self.contents.draw_text(dw*3/4, dy, dw/4, WLH, text, 1)

#---
end
end

#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data; end

#--------------------------------------------------------------------------
# update_help
#--------------------------------------------------------------------------
def update_help
case item
when :volume_bgm; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :volume_bgs; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :volume_sfx; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :animations; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :autocursor; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :skill_help; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
when :next_actor; @help_window.set_text(YEZ::BATTLE::OPTIONS::VOCAB,1)
else; @help_window.set_text("")
end
end

end # Window_Battle_Option

#===============================================================================
# Window_Turn_Orders
#===============================================================================

class Window_Turn_Orders < Window_Selectable

#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 56, 208, 232)
@column_max = 1
self.index = 0
self.active = true
refresh
end

#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
@data =
for i in $scene.action_battlers
@data.push(i) if i != nil and i.exist?
end
@item_max = @data.size
self.contents.clear
create_contents
for i in 0..@item_max
self.contents.font.color.alpha = 255
draw_item(i)
end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
battler = @data
return if battler == nil
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
sw = self.width - 32
dx = 4
dy = WLH * index
dw = sw - 8
text = battler.name
self.contents.draw_text(dx, dy, dw, WLH, text, 1)
end

#--------------------------------------------------------------------------
# item
#--------------------------------------------------------------------------
def item; return @data; end

end # Window_Turn_Orders

#===============================================================================
# Window_Order_Image
#===============================================================================

class Window_Order_Image < Window_Base

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(battler)
super(208, 56, 336, 232)
@battler = battler
refresh(battler)
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(battler = nil)
self.contents.clear
@battler = battler
return if @battler == nil
draw_battler_enemy if @battler.is_a?(Game_Enemy)
draw_battler_actor if @battler.is_a?(Game_Actor)
draw_battler_name
draw_battler_action
draw_debug
end

#--------------------------------------------------------------------------
# draw_battler_enemy
#--------------------------------------------------------------------------
def draw_battler_enemy
enemybit = Cache.battler(@battler.battler_name, @battler.battler_hue)
bw = enemybit.width
bh = enemybit.height
if bh > (self.height - 32)
bh = (self.height - 32)
bw *= (self.height - 32)
bw /= enemybit.height
end
if bw > (self.width - 32)
bw = (self.width - 32)
bh *= (self.width - 32)
bh /= enemybit.width
end
rect = Rect.new(0, 0, bw, bh)
rect.x = (self.width - 32 - rect.width) / 2
rect.y = (self.height - 32 - rect.height) / 2
self.contents.stretch_blt(rect, enemybit, enemybit.rect)
end

#--------------------------------------------------------------------------
# draw_battler_actor
#--------------------------------------------------------------------------
def draw_battler_actor
sw = self.width - 32
sh = self.height - 32
draw_actor_face(@battler, sw/2 - 48, sh/2 - 48)
end

#--------------------------------------------------------------------------
# draw_battler_name
#--------------------------------------------------------------------------
def draw_battler_name
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, self.width-32, WLH, @battler.name)
end

#--------------------------------------------------------------------------
# draw_battler_action
#--------------------------------------------------------------------------
def draw_battler_action
self.contents.font.color = system_color
self.contents.draw_text(0, WLH, 24, WLH, ">", 1)
self.contents.font.color = normal_color
trigger = !@battler.actor? and !YEZ::BATTLE::TURN_ORDERS::DISPLAY_ENEMY_ACTION
trigger = false if ($TEST or $BTEST) and YEZ::BATTLE::TURN_ORDERS::DEBUG_ENEMY_ACTION
trigger = false if !@battler.actor? and @battler.revealed_actions
trigger = true if !@battler.actor? and @battler.concealed_actions
if trigger
icon = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
text = YEZ::BATTLE::TURN_ORDERS::VOCAB
draw_icon(icon, 24, WLH)
self.contents.draw_text(48, WLH, self.width-104, WLH, text, 0)
else
case @battler.action.kind
when 0 # Basic
case @battler.action.basic
when 0 # Attack
icon = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
if @battler.actor?
for weapon in @battler.weapons
next if weapon == nil
icon = weapon.icon_index
break
end
end
text = YEZ::BATTLE::TURN_ORDERS::VOCAB
when 1 # Guard
icon = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
text = YEZ::BATTLE::TURN_ORDERS::VOCAB
when 2 # Escape
icon = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
text = YEZ::BATTLE::TURN_ORDERS::VOCAB
else
icon = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
text = YEZ::BATTLE::TURN_ORDERS::VOCAB
end
when 1 # Skill
icon = @battler.action.skill.icon_index
text = @battler.action.skill.name
when 2 # Item
icon = @battler.action.item.icon_index
text = @battler.action.item.name
end
draw_icon(icon, 24, WLH)
self.contents.draw_text(48, WLH, self.width-104, WLH, text, 0)
end
end

#--------------------------------------------------------------------------
# draw_debug
#--------------------------------------------------------------------------
def draw_debug
if YEZ::BATTLE::TURN_ORDERS::DEBUG_SHOW_SPEED and ($TEST or $BTEST)
self.contents.font.color = system_color
speed = sprintf("Debug %s Speed", @battler.action.speed)
self.contents.draw_text(0, WLH*7, self.width-32, WLH, speed, 2)
end
end

end # Window_Order_Image

#===============================================================================
# Window_StatusQuery
#===============================================================================

class Window_StatusQuery < Window_Selectable

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super(20, 156, 240, 132)
self.opacity = 0
create_contents
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(index = 0)
self.contents.clear
@actor = $game_party.members
self.index = -1
return if @actor == nil
@data =
for state in @actor.states
next if state == nil
next if state.icon_index == 0
@data.push(state)
end
self.index = 0 if @data.size > 0
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end

#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
state = @data
rect.width -= 4
draw_icon(state.icon_index, rect.x, rect.y)
draw_state_turns(rect.x+4, rect.y, state, @actor) if $imported
self.contents.font.color = normal_color
self.contents.font.bold = false
self.contents.font.size = Font.default_size
name = state.name
if $imported and @actor.stack(state) > 1
name = sprintf("%s(%d)", state.name, @actor.stack(state))
end
self.contents.draw_text(rect.x + 28, rect.y, 172, WLH, name)
end

end # Window_StatusQuery

#===============================================================================
# Window_AllyQuery
#===============================================================================

class Window_AllyQuery < Window_Status

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super($game_party.members)
self.height = 288
create_contents
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh(index = 0)
self.contents.font.color = normal_color
self.contents.clear
sw = self.width - 32
sh = self.height - 32
dy = 0
@actor = $game_party.members
return if @actor == nil
draw_actor_face(@actor, 24, dy)
draw_actor_name(@actor, 136, dy); dy += WLH
draw_actor_class(@actor, 136, dy); dy += WLH
draw_actor_level(@actor, 136, dy); dy += WLH*2
draw_actor_stun(@actor, 120, dy - WLH) if $imported
draw_actor_hp(@actor, 24, dy, 200); dy += WLH
draw_actor_mp(@actor, 24, dy, 200); dy += WLH
dy = WLH / 2
draw_actor_elemental_affinity(dy); dy += WLH*3
draw_actor_status_resistance(dy); dy = WLH * 6 + WLH / 2
draw_parameters((self.width - 32)/2, dy)
end

#--------------------------------------------------------------------------
# draw_actor_elemental_affinity
#--------------------------------------------------------------------------
def draw_actor_elemental_affinity(dy)
self.contents.font.size = YEZ::BATTLE::STATUS::RANK_FONT_SIZE
dx = (self.width - 32) * 3/4 - 8
dx -= YEZ::BATTLE::STATUS::SHOWN_ELEMENTS.size * 12
for i in YEZ::BATTLE::STATUS::SHOWN_ELEMENTS
icon = YEZ::BATTLE::STATUS::ELEMENT_ICONS
draw_icon(icon, dx, dy)
next if i > $data_system.elements.size
rate = @actor.element_rate(i)
text = sprintf("%+d%%", rate - 100)
if rate > 200
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 150
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 100
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 50
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 0
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate == 0
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
else
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
text = sprintf("%d%%", rate * -1)
end
self.contents.font.color = text_color(colour)
self.contents.draw_text(dx+2, dy+WLH, 20, WLH, text, 1)
dx += 24
end
end

#--------------------------------------------------------------------------
# draw_actor_status_resistance
#--------------------------------------------------------------------------
def draw_actor_status_resistance(dy)
self.contents.font.size = YEZ::BATTLE::STATUS::RANK_FONT_SIZE
dx = (self.width - 32) * 3/4 - 8
dx -= YEZ::BATTLE::STATUS::SHOWN_STATES.size * 12
for i in YEZ::BATTLE::STATUS::SHOWN_STATES
state = $data_states
next if state == nil
draw_icon(state.icon_index, dx, dy)
rate = @actor.state_probability(i)
text = sprintf("%d%%", rate)
if rate > 100
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 80
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 60
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 40
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 20
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
elsif rate > 0
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
else
colour = YEZ::BATTLE::STATUS::RANK_COLOUR
end
self.contents.font.color = text_color(colour)
self.contents.draw_text(dx+2, dy+WLH, 20, WLH, text, 1)
dx += 24
end
end

#--------------------------------------------------------------------------
# draw_parameters
#--------------------------------------------------------------------------
def draw_parameters(fx, fy)
self.contents.font.size = Font.default_size
dx = fx; dy = fy
up_icon = YEZ::BATTLE::STATUS::AFFINITY_RANKS
dn_icon = YEZ::BATTLE::STATUS::AFFINITY_RANKS
for type in YEZ::BATTLE::STATUS::SHOWN_STATS
case type
when :atk
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.atk > @actor.base_atk
icon = dn_icon if @actor.atk < @actor.base_atk
value = convert_number(@actor.atk)
name = Vocab.atk
when :def
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.def > @actor.base_def
icon = dn_icon if @actor.def < @actor.base_def
value = convert_number(@actor.def)
name = Vocab.def
when :spi
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.spi > @actor.base_spi
icon = dn_icon if @actor.spi < @actor.base_spi
value = convert_number(@actor.spi)
name = Vocab.spi
when :agi
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.agi > @actor.base_agi
icon = dn_icon if @actor.agi < @actor.base_agi
value = convert_number(@actor.agi)
name = Vocab.agi
when :hit
icon = $imported ? YEZ::ICONS : 0
value = sprintf("%d%%",[.max, 99].min)
name = Vocab.hit
when :eva
icon = $imported ? YEZ::ICONS : 0
value = sprintf("%d%%",[.max, 99].min)
name = Vocab.eva
when :cri
icon = $imported ? YEZ::ICONS : 0
value = sprintf("%d%%",[.max, 99].min)
name = Vocab.cri
when :odds
icon = $imported ? YEZ::ICONS : 0
n = 0
for member in $game_party.existing_members; n += member.odds; end
value = sprintf("%d%%",[.max, 99].min)
name = Vocab.odds
when :res
next unless $imported
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.res > @actor.base_res
icon = dn_icon if @actor.res < @actor.base_res
value = convert_number(@actor.res)
name = Vocab.res
when :dex
next unless $imported
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.dex > @actor.base_dex
icon = dn_icon if @actor.dex < @actor.base_dex
value = convert_number(@actor.dex)
name = Vocab.dex
when :luk
next unless $imported
up_icon = YEZ::ICONS if $imported
dp_icon = YEZ::ICONS if $imported
icon = $imported ? YEZ::ICONS : 0
icon = up_icon if @actor.luk > @actor.base_luk
icon = dn_icon if @actor.luk < @actor.base_luk
value = convert_number(@actor.luk)
name = Vocab.luk
when :dur
next unless $imported
icon = $imported ? YEZ::ICONS : 0
value = convert_number(@actor.max_dur)
name = Vocab.dur
else
next
end
draw_icon(icon, dx, dy)
if $imported
self.contents.font.color = normal_color
self.contents.draw_text(dx+24, dy, 62, WLH, value, 2)
else
self.contents.font.color = system_color
self.contents.draw_text(dx+24, dy, 40, WLH, name, 0)
self.contents.font.color = normal_color
self.contents.draw_text(dx+64, dy, 52, WLH, value, 2)
end
dx = dx == fx ? dx + 120 : fx
dy = dx == fx ? dy + WLH : dy
break if dy + 24 > self.height - 32
end
end

#--------------------------------------------------------------------------
# convert_number
#--------------------------------------------------------------------------
def convert_number(value)
settings = YEZ::BATTLE::POPUP::SETTINGS
value = value.abs
if value.is_a?(Integer)
if value >= 100000000000000
value = sprintf(settings, value / 1000000000000)
elsif value >= 100000000000
value = sprintf(settings, value / 1000000000)
elsif value >= 100000000
value = sprintf(settings, value / 1000000)
elsif value >= 100000
value = sprintf(settings, value / 1000)
end
end
return value
end

end # Window_AllyStatus

#===============================================================================
# Window_BattleMini
#===============================================================================

class Window_BattleMini < Window_BattleStatus

#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
super
self.x = 416
self.y = 288
self.width = 128
self.height = 128
create_contents
refresh
end

#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = 1
draw_item($scene.active_battler.index, true)
end

end # Window_BattleMini

#===============================================================================
# Window_BattleStatus
#===============================================================================

class Window_BattleStatus < Window_Selectable

#--------------------------------------------------------------------------
# alias method: initialize
#--------------------------------------------------------------------------
alias displaypartydata_initialize initialize unless $@
def initialize
displaypartydata_initialize
@column_max = $game_party.members.size
@spacing = 0
end

#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index, mini = false)
@actor = $game_party.members
index = 0 if mini
rect = Rect.new(0, 0, 0, 0)
rect.width = 96
rect.height = 96
rect.x = index * 96
rect.y = 0
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
return if @actor == nil
draw_ally_face(@actor, index)
draw_ally_state(@actor, index)
draw_ally_name(@actor, index)
draw_ally_action(@actor, index)
draw_ally_dur(@actor, index)
draw_ally_mp(@actor, index)
draw_ally_hp(@actor, index)
end

#--------------------------------------------------------------------------
# overwrite method: update_cursor
#--------------------------------------------------------------------------
def update_cursor
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 96, 0, 96, 96)
end
end

#--------------------------------------------------------------------------
# new method: draw_ally_face
#--------------------------------------------------------------------------
def draw_ally_face(actor, index = 0)
opacity = YEZ::BATTLE::PARTY_WINDOW::FACE_OPACITY
face_name = actor.face_name
face_index = actor.face_index
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = face_index % 4 * 96 + 4 / 2
rect.y = face_index / 4 * 96 + 4 / 2
rect.width = 92
rect.height = 92
self.contents.blt(index * 96 + 2, 2, bitmap, rect, opacity)
bitmap.dispose
end

#--------------------------------------------------------------------------
# new method: draw_ally_state
#--------------------------------------------------------------------------
def draw_ally_state(actor, index = 0)
return unless YEZ::BATTLE::PARTY_WINDOW::MAX_STATES_SHOWN > 0
dx = index * 96
dy = WLH * 1
dw = YEZ::BATTLE::PARTY_WINDOW::MAX_STATES_SHOWN * 24
draw_actor_state(@actor, dx, dy, dw)
end

#--------------------------------------------------------------------------
# new method: draw_ally_name
#--------------------------------------------------------------------------
def draw_ally_name(actor, index = 0)
self.contents.font.color = hp_color(actor)
self.contents.font.size = YEZ::BATTLE::PARTY_WINDOW::NAME_SIZE
dx = 96 * index + 24
dy = 0
dw = 70
self.contents.draw_text(dx, dy, dw, WLH, actor.name)
end

#--------------------------------------------------------------------------
# Draw Ally Action
#--------------------------------------------------------------------------
def draw_ally_action(actor, index = 0)
library = YEZ::BATTLE::PARTY_WINDOW::BATTLE_ACTION_ICONS
icon = library
#---
case actor.action.kind
when 0 # Basic
case actor.action.basic
when 0 # Attack
icon = library
for weapon in actor.weapons
next if weapon == nil
icon = weapon.icon_index
break
end
when 1 # Guard
icon = library
else
actor.action.kind = 0
actor.action.basic = 3
end
when 1 # Skill
if actor.action.valid? and actor.total_skills.include?(actor.action.skill)
icon = actor.action.skill.icon_index
else
actor.action.kind = 0
actor.action.basic = 3
end
when 2 # Item
if actor.action.valid?
icon = actor.action.item.icon_index
else
actor.action.kind = 0
actor.action.basic = 3
end
end
#---
enabled = icon == library ? false : true
draw_icon(icon, 96 * index, 0, enabled)
end

#--------------------------------------------------------------------------
# Draw Ally DUR
#--------------------------------------------------------------------------
def draw_ally_dur(actor, index)
return unless $imported
return unless YEZ::STAT::SHOW_DUR_INDICATOR
dx = YEZ::STAT::DUR_INDICATOR_SIDE == 1 ? index * 96 : (index+1) * 96 - 24
dy = WLH * 2
draw_stun_indicator(dx, dy, actor)
end

#--------------------------------------------------------------------------
# Draw Ally MP
#--------------------------------------------------------------------------
def draw_ally_mp(actor, index = 0)
dx = index * 96 + 2
dy = WLH * 3
dw = 92
self.contents.font.size = YEZ::BATTLE::PARTY_WINDOW::STAT_SIZE
self.contents.font.color = system_color
if $imported and actor.use_rage?
draw_actor_rage_gauge(actor, dx, dy, dw/2)
draw_actor_mp_gauge(actor, dx + dw/2, dy, dw/2)
self.contents.draw_text(dx+2+dw/2, dy + 4, 28, WLH, Vocab::mp_a, 0)
self.contents.draw_text(dx + 2, dy + 4, 28, WLH, Vocab::rage_a, 0)
else
draw_actor_mp_gauge(actor, dx, dy, dw)
self.contents.draw_text(dx + 2, dy + 4, 28, WLH, Vocab::mp_a, 0)
end
#---
case YEZ::BATTLE::PARTY_WINDOW::SHOWN_MP_TYPE
when 1
text = actor.mp
when 2
text = sprintf("%d/%d", actor.mp, actor.maxmp)
when 3
percent = actor.maxmp == 0 ? 0 : actor.mp * 100.0 / actor.maxmp
text = sprintf("%d%%", percent)
end
#---
if $imported and actor.use_rage?
self.contents.font.color = normal_color
self.contents.draw_text(dx+20, dy + 4, 24, WLH, @actor.rage, 2)
self.contents.font.color = mp_color(actor)
self.contents.draw_text(dx+dw/2+20, dy + 4, 24, WLH, text, 2)
else
self.contents.font.color = mp_color(actor)
self.contents.draw_text(dx + 30, dy + 4, dw - 32, WLH, text, 2)
end
end

#--------------------------------------------------------------------------
# Draw Ally HP
#--------------------------------------------------------------------------
def draw_ally_hp(actor, index = 0)
dx = index * 96 + 2
dy = WLH * 3 - YEZ::BATTLE::PARTY_WINDOW::STAT_SIZE + 2
dw = 92
draw_actor_hp_gauge(actor, dx, dy, dw)
self.contents.font.size = YEZ::BATTLE::PARTY_WINDOW::STAT_SIZE
self.contents.font.color = system_color
self.contents.draw_text(dx + 2, dy + 4, 28, WLH, Vocab::hp_a, 0)
self.contents.font.color = hp_color(actor)
#---
case YEZ::BATTLE::PARTY_WINDOW::SHOWN_HP_TYPE
when 1
text = actor.hp
when 2
text = sprintf("%d/%d", actor.hp, actor.maxhp)
when 3
percent = actor.maxmp == 0 ? 0 : actor.hp * 100.0 / actor.maxhp
text = sprintf("%d%%", percent)
end
#---
self.contents.draw_text(dx + 30, dy + 4, dw - 32, WLH, text, 2)
end

end # end Window_BattleStatus

#===============================================================================
#
# END OF FILE
#
#===============================================================================