Skip to content

Instantly share code, notes, and snippets.

/Pokèmon Battle System Secret

Created Jun 5, 2016
Embed
What would you like to do?
#=============================================================================
# * Crystal Engine - Pokémon Battle System
#-----------------------------------------------------------------------------
# Current Version: 1.19
#=============================================================================
$imported = {} if $imported.nil?
$imported["CE-PBS"] = true
=begin
This is a Pokemon Battle System. For those who have not played Pokémon let me
explain. In Pokémon the combat is a 1 on 1 style where you and your opponet switch
out Pokémon. You can either fight Pokémon that are wild or owned by a trainer.
Since Pokémon Ruby and Sapphire double battles have been part of the series. In
a double battle the combat is 2 on 2 as opposed to 1 on 1 because of that you can
use any number of Pokemon you wish. However right now there are no rules in place
just yet for Triple and Rotation Battles
------------------------------------------------------------------------------
Notetags:
Actor Notes
<trainer> # Signifies that this is a trainer
<trainer data> # Opens up the information for a trainer
[new team] # Creates a new team of Pokemon for this trainer
[new pokemon] # Creates a new Pokemon in the current team
class: x # Sets the Pokemon to class x
level: x # Sets the Level to x
ivs: mhp, mmp, atk, def, mat, mdf, agi, luk # If you have my Base Stat Formula
# script it sets all the IVs for the Pokemon
nature: x # If you have my Base Stat Formula script it sets the nature to nature x
friendship: x # If you have my Friendship script it sets the friendship to x (base = 70)
equip slots: x, y # If you have YEA - Ace Equip Engine it sets the equip slots to the values
equips: x, y # Sets the equipment by the id in the data base
moves: x, y # If you have my Move Limit script it sets the usable moves
nickname: string # Sets the name of the Pokemon to something other than it's class
shiny # If you have my Class Sprites script it makes the pokemon shiny
shadow # Currently this has no effect but eventually will
gender: x # If you have Bubs Gender Functions it sets the gender to x
ability: x # If you have my Abilities script it sets the ability to x
form: x # If you have my Genders and Forms script it sets the form to x
evs: mhp, mmp, atk, def, mat, mdf, agi, luk # If you have my Base Stat Formula
# script it sets all the EVs for the Pokemon
</trainer_data> # Closes the information for the trainer
Class Notes
<evs: hp, mp, atk, def, mat, mdf, agi, luk> # Sets the EV yeild sub the stat names
# for the number of EVs that go to that stat
Skill Notes
<priority: x> # Sets the priority for the skill to x
# (Higher priority moves go before lower priority)
<pursuit> # Makes the skill's priority change when the target is switching out
Item Notes
<pursuit> # Makes the skill's priority change when the target is switching out
Weapon Notes
<ev double> # Doubles EVs if equiped
Armor Notes
<ev double> # Doubles EVs if equiped
Enemy Notes
<trainer> # Signifies that this is a trainer
<trainer data> # Opens up the information for a trainer
[new team] # Creates a new team of Pokemon for this trainer
[new pokemon] # Creates a new Pokemon in the current team
class: x # Sets the Pokemon to class x
level: x # Sets the Level to x
ivs: mhp, mmp, atk, def, mat, mdf, agi, luk # If you have my Base Stat Formula
# script it sets all the IVs for the Pokemon
nature: x # If you have my Base Stat Formula script it sets the nature to nature x
friendship: x # If you have my Friendship script it sets the friendship to x (base = 70)
equip slots: x, y # If you have my Enemy Equips script it sets the equip slots to the values
equips: x, y # if you have my Enemy Equips script this sets the equipment by the id in the data base
moves: x, y # If you have my Move Limit script it sets the usable moves
nickname: string # Sets the name of the Pokemon to something other than it's class
shiny # If you have my Class Sprites script it makes the pokemon shiny
shadow # Currently this has no effect but eventually will
gender: x # If you have Bubs Gender Functions it sets the gender to x
ability: x # If you have my Abilities script it sets the ability to x
form: x # If you have my Genders and Forms script it sets the form to x
evs: mhp, mmp, atk, def, mat, mdf, agi, luk # If you have my Base Stat Formula
# script it sets all the EVs for the Pokemon
</trainer_data> # Closes the information for the trainer
State Notes
<lock switch> # If this state is inflicted you can't switch out
Troop Notes (place in a comment on an event page)
<troop total: x> # Sets the Limit of Pokemon you can send out
<trainer team x: y> # Sets the team id for trainer x to y. The x is by the order
# you added them to the troop. The y is made by the [new team] notetag.
<after battle: face_name, face_index> # Makes the message that display's when you
string win. Insert multiples of this tag for more
</after battle> than one message.
------------------------------------------------------------------------------
After the custimization part of the script is a more advanced section for those
with scripting knowlage. To add custom effects for when you send out a Pokemon.
=end
module CRYSTAL
module PBS
#------------------------------------------------------------------------
# * Handles the sendout limit rules
#------------------------------------------------------------------------
NORMAL_LIMIT = 1 # The Usual Limit for a Battle
USE_COMBINED_TOTAL = true # When you have VE - Multiple Troops installed use
#the commbined troop total for the auto adjust
#------------------------------------------------------------------------
# * All information involving trainer Pokemon
#------------------------------------------------------------------------
TRAINER_POKEMON = 2 # The Enemy used for trainer Pokemon
ALLY_BASE = 3 # The actor used to create partner's Pokemon
#------------------------------------------------------------------------
# * All information for the windows
#------------------------------------------------------------------------
COMMAND_WINDOW_OPPACITY = 180 # The oppacity for the command windows
GALV_MENU_LAYOUT = true # Are you using Galv Menu Layout?
#------------------------------------------------------------------------
# * Handles the contents of the switch command window
#------------------------------------------------------------------------
CONFIRM_COMMANDS = [
# ["Name", :symbol],
["Switch", :switch],
["Summary", :status],
# ["Extra", :custom1],
# ["Extra2", :custom2],
["Cancel", :goback],
]
CUSTOM_COMMANDS = {
# :command => [EnableSwitch, ShowSwitch, Handler Method],
:custom1 => [ 0, 0, :command_custom1],
:custom2 => [ 0, 0, :command_custom2],
}
#-------------------------------------------------------------------------
# * This contains the the rules for priority
#-------------------------------------------------------------------------
ITEM_PRIORITY = 6 # The priority of Items
PURSUIT_PRIORITY = 7 # Pursuit only has increased priority if the foe is switching
# Your best option is to make sure that the priority is higher than switching
SWITCH_SKILL = 591 # The skill that performs the switch out
#-------------------------------------------------------------------------
# * This is the switch that controls whether battles are set to set or switch
# [ON] is set. [OFF] is switch.
#-------------------------------------------------------------------------
SET_SWITCH = 28
#-------------------------------------------------------------------------
# * This handles the placement of Trainer Pokemon
#-------------------------------------------------------------------------
FIRST_POKEMON_POS = [330, 200] # The position of the First Pokemon
# This is for the foe's party
ADDITIONAL_POKEMON_ADJUST = [48, 16] # the amount that foes are adjusted by
# when additional trainer pokemon are added
PLAYER_POS = [50, 384] # The position of your character
PARTNER_POS = [98, 384] # The position of your partner
#-------------------------------------------------------------------------
# * This is for the Enemies when they send out a Pokemon or recall one
#-------------------------------------------------------------------------
FOE_SENDOUT_ANIMATION = 113 # The Animation used when the foe sends out a Pokemon
FOE_APPEAR_FRAME = 25 # The frame in the animation at which the foe appears
FOE_RECALL_ANIMATION = 117 # The animation played when the foe recalls a Pokemon
POKEBALL_OFFSET = [0, -50] # The offset for the PokéBall animation
#-------------------------------------------------------------------------
# * These are the Animations for the player when they send out or recall
# a Pokemon :normal is the only one that matters unless you have Enemy Capture
#-------------------------------------------------------------------------
PLAYER_ANIMATIONS = {
:normal => 113,
:great => 114,
:ultra => 115,
:master => 116,
:safari => 158,
:heavy => 161,
:level => 164,
:love => 167,
:lure => 170,
:fast => 173,
:friend => 176,
:moon => 179,
:sport => 182,
:premier => 185,
:repeat => 188,
:timer => 191,
:nest => 194,
:net => 197,
:dive => 200,
:luxury => 203,
:heal => 206,
:quick => 209,
:dusk => 212,
:cherish => 215,
:dream => 218,
:park => 221,
}
PLAYER_RECALL_ANIMATIONS = {
:normal => 117,
:great => 118,
:ultra => 119,
:master => 120,
:safari => 157,
:heavy => 160,
:level => 163,
:love => 166,
:lure => 169,
:fast => 172,
:friend => 175,
:moon => 178,
:sport => 181,
:premier => 184,
:repeat => 187,
:timer => 190,
:nest => 193,
:net => 196,
:dive => 199,
:luxury => 202,
:heal => 205,
:quick => 208,
:dusk => 211,
:cherish => 214,
:dream => 217,
:park => 220,
}
PLAYER_APPEAR_FRAME = {
:normal => 25,
:great => 25,
:ultra => 25,
:master => 25,
:safari => 25,
:heavy => 25,
:level => 25,
:love => 25,
:lure => 25,
:fast => 25,
:friend => 25,
:moon => 25,
:sport => 25,
:premier => 25,
:repeat => 25,
:timer => 25,
:nest => 25,
:net => 25,
:dive => 25,
:luxury => 25,
:heal => 25,
:quick => 25,
:dusk => 25,
:cherish => 25,
:dream => 25,
:park => 25,
}
EXP_SHARE_SWITCH = 17 # The switch for turning on the X and Y EXP Share
#-------------------------------------------------------------------------
# * This covers anything with Windows
#-------------------------------------------------------------------------
TRANSLUCENT_WINDOWS = false # Use trasnlucent command windows
#-------------------------------------------------------------------------
# * Checks for foreign battle systems
#-------------------------------------------------------------------------
def self.imported_other_battle_system?
return true if $imported[:ve_active_time_battle]
if $imported["YEA-BattleEngine"]
return true if $game_system.battle_system == :ftb && $imported["YEA-BattleSystem-FTB"]
return true if $game_system.battle_system == :catb && $imported["YSA-CATB"]
return true if $game_system.battle_system == :pctb && $imported["YSA-PCTB"]
end
return false
end
#-------------------------------------------------------------------------
# * Checks for a visual actors script
#-------------------------------------------------------------------------
def self.check_for_visal_actors
print "Checking for Actor Battlers script\n"
if $imported[:ve_actor_battlers]
print "Recognized: Victor Engine - Actor Battlers\n"
elsif $imported["YEA-VisualBattlers"]
pring "Recognized: Yanfly Engine Ace - Visual Battlers\n"
elsif $imported["YES-BattleSymphony"]
print "Recognized: Yami Engine Symphony - Battle Symphony\n"
else
text = "Crystal Engine - Pokémon Battle System requires a visual"
text += "actor script of some kind. Please download one for this"
text += "script. If you already have one, add it to the visual"
text += "actors check method in the module."
raise SyntaxError.new(text)
end
end
#-------------------------------------------------------------------------
# * Check to see if the game should not wait for a turn to end for a switch
#-------------------------------------------------------------------------
def self.no_wait_for_switch?
return true if $imported[:ve_active_time_battle]
if $imported["YEA-BattleEngine"]
return true if $game_system.battle_system == :catb && $imported["YSA-CATB"]
return true if $game_system.battle_system == :pctb && $imported["YSA-PCTB"]
end
return false
end
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Effects Triggered when the Pokemon is sent out
#--------------------------------------------------------------------------
def sendout_effect(user)
user.turns_present = 0
if user.actor?
$game_troop.members.each do |enemy|
enemy.exp_receivers.push(user)
enemy.exp_receivers.uniq!
end
else
$game_party.members.each do |actor|
user.exp_receivers.push(actor)
user.exp_receivers.uniq!
end
end
if $imported["CE-ShadowPokemon"] && user.shadow?
if user.actor?
user.heart_gauge = [user.heart_gauge - 60, 0].max
elsif user.enemy?
fmt = "%s First Seen\n"
if $BTEST
text = sprintf(fmt, "Battle Test")
else
text = sprintf(fmt, $imported["TH_AreaMaps"] ? $game_map.area.display_name : $game_map.display_name)
end
$game_party.extra_data[:system][:shadow_pokemon][user.class.id] ||= {}
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:name] ||= user.name
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:level] ||= user.level
if $imported["CE-BSF"]
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:ivs] ||= user.iv
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:nature] ||= user.nature
end
if $imported["BubsGenderFunctions"]
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:gender] ||= $imported["CE-Genders&Forms"] ? user.gender : user.enemy.gender
end
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:snagged] ||= false
$game_party.extra_data[:system][:shadow_pokemon][user.class.id][:message] ||= text
end
end
if user.shadow?
sprite = spriteset.battler_sprites.find {|spr| spr.battler == user }
sprite.start_animation($data_animations[77])
if user.enemy?
text = "Oh! A Shadow Pokémon!"
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
end
elsif user.shiny
sprite = spriteset.battler_sprites.find {|spr| spr.battler == user }
sprite.start_animation($data_animations[39])
end
case user.class.internal_name
when :KYOGRE
if has_const?(user.equips, $data_armors, POKE_ARMORS, :BLUE_ORB)
sprite = spriteset.battler_sprites.find {|spr| spr.battler == user }
sprite.start_animation($data_animations[95])
update_basic while sprite.animation?
user.form = 1
text = sprintf("%s's Primal Reversion!", user.name)
@log_window.add_text(text)
text = "It reverted to its primal form!"
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
user.refresh
end
when :GROUDON
if has_const?(user.equips, $data_armors, POKE_ARMORS, :RED_ORB)
sprite = spriteset.battler_sprites.find {|spr| spr.battler == user }
sprite.start_animation($data_animations[95])
update_basic while sprite.animation?
user.form = 1
text = sprintf("%s has Reverted to Primal %s!", user.name, user.class.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_winow.wait_and_clear
user.refresh
end
end
ability_effect(user)
user.apply_entry_hazzards
end
#---------------------------------------------------------------------------
# * Ability Effect
#---------------------------------------------------------------------------
def ability_effect(user)
case user.ability
when get_const(POKE_ABILITIES, :ANTICIPATION)
text = ""
if user.actor?
$game_troop.members.each { |member|
member.moves.each { |move|
user.element_set($data_skills[move]).each do |element|
if user.element_rate(element) > 1
text = sprintf("%s shuttered!", user.name)
end
end
if $data_skills[move].note =~ /<ONE HIT KO>/i
text = sprintf("%s shuttered!", user.name)
end
}
}
unless text.empty?
@spriteset.display_ability(user)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
end
end
when get_const(POKE_ABILITIES, :DOWNLOAD)
defense = 0
mdefense = 0
@spriteset.display_ability(user)
if user.actor?
$game_troop.members.each { |member|
defense += member.def
mdefense += member.mdf
}
if defense >= mdefense
user.add_buff(4, 3)
else
user.add_buff(2, 3)
end
elsif user.enemy?
$game_party.battle_members.each { |member|
defense += member.def
mdefense += member.mdf
}
if defense >= mdefense
user.add_buff(4, 3)
else
user.add_buff(2, 3)
end
end
@log_window.display_changed_buffs(user)
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :DRIZZLE)
if !BattleWeather.ancient_weather? && !BattleWeather.weather != RainDance
@spriteset.display_ability(user, false)
turns = has_const?(user.equips, $data_armors, POKE_ARMORS, :DAMP_ROCK) ? 8 : 5
BattleWeather.change_weather(RainDance, turns, true, false)
@spriteset.hide_ability(user)
end
when get_const(POKE_ABILITIES, :PRIMORDIAL_SEA)
if !BattleWeather.weather != DeltaStream && !BattleWeather.weather != PrimordialSea
@spriteset.display_ability(user)
BattleWeather.change_weather(PrimordialSea, -1, true, false)
end
when get_const(POKE_ABILITIES, :DROUGHT)
if !BattleWeather.ancient_weather? && !BattleWeather.weather != SunnyDay
@spriteset.display_ability(user)
turns = has_const?(user.equips, $data_armors, POKE_ARMORS, :HEAT_ROCK) ? 8 : 5
BattleWeather.change_weather(SunnyDay, turns, true, false)
end
when get_const(POKE_ABILITIES, :DESOLATE_LAND)
if !BattleWeather.weather != DeltaStream && !BattleWeather.weather != DesolateLand
@spriteset.display_ability(user)
BattleWeather.change_weather(DesolateLand, -1, true, false)
end
when get_const(POKE_ABILITIES, :SAND_STREAM)
if !BattleWeather.ancient_weather? && !BattleWeather.weather != SandStorm
@spriteset.display_ability(user)
turns = has_const?(user.equips, $data_armors, POKE_ARMORS, :SMOOTH_ROCK) ? 8 : 5
BattleWeather.change_weather(SandStorm, turns, true, false)
end
when get_const(POKE_ABILITIES, :SNOW_WARNING)
if !BattleWeather.ancient_weather? && !BattleWeather.weather != Hail
@spriteset.display_ability(user)
turns = has_const?(user.equips, $data_armors, POKE_ARMORS, :ICY_ROCK) ? 8 : 5
BattleWeather.change_weather(Hail, turns, true, false)
end
when get_const(POKE_ABILITIES, :DELTA_STREAM)
if !BattleWeather.weather != DeltaStream
@spriteset.display_ability(user)
BattleWeather.change_weather(DeltaStream, -1, true, false)
end
when get_const(POKE_ABILITIES, :CLOUD_NINE), get_const(POKE_ABILITIES, :AIR_LOCK)
@spriteset.display_ability(user)
text = "The effects of weather disapeared"
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :FOREWARN)
power = 0
skills = []
if user.actor?
$game_troop.members.each { |member|
member.skills.each { |move|
amount = move.damage.formula.eval(member, user, $game_variable)
power = amount if amount > power
skills.push(move) if amount >= power
}
}
elsif user.enemy?
$game_party.battle_members.each { |member|
member.skills.each { |move|
amount = move.damage.formula.eval(member, user, $game_variable)
power = amount if amount > power
skills.push(move) if amount >= power
}
}
end
@spriteset.display_ability(user)
final_skill = skills.sample
text = sprintf("%s was alerted to the foe's %s", user.name, final_skill.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :FRISK)
if user.actor?
foe = $game_troop.alive_members.sample
elsif user.enemy?
foe = $game_party.alive_members.sample
end
equips = foe.equips.dup
equips.compact
item = equips.sample
return if item.nil?
@spriteset.display_ability(user)
text = sprintf("%s frisked its foe and found one %s!", user.name, item.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :IMPOSTER)
if user.actor?
foe = $game_troop.alive_members.sample
elsif user.enemy?
foe = $game_party.alive_members.sample
end
user.transform_target = foe
@spriteset.display_ability(user)
text = sprintf("%s transformed into %s!", user.name, foe.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :INTIMIDATE)
@spriteset.display_ability(user)
if user.actor?
$game_troop.alive_members.each do |enemy|
enemy.add_debuff(2, 3)
@log_window.display_changed_buffs(enemy)
@log_window.wait_and_clear
end
elsif user.enemy?
$game_party.alive_members.each do |actor|
actor.add_debuff(2, 3)
@log_window.display_changed_buffs(actor)
@log_window.wait_and_clear
end
end
when get_const(POKE_ABILITIES, :SLOW_START)
@spriteset.display_ability(user)
user.add_state(202)
text = sprintf("%s can't get it going!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :TRACE)
targets = user.opponents_unit.members
targets.inject([]) do |final_targets, target|
next if is_const?(target.ability, POKE_ABILITIES, :WONDER_GUARD)
next if is_const?(target.ability, POKE_ABILITIES, :ILLUSION)
next if is_const?(target.ability, POKE_ABILITIES, :ZEN_MODE)
next if is_const?(target.ability, POKE_ABILITIES, :IMPOSTER)
next if is_const?(target.ability, POKE_ABILITIES, :STANCE_CHANGE)
next if is_const?(target.ability, POKE_ABILITIES, :TRACE)
final_targets.push(target)
end
return if final_targets.empty?
@spriteset.display_ability(user)
target = final_targets.sample
user.temp_ability = target.ability
@spriteset.display_ability(user, false)
@spriteset.hide_ability(user)
ability_effect(target)
when get_const(POKE_ABILITIES, :PRESSURE)
@spriteset.display_ability(user)
text = sprintf("%s is exerting its Pressure!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :MOLD_BREAKER)
@spriteset.display_ability(user)
text = sprintf("%s breaks the mold!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :TURBOBLAZE)
@spriteset.display_ability(user)
text = sprintf("%s is radiating a bursting aura!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :TERAVOLT)
@spriteset.display_ability(user)
text = sprintf("%s is radiating a bursting aura!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :FAIRY_AURA)
@spriteset.display_ability(user)
text = sprintf("%s is radiating a fairy aura!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :DARK_AURA)
@spriteset.display_ability(user)
text = sprintf("%s is radiating a dark aura!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :AURA_BREAK)
@spriteset.display_ability(user)
text = sprintf("%s reversed all other Pokémon's auras!", user.name)
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
when get_const(POKE_ABILITIES, :UNNERVE)
@spriteset.display_ability(user)
if user.actor?
text = "The opposing team is too nervous to eat Berries!"
else
text = "Your team is too nervous to eat Berries!"
end
@log_window.add_text(text)
3.times do @log_window.wait end
@log_window.wait_and_clear
end
end
#--------------------------------------------------------------------------
# * Remove Ancient Weather from the Field
#--------------------------------------------------------------------------
def check_weather
if BattleWeather.desolate_land?
members = $game_party.alive_members + $game_troop.alive_members
if members.all? {|m| !is_const?(m.ability, POKE_ABILITIES, :DESOLATE_LAND) }
BattleWeather.resume_weather
end
elsif BattleWeather.primordial_sea?
members = $game_party.alive_members + $game_troop.alive_members
if members.any? {|m| !is_const?(m.ability, POKE_ABILITIES, :PRIMORDIAL_SEA) }
BattleWeather.resume_weather
end
elsif BattleWeather.delta_stream?
members = $game_party.alive_members + $game_troop.alive_members
if members.all? {|m| !is_const?(m.ability, POKE_ABILITIES, :DELTA_STREAM) }
BattleWeather.resume_weather
end
end
end
#--------------------------------------------------------------------------
# * Additional Effects for When You KO and Enemy
#--------------------------------------------------------------------------
def additional_add_effects(actor, enemy)
if $imported["YEA-JPManager"]
actor.earn_jp(enemy.jp)
text = sprintf("%s gained %s %s!", actor.name, actor.battle_jp_earned, Vocab.jp)
$game_message.add(text)
wait_for_message
actor.battle_jp_earned = 0
end
if $imported["CE-LB"]
actor.lp += enemy.lp
text = sprintf("%s gained %s %s!", actor.name, enemy.lp, CRYSTAL::LICENCE::LP_TERM)
$game_message.add(text)
wait_for_message
end
if $imported["YSE-GuardianEsperLearning"]
actor.add_gsp(enemy.gsp)
text = sprintf("%s gained %s GSP!", actor.name, enemy.gsp)
$game_message.add(text)
wait_for_message
end
end
end
#==============================================================================
# Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad,
# so edit at your own risk.
#==============================================================================
module CRYSTAL
module REGEXP
module BATTLER
TRAINER = /<(?:TRAINER|Trainer|trainer)>/i
TRAINER_DATA_ON = /<(?:TRAINER_DATA|trainer data)>/i
TRAINER_DATA_OFF = /<\/(?:TRAINER_DATA|trainer data)>/i
NEW_TEAM = /\[(?:NEW_TEAM|new team)\]/i
NEW_POKEMON = /\[(?:NEW_POKEMON|new pokemon)\]/i
SPEICIES = /CLASS:[ ](\d+)/i
POKEMON_LEVEL = /LEVEL:[ ](\d+)/i
POKEMON_IVS = /IVS: ((?:\d+,? *)+)/i
POKEMON_NATURE = /NATURE:[ ](\d+)/i
POKEMON_FRIENDSHIP = /FRIENDSHIP:[ ](\d+)/i
POKEMON_EQUIP_SLOTS = /EQUIP SLOTS: ((?:\d+,? *)+)/i
POKEMON_EQUIPS = /EQUIPS: ((?:\d+,? *)+)/i
POKEMON_MOVES = /MOVES: ((?:\d+,? *)+)/i
NICKNAME = /NICKNAME:[ ](.*)/i
POKEMON_SHINY = /SHINY/i
POKEMON_SHADOW = /SHADOW/i
POKEMON_GENDER = /GENDER:[ ](\d+)/i
POKEMON_ABILITY = /ABILITY:[ ](\d+)/i
POKEMON_FORM = /FORM:[ ](\d+)/i
POKEMON_EVS = /EVS: ((?:\d+,? *)+)/i
end
module SKILL
PRIORITY = /<PRIORITY:[ ]([\+\-]\d+)>/i
end
module STATE
NO_SWITCH = /<(?:LOCK_SWITCH|Lock Switch|lock switch)>/i
end
end
end
module CRYSTAL
module CHECK
#--------------------------------------------------------------------------
# * Checks if you have a certain script installed
#--------------------------------------------------------------------------
def self.require(self_name, script, site = "http://crystalnoel42.wordpress.com")
unless $imported["CE-BasicModule"]
msg = "The script '#{self_name}' requires the latest\n"
msg += "version of 'Crystal Engine - Basic Module' to work properly\n"
msg += "Go to http://crystalnoel42.wordpress.com/ to download this script."
raise SyntaxError.new(msg)
end
unless $imported[script]
msg = "The script '#{self_name}' requires the latest\n"
msg += "version of #{scripts_list(script)} to work properly\n"
msg += "Go to #{site} to download this script."
raise SyntaxError.new(msg)
end
end
require("Crystal Engine - Pokémon Battle System", "CE-BasicModule")
#--------------------------------------------------------------------------
# * Script Name Guide
#--------------------------------------------------------------------------
class <<self; alias scripts_list_pbs scripts_list; end
def self.scripts_list(name)
scripts_list_pbs(name)
case name
when :ve_basic_module
return "Victor Engine - Basic Module"
when :ve_actor_battlers
return "Victor Engine - Actor Battlers"
when "CE-Trainers"
return "Crystal Engine - Trainers"
when "CE-EnemyClasses"
return "Crystal Engine - Enemy Classes and Levels"
end
end
end
end
CRYSTAL::CHECK.require("Crystal Engine - Pokémon Battle System", :ve_basic_module, "http://victorscripts.wordpress.com")
CRYSTAL::PBS.check_for_visal_actors
CRYSTAL::CHECK.require("Crystal Engine - Pokémon Battle System", "CE-Trainers")
CRYSTAL::CHECK.require("Crystal Engine - Pokémon Battle System", "CE-EnemyClasses")
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# * Load Database
#--------------------------------------------------------------------------
class <<self; alias load_database_pbs load_database; end
def self.load_database
load_database_pbs
load_notetags_pbs
end
#--------------------------------------------------------------------------
# * Create Game Objects
#--------------------------------------------------------------------------
class <<self; alias create_game_objects_pbs create_game_objects; end
def self.create_game_objects
create_game_objects_pbs
end
#--------------------------------------------------------------------------
# new method: load_notetags_ehpb
#--------------------------------------------------------------------------
def self.load_notetags_pbs
groups = [$data_actors, $data_states, $data_enemies]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_pbs
end
end
end
end
#==============================================================================
# ■ RPG::Actor
#==============================================================================
class RPG::Actor < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :trainer
attr_accessor :trainer_data
def replace_shadows(team_id)
@note =~ /<REPLACE SHADOWS #{team_id}: (\d+)>/i ? $1.to_i : nil
end
def shuffle_team?
@note =~ /<SHUFFLE ORDER>/i
end
def have_shadows(team_id)
@note =~ /<HAVE SHADOWS #{team_id}: (\d+)>/i ? $1.to_i : nil
end
#--------------------------------------------------------------------------
# common cache: load_notetags_tpm
#--------------------------------------------------------------------------
def load_notetags_pbs
@trainer = false
@trainer_data = []
@trainer_data[0] = []
@trainer_data[0][0] = {}
@trainer_data_on = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when CRYSTAL::REGEXP::BATTLER::TRAINER
@trainer = true
when CRYSTAL::REGEXP::BATTLER::TRAINER_DATA_ON
@trainer_data_on = true
when CRYSTAL::REGEXP::BATTLER::TRAINER_DATA_OFF
@trainer_data_on = false
when CRYSTAL::REGEXP::BATTLER::NEW_TEAM
next unless @trainer_data_on
size = @trainer_data.size
@trainer_data[size] = []
@trainer_data[size][0] = {}
when CRYSTAL::REGEXP::BATTLER::NEW_POKEMON
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party] = {}
when CRYSTAL::REGEXP::BATTLER::SPEICIES
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:class] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_LEVEL
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:level] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_IVS
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
set = $1.scan(/\d+/i).collect {|i| i.to_i }
unless set.size == 8
raise SyntaxError.new("The number of IVs for a class must be 8 one for each stat.")
end
@trainer_data[size][party][:ivs] = set
when CRYSTAL::REGEXP::BATTLER::POKEMON_NATURE
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:nature] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_FRIENDSHIP
next unless $imported["CE-Friendship"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:friendship] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_EQUIP_SLOTS
next unless $imported["CE-EnemyEquips"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:equip_slots] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:equip_slots].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::POKEMON_EQUIPS
next unless $imported["CE-EnemyEquips"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:equips] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:equips].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::POKEMON_MOVES
next unless $imported["CE-MoveLimits"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:moves] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:moves].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::NICKNAME
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:nickname] = $1
when CRYSTAL::REGEXP::BATTLER::POKEMON_SHINY
next unless $imported["CE-ClassSprites"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:shiny] = true
when CRYSTAL::REGEXP::BATTLER::POKEMON_SHADOW
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:shadow] = true
when CRYSTAL::REGEXP::BATTLER::POKEMON_GENDER
next unless $imported["CE-Genders&Forms"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:gender] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_ABILITY
next unless $imported["CE-Abilities"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:ability] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_FORM
next unless $imported["CE-Genders&Forms"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:form] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_EVS
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
set = $1.scan(/\d+/i).collect {|i| i.to_i }
unless set.size == 8
raise SyntaxError.new("The number of EVs for a class must be 8 one for each stat.")
end
@trainer_data[size][party][:evs] = set
#---
end
} # self.note.split
#---
if @trainer
@trainer_data.each { |team|
team.each { |pokemon|
unless pokemon[:class]
raise SyntaxError.new("One of the Pokemon on the Actor #{@name} has no class")
end
unless pokemon[:level]
raise SyntaxError.new("One of the Pokemon on the Actor #{@name} has no level")
end
}
}
end
#---
end
end # RPG::Actor
#==============================================================================
# ** RPG::Class
#------------------------------------------------------------------------------
# The data class for class.
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# * New method: element_set
#--------------------------------------------------------------------------
def ev_distribution
set = []
regexp = /<EVS: ((?:\d+,? *)+)>/i
note.scan(regexp).each { set += $1.scan(/\d+/i).collect {|i| i.to_i } }
if set.empty?
set = [0] * 8
end
unless set.size == 8
raise SyntaxError.new("The number of EVs for a class must be 8 one for each stat.")
end
set.compact
end
end
#==============================================================================
# ■ RPG::Skill
#==============================================================================
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# Priority
#--------------------------------------------------------------------------
def priority
if @note =~ /<PRIORITY: (\d+)>/i
return $1.to_i
else
return 0
end
end
#--------------------------------------------------------------------------
# Pursuit Flag
#--------------------------------------------------------------------------
def pursuit?
return true if @note =~ /<PURSUIT>/i
end
#--------------------------------------------------------------------------
# Does this skill perform a switch out
#--------------------------------------------------------------------------
def switch?
@id == CRYSTAL::PBS::SWITCH_SKILL
end
end # RPG::Skill
#==============================================================================
# ■ RPG::Item
#==============================================================================
class RPG::Item < RPG::UsableItem
#--------------------------------------------------------------------------
# Priority
#--------------------------------------------------------------------------
def priority
CRYSTAL::PBS::ITEM_PRIORITY
end
#--------------------------------------------------------------------------
# Pursuit Flag
#--------------------------------------------------------------------------
def pursuit?
return true if @note =~ /<PURSUIT>/i
end
#--------------------------------------------------------------------------
# Does this skill perform a switch out
#--------------------------------------------------------------------------
def switch?
false
end
end
#==============================================================================
# ** RPG::EquipItem
#------------------------------------------------------------------------------
# A superclass of weapons and armor.
#==============================================================================
class RPG::EquipItem < RPG::BaseItem
#--------------------------------------------------------------------------
# Pursuit Flag
#--------------------------------------------------------------------------
def ev_double?
return true if @note =~ /<EV DOUBLE>/i
end
end
#==============================================================================
# ■ RPG::Enemy
#==============================================================================
class RPG::Enemy < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :trainer
attr_accessor :trainer_data
def replace_shadows(team_id)
@note =~ /<REPLACE SHADOWS #{team_id}: (\d+)>/i ? $1.to_i : nil
end
def shuffle_team?
@note =~ /<SHUFFLE ORDER>/i
end
def have_shadows(team_id)
@note =~ /<HAVE SHADOWS #{team_id}: (\d+)>/i ? $1.to_i : nil
end
#--------------------------------------------------------------------------
# common cache: load_notetags_tpm
#--------------------------------------------------------------------------
def load_notetags_pbs
@trainer = false
@trainer_data = []
@trainer_data[0] = []
@trainer_data[0][0] = {}
@trainer_data_on = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when CRYSTAL::REGEXP::BATTLER::TRAINER
@trainer = true
when CRYSTAL::REGEXP::BATTLER::TRAINER_DATA_ON
@trainer_data_on = true
when CRYSTAL::REGEXP::BATTLER::TRAINER_DATA_OFF
@trainer_data_on = false
when CRYSTAL::REGEXP::BATTLER::NEW_TEAM
next unless @trainer_data_on
size = @trainer_data.size
@trainer_data[size] = []
@trainer_data[size][0] = {}
when CRYSTAL::REGEXP::BATTLER::NEW_POKEMON
next unless @trainer_data_on
size = @trainer_data.size-1
@trainer_data[size].push({})
when CRYSTAL::REGEXP::BATTLER::SPEICIES
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:class] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_LEVEL
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:level] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_IVS
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
set = $1.scan(/\d+/i).collect {|i| i.to_i }
unless set.size == 8
raise SyntaxError.new("The number of IVs for a class must be 8 one for each stat.")
end
@trainer_data[size][party][:ivs] = set
when CRYSTAL::REGEXP::BATTLER::POKEMON_NATURE
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:nature] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_FRIENDSHIP
next unless $imported["CE-Friendship"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:friendship] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_EQUIP_SLOTS
next unless $imported["CE-EnemyEquips"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:equip_slots] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:equip_slots].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::POKEMON_EQUIPS
next unless $imported["CE-EnemyEquips"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:equips] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:equips].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::POKEMON_MOVES
next unless $imported["CE-MoveLimits"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:moves] = []
$1.scan(/\d+/).each { |num|
@trainer_data[size][party][:moves].push(num.to_i) if num.to_i >= 0 }
when CRYSTAL::REGEXP::BATTLER::NICKNAME
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:nickname] = $1
when CRYSTAL::REGEXP::BATTLER::POKEMON_SHINY
next unless $imported["CE-ClassSprites"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:shiny] = true
when CRYSTAL::REGEXP::BATTLER::POKEMON_SHADOW
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:shadow] = true
when CRYSTAL::REGEXP::BATTLER::POKEMON_GENDER
next unless $imported["CE-Genders&Forms"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:gender] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_ABILITY
next unless $imported["CE-Abilities"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:ability] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_FORM
next unless $imported["CE-Genders&Forms"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
@trainer_data[size][party][:form] = $1.to_i
when CRYSTAL::REGEXP::BATTLER::POKEMON_EVS
next unless $imported["CE-BSF"]
next unless @trainer_data_on
size = @trainer_data.size-1
party = @trainer_data[size].size-1
set = $1.scan(/\d+/i).collect {|i| i.to_i }
unless set.size == 8
raise SyntaxError.new("The number of EVs for a class must be 8 one for each stat.")
end
@trainer_data[size][party][:evs] = set
#---
end
} # self.note.split
#---
if @trainer
@trainer_data.each { |team|
team.each { |pokemon|
unless pokemon[:class]
raise SyntaxError.new("One of the Pokemon on the Enemy #{@name} has no class")
end
unless pokemon[:level]
raise SyntaxError.new("One of the Pokemon on the Enemy #{@name} has no level")
end
}
}
end
#---
end
end # RPG::Enemy
#==============================================================================
# ■ RPG::State
#==============================================================================
class RPG::State < RPG::BaseItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :no_switch_state
#--------------------------------------------------------------------------
# common cache: load_notetags_fse
#--------------------------------------------------------------------------
def load_notetags_pbs
@no_switch_state = false
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when CRYSTAL::REGEXP::STATE::NO_SWITCH
@no_switch_state = true
end
} # self.note.split
#---
end
end # RPG::State
#==============================================================================
# ** BattleManager
#------------------------------------------------------------------------------
# This module manages battle progress.
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# * Initialize Member Variables
#--------------------------------------------------------------------------
class <<self; alias ce_pbs_init_members init_members; end
def self.init_members
ce_pbs_init_members
@sendout_status = :init
end
#--------------------------------------------------------------------------
# * Battle Start
#--------------------------------------------------------------------------
def self.battle_start
$game_system.battle_count += 1
$game_party.on_battle_start
$game_troop.on_battle_start
trainer_intro
if $game_troop.trainer_battle?
trainer_sendout
trainer_sendout_animation
end
ally_sendout
@sendout_status = :none
$game_party.members.each { |member| SceneManager.scene.sendout_effect(member)}
$game_troop.members.each { |member| SceneManager.scene.sendout_effect(member)}
end
#--------------------------------------------------------------------------
# * End Turn
#--------------------------------------------------------------------------
class <<self; alias turn_end_ce_pbs turn_end; end
def self.turn_end
turn_end_ce_pbs
SceneManager.scene.check_for_switch
judge_for_victory
end
#--------------------------------------------------------------------------
# * Trainer Intro Section
#--------------------------------------------------------------------------
def self.trainer_intro
if @preemptive
text = sprintf(Vocab::Preemptive, $game_party.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
elsif @surprise
text = sprintf(Vocab::Surprise, $game_party.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
end
if $game_troop.trainer_battle?
set = []
$game_troop.trainers.each do |trainer|
set.push(trainer)
end
trainer_string = ""
for i in 0...set.size
if set.size == 1
trainer_string += "#{set[i].full_name}"
elsif i == set.size - 1
trainer_string += "and #{set[i].full_name}"
else
if set.size > 2
trainer_string += "#{set[i].full_name}, "
else
trainer_string += "#{set[i].full_name} "
end
end
end
text = sprintf("You are challenged by %s!", trainer_string)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
else
string = ""
$game_troop.enemy_names.each_with_index do |name, i|
if $game_troop.enemy_names.size == 1
string += "#{name}"
elsif i == $game_troop.enemy_names.size - 1
string += "and #{name}"
else
if $game_troop.enemy_names.size > 2
string += "#{name}, "
else
string += "#{name} "
end
end
end
text = sprintf($game_troop.emerge_message, string)
$game_troop.members.each {|member| member.cry.play }
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
end
wait_for_message
wait_for_intro
end
#--------------------------------------------------------------------------
# * Sendout Trainer Pokémon
#--------------------------------------------------------------------------
def self.trainer_sendout
number = $game_troop.get_battle_participants / $game_troop.trainers.size
@enemy_sendout = []
$game_troop.trainers.each do |trainer|
set = []
trainer.current_team[0...number].each_with_index do |pokemon, index|
x = CRYSTAL::PBS::FIRST_POKEMON_POS[0]
y = CRYSTAL::PBS::FIRST_POKEMON_POS[1]
ox = CRYSTAL::PBS::ADDITIONAL_POKEMON_ADJUST[0]
oy = CRYSTAL::PBS::ADDITIONAL_POKEMON_ADJUST[1]
pokemon.screen_x = x + (set.size * ox)
pokemon.screen_y = y + (set.size * oy)
pokemon.refresh
pokemon.index = index
set.push(pokemon)
@enemy_sendout.push(pokemon)
end
sendout = ""
for i in 0...set.size
if i == set.size - 1
if set.size > 1
sendout += "and #{set[i].name}"
else
sendout += "#{set[i].name}"
end
else
if set.size > 2
sendout += "#{set[i].name}, "
else
sendout += "#{set[i].name} "
end
end
end
text = sprintf("%s sent out %s!", trainer.full_name, sendout)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
end
end
#--------------------------------------------------------------------------
# * Opponent Sendout Animations
#--------------------------------------------------------------------------
def self.trainer_sendout_animation
anim_sprites = []
for i in 0...@enemy_sendout.size
pokemon = @enemy_sendout[i]
anim_sprites[i] = Sprite_Base.new
anim_sprites[i].x = pokemon.screen_x + CRYSTAL::PBS::POKEBALL_OFFSET[0]
anim_sprites[i].y = pokemon.screen_y + CRYSTAL::PBS::POKEBALL_OFFSET[1]
anim = $data_animations[CRYSTAL::PBS::FOE_SENDOUT_ANIMATION]
anim_sprites[i].start_animation(anim) if pokemon.trained
end
num = 0
while anim_sprites[0].animation?
num += 1
SceneManager.scene.update_basic
for i in 0...anim_sprites.size
sprite = anim_sprites[i]
sprite.update
if num == CRYSTAL::PBS::FOE_APPEAR_FRAME * sprite.set_animation_rate
battler = @enemy_sendout[i]
battler.cry.play
$game_troop.enemies.push(battler)
SceneManager.scene.refresh_spriteset
end
end
end
anim_sprites.each do |sprite|
sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Sendout Your Pokémon
#--------------------------------------------------------------------------
def self.ally_sendout
anim_sprites = []
battlers = []
participants = $game_party.partner_trainer ? $game_troop.get_battle_participants - 1 : $game_troop.get_battle_participants
for i in 0...participants
battler = $game_party.all_members[i]
next if battler.nil?
battlers.push(battler)
if $imported["YES-BattleSymphony"]
battler.screen_x = SYMPHONY::View::ACTORS_POSITION[i][0]
battler.screen_y = SYMPHONY::View::ACTORS_POSITION[i][1]
end
end
for i in participants...$game_party.pokemon_party.size
battler = $game_party.pokemon_party[i]
$game_party.reserve_members.push(battler) unless battler.nil?
end
set = battlers
sendout = ""
for i in 0...set.size
if i == set.size - 1
if set.size > 1
sendout += "and #{set[i].name}"
else
sendout += "#{set[i].name}"
end
else
if set.size > 2
sendout += "#{set[i].name}, "
else
sendout += "#{set[i].name} "
end
end
end
if $game_party.partner_trainer
battlers.push($game_party.partner_trainer.current_team[0])
battler = $game_party.partner_trainer.current_team[0]
i = participants
if $imported["YES-BattleSymphony"]
battler.screen_x = SYMPHONY::View::ACTORS_POSITION[i][0]
battler.screen_y = SYMPHONY::View::ACTORS_POSITION[i][1]
end
battler.sprite.visible = false
text = sprintf("%s sent out %s!", $game_party.partner_trainer.full_name, $game_party.partner_trainer.current_team[0])
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
end
text = sprintf("Go %s!", sendout)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
$game_party.battling_members = battlers.dup
anim_sprites = []
appear_frames = []
frames = 0
for i in 0...set.size
pokemon = set[i]
if $imported["CE-EnemyCapture"]
anim_id = CRYSTAL::PBS::PLAYER_ANIMATIONS[pokemon.actor.pokeball]
appear_frames[i] = CRYSTAL::PBS::PLAYER_APPEAR_FRAME[pokemon.actor.pokeball]
else
anim_id = CRYSTAL::PBS::PLAYER_ANIMATIONS[:normal]
appear_frames[i] = CRYSTAL::PBS::PLAYER_APPEAR_FRAME[:normal]
end
anim_sprites[i] = Sprite_Base.new
anim_sprites[i].x = pokemon.screen_x + CRYSTAL::PBS::POKEBALL_OFFSET[0]
anim_sprites[i].y = pokemon.screen_y + CRYSTAL::PBS::POKEBALL_OFFSET[1]
anim = $data_animations[anim_id]
if anim.frame_max > frames
frames = anim.frame_max
longest_anim = anim_sprites[i]
end
anim_sprites[i].start_animation(anim)
$game_party.battling_members = []
end
num = 0
while longest_anim.animation?
num += 1
SceneManager.scene.update_basic
for i in 0...anim_sprites.size
sprite = anim_sprites[i]
sprite.update
if num == appear_frames[i] * sprite.set_animation_rate
battler = set[i]
battler.cry.play
$game_party.battling_members.push(battler)
end
end
end
anim_sprites.each do |sprite|
sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Sendout Status
#--------------------------------------------------------------------------
def self.sendout_status
@sendout_status
end
#--------------------------------------------------------------------------
# * Set Sendout Status
#--------------------------------------------------------------------------
def self.sendout_status=(symbol)
@sendout_status = symbol
end
#--------------------------------------------------------------------------
# * Set Wait Method
#--------------------------------------------------------------------------
def self.method_wait_for_intro=(method)
@method_wait_for_intro = method
end
#--------------------------------------------------------------------------
# * Wait Until Message Display has Finished
#--------------------------------------------------------------------------
def self.wait_for_intro
@method_wait_for_intro.call if @method_wait_for_intro
end
#--------------------------------------------------------------------------
# * Action Battlers
#--------------------------------------------------------------------------
def self.action_battlers
return @action_battlers
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
def self.process_victory
play_battle_end_me
display_exp
gain_gold
gain_drop_items
gain_exp
replay_bgm_and_bgs
SceneManager.return
battle_end(0)
return true
end
#--------------------------------------------------------------------------
# * Display EXP Earned
# The contents have been cleared and it is now used for messages
#--------------------------------------------------------------------------
def self.display_exp
win_message
$game_troop.after_battle_messages.each do |message|
$game_message.face_name = message[0]
$game_message.face_index = message[1]
$game_message.add(message[2])
wait_for_message
end
end
#--------------------------------------------------------------------------
# * Win Message
#--------------------------------------------------------------------------
def self.win_message
if $game_troop.trainer_battle?
set = []
$game_troop.trainers.each do |trainer|
set.push(trainer)
end
trainer_string = ""
for i in 0...set.size
if i == set.size - 1
if set.size > 1
trainer_string += "and #{set[i].full_name}"
else
trainer_string += "#{set[i].full_name}"
end
else
if set.size > 2
trainer_string += "#{set[i].full_name}, "
else
trainer_string += "#{set[i].full_name} "
end
end
end
text = sprintf("%s defeated %s!", $game_party.name, trainer_string)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
else
text = sprintf("%s is victorious!", $game_party.name, trainer_string)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
end
end
#--------------------------------------------------------------------------
# * Gold Acquisition and Display
#--------------------------------------------------------------------------
def self.gain_gold
if $game_troop.gold_total > 0
text = sprintf(Vocab::ObtainGold, $game_troop.gold_total.group)
$game_party.gain_gold($game_troop.gold_total)
$game_message.add(text)
wait_for_message
end
end
#--------------------------------------------------------------------------
# * EXP Acquisition and Level Up Display
#--------------------------------------------------------------------------
def self.gain_exp
$game_party.pokemon_party.each do |actor|
if actor.heart_gauge == 0
$game_message.add("#{actor.name} can now be purified!")
wait_for_message
end
end
end
#--------------------------------------------------------------------------
# * Create Action Order
#--------------------------------------------------------------------------
class <<self; alias make_action_orders_ce_pbs make_action_orders; end
def self.make_action_orders
if CRYSTAL::PBS.imported_other_battle_system?
make_action_orders_ce_pbs
else
@action_battlers = []
action_battlers = []
@priority_brackets = {}
action_battlers += $game_party.alive_members unless @surprise
action_battlers += $game_troop.alive_members unless @preemptive
action_battlers.select! {|battler| battler.current_action.is_a?(Game_Action)}
if $imported["YSE-ChargeSkill"]
action_battlers.select! {|battler| battler.charging? ?
battler.current_charging.item.is_a?(RPG::UsableItem) :
battler.current_action.item.is_a?(RPG::UsableItem)}
action_battlers.sort_by! {|battler| battler.charging? ?
battler.current_charging.item.priority : battler.current_action.item.priority}.reverse!
else
action_battlers.select! {|battler| battler.current_action.item.is_a?(RPG::UsableItem)}
action_battlers.sort_by! {|battler|
battler.current_action.item.priority}.reverse!
end
action_battlers.each do |battler|
if battler.pursuing?
@priority_brackets[CRYSTAL::PBS::PURSUIT_PRIORITY] ||= []
@priority_brackets[CRYSTAL::PBS::PURSUIT_PRIORITY].push(battler)
else
@priority_brackets[battler.highest_priority_action.item.priority] ||= []
@priority_brackets[battler.highest_priority_action.item.priority].push(battler)
end
end
@priority_brackets.keys.sort.reverse.each do |key|
bracket = @priority_brackets[key]
next if bracket.nil?
bracket.each {|battler| battler.make_speed }
bracket.sort! {|a,b| b.speed - a.speed }
@action_battlers += bracket
end
end
end
#--------------------------------------------------------------------------
# * Determine Win/Loss Results
#--------------------------------------------------------------------------
class <<self; alias judge_for_victory judge_win_loss; end
def self.judge_win_loss
end
#--------------------------------------------------------------------------
# * New method: wating?
#--------------------------------------------------------------------------
def self.wating?
return true if scene_changing?
return true if $game_troop.interpreter.running?
return true if SceneManager.scene.full_wait?
return true if SceneManager.scene.semi_wait?
return true if wait_action?
return true if SceneManager.scene.switching?
return false
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Can you Switch at the End of the Turn
#--------------------------------------------------------------------------
def switch?
if $imported["PokéAce-OrganizedBattle"]
return false if $game_party.organized_party.size > 0
end
if CRYSTAL::PBS::SET_SWITCH
return false if $game_switches[CRYSTAL::PBS::SET_SWITCH]
end
return true
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Add a Partner Trainer
#--------------------------------------------------------------------------
def add_partner_trainer(id, team)
$game_party.partner_trainer = Game_Trainer.new(id, :actor)
$game_party.partner_trainer.team_id = team
end
#--------------------------------------------------------------------------
# * Add a Partner Trainer
#--------------------------------------------------------------------------
def remove_partner_trainer
$game_party.partner_trainer = nil
end
end
#==============================================================================
# ** Game_Action
#------------------------------------------------------------------------------
# This class handles battle actions. This class is used within the
# Game_Battler class.
#==============================================================================
class Game_Action
#--------------------------------------------------------------------------
# * Set Switch
#--------------------------------------------------------------------------
def set_switch(member)
@item.object = $data_skills[CRYSTAL::PBS::SWITCH_SKILL]
@target_battler = member
self
end
#--------------------------------------------------------------------------
# * Target Battler
#--------------------------------------------------------------------------
def target_battler
@target_battler
end
end
#==============================================================================
# ** Game_BattlerBase
#------------------------------------------------------------------------------
# This base class handles battlers. It mainly contains methods for calculating
# parameters. It is used as a super class of the Game_Battler class.
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# * Check When Skill/Item Can Be Used
#--------------------------------------------------------------------------
alias true_occasion_ok? occasion_ok?
def occasion_ok?(item)
codition = $game_party.in_battle && SceneManager.scene_is?(Scene_Skill)
return codition ? false : true_occasion_ok?(item)
end
#--------------------------------------------------------------------------
# * The Skill used to Switch Out
#--------------------------------------------------------------------------
def switch_skill
$data_skills[CRYSTAL::PBS::SWITCH_SKILL]
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :introduced # Has the Intro Played
attr_accessor :exp_given
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ce_pbs_init_battler initialize
def initialize
@introduced = false
@exp_given
ce_pbs_init_battler
end
#--------------------------------------------------------------------------
# * Knock Out
# Edited for Pokemon for Ace
#--------------------------------------------------------------------------
alias ce_pbs_game_battler_die die
def die
ce_pbs_game_battler_die
BattleManager.sendout_status = :checking
SceneManager.scene.check_weather if SceneManager.scene_is?(Scene_Battle)
SceneManager.scene.refresh_status
end
#--------------------------------------------------------------------------
# * EV Gain Rate
#--------------------------------------------------------------------------
def ev_rate
equips.each do |equip|
next if equip.nil?
return 2 if equip.ev_double?
end
return 1
end
#--------------------------------------------------------------------------
# * Can't Switch
#--------------------------------------------------------------------------
def no_switch?
return true if $game_party.reserve_members.empty?
states.each do |state|
return true if state.no_switch_state
end
return false
end
#--------------------------------------------------------------------------
# * Use Skill/Item
# Called for the acting side and applies the effect to other than the user.
#--------------------------------------------------------------------------
alias use_item_pbs use_item
def use_item(item)
use_item_pbs(item)
if item.switch?
if actor?
if $game_party.partner_trainer
if $game_party.partner_trainer.battling_members.include?(self)
SceneManager.scene.parnter_switch(self)
else
SceneManager.scene.execute_actual_switch(self, current_action.target_battler) if current_action.target_battler
end
else
SceneManager.scene.execute_actual_switch(self, current_action.target_battler) if current_action.target_battler
end
elsif enemy?
SceneManager.scene.enemy_switch(self, @trainer) if @trainer
end
end
end
#--------------------------------------------------------------------------
# * Is this a Trainer?
#--------------------------------------------------------------------------
def trainer?
if actor?
return actor.trainer
elsif enemy?
return enemy.trainer
end
return false
end
#--------------------------------------------------------------------------
# * Pursuit Effect?
#--------------------------------------------------------------------------
def pursuing?
return false if CRYSTAL::PBS.imported_other_battle_system?
@actions.each do |action|
next if action.nil?
next if action.item.nil?
if action.item.scope == 1
array = action.targets_for_opponents
next if array[0].current_action.nil?
item = array[0].current_action.item
if item.is_a?(RPG::Skill) && item.id == CRYSTAL::PBS::SWITCH_SKILL
return true if action.item.pursuit?
end
end
end
return false
end
#--------------------------------------------------------------------------
# * The action with the highest priority
#--------------------------------------------------------------------------
def highest_priority_action
highest_action = current_action
@actions.each do |action|
next if action.item.nil?
highest_action = action if action.item.priority > highest_action.item.priority
end
if $imported["YSE-ChargeSkill"] && charging?
highest_action = current_charging
end
return highest_action
end
#--------------------------------------------------------------------------
# * Processing at End of Battle
#--------------------------------------------------------------------------
alias end_battle_actions_ce_pbs on_battle_end
def on_battle_end
end_battle_actions_ce_pbs
@introduced = false
clear_sprite_effects
end
#--------------------------------------------------------------------------
# * Cry Sound File
#--------------------------------------------------------------------------
def cry
folder = "Audio/SE/"
c = sprintf("%3.3dCry%s", self.class.id, @form == 0 ? "" : "_#{@form}")
wav_mp3 = FileTest.exist?(folder + c + ".wav") || FileTest.exist?(folder + c + ".mp3")
midi_ogg = FileTest.exist?(c + ".midi") || FileTest.exist?(folder + c + ".ogg")
wma = FileTest.exist?(folder + c + ".wma")
if wav_mp3 || midi_ogg || wma
return RPG::SE.new(c)
else
c = sprintf("%3.3dCry", self.class.id,)
wav_mp3 = FileTest.exist?(folder + c + ".wav") || FileTest.exist?(folder + c + ".mp3")
midi_ogg = FileTest.exist?(folder + c + ".mid") || FileTest.exist?(folder + c + ".ogg")
wma = FileTest.exist?(folder + c + ".wma")
if wav_mp3 || midi_ogg || wma
return RPG::SE.new(c)
end
end
return RPG::SE.new
end
#--------------------------------------------------------------------------
# update_move_to
#--------------------------------------------------------------------------
def update_move_to
if actor?
if trainer?
location = ($game_system.party_direction ||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
base_x ||= YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][0]
base_y ||= YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][1]
mod_x ||= YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][2]
mod_y ||= YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][3]
@screen_x ||= player? ? CRYSTAL::PBS::PLAYER_POS[0] : CRYSTAL::PBS::PARTNER_POS[0]
@screen_y ||= player? ? CRYSTAL::PBS::PLAYER_POS[1] : CRYSTAL::PBS::PARTNER_POS[1]
@origin_x ||= @screen_x
@origin_y ||= @screen_y
create_move_to(@screen_x, @screen_y, 1)
else
location = ($game_system.party_direction ||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
base_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][0]
base_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][1]
mod_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][2]
mod_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][3]
@screen_x ||= eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_X)
@screen_y ||= eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_Y)
@origin_x ||= @screen_x
@origin_y ||= @screen_y
create_move_to(@screen_x, @screen_y, 1)
end
end
@destination_x ||= @screen_x
@destination_y ||= @screen_y
@move_x_rate = 0 if @screen_x == @destination_x || @move_x_rate.nil?
@move_y_rate = 0 if @screen_y == @destination_y || @move_y_rate.nil?
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
@screen_x += (@destination_x > @screen_x) ? value : -value
value = [(@screen_y - @destination_y).abs, @move_y_rate].min
@screen_y += (@destination_y > @screen_y) ? value : -value
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :trainer # The trainer for the character
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ce_pbs_init initialize
def initialize(actor_id)
ce_pbs_init(actor_id)
@trainer = $game_party.player_trainer
end
#--------------------------------------------------------------------------
# * Clear your Skills
#--------------------------------------------------------------------------
def clear_skills
@skills.clear
end
end
#==============================================================================
# ** Game_TrainerActor
#------------------------------------------------------------------------------
# This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_TrainerActor < Game_Actor
attr_accessor :partner_pokemon
attr_accessor :data
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_id, data, trainer)
@data = data
super(actor_id)
@trainer = trainer
make_shadow if $imported["CE-ShadowPokemon"] && data[:shadow]
if $imported["CE-ShadowPokemon"] && shadow?
if $game_party.extra_data[:system][:shadow_pokemon][self.class.id].nil?
info = {:name => name, :level => level, :ivs => iv, :nature => nature,
:gender => gender, :moves => @data[:moves], :shiny => shiny,
:ability_flag => ability_flag, :equip_slots => @data[:equip_slots],
:equips => @data[:equips], :form => @data[:form]}
$game_party.extra_data[:system][:shadow_pokemon][self.class.id] = info
else
info = $game_party.extra_data[:system][:shadow_pokemon][self.class.id]
@data[:nickname] = info[:name]
@data[:level] = info[:level]
if $imported["CE-BSF"]
@data[:ivs] = info[:ivs]
@data[:nature] = info[:nature]
end
if $imported["CE-ClassSprites"]
@data[:shiny] = info[:shiny]
end
if $imported["BubsGenderFunctions"] && $imported["CE-Genders&Forms"]
@data[:gender] = info[:gender]
@data[:form] = info[:form]
end
if $imported["CE-Abilities"]
@data[:ability_flag] = info[:ability_flag]
end
if $imported["CE-EnemyEquips"]
@data[:equip_slots] = info[:equip_slots]
@data[:equips] = info[:equips]
end
end
end
skills.each do |skill|
setup_tech(skill.id) if $imported[:ve_techs_points] && !@tech_skills[skill.id]
end
@equip_skills = @data[:moves] if $imported["YES-SkillEquip"]
@form = @data[:form] if @data[:form]
@name = self.class.name
refresh
@partner_pokemon = true
end
#--------------------------------------------------------------------------
# * Get Equipment Slot Array
#--------------------------------------------------------------------------
def equip_slots
@data[:equip_slots] ? @data[:equip_slots] : super
end
#--------------------------------------------------------------------------
# * Get Equipped Item Object Array
#--------------------------------------------------------------------------
def equips
if @data[:equips]
set = []
@data[:equips].each_with_index do |num, point|
unless num == 0
if equip_slots[point] == 0
set[point] = $data_weapons[num]
elsif equip_slots[point] == CRYSTAL::EQUIPS::ITEM_SLOT
next unless $imported["CE-ItemAccessories"]
set[point] = $data_armor_items[num]
else
equip = $data_armors[num]
if equip.etype_id == equip_slots[point]
set[point] = equip
end
end
else
set[point] = nil
end
end
else
set = super
end
return set
end
#--------------------------------------------------------------------------
# * Get Skill Object Array
#--------------------------------------------------------------------------
def skills
@data[:moves] ? (@data[:moves] | added_skills).sort.collect {|id| $data_skills[id] } : super
end
if $imported["YES-SkillEquip"]
#--------------------------------------------------------------------------
# * Get Skill ID Array
#--------------------------------------------------------------------------
alias all_skills_ce_pbs all_skills
def all_skills
(all_skills_ce_pbs | @data[:moves]).uniq.sort
end
end
#--------------------------------------------------------------------------
# * Get Class Object
#--------------------------------------------------------------------------
def class
@data[:class] ? $data_classes[@data[:class]] : super
end
#--------------------------------------------------------------------------
# * Get Level
#--------------------------------------------------------------------------
def level
@data[:level] ? @data[:level] : @level
end
#--------------------------------------------------------------------------
# * Get IV Array
#--------------------------------------------------------------------------
def iv
@data[:ivs] ? @data[:ivs] : @iv
end
#--------------------------------------------------------------------------
# * Get EV Array
#--------------------------------------------------------------------------
def ev
@data[:evs] ? @data[:evs] : @ev
end
#--------------------------------------------------------------------------
# * Get Nature
#--------------------------------------------------------------------------
def nature
@data[:nature] ? @data[:nature] : @nature
end
#--------------------------------------------------------------------------
# * Get Nature Bonus
#--------------------------------------------------------------------------
def nature_effect(param_id)
case param_id
when 0 || 1
return 0
else
return CRYSTAL::BSF::NATURE_FORMULAS[nature][param_id - 2]
end
end
#--------------------------------------------------------------------------
# * Get Nature Name
#--------------------------------------------------------------------------
def nature_name
return CRYSTAL::BSF::NATURE_NAME[nature]
end
#--------------------------------------------------------------------------
# * Get Parameter
#--------------------------------------------------------------------------
def param_base(param_id)
return super unless $imported["CE-BSF"]
return base_param(param_id) if iv.nil?
return base_param(param_id) if ev.nil?
return base_param(param_id) if nature.nil?
return base_param(param_id) if @base.nil?
case param_id
when 0 || 1
value = (((iv[param_id] + (2 * @base[param_id]) + (ev[param_id]/4) + 100) * level)/100) + 10
else
value = ((((iv[param_id] + (2 * @base[param_id]) + (ev[param_id]/4)) * level)/100) + 5) * nature_effect(param_id)
end
return value.to_i
end
#--------------------------------------------------------------------------
# * Get Gender
#--------------------------------------------------------------------------
def gender
if $imported["CE-Genders&Forms"]
return @data[:gender] ? @data[:gender] : @gender
else
return @data[:gender] ? @data[:gender] : actor.gender
end
end
#--------------------------------------------------------------------------
# overwrite method : genderless?
#--------------------------------------------------------------------------
def genderless?
return true if gender == 0
return false
end
#--------------------------------------------------------------------------
# overwrite method : male?
#--------------------------------------------------------------------------
def male?
return true if gender == 1
return false
end
#--------------------------------------------------------------------------
# overwrite method : female?
#--------------------------------------------------------------------------
def female?
return true if gender == 2
return false
end
#--------------------------------------------------------------------------
# * Shiny
#--------------------------------------------------------------------------
def shiny
@data[:shiny] ? @data[:shiny] : @shiny
end
#--------------------------------------------------------------------------
# * Get Display Name
#--------------------------------------------------------------------------
def name
name = @data[:nickname] ? @data[:nickname] : @name
if $imported["CE-Illusion"]
return name if @illusion_hit
return name if @illusion_target == self
return name if @illusion_target.nil?
return @illusion_target.name
else
return name
end
end
#--------------------------------------------------------------------------
# * Ability
#--------------------------------------------------------------------------
def ability
if @temp_ability
return @temp_ability
elsif @ability_override
return @ability_override
else
return @data[:ability] ? @data[:ability] : super
end
end
#--------------------------------------------------------------------------
# * Ability Flag
#--------------------------------------------------------------------------
def ability_flag
if ability == self.class.hidden_ability
return 2
elsif self.class.ability.include?(ability)
return self.class.ability.index(ability)
else
return @ability_flag
end
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemies. It used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :nickname # Nickname
attr_accessor :trainer # The trainer for the character
attr_accessor :exp_receivers # Actors who get the EXP
attr_accessor :index
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ce_pbs_init initialize
def initialize(index, enemy_id)
@trainer = nil
@exp_receivers = []
ce_pbs_init(index, enemy_id)
x = CRYSTAL::PBS::FIRST_POKEMON_POS[0]
y = CRYSTAL::PBS::FIRST_POKEMON_POS[1]
ox = CRYSTAL::PBS::ADDITIONAL_POKEMON_ADJUST[0]
oy = CRYSTAL::PBS::ADDITIONAL_POKEMON_ADJUST[1]
@screen_x = x + (index * ox)
@screen_y = y + (index * oy)
end
end
#==============================================================================
# ** Game_TrainerEnemy
#------------------------------------------------------------------------------
# This class handles enemies. It used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_TrainerEnemy < Game_Enemy
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(index, enemy_id, data, trainer)
@data = data
super(index, enemy_id)
@trainer = trainer
@trained = true
make_shadow if $imported["CE-ShadowPokemon"] && data[:shadow]
if $imported["CE-ShadowPokemon"] && shadow?
if $game_party.extra_data[:system][:shadow_pokemon][self.class.id].nil?
info = {:name => name, :level => level, :ivs => iv, :nature => nature,
:gender => gender, :moves => @data[:moves], :shiny => shiny,
:ability_flag => ability_flag, :equip_slots => @data[:equip_slots],
:equips => @data[:equips], :form => @data[:form]}
$game_party.extra_data[:system][:shadow_pokemon][self.class.id] = info
else
info = $game_party.extra_data[:system][:shadow_pokemon][self.class.id]
@data[:nickname] = info[:name]
@data[:level] = info[:level]
if $imported["CE-BSF"]
@data[:ivs] = info[:ivs]
@data[:nature] = info[:nature]
end
if $imported["CE-ClassSprites"]
@data[:shiny] = info[:shiny]
end
if $imported["BubsGenderFunctions"] && $imported["CE-Genders&Forms"]
@data[:gender] = info[:gender]
@data[:form] = info[:form]
end
if $imported["CE-Abilities"]
@data[:ability_flag] = info[:ability_flag]
end
if $imported["CE-EnemyEquips"]
@data[:equip_slots] = info[:equip_slots]
@data[:equips] = info[:equips]
end
end
end
@form = @data[:form] if @data[:form]
@equip_slots = @data[:equip_slots] ? @data[:equip_slots] : @equip_slots
@equip_numbers = @data[:equips] ? @data[:equips] : []
refresh
end
#--------------------------------------------------------------------------
# * Get Skill ID Array
#--------------------------------------------------------------------------
def moves
if $imported["CE-ShadowPokemon"] && shadow?
@shadow_moves
else
@data[:moves] ? @data[:moves] + added_skills : super
end
end
#--------------------------------------------------------------------------
# * Get Class Object
#--------------------------------------------------------------------------
def class
@data[:class] ? $data_classes[@data[:class]] : super
end
#--------------------------------------------------------------------------
# * Get Level
#--------------------------------------------------------------------------
def level
@data[:level] ? @data[:level] : @level
end
#--------------------------------------------------------------------------
# * Get IV Array
#--------------------------------------------------------------------------
def iv
@data[:ivs] ? @data[:ivs] : @iv
end
#--------------------------------------------------------------------------
# * Get EV Array
#--------------------------------------------------------------------------
def ev
@data[:evs] ? @data[:evs] : @ev
end
#--------------------------------------------------------------------------
# * Get Nature
#--------------------------------------------------------------------------
def nature
@data[:nature] ? @data[:nature] : @nature
end
#--------------------------------------------------------------------------
# * Get Nature Bonus
#--------------------------------------------------------------------------
def nature_effect(param_id)
case param_id
when 0 || 1
return 0
else
return CRYSTAL::BSF::NATURE_FORMULAS[nature][param_id - 2]
end
end
#--------------------------------------------------------------------------
# * Get Nature Name
#--------------------------------------------------------------------------
def nature_name
return CRYSTAL::BSF::NATURE_NAME[nature]
end
#--------------------------------------------------------------------------
# * Get Parameter
#--------------------------------------------------------------------------
def param_base(param_id)
return super unless $imported["CE-BSF"]
return base_param(param_id) if iv.nil?
return base_param(param_id) if ev.nil?
return base_param(param_id) if nature.nil?
return base_param(param_id) if @base.nil?
case param_id
when 0 || 1
value = (((iv[param_id] + (2 * @base[param_id]) + (ev[param_id]/4) + 100) * level)/100) + 10
else
value = ((((iv[param_id] + (2 * @base[param_id]) + (ev[param_id]/4)) * level)/100) + 5) * nature_effect(param_id)
end
return value.to_i
end
#--------------------------------------------------------------------------
# * Get Gender
#--------------------------------------------------------------------------
def gender
if $imported["CE-Genders&Forms"]
return @data[:gender] ? @data[:gender] : @gender
else
return @data[:gender] ? @data[:gender] : actor.gender
end
end
#--------------------------------------------------------------------------
# overwrite method : genderless?
#--------------------------------------------------------------------------
def genderless?
return true if gender == 0
return false
end
#--------------------------------------------------------------------------
# overwrite method : male?
#--------------------------------------------------------------------------
def male?
return true if gender == 1
return false
end
#--------------------------------------------------------------------------
# overwrite method : female?
#--------------------------------------------------------------------------
def female?
return true if gender == 2
return false
end
#--------------------------------------------------------------------------
# * Shiny
#--------------------------------------------------------------------------
def shiny
@data[:shiny] ? @data[:shiny] : @shiny
end
#--------------------------------------------------------------------------
# * Get Display Name
#--------------------------------------------------------------------------
def name
name = @data[:nickname] ? @data[:nickname] : super
if $imported["CE-Illusion"]
return name if @illusion_hit
return name if @illusion_target == self
return name if @illusion_target.nil?
return @illusion_target.name
else
return name
end
end
#--------------------------------------------------------------------------
# * Ability
#--------------------------------------------------------------------------
def ability
if @temp_ability
return @temp_ability
elsif @ability_override
return @ability_override
else
return @data[:ability] ? @data[:ability] : super
end
end
#--------------------------------------------------------------------------
# * Ability Flag
#--------------------------------------------------------------------------
def ability_flag
if ability == self.class.hidden_ability
return 2
elsif self.class.ability.include?(ability)
return self.class.ability.index(ability)
else
return @ability_flag
end
end
end
#==============================================================================
# ** Game_Trainer
#------------------------------------------------------------------------------
# A battler class reserved especially for trainers stores and creates all their
# team stats.
#==============================================================================
class Game_Trainer < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :id # The ID of the trainer
attr_accessor :name # Name
attr_accessor :teams # Array storing all teams
attr_accessor :team_id # The id of the team
attr_accessor :screen_x # battle screen X coordinate
attr_accessor :screen_y # battle screen Y coordinate
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(id, type = :enemy)
super()
@type = type
@id = id
@name = trainer.name
@teams = []
@team_id = 0
create_teams unless player?
@screen_x = 0
@screen_y = 0
end
#--------------------------------------------------------------------------
# * Name
#--------------------------------------------------------------------------
def name
case @type
when :actor
return game_actor.name
else
return @name
end
end
#--------------------------------------------------------------------------
# * Battler Name
#--------------------------------------------------------------------------
def battler_name
@battler_name = nil if @battler_name == ""
if @battler_name.nil?
if @type == :actor
@battler_name = trainer.note =~ /<BATTLER NAME: (.*)>/i ? $1.to_s : ""
else
@battler_name = trainer.battler_name
end
end
return @battler_name
end
#--------------------------------------------------------------------------
# * Battler Name
#--------------------------------------------------------------------------
def battler_hue
if @type == :actor
return trainer.note =~ /<BATTLER HUE: (\d+)>/i ? $1.to_i : 0
else
return trainer.battler_hue
end
end
#--------------------------------------------------------------------------
# * Get All Trainers in the Troop
#--------------------------------------------------------------------------
def create_teams
id = -1
trainer.trainer_data.each do |team|
id += 1
@teams.push([])
team = team.shuffle if trainer.shuffle_team?
team.each do |pokemon|
case @type
when :actor
@teams[id].push(Game_TrainerActor(CRYSTAL::PBS::ALLY_BASE, pokemon, self))
when :enemy
enemy = Game_TrainerEnemy.new(@teams[id].size,
CRYSTAL::PBS::TRAINER_POKEMON, pokemon, self)
@teams[id].push(enemy)
end
end
end
end
#--------------------------------------------------------------------------
# * Get the Current Team
#--------------------------------------------------------------------------
def current_team
@teams[@team_id]
end
#--------------------------------------------------------------------------
# * Set the Current Team
#--------------------------------------------------------------------------
def set_team
team = @teams[@team_id].dup
team = team.shuffle if trainer.shuffle_team?
team.each_with_index do |member, i|
next unless member.shadow? && $game_party.extra_data[:system][:shadow_pokemon][member.class.id][:snagged]
team_id = trainer.replace_shadows(@team_id)
if team_id && @teams[team_id] && @teams[team_id][i]
team[i] = @teams[team_id][i]
else
team.delete(member)
end
end
if trainer.have_shadows(@team_id)
shadows = $game_party.extra_data[:system][:shadow_pokemon].dup.select {|id, data| !data[:snagged] && !CRYSTAL::SHADOW::NO_REGAIN.include?(id) }
p shadows.keys
trainer.have_shadows(@team_id).times do
next if shadows.empty?
poke_id = shadow.keys.random!
pokemon = shadows[poke_id]
data = {:class => poke_id, :nickname => pokemon[:name],
:level => pokemon[:level], :ivs => pokemon[:ivs],
:nature => pokemon[:nature], :gender => pokemon[:gender],
:moves => pokemon[:moves], :equip_slots => pokemon[:equip_slots],
:equips => pokemon[:equips], :shiny => pokemon[:shiny],
:shadow => true}
enemy = Game_TrainerEnemy.new(team.size,
CRYSTAL::PBS::TRAINER_POKEMON, data, self)
team.push(enemy)
end
end
@teams[@team_id] = team.dup
end
#--------------------------------------------------------------------------
# * Currently Battling Members
#--------------------------------------------------------------------------
def battling_members
set = []
current_team.each do |member|
set.push(member) if $game_troop.members.include?(member)
end
return set
end
#--------------------------------------------------------------------------
# * Reserve Members
#--------------------------------------------------------------------------
def reserve_members
set = []
current_team.each do |member|
set.push(member) unless $game_troop.members.include?(member) || (member.dead? || member.incapacitated?)
end
return set
end
#--------------------------------------------------------------------------
# * Get Members
#--------------------------------------------------------------------------
def members
reserve_members + battling_members
end
#--------------------------------------------------------------------------
# * Get Array of Living Members
#--------------------------------------------------------------------------
def alive_members
members.select {|member| member.alive? && !member.incapacitated? }
end
#--------------------------------------------------------------------------
# * Get Array of Incapacitated Members
#--------------------------------------------------------------------------
def dead_members
members.select {|member| member.dead? || member.incapacitated? }
end
#--------------------------------------------------------------------------
# * Get Gold
#--------------------------------------------------------------------------
def gold
trainer.gold * current_team[current_team.size-1].level
end
#--------------------------------------------------------------------------
# * Create Array of Dropped Items
#--------------------------------------------------------------------------
def make_drop_items
trainer.drop_items.inject([]) do |r, di|
if di.kind > 0 && rand * di.denominator < drop_item_rate
r.push(item_object(di.kind, di.data_id))
else
r
end
end
end
#--------------------------------------------------------------------------
# * Get Multiplier for Dropped Item Acquisition Probability
#--------------------------------------------------------------------------
def drop_item_rate
$game_party.drop_item_double? ? 2 : 1
end
#--------------------------------------------------------------------------
# * Get Item Object
#--------------------------------------------------------------------------
def item_object(kind, data_id)
return $data_items [data_id] if kind == 1
return $data_weapons [data_id] if kind == 2
return $data_armors [data_id] if kind == 3
return nil
end
#--------------------------------------------------------------------------
# * class
#--------------------------------------------------------------------------
def class
$data_trainers[trainer.class_id]
end
#--------------------------------------------------------------------------
# * Determine if Actor or Not
#--------------------------------------------------------------------------
def actor?
@type == :actor
end
#--------------------------------------------------------------------------
# * Determine if Enemy
#--------------------------------------------------------------------------
def enemy?
@type == :enemy
end
#--------------------------------------------------------------------------
# * Trainer
#--------------------------------------------------------------------------
def trainer
case @type
when :actor
return $data_actors[@id]
when :enemy
return $data_enemies[@id]
end
end
#--------------------------------------------------------------------------
# * Get Actor Object
#--------------------------------------------------------------------------
def actor
trainer
end
#--------------------------------------------------------------------------
# * Get Enemy Object
#--------------------------------------------------------------------------
def enemy
trainer
end
#--------------------------------------------------------------------------
# * Trainer Class Name + Actual Name
#--------------------------------------------------------------------------
def full_name
sprintf("%s %s", self.class.name, @name)
end
#--------------------------------------------------------------------------
# * Is this a Trainer?
#--------------------------------------------------------------------------
def trainer?
true
end
#--------------------------------------------------------------------------
# * Is this a the Player
#--------------------------------------------------------------------------
def player?
@type == :actor && @id == CRYSTAL::TRAINER::TRAINER_ID
end
#--------------------------------------------------------------------------
# * Use Sprites?
#--------------------------------------------------------------------------
def use_sprite?
true
end
#--------------------------------------------------------------------------
# * Get Parameter
#--------------------------------------------------------------------------
def param(param_id)
0
end
#--------------------------------------------------------------------------
# * Victor Engine Compatiablity: Obtain All Notes
#--------------------------------------------------------------------------
def get_all_notes(*args)
notes = ""
notes += trainer.note if !args.include?(:self)
notes += self.class.note if !args.include?(:class)
notes
end
#--------------------------------------------------------------------------
# * Get Battle Screen Z-Coordinate
#--------------------------------------------------------------------------
def screen_z
return 100
end
#--------------------------------------------------------------------------
# * Determine Survival
#--------------------------------------------------------------------------
def alive?
true
end
#--------------------------------------------------------------------------
# * Get Hide State
#--------------------------------------------------------------------------
def hidden?
false
end
#--------------------------------------------------------------------------
# * New method: intro_pose?
#--------------------------------------------------------------------------
def intro_pose?
note =~ /<INTRO POSE>/i
end
#--------------------------------------------------------------------------
# * New method: note
#--------------------------------------------------------------------------
def note
trainer ? trainer.note : ""
end
#--------------------------------------------------------------------------
# * Game Actor Object
#--------------------------------------------------------------------------
def game_actor
$game_actors[id]
end
#--------------------------------------------------------------------------
# * New method: character_name
#--------------------------------------------------------------------------
def character_name
@character_name = actor? ? game_actor.character_name : @battler_name
@character_name
end
#--------------------------------------------------------------------------
# * New method: character_hue
#--------------------------------------------------------------------------
def character_hue
@character_hue = @battler_hue
@character_hue
end
#--------------------------------------------------------------------------
# * New method: character_index
#--------------------------------------------------------------------------
def character_index
if actor?
return game_actor.character_index
else
note =~ /<CHARACTER INDEX: (\d+)>/i ? $1.to_i - 1 : 0
end
end
#--------------------------------------------------------------------------
# * Index
#--------------------------------------------------------------------------
def index
if player?
$game_party.max_battle_members
elsif actor?
$game_party.max_battle_members + 1
end
end
#--------------------------------------------------------------------------
# new method: sprite
#--------------------------------------------------------------------------
def sprite
index = $game_party.battle_members.index(self)
return nil unless index
return nil unless SceneManager.scene_is?(Scene_Battle)
return SceneManager.scene.spriteset.actor_sprites[index]
end
#--------------------------------------------------------------------------
# new method: use_charset?
#--------------------------------------------------------------------------
def use_charset?
return true
end
end
#==============================================================================
# ** Game_Unit
#------------------------------------------------------------------------------
# This class handles units. It's used as a superclass of the Game_Party and
# and Game_Troop classes.
#==============================================================================
class Game_Unit
#--------------------------------------------------------------------------
# * Smooth Selection of Target
#--------------------------------------------------------------------------
alias smooth_target_ce_pbs smooth_target
def smooth_target(index, user = nil, item = nil)
if is_a?(Game_Party) && index >= @battling_members.size - (partner_trainer ? 1 : 0)
member = (@battling_members + @reserve_members)[index]
return (member && member.alive?) ? member : alive_members[0]
else
return smooth_target_ce_pbs(index, user, item)
end
end
#--------------------------------------------------------------------------
# * Smooth Selection of Target (K.O.)
#--------------------------------------------------------------------------
alias smooth_dead_target_ce_pbs smooth_dead_target
def smooth_dead_target(index, user = nil, item = nil)
if is_a?(Game_Party) && index >= @battling_members.size
member = (@battling_members + @reserve_members)[index]
return (member && member.alive?) ? member : dead_members[0]
else
return smooth_dead_target_ce_pbs(index, user, item)
end
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles parties. Information such as gold and items is included.
# Instances of this class are referenced by $game_party.
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battling_members # The members currently battling
attr_accessor :reserve_members # Members in reserve
attr_accessor :partner_trainer
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ce_pbs_init initialize
def initialize
ce_pbs_init
@battling_members = []
@reserve_members = []
@partner_trainer = nil
end
#--------------------------------------------------------------------------
# * Get Battle Members
#--------------------------------------------------------------------------
alias pokemon_party battle_members
def battle_members
return @battling_members if in_battle || SceneManager.scene_is?(Scene_Battle)
return pokemon_party
end
#--------------------------------------------------------------------------
# * Your Trainer
#--------------------------------------------------------------------------
def player_trainer
@player ||= Game_Trainer.new(CRYSTAL::TRAINER::TRAINER_ID, :actor)
@player.screen_x = CRYSTAL::PBS::PLAYER_POS[0]
@player.screen_y = CRYSTAL::PBS::PLAYER_POS[1]
return @player
end
#--------------------------------------------------------------------------
# * Your Partner
#--------------------------------------------------------------------------
def partner_trainer
return nil if @partner_trainer.nil?
@partner_trainer.screen_x = CRYSTAL::PBS::PARTNER_POS[0]
@partner_trainer.screen_y = CRYSTAL::PBS::PARTNER_POS[1]
return @partner_trainer
end
end
#==============================================================================
# ** Game_Troop
#------------------------------------------------------------------------------
# This class handles enemy groups and battle-related data. Also performs
# battle events. The instance of this class is referenced by $game_troop.
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :enemies # The members currently battling
attr_accessor :after_battle_messages
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias pokemon_setup setup
def setup(troop_id)
pokemon_setup(troop_id)
set = []
@enemies.each { |enemy|
if enemy.trainer?
set.push(enemy)
@enemies.delete(enemy)
end
}
@trainers = []
set.each do |trainer|
@trainers.push(Game_Trainer.new(trainer.enemy_id, :enemy))
end
@trainers.each do |trainer|
member = set[@trainers.index(trainer)]
trainer.screen_x = member.screen_x
trainer.screen_y = member.screen_y
end
for i in 0...trainers.size
trainers[i].team_id = get_trainer_teams[i]
trainers[i].set_team
end
load_after_battle_messages
end
#--------------------------------------------------------------------------
# * Get All Trainers in the Troop
#--------------------------------------------------------------------------
def trainers
@trainers
end
#--------------------------------------------------------------------------
# * Get the Battle Total
#--------------------------------------------------------------------------
def get_battle_participants
total = 0
regexp = /<TROOP TOTAL: (\d+)>/i
troop.pages.each do |page|
page.note.scan(regexp) { total += $1.to_i }
end
if total == 0
total = CRYSTAL::PBS::NORMAL_LIMIT
end
if CRYSTAL::PBS::USE_COMBINED_TOTAL && $imported[:ve_multiple_troop]
get_extra_troops.each {|troop| total += troop.get_battle_participants}
end
return total
end
#--------------------------------------------------------------------------
# * New method: get_extra_troops
#--------------------------------------------------------------------------
def get_trainer_teams
teams = [0] * trainers.size
regexp = /<TRAINER TEAM (\d+): (\d+)>/i
troop.pages.each do |page|
page.note.scan(regexp) {
teams[$1.to_i] = $2.to_i }
end
return teams
end
#--------------------------------------------------------------------------
# * Emerge Message
#--------------------------------------------------------------------------
def emerge_message
message = Vocab::Emerge
regexp = /<EMERGE MESSAGE: (.*)>/i
troop.pages.each do |page|
page.note.scan(regexp) {
message = $1.to_s }
end
return message
end
#--------------------------------------------------------------------------
# * Get the Messages Displayed After Battle
#--------------------------------------------------------------------------
def load_after_battle_messages
@after_battle_messages = []
message_on = false
troop.pages.each do |page|
page.note.split(/[\r\n]+/).each do |line|
case line
when /<AFTER BATTLE: (.*), (\d+)>/i
message_on = true
@after_battle_messages.push([$1, $2.to_i, ""])
when /<AFTER BATTLE>/i
message_on = true
@after_battle_messages.push(["", 0, ""])
when /<\/AFTER BATTLE>/i
message_on = false
else
next unless message_on
@after_battle_messages[@after_battle_messages.size-1][2] += line
end
end
end
end
#--------------------------------------------------------------------------
# * Get Array of Movable Members
#--------------------------------------------------------------------------
def movable_members
super + trainers
end
#--------------------------------------------------------------------------
# * Calculate Total Gold
#--------------------------------------------------------------------------
def gold_total
total = 0
dead_members.each {|enemy| total += enemy.gold }
trainers.each {|trainer| total += trainer.gold }
total * gold_rate
end
#--------------------------------------------------------------------------
# * Create Array of Dropped Items
#--------------------------------------------------------------------------
def make_drop_items
items = []
dead_members.each {|enemy| items += enemy.make_drop_items }
trainers.each {|trainer| items += trainer.make_drop_items }
items
end
#--------------------------------------------------------------------------
# * Is this a Trainer Battle?
#--------------------------------------------------------------------------
def trainer_battle?
!trainers.empty?
end
#--------------------------------------------------------------------------
# * Get Members
#--------------------------------------------------------------------------
def members
set = []
@enemies.compact.each do |enemy|
set.push(enemy) unless enemy.trainer?
end
return set
end
end
#==============================================================================
# ? ¥ Game_BattleCharacter
#==============================================================================
class Game_BattleCharacter < Game_Character
#--------------------------------------------------------------------------
# setup_coordinates
#--------------------------------------------------------------------------
def setup_coordinates
unless @actor.trainer?
location = ($game_system.party_direction ||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
base_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][0]
base_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][1]
mod_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][2]
mod_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][3]
@actor.screen_x = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_X)
@actor.screen_y = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_Y)
@actor.origin_x = @actor.screen_x
@actor.origin_y = @actor.screen_y
@actor.create_move_to(screen_x, screen_y, 1)
end
end
end
#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
# This sprite is used to display battlers. It observes an instance of the
# Game_Battler class and automatically changes sprite states.
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# * Update Position
#--------------------------------------------------------------------------
alias update_position_ce_pbs update_position
def update_position
return if @battler.screen_x.nil?
return if @battler.screen_y.nil?
update_position_ce_pbs
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Create Enemy Sprite
#--------------------------------------------------------------------------
alias create_actual_enemies create_enemies
def create_enemies
create_actual_enemies
$game_troop.trainers.reverse.collect do |trainer|
@enemy_sprites.push(Sprite_Battler.new(@viewport1, trainer))
end
end
#--------------------------------------------------------------------------
# * Create Actor Sprite
# By default, the actor image is not displayed, but for convenience
# a dummy sprite is created for treating enemies and allies the same.
#--------------------------------------------------------------------------
alias create_true_actors create_actors
def create_actors
create_true_actors
if $imported["YEA-VisualBattlers"]
@actor_sprites[$game_party.player_trainer.index] ||=Sprite_Battler.new(@viewport1)
create_actor_sprite($game_party.player_trainer)
unless $game_party.partner_trainer.nil?
@actor_sprites[$game_party.partner_trainer.index] ||=Sprite_Battler.new(@viewport1)
create_actor_sprite($game_party.partner_trainer)
end
else
@actor_sprites.push(Sprite_Battler.new(@viewport1, $game_party.player_trainer))
unless $game_party.partner_trainer.nil?
@actor_sprites.push(Sprite_Battler.new(@viewport1, $game_party.partner_trainer))
end
end
end
#--------------------------------------------------------------------------
# * New method: update_party
#--------------------------------------------------------------------------
def update_party
@actor_sprites.each_index do |i|
next if $game_party.battle_members.include?(@actor_sprites[i].battler)
@actor_sprites[i].dispose
@actor_sprites[i] = nil
end
$game_party.battle_members.collect do |actor|
next if @actors_party.include?(actor)
@actor_sprites.push(Sprite_Battler.new(@viewport1, actor))
end
@actor_sprites.compact!
@actors_party = $game_party.battle_members.dup
$game_party.battle_members.each do |actor|
old_position = [actor.screen_x, actor.screen_y]
actor.poses.default_direction if $imported[:ve_animated_battle]
if old_position != [actor.screen_x, actor.screen_y]
sprite(actor).start_effect(:appear)
end
end
end
if $imported["YES-BattleSymphony"]
#--------------------------------------------------------------------------
# overwrite method: update_actors
# Fixed Change Party.
#--------------------------------------------------------------------------
def update_actors
@actor_sprites.each_with_index do |sprite, i|
party_member = $game_party.battle_members[i]
party_member = sprite.battler if sprite.battler.is_a?(Game_Trainer)
if party_member != sprite.battler
sprite.battler = $game_party.battle_members[i]
#---
if party_member
party_member.reset_position
party_member.correct_origin_position
party_member.break_pose if party_member.dead?
end
sprite.init_visibility if sprite.battler && !sprite.battler.use_custom_charset?
end
sprite.update
end
end
end
end
if CRYSTAL::PBS::TRANSLUCENT_WINDOWS
#==============================================================================
# ** Window_PartyCommand
#------------------------------------------------------------------------------
# This window is used to select whether to fight or escape on the battle
# screen.
#==============================================================================
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias party_command_init initialize
def initialize
party_command_init
self.opacity = 0
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
alias party_command_dispose dispose
def dispose
party_command_dispose
dispose_back_bitmap
dispose_back_sprite
end
#--------------------------------------------------------------------------
# * Create Background Bitmap
#--------------------------------------------------------------------------
def create_back_bitmap
@back_bitmap = Bitmap.new(width, height)
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
self.z += 2
end
#--------------------------------------------------------------------------
# * Free Background Bitmap
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap.dispose
end
#--------------------------------------------------------------------------
# * Free Background Sprite
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# * Draw Background
#--------------------------------------------------------------------------
def draw_background
return if @back_bitmap == nil
@back_bitmap.clear
@back_sprite.x = x
@back_sprite.y = viewport.rect.y
@back_bitmap.fill_rect(0, 0, width, height, back_color)
end
#--------------------------------------------------------------------------
# * Back Color
#--------------------------------------------------------------------------
def back_color
Color.new(0, 0, 0, back_opacity)
end
#--------------------------------------------------------------------------
# * Back Opacity
#--------------------------------------------------------------------------
def back_opacity
CRYSTAL::PBS::COMMAND_WINDOW_OPPACITY
end
#--------------------------------------------------------------------------
# * Refresh Background
#--------------------------------------------------------------------------
def refresh_background
@back_bitmap.clear if @back_bitmap != nil
draw_background if self.openness == 255
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias party_command_update update
def update
party_command_update
refresh_background
end
end
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is for selecting an actor's action on the battle screen.
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias actor_command_init initialize
def initialize
actor_command_init
self.opacity = 0
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
alias actor_command_dispose dispose
def dispose
actor_command_dispose
dispose_back_bitmap
dispose_back_sprite
end
#--------------------------------------------------------------------------
# * Create Background Bitmap
#--------------------------------------------------------------------------
def create_back_bitmap
@back_bitmap = Bitmap.new(width, height)
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
self.z += 2
end
#--------------------------------------------------------------------------
# * Free Background Bitmap
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap.dispose
end
#--------------------------------------------------------------------------
# * Free Background Sprite
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# * Draw Background
#--------------------------------------------------------------------------
def draw_background
return if @back_bitmap == nil
@back_bitmap.clear
@back_sprite.x = x-width
@back_sprite.y = viewport.rect.y
@back_bitmap.fill_rect(0, 0, width, height, back_color)
end
#--------------------------------------------------------------------------
# * Back Color
#--------------------------------------------------------------------------
def back_color
Color.new(0, 0, 0, back_opacity)
end
#--------------------------------------------------------------------------
# * Back Opacity
#--------------------------------------------------------------------------
def back_opacity
CRYSTAL::PBS::COMMAND_WINDOW_OPPACITY
end
#--------------------------------------------------------------------------
# * Refresh Background
#--------------------------------------------------------------------------
def refresh_background
@back_bitmap.clear if @back_bitmap != nil
draw_background if self.openness == 255
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias actor_command_update update
def update
actor_command_update
refresh_background
end
end
#==============================================================================
# ¡ Window_ConfirmCommand
#==============================================================================
class Window_ConfirmCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias confirm_command_init initialize
def initialize
confirm_command_init
self.opacity = 0
create_back_bitmap
create_back_sprite
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
alias confirm_command_dispose dispose
def dispose
confirm_command_dispose
dispose_back_bitmap
dispose_back_sprite
end
#--------------------------------------------------------------------------
# * Create Background Bitmap
#--------------------------------------------------------------------------
def create_back_bitmap
@back_bitmap = Bitmap.new(width, height)
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
self.z += 2
end
#--------------------------------------------------------------------------
# * Free Background Bitmap
#--------------------------------------------------------------------------
def dispose_back_bitmap
@back_bitmap.dispose
end
#--------------------------------------------------------------------------
# * Free Background Sprite
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# * Draw Background
#--------------------------------------------------------------------------
def draw_background
return if @back_bitmap == nil
@back_bitmap.clear
@back_sprite.x = x
@back_sprite.y = viewport.rect.y
@back_bitmap.fill_rect(0, 0, width, height, back_color)
end
#--------------------------------------------------------------------------
# * Back Color
#--------------------------------------------------------------------------
def back_color
Color.new(0, 0, 0, back_opacity)
end
#--------------------------------------------------------------------------
# * Back Opacity
#--------------------------------------------------------------------------
def back_opacity
CRYSTAL::PBS::COMMAND_WINDOW_OPPACITY
end
#--------------------------------------------------------------------------
# * Refresh Background
#--------------------------------------------------------------------------
def refresh_background
@back_bitmap.clear if @back_bitmap != nil
draw_background if self.openness == 255
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias confirm_command_update update
def update
confirm_command_update
refresh_background
end
end # Window_ConfirmCommand
end
#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
# This window is for selecting an actor's action on the battle screen.
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Add Skill Command to List
#--------------------------------------------------------------------------
alias add_skill_commands_ce_pbs add_skill_commands
def add_skill_commands
add_skill_commands_ce_pbs
add_command("Switch", :switch, !@actor.no_switch? && @actor.usable?(@actor.switch_skill))
end
end
if $imported["YEA-BattleEngine"]
#==============================================================================
# ** Window_BattleEnemy
#------------------------------------------------------------------------------
# Window for selecting the enemy who is the action target on the battle
# screen.
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
alias item_max_ce_pbs item_max
def item_max
[item_max_ce_pbs, 1].max
end
end
end
#==============================================================================
# ** Window_SwitchStatus
#------------------------------------------------------------------------------
# This window is for switching out members
#==============================================================================
class Window_SwitchStatus < Window_MenuStatus
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
$game_party.reserve_members.size
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
if CRYSTAL::PBS::GALV_MENU_LAYOUT
def draw_item(index)
actor = $game_party.reserve_members[index]
return if actor.nil?
enabled = actor.alive?
rect = item_rect(index)
draw_item_background(index)
draw_actor_portrait(actor, rect.x + 1, rect.y + 1, enabled)
draw_actor_simple_status(actor, rect.x, rect.y)
end
else
def draw_item(index)
actor = $game_party.reserve_members[index]
return if actor.nil?
enabled = actor.alive?
rect = item_rect(index)
draw_item_background(index)
draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
end
end
#--------------------------------------------------------------------------
# * Processing When OK Button Is Pressed
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Sound.play_ok
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
$game_party.menu_actor = $game_party.reserve_members[index]
end
end # Window_ConfirmCommand
#==============================================================================
# ** Window_SwitchCommand
#------------------------------------------------------------------------------
# This window deals with the choices when switching
#==============================================================================
class Window_SwitchCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(status_window)
@status_window = status_window
super(@status_window.width, @status_window.y)
end
#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
alias visible_line_number_ce_pokemon_battle_system visible_line_number
def visible_line_number
if $imported["CE-PartyMenu"]
return CRYSTAL::PARTY::MAIN_MENU_ROWS
else
return visible_line_number_ce_pokemon_battle_system
end
end
#--------------------------------------------------------------------------
# * Change the Status Window
#--------------------------------------------------------------------------
def set_status_window(status_window)
@status_window = status_window
x = @status_window.width
y = @status_window.y
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
CRYSTAL::PBS::CONFIRM_COMMANDS.each do |command|
case command[1]
when :switch
if @status_window.index == -1
enabled = false
elsif $imported["CE-PartyMenu"]
members = $game_party.battling_members + $game_party.reserve_members
alive = members[@status_window.index].alive?
actor = members[@status_window.index]
enabled = alive && !$game_party.battling_members.include?(actor)
else
enabled = $game_party.reserve_members[@status_window.index].alive?
end
add_command(command[0], :switch, enabled)
when :skill
add_command(command[0], :skill)
when :equip
add_command(command[0], :equip)
when :status
add_command(command[0], :status)
when :goback
add_command(command[0], :goback)
else
add_custom_command(command)
end
end
end
#--------------------------------------------------------------------------
# * Create Custom Command
#--------------------------------------------------------------------------
def add_custom_command(command)
show = CRYSTAL::PBS::CUSTOM_COMMANDS[command[1]][1]
if show > 0
show_switch = $game_switches[show]
else
show_switch = true
end
enabled = CRYSTAL::PBS::CUSTOM_COMMANDS[command[1]][0]
if enabled > 0
enabled_switch = $game_switches[enabled]
else
enabled_switch = true
end
add_command(command[0], command[1], enabled_switch) if show_switch
end
end
#==============================================================================
# ** Window_SkillReplaceConfirm
#------------------------------------------------------------------------------
# This deals with the yes no commands for swithing.
#==============================================================================
class Window_SwitchConfirm < Window_Command
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_command("Yes", :yes)
add_command("No", :no)
end
end
#==============================================================================
# ** Window_BattleLog
#------------------------------------------------------------------------------
# This window is for displaying battle progress. No frame is displayed, but it
# is handled as a window for convenience.
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# * Wait and Clear
# Clear after inputing minimum necessary wait for the message to be read.
#--------------------------------------------------------------------------
def wait_and_clear
wait while @num_wait < 2 if line_number > 0
clear
end
#--------------------------------------------------------------------------
# * Wait
#--------------------------------------------------------------------------
def wait
@num_wait += 1
@method_wait.call(message_speed) if @method_wait
end
#--------------------------------------------------------------------------
# * Return to Designated Line
#--------------------------------------------------------------------------
def back_to(line_number)
@lines.pop while @lines.size > line_number
refresh
end
#--------------------------------------------------------------------------
# * Display Skill/Item Use
#--------------------------------------------------------------------------
alias display_use_item_ce_pbs display_use_item
def display_use_item(subject, item)
if item.is_a?(RPG::Skill)
display_use_item_ce_pbs(subject, item)
else
display_use_item_ce_pbs($game_party.player_trainer, item)
end
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :status_window # The Status Window needs to be modified
attr_accessor :log_window # The Battle Log
attr_accessor :switch_viewport
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
alias pbs_start start
def start
$game_party.battling_members.clear
$game_party.reserve_members.clear
pbs_start
BattleManager.method_wait_for_intro = method(:wait_for_intro)
@switching = false
end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
alias pbs_post_start post_start
def post_start
pbs_post_start
@switch_viewport = Viewport.new
@switch_viewport.visible = false
@switch_back = Sprite.new
@switch_back.bitmap = Cache.system("partybg")
@switch_back.viewport = @switch_viewport
if $imported["CE-PartyMenu"]
@switch_window = Window_MenuParty.new(-12, -12)
else
@switch_window = Window_SwitchStatus.new(0, 0)
end
@switch_window.opacity = 0
@switch_window.viewport = @switch_viewport
@switch_back.z += 300
@switch_window.set_handler(:ok, method(:open_switch_confirm))
@switch_window.set_handler(:cancel, method(:end_switch_without_moving_on))
@switch_window.unselect
@switch_window.active = false
@switch_window.z += 300
@switch_options = Window_SwitchCommand.new(@switch_window)
@switch_options.set_handler(:switch, method(:execute_switch))
@switch_options.set_handler(:skill, method(:command_personal))
@switch_options.set_handler(:equip, method(:command_personal))
@switch_options.set_handler(:status, method(:command_personal))
@switch_options.set_handler(:goback, method(:close_switch_confirm))
@switch_options.set_handler(:cancel, method(:close_switch_confirm))
set_custom_switch_window_commands
@switch_options.unselect
@switch_options.active = false
@switch_options.openness = 0
@switch_options.viewport = @switch_viewport
@switch_options.z += 301
if $imported["CE-PartyMenu"]
@switch_options.x = CRYSTAL::PARTY::COMMAND_WINDOW_POS[0]
@switch_options.y = CRYSTAL::PARTY::COMMAND_WINDOW_POS[1]
actor = $game_party.all_members[0]
@states_window = Window_StateStatus.new(256, 312, 256, 72, actor)
@states_window.viewport = @switch_viewport
end
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
alias ce_pbs_terminate terminate
def terminate
ce_pbs_terminate
end
#--------------------------------------------------------------------------
# * Switch Check
#--------------------------------------------------------------------------
def check_for_switch
if $game_party.reserve_members.compact.any? {|member| member.alive?}
$game_party.members.each do |member|
next unless member.dead? || member.incapacitated?
if member.partner_pokemon
partner_switch(member) if $game_party.partner_trainer.reserve_members.any? {|member| member.alive? }
else
process_switch(member)
end
end
end
$game_troop.trainers.each do |trainer|
trainer.battling_members.each do |member|
enemy_switch(member, trainer) if member.dead? || member.incapacitated?
end
end
end
#--------------------------------------------------------------------------
# * Create Actor Commands Window
#--------------------------------------------------------------------------
alias create_actor_command_window_ce_pbs create_actor_command_window
def create_actor_command_window
create_actor_command_window_ce_pbs
@actor_command_window.set_handler(:switch, method(:command_switch))
end
#--------------------------------------------------------------------------
# * [Switch] Command
#--------------------------------------------------------------------------
def command_switch
@no_move_on = false
process_switch(BattleManager.actor)
end
#--------------------------------------------------------------------------
# * Sets the Handler Methods of the Custom Switch Commands
#--------------------------------------------------------------------------
def set_custom_switch_window_commands
for command in CRYSTAL::PBS::CUSTOM_COMMANDS.keys
@switch_options.set_handler(command, CRYSTAL::PBS::CUSTOM_COMMANDS[command][2])
end
end
#--------------------------------------------------------------------------
# * Process a Switch Out
#--------------------------------------------------------------------------
def process_switch(member, switch_opt = false, choose = true)
@switch_member = member
@switch_opt = switch_opt
if choose
@switch_viewport.visible = true
@info_viewport.visible = false
@switch_window.refresh
@switch_window.select(0)
@switch_window.active = true
@states_window.open if @states_window
update_for_wait while @switch_viewport.visible
else
possibilities = $game_party.reserve_members.select {|m| m.alive? }
return if possibilities.empty?
new_member = possiblities.sample
execute_actual_switch(@switch_member, new_member)
end
end
#--------------------------------------------------------------------------
# * Process a Switch Out During a Sendout Opt
#--------------------------------------------------------------------------
def process_switch_choice
end
#--------------------------------------------------------------------------
# * Enemy Switch
#--------------------------------------------------------------------------
def enemy_switch(member, trainer, choose = true)
@switching = true
if choose
shadows = []
megas = []
bad_matchup = []
no_matchup = []
ok_matchup = []
good_matchup = []
superb_matchup = []
trainer.reserve_members.each do |pokemon|
next if pokemon.dead? || pokemon.incapacitated?
if pokemon.shadow?
shadows.push(pokemon)
next
elsif pokemon.skills.any? {|s| s.note =~ /<MEGA EVOLVE>/i }
megas.push(pokemon)
next
end
$game_party.battling_members.each do |battler|
next if battler.dead? || battler.incapacitated?
battler.skills.each do |skill|
rate = battler.item_element_rate(pokemon, skill)
bad_matchup.push(pokemon) if rate > 1
good_matchup.push(pokemon) if rate < 1
end
pokemon.skills.each do |skill|
rate = pokemon.item_element_rate(battler, skill)
ok_matchup.push(pokemon) if rate > 1
end
end
bad_matchup.uniq!
good_matchup.uniq!
ok_matchup.uniq!
good_matchup.delete(pokemon) if bad_matchup.include?(pokemon)
superb_matchup.push(pokemon) if ok_matchup.include?(pokemon) && good_matchup.include?(pokemon)
condition_a = !bad_matchup.include?(pokemon) && !ok_matchup.include?(pokemon)
condition_b = !good_matchup.include?(pokemon) && !superb_matchup.include?(pokemon)
no_matchup.push(pokemon) if condition_a && condition_b
end
bad_matchup.sort_by! {|battler| battler.level}.reverse!
no_matchup.sort_by! {|battler| battler.level}.reverse!
ok_matchup.sort_by! {|battler| battler.level}.reverse!
good_matchup.sort_by! {|battler| battler.level}.reverse!
superb_matchup.sort_by! {|battler| battler.level}.reverse!
final_set = superb_matchup + good_matchup + ok_matchup + no_matchup + bad_matchup + shadows + megas
final_set.compact!
final_set.uniq!
final_set.reverse!
old_member = member
old_member_index = old_member.index
new_member = final_set.pop
else
possibilities = trainer.reserve_members.select {|m| m.alive? }
return if possibilities.empty?
old_member = member
old_member_index = old_member.index
new_member = possiblities.sample
end
return if new_member.nil?
return if new_member == old_member
@spriteset.battler_sprites.each do |sprite|
next if old_member.dead? || old_member.incapacitated?
if old_member.sprite == sprite
text = sprintf("%s withdrew %s!", trainer.name, old_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
sprite.start_animation($data_animations[CRYSTAL::PBS::FOE_RECALL_ANIMATION])
while sprite.animation?
SceneManager.scene.update_basic
end
sprite.visible = false
end
end
if BattleManager.turn_end? && $game_troop.get_battle_participants == 1 && $game_system.switch?
party = $game_party.reserve_members.select {|member| member.alive? }
unless party.empty?
text = sprintf("%s is about to send out %s.", trainer.full_name, new_member.name)
$game_message.add(text)
wait_for_message
text = "Change Pokémon?"
$game_message.add(text)
$game_message.choices.push("Yes")
$game_message.choices.push("No")
$game_message.choice_cancel_type = 1
$game_message.choice_proc = Proc.new {|n| @choice = n }
wait_for_message
case @choice
when 0
process_switch($game_party.members[0], true)
end
end
end
new_member.screen_x = old_member.screen_x
new_member.screen_y = old_member.screen_y
anim_sprite = Sprite_Base.new
anim_sprite.x = old_member.screen_x + CRYSTAL::PBS::POKEBALL_OFFSET[0]
anim_sprite.y = old_member.screen_y + CRYSTAL::PBS::POKEBALL_OFFSET[1]
anim_sprite.start_animation($data_animations[CRYSTAL::PBS::FOE_SENDOUT_ANIMATION])
appear_frame = CRYSTAL::PBS::FOE_APPEAR_FRAME
num = 0
text = sprintf("%s sent out %s!", trainer.full_name, new_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
while anim_sprite.animation?
num += 1
SceneManager.scene.update_basic
anim_sprite.update
if num == appear_frame * anim_sprite.set_animation_rate
index = $game_troop.enemies.index(old_member)
$game_troop.enemies[old_member_index] = new_member
new_member.index = old_member_index
new_member.set_default_position if $imported["YES-BattleSymphony"]
new_member.refresh
new_member.cry.play
SceneManager.scene.refresh_spriteset
end
end
old_member.on_turn_end
old_member.on_battle_end
old_member.poses.active = false if $imported[:ve_animated_battle]
sendout_effect(new_member)
@switching = false
BattleManager.sendout_status = :none
anim_sprite.dispose
end
#--------------------------------------------------------------------------
# * Wait for the player to select yes or no
#--------------------------------------------------------------------------
def wait_for_switch_input
update_for_wait while @option_window.active
end
#--------------------------------------------------------------------------
# * Is the player selecting to switch
#--------------------------------------------------------------------------
def switching?
(@option_window ? @option_window.active : false | @switch_back.opacity == 255)|
@switching
end
#--------------------------------------------------------------------------
# * Complete the Switch Out
#--------------------------------------------------------------------------
def execute_actual_switch(user, switch_target)
@switching = true
end_switch
new_member = switch_target
new_member_index = $game_party.reserve_members.index(new_member)
old_member_index = user.index
old_member = $game_party.battling_members[old_member_index]
return if new_member == old_member
$game_party.reserve_members[new_member_index] = old_member
@spriteset.battler_sprites.each do |sprite|
next unless sprite
next unless sprite.battler
next if sprite.battler.dead? || sprite.battler.incapacitated?
if sprite.battler == old_member
text = sprintf("%s! Get back!", old_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
pokeball = $imported["CE-EnemyCapture"] ? old_member.actor.pokeball : :normal
sprite.start_animation($data_animations[CRYSTAL::PBS::PLAYER_RECALL_ANIMATIONS[pokeball]])
while sprite.animation?
SceneManager.scene.update_basic
end
end
end
$game_party.battling_members[old_member_index] = nil
anim_sprite = Sprite_Base.new
anim_sprite.x = old_member.screen_x + CRYSTAL::PBS::POKEBALL_OFFSET[0]
anim_sprite.y = old_member.screen_y + CRYSTAL::PBS::POKEBALL_OFFSET[1]
pokeball = $imported["CE-EnemyCapture"] ? new_member.actor.pokeball : :normal
anim_sprite.start_animation($data_animations[CRYSTAL::PBS::PLAYER_ANIMATIONS[pokeball]])
appear_frame = CRYSTAL::PBS::PLAYER_APPEAR_FRAME[pokeball]
num = 0
text = sprintf("Go %s!", new_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
while anim_sprite.animation?
num += 1
SceneManager.scene.update_basic
anim_sprite.update
if num == appear_frame * anim_sprite.set_animation_rate
$game_party.battling_members[old_member_index] = new_member
new_member.set_default_position if $imported["YES-BattleSymphony"]
new_member.refresh
new_member.cry.play
end
end
sendout_effect(new_member)
old_member.on_turn_end
old_member.on_battle_end
old_member.poses.active = false if $imported[:ve_animated_battle]
@switch_window.refresh
@switching = false
@actor_window.refresh
@status_window.refresh
if $game_troop.members.any? {|member| member.dead? }
if $game_troop.trainers.all? {|trainer| trainer.reserve_members.empty?}
BattleManager.sendout_status = :none
end
else
BattleManager.sendout_status = :none
end
anim_sprite.dispose
end
#--------------------------------------------------------------------------
# * Partner Switch
#--------------------------------------------------------------------------
def partner_switch(member, choose = true)
@switching = true
trainer = $game_party.partner_trainer
if choose
shadows = []
megas = []
bad_matchup = []
no_matchup = []
ok_matchup = []
good_matchup = []
superb_matchup = []
trainer.reserve_members.each do |pokemon|
next if pokemon.dead? || pokemon.incapacitated?
if pokemon.shadow?
shadows.push(pokemon)
next
elsif pokemon.skills.any? {|s| s.note =~ /<MEGA EVOLVE>/i }
megas.push(pokemon)
next
end
$game_party.battling_members.each do |battler|
next if battler.dead? || battler.incapacitated?
battler.skills.each do |skill|
rate = battler.item_element_rate(pokemon, skill)
bad_matchup.push(pokemon) if rate > 1
good_matchup.push(pokemon) if rate < 1
end
pokemon.skills.each do |skill|
rate = pokemon.item_element_rate(battler, skill)
ok_matchup.push(pokemon) if rate > 1
end
end
bad_matchup.uniq!
good_matchup.uniq!
ok_matchup.uniq!
good_matchup.delete(pokemon) if bad_matchup.include?(pokemon)
superb_matchup.push(pokemon) if ok_matchup.include?(pokemon) && good_matchup.include?(pokemon)
condition_a = !bad_matchup.include?(pokemon) && !ok_matchup.include?(pokemon)
condition_b = !good_matchup.include?(pokemon) && !superb_matchup.include?(pokemon)
no_matchup.push(pokemon) if condition_a && condition_b
end
bad_matchup.sort_by! {|battler| battler.level}.reverse!
no_matchup.sort_by! {|battler| battler.level}.reverse!
ok_matchup.sort_by! {|battler| battler.level}.reverse!
good_matchup.sort_by! {|battler| battler.level}.reverse!
superb_matchup.sort_by! {|battler| battler.level}.reverse!
final_set = superb_matchup + good_matchup + ok_matchup + no_matchup + bad_matchup + shadows + megas
final_set.compact!
final_set.uniq!
final_set.reverse!
old_member = member
old_member_index = old_member.index
new_member = final_set.pop
else
possibilities = trainer.reserve_members.select {|m| m.alive? }
return if possibilities.empty?
old_member = member
old_member_index = old_member.index
new_member = possiblities.sample
end
return if new_member.nil?
return if new_member == old_member
@spriteset.battler_sprites.each do |sprite|
next if sprite.battler.dead?
if sprite.battler == old_member
text = sprintf("%s! Get back!", old_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
sprite.start_animation($data_animations[CRYSTAL::PBS::PLAYER_RECALL_ANIMATIONS[old_member.actor.pokeball]])
while sprite.animation?
SceneManager.scene.update_basic
end
end
end
new_member.screen_x = old_member.screen_x
new_member.screen_y = old_member.screen_y
$game_party.battling_members[old_member.index] = new_member
anim_sprite = Sprite_Base.new
anim_sprite.x = old_member.screen_x + CRYSTAL::PBS::POKEBALL_OFFSET[0]
anim_sprite.y = old_member.screen_y + CRYSTAL::PBS::POKEBALL_OFFSET[1]
anim_sprite.start_animation($data_animations[CRYSTAL::PBS::FOE_SENDOUT_ANIMATION])
appear_frame = CRYSTAL::PBS::FOE_APPEAR_FRAME
num = 0
text = sprintf("%s sent out %s!", trainer.full_name, new_member.name)
SceneManager.scene.log_window.combatlog(text)
$game_message.add(text)
wait_for_message
while anim_sprite.animation?
num += 1
SceneManager.scene.update_basic
anim_sprite.update
if num == appear_frame * anim_sprite.set_animation_rate
$game_party.battling_members[old_member_index] = new_member
new_member.set_default_position if $imported["YES-BattleSymphony"]
$game_troop.captured[new_member.index] = false
new_member.refresh
new_member.cry.play
end
end
old_member.on_turn_end
old_member.on_battle_end
old_member.poses.active = false if $imported[:ve_animated_battle]
sendout_effect(new_member)
@switching = false
if $game_troop.members.any? {|member| member.dead? }
if $game_troop.trainers.all? {|trainer| trainer.reserve_members.empty?}
BattleManager.sendout_status = :none
end
else
BattleManager.sendout_status = :none
end
anim_sprite.dispose
end
#--------------------------------------------------------------------------
# * End the Switch Out
#--------------------------------------------------------------------------
def execute_switch
if $imported["CE-PartyMenu"]
members = $game_party.battling_members + $game_party.reserve_members
new_member = members[@switch_window.index]
else
new_member = $game_party.reserve_members[@switch_window.index]
end
old_member = @switch_member
end_switch
if @switch_member.dead? || @switch_opt
execute_actual_switch(old_member, new_member)
else
BattleManager.actor.input.set_switch(new_member)
next_command
end
end
#--------------------------------------------------------------------------
# * Event Processing
#--------------------------------------------------------------------------
def process_event(judge_win_loss = true)
while !scene_changing?
$game_troop.interpreter.update
$game_troop.setup_battle_event
wait_for_message
wait_for_effect if $game_troop.all_dead?
process_forced_action
BattleManager.judge_win_loss if judge_win_loss
break unless $game_troop.interpreter.running?
update_for_wait
end
end
#--------------------------------------------------------------------------
# * End the Switch Out
#--------------------------------------------------------------------------
def end_switch
@switch_options.close
@info_viewport.visible = true
@switch_viewport.visible = false
@switch_window.unselect
@switch_window.active = false
@states_window.close if @states_window
end
#--------------------------------------------------------------------------
# * End the Switch Out
#--------------------------------------------------------------------------
def end_switch_without_moving_on
if @switch_member && @switch_member.dead?
Sound.play_buzzer
@switch_window.activate
elsif @switch_opt
end_switch
else
end_switch
@no_move_on = true
@actor_command_window.activate
end
end
#--------------------------------------------------------------------------
# * [Skill], [Equipment] and [Status] Commands
#--------------------------------------------------------------------------
def command_personal
case @switch_options.current_symbol
when :skill
Graphics.freeze
@switch_viewport.visible = false
SceneManager.call(Scene_Skill)
SceneManager.scene.main
SceneManager.force_recall(self)
@switch_viewport.visible = true
perform_transition
when :equip
Graphics.freeze
@switch_viewport.visible = false
SceneManager.call(Scene_Equip)
SceneManager.scene.main
SceneManager.force_recall(self)
@switch_viewport.visible = true
perform_transition
when :status
Graphics.freeze
@switch_viewport.visible = false
SceneManager.call(Scene_Status)
SceneManager.scene.main
SceneManager.force_recall(self)
@switch_viewport.visible = true
perform_transition
end
@switch_options.activate
end
#--------------------------------------------------------------------------
# * Processing at End of Action
#--------------------------------------------------------------------------
alias process_action_end_ce_pbs process_action_end
def process_action_end
$game_troop.dead_members.each do |enemy|
next if enemy.exp_given
reserve = $game_party.reserve_members
if $imported["PokemonAce-DatabaseConstats"]
enemy.exp_receivers += reserve.select{|a| has_const?(a.equips, $data_armors, POKE_ARMORS, :EXP_SHARE)}
end
enemy.exp_receivers.each do |actor|
next unless actor
next unless actor.is_a?(Game_Actor)
next if actor.organized
exp_amount = enemy.exp(actor)
unless ($imported["CE-ShadowPokemon"] && actor.shadow?) || actor.max_level? || ((exp_amount * actor.final_exp_rate).to_i == 0)
text = sprintf("%s gained %s EXP!", actor.name, (exp_amount * actor.final_exp_rate).to_i)
$game_message.add(text)
wait_for_message
refresh_status
end
actor.gain_exp(exp_amount)
SceneManager.scene.refresh_status
if $imported["CE-BSF"]
for i in 0...enemy.class.ev_distribution.size
if actor.shadow?
total = actor.shadow_exp[:evs].inject(0) {|total, ev| total += ev}
if 510 < total + ((enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate)
actor.shadow_exp[:evs][i] += 510 - ((enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate)
else
actor.shadow_exp[:evs][i] += (enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate
end
actor.shadow_exp[:evs][i] = [actor.shadow_exp[:evs][i], 252].min
else
total = actor.ev.inject(0) {|total, ev| total += ev}
if 510 < total + ((enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate)
actor.ev[i] += 510 - ((enemy.class.ev_distribution[i] + extra_evs(i)) * actor.ev_rate)
else
actor.ev[i] += (enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate
end
actor.ev[i] = [actor.ev[i], 252].min
end
end
end
additional_add_effects(actor, enemy)
end
if $game_switches[CRYSTAL::PBS::EXP_SHARE_SWITCH]
extra = reserve.select{|a| !enemy.exp_receivers.include?(a)}
exp_amount = enemy.exp(actor) / 2
text = "The rest of your team gain EXP from the Exp. Share"
$game_message.add(text)
wait_for_message
extra.each do |actor|
actor.gain_exp(exp_amount)
if $imported["CE-BSF"]
for i in 0...self.class.ev_distribution.size
total = actor.ev.inject(0) {|total, ev| total += ev}
if 510 < total + ((enemy.class.ev_distribution[i] + actor.extra_evs(i)) * actor.ev_rate)
actor.ev[i] += 510 - ((enemy.class.ev_distribution[i] + actor.extra_evs(stat)) * actor.ev_rate)
else
actor.ev[i] += (enemy.class.ev_distribution[i] + extra_evs(i)) * ev_rate
end
actor.ev[i] = [actor.ev[i], 255].min
end
end
additional_add_effects(actor, enemy)
end
end
enemy.exp_receivers = []
enemy.exp_given = true
end
process_action_end_ce_pbs
if $game_troop.trainers.empty? && !$game_party.battling_members.any? {|a| a.alive? }
BattleManager.sendout_status = :none
BattleManager.judge_for_victory
elsif $game_troop.trainers.all? {|trainer| trainer.reserve_members.empty?}
BattleManager.sendout_status = :none
BattleManager.judge_for_victory
end
end
#--------------------------------------------------------------------------
# * Open the Switch Command Window
#--------------------------------------------------------------------------
def open_switch_confirm
@switch_options.refresh
@switch_options.open
@switch_options.select(0)
@switch_options.active = true
end
#--------------------------------------------------------------------------
# * Close the Switch Command Window
#--------------------------------------------------------------------------
def close_switch_confirm
@switch_options.close
@switch_window.active = true
end
#--------------------------------------------------------------------------
# * Wait Until Switch Selection has Finished
#--------------------------------------------------------------------------
def wait_for_switch
update_for_wait while @switch_window.open?
end
#--------------------------------------------------------------------------
# * Wait Until Intro has Finished
#--------------------------------------------------------------------------
def wait_for_intro
if $imported[:ve_animated_battle]
@spriteset.update
@spriteset.battler_sprites.each do |battler|
update_for_wait while battler.battler.poses.pose_name_list.include?(:intro)
end
end
end
#--------------------------------------------------------------------------
# * New method: setup_spriteset
#--------------------------------------------------------------------------
def setup_spriteset
all_battle_members.each {|member| member.poses.default_direction }
members = $game_party.movable_members + $game_troop.movable_members
members.each do |member|
next if $game_system.no_intro || !member.intro_pose? || member.introduced
member.introduced = true
member.poses.call_pose(:intro, :clear)
end
2.times { @spriteset.update }
end
if $imported[:ve_leap_attack]
#--------------------------------------------------------------------------
# * New method: update_pose_leap
#--------------------------------------------------------------------------
alias no_leap_target_pbs? no_leap_target?
def no_leap_target?
item = @subject.current_action.item
return false if (item.is_a?(RPG::Skill) && item.id == CRYSTAL::PBS::SWITCH_SKILL)
return no_leap_target_pbs?
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@states_window.actor = $game_party.members[@status_window.index]
@states_window.refresh
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
alias select_actor_selection_ce_pbs select_actor_selection
def select_actor_selection
if (@item && @item.for_friend? && @item.for_one? && !@item.for_user?) || @skill.for_dead_friend?
@switch_viewport.visible = true
@info_viewport.visible = false
@item_window.hide
@skill_window.hide
@status_aid_window.hide if @status_aid_window
@switch_window.refresh
@states_window.refresh
@switch_window.select(0)
@switch_window.active = true
@states_window.open if @states_window
@switch_window.set_handler(:ok, method(:on_any_actor_ok))
@switch_window.set_handler(:cancel, method(:on_any_actor_cancel))
else
select_actor_selection_ce_pbs
end
end
#--------------------------------------------------------------------------
# * Actor [OK]
#--------------------------------------------------------------------------
def on_any_actor_ok
BattleManager.actor.input.target_index = @switch_window.index
@switch_viewport.visible = false
@info_viewport.visible = true
@switch_window.set_handler(:ok, method(:open_switch_confirm))
@switch_window.set_handler(:cancel, method(:end_switch_without_moving_on))
next_command
end
#--------------------------------------------------------------------------
# * Actor [Cancel]
#--------------------------------------------------------------------------
def on_any_actor_cancel
@switch_viewport.visible = false
@info_viewport.visible = true
BattleManager.actor.input.clear
@status_aid_window.show
@status_aid_window.refresh
$game_temp.battle_aid = nil
case @actor_command_window.current_symbol
when :skill
@skill_window.show
@help_window.show
when :item
@item_window.show
@help_window.show
when :use_skill, :use_item
@help_window.hide
@status_window.show
@actor_command_window.activate
status_redraw_target(BattleManager.actor)
end
@switch_window.set_handler(:ok, method(:open_switch_confirm))
@switch_window.set_handler(:cancel, method(:end_switch_without_moving_on))
end
end
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.