mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-06-13 07:19:28 +00:00
Implemented usage of GameData::Item
This commit is contained in:
@@ -14,17 +14,17 @@ def pbGetExceptionMessage(e,_script="")
|
||||
end
|
||||
if emessage && !safeExists?("Game.rgssad") && !safeExists?("Game.rgss2a")
|
||||
emessage = emessage.gsub(/uninitialized constant PBItems\:\:(\S+)/) {
|
||||
"The item '#{$1}' is not valid. Please add the item\r\nto the list of items in the editor. See the wiki for more information." }
|
||||
"The item '#{$1}' is not valid. Please add the item\r\nto the PBS/items.txt file. See the wiki for more information." }
|
||||
emessage = emessage.gsub(/undefined method `(\S+?)' for PBItems\:Module/) {
|
||||
"The item '#{$1}' is not valid. Please add the item\r\nto the list of items in the editor. See the wiki for more information." }
|
||||
"The item '#{$1}' is not valid. Please add the item\r\nto the PBS/items.txt file. See the wiki for more information." }
|
||||
emessage = emessage.gsub(/uninitialized constant PBTypes\:\:(\S+)/) {
|
||||
"The type '#{$1}' is not valid. Please add the type\r\nto the PBS/types.txt file." }
|
||||
emessage = emessage.gsub(/undefined method `(\S+?)' for PBTypes\:Module/) {
|
||||
"The type '#{$1}' is not valid. Please add the type\r\nto the PBS/types.txt file." }
|
||||
emessage = emessage.gsub(/uninitialized constant PBTrainers\:\:(\S+)$/) {
|
||||
"The trainer type '#{$1}' is not valid. Please add the trainer\r\nto the list of trainer types in the Editor. See the wiki for\r\nmore information." }
|
||||
"The trainer type '#{$1}' is not valid. Please add the trainer\r\nto the PBS/trainertypes.txt file. See the wiki for\r\nmore information." }
|
||||
emessage = emessage.gsub(/undefined method `(\S+?)' for PBTrainers\:Module/) {
|
||||
"The trainer type '#{$1}' is not valid. Please add the trainer\r\nto the list of trainer types in the Editor. See the wiki for\r\nmore information." }
|
||||
"The trainer type '#{$1}' is not valid. Please add the trainer\r\nto the PBS/trainertypes.txt file. See the wiki for\r\nmore information." }
|
||||
emessage = emessage.gsub(/uninitialized constant PBSpecies\:\:(\S+)$/) {
|
||||
"The Pokemon species '#{$1}' is not valid. Please\r\nadd the species to the PBS/pokemon.txt file.\r\nSee the wiki for more information." }
|
||||
emessage = emessage.gsub(/undefined method `(\S+?)' for PBSpecies\:Module/) {
|
||||
|
||||
@@ -156,6 +156,7 @@ class HandlerHash2
|
||||
end
|
||||
|
||||
def [](sym)
|
||||
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
|
||||
return @hash[sym] if sym && @hash[sym]
|
||||
for add_if in @add_ifs
|
||||
return add_if[1] if add_if[0].call(sym)
|
||||
@@ -211,10 +212,7 @@ end
|
||||
|
||||
|
||||
|
||||
class ItemHandlerHash < HandlerHash
|
||||
def initialize
|
||||
super(:PBItems)
|
||||
end
|
||||
class ItemHandlerHash < HandlerHash2
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -194,9 +194,9 @@ module SpeciesData
|
||||
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
|
||||
:Ability, :Ability],
|
||||
"Habitat" => [HABITAT, "e", :PBHabitats],
|
||||
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems],
|
||||
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems],
|
||||
"WildItemRare" => [WILD_ITEM_RARE, "e", :PBItems],
|
||||
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :Item],
|
||||
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :Item],
|
||||
"WildItemRare" => [WILD_ITEM_RARE, "e", :Item],
|
||||
"BattlerPlayerX" => [METRIC_PLAYER_X, "i"],
|
||||
"BattlerPlayerY" => [METRIC_PLAYER_Y, "i"],
|
||||
"BattlerEnemyX" => [METRIC_ENEMY_X, "i"],
|
||||
@@ -210,12 +210,12 @@ module SpeciesData
|
||||
}
|
||||
if compilingForms
|
||||
ret["PokedexForm"] = [POKEDEX_FORM, "u"]
|
||||
ret["MegaStone"] = [MEGA_STONE, "e", :PBItems]
|
||||
ret["MegaStone"] = [MEGA_STONE, "e", :Item]
|
||||
ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves]
|
||||
ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
|
||||
ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
|
||||
else
|
||||
ret["Incense"] = [INCENSE, "e", :PBItems]
|
||||
ret["Incense"] = [INCENSE, "e", :Item]
|
||||
ret["RegionalNumbers"] = [0, "*u"]
|
||||
end
|
||||
return ret
|
||||
|
||||
@@ -102,3 +102,10 @@ class PBMoveData
|
||||
@flags = move_data[MoveData::FLAGS]
|
||||
end
|
||||
end
|
||||
|
||||
def pbIsHiddenMove?(move)
|
||||
GameData::Item.each do |i|
|
||||
return true if i.is_HM? && move == i.move
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
# A mixin module for data classes which provides common class methods (called
|
||||
# by PokemonData::Thing.method) that provide access to data held within.
|
||||
# by GameData::Thing.method) that provide access to data held within.
|
||||
# Assumes the data class's data is stored in a class constant hash called DATA.
|
||||
module ClassMethods
|
||||
# @param other [Symbol, self, Integer]
|
||||
# @param other [Symbol, self, String, Integer]
|
||||
# @return [Boolean] whether the given other is defined as a self
|
||||
def exists?(other)
|
||||
return false if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
other = other.id if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
other = other.id if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
return !self::DATA[other].nil?
|
||||
end
|
||||
|
||||
# @param other [Symbol, self, Integer]
|
||||
# @param other [Symbol, self, String, Integer]
|
||||
# @return [self]
|
||||
def get(other)
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
return other if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
return other if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
# if other.is_a?(Integer)
|
||||
# p "Please switch to symbols, thanks."
|
||||
# end
|
||||
@@ -26,8 +28,9 @@ module PokemonData
|
||||
|
||||
def try_get(other)
|
||||
return nil if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
return other if other.is_a?(self.class)
|
||||
validate other => [Symbol, self, String, Integer]
|
||||
return other if other.is_a?(self)
|
||||
other = other.to_sym if other.is_a?(String)
|
||||
# if other.is_a?(Integer)
|
||||
# p "Please switch to symbols, thanks."
|
||||
# end
|
||||
@@ -35,8 +38,7 @@ module PokemonData
|
||||
end
|
||||
|
||||
def each
|
||||
keys = self::DATA.keys
|
||||
keys.sort! { |a, b| a.id_number <=> b.id_number }
|
||||
keys = self::DATA.keys.sort { |a, b| self::DATA[a].id_number <=> self::DATA[b].id_number }
|
||||
keys.each do |key|
|
||||
yield self::DATA[key] if key.is_a?(Symbol)
|
||||
end
|
||||
@@ -55,15 +57,17 @@ module PokemonData
|
||||
# (called by thing.method) that analyse the data of a particular thing which
|
||||
# the instance represents.
|
||||
module InstanceMethods
|
||||
# @param other [Symbol, self.class, Integer]
|
||||
# @param other [Symbol, self.class, String, Integer]
|
||||
# @return [Boolean] whether other represents the same thing as this thing
|
||||
def ==(other)
|
||||
return false if other.nil?
|
||||
validate other => [Symbol, self.class, Integer]
|
||||
validate other => [Symbol, self.class, String, Integer]
|
||||
if other.is_a?(Symbol)
|
||||
return @id == other
|
||||
elsif other.is_a?(self.class)
|
||||
return @id == other.id
|
||||
elsif other.is_a?(String)
|
||||
return @id_number == other.to_sym
|
||||
elsif other.is_a?(Integer)
|
||||
return @id_number == other
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
class Item
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
@@ -47,54 +47,187 @@ module PokemonData
|
||||
def description
|
||||
return pbGetMessage(MessageTypes::ItemDescriptions, @id_number)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def is_TM?; return @field_use == 3; end
|
||||
def is_HM?; return @field_use == 4; end
|
||||
def is_machine?; return is_TM? || is_HM?; end
|
||||
def is_mail?; return @type == 1 || @type == 2; end
|
||||
def is_icon_mail?; return @type == 2; end
|
||||
def is_poke_ball?; return @type == 3 || @type == 4; end
|
||||
def is_snag_ball?; return @type == 3 || (@type == 4 && $PokemonGlobal.snagMachine); end
|
||||
def is_berry?; return @type == 5; end
|
||||
def is_key_item?; return @type == 6; end
|
||||
def is_evolution_stone?; return @type == 7; end
|
||||
def is_fossil?; return @type == 8; end
|
||||
def is_apricorn?; return @type == 9; end
|
||||
def is_gem?; return @type == 10; end
|
||||
def is_mulch?; return @type == 11; end
|
||||
def is_mega_stone?; return @type == 12; end # Does NOT include Red Orb/Blue Orb
|
||||
|
||||
def is_important?
|
||||
return true if is_key_item? || is_HM?
|
||||
return true if is_TM? && INFINITE_TMS
|
||||
return false
|
||||
end
|
||||
|
||||
module Compiler
|
||||
module_function
|
||||
def can_hold?; return !is_important?; end
|
||||
|
||||
def compile_items
|
||||
item_names = []
|
||||
item_names_plural = []
|
||||
item_descriptions = []
|
||||
# Read each line of items.txt at a time and compile it into an item
|
||||
pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"])
|
||||
item_number = line[0]
|
||||
item_symbol = line[1].to_sym
|
||||
if PokemonData::Item::DATA[item_number]
|
||||
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}", item_number, FileLineData.linereport)
|
||||
elsif PokemonData::Item::DATA[item_symbol]
|
||||
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport)
|
||||
end
|
||||
# Construct item hash
|
||||
item_hash = {
|
||||
:id_number => item_number,
|
||||
:id => item_symbol,
|
||||
:name => line[2],
|
||||
:name_plural => line[3],
|
||||
:pocket => line[4],
|
||||
:price => line[5],
|
||||
:description => line[6],
|
||||
:field_use => line[7],
|
||||
:battle_use => line[8],
|
||||
:type => line[9]
|
||||
def unlosable?(species, ability)
|
||||
return false if isConst?(species, PBSpecies, :ARCEUS) && ability != :MULTITYPE
|
||||
return false if isConst?(species, PBSpecies, :SILVALLY) && ability != :RKSSYSTEM
|
||||
combos = {
|
||||
:ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
|
||||
:SKYPLATE, :FLYINIUMZ,
|
||||
:TOXICPLATE, :POISONIUMZ,
|
||||
:EARTHPLATE, :GROUNDIUMZ,
|
||||
:STONEPLATE, :ROCKIUMZ,
|
||||
:INSECTPLATE, :BUGINIUMZ,
|
||||
:SPOOKYPLATE, :GHOSTIUMZ,
|
||||
:IRONPLATE, :STEELIUMZ,
|
||||
:FLAMEPLATE, :FIRIUMZ,
|
||||
:SPLASHPLATE, :WATERIUMZ,
|
||||
:MEADOWPLATE, :GRASSIUMZ,
|
||||
:ZAPPLATE, :ELECTRIUMZ,
|
||||
:MINDPLATE, :PSYCHIUMZ,
|
||||
:ICICLEPLATE, :ICIUMZ,
|
||||
:DRACOPLATE, :DRAGONIUMZ,
|
||||
:DREADPLATE, :DARKINIUMZ,
|
||||
:PIXIEPLATE, :FAIRIUMZ],
|
||||
:SILVALLY => [:FIGHTINGMEMORY,
|
||||
:FLYINGMEMORY,
|
||||
:POISONMEMORY,
|
||||
:GROUNDMEMORY,
|
||||
:ROCKMEMORY,
|
||||
:BUGMEMORY,
|
||||
:GHOSTMEMORY,
|
||||
:STEELMEMORY,
|
||||
:FIREMEMORY,
|
||||
:WATERMEMORY,
|
||||
:GRASSMEMORY,
|
||||
:ELECTRICMEMORY,
|
||||
:PSYCHICMEMORY,
|
||||
:ICEMEMORY,
|
||||
:DRAGONMEMORY,
|
||||
:DARKMEMORY,
|
||||
:FAIRYMEMORY],
|
||||
:GIRATINA => [:GRISEOUSORB],
|
||||
:GENESECT => [:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE],
|
||||
:KYOGRE => [:BLUEORB],
|
||||
:GROUDON => [:REDORB]
|
||||
}
|
||||
item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
|
||||
# Add item's data to records
|
||||
PokemonData::Item::DATA[item_number] = PokemonData::Item::DATA[item_symbol] = PokemonData::Item.new(item_hash)
|
||||
item_names[item_number] = item_hash[:name]
|
||||
item_names_plural[item_number] = item_hash[:name_plural]
|
||||
item_descriptions[item_number] = item_hash[:description]
|
||||
}
|
||||
# Save all data
|
||||
PokemonData::Item.save
|
||||
MessageTypes.setMessages(MessageTypes::Items, item_names)
|
||||
MessageTypes.setMessages(MessageTypes::ItemPlurals, item_names_plural)
|
||||
MessageTypes.setMessages(MessageTypes::ItemDescriptions, item_descriptions)
|
||||
|
||||
Graphics.update
|
||||
combos.each do |comboSpecies, items|
|
||||
next if !isConst?(species, PBSpecies, comboSpecies)
|
||||
return items.include?(@id)
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Deprecated methods
|
||||
#===============================================================================
|
||||
def pbGetPocket(item)
|
||||
Deprecation.warn_method('pbGetPocket', 'v20', 'GameData::Item.get(item).pocket')
|
||||
return GameData::Item.get(item).pocket
|
||||
end
|
||||
|
||||
def pbGetPrice(item)
|
||||
Deprecation.warn_method('pbGetPrice', 'v20', 'GameData::Item.get(item).price')
|
||||
return GameData::Item.get(item).price
|
||||
end
|
||||
|
||||
def pbGetMachine(item)
|
||||
Deprecation.warn_method('pbGetMachine', 'v20', 'GameData::Item.get(item).move')
|
||||
return GameData::Item.get(item).move
|
||||
end
|
||||
|
||||
def pbIsTechnicalMachine?(item)
|
||||
Deprecation.warn_method('pbIsTechnicalMachine?', 'v20', 'GameData::Item.get(item).is_TM?')
|
||||
return GameData::Item.get(item).is_TM?
|
||||
end
|
||||
|
||||
def pbIsHiddenMachine?(item)
|
||||
Deprecation.warn_method('pbIsHiddenMachine?', 'v20', 'GameData::Item.get(item).is_HM?')
|
||||
return GameData::Item.get(item).is_HM?
|
||||
end
|
||||
|
||||
def pbIsMachine?(item)
|
||||
Deprecation.warn_method('pbIsMachine?', 'v20', 'GameData::Item.get(item).is_machine?')
|
||||
return GameData::Item.get(item).is_machine?
|
||||
end
|
||||
|
||||
def pbIsMail?(item)
|
||||
Deprecation.warn_method('pbIsMail?', 'v20', 'GameData::Item.get(item).is_mail?')
|
||||
return GameData::Item.get(item).is_mail?
|
||||
end
|
||||
|
||||
def pbIsMailWithPokemonIcons?(item)
|
||||
Deprecation.warn_method('pbIsMailWithPokemonIcons?', 'v20', 'GameData::Item.get(item).is_icon_mail?')
|
||||
return GameData::Item.get(item).is_icon_mail?
|
||||
end
|
||||
|
||||
def pbIsPokeBall?(item)
|
||||
Deprecation.warn_method('pbIsPokeBall?', 'v20', 'GameData::Item.get(item).is_poke_ball?')
|
||||
return GameData::Item.get(item).is_poke_ball?
|
||||
end
|
||||
|
||||
def pbIsSnagBall?(item)
|
||||
Deprecation.warn_method('pbIsSnagBall?', 'v20', 'GameData::Item.get(item).is_snag_ball?')
|
||||
return GameData::Item.get(item).is_snag_ball?
|
||||
end
|
||||
|
||||
def pbIsBerry?(item)
|
||||
Deprecation.warn_method('pbIsBerry?', 'v20', 'GameData::Item.get(item).is_berry?')
|
||||
return GameData::Item.get(item).is_berry?
|
||||
end
|
||||
|
||||
def pbIsKeyItem?(item)
|
||||
Deprecation.warn_method('pbIsKeyItem?', 'v20', 'GameData::Item.get(item).is_key_item?')
|
||||
return GameData::Item.get(item).is_key_item?
|
||||
end
|
||||
|
||||
def pbIsEvolutionStone?(item)
|
||||
Deprecation.warn_method('pbIsEvolutionStone?', 'v20', 'GameData::Item.get(item).is_evolution_stone?')
|
||||
return GameData::Item.get(item).is_evolution_stone?
|
||||
end
|
||||
|
||||
def pbIsFossil?(item)
|
||||
Deprecation.warn_method('pbIsFossil?', 'v20', 'GameData::Item.get(item).is_fossil?')
|
||||
return GameData::Item.get(item).is_fossil?
|
||||
end
|
||||
|
||||
def pbIsApricorn?(item)
|
||||
Deprecation.warn_method('pbIsApricorn?', 'v20', 'GameData::Item.get(item).is_apricorn?')
|
||||
return GameData::Item.get(item).is_apricorn?
|
||||
end
|
||||
|
||||
def pbIsGem?(item)
|
||||
Deprecation.warn_method('pbIsGem?', 'v20', 'GameData::Item.get(item).is_gem?')
|
||||
return GameData::Item.get(item).is_gem?
|
||||
end
|
||||
|
||||
def pbIsMulch?(item)
|
||||
Deprecation.warn_method('pbIsMulch?', 'v20', 'GameData::Item.get(item).is_mulch?')
|
||||
return GameData::Item.get(item).is_mulch?
|
||||
end
|
||||
|
||||
def pbIsMegaStone?(item)
|
||||
Deprecation.warn_method('pbIsMegaStone?', 'v20', 'GameData::Item.get(item).is_mega_stone?')
|
||||
return GameData::Item.get(item).is_mega_stone?
|
||||
end
|
||||
|
||||
def pbIsImportantItem?(item)
|
||||
Deprecation.warn_method('pbIsImportantItem?', 'v20', 'GameData::Item.get(item).is_important?')
|
||||
return GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def pbCanHoldItem?(item)
|
||||
Deprecation.warn_method('pbCanHoldItem?', 'v20', 'GameData::Item.get(item).can_hold?')
|
||||
return GameData::Item.get(item).can_hold?
|
||||
end
|
||||
|
||||
def pbIsUnlosableItem?(check_item, species, ability)
|
||||
Deprecation.warn_method('pbIsUnlosableItem?', 'v20', 'GameData::Item.get(item).unlosable?')
|
||||
return GameData::Item.get(check_item).unlosable?(species, ability)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module PokemonData
|
||||
module GameData
|
||||
class Ability
|
||||
attr_reader :id
|
||||
attr_reader :id_number
|
||||
|
||||
@@ -9,6 +9,7 @@ class PokeBattle_Battler
|
||||
attr_accessor :type1
|
||||
attr_accessor :type2
|
||||
attr_accessor :ability_id
|
||||
attr_accessor :item_id
|
||||
attr_accessor :moves
|
||||
attr_accessor :gender
|
||||
attr_accessor :iv
|
||||
@@ -60,19 +61,22 @@ class PokeBattle_Battler
|
||||
end
|
||||
|
||||
def ability
|
||||
return PokemonData::Ability.try_get(@ability_id)
|
||||
return GameData::Ability.try_get(@ability_id)
|
||||
end
|
||||
|
||||
def ability=(value)
|
||||
abil = PokemonData::Ability.try_get(value)
|
||||
@ability_id = (abil) ? abil.id : nil
|
||||
new_ability = GameData::Ability.try_get(value)
|
||||
@ability_id = (new_ability) ? new_ability.id : nil
|
||||
end
|
||||
|
||||
attr_reader :item
|
||||
def item
|
||||
return GameData::Item.try_get(@item_id)
|
||||
end
|
||||
|
||||
def item=(value)
|
||||
@item = value
|
||||
@pokemon.setItem(value) if @pokemon
|
||||
new_item = GameData::Item.try_get(value)
|
||||
@item_id = (new_item) ? new_item.id : nil
|
||||
@pokemon.setItem(@item_id) if @pokemon
|
||||
end
|
||||
|
||||
def defense
|
||||
@@ -195,7 +199,10 @@ class PokeBattle_Battler
|
||||
return (abil) ? abil.name : ""
|
||||
end
|
||||
|
||||
def itemName; return PBItems.getName(@item); end
|
||||
def itemName
|
||||
itm = self.item
|
||||
return (itm) ? itm.name : ""
|
||||
end
|
||||
|
||||
def pbThis(lowerCase=false)
|
||||
if opposes?
|
||||
@@ -240,7 +247,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
# Item effects that alter calculated Speed
|
||||
if itemActive?
|
||||
speedMult = BattleHandlers.triggerSpeedCalcItem(@item,self,speedMult)
|
||||
speedMult = BattleHandlers.triggerSpeedCalcItem(self.item,self,speedMult)
|
||||
end
|
||||
# Other effects
|
||||
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
|
||||
@@ -266,7 +273,7 @@ class PokeBattle_Battler
|
||||
ret = BattleHandlers.triggerWeightCalcAbility(self.ability,self,ret)
|
||||
end
|
||||
if itemActive?
|
||||
ret = BattleHandlers.triggerWeightCalcItem(@item,self,ret)
|
||||
ret = BattleHandlers.triggerWeightCalcItem(self.item,self,ret)
|
||||
end
|
||||
return [ret,1].max
|
||||
end
|
||||
@@ -331,14 +338,14 @@ class PokeBattle_Battler
|
||||
# active, and the code for the two combined would cause an infinite loop
|
||||
# (regardless of whether any Pokémon actualy has either the ability or
|
||||
# the item - the code existing is enough to cause the loop).
|
||||
def abilityActive?(ignoreFainted=false)
|
||||
return false if fainted? && !ignoreFainted
|
||||
def abilityActive?(ignore_fainted = false)
|
||||
return false if fainted? && !ignore_fainted
|
||||
return false if @effects[PBEffects::GastroAcid]
|
||||
return true
|
||||
end
|
||||
|
||||
def hasActiveAbility?(check_ability, ignoreFainted = false)
|
||||
return false if !abilityActive?(ignoreFainted)
|
||||
def hasActiveAbility?(check_ability, ignore_fainted = false)
|
||||
return false if !abilityActive?(ignore_fainted)
|
||||
return check_ability.include?(@ability_id) if check_ability.is_a?(Array)
|
||||
return check_ability == self.ability
|
||||
end
|
||||
@@ -348,7 +355,7 @@ class PokeBattle_Battler
|
||||
# having self's ability be negated.
|
||||
def unstoppableAbility?(abil = nil)
|
||||
abil = @ability_id if !abil
|
||||
abil = PokemonData::Ability.try_get(abil)
|
||||
abil = GameData::Ability.try_get(abil)
|
||||
return false if !abil
|
||||
ability_blacklist = [
|
||||
# Form-changing abilities
|
||||
@@ -372,7 +379,7 @@ class PokeBattle_Battler
|
||||
# Applies to gaining the ability.
|
||||
def ungainableAbility?(abil = nil)
|
||||
abil = @ability_id if !abil
|
||||
abil = PokemonData::Ability.try_get(abil)
|
||||
abil = GameData::Ability.try_get(abil)
|
||||
return false if !abil
|
||||
ability_blacklist = [
|
||||
# Form-changing abilities
|
||||
@@ -404,28 +411,21 @@ class PokeBattle_Battler
|
||||
return true
|
||||
end
|
||||
|
||||
def hasActiveItem?(item,ignoreFainted=false)
|
||||
return false if !itemActive?(ignoreFainted)
|
||||
if item.is_a?(Array)
|
||||
item.each do |i|
|
||||
i = getID(PBItems,i)
|
||||
return true if i!=0 && i==@item
|
||||
end
|
||||
return false
|
||||
end
|
||||
item = getID(PBItems,item)
|
||||
return item!=0 && item==@item
|
||||
def hasActiveItem?(check_item, ignore_fainted = false)
|
||||
return false if !itemActive?(ignore_fainted)
|
||||
return check_item.include?(@item_id) if check_item.is_a?(Array)
|
||||
return check_item == self.item
|
||||
end
|
||||
alias hasWorkingItem hasActiveItem?
|
||||
|
||||
# Returns whether the specified item will be unlosable for this Pokémon.
|
||||
def unlosableItem?(check_item)
|
||||
return false if check_item <= 0
|
||||
return true if pbIsMail?(check_item)
|
||||
return false if !check_item
|
||||
return true if GameData::Item.get(check_item).is_mail?
|
||||
return false if @effects[PBEffects::Transform]
|
||||
# Items that change a Pokémon's form
|
||||
return true if @pokemon && @pokemon.getMegaForm(true) > 0 # Mega Stone
|
||||
return pbIsUnlosableItem?(check_item, @species, self.ability)
|
||||
return GameData::Item.get(check_item).unlosable?(@species, self.ability)
|
||||
end
|
||||
|
||||
def eachMove
|
||||
|
||||
@@ -22,7 +22,7 @@ class PokeBattle_Battler
|
||||
@hp = @totalhp = 0
|
||||
@type1 = @type2 = 0
|
||||
@ability_id = nil
|
||||
@item = 0
|
||||
@item_id = nil
|
||||
@gender = 0
|
||||
@attack = @defense = @spatk = @spdef = @speed = 0
|
||||
@status = PBStatuses::NONE
|
||||
@@ -79,7 +79,7 @@ class PokeBattle_Battler
|
||||
@type1 = pkmn.type1
|
||||
@type2 = pkmn.type2
|
||||
@ability_id = pkmn.ability_id
|
||||
@item = pkmn.item
|
||||
@item_id = pkmn.item_id
|
||||
@gender = pkmn.gender
|
||||
@attack = pkmn.attack
|
||||
@defense = pkmn.defense
|
||||
@@ -188,7 +188,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::FollowMe] = 0
|
||||
@effects[PBEffects::Foresight] = false
|
||||
@effects[PBEffects::FuryCutter] = 0
|
||||
@effects[PBEffects::GemConsumed] = 0
|
||||
@effects[PBEffects::GemConsumed] = nil
|
||||
@effects[PBEffects::Grudge] = false
|
||||
@effects[PBEffects::HelpingHand] = false
|
||||
@effects[PBEffects::HyperBeam] = 0
|
||||
@@ -227,7 +227,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::Nightmare] = false
|
||||
@effects[PBEffects::Outrage] = 0
|
||||
@effects[PBEffects::ParentalBond] = 0
|
||||
@effects[PBEffects::PickupItem] = 0
|
||||
@effects[PBEffects::PickupItem] = nil
|
||||
@effects[PBEffects::PickupUse] = 0
|
||||
@effects[PBEffects::Pinch] = false
|
||||
@effects[PBEffects::Powder] = false
|
||||
|
||||
@@ -17,7 +17,7 @@ class PokeBattle_Battler
|
||||
@battle.pbEndPrimordialWeather
|
||||
# Items that trigger upon switching in (Air Balloon message)
|
||||
if switchIn && itemActive?
|
||||
BattleHandlers.triggerItemOnSwitchIn(@item,self,@battle)
|
||||
BattleHandlers.triggerItemOnSwitchIn(self.item,self,@battle)
|
||||
end
|
||||
# Berry check, status-curing ability check
|
||||
pbHeldItemTriggerCheck if switchIn
|
||||
@@ -75,7 +75,7 @@ class PokeBattle_Battler
|
||||
choices = []
|
||||
@battle.eachOtherSideBattler(@index) do |b|
|
||||
next if b.ungainableAbility? ||
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
|
||||
choices.push(b)
|
||||
end
|
||||
if choices.length>0
|
||||
@@ -109,7 +109,7 @@ class PokeBattle_Battler
|
||||
@effects[PBEffects::Illusion] = nil
|
||||
if !@effects[PBEffects::Transform]
|
||||
@battle.scene.pbChangePokemon(self, @pokemon)
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, PokemonData::Ability.get(oldAbil).name))
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, GameData::Ability.get(oldAbil).name))
|
||||
@battle.pbSetSeen(self)
|
||||
end
|
||||
end
|
||||
@@ -135,32 +135,32 @@ class PokeBattle_Battler
|
||||
|
||||
# permanent is whether the item is lost even after battle. Is false for Knock
|
||||
# Off.
|
||||
def pbRemoveItem(permanent=true)
|
||||
def pbRemoveItem(permanent = true)
|
||||
@effects[PBEffects::ChoiceBand] = -1
|
||||
@effects[PBEffects::Unburden] = true if @item>0
|
||||
setInitialItem(0) if self.initialItem==@item && permanent
|
||||
self.item = 0
|
||||
@effects[PBEffects::Unburden] = true if self.item
|
||||
setInitialItem(nil) if permanent && self.item == self.initialItem
|
||||
self.item = nil
|
||||
end
|
||||
|
||||
def pbConsumeItem(recoverable=true,symbiosis=true,belch=true)
|
||||
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{PBItems.getName(@item)}")
|
||||
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{itemName}")
|
||||
if recoverable
|
||||
setRecycleItem(@item)
|
||||
@effects[PBEffects::PickupItem] = @item
|
||||
setRecycleItem(@item_id)
|
||||
@effects[PBEffects::PickupItem] = @item_id
|
||||
@effects[PBEffects::PickupUse] = @battle.nextPickupUse
|
||||
end
|
||||
setBelched if belch && pbIsBerry?(@item)
|
||||
setBelched if belch && self.item.is_berry?
|
||||
pbRemoveItem
|
||||
pbSymbiosis if symbiosis
|
||||
end
|
||||
|
||||
def pbSymbiosis
|
||||
return if fainted?
|
||||
return if @item!=0
|
||||
return if !self.item
|
||||
@battle.pbPriority(true).each do |b|
|
||||
next if b.opposes?
|
||||
next if !b.hasActiveAbility?(:SYMBIOSIS)
|
||||
next if b.item==0 || b.unlosableItem?(b.item)
|
||||
next if !b.item || b.unlosableItem?(b.item)
|
||||
next if unlosableItem?(b.item)
|
||||
@battle.pbShowAbilitySplash(b)
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
@@ -171,7 +171,7 @@ class PokeBattle_Battler
|
||||
b.pbThis,b.abilityName,b.itemName,pbThis(true)))
|
||||
end
|
||||
self.item = b.item
|
||||
b.item = 0
|
||||
b.item = nil
|
||||
b.effects[PBEffects::Unburden] = true
|
||||
@battle.pbHideAbilitySplash(b)
|
||||
pbHeldItemTriggerCheck
|
||||
@@ -179,20 +179,22 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
|
||||
def pbHeldItemTriggered(thisItem,forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID or GameData::Item object. own_item is whether the
|
||||
# item is held by self. fling is for Fling only.
|
||||
def pbHeldItemTriggered(item_to_use, own_item = true, fling = false)
|
||||
# Cheek Pouch
|
||||
if hasActiveAbility?(:CHEEKPOUCH) && pbIsBerry?(thisItem) && canHeal?
|
||||
if hasActiveAbility?(:CHEEKPOUCH) && GameData::Item.get(item_to_use).is_berry? && canHeal?
|
||||
@battle.pbShowAbilitySplash(self)
|
||||
pbRecoverHP(@totalhp/3)
|
||||
pbRecoverHP(@totalhp / 3)
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
@battle.pbDisplay(_INTL("{1}'s HP was restored.",pbThis))
|
||||
@battle.pbDisplay(_INTL("{1}'s HP was restored.", pbThis))
|
||||
else
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",pbThis,abilityName))
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", pbThis, abilityName))
|
||||
end
|
||||
@battle.pbHideAbilitySplash(self)
|
||||
end
|
||||
pbConsumeItem if forcedItem<=0
|
||||
pbSymbiosis if forcedItem>0 && !fling # Bug Bite/Pluck users trigger Symbiosis
|
||||
pbConsumeItem if own_item
|
||||
pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -201,96 +203,91 @@ class PokeBattle_Battler
|
||||
# NOTE: A Pokémon using Bug Bite/Pluck, and a Pokémon having an item thrown at
|
||||
# it via Fling, will gain the effect of the item even if the Pokémon is
|
||||
# affected by item-negating effects.
|
||||
# If forcedItem is -1, the Pokémon's held item is forced to be consumed. If it
|
||||
# is greater than 0, a different item (of that ID) is forced to be consumed
|
||||
# (not the Pokémon's held one).
|
||||
def pbHeldItemTriggerCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbHeldItemTriggerCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
pbItemHPHealCheck(forcedItem,fling)
|
||||
pbItemStatusCureCheck(forcedItem,fling)
|
||||
pbItemEndOfMoveCheck(forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
pbItemHPHealCheck(item_to_use, fling)
|
||||
pbItemStatusCureCheck(item_to_use, fling)
|
||||
pbItemEndOfMoveCheck(item_to_use, fling)
|
||||
# For Enigma Berry, Kee Berry and Maranga Berry, which have their effects
|
||||
# when forcibly consumed by Pluck/Fling.
|
||||
if forcedItem!=0
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(thisItem,self,@battle,true)
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
if item_to_use
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(itm, self, @battle, true)
|
||||
pbHeldItemTriggered(itm, false, fling)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# forcedItem is an item ID for Bug Bite/Pluck/Fling, and 0 otherwise.
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemHPHealCheck(forcedItem=0,fling=false)
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerHPHealItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
elsif forcedItem==0
|
||||
def pbItemHPHealCheck(item_to_use = nil, fling = false)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerHPHealItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
elsif !item_to_use
|
||||
pbItemTerrainStatBoostCheck
|
||||
end
|
||||
end
|
||||
|
||||
# Cures status conditions, confusion, infatuation and the other effects cured
|
||||
# by Mental Herb.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemStatusCureCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemStatusCureCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerStatusCureItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerStatusCureItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Called at the end of using a move.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemEndOfMoveCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemEndOfMoveCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerEndOfMoveItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerEndOfMoveItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Used for White Herb (restore lowered stats). Only called by Moody and Sticky
|
||||
# Web, as all other stat reduction happens because of/during move usage and
|
||||
# this handler is also called at the end of each move's usage.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemStatRestoreCheck(forcedItem=0,fling=false)
|
||||
# item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
|
||||
# fling is for Fling only.
|
||||
def pbItemStatRestoreCheck(item_to_use = nil, fling = false)
|
||||
return if fainted?
|
||||
return if forcedItem==0 && !itemActive?
|
||||
thisItem = (forcedItem>0) ? forcedItem : @item
|
||||
if BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0))
|
||||
pbHeldItemTriggered(thisItem,forcedItem,fling)
|
||||
return if !item_to_use && !itemActive?
|
||||
itm = item_to_use || self.item
|
||||
if BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
|
||||
pbHeldItemTriggered(itm, item_to_use.nil?, fling)
|
||||
end
|
||||
end
|
||||
|
||||
# Called when the battle terrain changes and when a Pokémon loses HP.
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemTerrainStatBoostCheck
|
||||
return if !itemActive?
|
||||
if BattleHandlers.triggerTerrainStatBoostItem(@item,self,@battle)
|
||||
pbHeldItemTriggered(@item)
|
||||
if BattleHandlers.triggerTerrainStatBoostItem(self.item, self, @battle)
|
||||
pbHeldItemTriggered(self.item)
|
||||
end
|
||||
end
|
||||
|
||||
# Used for Adrenaline Orb. Called when Intimidate is triggered (even if
|
||||
# Intimidate has no effect on the Pokémon).
|
||||
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for
|
||||
# Fling only.
|
||||
def pbItemOnIntimidatedCheck
|
||||
return if !itemActive?
|
||||
if BattleHandlers.triggerItemOnIntimidated(@item,self,@battle)
|
||||
pbHeldItemTriggered(@item)
|
||||
if BattleHandlers.triggerItemOnIntimidated(self.item, self, @battle)
|
||||
pbHeldItemTriggered(self.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -116,7 +116,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1
|
||||
@effects[PBEffects::GemConsumed] = 0
|
||||
@effects[PBEffects::GemConsumed] = nil
|
||||
@battle.eachBattler { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
|
||||
end
|
||||
|
||||
@@ -624,12 +624,12 @@ class PokeBattle_Battler
|
||||
# Show move animation (for this hit)
|
||||
move.pbShowAnimation(move.id,user,targets,hitNum)
|
||||
# Type-boosting Gem consume animation/message
|
||||
if user.effects[PBEffects::GemConsumed]>0 && hitNum==0
|
||||
if user.effects[PBEffects::GemConsumed] && hitNum==0
|
||||
# NOTE: The consume animation and message for Gems are shown now, but the
|
||||
# actual removal of the item happens in def pbEffectsAfterMove.
|
||||
@battle.pbCommonAnimation("UseItem",user)
|
||||
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!",
|
||||
PBItems.getName(user.effects[PBEffects::GemConsumed]),move.name))
|
||||
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
|
||||
end
|
||||
# Messages about missed target(s) (relevant for multi-target moves only)
|
||||
targets.each do |b|
|
||||
|
||||
@@ -111,7 +111,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Consume user's Gem
|
||||
if user.effects[PBEffects::GemConsumed]>0
|
||||
if user.effects[PBEffects::GemConsumed]
|
||||
# NOTE: The consume animation and message for Gems are shown immediately
|
||||
# after the move's animation, but the item is only consumed now.
|
||||
user.pbConsumeItem
|
||||
|
||||
@@ -1997,7 +1997,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_063 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !PokemonData::Ability.exists?(:SIMPLE)
|
||||
if !GameData::Ability.exists?(:SIMPLE)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2030,7 +2030,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_064 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !PokemonData::Ability.exists?(:INSOMNIA)
|
||||
if !GameData::Ability.exists?(:INSOMNIA)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_086 < PokeBattle_Move
|
||||
def pbBaseDamageMultiplier(damageMult,user,target)
|
||||
damageMult *= 2 if user.item==0
|
||||
damageMult *= 2 if !user.item
|
||||
return damageMult
|
||||
end
|
||||
end
|
||||
@@ -473,13 +473,13 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
:ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY, :JABOCABERRY, :ROWAPBERRY,
|
||||
:KEEBERRY, :MARANGABERRY]
|
||||
}
|
||||
@berry = 0
|
||||
@berry = nil
|
||||
end
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
# NOTE: Unnerve does not stop a Pokémon using this move.
|
||||
@berry = user.item
|
||||
if !pbIsBerry?(@berry) || !user.itemActive?
|
||||
if !@berry || !@berry.is_berry? || !user.itemActive?
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -492,14 +492,10 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# complex item movement is unlikely, perhaps this is good enough.
|
||||
def pbBaseType(user)
|
||||
ret = getID(PBTypes,:NORMAL)
|
||||
found = false
|
||||
@typeArray.each do |type, items|
|
||||
items.each do |i|
|
||||
next if !isConst?(@berry,PBItems,i)
|
||||
ret = getConst(PBTypes,type) || ret
|
||||
found = true; break
|
||||
end
|
||||
break if found
|
||||
next if !items.include?(@berry.id)
|
||||
ret = getConst(PBTypes,type) || ret
|
||||
break
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -507,21 +503,17 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# This is a separate method so that the AI can use it as well
|
||||
def pbNaturalGiftBaseDamage(heldItem)
|
||||
ret = 1
|
||||
found = false
|
||||
@damageArray.each do |dmg, items|
|
||||
items.each do |i|
|
||||
next if !isConst?(heldItem,PBItems,i)
|
||||
ret = dmg
|
||||
ret += 20 if NEWEST_BATTLE_MECHANICS
|
||||
found = true; break
|
||||
end
|
||||
break if found
|
||||
next if !items.include?(heldItem)
|
||||
ret = dmg
|
||||
ret += 20 if NEWEST_BATTLE_MECHANICS
|
||||
break
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
return pbNaturalGiftBaseDamage(@berry)
|
||||
return pbNaturalGiftBaseDamage(@berry.id)
|
||||
end
|
||||
|
||||
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
|
||||
@@ -529,8 +521,8 @@ class PokeBattle_Move_096 < PokeBattle_Move
|
||||
# missed. The item is not consumed if the target was switched out by
|
||||
# an effect like a target's Red Card.
|
||||
# NOTE: There is no item consumption animation.
|
||||
user.pbConsumeItem(true,true,false) if user.item>0
|
||||
@berry = 0
|
||||
user.pbConsumeItem(true,true,false) if user.item
|
||||
@berry = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -776,7 +768,7 @@ class PokeBattle_Move_09F < PokeBattle_Move
|
||||
ret = getID(PBTypes,:NORMAL)
|
||||
if user.itemActive?
|
||||
@itemTypes.each do |item, itemType|
|
||||
next if !isConst?(user.item,PBItems,item)
|
||||
next if user.item != item
|
||||
t = getConst(PBTypes,itemType)
|
||||
ret = t || ret
|
||||
break
|
||||
@@ -3195,7 +3187,7 @@ end
|
||||
class PokeBattle_Move_0F0 < PokeBattle_Move
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
if NEWEST_BATTLE_MECHANICS &&
|
||||
target.item!=0 && !target.unlosableItem?(target.item)
|
||||
target.item && !target.unlosableItem?(target.item)
|
||||
# NOTE: Damage is still boosted even if target has Sticky Hold or a
|
||||
# substitute.
|
||||
baseDmg = (baseDmg*1.5).round
|
||||
@@ -3207,7 +3199,7 @@ class PokeBattle_Move_0F0 < PokeBattle_Move
|
||||
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't knock off
|
||||
return if user.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || target.unlosableItem?(target.item)
|
||||
return if !target.item || target.unlosableItem?(target.item)
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
itemName = target.itemName
|
||||
target.pbRemoveItem(false)
|
||||
@@ -3226,7 +3218,7 @@ class PokeBattle_Move_0F1 < PokeBattle_Move
|
||||
return if @battle.wildBattle? && user.opposes? # Wild Pokémon can't thieve
|
||||
return if user.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || user.item!=0
|
||||
return if !target.item || user.item
|
||||
return if target.unlosableItem?(target.item)
|
||||
return if user.unlosableItem?(target.item)
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
@@ -3234,7 +3226,7 @@ class PokeBattle_Move_0F1 < PokeBattle_Move
|
||||
user.item = target.item
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && target.opposes? &&
|
||||
target.initialItem==target.item && user.initialItem==0
|
||||
target.initialItem==target.item && !user.initialItem
|
||||
user.setInitialItem(target.item)
|
||||
target.pbRemoveItem
|
||||
else
|
||||
@@ -3261,7 +3253,7 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if user.item==0 && target.item==0
|
||||
if !user.item && !target.item
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3291,22 +3283,22 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
|
||||
oldTargetItem = target.item; oldTargetItemName = target.itemName
|
||||
user.item = oldTargetItem
|
||||
user.effects[PBEffects::ChoiceBand] = -1
|
||||
user.effects[PBEffects::Unburden] = (user.item==0 && oldUserItem>0)
|
||||
user.effects[PBEffects::Unburden] = (!user.item && oldUserItem)
|
||||
target.item = oldUserItem
|
||||
target.effects[PBEffects::ChoiceBand] = -1
|
||||
target.effects[PBEffects::Unburden] = (target.item==0 && oldTargetItem>0)
|
||||
target.effects[PBEffects::Unburden] = (!target.item && oldTargetItem)
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && target.opposes? &&
|
||||
target.initialItem==oldTargetItem && user.initialItem==0
|
||||
target.initialItem==oldTargetItem && !user.initialItem
|
||||
user.setInitialItem(oldTargetItem)
|
||||
end
|
||||
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis))
|
||||
if oldUserItem>0 && oldTargetItem>0
|
||||
if oldUserItem && oldTargetItem
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
|
||||
elsif oldTargetItem>0
|
||||
elsif oldTargetItem
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
|
||||
end
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem>0
|
||||
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem
|
||||
user.pbHeldItemTriggerCheck
|
||||
target.pbHeldItemTriggerCheck
|
||||
end
|
||||
@@ -3325,7 +3317,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
if user.item==0 || user.unlosableItem?(user.item)
|
||||
if !user.item || user.unlosableItem?(user.item)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3333,7 +3325,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if target.item!=0 || target.unlosableItem?(user.item)
|
||||
if target.item || target.unlosableItem?(user.item)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3345,7 +3337,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
|
||||
target.item = user.item
|
||||
# Permanently steal the item from wild Pokémon
|
||||
if @battle.wildBattle? && user.opposes? &&
|
||||
user.initialItem==user.item && target.initialItem==0
|
||||
user.initialItem==user.item && !target.initialItem
|
||||
target.setInitialItem(user.item)
|
||||
user.pbRemoveItem
|
||||
else
|
||||
@@ -3365,7 +3357,7 @@ class PokeBattle_Move_0F4 < PokeBattle_Move
|
||||
def pbEffectAfterAllHits(user,target)
|
||||
return if user.fainted? || target.fainted?
|
||||
return if target.damageState.unaffected || target.damageState.substitute
|
||||
return if target.item==0 || !pbIsBerry?(target.item)
|
||||
return if !target.item || !target.item.is_berry?
|
||||
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
|
||||
item = target.item
|
||||
itemName = target.itemName
|
||||
@@ -3383,8 +3375,8 @@ end
|
||||
class PokeBattle_Move_0F5 < PokeBattle_Move
|
||||
def pbEffectWhenDealingDamage(user,target)
|
||||
return if target.damageState.substitute || target.damageState.berryWeakened
|
||||
return if !pbIsBerry?(target.item) &&
|
||||
!(NEWEST_BATTLE_MECHANICS && pbIsGem?(target.item))
|
||||
return if !target.item || (!target.item.is_berry? &&
|
||||
!(NEWEST_BATTLE_MECHANICS && target.item.is_gem?))
|
||||
target.pbRemoveItem
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName))
|
||||
end
|
||||
@@ -3397,7 +3389,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_0F6 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if user.recycleItem==0
|
||||
if !user.recycleItem
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -3407,11 +3399,11 @@ class PokeBattle_Move_0F6 < PokeBattle_Move
|
||||
def pbEffectGeneral(user)
|
||||
item = user.recycleItem
|
||||
user.item = item
|
||||
user.setInitialItem(item) if @battle.wildBattle? && user.initialItem==0
|
||||
user.setRecycleItem(0)
|
||||
user.effects[PBEffects::PickupItem] = 0
|
||||
user.setInitialItem(item) if @battle.wildBattle? && !user.initialItem
|
||||
user.setRecycleItem(nil)
|
||||
user.effects[PBEffects::PickupItem] = nil
|
||||
user.effects[PBEffects::PickupUse] = 0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if itemName.starts_with_vowel?
|
||||
@battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName))
|
||||
else
|
||||
@@ -3545,20 +3537,18 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
|
||||
def pbCheckFlingSuccess(user)
|
||||
@willFail = false
|
||||
@willFail = true if user.item==0 || !user.itemActive? || user.unlosableItem?(user.item)
|
||||
if pbIsBerry?(user.item)
|
||||
@willFail = true if @battle.pbCheckOpposingAbility(:UNNERVE,user.index)
|
||||
return
|
||||
@willFail = true if !user.item || !user.itemActive? || user.unlosableItem?(user.item)
|
||||
return if @willFail
|
||||
if user.item.is_berry? && @battle.pbCheckOpposingAbility(:UNNERVE,user.index)
|
||||
@willFail = true
|
||||
end
|
||||
return if pbIsMegaStone?(user.item)
|
||||
return if @willFail
|
||||
return if user.item.is_mega_stone?
|
||||
flingableItem = false
|
||||
@flingPowers.each do |_power,items|
|
||||
items.each do |i|
|
||||
next if !isConst?(user.item,PBItems,i)
|
||||
flingableItem = true
|
||||
break
|
||||
end
|
||||
break if flingableItem
|
||||
@flingPowers.each do |_power, items|
|
||||
next if !items.include?(user.item_id)
|
||||
flingableItem = true
|
||||
break
|
||||
end
|
||||
@willFail = true if !flingableItem
|
||||
end
|
||||
@@ -3582,10 +3572,10 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
def pbNumHits(user,targets); return 1; end
|
||||
|
||||
def pbBaseDamage(baseDmg,user,target)
|
||||
return 10 if pbIsBerry?(user.item)
|
||||
return 80 if pbIsMegaStone?(user.item)
|
||||
return 10 if user.item && user.item.is_berry?
|
||||
return 80 if user.item && user.item.is_mega_stone?
|
||||
@flingPowers.each do |power,items|
|
||||
items.each { |i| return power if isConst?(user.item,PBItems,i) }
|
||||
return power if items.include?(user.item_id)
|
||||
end
|
||||
return 10
|
||||
end
|
||||
@@ -3593,16 +3583,16 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
def pbEffectAgainstTarget(user,target)
|
||||
return if target.damageState.substitute
|
||||
return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
|
||||
if isConst?(user.item,PBItems,:POISONBARB)
|
||||
case user.item_id
|
||||
when :POISONBARB
|
||||
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:TOXICORB)
|
||||
when :TOXICORB
|
||||
target.pbPoison(user,nil,true) if target.pbCanPoison?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:FLAMEORB)
|
||||
when :FLAMEORB
|
||||
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:LIGHTBALL)
|
||||
when :LIGHTBALL
|
||||
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
|
||||
elsif isConst?(user.item,PBItems,:KINGSROCK) ||
|
||||
isConst?(user.item,PBItems,:RAZORFANG)
|
||||
when :KINGSROCK, :RAZORFANG
|
||||
target.pbFlinch(user)
|
||||
else
|
||||
target.pbHeldItemTriggerCheck(user.item,true)
|
||||
@@ -3614,7 +3604,7 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
|
||||
# missed. The item is not consumed if the target was switched out by
|
||||
# an effect like a target's Red Card.
|
||||
# NOTE: There is no item consumption animation.
|
||||
user.pbConsumeItem(true,true,false) if user.item>0
|
||||
user.pbConsumeItem(true,true,false) if user.item
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module PokeBattle_BattleCommon
|
||||
storedBox = @peer.pbStorePokemon(pbPlayer,pkmn)
|
||||
if storedBox<0
|
||||
pbDisplayPaused(_INTL("{1} has been added to your party.",pkmn.name))
|
||||
@initialItems[0][pbPlayer.party.length-1] = pkmn.item if @initialItems
|
||||
@initialItems[0][pbPlayer.party.length-1] = pkmn.item_id if @initialItems
|
||||
return
|
||||
end
|
||||
# Messages saying the Pokémon was stored in a PC box
|
||||
@@ -80,7 +80,7 @@ module PokeBattle_BattleCommon
|
||||
end
|
||||
end
|
||||
# Messages
|
||||
itemName = PBItems.getName(ball)
|
||||
itemName = GameData::Item.get(ball).name
|
||||
if battler.fainted?
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
|
||||
@@ -97,7 +97,7 @@ module PokeBattle_BattleCommon
|
||||
end
|
||||
# Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball
|
||||
# at a Shadow Pokémon)
|
||||
if trainerBattle? && !(pbIsSnagBall?(ball) && battler.shadowPokemon?)
|
||||
if trainerBattle? && !(GameData::Item.get(ball).is_snag_ball? && battler.shadowPokemon?)
|
||||
@scene.pbThrowAndDeflect(ball,1)
|
||||
pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!"))
|
||||
return
|
||||
@@ -140,7 +140,7 @@ module PokeBattle_BattleCommon
|
||||
@decision = 4 if pbAllFainted?(battler.index) # Battle ended by capture
|
||||
end
|
||||
# Modify the Pokémon's properties because of the capture
|
||||
if pbIsSnagBall?(ball)
|
||||
if GameData::Item.get(ball).is_snag_ball?
|
||||
pkmn.owner = Pokemon::Owner.new_from_trainer(pbPlayer)
|
||||
end
|
||||
BallHandlers.onCatch(ball,self,pkmn)
|
||||
@@ -180,7 +180,7 @@ module PokeBattle_BattleCommon
|
||||
battler.isSpecies?(:NAGANADEL) ||
|
||||
battler.isSpecies?(:STAKATAKA) ||
|
||||
battler.isSpecies?(:BLACEPHALON))
|
||||
if !ultraBeast || isConst?(ball,PBItems,:BEASTBALL)
|
||||
if !ultraBeast || ball == :BEASTBALL
|
||||
rareness = BallHandlers.modifyCatchRate(ball,rareness,self,battler,ultraBeast)
|
||||
else
|
||||
rareness /= 10
|
||||
|
||||
@@ -144,13 +144,13 @@ class PokeBattle_Battle
|
||||
[-1] * (@opponent ? @opponent.length : 1)
|
||||
]
|
||||
@initialItems = [
|
||||
Array.new(@party1.length) { |i| (@party1[i]) ? @party1[i].item : 0 },
|
||||
Array.new(@party2.length) { |i| (@party2[i]) ? @party2[i].item : 0 }
|
||||
Array.new(@party1.length) { |i| (@party1[i]) ? @party1[i].item_id : nil },
|
||||
Array.new(@party2.length) { |i| (@party2[i]) ? @party2[i].item_id : nil }
|
||||
]
|
||||
@recycleItems = [Array.new(@party1.length,0),Array.new(@party2.length,0)]
|
||||
@belch = [Array.new(@party1.length,false),Array.new(@party2.length,false)]
|
||||
@battleBond = [Array.new(@party1.length,false),Array.new(@party2.length,false)]
|
||||
@usedInBattle = [Array.new(@party1.length,false),Array.new(@party2.length,false)]
|
||||
@recycleItems = [Array.new(@party1.length, nil), Array.new(@party2.length, nil)]
|
||||
@belch = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
|
||||
@battleBond = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
|
||||
@usedInBattle = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
|
||||
@successStates = []
|
||||
@lastMoveUsed = -1
|
||||
@lastMoveUser = -1
|
||||
|
||||
@@ -478,7 +478,7 @@ class PokeBattle_Battle
|
||||
pbParty(0).each_with_index do |pkmn,i|
|
||||
next if !pkmn
|
||||
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
|
||||
pkmn.setItem(@initialItems[0][i] || 0)
|
||||
pkmn.setItem(@initialItems[0][i])
|
||||
end
|
||||
return @decision
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class PokeBattle_Battle
|
||||
return if !@internalBattle || !@expGain
|
||||
# Go through each battler in turn to find the Pokémon that participated in
|
||||
# battle against it, and award those Pokémon Exp/EVs
|
||||
expAll = (hasConst?(PBItems,:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
|
||||
expAll = (GameData::Item.exists?(:EXPALL) && $PokemonBag.pbHasItem?(:EXPALL))
|
||||
p1 = pbParty(0)
|
||||
@battlers.each do |b|
|
||||
next unless b && b.opposes? # Can only gain Exp from fainted foes
|
||||
@@ -25,8 +25,7 @@ class PokeBattle_Battle
|
||||
if !expAll
|
||||
eachInTeam(0,0) do |pkmn,i|
|
||||
next if !pkmn.able?
|
||||
next if !pkmn.hasItem?(:EXPSHARE) &&
|
||||
!isConst?(@initialItems[0][i],PBItems,:EXPSHARE)
|
||||
next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
|
||||
expShare.push(i)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -323,8 +323,7 @@ class PokeBattle_Battle
|
||||
pbDisplay(_INTL("Oh!\nA Shadow Pokémon!"))
|
||||
end
|
||||
# Record money-doubling effect of Amulet Coin/Luck Incense
|
||||
if !battler.opposes? && (isConst?(battler.item,PBItems,:AMULETCOIN) ||
|
||||
isConst?(battler.item,PBItems,:LUCKINCENSE))
|
||||
if !battler.opposes? && [:AMULETCOIN, :LUCKINCENSE].include?(battler.item_id)
|
||||
@field.effects[PBEffects::AmuletCoin] = true
|
||||
end
|
||||
# Update battlers' participants (who will gain Exp/EVs when a battler faints)
|
||||
|
||||
@@ -20,7 +20,7 @@ class PokeBattle_Battle
|
||||
# below is one half of making this happen; the other half is in the
|
||||
# ItemHandlers::CanUseInBattle for Poké Balls.
|
||||
def pbItemUsesAllActions?(item)
|
||||
return true if pbIsPokeBall?(item)
|
||||
return true if GameData::Item.get(item).is_poke_ball?
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -40,9 +40,9 @@ class PokeBattle_Battle
|
||||
# Using an item
|
||||
#=============================================================================
|
||||
def pbConsumeItemInBag(item,idxBattler)
|
||||
return if item==0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
return if !item
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
if !$PokemonBag.pbDeleteItem(item)
|
||||
raise _INTL("Tried to consume item that wasn't in the Bag somehow.")
|
||||
@@ -59,9 +59,9 @@ class PokeBattle_Battle
|
||||
end
|
||||
|
||||
def pbReturnUnusedItemToBag(item,idxBattler)
|
||||
return if item==0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
return if item!
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
if $PokemonBag && $PokemonBag.pbCanStore?(item)
|
||||
$PokemonBag.pbStoreItem(item)
|
||||
@@ -75,7 +75,7 @@ class PokeBattle_Battle
|
||||
end
|
||||
|
||||
def pbUseItemMessage(item,trainerName)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName))
|
||||
else
|
||||
@@ -92,7 +92,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it had no effect!"))
|
||||
@@ -109,7 +109,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it's not where this item can be used!"))
|
||||
@@ -122,7 +122,7 @@ class PokeBattle_Battle
|
||||
idxBattler = userBattler.index if idxBattler<0
|
||||
battler = @battlers[idxBattler]
|
||||
ItemHandlers.triggerUseInBattle(item,battler,self)
|
||||
@choices[userBattler.index][1] = 0 # Delete item from choice
|
||||
@choices[userBattler.index][1] = nil # Delete item from choice
|
||||
end
|
||||
|
||||
# Uses an item in battle directly.
|
||||
@@ -134,7 +134,7 @@ class PokeBattle_Battle
|
||||
ch = @choices[userBattler.index]
|
||||
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
|
||||
ItemHandlers.triggerUseInBattle(item,battler,self)
|
||||
ch[1] = 0 # Delete item from choice
|
||||
ch[1] = nil # Delete item from choice
|
||||
return
|
||||
end
|
||||
pbDisplay(_INTL("But it had no effect!"))
|
||||
|
||||
@@ -62,17 +62,14 @@ class PokeBattle_Battle
|
||||
#=============================================================================
|
||||
def pbHasMegaRing?(idxBattler)
|
||||
return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring
|
||||
MEGA_RINGS.each do |item|
|
||||
return true if hasConst?(PBItems,item) && $PokemonBag.pbHasItem?(item)
|
||||
end
|
||||
MEGA_RINGS.each { |item| return true if $PokemonBag.pbHasItem?(item) }
|
||||
return false
|
||||
end
|
||||
|
||||
def pbGetMegaRingName(idxBattler)
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
MEGA_RINGS.each do |i|
|
||||
next if !hasConst?(PBItems,i)
|
||||
return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbHasItem?(i)
|
||||
MEGA_RINGS.each do |item|
|
||||
return GameData::Item.get(item).name if $PokemonBag.pbHasItem?(item)
|
||||
end
|
||||
end
|
||||
# NOTE: Add your own Mega objects for particular NPC trainers here.
|
||||
|
||||
@@ -12,9 +12,9 @@ class PokeBattle_Battle
|
||||
|
||||
def pbCancelChoice(idxBattler)
|
||||
# If idxBattler's choice was to use an item, return that item to the Bag
|
||||
if @choices[idxBattler][0]==:UseItem
|
||||
if @choices[idxBattler][0] == :UseItem
|
||||
item = @choices[idxBattler][1]
|
||||
pbReturnUnusedItemToBag(item,idxBattler) if item && item>0
|
||||
pbReturnUnusedItemToBag(item, idxBattler) if item
|
||||
end
|
||||
# If idxBattler chose to Mega Evolve, cancel it
|
||||
pbUnregisterMegaEvolution(idxBattler)
|
||||
@@ -104,7 +104,7 @@ class PokeBattle_Battle
|
||||
end
|
||||
ret = false
|
||||
@scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene|
|
||||
next false if item<0
|
||||
next false if !item
|
||||
battler = pkmn = nil
|
||||
case useType
|
||||
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move
|
||||
|
||||
@@ -66,23 +66,23 @@ class PokeBattle_Battle
|
||||
|
||||
def pbAttackPhaseItems
|
||||
pbPriority.each do |b|
|
||||
next unless @choices[b.index][0]==:UseItem && !b.fainted?
|
||||
next unless @choices[b.index][0] == :UseItem && !b.fainted?
|
||||
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
|
||||
item = @choices[b.index][1]
|
||||
next if !item || item<=0
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
next if !useType
|
||||
case useType
|
||||
next if !item
|
||||
case GameData::Item.get(item).battle_use
|
||||
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move
|
||||
pbUseItemOnPokemon(item,@choices[b.index][2],b) if @choices[b.index][2]>=0
|
||||
pbUseItemOnPokemon(item, @choices[b.index][2], b) if @choices[b.index][2] >= 0
|
||||
when 3, 8 # Use on battler
|
||||
pbUseItemOnBattler(item,@choices[b.index][2],b)
|
||||
pbUseItemOnBattler(item, @choices[b.index][2], b)
|
||||
when 4, 9 # Use Poké Ball
|
||||
pbUsePokeBallInBattle(item,@choices[b.index][2],b)
|
||||
pbUsePokeBallInBattle(item, @choices[b.index][2], b)
|
||||
when 5, 10 # Use directly
|
||||
pbUseItemInBattle(item,@choices[b.index][2],b)
|
||||
pbUseItemInBattle(item, @choices[b.index][2], b)
|
||||
else
|
||||
next
|
||||
end
|
||||
return if @decision>0
|
||||
return if @decision > 0
|
||||
end
|
||||
# pbCalculatePriority if NEWEST_BATTLE_MECHANICS
|
||||
end
|
||||
|
||||
@@ -5,24 +5,24 @@ class PokeBattle_AI
|
||||
def pbEnemyShouldUseItem?(idxBattler)
|
||||
user = @battle.battlers[idxBattler]
|
||||
item, idxTarget = pbEnemyItemToUse(idxBattler)
|
||||
return false if item==0
|
||||
return false if !item
|
||||
# Determine target of item (always the Pokémon choosing the action)
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
if useType && (useType==1 || useType==6) # Use on Pokémon
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
if useType==1 || useType==6 # Use on Pokémon
|
||||
idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon
|
||||
end
|
||||
# Register use of item
|
||||
@battle.pbRegisterItem(idxBattler,item,idxTarget)
|
||||
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{PBItems.getName(item)}")
|
||||
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{GameData::Item.get(item).name}")
|
||||
return true
|
||||
end
|
||||
|
||||
# NOTE: The AI will only consider using an item on the Pokémon it's currently
|
||||
# choosing an action for.
|
||||
def pbEnemyItemToUse(idxBattler)
|
||||
return 0 if !@battle.internalBattle
|
||||
return nil if !@battle.internalBattle
|
||||
items = @battle.pbGetOwnerItems(idxBattler)
|
||||
return 0 if !items || items.length==0
|
||||
return nil if !items || items.length==0
|
||||
# Determine target of item (always the Pokémon choosing the action)
|
||||
idxTarget = idxBattler # Battler using the item
|
||||
battler = @battle.battlers[idxTarget]
|
||||
@@ -49,106 +49,95 @@ class PokeBattle_AI
|
||||
:FULLRESTORE
|
||||
]
|
||||
oneStatusItems = [ # Preferred over items that heal all status problems
|
||||
:AWAKENING,:CHESTOBERRY,:BLUEFLUTE,
|
||||
:ANTIDOTE,:PECHABERRY,
|
||||
:BURNHEAL,:RAWSTBERRY,
|
||||
:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY,
|
||||
:ICEHEAL,:ASPEARBERRY
|
||||
:AWAKENING, :CHESTOBERRY, :BLUEFLUTE,
|
||||
:ANTIDOTE, :PECHABERRY,
|
||||
:BURNHEAL, :RAWSTBERRY,
|
||||
:PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY,
|
||||
:ICEHEAL, :ASPEARBERRY
|
||||
]
|
||||
allStatusItems = [
|
||||
:FULLHEAL,:LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE,
|
||||
:SHALOURSABLE,:BIGMALASADA,:LUMBERRY,:HEALPOWDER
|
||||
:FULLHEAL, :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE,
|
||||
:SHALOURSABLE, :BIGMALASADA, :LUMBERRY, :HEALPOWDER
|
||||
]
|
||||
allStatusItems.push(:RAGECANDYBAR) if NEWEST_BATTLE_MECHANICS
|
||||
xItems = {
|
||||
:XATTACK => [PBStats::ATTACK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XATTACK2 => [PBStats::ATTACK,2],
|
||||
:XATTACK3 => [PBStats::ATTACK,3],
|
||||
:XATTACK6 => [PBStats::ATTACK,6],
|
||||
:XDEFENSE => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFENSE2 => [PBStats::DEFENSE,2],
|
||||
:XDEFENSE3 => [PBStats::DEFENSE,3],
|
||||
:XDEFENSE6 => [PBStats::DEFENSE,6],
|
||||
:XDEFEND => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFEND2 => [PBStats::DEFENSE,2],
|
||||
:XDEFEND3 => [PBStats::DEFENSE,3],
|
||||
:XDEFEND6 => [PBStats::DEFENSE,6],
|
||||
:XSPATK => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPATK2 => [PBStats::SPATK,2],
|
||||
:XSPATK3 => [PBStats::SPATK,3],
|
||||
:XSPATK6 => [PBStats::SPATK,6],
|
||||
:XSPECIAL => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPECIAL2 => [PBStats::SPATK,2],
|
||||
:XSPECIAL3 => [PBStats::SPATK,3],
|
||||
:XSPECIAL6 => [PBStats::SPATK,6],
|
||||
:XSPDEF => [PBStats::SPDEF,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPDEF2 => [PBStats::SPDEF,2],
|
||||
:XSPDEF3 => [PBStats::SPDEF,3],
|
||||
:XSPDEF6 => [PBStats::SPDEF,6],
|
||||
:XSPEED => [PBStats::SPEED,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPEED2 => [PBStats::SPEED,2],
|
||||
:XSPEED3 => [PBStats::SPEED,3],
|
||||
:XSPEED6 => [PBStats::SPEED,6],
|
||||
:XACCURACY => [PBStats::ACCURACY,(NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XACCURACY2 => [PBStats::ACCURACY,2],
|
||||
:XACCURACY3 => [PBStats::ACCURACY,3],
|
||||
:XACCURACY6 => [PBStats::ACCURACY,6]
|
||||
:XATTACK => [PBStats::ATTACK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XATTACK2 => [PBStats::ATTACK, 2],
|
||||
:XATTACK3 => [PBStats::ATTACK, 3],
|
||||
:XATTACK6 => [PBStats::ATTACK, 6],
|
||||
:XDEFENSE => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFENSE2 => [PBStats::DEFENSE, 2],
|
||||
:XDEFENSE3 => [PBStats::DEFENSE, 3],
|
||||
:XDEFENSE6 => [PBStats::DEFENSE, 6],
|
||||
:XDEFEND => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XDEFEND2 => [PBStats::DEFENSE, 2],
|
||||
:XDEFEND3 => [PBStats::DEFENSE, 3],
|
||||
:XDEFEND6 => [PBStats::DEFENSE, 6],
|
||||
:XSPATK => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPATK2 => [PBStats::SPATK, 2],
|
||||
:XSPATK3 => [PBStats::SPATK, 3],
|
||||
:XSPATK6 => [PBStats::SPATK, 6],
|
||||
:XSPECIAL => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPECIAL2 => [PBStats::SPATK, 2],
|
||||
:XSPECIAL3 => [PBStats::SPATK, 3],
|
||||
:XSPECIAL6 => [PBStats::SPATK, 6],
|
||||
:XSPDEF => [PBStats::SPDEF, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPDEF2 => [PBStats::SPDEF, 2],
|
||||
:XSPDEF3 => [PBStats::SPDEF, 3],
|
||||
:XSPDEF6 => [PBStats::SPDEF, 6],
|
||||
:XSPEED => [PBStats::SPEED, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XSPEED2 => [PBStats::SPEED, 2],
|
||||
:XSPEED3 => [PBStats::SPEED, 3],
|
||||
:XSPEED6 => [PBStats::SPEED, 6],
|
||||
:XACCURACY => [PBStats::ACCURACY, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
|
||||
:XACCURACY2 => [PBStats::ACCURACY, 2],
|
||||
:XACCURACY3 => [PBStats::ACCURACY, 3],
|
||||
:XACCURACY6 => [PBStats::ACCURACY, 6]
|
||||
}
|
||||
losthp = battler.totalhp-battler.hp
|
||||
preferFullRestore = (battler.hp<=battler.totalhp*2/3 &&
|
||||
(battler.status!=PBStatuses::NONE || battler.effects[PBEffects::Confusion]>0))
|
||||
losthp = battler.totalhp - battler.hp
|
||||
preferFullRestore = (battler.hp <= battler.totalhp * 2 / 3 &&
|
||||
(battler.status != PBStatuses::NONE || battler.effects[PBEffects::Confusion] > 0))
|
||||
# Find all usable items
|
||||
usableHPItems = []
|
||||
usableStatusItems = []
|
||||
usableXItems = []
|
||||
items.each do |i|
|
||||
next if !i || i==0
|
||||
next if !i
|
||||
next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false)
|
||||
next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil,
|
||||
false,self,@battle.scene,false)
|
||||
checkedItem = false
|
||||
# Log HP healing items
|
||||
if losthp>0
|
||||
hpItems.each do |item, power|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableHPItems.push([i,5,power])
|
||||
if losthp > 0
|
||||
power = hpItems[i]
|
||||
if power
|
||||
usableHPItems.push([i, 5, power])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Log Full Restores (HP healer and status curer)
|
||||
if losthp>0 || battler.status!=PBStatuses::NONE
|
||||
fullRestoreItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableHPItems.push([i,(preferFullRestore) ? 3 : 7,999])
|
||||
usableStatusItems.push([i,(preferFullRestore) ? 3 : 9])
|
||||
if losthp > 0 || battler.status != PBStatuses::NONE
|
||||
if fullRestoreItems.include?(i)
|
||||
usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
|
||||
usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Log single status-curing items
|
||||
if battler.status!=PBStatuses::NONE
|
||||
oneStatusItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableStatusItems.push([i,5])
|
||||
end
|
||||
next if checkedItem
|
||||
# Log Full Heal-type items
|
||||
allStatusItems.each do |item|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableStatusItems.push([i,7])
|
||||
end
|
||||
next if checkedItem
|
||||
if oneStatusItems.include?(i)
|
||||
usableStatusItems.push([i, 5])
|
||||
next
|
||||
end
|
||||
# Log Full Heal-type items
|
||||
if allStatusItems.include?(i)
|
||||
usableStatusItems.push([i, 7])
|
||||
next
|
||||
end
|
||||
# Log stat-raising items
|
||||
xItems.each do |item, data|
|
||||
next if !isConst?(i,PBItems,item)
|
||||
checkedItem = true
|
||||
usableXItems.push([i,battler.stages[data[0]],data[1]])
|
||||
if xItems[i]
|
||||
data = xItems[i]
|
||||
usableXItems.push([i, battler.stages[data[0]], data[1]])
|
||||
next
|
||||
end
|
||||
next if checkedItem
|
||||
end
|
||||
# Prioritise using a HP restoration item
|
||||
if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 ||
|
||||
@@ -156,15 +145,15 @@ class PokeBattle_AI
|
||||
usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
|
||||
prevItem = nil
|
||||
usableHPItems.each do |i|
|
||||
return i[0],idxTarget if i[2]>=losthp
|
||||
return i[0], idxTarget if i[2]>=losthp
|
||||
prevItem = i
|
||||
end
|
||||
return prevItem[0],idxTarget
|
||||
return prevItem[0], idxTarget
|
||||
end
|
||||
# Next prioritise using a status-curing item
|
||||
if usableStatusItems.length>0 && pbAIRandom(100)<40
|
||||
usableStatusItems.sort! { |a,b| a[1]<=>b[1] }
|
||||
return usableStatusItems[0][0],idxTarget
|
||||
return usableStatusItems[0][0], idxTarget
|
||||
end
|
||||
# Next try using an X item
|
||||
if usableXItems.length>0 && pbAIRandom(100)<30
|
||||
@@ -172,11 +161,11 @@ class PokeBattle_AI
|
||||
prevItem = nil
|
||||
usableXItems.each do |i|
|
||||
break if prevItem && i[1]>prevItem[1]
|
||||
return i[0],idxTarget if i[1]+i[2]>=6
|
||||
return i[0], idxTarget if i[1]+i[2]>=6
|
||||
prevItem = i
|
||||
end
|
||||
return prevItem[0],idxTarget
|
||||
return prevItem[0], idxTarget
|
||||
end
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1632,7 +1632,7 @@ class PokeBattle_AI
|
||||
when "095"
|
||||
#---------------------------------------------------------------------------
|
||||
when "096"
|
||||
score -= 90 if !pbIsBerry?(user.item) || !user.itemActive?
|
||||
score -= 90 if !user.item || !user.item.is_berry? || !user.itemActive?
|
||||
#---------------------------------------------------------------------------
|
||||
when "097"
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2031,12 +2031,12 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F0"
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
score += 20 if target.item!=0
|
||||
score += 20 if target.item
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F1"
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
if user.item==0 && target.item!=0
|
||||
if !user.item && target.item
|
||||
score += 40
|
||||
else
|
||||
score -= 90
|
||||
@@ -2046,19 +2046,19 @@ class PokeBattle_AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F2"
|
||||
if user.item==0 && target.item==0
|
||||
if !user.item && !target.item
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD)
|
||||
score -= 90
|
||||
elsif user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
|
||||
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
|
||||
score += 50
|
||||
elsif user.item==0 && target.item!=0
|
||||
elsif !user.item && target.item
|
||||
score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F3"
|
||||
if user.item==0 || target.item!=0
|
||||
if !user.item || target.item
|
||||
score -= 90
|
||||
else
|
||||
if user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
|
||||
@@ -2071,21 +2071,21 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F4", "0F5"
|
||||
if target.effects[PBEffects::Substitute]==0
|
||||
if skill>=PBTrainerAI.highSkill && pbIsBerry?(target.item)
|
||||
if skill>=PBTrainerAI.highSkill && target.item && target.item.is_berry?
|
||||
score += 30
|
||||
end
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F6"
|
||||
if user.recycleItem==0 || user.item!=0
|
||||
if !user.recycleItem || user.item
|
||||
score -= 80
|
||||
elsif user.recycleItem!=0
|
||||
elsif user.recycleItem
|
||||
score += 30
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0F7"
|
||||
if user.item==0 || !user.itemActive? ||
|
||||
user.unlosableItem?(user.item) || pbIsPokeBall?(user.item)
|
||||
if !user.item || !user.itemActive? ||
|
||||
user.unlosableItem?(user.item) || user.item.is_poke_ball?
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2096,7 +2096,7 @@ class PokeBattle_AI
|
||||
if @battle.field.effects[PBEffects::MagicRoom]>0
|
||||
score -= 90
|
||||
else
|
||||
score += 30 if user.item==0 && target.item!=0
|
||||
score += 30 if !user.item && target.item
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "0FA"
|
||||
|
||||
@@ -186,7 +186,7 @@ class PokeBattle_AI
|
||||
"098", "099", "09A", "0F7", "113"
|
||||
baseDmg = move.pbBaseDamage(baseDmg,user,target)
|
||||
when "086" # Acrobatics
|
||||
baseDmg *= 2 if user.item==0 || user.hasActiveItem?(:FLYINGGEM)
|
||||
baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM)
|
||||
when "08D" # Gyro Ball
|
||||
targetSpeed = pbRoughStat(target,PBStats::SPEED,skill)
|
||||
userSpeed = pbRoughStat(user,PBStats::SPEED,skill)
|
||||
@@ -197,7 +197,7 @@ class PokeBattle_AI
|
||||
baseDmg = 71
|
||||
baseDmg *= 2 if target.inTwoTurnAttack?("0CA") # Dig
|
||||
when "096" # Natural Gift
|
||||
baseDmg = move.pbNaturalGiftBaseDamage(user.item)
|
||||
baseDmg = move.pbNaturalGiftBaseDamage(user.item_id)
|
||||
when "09B" # Heavy Slam
|
||||
baseDmg = move.pbBaseDamage(baseDmg,user,target)
|
||||
baseDmg *= 2 if NEWEST_BATTLE_MECHANICS && skill>=PBTrainerAI.mediumSkill &&
|
||||
@@ -332,13 +332,7 @@ class PokeBattle_AI
|
||||
# NOTE: These items aren't suitable for checking at the start of the
|
||||
# round.
|
||||
itemBlacklist = [:EXPERTBELT,:LIFEORB]
|
||||
canCheck = true
|
||||
itemBlacklist.each do |i|
|
||||
next if !isConst?(user.item,PBItems,i)
|
||||
canCheck = false
|
||||
break
|
||||
end
|
||||
if canCheck
|
||||
if !itemBlacklist.include?(user.item_id)
|
||||
BattleHandlers.triggerDamageCalcUserItem(user.item,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
end
|
||||
@@ -346,7 +340,7 @@ class PokeBattle_AI
|
||||
if skill>=PBTrainerAI.bestSkill && target.itemActive?
|
||||
# NOTE: Type-weakening berries aren't suitable for checking at the start
|
||||
# of the round.
|
||||
if !pbIsBerry?(target.item)
|
||||
if !target.item.is_berry?
|
||||
BattleHandlers.triggerDamageCalcTargetItem(target.item,
|
||||
user,target,move,multipliers,baseDmg,type)
|
||||
end
|
||||
|
||||
@@ -200,7 +200,7 @@ class PokeBattle_Scene
|
||||
# Start Bag screen
|
||||
itemScene = PokemonBag_Scene.new
|
||||
itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
useType = GameData::Item.get(item).battle_use
|
||||
next useType && useType>0
|
||||
},false)
|
||||
# Loop while in Bag screen
|
||||
@@ -208,10 +208,11 @@ class PokeBattle_Scene
|
||||
loop do
|
||||
# Select an item
|
||||
item = itemScene.pbChooseItem
|
||||
break if item==0
|
||||
break if !item
|
||||
# Choose a command for the selected item
|
||||
itemName = PBItems.getName(item)
|
||||
useType = pbGetItemData(item,ItemData::BATTLE_USE)
|
||||
item = GameData::Item.get(item)
|
||||
itemName = item.name
|
||||
useType = item.battle_use
|
||||
cmdUse = -1
|
||||
commands = []
|
||||
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
|
||||
@@ -237,11 +238,11 @@ class PokeBattle_Scene
|
||||
case useType
|
||||
when 1, 6 # Use on Pokémon
|
||||
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1
|
||||
break if yield item, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
end
|
||||
when 3, 8 # Use on battler
|
||||
if @battle.pbPlayerBattlerCount==1
|
||||
break if yield item, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
|
||||
end
|
||||
end
|
||||
# Fade out and hide Bag screen
|
||||
@@ -276,7 +277,7 @@ class PokeBattle_Scene
|
||||
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
|
||||
next if idxMove<0
|
||||
end
|
||||
break if yield item, useType, idxPartyRet, idxMove, pkmnScene
|
||||
break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
|
||||
end
|
||||
pkmnScene.pbEndScene
|
||||
break if idxParty>=0
|
||||
@@ -286,7 +287,7 @@ class PokeBattle_Scene
|
||||
idxTarget = -1
|
||||
if @battle.pbOpposingBattlerCount(idxBattler)==1
|
||||
@battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index }
|
||||
break if yield item, useType, idxTarget, -1, itemScene
|
||||
break if yield item.id, useType, idxTarget, -1, itemScene
|
||||
else
|
||||
wasTargeting = true
|
||||
# Fade out and hide Bag screen
|
||||
@@ -297,7 +298,7 @@ class PokeBattle_Scene
|
||||
tempVisibleSprites["targetWindow"] = true
|
||||
idxTarget = pbChooseTarget(idxBattler,PBTargets::Foe,tempVisibleSprites)
|
||||
if idxTarget>=0
|
||||
break if yield item, useType, idxTarget, -1, self
|
||||
break if yield item.id, useType, idxTarget, -1, self
|
||||
end
|
||||
# Target invalid/cancelled choosing a target; show the Bag screen again
|
||||
wasTargeting = false
|
||||
@@ -305,7 +306,7 @@ class PokeBattle_Scene
|
||||
itemScene.pbFadeInScene
|
||||
end
|
||||
when 5, 10 # Use with no target
|
||||
break if yield item, useType, idxBattler, -1, itemScene
|
||||
break if yield item.id, useType, idxBattler, -1, itemScene
|
||||
end
|
||||
end
|
||||
@bagLastPocket = $PokemonBag.lastpocket
|
||||
|
||||
@@ -492,7 +492,7 @@ FINAL_DMG_MULT = 3
|
||||
def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
|
||||
return false if !forced && !battler.canHeal?
|
||||
return false if !forced && !battler.pbCanConsumeBerry?(item,false)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8)
|
||||
if amt>0
|
||||
@@ -515,7 +515,7 @@ end
|
||||
def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1)
|
||||
return false if !forced && !battler.pbCanConsumeBerry?(item)
|
||||
return false if !battler.pbCanRaiseStatStage?(stat,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
return battler.pbRaiseStatStage(stat,increment,battler)
|
||||
@@ -576,7 +576,7 @@ def pbBattleGem(user,type,move,mults,moveType)
|
||||
# Pledge moves never consume Gems
|
||||
return if move.is_a?(PokeBattle_PledgeMove)
|
||||
return if !isConst?(moveType,PBTypes,type)
|
||||
user.effects[PBEffects::GemConsumed] = user.item
|
||||
user.effects[PBEffects::GemConsumed] = user.item_id
|
||||
if NEWEST_BATTLE_MECHANICS
|
||||
mults[BASE_DMG_MULT] *= 1.3
|
||||
else
|
||||
|
||||
@@ -427,7 +427,7 @@ class PokeBattle_SafariZone
|
||||
pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
|
||||
@scene.pbSafariStart
|
||||
@scene.pbCommonAnimation(PBWeather.animationName(@weather))
|
||||
safariBall = getConst(PBItems,:SAFARIBALL)
|
||||
safariBall = GameData::Item.get(:SAFARIBALL).id
|
||||
rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesData::RARENESS)
|
||||
catchFactor = (rareness*100)/1275
|
||||
catchFactor = [[catchFactor,3].max,20].min
|
||||
|
||||
@@ -36,7 +36,7 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle
|
||||
|
||||
def initialize(*arg)
|
||||
@ballCount = 0
|
||||
@ballConst = getConst(PBItems,:SPORTBALL) || -1
|
||||
@ballConst = GameData::Item.get(:SPORTBALL).id
|
||||
super(*arg)
|
||||
end
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ BattleHandlers::SpeedCalcAbility.add(:SWIFTSWIM,
|
||||
|
||||
BattleHandlers::SpeedCalcAbility.add(:UNBURDEN,
|
||||
proc { |ability,battler,mult|
|
||||
next mult*2 if battler.effects[PBEffects::Unburden] && battler.item==0
|
||||
next mult*2 if battler.effects[PBEffects::Unburden] && !battler.item
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1673,11 +1673,11 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
|
||||
proc { |ability,user,targets,move,battle|
|
||||
next if !battle.futureSight
|
||||
next if !move.pbDamagingMove?
|
||||
next if user.item>0
|
||||
next if user.item
|
||||
next if battle.wildBattle? && user.opposes?
|
||||
targets.each do |b|
|
||||
next if b.damageState.unaffected || b.damageState.substitute
|
||||
next if b.item==0
|
||||
next if !b.item
|
||||
next if b.unlosableItem?(b.item) || user.unlosableItem?(b.item)
|
||||
battle.pbShowAbilitySplash(user)
|
||||
if b.hasActiveAbility?(:STICKYHOLD)
|
||||
@@ -1689,11 +1689,11 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
|
||||
next
|
||||
end
|
||||
user.item = b.item
|
||||
b.item = 0
|
||||
b.item = nil
|
||||
b.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && user.initialItem==0 && b.initialItem==user.item
|
||||
if battle.wildBattle? && !user.initialItem && b.initialItem==user.item
|
||||
user.setInitialItem(user.item)
|
||||
b.setInitialItem(0)
|
||||
b.setInitialItem(nil)
|
||||
end
|
||||
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,
|
||||
@@ -1755,7 +1755,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
|
||||
next if !move.contactMove?
|
||||
next if switched.include?(user.index)
|
||||
next if user.effects[PBEffects::Substitute]>0 || target.damageState.substitute
|
||||
next if target.item>0 || user.item==0
|
||||
next if target.item || !user.item
|
||||
next if user.unlosableItem?(user.item) || target.unlosableItem?(user.item)
|
||||
battle.pbShowAbilitySplash(target)
|
||||
if user.hasActiveAbility?(:STICKYHOLD)
|
||||
@@ -1768,11 +1768,11 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
|
||||
next
|
||||
end
|
||||
target.item = user.item
|
||||
user.item = 0
|
||||
user.item = nil
|
||||
user.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && target.initialItem==0 && user.initialItem==target.item
|
||||
if battle.wildBattle? && !target.initialItem && user.initialItem==target.item
|
||||
target.setInitialItem(target.item)
|
||||
user.setInitialItem(0)
|
||||
user.setInitialItem(nil)
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!",target.pbThis,
|
||||
user.pbThis(true),target.itemName))
|
||||
@@ -1998,16 +1998,16 @@ BattleHandlers::EOREffectAbility.add(:SPEEDBOOST,
|
||||
|
||||
BattleHandlers::EORGainItemAbility.add(:HARVEST,
|
||||
proc { |ability,battler,battle|
|
||||
next if battler.item>0
|
||||
next if battler.recycleItem<=0 || !pbIsBerry?(battler.recycleItem)
|
||||
next if battler.item
|
||||
next if !battler.recycleItem || !GameData::Item.get(battler.recycleItem).is_berry?
|
||||
curWeather = battle.pbWeather
|
||||
if curWeather!=PBWeather::Sun && curWeather!=PBWeather::HarshSun
|
||||
next unless battle.pbRandom(100)<50
|
||||
end
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
battler.item = battler.recycleItem
|
||||
battler.setRecycleItem(0)
|
||||
battler.setInitialItem(battler.item) if battler.initialItem==0
|
||||
battler.setRecycleItem(nil)
|
||||
battler.setInitialItem(battler.item) if !battler.initialItem
|
||||
battle.pbDisplay(_INTL("{1} harvested one {2}!",battler.pbThis,battler.itemName))
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
battler.pbHeldItemTriggerCheck
|
||||
@@ -2016,8 +2016,8 @@ BattleHandlers::EORGainItemAbility.add(:HARVEST,
|
||||
|
||||
BattleHandlers::EORGainItemAbility.add(:PICKUP,
|
||||
proc { |ability,battler,battle|
|
||||
next if battler.item>0
|
||||
foundItem = 0; fromBattler = nil; use = 0
|
||||
next if battler.item
|
||||
foundItem = nil; fromBattler = nil; use = 0
|
||||
battle.eachBattler do |b|
|
||||
next if b.index==battler.index
|
||||
next if b.effects[PBEffects::PickupUse]<=use
|
||||
@@ -2025,15 +2025,15 @@ BattleHandlers::EORGainItemAbility.add(:PICKUP,
|
||||
fromBattler = b
|
||||
use = b.effects[PBEffects::PickupUse]
|
||||
end
|
||||
next if foundItem<=0
|
||||
next if !foundItem
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
battler.item = foundItem
|
||||
fromBattler.effects[PBEffects::PickupItem] = 0
|
||||
fromBattler.effects[PBEffects::PickupItem] = nil
|
||||
fromBattler.effects[PBEffects::PickupUse] = 0
|
||||
fromBattler.setRecycleItem(0) if fromBattler.recycleItem==foundItem
|
||||
if battle.wildBattle? && battler.initialItem==0 && fromBattler.initialItem==foundItem
|
||||
fromBattler.setRecycleItem(nil) if fromBattler.recycleItem==foundItem
|
||||
if battle.wildBattle? && !battler.initialItem && fromBattler.initialItem==foundItem
|
||||
battler.setInitialItem(foundItem)
|
||||
fromBattler.setInitialItem(0)
|
||||
fromBattler.setInitialItem(nil)
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1} found one {2}!",battler.pbThis,battler.itemName))
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
@@ -2244,19 +2244,19 @@ BattleHandlers::AbilityOnSwitchIn.add(:FRISK,
|
||||
next if !battler.pbOwnedByPlayer?
|
||||
foes = []
|
||||
battle.eachOtherSideBattler(battler.index) do |b|
|
||||
foes.push(b) if b.item>0
|
||||
foes.push(b) if b.item
|
||||
end
|
||||
if foes.length>0
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
if NEWEST_BATTLE_MECHANICS
|
||||
foes.each do |b|
|
||||
battle.pbDisplay(_INTL("{1} frisked {2} and found its {3}!",
|
||||
battler.pbThis,b.pbThis(true),PBItems.getName(b.item)))
|
||||
battler.pbThis,b.pbThis(true),b.itemName))
|
||||
end
|
||||
else
|
||||
foe = foes[battle.pbRandom(foes.length)]
|
||||
battle.pbDisplay(_INTL("{1} frisked the foe and found one {2}!",
|
||||
battler.pbThis,PBItems.getName(foe.item)))
|
||||
battler.pbThis,foe.itemName))
|
||||
end
|
||||
battle.pbHideAbilitySplash(battler)
|
||||
end
|
||||
|
||||
@@ -48,7 +48,7 @@ BattleHandlers::WeightCalcItem.add(:FLOATSTONE,
|
||||
BattleHandlers::HPHealItem.add(:AGUAVBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,4,
|
||||
_INTL("For {1}, the {2} was too bitter!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too bitter!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ BattleHandlers::HPHealItem.add(:BERRYJUICE,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !battler.canHeal?
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") if forced
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
battler.pbRecoverHP(20)
|
||||
@@ -78,7 +78,7 @@ BattleHandlers::HPHealItem.add(:BERRYJUICE,
|
||||
BattleHandlers::HPHealItem.add(:FIGYBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,0,
|
||||
_INTL("For {1}, the {2} was too spicy!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too spicy!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -91,7 +91,7 @@ BattleHandlers::HPHealItem.add(:GANLONBERRY,
|
||||
BattleHandlers::HPHealItem.add(:IAPAPABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,1,
|
||||
_INTL("For {1}, the {2} was too sour!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too sour!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ BattleHandlers::HPHealItem.add(:LANSATBERRY,
|
||||
next false if battler.effects[PBEffects::FocusEnergy]>=2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.effects[PBEffects::FocusEnergy] = 2
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName))
|
||||
else
|
||||
@@ -120,7 +120,7 @@ BattleHandlers::HPHealItem.add(:LIECHIBERRY,
|
||||
BattleHandlers::HPHealItem.add(:MAGOBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,2,
|
||||
_INTL("For {1}, the {2} was too sweet!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too sweet!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -130,7 +130,7 @@ BattleHandlers::HPHealItem.add(:MICLEBERRY,
|
||||
next false if !battler.effects[PBEffects::MicleBerry]
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.effects[PBEffects::MicleBerry] = true
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis))
|
||||
@@ -149,7 +149,7 @@ BattleHandlers::HPHealItem.add(:ORANBERRY,
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(10)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
|
||||
@@ -179,7 +179,7 @@ BattleHandlers::HPHealItem.add(:SITRUSBERRY,
|
||||
next false if !forced && battler.hp>battler.totalhp/2
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(battler.totalhp/4)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
|
||||
@@ -203,7 +203,7 @@ BattleHandlers::HPHealItem.add(:STARFBERRY,
|
||||
BattleHandlers::HPHealItem.add(:WIKIBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next pbBattleConfusionBerry(battler,battle,item,forced,3,
|
||||
_INTL("For {1}, the {2} was too dry!",battler.pbThis(true),PBItems.getName(item)))
|
||||
_INTL("For {1}, the {2} was too dry!",battler.pbThis(true),GameData::Item.get(item).name))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -215,7 +215,7 @@ BattleHandlers::StatusCureItem.add(:ASPEARBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::FROZEN
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -228,7 +228,7 @@ BattleHandlers::StatusCureItem.add(:CHERIBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::PARALYSIS
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -241,7 +241,7 @@ BattleHandlers::StatusCureItem.add(:CHESTOBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::SLEEP
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -255,7 +255,7 @@ BattleHandlers::StatusCureItem.add(:LUMBERRY,
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status==PBStatuses::NONE &&
|
||||
battler.effects[PBEffects::Confusion]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
oldStatus = battler.status
|
||||
@@ -293,7 +293,7 @@ BattleHandlers::StatusCureItem.add(:MENTALHERB,
|
||||
!battler.effects[PBEffects::Torment] &&
|
||||
battler.effects[PBEffects::Disable]==0 &&
|
||||
battler.effects[PBEffects::HealBlock]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}")
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
if battler.effects[PBEffects::Attract]>=0
|
||||
@@ -324,7 +324,7 @@ BattleHandlers::StatusCureItem.add(:PECHABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::POISON
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -337,7 +337,7 @@ BattleHandlers::StatusCureItem.add(:PERSIMBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.effects[PBEffects::Confusion]==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureConfusion
|
||||
@@ -355,7 +355,7 @@ BattleHandlers::StatusCureItem.add(:RAWSTBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if battler.status!=PBStatuses::BURN
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbCureStatus(forced)
|
||||
@@ -1124,14 +1124,14 @@ BattleHandlers::TargetItemOnHit.add(:SNOWBALL,
|
||||
BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
|
||||
proc { |item,user,target,move,battle|
|
||||
next if !move.pbContactMove?(user) || !user.affectedByContactEffect?
|
||||
next if user.fainted? || user.item>0
|
||||
next if user.fainted? || user.item
|
||||
user.item = target.item
|
||||
target.item = 0
|
||||
target.item = nil
|
||||
target.effects[PBEffects::Unburden] = true
|
||||
if battle.wildBattle? && !user.opposes?
|
||||
if user.initialItem==0 && target.initialItem==user.item
|
||||
if !user.initialItem && target.initialItem==user.item
|
||||
user.setInitialItem(user.item)
|
||||
target.setInitialItem(0)
|
||||
target.setInitialItem(nil)
|
||||
end
|
||||
end
|
||||
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
|
||||
@@ -1168,7 +1168,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:ENIGMABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !battler.canHeal?
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
battler.pbRecoverHP(battler.totalhp/4)
|
||||
@@ -1186,7 +1186,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:KEEBERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if !forced
|
||||
battle.pbCommonAnimation("EatBerry",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
@@ -1200,7 +1200,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:MARANGABERRY,
|
||||
proc { |item,battler,battle,forced|
|
||||
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
if !forced
|
||||
battle.pbCommonAnimation("EatBerry",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
@@ -1294,7 +1294,7 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY,
|
||||
found.push(i)
|
||||
end
|
||||
next false if found.length==0
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("EatBerry",battler) if !forced
|
||||
choice = found[battle.pbRandom(found.length)]
|
||||
@@ -1325,7 +1325,7 @@ BattleHandlers::EndOfMoveStatRestoreItem.add(:WHITEHERB,
|
||||
reducedStats = true
|
||||
end
|
||||
next false if !reducedStats
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
|
||||
battle.pbCommonAnimation("UseItem",battler) if !forced
|
||||
if forced
|
||||
@@ -1440,7 +1440,7 @@ BattleHandlers::TerrainStatBoostItem.add(:ELECTRICSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Electric
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ BattleHandlers::TerrainStatBoostItem.add(:GRASSYSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Grassy
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
|
||||
}
|
||||
@@ -1460,7 +1460,7 @@ BattleHandlers::TerrainStatBoostItem.add(:MISTYSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Misty
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
}
|
||||
@@ -1470,7 +1470,7 @@ BattleHandlers::TerrainStatBoostItem.add(:PSYCHICSEED,
|
||||
proc { |item,battler,battle|
|
||||
next false if battle.field.terrain!=PBBattleTerrains::Psychic
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
|
||||
}
|
||||
@@ -1577,7 +1577,7 @@ BattleHandlers::ItemOnSwitchIn.add(:AIRBALLOON,
|
||||
BattleHandlers::ItemOnIntimidated.add(:ADRENALINEORB,
|
||||
proc { |item,battler,battle|
|
||||
next false if !battler.pbCanRaiseStatStage?(PBStats::SPEED,battler)
|
||||
itemName = PBItems.getName(item)
|
||||
itemName = GameData::Item.get(item).name
|
||||
battle.pbCommonAnimation("UseItem",battler)
|
||||
next battler.pbRaiseStatStageByCause(PBStats::SPEED,1,battler,itemName)
|
||||
}
|
||||
|
||||
@@ -27,22 +27,18 @@ $BallTypes = {
|
||||
25 => :BEASTBALL
|
||||
}
|
||||
|
||||
def pbBallTypeToItem(balltype)
|
||||
if $BallTypes[balltype]
|
||||
ret = getID(PBItems,$BallTypes[balltype])
|
||||
return ret if ret!=0
|
||||
end
|
||||
if $BallTypes[0]
|
||||
ret = getID(PBItems,$BallTypes[0])
|
||||
return ret if ret!=0
|
||||
end
|
||||
return getID(PBItems,:POKEBALL)
|
||||
def pbBallTypeToItem(ball_type)
|
||||
ret = GameData::Item.try_get($BallTypes[ball_type])
|
||||
return ret if ret
|
||||
ret = GameData::Item.try_get($BallTypes[0])
|
||||
return ret if ret
|
||||
return GameData::Item.get(:POKEBALL)
|
||||
end
|
||||
|
||||
def pbGetBallType(ball)
|
||||
ball = getID(PBItems,ball)
|
||||
ball = GameData::Item.try_get(ball)
|
||||
$BallTypes.keys.each do |key|
|
||||
return key if isConst?(ball,PBItems,$BallTypes[key])
|
||||
return key if ball == $BallTypes[key]
|
||||
end
|
||||
return 0
|
||||
end
|
||||
@@ -206,8 +202,8 @@ BallHandlers::ModifyCatchRate.add(:MOONBALL,proc { |ball,catchRate,battle,battle
|
||||
# NOTE: Moon Ball cares about whether any species in the target's evolutionary
|
||||
# family can evolve with the Moon Stone, not whether the target itself
|
||||
# can immediately evolve with the Moon Stone.
|
||||
if hasConst?(PBItems,:MOONSTONE) &&
|
||||
pbCheckEvolutionFamilyForItemMethodItem(battler.species,getConst(PBItems,:MOONSTONE))
|
||||
moon_stone = GameData::Item.try_get(:MOONSTONE)
|
||||
if moon_stone && pbCheckEvolutionFamilyForItemMethodItem(battler.species, moon_stone.id)
|
||||
catchRate *= 4
|
||||
end
|
||||
next [catchRate,255].min
|
||||
|
||||
@@ -325,7 +325,7 @@ Events.onStepTakenFieldMovement += proc { |_sender,e|
|
||||
break
|
||||
end
|
||||
end
|
||||
if sootlevel>=0 && hasConst?(PBItems,:SOOTSACK)
|
||||
if sootlevel>=0 && GameData::Item.exists?(:SOOTSACK)
|
||||
$PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack
|
||||
# map.data[thistile[1],thistile[2],sootlevel]=0
|
||||
if event==$game_player && $PokemonBag.pbHasItem?(:SOOTSACK)
|
||||
@@ -1322,16 +1322,17 @@ end
|
||||
# Picking up an item found on the ground
|
||||
#===============================================================================
|
||||
def pbItemBall(item,quantity=1)
|
||||
item = getID(PBItems,item)
|
||||
return false if !item || item<=0 || quantity<1
|
||||
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
|
||||
pocket = pbGetPocket(item)
|
||||
item = GameData::Item.get(item)
|
||||
return false if !item || quantity<1
|
||||
itemname = (quantity>1) ? item.name_plural : item.name
|
||||
pocket = item.pocket
|
||||
move = item.move
|
||||
if $PokemonBag.pbStoreItem(item,quantity) # If item can be picked up
|
||||
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
|
||||
if isConst?(item,PBItems,:LEFTOVERS)
|
||||
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
||||
if item == :LEFTOVERS
|
||||
pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
|
||||
elsif pbIsMachine?(item) # TM or HM
|
||||
pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(pbGetMachine(item))))
|
||||
elsif item.is_machine? # TM or HM
|
||||
pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move)))
|
||||
elsif quantity>1
|
||||
pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
|
||||
elsif itemname.starts_with_vowel?
|
||||
@@ -1344,10 +1345,10 @@ def pbItemBall(item,quantity=1)
|
||||
return true
|
||||
end
|
||||
# Can't add the item
|
||||
if isConst?(item,PBItems,:LEFTOVERS)
|
||||
if item == :LEFTOVERS
|
||||
pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
|
||||
elsif pbIsMachine?(item) # TM or HM
|
||||
pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
|
||||
elsif item.is_machine? # TM or HM
|
||||
pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(move)))
|
||||
elsif quantity>1
|
||||
pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
|
||||
elsif itemname.starts_with_vowel?
|
||||
@@ -1365,15 +1366,16 @@ end
|
||||
# Being given an item
|
||||
#===============================================================================
|
||||
def pbReceiveItem(item,quantity=1)
|
||||
item = getID(PBItems,item)
|
||||
return false if !item || item<=0 || quantity<1
|
||||
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
|
||||
pocket = pbGetPocket(item)
|
||||
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get"
|
||||
if isConst?(item,PBItems,:LEFTOVERS)
|
||||
item = GameData::Item.get(item)
|
||||
return false if !item || quantity<1
|
||||
itemname = (quantity>1) ? item.name_plural : item.name
|
||||
pocket = item.pocket
|
||||
move = item.move
|
||||
meName = (item.is_key_item?) ? "Key item get" : "Item get"
|
||||
if item == :LEFTOVERS
|
||||
pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
|
||||
elsif pbIsMachine?(item) # TM or HM
|
||||
pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(pbGetMachine(item))))
|
||||
elsif item.is_machine? # TM or HM
|
||||
pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move)))
|
||||
elsif quantity>1
|
||||
pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
|
||||
elsif itemname.starts_with_vowel?
|
||||
|
||||
@@ -596,8 +596,7 @@ end
|
||||
def pbDynamicItemList(*args)
|
||||
ret = []
|
||||
for i in 0...args.length
|
||||
next if !hasConst?(PBItems,args[i])
|
||||
ret.push(getConst(PBItems,args[i].to_sym))
|
||||
ret.push(i) if GameData::Item.exists?(args[i])
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -674,7 +673,7 @@ end
|
||||
def pbHoneyGather(pkmn)
|
||||
return if pkmn.egg? || !pkmn.hasAbility?(:HONEYGATHER)
|
||||
return if pkmn.hasItem?
|
||||
return if !hasConst?(PBItems,:HONEY)
|
||||
return if !GameData::Item.exists?(:HONEY)
|
||||
chance = 5+((pkmn.level-1)/10)*5
|
||||
return unless rand(100)<chance
|
||||
pkmn.setItem(:HONEY)
|
||||
|
||||
@@ -338,9 +338,10 @@ class PokemonEncounters
|
||||
end
|
||||
firstPkmn = $Trainer.firstPokemon
|
||||
if firstPkmn
|
||||
if firstPkmn.hasItem?(:CLEANSETAG)
|
||||
case firstPkmn.item_id
|
||||
when :CLEANSETAG
|
||||
encount *= 2.0 / 3
|
||||
elsif firstPkmn.hasItem?(:PUREINCENSE)
|
||||
when :PUREINCENSE
|
||||
encount *= 2.0 / 3
|
||||
else # Ignore ability effects if an item effect applies
|
||||
case firstPkmn.ability_id
|
||||
@@ -411,7 +412,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
|
||||
genwildpoke.setItem(items[2])
|
||||
end
|
||||
# Shiny Charm makes shiny Pokémon more likely to generate
|
||||
if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
|
||||
if GameData::Item.exists?(:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
|
||||
2.times do # 3 times as likely
|
||||
break if genwildpoke.shiny?
|
||||
genwildpoke.personalID = rand(65536)|(rand(65536)<<16)
|
||||
|
||||
@@ -10,7 +10,7 @@ def pbLoadBerryPlantData
|
||||
if pbRgssExists?("Data/berry_plants.dat")
|
||||
$PokemonTemp.berryPlantData = load_data("Data/berry_plants.dat")
|
||||
else
|
||||
$PokemonTemp.berryPlantData = []
|
||||
$PokemonTemp.berryPlantData = {}
|
||||
end
|
||||
end
|
||||
return $PokemonTemp.berryPlantData
|
||||
@@ -19,7 +19,7 @@ end
|
||||
def pbGetBerryPlantData(item)
|
||||
data = pbLoadBerryPlantData
|
||||
return data[item] if data[item]
|
||||
return [3,15,2,5] # Hours/stage, drying/hour, min yield, max yield
|
||||
return [3, 15, 2, 5] # Hours/stage, drying/hour, min yield, max yield
|
||||
end
|
||||
|
||||
alias __berryPlant__pbClearData pbClearData
|
||||
@@ -77,7 +77,7 @@ class BerryPlantMoistureSprite
|
||||
def update
|
||||
return if !@light || !@event
|
||||
newmoisture=-1
|
||||
if @event.variable && @event.variable.length>6 && @event.variable[1]>0
|
||||
if @event.variable && @event.variable.length>6 && @event.variable[1]
|
||||
# Berry was planted, show moisture patch
|
||||
newmoisture=(@event.variable[4]>50) ? 2 : (@event.variable[4]>0) ? 1 : 0
|
||||
end
|
||||
@@ -153,16 +153,17 @@ class BerryPlantSprite
|
||||
dryingrate=berryvalues[1]
|
||||
maxreplants=REPLANTS
|
||||
ripestages=4
|
||||
if isConst?(berryData[7],PBItems,:GROWTHMULCH)
|
||||
timeperstage=(timeperstage*0.75).to_i
|
||||
dryingrate=(dryingrate*1.5).ceil
|
||||
elsif isConst?(berryData[7],PBItems,:DAMPMULCH)
|
||||
timeperstage=(timeperstage*1.25).to_i
|
||||
dryingrate=(dryingrate*0.5).floor
|
||||
elsif isConst?(berryData[7],PBItems,:GOOEYMULCH)
|
||||
maxreplants=(maxreplants*1.5).ceil
|
||||
elsif isConst?(berryData[7],PBItems,:STABLEMULCH)
|
||||
ripestages=6
|
||||
case berryData[7]
|
||||
when :GROWTHMULCH
|
||||
timeperstage = (timeperstage * 0.75).to_i
|
||||
dryingrate = (dryingrate * 1.5).ceil
|
||||
when :DAMPMULCH
|
||||
timeperstage = (timeperstage * 1.25).to_i
|
||||
dryingrate = (dryingrate * 0.5).floor
|
||||
when :GOOEYMULCH
|
||||
maxreplants = (maxreplants * 1.5).ceil
|
||||
when :STABLEMULCH
|
||||
ripestages = 6
|
||||
end
|
||||
# Cycle through all replants since last check
|
||||
loop do
|
||||
@@ -281,8 +282,10 @@ class BerryPlantSprite
|
||||
@event.character_name="berrytreeplanted" # Common to all berries
|
||||
@event.turn_down
|
||||
else
|
||||
filename=sprintf("berrytree%s",getConstantName(PBItems,berryData[1])) rescue nil
|
||||
filename=sprintf("berrytree%03d",berryData[1]) if !pbResolveBitmap("Graphics/Characters/"+filename)
|
||||
filename=sprintf("berrytree%s",GameData::Item.get(berryData[1]).id.to_s) rescue nil
|
||||
if !pbResolveBitmap("Graphics/Characters/"+filename)
|
||||
filename=sprintf("berrytree%03d",GameData::Item.get(berryData[1]).id_number)
|
||||
end
|
||||
if pbResolveBitmap("Graphics/Characters/"+filename)
|
||||
@event.character_name=filename
|
||||
case berryData[0]
|
||||
@@ -310,9 +313,9 @@ def pbBerryPlant
|
||||
berryData=interp.getVariable
|
||||
if !berryData
|
||||
if NEW_BERRY_PLANTS
|
||||
berryData=[0,0,0,0,0,0,0,0]
|
||||
berryData=[0,nil,0,0,0,0,0,0]
|
||||
else
|
||||
berryData=[0,0,false,0,0,0]
|
||||
berryData=[0,nil,false,0,0,0]
|
||||
end
|
||||
end
|
||||
# Stop the event turning towards the player
|
||||
@@ -323,12 +326,7 @@ def pbBerryPlant
|
||||
when 4; thisEvent.turn_right # X flowering
|
||||
when 5; thisEvent.turn_up # X berries
|
||||
end
|
||||
watering=[]
|
||||
watering.push(getConst(PBItems,:SPRAYDUCK))
|
||||
watering.push(getConst(PBItems,:SQUIRTBOTTLE))
|
||||
watering.push(getConst(PBItems,:WAILMERPAIL))
|
||||
watering.push(getConst(PBItems,:SPRINKLOTAD))
|
||||
watering.compact!
|
||||
watering = [:SPRAYDUCK, :SQUIRTBOTTLE, :WAILMERPAIL, :SPRINKLOTAD]
|
||||
berry=berryData[1]
|
||||
case berryData[0]
|
||||
when 0 # empty
|
||||
@@ -344,19 +342,19 @@ def pbBerryPlant
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| pbIsMulch?(item) })
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_mulch? })
|
||||
}
|
||||
if ret>0
|
||||
if pbIsMulch?(ret)
|
||||
if ret
|
||||
if GameData::Item.get(ret).is_mulch?
|
||||
berryData[7]=ret
|
||||
pbMessage(_INTL("The {1} was scattered on the soil.\1",PBItems.getName(ret)))
|
||||
pbMessage(_INTL("The {1} was scattered on the soil.\1",GameData::Item.get(ret).name))
|
||||
if pbConfirmMessage(_INTL("Want to plant a Berry?"))
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| pbIsBerry?(item) })
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? })
|
||||
}
|
||||
if berry>0
|
||||
if berry
|
||||
timenow=pbGetTimeNow
|
||||
berryData[0]=1 # growth stage (1-5)
|
||||
berryData[1]=berry # item ID of planted berry
|
||||
@@ -367,7 +365,7 @@ def pbBerryPlant
|
||||
berryData[6]=0 # yield penalty
|
||||
$PokemonBag.pbDeleteItem(berry,1)
|
||||
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
|
||||
PBItems.getName(berry)))
|
||||
GameData::Item.get(berry).name))
|
||||
end
|
||||
end
|
||||
interp.setVariable(berryData)
|
||||
@@ -380,9 +378,9 @@ def pbBerryPlant
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| pbIsBerry?(item) })
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? })
|
||||
}
|
||||
if berry>0
|
||||
if berry
|
||||
timenow=pbGetTimeNow
|
||||
berryData[0]=1 # growth stage (1-5)
|
||||
berryData[1]=berry # item ID of planted berry
|
||||
@@ -393,20 +391,20 @@ def pbBerryPlant
|
||||
berryData[6]=0 # yield penalty
|
||||
$PokemonBag.pbDeleteItem(berry,1)
|
||||
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
|
||||
PBItems.getName(berry)))
|
||||
GameData::Item.get(berry).name))
|
||||
interp.setVariable(berryData)
|
||||
end
|
||||
return
|
||||
end
|
||||
else
|
||||
pbMessage(_INTL("{1} has been laid down.\1",PBItems.getName(berryData[7])))
|
||||
pbMessage(_INTL("{1} has been laid down.\1",GameData::Item.get(berryData[7]).name))
|
||||
if pbConfirmMessage(_INTL("Want to plant a Berry?"))
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| pbIsBerry?(item) })
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? })
|
||||
}
|
||||
if berry>0
|
||||
if berry
|
||||
timenow=pbGetTimeNow
|
||||
berryData[0]=1 # growth stage (1-5)
|
||||
berryData[1]=berry # item ID of planted berry
|
||||
@@ -417,7 +415,7 @@ def pbBerryPlant
|
||||
berryData[6]=0 # yield penalty
|
||||
$PokemonBag.pbDeleteItem(berry,1)
|
||||
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
|
||||
PBItems.getName(berry)))
|
||||
GameData::Item.get(berry).name))
|
||||
interp.setVariable(berryData)
|
||||
end
|
||||
return
|
||||
@@ -429,9 +427,9 @@ def pbBerryPlant
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| pbIsBerry?(item) })
|
||||
berry = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_berry? })
|
||||
}
|
||||
if berry>0
|
||||
if berry
|
||||
timenow=pbGetTimeNow
|
||||
berryData[0]=1 # growth stage (1-5)
|
||||
berryData[1]=berry # item ID of planted berry
|
||||
@@ -442,33 +440,33 @@ def pbBerryPlant
|
||||
berryData[6]=nil; berryData[7]=nil; berryData.compact! # for compatibility
|
||||
$PokemonBag.pbDeleteItem(berry,1)
|
||||
pbMessage(_INTL("{1} planted a {2} in the soft loamy soil.",
|
||||
$Trainer.name,PBItems.getName(berry)))
|
||||
$Trainer.name,GameData::Item.get(berry).name))
|
||||
interp.setVariable(berryData)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
when 1 # X planted
|
||||
pbMessage(_INTL("A {1} was planted here.",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("A {1} was planted here.",GameData::Item.get(berry).name))
|
||||
when 2 # X sprouted
|
||||
pbMessage(_INTL("The {1} has sprouted.",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("The {1} has sprouted.",GameData::Item.get(berry).name))
|
||||
when 3 # X taller
|
||||
pbMessage(_INTL("The {1} plant is growing bigger.",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("The {1} plant is growing bigger.",GameData::Item.get(berry).name))
|
||||
when 4 # X flowering
|
||||
if NEW_BERRY_PLANTS
|
||||
pbMessage(_INTL("This {1} plant is in bloom!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is in bloom!",GameData::Item.get(berry).name))
|
||||
else
|
||||
case berryData[4]
|
||||
when 4
|
||||
pbMessage(_INTL("This {1} plant is in fabulous bloom!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is in fabulous bloom!",GameData::Item.get(berry).name))
|
||||
when 3
|
||||
pbMessage(_INTL("This {1} plant is blooming very beautifully!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is blooming very beautifully!",GameData::Item.get(berry).name))
|
||||
when 2
|
||||
pbMessage(_INTL("This {1} plant is blooming prettily!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is blooming prettily!",GameData::Item.get(berry).name))
|
||||
when 1
|
||||
pbMessage(_INTL("This {1} plant is blooming cutely!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is blooming cutely!",GameData::Item.get(berry).name))
|
||||
else
|
||||
pbMessage(_INTL("This {1} plant is in bloom!",PBItems.getName(berry)))
|
||||
pbMessage(_INTL("This {1} plant is in bloom!",GameData::Item.get(berry).name))
|
||||
end
|
||||
end
|
||||
when 5 # X berries
|
||||
@@ -487,7 +485,9 @@ def pbBerryPlant
|
||||
berrycount=berryvalues[2]
|
||||
end
|
||||
end
|
||||
itemname=(berrycount>1) ? PBItems.getNamePlural(berry) : PBItems.getName(berry)
|
||||
item = GameData::Item.get(berry)
|
||||
itemname = (berrycount>1) ? item.name_plural : item.name
|
||||
pocket = item.pocket
|
||||
if berrycount>1
|
||||
message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",berrycount,itemname)
|
||||
else
|
||||
@@ -504,15 +504,14 @@ def pbBerryPlant
|
||||
else
|
||||
pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname))
|
||||
end
|
||||
pocket = pbGetPocket(berry)
|
||||
pbMessage(_INTL("{1} put the \\c[1]{2}\\c[0] in the <icon=bagPocket{3}>\\c[1]{4}\\c[0] Pocket.\1",
|
||||
$Trainer.name,itemname,pocket,PokemonBag.pocketNames()[pocket]))
|
||||
if NEW_BERRY_PLANTS
|
||||
pbMessage(_INTL("The soil returned to its soft and earthy state."))
|
||||
berryData=[0,0,0,0,0,0,0,0]
|
||||
berryData=[0,nil,0,0,0,0,0,0]
|
||||
else
|
||||
pbMessage(_INTL("The soil returned to its soft and loamy state."))
|
||||
berryData=[0,0,false,0,0,0]
|
||||
berryData=[0,nil,false,0,0,0]
|
||||
end
|
||||
interp.setVariable(berryData)
|
||||
end
|
||||
@@ -520,38 +519,37 @@ def pbBerryPlant
|
||||
case berryData[0]
|
||||
when 1, 2, 3, 4
|
||||
for i in watering
|
||||
if i!=0 && $PokemonBag.pbHasItem?(i)
|
||||
if pbConfirmMessage(_INTL("Want to sprinkle some water with the {1}?",PBItems.getName(i)))
|
||||
if berryData.length>6
|
||||
# Gen 4 berry watering mechanics
|
||||
berryData[4]=100
|
||||
else
|
||||
# Gen 3 berry watering mechanics
|
||||
if berryData[2]==false
|
||||
berryData[4]+=1
|
||||
berryData[2]=true
|
||||
end
|
||||
end
|
||||
interp.setVariable(berryData)
|
||||
pbMessage(_INTL("{1} watered the plant.\\wtnp[40]",$Trainer.name))
|
||||
if NEW_BERRY_PLANTS
|
||||
pbMessage(_INTL("There! All happy!"))
|
||||
else
|
||||
pbMessage(_INTL("The plant seemed to be delighted."))
|
||||
next if !GameData::Item.exists?(i) || !$PokemonBag.pbHasItem?(i)
|
||||
if pbConfirmMessage(_INTL("Want to sprinkle some water with the {1}?",GameData::Item.get(i).name))
|
||||
if berryData.length>6
|
||||
# Gen 4 berry watering mechanics
|
||||
berryData[4]=100
|
||||
else
|
||||
# Gen 3 berry watering mechanics
|
||||
if berryData[2]==false
|
||||
berryData[4]+=1
|
||||
berryData[2]=true
|
||||
end
|
||||
end
|
||||
break
|
||||
interp.setVariable(berryData)
|
||||
pbMessage(_INTL("{1} watered the plant.\\wtnp[40]",$Trainer.name))
|
||||
if NEW_BERRY_PLANTS
|
||||
pbMessage(_INTL("There! All happy!"))
|
||||
else
|
||||
pbMessage(_INTL("The plant seemed to be delighted."))
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbPickBerry(berry,qty=1)
|
||||
def pbPickBerry(berry, qty = 1)
|
||||
interp=pbMapInterpreter
|
||||
thisEvent=interp.get_character(0)
|
||||
berryData=interp.getVariable
|
||||
berry=getID(PBItems,berry)
|
||||
itemname=(qty>1) ? PBItems.getNamePlural(berry) : PBItems.getName(berry)
|
||||
berry=GameData::Item.get(berry)
|
||||
itemname=(qty>1) ? berry.name_plural : berry.name
|
||||
if qty>1
|
||||
message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",qty,itemname)
|
||||
else
|
||||
@@ -568,15 +566,15 @@ def pbPickBerry(berry,qty=1)
|
||||
else
|
||||
pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname))
|
||||
end
|
||||
pocket = pbGetPocket(berry)
|
||||
pocket = berry.pocket
|
||||
pbMessage(_INTL("{1} put the \\c[1]{2}\\c[0] in the <icon=bagPocket{3}>\\c[1]{4}\\c[0] Pocket.\1",
|
||||
$Trainer.name,itemname,pocket,PokemonBag.pocketNames()[pocket]))
|
||||
if NEW_BERRY_PLANTS
|
||||
pbMessage(_INTL("The soil returned to its soft and earthy state."))
|
||||
berryData=[0,0,0,0,0,0,0,0]
|
||||
berryData=[0,nil,0,0,0,0,0,0]
|
||||
else
|
||||
pbMessage(_INTL("The soil returned to its soft and loamy state."))
|
||||
berryData=[0,0,false,0,0,0]
|
||||
berryData=[0,nil,false,0,0,0]
|
||||
end
|
||||
interp.setVariable(berryData)
|
||||
pbSetSelfSwitch(thisEvent.id,"A",true)
|
||||
|
||||
@@ -192,7 +192,7 @@ def pbDayCareGenerateEgg
|
||||
father = pokemon0
|
||||
end
|
||||
# Determine the egg's species
|
||||
babyspecies = pbGetBabySpecies(babyspecies,mother.item,father.item)
|
||||
babyspecies = pbGetBabySpecies(babyspecies,true,mother.item_id,father.item_id)
|
||||
if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
|
||||
babyspecies = getConst(PBSpecies,:PHIONE)
|
||||
elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) ||
|
||||
@@ -233,7 +233,7 @@ def pbDayCareGenerateEgg
|
||||
isConst?(babyspecies,PBSpecies,:GRIMER)
|
||||
if mother.form==1
|
||||
egg.form = 1 if mother.hasItem?(:EVERSTONE)
|
||||
elsif pbGetBabySpecies(father.species,mother.item,father.item)==babyspecies
|
||||
elsif pbGetBabySpecies(father.species,true,mother.item_id,father.item_id)==babyspecies
|
||||
egg.form = 1 if father.form==1 && father.hasItem?(:EVERSTONE)
|
||||
end
|
||||
end
|
||||
@@ -260,11 +260,9 @@ def pbDayCareGenerateEgg
|
||||
end
|
||||
# Inheriting Machine Moves
|
||||
if !NEWEST_BATTLE_MECHANICS
|
||||
itemsData = pbLoadItemsData
|
||||
for i in 0...itemsData.length
|
||||
next if !itemsData[i]
|
||||
atk = itemsData[i][ItemData::MOVE]
|
||||
next if !atk || atk==0
|
||||
GameData::Item.each do |i|
|
||||
atk = i.move
|
||||
next if !atk
|
||||
next if !egg.compatibleWithMove?(atk)
|
||||
next if !movefather.hasMove?(atk)
|
||||
moves.push(atk)
|
||||
@@ -351,7 +349,7 @@ def pbDayCareGenerateEgg
|
||||
# Masuda method and Shiny Charm
|
||||
shinyretries = 0
|
||||
shinyretries += 5 if father.owner.language != mother.owner.language
|
||||
shinyretries += 2 if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
|
||||
shinyretries += 2 if GameData::Item.exists?(:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
|
||||
if shinyretries>0
|
||||
shinyretries.times do
|
||||
break if egg.shiny?
|
||||
@@ -377,8 +375,7 @@ def pbDayCareGenerateEgg
|
||||
end
|
||||
# Inheriting Poké Ball from the mother
|
||||
if mother.female? &&
|
||||
!isConst?(pbBallTypeToItem(mother.ballused),PBItems,:MASTERBALL) &&
|
||||
!isConst?(pbBallTypeToItem(mother.ballused),PBItems,:CHERISHBALL)
|
||||
![:MASTERBALL, :CHERISHBALL].include?(pbBallTypeToItem(mother.ballused).id)
|
||||
egg.ballused = mother.ballused
|
||||
end
|
||||
# Set all stats
|
||||
@@ -417,7 +414,7 @@ Events.onStepTaken += proc { |_sender,_e|
|
||||
if $PokemonGlobal.daycareEggSteps==256
|
||||
$PokemonGlobal.daycareEggSteps = 0
|
||||
compatval = [0,20,50,70][pbDayCareGetCompat]
|
||||
if hasConst?(PBItems,:OVALCHARM) && $PokemonBag.pbHasItem?(:OVALCHARM)
|
||||
if GameData::Item.exists?(:OVALCHARM) && $PokemonBag.pbHasItem?(:OVALCHARM)
|
||||
compatval = [0,40,80,88][pbDayCareGetCompat]
|
||||
end
|
||||
$PokemonGlobal.daycareEgg = 1 if rand(100)<compatval # Egg is generated
|
||||
|
||||
@@ -20,10 +20,10 @@ module TrainerData
|
||||
LOSETEXT = 15
|
||||
|
||||
SCHEMA = {
|
||||
"Items" => [0, "eEEEEEEE", :PBItems, :PBItems, :PBItems, :PBItems,
|
||||
:PBItems, :PBItems, :PBItems, :PBItems],
|
||||
"Items" => [0, "eEEEEEEE", :Item, :Item, :Item, :Item,
|
||||
:Item, :Item, :Item, :Item],
|
||||
"Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level
|
||||
"Item" => [ITEM, "e", :PBItems],
|
||||
"Item" => [ITEM, "e", :Item],
|
||||
"Moves" => [MOVES, "eEEE", :PBMoves, :PBMoves, :PBMoves, :PBMoves],
|
||||
"Ability" => [ABILITY, "u"],
|
||||
"Gender" => [GENDER, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
|
||||
@@ -81,7 +81,7 @@ def pbLoadTrainer(trainerid,trainername,partyid=0)
|
||||
pokemon.forcedForm = poke[TrainerData::FORM] if MultipleForms.hasFunction?(pokemon.species,"getForm")
|
||||
pokemon.formSimple = poke[TrainerData::FORM]
|
||||
end
|
||||
pokemon.setItem(poke[TrainerData::ITEM]) if poke[TrainerData::ITEM]
|
||||
pokemon.setItem(poke[TrainerData::ITEM])
|
||||
if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0
|
||||
for move in poke[TrainerData::MOVES]
|
||||
pokemon.pbLearnMove(move)
|
||||
|
||||
@@ -1,224 +1,3 @@
|
||||
#===============================================================================
|
||||
# Item data
|
||||
#===============================================================================
|
||||
module ItemData
|
||||
ID = 0
|
||||
NAME = 1
|
||||
NAME_PLURAL = 2
|
||||
POCKET = 3
|
||||
PRICE = 4
|
||||
DESCRIPTION = 5
|
||||
FIELD_USE = 6
|
||||
BATTLE_USE = 7
|
||||
TYPE = 8
|
||||
MOVE = 9
|
||||
end
|
||||
|
||||
|
||||
|
||||
class PokemonTemp
|
||||
attr_accessor :itemsData
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbLoadItemsData
|
||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||
if !$PokemonTemp.itemsData
|
||||
$PokemonTemp.itemsData = load_data("Data/items.dat") || []
|
||||
end
|
||||
return $PokemonTemp.itemsData
|
||||
end
|
||||
|
||||
def pbGetItemData(item,itemDataType)
|
||||
item = getID(PBItems,item)
|
||||
itemsData = pbLoadItemsData
|
||||
return itemsData[item][itemDataType] if itemsData[item]
|
||||
return nil
|
||||
end
|
||||
|
||||
alias __itemsData__pbClearData pbClearData
|
||||
def pbClearData
|
||||
$PokemonTemp.itemsData = nil if $PokemonTemp
|
||||
__itemsData__pbClearData
|
||||
end
|
||||
|
||||
def pbGetPocket(item)
|
||||
ret = pbGetItemData(item,ItemData::POCKET)
|
||||
return ret || 0
|
||||
end
|
||||
|
||||
def pbGetPrice(item)
|
||||
ret = pbGetItemData(item,ItemData::PRICE)
|
||||
return ret || 0
|
||||
end
|
||||
|
||||
def pbGetMachine(item)
|
||||
ret = pbGetItemData(item,ItemData::MOVE)
|
||||
return ret || 0
|
||||
end
|
||||
|
||||
def pbIsTechnicalMachine?(item)
|
||||
ret = pbGetItemData(item,ItemData::FIELD_USE)
|
||||
return ret && ret==3
|
||||
end
|
||||
|
||||
def pbIsHiddenMachine?(item)
|
||||
ret = pbGetItemData(item,ItemData::FIELD_USE)
|
||||
return ret && ret==4
|
||||
end
|
||||
|
||||
def pbIsMachine?(item)
|
||||
ret = pbGetItemData(item,ItemData::FIELD_USE)
|
||||
return ret && (ret==3 || ret==4)
|
||||
end
|
||||
|
||||
def pbIsMail?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && (ret==1 || ret==2)
|
||||
end
|
||||
|
||||
def pbIsMailWithPokemonIcons?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==2
|
||||
end
|
||||
|
||||
def pbIsPokeBall?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && (ret==3 || ret==4)
|
||||
end
|
||||
|
||||
def pbIsSnagBall?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && (ret==3 || (ret==4 && $PokemonGlobal.snagMachine))
|
||||
end
|
||||
|
||||
def pbIsBerry?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==5
|
||||
end
|
||||
|
||||
def pbIsKeyItem?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==6
|
||||
end
|
||||
|
||||
def pbIsEvolutionStone?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==7
|
||||
end
|
||||
|
||||
def pbIsFossil?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==8
|
||||
end
|
||||
|
||||
def pbIsApricorn?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==9
|
||||
end
|
||||
|
||||
def pbIsGem?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==10
|
||||
end
|
||||
|
||||
def pbIsMulch?(item)
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==11
|
||||
end
|
||||
|
||||
def pbIsMegaStone?(item) # Does NOT include Red Orb/Blue Orb
|
||||
ret = pbGetItemData(item,ItemData::TYPE)
|
||||
return ret && ret==12
|
||||
end
|
||||
|
||||
# Important items can't be sold, given to hold, or tossed.
|
||||
def pbIsImportantItem?(item)
|
||||
itemData = pbLoadItemsData[getID(PBItems,item)]
|
||||
return false if !itemData
|
||||
return true if itemData[ItemData::TYPE] && itemData[ItemData::TYPE]==6 # Key item
|
||||
return true if itemData[ItemData::FIELD_USE] && itemData[ItemData::FIELD_USE]==4 # HM
|
||||
return true if itemData[ItemData::FIELD_USE] && itemData[ItemData::FIELD_USE]==3 && INFINITE_TMS # TM
|
||||
return false
|
||||
end
|
||||
|
||||
def pbCanHoldItem?(item)
|
||||
return !pbIsImportantItem?(item)
|
||||
end
|
||||
|
||||
def pbCanRegisterItem?(item)
|
||||
return ItemHandlers.hasUseInFieldHandler(item)
|
||||
end
|
||||
|
||||
def pbCanUseOnPokemon?(item)
|
||||
return ItemHandlers.hasUseOnPokemon(item) || pbIsMachine?(item)
|
||||
end
|
||||
|
||||
def pbIsHiddenMove?(move)
|
||||
itemsData = pbLoadItemsData
|
||||
return false if !itemsData
|
||||
for i in 0...itemsData.length
|
||||
next if !pbIsHiddenMachine?(i)
|
||||
atk = pbGetMachine(i)
|
||||
return true if move==atk
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def pbIsUnlosableItem?(item,species,ability)
|
||||
return false if isConst?(species,PBSpecies,:ARCEUS) && ability != :MULTITYPE
|
||||
return false if isConst?(species,PBSpecies,:SILVALLY) && ability != :RKSSYSTEM
|
||||
combos = {
|
||||
:ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
|
||||
:SKYPLATE, :FLYINIUMZ,
|
||||
:TOXICPLATE, :POISONIUMZ,
|
||||
:EARTHPLATE, :GROUNDIUMZ,
|
||||
:STONEPLATE, :ROCKIUMZ,
|
||||
:INSECTPLATE, :BUGINIUMZ,
|
||||
:SPOOKYPLATE, :GHOSTIUMZ,
|
||||
:IRONPLATE, :STEELIUMZ,
|
||||
:FLAMEPLATE, :FIRIUMZ,
|
||||
:SPLASHPLATE, :WATERIUMZ,
|
||||
:MEADOWPLATE, :GRASSIUMZ,
|
||||
:ZAPPLATE, :ELECTRIUMZ,
|
||||
:MINDPLATE, :PSYCHIUMZ,
|
||||
:ICICLEPLATE, :ICIUMZ,
|
||||
:DRACOPLATE, :DRAGONIUMZ,
|
||||
:DREADPLATE, :DARKINIUMZ,
|
||||
:PIXIEPLATE, :FAIRIUMZ],
|
||||
:SILVALLY => [:FIGHTINGMEMORY,
|
||||
:FLYINGMEMORY,
|
||||
:POISONMEMORY,
|
||||
:GROUNDMEMORY,
|
||||
:ROCKMEMORY,
|
||||
:BUGMEMORY,
|
||||
:GHOSTMEMORY,
|
||||
:STEELMEMORY,
|
||||
:FIREMEMORY,
|
||||
:WATERMEMORY,
|
||||
:GRASSMEMORY,
|
||||
:ELECTRICMEMORY,
|
||||
:PSYCHICMEMORY,
|
||||
:ICEMEMORY,
|
||||
:DRAGONMEMORY,
|
||||
:DARKMEMORY,
|
||||
:FAIRYMEMORY],
|
||||
:GIRATINA => [:GRISEOUSORB],
|
||||
:GENESECT => [:BURNDRIVE,:CHILLDRIVE,:DOUSEDRIVE,:SHOCKDRIVE],
|
||||
:KYOGRE => [:BLUEORB],
|
||||
:GROUDON => [:REDORB]
|
||||
}
|
||||
combos.each do |comboSpecies, items|
|
||||
next if !isConst?(species,PBSpecies,comboSpecies)
|
||||
items.each { |i| return true if isConst?(item,PBItems,i) }
|
||||
break
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# ItemHandlers
|
||||
#===============================================================================
|
||||
@@ -325,6 +104,16 @@ end
|
||||
|
||||
|
||||
|
||||
def pbCanRegisterItem?(item)
|
||||
return ItemHandlers.hasUseInFieldHandler(item)
|
||||
end
|
||||
|
||||
def pbCanUseOnPokemon?(item)
|
||||
return ItemHandlers.hasUseOnPokemon(item) || GameData::Item.get(item).is_machine?
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Change a Pokémon's level
|
||||
#===============================================================================
|
||||
@@ -680,32 +469,34 @@ end
|
||||
#===============================================================================
|
||||
# Use an item from the Bag and/or on a Pokémon
|
||||
#===============================================================================
|
||||
# @return [Integer] 0 = item wasn't used; 1 = item used; 2 = close Bag to use in field
|
||||
def pbUseItem(bag,item,bagscene=nil)
|
||||
useType = pbGetItemData(item,ItemData::FIELD_USE)
|
||||
if pbIsMachine?(item) # TM or HM
|
||||
itm = GameData::Item.get(item)
|
||||
useType = itm.field_use
|
||||
if itm.is_machine? # TM or HM
|
||||
if $Trainer.pokemonCount==0
|
||||
pbMessage(_INTL("There is no Pokémon."))
|
||||
return 0
|
||||
end
|
||||
machine = pbGetMachine(item)
|
||||
return 0 if machine==nil
|
||||
machine = itm.move
|
||||
return 0 if !machine
|
||||
movename = PBMoves.getName(machine)
|
||||
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",PBItems.getName(item)))
|
||||
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name))
|
||||
if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename))
|
||||
return 0
|
||||
elsif pbMoveTutorChoose(machine,nil,true)
|
||||
bag.pbDeleteItem(item) if pbIsTechnicalMachine?(item) && !INFINITE_TMS
|
||||
bag.pbDeleteItem(item) if itm.is_TM? && !INFINITE_TMS
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
elsif useType && (useType==1 || useType==5) # Item is usable on a Pokémon
|
||||
elsif useType==1 || useType==5 # Item is usable on a Pokémon
|
||||
if $Trainer.pokemonCount==0
|
||||
pbMessage(_INTL("There is no Pokémon."))
|
||||
return 0
|
||||
end
|
||||
ret = false
|
||||
annot = nil
|
||||
if pbIsEvolutionStone?(item)
|
||||
if itm.is_evolution_stone?
|
||||
annot = []
|
||||
for pkmn in $Trainer.party
|
||||
elig = pbCheckEvolution(pkmn,item)>0
|
||||
@@ -729,7 +520,7 @@ def pbUseItem(bag,item,bagscene=nil)
|
||||
if ret && useType==1 # Usable on Pokémon, consumed
|
||||
bag.pbDeleteItem(item)
|
||||
if !bag.pbHasItem?(item)
|
||||
pbMessage(_INTL("You used your last {1}.",PBItems.getName(item))) { screen.pbUpdate }
|
||||
pbMessage(_INTL("You used your last {1}.",itm.name)) { screen.pbUpdate }
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -739,7 +530,7 @@ def pbUseItem(bag,item,bagscene=nil)
|
||||
bagscene.pbRefresh if bagscene
|
||||
}
|
||||
return (ret) ? 1 : 0
|
||||
elsif useType && useType==2 # Item is usable from bag
|
||||
elsif useType==2 # Item is usable from bag
|
||||
intret = ItemHandlers.triggerUseFromBag(item)
|
||||
case intret
|
||||
when 0; return 0
|
||||
@@ -758,20 +549,21 @@ end
|
||||
# Only called when in the party screen and having chosen an item to be used on
|
||||
# the selected Pokémon
|
||||
def pbUseItemOnPokemon(item,pkmn,scene)
|
||||
itm = GameData::Item.get(item)
|
||||
# TM or HM
|
||||
if pbIsMachine?(item)
|
||||
machine = pbGetMachine(item)
|
||||
return false if machine==nil
|
||||
if itm.is_machine?
|
||||
machine = itm.move
|
||||
return false if !machine
|
||||
movename = PBMoves.getName(machine)
|
||||
if pkmn.shadowPokemon?
|
||||
pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate }
|
||||
elsif !pkmn.compatibleWithMove?(machine)
|
||||
pbMessage(_INTL("{1} can't learn {2}.",pkmn.name,movename)) { scene.pbUpdate }
|
||||
else
|
||||
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",PBItems.getName(item))) { scene.pbUpdate }
|
||||
pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name)) { scene.pbUpdate }
|
||||
if pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?",movename,pkmn.name)) { scene.pbUpdate }
|
||||
if pbLearnMove(pkmn,machine,false,true) { scene.pbUpdate }
|
||||
$PokemonBag.pbDeleteItem(item) if pbIsTechnicalMachine?(item) && !INFINITE_TMS
|
||||
$PokemonBag.pbDeleteItem(item) if itm.is_TM? && !INFINITE_TMS
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -782,11 +574,11 @@ def pbUseItemOnPokemon(item,pkmn,scene)
|
||||
ret = ItemHandlers.triggerUseOnPokemon(item,pkmn,scene)
|
||||
scene.pbClearAnnotations
|
||||
scene.pbHardRefresh
|
||||
useType = pbGetItemData(item,ItemData::FIELD_USE)
|
||||
if ret && useType && useType==1 # Usable on Pokémon, consumed
|
||||
useType = itm.field_use
|
||||
if ret && useType==1 # Usable on Pokémon, consumed
|
||||
$PokemonBag.pbDeleteItem(item)
|
||||
if !$PokemonBag.pbHasItem?(item)
|
||||
pbMessage(_INTL("You used your last {1}.",PBItems.getName(item))) { scene.pbUpdate }
|
||||
pbMessage(_INTL("You used your last {1}.",itm.name)) { scene.pbUpdate }
|
||||
end
|
||||
end
|
||||
return ret
|
||||
@@ -803,7 +595,7 @@ def pbUseKeyItemInField(item)
|
||||
end
|
||||
|
||||
def pbUseItemMessage(item)
|
||||
itemname = PBItems.getName(item)
|
||||
itemname = GameData::Item.get(item).name
|
||||
if itemname.starts_with_vowel?
|
||||
pbMessage(_INTL("You used an {1}.",itemname))
|
||||
else
|
||||
@@ -819,7 +611,7 @@ end
|
||||
# Give an item to a Pokémon to hold, and take a held item from a Pokémon
|
||||
#===============================================================================
|
||||
def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
|
||||
newitemname = PBItems.getName(item)
|
||||
newitemname = GameData::Item.get(item).name
|
||||
if pkmn.egg?
|
||||
scene.pbDisplay(_INTL("Eggs can't hold items."))
|
||||
return false
|
||||
@@ -828,7 +620,7 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
|
||||
return false if !pbTakeItemFromPokemon(pkmn,scene)
|
||||
end
|
||||
if pkmn.hasItem?
|
||||
olditemname = PBItems.getName(pkmn.item)
|
||||
olditemname = pkmn.item.name
|
||||
if pkmn.hasItem?(:LEFTOVERS)
|
||||
scene.pbDisplay(_INTL("{1} is already holding some {2}.\1",pkmn.name,olditemname))
|
||||
elsif newitemname.starts_with_vowel?
|
||||
@@ -844,7 +636,7 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
|
||||
end
|
||||
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed."))
|
||||
else
|
||||
if pbIsMail?(item)
|
||||
if GameData::Item.get(item).is_mail?
|
||||
if pbWriteMail(item,pkmn,pkmnid,scene)
|
||||
pkmn.setItem(item)
|
||||
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pkmn.name,newitemname))
|
||||
@@ -862,7 +654,7 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
|
||||
end
|
||||
end
|
||||
else
|
||||
if !pbIsMail?(item) || pbWriteMail(item,pkmn,pkmnid,scene)
|
||||
if !GameData::Item.get(item).is_mail? || pbWriteMail(item,pkmn,pkmnid,scene)
|
||||
$PokemonBag.pbDeleteItem(item)
|
||||
pkmn.setItem(item)
|
||||
scene.pbDisplay(_INTL("{1} is now holding the {2}.",pkmn.name,newitemname))
|
||||
@@ -884,22 +676,20 @@ def pbTakeItemFromPokemon(pkmn,scene)
|
||||
scene.pbDisplay(_INTL("Your PC's Mailbox is full."))
|
||||
else
|
||||
scene.pbDisplay(_INTL("The mail was saved in your PC."))
|
||||
pkmn.setItem(0)
|
||||
pkmn.setItem(nil)
|
||||
ret = true
|
||||
end
|
||||
elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?"))
|
||||
$PokemonBag.pbStoreItem(pkmn.item)
|
||||
itemname = PBItems.getName(pkmn.item)
|
||||
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pkmn.name))
|
||||
pkmn.setItem(0)
|
||||
scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name))
|
||||
pkmn.setItem(nil)
|
||||
pkmn.mail = nil
|
||||
ret = true
|
||||
end
|
||||
else
|
||||
$PokemonBag.pbStoreItem(pkmn.item)
|
||||
itemname = PBItems.getName(pkmn.item)
|
||||
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pkmn.name))
|
||||
pkmn.setItem(0)
|
||||
scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name))
|
||||
pkmn.setItem(nil)
|
||||
ret = true
|
||||
end
|
||||
return ret
|
||||
@@ -908,61 +698,61 @@ end
|
||||
#===============================================================================
|
||||
# Choose an item from the Bag
|
||||
#===============================================================================
|
||||
def pbChooseItem(var=0,*args)
|
||||
ret = 0
|
||||
def pbChooseItem(var = 0, *args)
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
ret = screen.pbChooseItemScreen
|
||||
}
|
||||
$game_variables[var] = ret if var>0
|
||||
$game_variables[var] = ret if var > 0
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseApricorn(var=0)
|
||||
ret = 0
|
||||
def pbChooseApricorn(var = 0)
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| pbIsApricorn?(item) })
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_apricorn? })
|
||||
}
|
||||
$game_variables[var] = ret if var>0
|
||||
$game_variables[var] = ret if var > 0
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseFossil(var=0)
|
||||
ret = 0
|
||||
def pbChooseFossil(var = 0)
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| pbIsFossil?(item) })
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).is_fossil? })
|
||||
}
|
||||
$game_variables[var] = ret if var>0
|
||||
$game_variables[var] = ret if var > 0
|
||||
return ret
|
||||
end
|
||||
|
||||
# Shows a list of items to choose from, with the chosen item's ID being stored
|
||||
# in the given Global Variable. Only items which the player has are listed.
|
||||
def pbChooseItemFromList(message,variable,*args)
|
||||
def pbChooseItemFromList(message, variable, *args)
|
||||
commands = []
|
||||
itemid = []
|
||||
for item in args
|
||||
next if !hasConst?(PBItems,item)
|
||||
id = getConst(PBItems,item)
|
||||
next if !$PokemonBag.pbHasItem?(id)
|
||||
commands.push(PBItems.getName(id))
|
||||
itemid.push(id)
|
||||
next if !GameData::Item.exists?(item)
|
||||
itm = GameData::Item.get(item)
|
||||
next if !$PokemonBag.pbHasItem?(itm)
|
||||
commands.push(itm.name)
|
||||
itemid.push(itm.id)
|
||||
end
|
||||
if commands.length==0
|
||||
if commands.length == 0
|
||||
$game_variables[variable] = 0
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
commands.push(_INTL("Cancel"))
|
||||
itemid.push(0)
|
||||
ret = pbMessage(message,commands,-1)
|
||||
if ret<0 || ret>=commands.length-1
|
||||
$game_variables[variable] = -1
|
||||
return -1
|
||||
itemid.push(nil)
|
||||
ret = pbMessage(message, commands, -1)
|
||||
if ret < 0 || ret >= commands.length-1
|
||||
$game_variables[variable] = nil
|
||||
return nil
|
||||
end
|
||||
$game_variables[variable] = itemid[ret]
|
||||
return itemid[ret]
|
||||
|
||||
@@ -121,17 +121,15 @@ Events.onStepTaken += proc {
|
||||
$PokemonBag.pbHasItem?(:SUPERREPEL) ||
|
||||
$PokemonBag.pbHasItem?(:MAXREPEL)
|
||||
if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?"))
|
||||
ret = 0
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item|
|
||||
isConst?(item,PBItems,:REPEL) ||
|
||||
isConst?(item,PBItems,:SUPERREPEL) ||
|
||||
isConst?(item,PBItems,:MAXREPEL)
|
||||
[:REPEL, :SUPERREPEL, :MAXREPEL].include?(item)
|
||||
})
|
||||
}
|
||||
pbUseItem($PokemonBag,ret) if ret>0
|
||||
pbUseItem($PokemonBag,ret) if ret
|
||||
end
|
||||
else
|
||||
pbMessage(_INTL("The repellent's effect wore off!"))
|
||||
@@ -292,7 +290,7 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
|
||||
$game_player.turn_right_90
|
||||
end
|
||||
pbWait(Graphics.frame_rate*3/10)
|
||||
pbMessage(_INTL("The {1}'s indicating something right underfoot!",PBItems.getName(item)))
|
||||
pbMessage(_INTL("The {1}'s indicating something right underfoot!",GameData::Item.get(item).name))
|
||||
else # Item is nearby, face towards it
|
||||
direction = $game_player.direction
|
||||
if offsetX.abs>offsetY.abs
|
||||
@@ -307,7 +305,7 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
|
||||
when 8; $game_player.turn_up
|
||||
end
|
||||
pbWait(Graphics.frame_rate*3/10)
|
||||
pbMessage(_INTL("Huh? The {1}'s responding!\1",PBItems.getName(item)))
|
||||
pbMessage(_INTL("Huh? The {1}'s responding!\1",GameData::Item.get(item).name))
|
||||
pbMessage(_INTL("There's an item buried around here!"))
|
||||
end
|
||||
end
|
||||
@@ -344,7 +342,7 @@ ItemHandlers::UseInField.add(:EXPALLOFF,proc { |item|
|
||||
|
||||
# Applies to all items defined as an evolution stone.
|
||||
# No need to add more code for new ones.
|
||||
ItemHandlers::UseOnPokemon.addIf(proc { |item| pbIsEvolutionStone?(item)},
|
||||
ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolution_stone? },
|
||||
proc { |item,pkmn,scene|
|
||||
if pkmn.shadowPokemon?
|
||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||
@@ -1096,7 +1094,7 @@ ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|
|
||||
next false
|
||||
end
|
||||
newabil = (pkmn.abilityIndex+1)%2
|
||||
newabilname = PokemonData::Ability.get((newabil==0) ? abil1 : abil2).name
|
||||
newabilname = GameData::Ability.get((newabil==0) ? abil1 : abil2).name
|
||||
if scene.pbConfirm(_INTL("Would you like to change {1}'s Ability to {2}?",
|
||||
pkmn.name,newabilname))
|
||||
pkmn.setAbility(newabil)
|
||||
|
||||
@@ -21,7 +21,7 @@ ItemHandlers::CanUseInBattle.add(:POKEDOLL,proc { |item,pokemon,battler,move,fir
|
||||
|
||||
ItemHandlers::CanUseInBattle.copy(:POKEDOLL,:FLUFFYTAIL,:POKETOY)
|
||||
|
||||
ItemHandlers::CanUseInBattle.addIf(proc { |item| pbIsPokeBall?(item) }, # Poké Balls
|
||||
ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls
|
||||
proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages|
|
||||
if battle.pbPlayer.party.length>=6 && $PokemonStorage.full?
|
||||
scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages
|
||||
@@ -42,7 +42,7 @@ ItemHandlers::CanUseInBattle.addIf(proc { |item| pbIsPokeBall?(item) }, # Pok
|
||||
# than one unfainted opposing Pokémon. (Snag Balls can be thrown in
|
||||
# this case, but only in trainer battles, and the trainer will deflect
|
||||
# them if they are trying to catch a non-Shadow Pokémon.)
|
||||
if battle.pbOpposingBattlerCount>1 && !(pbIsSnagBall?(item) && battle.trainerBattle?)
|
||||
if battle.pbOpposingBattlerCount>1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?)
|
||||
if battle.pbOpposingBattlerCount==2
|
||||
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages
|
||||
else
|
||||
@@ -302,7 +302,7 @@ ItemHandlers::UseInBattle.add(:POKEFLUTE,proc { |item,battler,battle|
|
||||
scene.pbDisplay(_INTL("All Pokémon were roused by the tune!"))
|
||||
})
|
||||
|
||||
ItemHandlers::UseInBattle.addIf(proc { |item| pbIsPokeBall?(item) }, # Poké Balls
|
||||
ItemHandlers::UseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls
|
||||
proc { |item,battler,battle|
|
||||
battle.pbThrowPokeBall(battler.index,item)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
class PokemonMail
|
||||
attr_accessor :item,:message,:sender,:poke1,:poke2,:poke3
|
||||
|
||||
def initialize(item,message,sender,poke1=nil,poke2=nil,poke3=nil)
|
||||
def initialize(item, message, sender, poke1 = nil, poke2 = nil, poke3 = nil)
|
||||
item = item.id if !item.is_a?(Symbol) && item.respond_to?("id")
|
||||
@item = item # Item represented by this mail
|
||||
@message = message # Message text
|
||||
@sender = sender # Name of the message's sender
|
||||
@@ -38,7 +39,7 @@ def pbDisplayMail(mail,_bearer=nil)
|
||||
sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
|
||||
overlay = sprites["overlay"].bitmap
|
||||
pbSetSystemFont(overlay)
|
||||
if pbIsMailWithPokemonIcons?(mail.item)
|
||||
if GameData::Item.get(mail.item).is_icon_mail?
|
||||
if mail.poke1
|
||||
sprites["bearer"] = IconSprite.new(64,288,viewport)
|
||||
bitmapFileName = pbCheckPokemonIconFiles(mail.poke1,mail.poke1[5])
|
||||
|
||||
@@ -14,10 +14,10 @@ class ItemIconSprite < SpriteWrapper
|
||||
@frame = 0
|
||||
self.x = x
|
||||
self.y = y
|
||||
@blankzero = false
|
||||
@forceitemchange = true
|
||||
self.item = item
|
||||
@forceitemchange = false
|
||||
@blankzero = false
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -71,8 +71,8 @@ class ItemIconSprite < SpriteWrapper
|
||||
@item = value
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
if @item && !(@item==0 && @blankzero)
|
||||
@animbitmap = AnimatedBitmap.new(pbItemIconFile(value))
|
||||
if @item || !@blankzero
|
||||
@animbitmap = AnimatedBitmap.new(pbItemIconFile(@item))
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
if self.bitmap.height==ANIM_ICON_SIZE
|
||||
@numframes = [(self.bitmap.width/ANIM_ICON_SIZE).floor,1].max
|
||||
@@ -120,26 +120,8 @@ class HeldItemIconSprite < SpriteWrapper
|
||||
self.x = x
|
||||
self.y = y
|
||||
@pokemon = pokemon
|
||||
@item = 0
|
||||
self.item = @pokemon.item
|
||||
end
|
||||
|
||||
def pokemon=(value)
|
||||
@pokemon = value
|
||||
self.item = @pokemon.item
|
||||
end
|
||||
|
||||
def item=(value)
|
||||
return if @item==value
|
||||
@item = value
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
if @item && @item>0
|
||||
@animbitmap = AnimatedBitmap.new(pbHeldItemIconFile(value))
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
else
|
||||
self.bitmap = nil
|
||||
end
|
||||
@item = nil
|
||||
self.item = @pokemon.item_id
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -147,9 +129,27 @@ class HeldItemIconSprite < SpriteWrapper
|
||||
super
|
||||
end
|
||||
|
||||
def pokemon=(value)
|
||||
@pokemon = value
|
||||
self.item = @pokemon.item_id
|
||||
end
|
||||
|
||||
def item=(value)
|
||||
return if @item==value
|
||||
@item = value
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
if @item
|
||||
@animbitmap = AnimatedBitmap.new(pbHeldItemIconFile(@item))
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
else
|
||||
self.bitmap = nil
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
self.item = @pokemon.item
|
||||
self.item = @pokemon.item_id
|
||||
if @animbitmap
|
||||
@animbitmap.update
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
|
||||
@@ -21,20 +21,20 @@ class PokemonBag
|
||||
@choices[i] = 0
|
||||
end
|
||||
@registeredItems = []
|
||||
@registeredIndex = [0,0,1]
|
||||
@registeredIndex = [0, 0, 1]
|
||||
end
|
||||
|
||||
def rearrange
|
||||
if (@pockets.length-1)!=PokemonBag.numPockets
|
||||
if (@pockets.length - 1) != PokemonBag.numPockets
|
||||
newpockets = []
|
||||
for i in 0..PokemonBag.numPockets
|
||||
newpockets[i] = []
|
||||
@choices[i] = 0 if !@choices[i]
|
||||
@choices[i] = 0 if !@choices[i]
|
||||
end
|
||||
nump = PokemonBag.numPockets
|
||||
for i in 0...[@pockets.length,nump].min
|
||||
num_pockets = PokemonBag.numPockets
|
||||
for i in 0...[@pockets.length, num_pockets].min
|
||||
for item in @pockets[i]
|
||||
p = pbGetPocket(item[0])
|
||||
p = GameData::Item.get(item[0]).pocket
|
||||
newpockets[p].push(item)
|
||||
end
|
||||
end
|
||||
@@ -43,9 +43,7 @@ class PokemonBag
|
||||
end
|
||||
|
||||
def clear
|
||||
for pocket in @pockets
|
||||
pocket.clear
|
||||
end
|
||||
@pockets.each { |pocket| pocket.clear }
|
||||
end
|
||||
|
||||
def pockets
|
||||
@@ -61,25 +59,27 @@ class PokemonBag
|
||||
|
||||
# Gets the index of the current selected item in the pocket
|
||||
def getChoice(pocket)
|
||||
if pocket<=0 || pocket>PokemonBag.numPockets
|
||||
raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect))
|
||||
if pocket <= 0 || pocket > PokemonBag.numPockets
|
||||
raise ArgumentError.new(_INTL("Invalid pocket: {1}", pocket.inspect))
|
||||
end
|
||||
rearrange
|
||||
return [@choices[pocket],@pockets[pocket].length].min || 0
|
||||
return [@choices[pocket], @pockets[pocket].length].min || 0
|
||||
end
|
||||
|
||||
# Sets the index of the current selected item in the pocket
|
||||
def setChoice(pocket,value)
|
||||
if pocket<=0 || pocket>PokemonBag.numPockets
|
||||
raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect))
|
||||
if pocket <= 0 || pocket > PokemonBag.numPockets
|
||||
raise ArgumentError.new(_INTL("Invalid pocket: {1}", pocket.inspect))
|
||||
end
|
||||
rearrange
|
||||
@choices[pocket] = value if value<=@pockets[pocket].length
|
||||
@choices[pocket] = value if value <= @pockets[pocket].length
|
||||
end
|
||||
|
||||
def getAllChoices
|
||||
ret = @choices.clone
|
||||
for i in 0...@choices.length; @choices[i] = 0; end
|
||||
for i in 0...@choices.length
|
||||
@choices[i] = 0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -88,143 +88,98 @@ class PokemonBag
|
||||
end
|
||||
|
||||
def pbQuantity(item)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
pocket = pbGetPocket(item)
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length if maxsize<0
|
||||
return ItemStorageHelper.pbQuantity(@pockets[pocket],maxsize,item)
|
||||
item = GameData::Item.get(item)
|
||||
pocket = item.pocket
|
||||
return ItemStorageHelper.pbQuantity(@pockets[pocket], item.id)
|
||||
end
|
||||
|
||||
def pbHasItem?(item)
|
||||
return pbQuantity(item)>0
|
||||
return pbQuantity(item) > 0
|
||||
end
|
||||
|
||||
def pbCanStore?(item,qty=1)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
pocket = pbGetPocket(item)
|
||||
def pbCanStore?(item, qty = 1)
|
||||
item = GameData::Item.get(item)
|
||||
pocket = item.pocket
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length+1 if maxsize<0
|
||||
return ItemStorageHelper.pbCanStore?(@pockets[pocket],maxsize,
|
||||
BAG_MAX_PER_SLOT,item,qty)
|
||||
maxsize = @pockets[pocket].length + 1 if maxsize < 0
|
||||
return ItemStorageHelper.pbCanStore?(
|
||||
@pockets[pocket], maxsize, BAG_MAX_PER_SLOT, item.id, qty)
|
||||
end
|
||||
|
||||
def pbStoreAllOrNone(item,qty=1)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
pocket = pbGetPocket(item)
|
||||
def pbStoreItem(item, qty = 1)
|
||||
item = GameData::Item.get(item)
|
||||
pocket = item.pocket
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length+1 if maxsize<0
|
||||
return ItemStorageHelper.pbStoreAllOrNone(@pockets[pocket],maxsize,
|
||||
BAG_MAX_PER_SLOT,item,qty)
|
||||
maxsize = @pockets[pocket].length + 1 if maxsize < 0
|
||||
return ItemStorageHelper.pbStoreItem(
|
||||
@pockets[pocket], maxsize, BAG_MAX_PER_SLOT, item.id, qty, true)
|
||||
end
|
||||
|
||||
def pbStoreItem(item,qty=1)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
pocket = pbGetPocket(item)
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length+1 if maxsize<0
|
||||
return ItemStorageHelper.pbStoreItem(@pockets[pocket],maxsize,
|
||||
BAG_MAX_PER_SLOT,item,qty,true)
|
||||
def pbStoreAllOrNone(item, qty = 1)
|
||||
return false if !pbCanStore?(item, qty)
|
||||
return pbStoreItem(item, qty)
|
||||
end
|
||||
|
||||
def pbChangeItem(olditem,newitem)
|
||||
olditem = getID(PBItems,olditem)
|
||||
newitem = getID(PBItems,newitem)
|
||||
if !olditem || olditem<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",olditem))
|
||||
elsif !newitem || newitem<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",newitem))
|
||||
end
|
||||
pocket = pbGetPocket(olditem)
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length if maxsize<0
|
||||
def pbChangeItem(old_item, new_item)
|
||||
old_item = GameData::Item.get(old_item)
|
||||
new_item = GameData::Item.get(new_item)
|
||||
pocket = old_item.pocket
|
||||
ret = false
|
||||
for i in 0...maxsize
|
||||
itemslot = @pockets[pocket][i]
|
||||
if itemslot && itemslot[0]==olditem
|
||||
itemslot[0] = newitem
|
||||
ret = true
|
||||
end
|
||||
@pockets[pocket].each do |item|
|
||||
next if !item || item[0] != old_item.id
|
||||
item[0] = new_item.id
|
||||
ret = true
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChangeQuantity(pocket,index,newqty=1)
|
||||
return false if pocket<=0 || pocket>self.numPockets
|
||||
return false if @pockets[pocket].length<index
|
||||
newqty = [newqty,maxPocketSize(pocket)].min
|
||||
def pbChangeQuantity(pocket, index, newqty = 1)
|
||||
return false if pocket <= 0 || pocket > self.numPockets
|
||||
return false if !@pockets[pocket][index]
|
||||
newqty = [newqty, maxPocketSize(pocket)].min
|
||||
@pockets[pocket][index][1] = newqty
|
||||
return true
|
||||
end
|
||||
|
||||
def pbDeleteItem(item,qty=1)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
pocket = pbGetPocket(item)
|
||||
maxsize = maxPocketSize(pocket)
|
||||
maxsize = @pockets[pocket].length if maxsize<0
|
||||
ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty)
|
||||
def pbDeleteItem(item, qty = 1)
|
||||
item = GameData::Item.get(item)
|
||||
pocket = item.pocket
|
||||
ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket], item.id, qty)
|
||||
return ret
|
||||
end
|
||||
|
||||
def registeredItems
|
||||
@registeredItems = [] if !@registeredItems
|
||||
if @registeredItem && @registeredItem>0 && !@registeredItems.include?(@registeredItem)
|
||||
@registeredItems.push(@registeredItem)
|
||||
@registeredItem = nil
|
||||
end
|
||||
return @registeredItems
|
||||
end
|
||||
|
||||
def registeredItem; return registeredItems; end
|
||||
|
||||
def pbIsRegistered?(item)
|
||||
item = GameData::Item.get(item).id
|
||||
registeredlist = self.registeredItems
|
||||
return registeredlist.include?(item)
|
||||
end
|
||||
|
||||
# Registers the item in the Ready Menu.
|
||||
def pbRegisterItem(item)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
item = GameData::Item.get(item).id
|
||||
registeredlist = self.registeredItems
|
||||
registeredlist.push(item) if !registeredlist.include?(item)
|
||||
end
|
||||
|
||||
# Unregisters the item from the Ready Menu.
|
||||
def pbUnregisterItem(item)
|
||||
item = getID(PBItems,item)
|
||||
if !item || item<1
|
||||
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
|
||||
end
|
||||
item = GameData::Item.get(item).id
|
||||
registeredlist = self.registeredItems
|
||||
if registeredlist.include?(item)
|
||||
for i in 0...registeredlist.length
|
||||
next if registeredlist[i]!=item
|
||||
registeredlist[i] = nil
|
||||
break
|
||||
end
|
||||
registeredlist.compact!
|
||||
for i in 0...registeredlist.length
|
||||
next if registeredlist[i] != item
|
||||
registeredlist[i] = nil
|
||||
break
|
||||
end
|
||||
registeredlist.compact!
|
||||
end
|
||||
|
||||
def registeredIndex
|
||||
@registeredIndex = [0,0,1] if !@registeredIndex
|
||||
@registeredIndex = [0, 0, 1] if !@registeredIndex
|
||||
return @registeredIndex
|
||||
end
|
||||
end
|
||||
@@ -235,25 +190,25 @@ end
|
||||
# The PC item storage object, which actually contains all the items
|
||||
#===============================================================================
|
||||
class PCItemStorage
|
||||
MAXSIZE = 50 # Number of different slots in storage
|
||||
MAXPERSLOT = 999 # Max. number of items per slot
|
||||
MAX_SIZE = 999 # Number of different slots in storage
|
||||
MAX_PER_SLOT = 999 # Max. number of items per slot
|
||||
|
||||
def initialize
|
||||
@items = []
|
||||
# Start storage with a Potion
|
||||
pbStoreItem(getConst(PBItems,:POTION)) if hasConst?(PBItems,:POTION)
|
||||
pbStoreItem(:POTION) if GameData::Item.exists?(:POTION)
|
||||
end
|
||||
|
||||
def [](i)
|
||||
@items[i]
|
||||
return @items[i]
|
||||
end
|
||||
|
||||
def length
|
||||
@items.length
|
||||
return @items.length
|
||||
end
|
||||
|
||||
def empty?
|
||||
return @items.length==0
|
||||
return @items.length == 0
|
||||
end
|
||||
|
||||
def clear
|
||||
@@ -261,27 +216,31 @@ class PCItemStorage
|
||||
end
|
||||
|
||||
def getItem(index)
|
||||
return (index<0 || index>=@items.length) ? 0 : @items[index][0]
|
||||
return (index < 0 || index >= @items.length) ? nil : @items[index][0]
|
||||
end
|
||||
|
||||
def getCount(index)
|
||||
return (index<0 || index>=@items.length) ? 0 : @items[index][1]
|
||||
return (index < 0 || index >= @items.length) ? 0 : @items[index][1]
|
||||
end
|
||||
|
||||
def pbQuantity(item)
|
||||
return ItemStorageHelper.pbQuantity(@items,MAXSIZE,item)
|
||||
item = GameData::Item.get(item).id
|
||||
return ItemStorageHelper.pbQuantity(@items, item)
|
||||
end
|
||||
|
||||
def pbCanStore?(item,qty=1)
|
||||
return ItemStorageHelper.pbCanStore?(@items,MAXSIZE,MAXPERSLOT,item,qty)
|
||||
def pbCanStore?(item, qty = 1)
|
||||
item = GameData::Item.get(item).id
|
||||
return ItemStorageHelper.pbCanStore?(@items, MAX_SIZE, MAX_PER_SLOT, item, qty)
|
||||
end
|
||||
|
||||
def pbStoreItem(item,qty=1)
|
||||
return ItemStorageHelper.pbStoreItem(@items,MAXSIZE,MAXPERSLOT,item,qty)
|
||||
def pbStoreItem(item, qty = 1)
|
||||
item = GameData::Item.get(item).id
|
||||
return ItemStorageHelper.pbStoreItem(@items, MAX_SIZE, MAX_PER_SLOT, item, qty)
|
||||
end
|
||||
|
||||
def pbDeleteItem(item,qty=1)
|
||||
return ItemStorageHelper.pbDeleteItem(@items,MAXSIZE,item,qty)
|
||||
def pbDeleteItem(item, qty = 1)
|
||||
item = GameData::Item.get(item).id
|
||||
return ItemStorageHelper.pbDeleteItem(@items, item, qty)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -293,30 +252,26 @@ end
|
||||
# Used by the Bag, PC item storage, and Triple Triad.
|
||||
#===============================================================================
|
||||
module ItemStorageHelper
|
||||
# Returns the quantity of the given item in the items array, maximum size per
|
||||
# slot, and item ID
|
||||
def self.pbQuantity(items,maxsize,item)
|
||||
# Returns the quantity of check_item in item_array
|
||||
def self.pbQuantity(item_array, check_item)
|
||||
ret = 0
|
||||
for i in 0...maxsize
|
||||
itemslot = items[i]
|
||||
ret += itemslot[1] if itemslot && itemslot[0]==item
|
||||
end
|
||||
item_array.each { |i| ret += i[1] if i && i[0] == check_item }
|
||||
return ret
|
||||
end
|
||||
|
||||
# Deletes an item (items array, max. size per slot, item, no. of items to delete)
|
||||
def self.pbDeleteItem(items,maxsize,item,qty)
|
||||
raise "Invalid value for qty: #{qty}" if qty<0
|
||||
return true if qty==0
|
||||
def self.pbDeleteItem(items, item, qty)
|
||||
raise "Invalid value for qty: #{qty}" if qty < 0
|
||||
return true if qty == 0
|
||||
ret = false
|
||||
for i in 0...maxsize
|
||||
for i in 0...items.length
|
||||
itemslot = items[i]
|
||||
next if !itemslot || itemslot[0]!=item
|
||||
amount = [qty,itemslot[1]].min
|
||||
next if !itemslot || itemslot[0] != item
|
||||
amount = [qty, itemslot[1]].min
|
||||
itemslot[1] -= amount
|
||||
qty -= amount
|
||||
items[i] = nil if itemslot[1]==0
|
||||
next if qty>0
|
||||
items[i] = nil if itemslot[1] == 0
|
||||
next if qty > 0
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
@@ -324,41 +279,44 @@ module ItemStorageHelper
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.pbCanStore?(items,maxsize,maxPerSlot,item,qty)
|
||||
raise "Invalid value for qty: #{qty}" if qty<0
|
||||
return true if qty==0
|
||||
def self.pbCanStore?(items, maxsize, maxPerSlot, item, qty)
|
||||
raise "Invalid value for qty: #{qty}" if qty < 0
|
||||
return true if qty == 0
|
||||
for i in 0...maxsize
|
||||
itemslot = items[i]
|
||||
if !itemslot
|
||||
qty -= [qty,maxPerSlot].min
|
||||
return true if qty==0
|
||||
elsif itemslot[0]==item && itemslot[1]<maxPerSlot
|
||||
qty -= [qty, maxPerSlot].min
|
||||
return true if qty == 0
|
||||
elsif itemslot[0] == item && itemslot[1] < maxPerSlot
|
||||
newamt = itemslot[1]
|
||||
newamt = [newamt+qty,maxPerSlot].min
|
||||
qty -= (newamt-itemslot[1])
|
||||
return true if qty==0
|
||||
newamt = [newamt + qty, maxPerSlot].min
|
||||
qty -= (newamt - itemslot[1])
|
||||
return true if qty == 0
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def self.pbStoreItem(items,maxsize,maxPerSlot,item,qty,sorting=false)
|
||||
raise "Invalid value for qty: #{qty}" if qty<0
|
||||
return true if qty==0
|
||||
itemPocket = pbGetPocket(item)
|
||||
def self.pbStoreItem(items, maxsize, maxPerSlot, item, qty, sorting = false)
|
||||
raise "Invalid value for qty: #{qty}" if qty < 0
|
||||
return true if qty == 0
|
||||
itm = GameData::Item.try_get(item)
|
||||
itemPocket = (itm) ? itm.pocket : 0
|
||||
for i in 0...maxsize
|
||||
itemslot = items[i]
|
||||
if !itemslot
|
||||
items[i] = [item,[qty,maxPerSlot].min]
|
||||
items[i] = [item, [qty, maxPerSlot].min]
|
||||
qty -= items[i][1]
|
||||
items.sort! if sorting && BAG_POCKET_AUTO_SORT[itemPocket]
|
||||
return true if qty==0
|
||||
elsif itemslot[0]==item && itemslot[1]<maxPerSlot
|
||||
if itemPocket > 0 && sorting && BAG_POCKET_AUTO_SORT[itemPocket]
|
||||
items.sort! { |a, b| GameData::Item.get(a[0]).id_number <=> GameData::Item.get(b[0]).id_number }
|
||||
end
|
||||
return true if qty == 0
|
||||
elsif itemslot[0] == item && itemslot[1] < maxPerSlot
|
||||
newamt = itemslot[1]
|
||||
newamt = [newamt+qty,maxPerSlot].min
|
||||
qty -= (newamt-itemslot[1])
|
||||
newamt = [newamt + qty, maxPerSlot].min
|
||||
qty -= (newamt - itemslot[1])
|
||||
itemslot[1] = newamt
|
||||
return true if qty==0
|
||||
return true if qty == 0
|
||||
end
|
||||
end
|
||||
return false
|
||||
|
||||
@@ -46,8 +46,8 @@ class Pokemon
|
||||
attr_accessor :moves
|
||||
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
|
||||
attr_accessor :firstmoves
|
||||
# @return [Integer] the ID of the item held by this Pokémon (0 = no held item)
|
||||
attr_accessor :item
|
||||
# @return [Symbol] the ID of the item held by this Pokémon (nil = no held item)
|
||||
attr_accessor :item_id
|
||||
# @return [Integer] this Pokémon's current status (from PBStatuses)
|
||||
attr_reader :status
|
||||
# @return [Integer] sleep count / toxic flag / 0:
|
||||
@@ -279,13 +279,13 @@ class Pokemon
|
||||
return @abilityflag || (@personalID & 1)
|
||||
end
|
||||
|
||||
# @return [PokemonData::Ability] an Ability object corresponding to this Pokémon's ability
|
||||
# @return [GameData::Ability, nil] an Ability object corresponding to this Pokémon's ability
|
||||
def ability
|
||||
ret = ability_id
|
||||
return PokemonData::Ability.try_get(ret)
|
||||
return GameData::Ability.try_get(ret)
|
||||
end
|
||||
|
||||
# @return [Symbol] the ability symbol of this Pokémon's ability
|
||||
# @return [Symbol, nil] the ability symbol of this Pokémon's ability
|
||||
def ability_id
|
||||
abilIndex = abilityIndex
|
||||
# Hidden ability
|
||||
@@ -293,9 +293,9 @@ class Pokemon
|
||||
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
|
||||
if hiddenAbil.is_a?(Array)
|
||||
ret = hiddenAbil[abilIndex - 2]
|
||||
return ret if PokemonData::Ability.exists?(ret)
|
||||
return ret if GameData::Ability.exists?(ret)
|
||||
elsif abilIndex == 2
|
||||
return hiddenAbil if PokemonData::Ability.exists?(hiddenAbil)
|
||||
return hiddenAbil if GameData::Ability.exists?(hiddenAbil)
|
||||
end
|
||||
abilIndex = (@personalID & 1)
|
||||
end
|
||||
@@ -303,7 +303,7 @@ class Pokemon
|
||||
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
|
||||
if abilities.is_a?(Array)
|
||||
ret = abilities[abilIndex]
|
||||
ret = abilities[(abilIndex + 1) % 2] if !PokemonData::Ability.exists?(ret)
|
||||
ret = abilities[(abilIndex + 1) % 2] if !GameData::Ability.exists?(ret)
|
||||
return ret
|
||||
end
|
||||
return abilities
|
||||
@@ -311,7 +311,7 @@ class Pokemon
|
||||
|
||||
# Returns whether this Pokémon has a particular ability. If no value
|
||||
# is given, returns whether this Pokémon has an ability set.
|
||||
# @param ability [Integer] ability ID to check
|
||||
# @param check_ability [Symbol, GameData::Ability, Integer] ability ID to check
|
||||
# @return [Boolean] whether this Pokémon has a particular ability or
|
||||
# an ability at all
|
||||
def hasAbility?(check_ability = nil)
|
||||
@@ -727,21 +727,29 @@ class Pokemon
|
||||
# Items
|
||||
#=============================================================================
|
||||
|
||||
# @return [GameData::Item, nil] an Item object corresponding to this Pokémon's item
|
||||
def item
|
||||
ret = @item_id
|
||||
return GameData::Item.try_get(ret)
|
||||
end
|
||||
|
||||
# Returns whether this Pokémon is holding an item. If an item id is passed,
|
||||
# returns whether the Pokémon is holding that item.
|
||||
# @param item_id [Integer, Symbol, String] id of the item to check
|
||||
# @param check_item [Symbol, GameData::Item, Integer] item ID to check
|
||||
# @return [Boolean] whether the Pokémon is holding the specified item or
|
||||
# an item at all
|
||||
def hasItem?(item_id = 0)
|
||||
held_item = self.item
|
||||
return held_item > 0 if item_id == 0
|
||||
return held_item == getID(PBItems, item_id)
|
||||
def hasItem?(check_item = nil)
|
||||
current_item = self.item
|
||||
return !current_item.nil? if check_item.nil?
|
||||
return current_item == check_item
|
||||
end
|
||||
|
||||
# Gives an item to this Pokémon. Passing 0 as the argument removes the held item.
|
||||
# @param item_id [Integer, Symbol, String] id of the item to give to this Pokémon (0 removes held item)
|
||||
def setItem(item_id)
|
||||
self.item = getID(PBItems, item_id) || 0
|
||||
# @param value [Symbol, GameData::Item, Integer] id of the item to give to this
|
||||
# Pokémon (a non-valid value sets it to nil)
|
||||
def setItem(value)
|
||||
new_item = GameData::Item.try_get(value)
|
||||
@item_id = (new_item) ? new_item.id : nil
|
||||
end
|
||||
|
||||
# @return [Array<Integer>] the items this species can be found holding in the wild
|
||||
@@ -756,7 +764,7 @@ class Pokemon
|
||||
# @return [PokemonMail, nil] mail held by this Pokémon (nil if there is none)
|
||||
def mail
|
||||
return nil if !@mail
|
||||
@mail = nil if @mail.item == 0 || !hasItem?(@mail.item)
|
||||
@mail = nil if !@mail.item || !hasItem?(@mail.item)
|
||||
return @mail
|
||||
end
|
||||
|
||||
@@ -1075,7 +1083,7 @@ class Pokemon
|
||||
@moves = []
|
||||
@status = PBStatuses::NONE
|
||||
@statusCount = 0
|
||||
@item = 0
|
||||
@item_id = nil
|
||||
@mail = nil
|
||||
@fused = nil
|
||||
@ribbons = []
|
||||
|
||||
@@ -11,8 +11,8 @@ class Pokemon
|
||||
for i in 0...formData[@species].length
|
||||
fSpec = formData[@species][i]
|
||||
next if !fSpec || fSpec<=0
|
||||
megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE] || 0
|
||||
if megaStone>0 && self.hasItem?(megaStone)
|
||||
megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE]
|
||||
if megaStone && self.hasItem?(megaStone)
|
||||
ret = i; break
|
||||
end
|
||||
if !checkItemOnly
|
||||
|
||||
@@ -350,10 +350,7 @@ class PokeBattle_Battle
|
||||
|
||||
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true)
|
||||
ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages)
|
||||
if ret && pkmn.hypermode &&
|
||||
!isConst?(item,PBItems,:JOYSCENT) &&
|
||||
!isConst?(item,PBItems,:EXCITESCENT) &&
|
||||
!isConst?(item,PBItems,:VIVIDSCENT)
|
||||
if ret && pkmn.hypermode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
|
||||
scene.pbDisplay(_INTL("This item can't be used on that Pokémon."))
|
||||
return false
|
||||
end
|
||||
@@ -477,21 +474,21 @@ ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT)
|
||||
ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-500)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-1000)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-2000)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
|
||||
@@ -149,21 +149,21 @@ def pbGetPreviousForm(species) # Unused
|
||||
return species
|
||||
end
|
||||
|
||||
def pbGetBabySpecies(species,item1=-1,item2=-1)
|
||||
def pbGetBabySpecies(species, check_items = false, item1 = nil, item2 = nil)
|
||||
ret = species
|
||||
evoData = pbGetEvolutionData(species)
|
||||
return ret if !evoData || evoData.length==0
|
||||
return ret if !evoData || evoData.length == 0
|
||||
evoData.each do |evo|
|
||||
next if !evo[3]
|
||||
if item1>=0 && item2>=0
|
||||
incense = pbGetSpeciesData(evo[0],0,SpeciesData::INCENSE)
|
||||
ret = evo[0] if item1==incense || item2==incense
|
||||
next if !evo[3] # Not the prevolution
|
||||
if check_items
|
||||
incense = pbGetSpeciesData(evo[0], 0, SpeciesData::INCENSE)
|
||||
ret = evo[0] if !incense || item1 == incense || item2 == incense
|
||||
else
|
||||
ret = evo[0] # Species of prevolution
|
||||
end
|
||||
break
|
||||
end
|
||||
ret = pbGetBabySpecies(ret) if ret!=species
|
||||
ret = pbGetBabySpecies(ret) if ret != species
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -194,8 +194,6 @@ def pbGetEvolutionFamilyData(species)
|
||||
return ret
|
||||
end
|
||||
|
||||
# Used by the Moon Ball when checking if a Pokémon's evolution family includes
|
||||
# an evolution that uses the Moon Stone.
|
||||
def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
|
||||
species = pbGetBabySpecies(species)
|
||||
evos = pbGetEvolutionFamilyData(species)
|
||||
@@ -203,7 +201,7 @@ def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
|
||||
for evo in evos
|
||||
if method.is_a?(Array)
|
||||
next if !method.include?(evo[1])
|
||||
elsif method>=0
|
||||
elsif method >= 0
|
||||
next if evo[1] != method
|
||||
end
|
||||
next if param >= 0 && evo[2] != param
|
||||
@@ -214,13 +212,13 @@ end
|
||||
|
||||
# Used by the Moon Ball when checking if a Pokémon's evolution family includes
|
||||
# an evolution that uses the Moon Stone.
|
||||
def pbCheckEvolutionFamilyForItemMethodItem(species, param = -1)
|
||||
def pbCheckEvolutionFamilyForItemMethodItem(species, param = nil)
|
||||
species = pbGetBabySpecies(species)
|
||||
evos = pbGetEvolutionFamilyData(species)
|
||||
return false if !evos || evos.length == 0
|
||||
for evo in evos
|
||||
next if !PBEvolution.hasFunction?(evo[1], "itemCheck")
|
||||
next if param >= 0 && evo[2] != param
|
||||
next if param && evo[2] != param
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@@ -270,14 +268,14 @@ end
|
||||
|
||||
# Checks whether a Pokemon can evolve now. If an item is used on the Pokémon,
|
||||
# checks whether the Pokemon can evolve with the given item.
|
||||
def pbCheckEvolution(pokemon,item=0)
|
||||
if item==0
|
||||
def pbCheckEvolution(pokemon,item=nil)
|
||||
if item
|
||||
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
|
||||
next pbMiniCheckEvolution(pokemon,evonib,level,poke)
|
||||
next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
|
||||
}
|
||||
else
|
||||
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
|
||||
next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
|
||||
next pbMiniCheckEvolution(pokemon,evonib,level,poke)
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -446,9 +444,9 @@ PBEvolution.register(:Shedinja, {
|
||||
"parameterType" => nil,
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if $Trainer.party.length>=6
|
||||
next false if !$PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL))
|
||||
next false if !$PokemonBag.pbHasItem?(:POKEBALL)
|
||||
PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species)
|
||||
$PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
|
||||
$PokemonBag.pbDeleteItem(:POKEBALL)
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -515,13 +513,13 @@ PBEvolution.register(:HappinessMoveType, {
|
||||
|
||||
PBEvolution.register(:HappinessHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.happiness >= 220
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -543,78 +541,78 @@ PBEvolution.register(:Beauty, { # Feebas
|
||||
|
||||
PBEvolution.register(:HoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemMale, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.male?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemFemale, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.female?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:DayHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && PBDayNight.isDay?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:NightHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && PBDayNight.isNight?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemHappiness, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.happiness >= 220
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -662,42 +660,42 @@ PBEvolution.register(:Region, {
|
||||
# Evolution methods that trigger when using an item on the Pokémon
|
||||
#===============================================================================
|
||||
PBEvolution.register(:Item, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemMale, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.male?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemFemale, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.female?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemDay, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && PBDayNight.isDay?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemNight, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && PBDayNight.isNight?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemHappiness, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.happiness >= 220
|
||||
}
|
||||
@@ -742,13 +740,13 @@ PBEvolution.register(:TradeNight, {
|
||||
})
|
||||
|
||||
PBEvolution.register(:TradeItem, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"tradeCheck" => proc { |pkmn, parameter, other_pkmn|
|
||||
next pkmn.item == parameter
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
@@ -184,14 +184,14 @@ class PokemonPauseMenu
|
||||
return
|
||||
end
|
||||
elsif cmdBag>=0 && command==cmdBag
|
||||
item = 0
|
||||
item = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
item = screen.pbStartScreen
|
||||
(item>0) ? @scene.pbEndScene : @scene.pbRefresh
|
||||
(item) ? @scene.pbEndScene : @scene.pbRefresh
|
||||
}
|
||||
if item>0
|
||||
if item
|
||||
$game_temp.in_menu = false
|
||||
pbUseKeyItemInField(item)
|
||||
return
|
||||
|
||||
@@ -642,25 +642,26 @@ class PokemonParty_Scene
|
||||
end
|
||||
|
||||
def pbChooseItem(bag)
|
||||
ret = 0
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,bag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| pbCanHoldItem?(item) })
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? })
|
||||
yield if block_given?
|
||||
}
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbUseItem(bag,pokemon)
|
||||
ret = 0
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,bag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item|
|
||||
next false if !pbCanUseOnPokemon?(item)
|
||||
if pbIsMachine?(item)
|
||||
move = pbGetMachine(item)
|
||||
itm = GameData::Item.get(item)
|
||||
next false if !pbCanUseOnPokemon?(itm)
|
||||
if itm.is_machine?
|
||||
move = itm.move
|
||||
next false if pokemon.hasMove?(move) || !pokemon.compatibleWithMove?(move)
|
||||
end
|
||||
next true
|
||||
@@ -1250,14 +1251,15 @@ class PokemonPartyScreen
|
||||
itemcommands[cmdUseItem=itemcommands.length] = _INTL("Use")
|
||||
itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give")
|
||||
itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem?
|
||||
itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
|
||||
itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? &&
|
||||
!GameData::Item.get(pkmn.item).is_mail?
|
||||
itemcommands[itemcommands.length] = _INTL("Cancel")
|
||||
command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands)
|
||||
if cmdUseItem>=0 && command==cmdUseItem # Use
|
||||
item = @scene.pbUseItem($PokemonBag,pkmn) {
|
||||
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
|
||||
}
|
||||
if item>0
|
||||
if item
|
||||
pbUseItemOnPokemon(item,pkmn,self)
|
||||
pbRefreshSingle(pkmnid)
|
||||
end
|
||||
@@ -1265,7 +1267,7 @@ class PokemonPartyScreen
|
||||
item = @scene.pbChooseItem($PokemonBag) {
|
||||
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
|
||||
}
|
||||
if item>0
|
||||
if item
|
||||
if pbGiveItemToPokemon(item,pkmn,self,pkmnid)
|
||||
pbRefreshSingle(pkmnid)
|
||||
end
|
||||
@@ -1276,7 +1278,7 @@ class PokemonPartyScreen
|
||||
end
|
||||
elsif cmdMoveItem>=0 && command==cmdMoveItem # Move
|
||||
item = pkmn.item
|
||||
itemname = PBItems.getName(item)
|
||||
itemname = item.name
|
||||
@scene.pbSetHelpText(_INTL("Move {1} to where?",itemname))
|
||||
oldpkmnid = pkmnid
|
||||
loop do
|
||||
@@ -1284,23 +1286,22 @@ class PokemonPartyScreen
|
||||
pkmnid = @scene.pbChoosePokemon(true,pkmnid)
|
||||
break if pkmnid<0
|
||||
newpkmn = @party[pkmnid]
|
||||
if pkmnid==oldpkmnid
|
||||
break
|
||||
elsif newpkmn.egg?
|
||||
break if pkmnid==oldpkmnid
|
||||
if newpkmn.egg?
|
||||
pbDisplay(_INTL("Eggs can't hold items."))
|
||||
elsif !newpkmn.hasItem?
|
||||
newpkmn.setItem(item)
|
||||
pkmn.setItem(0)
|
||||
pkmn.setItem(nil)
|
||||
@scene.pbClearSwitching
|
||||
pbRefresh
|
||||
pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
|
||||
break
|
||||
elsif pbIsMail?(newpkmn.item)
|
||||
elsif GameData::Item.get(newpkmn.item).is_mail?
|
||||
pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name))
|
||||
else
|
||||
newitem = newpkmn.item
|
||||
newitemname = PBItems.getName(newitem)
|
||||
if isConst?(newitem,PBItems,:LEFTOVERS)
|
||||
newitemname = newitem.name
|
||||
if newitem == :LEFTOVERS
|
||||
pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname))
|
||||
elsif newitemname.starts_with_vowel?
|
||||
pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname))
|
||||
|
||||
@@ -123,7 +123,7 @@ class PokemonSummary_Scene
|
||||
@sprites["pokeicon"].x = 46
|
||||
@sprites["pokeicon"].y = 92
|
||||
@sprites["pokeicon"].visible = false
|
||||
@sprites["itemicon"] = ItemIconSprite.new(30,320,@pokemon.item,@viewport)
|
||||
@sprites["itemicon"] = ItemIconSprite.new(30,320,@pokemon.item_id,@viewport)
|
||||
@sprites["itemicon"].blankzero = true
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@@ -287,7 +287,7 @@ class PokemonSummary_Scene
|
||||
if @pokemon.egg?
|
||||
drawPageOneEgg; return
|
||||
end
|
||||
@sprites["itemicon"].item = @pokemon.item
|
||||
@sprites["itemicon"].item = @pokemon.item_id
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
base = Color.new(248,248,248)
|
||||
@@ -330,7 +330,7 @@ class PokemonSummary_Scene
|
||||
]
|
||||
# Write the held item's name
|
||||
if @pokemon.hasItem?
|
||||
textpos.push([PBItems.getName(@pokemon.item),16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
textpos.push([@pokemon.item.name,16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
else
|
||||
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
|
||||
end
|
||||
@@ -454,7 +454,7 @@ class PokemonSummary_Scene
|
||||
end
|
||||
|
||||
def drawPageOneEgg
|
||||
@sprites["itemicon"].item = @pokemon.item
|
||||
@sprites["itemicon"].item = @pokemon.item_id
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
base = Color.new(248,248,248)
|
||||
@@ -475,7 +475,7 @@ class PokemonSummary_Scene
|
||||
]
|
||||
# Write the held item's name
|
||||
if @pokemon.hasItem?
|
||||
textpos.push([PBItems.getName(@pokemon.item),16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
textpos.push([@pokemon.item.name,16,352,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
else
|
||||
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
|
||||
end
|
||||
@@ -892,7 +892,7 @@ class PokemonSummary_Scene
|
||||
def pbChangePokemon
|
||||
@pokemon = @party[@partyindex]
|
||||
@sprites["pokemon"].setPokemonBitmap(@pokemon)
|
||||
@sprites["itemicon"].item = @pokemon.item
|
||||
@sprites["itemicon"].item = @pokemon.item_id
|
||||
pbSEStop
|
||||
pbPlayCry(@pokemon)
|
||||
end
|
||||
@@ -1169,13 +1169,13 @@ class PokemonSummary_Scene
|
||||
commands[commands.length] = _INTL("Cancel")
|
||||
command = pbShowCommands(commands)
|
||||
if cmdGiveItem>=0 && command==cmdGiveItem
|
||||
item = 0
|
||||
item = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
item = screen.pbChooseItemScreen(Proc.new { |itm| pbCanHoldItem?(itm) })
|
||||
item = screen.pbChooseItemScreen(Proc.new { |itm| GameData::Item.get(itm).can_hold? })
|
||||
}
|
||||
if item>0
|
||||
if item
|
||||
dorefresh = pbGiveItemToPokemon(item,@pokemon,self,@partyindex)
|
||||
end
|
||||
elsif cmdTakeItem>=0 && command==cmdTakeItem
|
||||
|
||||
@@ -29,10 +29,10 @@ class Window_PokemonBag < Window_DrawableCommand
|
||||
def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end
|
||||
|
||||
def item
|
||||
return 0 if @filterlist && !@filterlist[@pocket][self.index]
|
||||
return nil if @filterlist && !@filterlist[@pocket][self.index]
|
||||
thispocket = @bag.pockets[@pocket]
|
||||
item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index]
|
||||
return (item) ? item[0] : 0
|
||||
return (item) ? item[0] : nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
@@ -76,13 +76,7 @@ class Window_PokemonBag < Window_DrawableCommand
|
||||
textpos.push(
|
||||
[@adapter.getDisplayName(item),rect.x,ypos,false,baseColor,shadowColor]
|
||||
)
|
||||
if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM)
|
||||
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
|
||||
qtytext = _ISPRINTF("x{1: 3d}",qty)
|
||||
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
|
||||
textpos.push([qtytext,xQty,ypos,false,baseColor,shadowColor])
|
||||
end
|
||||
if pbIsImportantItem?(item)
|
||||
if GameData::Item.get(item).is_important?
|
||||
if @bag.pbIsRegistered?(item)
|
||||
pbDrawImagePositions(self.contents,[
|
||||
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,0,-1,24]
|
||||
@@ -92,6 +86,11 @@ class Window_PokemonBag < Window_DrawableCommand
|
||||
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,24,-1,24]
|
||||
])
|
||||
end
|
||||
else
|
||||
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
|
||||
qtytext = _ISPRINTF("x{1: 3d}",qty)
|
||||
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
|
||||
textpos.push([qtytext,xQty,ypos,false,baseColor,shadowColor])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(self.contents,textpos)
|
||||
@@ -195,7 +194,7 @@ class PokemonBag_Scene
|
||||
@sprites["itemlist"].index = @bag.getChoice(lastpocket)
|
||||
@sprites["itemlist"].baseColor = ITEMLISTBASECOLOR
|
||||
@sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR
|
||||
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,-1,@viewport)
|
||||
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport)
|
||||
@sprites["itemtext"] = Window_UnformattedTextPokemon.new("")
|
||||
@sprites["itemtext"].x = 72
|
||||
@sprites["itemtext"].y = 270
|
||||
@@ -318,8 +317,9 @@ class PokemonBag_Scene
|
||||
# Set the selected item's icon
|
||||
@sprites["itemicon"].item = itemlist.item
|
||||
# Set the selected item's description
|
||||
@sprites["itemtext"].text = (itemlist.item==0) ? _INTL("Close bag.") :
|
||||
pbGetMessage(MessageTypes::ItemDescriptions,itemlist.item)
|
||||
@sprites["itemtext"].text =
|
||||
(itemlist.item) ? GameData::Item.get(itemlist.item).description : _INTL("Close bag.")
|
||||
|
||||
end
|
||||
|
||||
def pbRefreshFilter
|
||||
@@ -379,8 +379,10 @@ class PokemonBag_Scene
|
||||
loop do
|
||||
newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
|
||||
break if !@choosing || newpocket==itemwindow.pocket
|
||||
if @filterlist; break if @filterlist[newpocket].length>0
|
||||
else; break if @bag.pockets[newpocket].length>0
|
||||
if @filterlist
|
||||
break if @filterlist[newpocket].length>0
|
||||
else
|
||||
break if @bag.pockets[newpocket].length>0
|
||||
end
|
||||
end
|
||||
if itemwindow.pocket!=newpocket
|
||||
@@ -395,8 +397,10 @@ class PokemonBag_Scene
|
||||
loop do
|
||||
newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
|
||||
break if !@choosing || newpocket==itemwindow.pocket
|
||||
if @filterlist; break if @filterlist[newpocket].length>0
|
||||
else; break if @bag.pockets[newpocket].length>0
|
||||
if @filterlist
|
||||
break if @filterlist[newpocket].length>0
|
||||
else
|
||||
break if @bag.pockets[newpocket].length>0
|
||||
end
|
||||
end
|
||||
if itemwindow.pocket!=newpocket
|
||||
@@ -428,9 +432,9 @@ class PokemonBag_Scene
|
||||
end
|
||||
elsif Input.trigger?(Input::B) # Cancel the item screen
|
||||
pbPlayCloseMenuSE
|
||||
return 0
|
||||
return nil
|
||||
elsif Input.trigger?(Input::C) # Choose selected item
|
||||
(itemwindow.item==0) ? pbPlayCloseMenuSE : pbPlayDecisionSE
|
||||
(itemwindow.item) ? pbPlayDecisionSE : pbPlayCloseMenuSE
|
||||
return itemwindow.item
|
||||
end
|
||||
end
|
||||
@@ -452,10 +456,11 @@ class PokemonBagScreen
|
||||
|
||||
def pbStartScreen
|
||||
@scene.pbStartScene(@bag)
|
||||
item = 0
|
||||
item = nil
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if item==0
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
cmdRead = -1
|
||||
cmdUse = -1
|
||||
cmdRegister = -1
|
||||
@@ -464,16 +469,16 @@ class PokemonBagScreen
|
||||
cmdDebug = -1
|
||||
commands = []
|
||||
# Generate command list
|
||||
commands[cmdRead = commands.length] = _INTL("Read") if pbIsMail?(item)
|
||||
if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0)
|
||||
commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail?
|
||||
if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $Trainer.party.length>0)
|
||||
if ItemHandlers.hasUseText(item)
|
||||
commands[cmdUse = commands.length] = ItemHandlers.getUseText(item)
|
||||
else
|
||||
commands[cmdUse = commands.length] = _INTL("Use")
|
||||
end
|
||||
end
|
||||
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && pbCanHoldItem?(item)
|
||||
commands[cmdToss = commands.length] = _INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG
|
||||
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && itm.can_hold?
|
||||
commands[cmdToss = commands.length] = _INTL("Toss") if !itm.is_important? || $DEBUG
|
||||
if @bag.pbIsRegistered?(item)
|
||||
commands[cmdRegister = commands.length] = _INTL("Deselect")
|
||||
elsif pbCanRegisterItem?(item)
|
||||
@@ -482,7 +487,7 @@ class PokemonBagScreen
|
||||
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
|
||||
commands[commands.length] = _INTL("Cancel")
|
||||
# Show commands generated above
|
||||
itemname = PBItems.getName(item)
|
||||
itemname = itm.name
|
||||
command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
|
||||
if cmdRead>=0 && command==cmdRead # Read mail
|
||||
pbFadeOutIn {
|
||||
@@ -497,7 +502,7 @@ class PokemonBagScreen
|
||||
elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
|
||||
if $Trainer.pokemonCount==0
|
||||
@scene.pbDisplay(_INTL("There is no Pokémon."))
|
||||
elsif pbIsImportantItem?(item)
|
||||
elsif itm.is_important?
|
||||
@scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
|
||||
else
|
||||
pbFadeOutIn {
|
||||
@@ -510,11 +515,11 @@ class PokemonBagScreen
|
||||
elsif cmdToss>=0 && command==cmdToss # Toss item
|
||||
qty = @bag.pbQuantity(item)
|
||||
if qty>1
|
||||
helptext = _INTL("Toss out how many {1}?",PBItems.getNamePlural(item))
|
||||
helptext = _INTL("Toss out how many {1}?",itm.name_plural)
|
||||
qty = @scene.pbChooseNumber(helptext,qty)
|
||||
end
|
||||
if qty>0
|
||||
itemname = PBItems.getNamePlural(item) if qty>1
|
||||
itemname = itm.name_plural if qty>1
|
||||
if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
|
||||
pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
|
||||
qty.times { @bag.pbDeleteItem(item) }
|
||||
@@ -543,7 +548,7 @@ class PokemonBagScreen
|
||||
### Change quantity ###
|
||||
when 0
|
||||
qty = @bag.pbQuantity(item)
|
||||
itemplural = PBItems.getNamePlural(item)
|
||||
itemplural = itm.name_plural
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0,BAG_MAX_PER_SLOT)
|
||||
params.setDefaultValue(qty)
|
||||
@@ -596,9 +601,10 @@ class PokemonBagScreen
|
||||
@scene.pbStartScene(storage)
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if item==0
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
qty = storage.pbQuantity(item)
|
||||
if qty>1 && !pbIsImportantItem?(item)
|
||||
if qty>1 && !itm.is_important?
|
||||
qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
|
||||
end
|
||||
next if qty<=0
|
||||
@@ -610,8 +616,8 @@ class PokemonBagScreen
|
||||
raise "Can't withdraw items from storage"
|
||||
end
|
||||
@scene.pbRefresh
|
||||
dispqty = (pbIsImportantItem?(item)) ? 1 : qty
|
||||
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
|
||||
dispqty = (itm.is_important?) ? 1 : qty
|
||||
itemname = (dispqty>1) ? itm.name_plural : itm.name
|
||||
pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname))
|
||||
else
|
||||
pbDisplay(_INTL("There's no more room in the Bag."))
|
||||
@@ -627,12 +633,12 @@ class PokemonBagScreen
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
storage = $PokemonGlobal.pcItemStorage
|
||||
item = 0
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if item==0
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
qty = @bag.pbQuantity(item)
|
||||
if qty>1 && !pbIsImportantItem?(item)
|
||||
if qty>1 && !itm.is_important?
|
||||
qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
|
||||
end
|
||||
if qty>0
|
||||
@@ -646,8 +652,8 @@ class PokemonBagScreen
|
||||
raise "Can't deposit items to storage"
|
||||
end
|
||||
@scene.pbRefresh
|
||||
dispqty = (pbIsImportantItem?(item)) ? 1 : qty
|
||||
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
|
||||
dispqty = (itm.is_important?) ? 1 : qty
|
||||
itemname = (dispqty>1) ? itm.name_plural : itm.name
|
||||
pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname))
|
||||
end
|
||||
end
|
||||
@@ -664,14 +670,15 @@ class PokemonBagScreen
|
||||
@scene.pbStartScene(storage)
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if item==0
|
||||
if pbIsImportantItem?(item)
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
if itm.is_important?
|
||||
@scene.pbDisplay(_INTL("That's too important to toss out!"))
|
||||
next
|
||||
end
|
||||
qty = storage.pbQuantity(item)
|
||||
itemname = PBItems.getName(item)
|
||||
itemnameplural = PBItems.getNamePlural(item)
|
||||
itemname = itm.name
|
||||
itemnameplural = itm.name_plural
|
||||
if qty>1
|
||||
qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty)
|
||||
end
|
||||
|
||||
@@ -268,7 +268,6 @@ class PokemonLoadScreen
|
||||
$scene = nil
|
||||
return
|
||||
end
|
||||
PokemonData::Ability.load
|
||||
commands = []
|
||||
cmdContinue = -1
|
||||
cmdNewGame = -1
|
||||
|
||||
@@ -66,12 +66,12 @@ class ReadyMenuButton < SpriteWrapper
|
||||
self.bitmap.clear
|
||||
rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2)
|
||||
self.bitmap.blt(0,0,@button.bitmap,rect)
|
||||
textx = (@command[2]) ? 164 : (pbIsImportantItem?(@command[0])) ? 146 : 124
|
||||
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
|
||||
textpos = [
|
||||
[@command[1],textx,18,2,Color.new(248,248,248),Color.new(40,40,40),1],
|
||||
]
|
||||
if !@command[2]
|
||||
if !pbIsImportantItem?(@command[0])
|
||||
if !GameData::Item.get(@command[0]).is_important?
|
||||
qty = $PokemonBag.pbQuantity(@command[0])
|
||||
if qty>99
|
||||
textpos.push([_INTL(">99"),230,18,1,
|
||||
@@ -236,11 +236,11 @@ class PokemonReadyMenu
|
||||
def pbStartReadyMenu(moves,items)
|
||||
commands = [[],[]] # Moves, items
|
||||
for i in moves
|
||||
commands[0].push([i[0],PBMoves.getName(i[0]),true,i[1]])
|
||||
commands[0].push([i[0], PBMoves.getName(i[0]), true, i[1]])
|
||||
end
|
||||
commands[0].sort! { |a,b| a[1]<=>b[1] }
|
||||
for i in items
|
||||
commands[1].push([i,PBItems.getName(i),false])
|
||||
commands[1].push([i, GameData::Item.get(i).name, false])
|
||||
end
|
||||
commands[1].sort! { |a,b| a[1]<=>b[1] }
|
||||
@scene.pbStartScene(commands)
|
||||
@@ -296,9 +296,9 @@ end
|
||||
# Using a registered item
|
||||
#===============================================================================
|
||||
def pbUseKeyItem
|
||||
moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH,
|
||||
:SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL,
|
||||
:WHIRLPOOL]
|
||||
moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB,
|
||||
:ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT,
|
||||
:WATERFALL, :WHIRLPOOL]
|
||||
realmoves = []
|
||||
for i in moves
|
||||
move = getID(PBMoves,i)
|
||||
@@ -312,7 +312,8 @@ def pbUseKeyItem
|
||||
end
|
||||
realitems = []
|
||||
for i in $PokemonBag.registeredItems
|
||||
realitems.push(i) if $PokemonBag.pbHasItem?(i)
|
||||
itm = GameData::Item.get(i).id
|
||||
realitems.push(itm) if $PokemonBag.pbHasItem?(itm)
|
||||
end
|
||||
if realitems.length==0 && realmoves.length==0
|
||||
pbMessage(_INTL("An item in the Bag can be registered to this key for instant use."))
|
||||
|
||||
@@ -1205,11 +1205,11 @@ class PokemonStorageScene
|
||||
end
|
||||
|
||||
def pbChooseItem(bag)
|
||||
ret = 0
|
||||
ret = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,bag)
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| pbCanHoldItem?(item) })
|
||||
ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? })
|
||||
}
|
||||
return ret
|
||||
end
|
||||
@@ -1415,14 +1415,13 @@ class PokemonStorageScene
|
||||
end
|
||||
imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246])
|
||||
textstrings.push([pokemon.level.to_s,28,234,false,base,shadow])
|
||||
ability = pokemon.ability
|
||||
if ability
|
||||
textstrings.push([ability.name,86,306,2,base,shadow])
|
||||
if pokemon.ability
|
||||
textstrings.push([pokemon.ability.name,86,306,2,base,shadow])
|
||||
else
|
||||
textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow])
|
||||
end
|
||||
if pokemon.item>0
|
||||
textstrings.push([PBItems.getName(pokemon.item),86,342,2,base,shadow])
|
||||
if pokemon.item
|
||||
textstrings.push([pokemon.item.name,86,342,2,base,shadow])
|
||||
else
|
||||
textstrings.push([_INTL("No item"),86,342,2,nonbase,nonshadow])
|
||||
end
|
||||
@@ -1869,21 +1868,21 @@ class PokemonStorageScreen
|
||||
pbDisplay(_INTL("Please remove the mail."))
|
||||
return
|
||||
end
|
||||
if pokemon.item>0
|
||||
itemname = PBItems.getName(pokemon.item)
|
||||
if pokemon.item
|
||||
itemname = pokemon.item.name
|
||||
if pbConfirm(_INTL("Take this {1}?",itemname))
|
||||
if !$PokemonBag.pbStoreItem(pokemon.item)
|
||||
pbDisplay(_INTL("Can't store the {1}.",itemname))
|
||||
else
|
||||
pbDisplay(_INTL("Took the {1}.",itemname))
|
||||
pokemon.setItem(0)
|
||||
pokemon.setItem(nil)
|
||||
@scene.pbHardRefresh
|
||||
end
|
||||
end
|
||||
else
|
||||
item = scene.pbChooseItem($PokemonBag)
|
||||
if item>0
|
||||
itemname = PBItems.getName(item)
|
||||
if item
|
||||
itemname = GameData::Item.get(item).name
|
||||
pokemon.setItem(item)
|
||||
$PokemonBag.pbDeleteItem(item)
|
||||
pbDisplay(_INTL("{1} is now being held.",itemname))
|
||||
|
||||
@@ -18,7 +18,7 @@ class Window_PokemonItemStorage < Window_DrawableCommand
|
||||
|
||||
def item
|
||||
item = @bag[self.index]
|
||||
return item ? item[0] : 0
|
||||
return item ? item[0] : nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
@@ -34,12 +34,12 @@ class Window_PokemonItemStorage < Window_DrawableCommand
|
||||
else
|
||||
item = @bag[index][0]
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
qty = _ISPRINTF("x{1: 2d}",@bag[index][1])
|
||||
sizeQty = self.contents.text_size(qty).width
|
||||
xQty = rect.x+rect.width-sizeQty-2
|
||||
baseColor = (index==@sortIndex) ? Color.new(248,24,24) : self.baseColor
|
||||
textpos.push([itemname,rect.x,ypos,false,self.baseColor,self.shadowColor])
|
||||
if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM)
|
||||
if !GameData::Item.get(item).is_important? # Not a Key item or HM (or infinite TM)
|
||||
qty = _ISPRINTF("x{1: 2d}",@bag[index][1])
|
||||
sizeQty = self.contents.text_size(qty).width
|
||||
xQty = rect.x+rect.width-sizeQty-2
|
||||
textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor])
|
||||
end
|
||||
end
|
||||
@@ -73,7 +73,7 @@ class ItemStorage_Scene
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/pcItembg")
|
||||
@sprites["icon"] = ItemIconSprite.new(50,334,-1,@viewport)
|
||||
@sprites["icon"] = ItemIconSprite.new(50,334,nil,@viewport)
|
||||
# Item list
|
||||
@sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32)
|
||||
@sprites["itemwindow"].viewport = @viewport
|
||||
@@ -134,10 +134,10 @@ class ItemStorage_Scene
|
||||
# Draw item icon
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
# Get item description
|
||||
if itemwindow.item==0
|
||||
@sprites["itemtextwindow"].text = _INTL("Close storage.")
|
||||
if itemwindow.item
|
||||
@sprites["itemtextwindow"].text = GameData::Item.get(itemwindow.item).description
|
||||
else
|
||||
@sprites["itemtextwindow"].text = pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item)
|
||||
@sprites["itemtextwindow"].text = _INTL("Close storage.")
|
||||
end
|
||||
itemwindow.refresh
|
||||
end
|
||||
@@ -155,13 +155,13 @@ class ItemStorage_Scene
|
||||
self.update
|
||||
pbRefresh if itemwindow.item!=olditem
|
||||
if Input.trigger?(Input::B)
|
||||
return 0
|
||||
return nil
|
||||
elsif Input.trigger?(Input::C)
|
||||
if itemwindow.index<@bag.length
|
||||
pbRefresh
|
||||
return @bag[itemwindow.index][0]
|
||||
else
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -258,10 +258,10 @@ module UIHelper
|
||||
(block_given?) ? yield : dw.update
|
||||
if !dw.busy? && dw.resume
|
||||
if Input.trigger?(Input::B)
|
||||
pbPlayCancelSE()
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::C)
|
||||
pbPlayDecisionSE()
|
||||
pbPlayDecisionSE
|
||||
ret = (cw.index==0)
|
||||
break
|
||||
end
|
||||
@@ -294,32 +294,32 @@ module UIHelper
|
||||
(block_given?) ? yield : helpwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
ret = 0
|
||||
pbPlayCancelSE()
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::C)
|
||||
ret = curnumber
|
||||
pbPlayDecisionSE()
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
elsif Input.repeat?(Input::UP)
|
||||
curnumber += 1
|
||||
curnumber = 1 if curnumber>maximum
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE()
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
curnumber -= 1
|
||||
curnumber = maximum if curnumber<1
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE()
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::LEFT)
|
||||
curnumber -= 10
|
||||
curnumber = 1 if curnumber<1
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE()
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
curnumber += 10
|
||||
curnumber = maximum if curnumber>maximum
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE()
|
||||
pbPlayCursorSE
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -347,12 +347,12 @@ module UIHelper
|
||||
cmdwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
ret = -1
|
||||
pbPlayCancelSE()
|
||||
pbPlayCancelSE
|
||||
break
|
||||
end
|
||||
if Input.trigger?(Input::C)
|
||||
ret = cmdwindow.index
|
||||
pbPlayDecisionSE()
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@@ -614,7 +614,7 @@ class PokemonEvolutionScene
|
||||
new_pkmn.name = PBSpecies.getName(new_species)
|
||||
new_pkmn.markings = 0
|
||||
new_pkmn.ballused = 0
|
||||
new_pkmn.setItem(0)
|
||||
new_pkmn.setItem(nil)
|
||||
new_pkmn.clearAllRibbons
|
||||
new_pkmn.calcStats
|
||||
new_pkmn.heal
|
||||
|
||||
@@ -18,21 +18,21 @@ class PokemonMartAdapter
|
||||
return $PokemonBag
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
itemname = PBItems.getName(item)
|
||||
if pbIsMachine?(item)
|
||||
machine = pbGetMachine(item)
|
||||
itemname = _INTL("{1} {2}",itemname,PBMoves.getName(machine))
|
||||
end
|
||||
return itemname
|
||||
def getName(item)
|
||||
return GameData::Item.get(item).name
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
return PBItems.getName(item)
|
||||
def getDisplayName(item)
|
||||
item_name = getName(item)
|
||||
if GameData::Item.get(item).is_machine?
|
||||
machine = GameData::Item.get(item).move
|
||||
item_name = _INTL("{1} {2}", item_name, PBMoves.getName(machine))
|
||||
end
|
||||
return item_name
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return pbGetMessage(MessageTypes::ItemDescriptions,item)
|
||||
return GameData::Item.get(item).description
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
@@ -40,8 +40,9 @@ class PokemonMartAdapter
|
||||
return pbItemIconFile(item)
|
||||
end
|
||||
|
||||
# Unused
|
||||
def getItemIconRect(_item)
|
||||
return Rect.new(0,0,48,48)
|
||||
return Rect.new(0, 0, 48, 48)
|
||||
end
|
||||
|
||||
def getQuantity(item)
|
||||
@@ -49,27 +50,27 @@ class PokemonMartAdapter
|
||||
end
|
||||
|
||||
def showQuantity?(item)
|
||||
return !pbIsImportantItem?(item)
|
||||
return !GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def getPrice(item,selling=false)
|
||||
def getPrice(item, selling = false)
|
||||
if $game_temp.mart_prices && $game_temp.mart_prices[item]
|
||||
if selling
|
||||
return $game_temp.mart_prices[item][1] if $game_temp.mart_prices[item][1]>=0
|
||||
return $game_temp.mart_prices[item][1] if $game_temp.mart_prices[item][1] >= 0
|
||||
else
|
||||
return $game_temp.mart_prices[item][0] if $game_temp.mart_prices[item][0]>0
|
||||
return $game_temp.mart_prices[item][0] if $game_temp.mart_prices[item][0] > 0
|
||||
end
|
||||
end
|
||||
return pbGetPrice(item)
|
||||
return GameData::Item.get(item).price
|
||||
end
|
||||
|
||||
def getDisplayPrice(item,selling=false)
|
||||
price = getPrice(item,selling).to_s_formatted
|
||||
return _INTL("$ {1}",price)
|
||||
def getDisplayPrice(item, selling = false)
|
||||
price = getPrice(item, selling).to_s_formatted
|
||||
return _INTL("$ {1}", price)
|
||||
end
|
||||
|
||||
def canSell?(item)
|
||||
return (getPrice(item,true)>0 && !pbIsImportantItem?(item))
|
||||
return getPrice(item, true) > 0 && !GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
@@ -101,32 +102,31 @@ class RpgxpMartAdapter
|
||||
$game_party.gain_gold(value)
|
||||
end
|
||||
|
||||
def getPrice(item,_selling=false)
|
||||
def getPrice(item, _selling = false)
|
||||
return item.price
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return nil if !item
|
||||
if item==0
|
||||
if item == 0
|
||||
return sprintf("Graphics/Icons/itemBack")
|
||||
elsif item.respond_to?("icon_index")
|
||||
return "Graphics/System/IconSet"
|
||||
else
|
||||
return sprintf("Graphics/Icons/%s",item.icon_name)
|
||||
return sprintf("Graphics/Icons/%s", item.icon_name)
|
||||
end
|
||||
end
|
||||
|
||||
def getItemIconRect(item)
|
||||
if item && item.respond_to?("icon_index")
|
||||
ix=item.icon_index % 16 * 24
|
||||
iy=item.icon_index / 16 * 24
|
||||
return Rect.new(ix,iy,24,24)
|
||||
else
|
||||
return Rect.new(0,0,32,32)
|
||||
ix = item.icon_index % 16 * 24
|
||||
iy = item.icon_index / 16 * 24
|
||||
return Rect.new(ix, iy, 24, 24)
|
||||
end
|
||||
return Rect.new(0, 0, 32, 32)
|
||||
end
|
||||
|
||||
def getInventory()
|
||||
def getInventory
|
||||
data = []
|
||||
for i in 1...$data_items.size
|
||||
data.push($data_items[i]) if getQuantity($data_items[i]) > 0
|
||||
@@ -141,7 +141,7 @@ class RpgxpMartAdapter
|
||||
end
|
||||
|
||||
def canSell?(item)
|
||||
return item ? item.price>0 : false
|
||||
return item ? item.price > 0 : false
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
@@ -152,17 +152,17 @@ class RpgxpMartAdapter
|
||||
return item ? item.name : ""
|
||||
end
|
||||
|
||||
def getDisplayPrice(item,_selling=false)
|
||||
price=item.price
|
||||
return price.to_s
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return item ? item.description : ""
|
||||
end
|
||||
|
||||
def getDisplayPrice(item, _selling = false)
|
||||
price = item.price
|
||||
return price.to_s
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
ret=(getQuantity(item)<99)
|
||||
ret = (getQuantity(item) < 99)
|
||||
if $game_party.respond_to?("gain_weapon")
|
||||
case item
|
||||
when RPG::Item
|
||||
@@ -173,21 +173,21 @@ class RpgxpMartAdapter
|
||||
$game_party.gain_armor(item.id, 1) if ret
|
||||
end
|
||||
else
|
||||
$game_party.gain_item(item,1) if ret
|
||||
$game_party.gain_item(item, 1) if ret
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def getQuantity(item)
|
||||
ret=0
|
||||
ret = 0
|
||||
if $game_party.respond_to?("weapon_number")
|
||||
case item
|
||||
when RPG::Item
|
||||
ret=$game_party.item_number(item.id)
|
||||
ret = $game_party.item_number(item.id)
|
||||
when RPG::Weapon
|
||||
ret=($game_party.weapon_number(item.id))
|
||||
ret = ($game_party.weapon_number(item.id))
|
||||
when RPG::Armor
|
||||
ret=($game_party.armor_number(item.id))
|
||||
ret = ($game_party.armor_number(item.id))
|
||||
end
|
||||
else
|
||||
return $game_party.item_number(item)
|
||||
@@ -200,7 +200,7 @@ class RpgxpMartAdapter
|
||||
end
|
||||
|
||||
def removeItem(item)
|
||||
ret=(getQuantity(item)>0)
|
||||
ret = (getQuantity(item) > 0)
|
||||
if $game_party.respond_to?("lose_weapon")
|
||||
case item
|
||||
when RPG::Item
|
||||
@@ -211,7 +211,7 @@ class RpgxpMartAdapter
|
||||
$game_party.lose_armor(item.id, 1) if ret
|
||||
end
|
||||
else
|
||||
$game_party.lose_item(item,1) if ret
|
||||
$game_party.lose_item(item, 1) if ret
|
||||
end
|
||||
return ret
|
||||
end
|
||||
@@ -223,7 +223,7 @@ end
|
||||
#===============================================================================
|
||||
class BuyAdapter
|
||||
def initialize(adapter)
|
||||
@adapter=adapter
|
||||
@adapter = adapter
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
@@ -231,7 +231,7 @@ class BuyAdapter
|
||||
end
|
||||
|
||||
def getDisplayPrice(item)
|
||||
@adapter.getDisplayPrice(item,false)
|
||||
@adapter.getDisplayPrice(item, false)
|
||||
end
|
||||
|
||||
def isSelling?
|
||||
@@ -243,7 +243,7 @@ end
|
||||
|
||||
class SellAdapter
|
||||
def initialize(adapter)
|
||||
@adapter=adapter
|
||||
@adapter = adapter
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
@@ -252,7 +252,7 @@ class SellAdapter
|
||||
|
||||
def getDisplayPrice(item)
|
||||
if @adapter.showQuantity?(item)
|
||||
return sprintf("x%d",@adapter.getQuantity(item))
|
||||
return sprintf("x%d", @adapter.getQuantity(item))
|
||||
else
|
||||
return ""
|
||||
end
|
||||
@@ -269,41 +269,40 @@ end
|
||||
# Pokémon Mart
|
||||
#===============================================================================
|
||||
class Window_PokemonMart < Window_DrawableCommand
|
||||
def initialize(stock,adapter,x,y,width,height,viewport=nil)
|
||||
@stock=stock
|
||||
@adapter=adapter
|
||||
super(x,y,width,height,viewport)
|
||||
@selarrow=AnimatedBitmap.new("Graphics/Pictures/martSel")
|
||||
@baseColor=Color.new(88,88,80)
|
||||
@shadowColor=Color.new(168,184,184)
|
||||
self.windowskin=nil
|
||||
def initialize(stock, adapter, x, y, width, height, viewport = nil)
|
||||
@stock = stock
|
||||
@adapter = adapter
|
||||
super(x, y, width, height, viewport)
|
||||
@selarrow = AnimatedBitmap.new("Graphics/Pictures/martSel")
|
||||
@baseColor = Color.new(88,88,80)
|
||||
@shadowColor = Color.new(168,184,184)
|
||||
self.windowskin = nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return @stock.length+1
|
||||
return @stock.length + 1
|
||||
end
|
||||
|
||||
def item
|
||||
return self.index>=@stock.length ? 0 : @stock[self.index]
|
||||
return (self.index >= @stock.length) ? nil : @stock[self.index]
|
||||
end
|
||||
|
||||
def drawItem(index,count,rect)
|
||||
textpos=[]
|
||||
rect=drawCursor(index,rect)
|
||||
ypos=rect.y
|
||||
if index==count-1
|
||||
textpos.push([_INTL("CANCEL"),rect.x,ypos+2,false,
|
||||
self.baseColor,self.shadowColor])
|
||||
def drawItem(index, count, rect)
|
||||
textpos = []
|
||||
rect = drawCursor(index, rect)
|
||||
ypos = rect.y
|
||||
if index == count-1
|
||||
textpos.push([_INTL("CANCEL"), rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
|
||||
else
|
||||
item=@stock[index]
|
||||
itemname=@adapter.getDisplayName(item)
|
||||
qty=@adapter.getDisplayPrice(item)
|
||||
sizeQty=self.contents.text_size(qty).width
|
||||
xQty=rect.x+rect.width-sizeQty-2-16
|
||||
textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor])
|
||||
textpos.push([qty,xQty,ypos+2,false,self.baseColor,self.shadowColor])
|
||||
item = @stock[index]
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
qty = @adapter.getDisplayPrice(item)
|
||||
sizeQty = self.contents.text_size(qty).width
|
||||
xQty = rect.x + rect.width - sizeQty - 2 - 16
|
||||
textpos.push([itemname, rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
|
||||
textpos.push([qty, xQty, ypos + 2, false, self.baseColor, self.shadowColor])
|
||||
end
|
||||
pbDrawTextPositions(self.contents,textpos)
|
||||
pbDrawTextPositions(self.contents, textpos)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -319,112 +318,112 @@ class PokemonMart_Scene
|
||||
if @subscene
|
||||
@subscene.pbRefresh
|
||||
else
|
||||
itemwindow=@sprites["itemwindow"]
|
||||
@sprites["icon"].item=itemwindow.item
|
||||
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
|
||||
@adapter.getDescription(itemwindow.item)
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
|
||||
itemwindow.refresh
|
||||
end
|
||||
@sprites["moneywindow"].text=_INTL("Money:\r\n<r>{1}",@adapter.getMoneyString)
|
||||
@sprites["moneywindow"].text = _INTL("Money:\r\n<r>{1}", @adapter.getMoneyString)
|
||||
end
|
||||
|
||||
def pbStartBuyOrSellScene(buying,stock,adapter)
|
||||
def pbStartBuyOrSellScene(buying, stock, adapter)
|
||||
# Scroll right before showing screen
|
||||
pbScrollMap(6,5,5)
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@stock=stock
|
||||
@adapter=adapter
|
||||
@sprites={}
|
||||
@sprites["background"]=IconSprite.new(0,0,@viewport)
|
||||
pbScrollMap(6, 5, 5)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@stock = stock
|
||||
@adapter = adapter
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/martScreen")
|
||||
@sprites["icon"]=ItemIconSprite.new(36,Graphics.height-50,-1,@viewport)
|
||||
winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
|
||||
@sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter,
|
||||
Graphics.width-316-16,12,330+16,Graphics.height-126)
|
||||
@sprites["itemwindow"].viewport=@viewport
|
||||
@sprites["itemwindow"].index=0
|
||||
@sprites["icon"] = ItemIconSprite.new(36, Graphics.height - 50, nil, @viewport)
|
||||
winAdapter = buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
|
||||
@sprites["itemwindow"] = Window_PokemonMart.new(stock, winAdapter,
|
||||
Graphics.width - 316 - 16, 12, 330 + 16, Graphics.height - 126)
|
||||
@sprites["itemwindow"].viewport = @viewport
|
||||
@sprites["itemwindow"].index = 0
|
||||
@sprites["itemwindow"].refresh
|
||||
@sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("")
|
||||
@sprites["itemtextwindow"] = Window_UnformattedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["itemtextwindow"])
|
||||
@sprites["itemtextwindow"].x=64
|
||||
@sprites["itemtextwindow"].y=Graphics.height-96-16
|
||||
@sprites["itemtextwindow"].width=Graphics.width-64
|
||||
@sprites["itemtextwindow"].height=128
|
||||
@sprites["itemtextwindow"].baseColor=Color.new(248,248,248)
|
||||
@sprites["itemtextwindow"].shadowColor=Color.new(0,0,0)
|
||||
@sprites["itemtextwindow"].visible=true
|
||||
@sprites["itemtextwindow"].viewport=@viewport
|
||||
@sprites["itemtextwindow"].windowskin=nil
|
||||
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("")
|
||||
@sprites["itemtextwindow"].x = 64
|
||||
@sprites["itemtextwindow"].y = Graphics.height - 96 - 16
|
||||
@sprites["itemtextwindow"].width = Graphics.width - 64
|
||||
@sprites["itemtextwindow"].height = 128
|
||||
@sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248)
|
||||
@sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0)
|
||||
@sprites["itemtextwindow"].visible = true
|
||||
@sprites["itemtextwindow"].viewport = @viewport
|
||||
@sprites["itemtextwindow"].windowskin = nil
|
||||
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["helpwindow"])
|
||||
@sprites["helpwindow"].visible=false
|
||||
@sprites["helpwindow"].viewport=@viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"],1)
|
||||
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"], 1)
|
||||
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["moneywindow"])
|
||||
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
|
||||
@sprites["moneywindow"].visible=true
|
||||
@sprites["moneywindow"].viewport=@viewport
|
||||
@sprites["moneywindow"].x=0
|
||||
@sprites["moneywindow"].y=0
|
||||
@sprites["moneywindow"].width=190
|
||||
@sprites["moneywindow"].height=96
|
||||
@sprites["moneywindow"].baseColor=Color.new(88,88,80)
|
||||
@sprites["moneywindow"].shadowColor=Color.new(168,184,184)
|
||||
@sprites["moneywindow"].visible = true
|
||||
@sprites["moneywindow"].viewport = @viewport
|
||||
@sprites["moneywindow"].x = 0
|
||||
@sprites["moneywindow"].y = 0
|
||||
@sprites["moneywindow"].width = 190
|
||||
@sprites["moneywindow"].height = 96
|
||||
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
|
||||
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
|
||||
pbDeactivateWindows(@sprites)
|
||||
@buying=buying
|
||||
@buying = buying
|
||||
pbRefresh
|
||||
Graphics.frame_reset
|
||||
end
|
||||
|
||||
def pbStartBuyScene(stock,adapter)
|
||||
pbStartBuyOrSellScene(true,stock,adapter)
|
||||
def pbStartBuyScene(stock, adapter)
|
||||
pbStartBuyOrSellScene(true, stock, adapter)
|
||||
end
|
||||
|
||||
def pbStartSellScene(bag,adapter)
|
||||
def pbStartSellScene(bag, adapter)
|
||||
if $PokemonBag
|
||||
pbStartSellScene2(bag,adapter)
|
||||
pbStartSellScene2(bag, adapter)
|
||||
else
|
||||
pbStartBuyOrSellScene(false,bag,adapter)
|
||||
pbStartBuyOrSellScene(false, bag, adapter)
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartSellScene2(bag,adapter)
|
||||
@subscene=PokemonBag_Scene.new
|
||||
@adapter=adapter
|
||||
@viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport2.z=99999
|
||||
numFrames = Graphics.frame_rate*4/10
|
||||
alphaDiff = (255.0/numFrames).ceil
|
||||
def pbStartSellScene2(bag, adapter)
|
||||
@subscene = PokemonBag_Scene.new
|
||||
@adapter = adapter
|
||||
@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport2.z = 99999
|
||||
numFrames = Graphics.frame_rate * 4 / 10
|
||||
alphaDiff = (255.0 / numFrames).ceil
|
||||
for j in 0..numFrames
|
||||
col=Color.new(0,0,0,j*alphaDiff)
|
||||
@viewport2.color=col
|
||||
col = Color.new(0, 0, 0, j * alphaDiff)
|
||||
@viewport2.color = col
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
@subscene.pbStartScene(bag)
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@sprites={}
|
||||
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("")
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["helpwindow"])
|
||||
@sprites["helpwindow"].visible=false
|
||||
@sprites["helpwindow"].viewport=@viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"],1)
|
||||
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("")
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"], 1)
|
||||
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["moneywindow"])
|
||||
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
|
||||
@sprites["moneywindow"].visible=false
|
||||
@sprites["moneywindow"].viewport=@viewport
|
||||
@sprites["moneywindow"].x=0
|
||||
@sprites["moneywindow"].y=0
|
||||
@sprites["moneywindow"].width=186
|
||||
@sprites["moneywindow"].height=96
|
||||
@sprites["moneywindow"].baseColor=Color.new(88,88,80)
|
||||
@sprites["moneywindow"].shadowColor=Color.new(168,184,184)
|
||||
@sprites["moneywindow"].visible = false
|
||||
@sprites["moneywindow"].viewport = @viewport
|
||||
@sprites["moneywindow"].x = 0
|
||||
@sprites["moneywindow"].y = 0
|
||||
@sprites["moneywindow"].width = 186
|
||||
@sprites["moneywindow"].height = 96
|
||||
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
|
||||
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
|
||||
pbDeactivateWindows(@sprites)
|
||||
@buying=false
|
||||
@buying = false
|
||||
pbRefresh
|
||||
end
|
||||
|
||||
@@ -432,82 +431,78 @@ class PokemonMart_Scene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
# Scroll left after showing screen
|
||||
pbScrollMap(4,5,5)
|
||||
pbScrollMap(4, 5, 5)
|
||||
end
|
||||
|
||||
def pbEndSellScene
|
||||
if @subscene
|
||||
@subscene.pbEndScene
|
||||
end
|
||||
@subscene.pbEndScene if @subscene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
if @viewport2
|
||||
numFrames = Graphics.frame_rate*4/10
|
||||
alphaDiff = (255.0/numFrames).ceil
|
||||
numFrames = Graphics.frame_rate * 4 / 10
|
||||
alphaDiff = (255.0 / numFrames).ceil
|
||||
for j in 0..numFrames
|
||||
col=Color.new(0,0,0,(numFrames-j)*alphaDiff)
|
||||
@viewport2.color=col
|
||||
col = Color.new(0, 0, 0, (numFrames - j) * alphaDiff)
|
||||
@viewport2.color = col
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
@viewport2.dispose
|
||||
end
|
||||
@viewport.dispose
|
||||
if !@subscene
|
||||
pbScrollMap(4,5,5)
|
||||
end
|
||||
pbScrollMap(4, 5, 5) if !@subscene
|
||||
end
|
||||
|
||||
def pbPrepareWindow(window)
|
||||
window.visible=true
|
||||
window.letterbyletter=false
|
||||
window.visible = true
|
||||
window.letterbyletter = false
|
||||
end
|
||||
|
||||
def pbShowMoney
|
||||
pbRefresh
|
||||
@sprites["moneywindow"].visible=true
|
||||
@sprites["moneywindow"].visible = true
|
||||
end
|
||||
|
||||
def pbHideMoney
|
||||
pbRefresh
|
||||
@sprites["moneywindow"].visible=false
|
||||
@sprites["moneywindow"].visible = false
|
||||
end
|
||||
|
||||
def pbDisplay(msg,brief=false)
|
||||
cw=@sprites["helpwindow"]
|
||||
cw.letterbyletter=true
|
||||
cw.text=msg
|
||||
pbBottomLeftLines(cw,2)
|
||||
cw.visible=true
|
||||
i=0
|
||||
pbPlayDecisionSE()
|
||||
def pbDisplay(msg, brief = false)
|
||||
cw = @sprites["helpwindow"]
|
||||
cw.letterbyletter = true
|
||||
cw.text = msg
|
||||
pbBottomLeftLines(cw, 2)
|
||||
cw.visible = true
|
||||
i = 0
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
self.update
|
||||
if !cw.busy?
|
||||
return if brief
|
||||
pbRefresh if i==0
|
||||
pbRefresh if i == 0
|
||||
end
|
||||
if Input.trigger?(Input::C) && cw.busy?
|
||||
cw.resume
|
||||
end
|
||||
return if i>=Graphics.frame_rate*3/2
|
||||
i+=1 if !cw.busy?
|
||||
return if i >= Graphics.frame_rate * 3 / 2
|
||||
i += 1 if !cw.busy?
|
||||
end
|
||||
end
|
||||
|
||||
def pbDisplayPaused(msg)
|
||||
cw=@sprites["helpwindow"]
|
||||
cw.letterbyletter=true
|
||||
cw.text=msg
|
||||
pbBottomLeftLines(cw,2)
|
||||
cw.visible=true
|
||||
cw = @sprites["helpwindow"]
|
||||
cw.letterbyletter = true
|
||||
cw.text = msg
|
||||
pbBottomLeftLines(cw, 2)
|
||||
cw.visible = true
|
||||
yielded = false
|
||||
pbPlayDecisionSE()
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
wasbusy=cw.busy?
|
||||
wasbusy = cw.busy?
|
||||
self.update
|
||||
if !cw.busy? && !yielded
|
||||
yield if block_given? # For playing SE as soon as the message is all shown
|
||||
@@ -515,73 +510,73 @@ class PokemonMart_Scene
|
||||
end
|
||||
pbRefresh if !cw.busy? && wasbusy
|
||||
if Input.trigger?(Input::C) && cw.resume && !cw.busy?
|
||||
@sprites["helpwindow"].visible=false
|
||||
@sprites["helpwindow"].visible = false
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
dw=@sprites["helpwindow"]
|
||||
dw.letterbyletter=true
|
||||
dw.text=msg
|
||||
dw.visible=true
|
||||
pbBottomLeftLines(dw,2)
|
||||
commands=[_INTL("Yes"),_INTL("No")]
|
||||
dw = @sprites["helpwindow"]
|
||||
dw.letterbyletter = true
|
||||
dw.text = msg
|
||||
dw.visible = true
|
||||
pbBottomLeftLines(dw, 2)
|
||||
commands = [_INTL("Yes"), _INTL("No")]
|
||||
cw = Window_CommandPokemon.new(commands)
|
||||
cw.viewport=@viewport
|
||||
cw.viewport = @viewport
|
||||
pbBottomRight(cw)
|
||||
cw.y-=dw.height
|
||||
cw.index=0
|
||||
pbPlayDecisionSE()
|
||||
cw.y -= dw.height
|
||||
cw.index = 0
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
cw.visible=!dw.busy?
|
||||
cw.visible = !dw.busy?
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
self.update
|
||||
if Input.trigger?(Input::B) && dw.resume && !dw.busy?
|
||||
cw.dispose
|
||||
@sprites["helpwindow"].visible=false
|
||||
@sprites["helpwindow"].visible = false
|
||||
return false
|
||||
end
|
||||
if Input.trigger?(Input::C) && dw.resume && !dw.busy?
|
||||
cw.dispose
|
||||
@sprites["helpwindow"].visible=false
|
||||
return (cw.index==0)?true:false
|
||||
@sprites["helpwindow"].visible = false
|
||||
return (cw.index == 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbChooseNumber(helptext,item,maximum)
|
||||
curnumber=1
|
||||
ret=0
|
||||
helpwindow=@sprites["helpwindow"]
|
||||
itemprice=@adapter.getPrice(item,!@buying)
|
||||
itemprice/=2 if !@buying
|
||||
pbDisplay(helptext,true)
|
||||
using(numwindow=Window_AdvancedTextPokemon.new("")) { # Showing number of items
|
||||
qty=@adapter.getQuantity(item)
|
||||
using(inbagwindow=Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
|
||||
curnumber = 1
|
||||
ret = 0
|
||||
helpwindow = @sprites["helpwindow"]
|
||||
itemprice = @adapter.getPrice(item, !@buying)
|
||||
itemprice /= 2 if !@buying
|
||||
pbDisplay(helptext, true)
|
||||
using (numwindow = Window_AdvancedTextPokemon.new("")) { # Showing number of items
|
||||
qty = @adapter.getQuantity(item)
|
||||
using (inbagwindow = Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
|
||||
pbPrepareWindow(numwindow)
|
||||
pbPrepareWindow(inbagwindow)
|
||||
numwindow.viewport=@viewport
|
||||
numwindow.width=224
|
||||
numwindow.height=64
|
||||
numwindow.baseColor=Color.new(88,88,80)
|
||||
numwindow.shadowColor=Color.new(168,184,184)
|
||||
inbagwindow.visible=@buying
|
||||
inbagwindow.viewport=@viewport
|
||||
inbagwindow.width=190
|
||||
inbagwindow.height=64
|
||||
inbagwindow.baseColor=Color.new(88,88,80)
|
||||
inbagwindow.shadowColor=Color.new(168,184,184)
|
||||
inbagwindow.text=_INTL("In Bag:<r>{1} ",qty)
|
||||
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
|
||||
numwindow.viewport = @viewport
|
||||
numwindow.width = 224
|
||||
numwindow.height = 64
|
||||
numwindow.baseColor = Color.new(88, 88, 80)
|
||||
numwindow.shadowColor = Color.new(168, 184, 184)
|
||||
inbagwindow.visible = @buying
|
||||
inbagwindow.viewport = @viewport
|
||||
inbagwindow.width = 190
|
||||
inbagwindow.height = 64
|
||||
inbagwindow.baseColor = Color.new(88, 88, 80)
|
||||
inbagwindow.shadowColor = Color.new(168, 184, 184)
|
||||
inbagwindow.text = _INTL("In Bag:<r>{1} ", qty)
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
pbBottomRight(numwindow)
|
||||
numwindow.y-=helpwindow.height
|
||||
numwindow.y -= helpwindow.height
|
||||
pbBottomLeft(inbagwindow)
|
||||
inbagwindow.y-=helpwindow.height
|
||||
inbagwindow.y -= helpwindow.height
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@@ -589,65 +584,65 @@ class PokemonMart_Scene
|
||||
inbagwindow.update
|
||||
self.update
|
||||
if Input.repeat?(Input::LEFT)
|
||||
pbPlayCursorSE()
|
||||
curnumber-=10
|
||||
curnumber=1 if curnumber<1
|
||||
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
|
||||
pbPlayCursorSE
|
||||
curnumber -= 10
|
||||
curnumber = 1 if curnumber < 1
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
pbPlayCursorSE()
|
||||
curnumber+=10
|
||||
curnumber=maximum if curnumber>maximum
|
||||
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
|
||||
pbPlayCursorSE
|
||||
curnumber += 10
|
||||
curnumber = maximum if curnumber > maximum
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::UP)
|
||||
pbPlayCursorSE()
|
||||
curnumber+=1
|
||||
curnumber=1 if curnumber>maximum
|
||||
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
|
||||
pbPlayCursorSE
|
||||
curnumber += 1
|
||||
curnumber = 1 if curnumber > maximum
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
pbPlayCursorSE()
|
||||
curnumber-=1
|
||||
curnumber=maximum if curnumber<1
|
||||
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted)
|
||||
pbPlayCursorSE
|
||||
curnumber -= 1
|
||||
curnumber = maximum if curnumber < 1
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.trigger?(Input::C)
|
||||
pbPlayDecisionSE()
|
||||
ret=curnumber
|
||||
pbPlayDecisionSE
|
||||
ret = curnumber
|
||||
break
|
||||
elsif Input.trigger?(Input::B)
|
||||
pbPlayCancelSE()
|
||||
ret=0
|
||||
pbPlayCancelSE
|
||||
ret = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
helpwindow.visible=false
|
||||
helpwindow.visible = false
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseBuyItem
|
||||
itemwindow=@sprites["itemwindow"]
|
||||
@sprites["helpwindow"].visible=false
|
||||
pbActivateWindow(@sprites,"itemwindow") {
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
@sprites["helpwindow"].visible = false
|
||||
pbActivateWindow(@sprites, "itemwindow") {
|
||||
pbRefresh
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
olditem=itemwindow.item
|
||||
olditem = itemwindow.item
|
||||
self.update
|
||||
if itemwindow.item!=olditem
|
||||
@sprites["icon"].item=itemwindow.item
|
||||
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") :
|
||||
@adapter.getDescription(itemwindow.item)
|
||||
if itemwindow.item != olditem
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
|
||||
end
|
||||
if Input.trigger?(Input::B)
|
||||
pbPlayCloseMenuSE
|
||||
return 0
|
||||
return nil
|
||||
elsif Input.trigger?(Input::C)
|
||||
if itemwindow.index<@stock.length
|
||||
if itemwindow.index < @stock.length
|
||||
pbRefresh
|
||||
return @stock[itemwindow.index]
|
||||
else
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -688,18 +683,18 @@ class PokemonMartScreen
|
||||
|
||||
def pbBuyScreen
|
||||
@scene.pbStartBuyScene(@stock,@adapter)
|
||||
item=0
|
||||
item=nil
|
||||
loop do
|
||||
item=@scene.pbChooseBuyItem
|
||||
break if !item
|
||||
quantity=0
|
||||
break if item==0
|
||||
itemname=@adapter.getDisplayName(item)
|
||||
price=@adapter.getPrice(item)
|
||||
if @adapter.getMoney<price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
if pbIsImportantItem?(item)
|
||||
if GameData::Item.get(item).is_important?
|
||||
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
|
||||
itemname,price.to_s_formatted))
|
||||
next
|
||||
@@ -723,9 +718,7 @@ class PokemonMartScreen
|
||||
end
|
||||
added=0
|
||||
quantity.times do
|
||||
if !@adapter.addItem(item)
|
||||
break
|
||||
end
|
||||
break if !@adapter.addItem(item)
|
||||
added+=1
|
||||
end
|
||||
if added!=quantity
|
||||
@@ -738,15 +731,15 @@ class PokemonMartScreen
|
||||
else
|
||||
@adapter.setMoney(@adapter.getMoney-price)
|
||||
for i in 0...@stock.length
|
||||
if pbIsImportantItem?(@stock[i]) && $PokemonBag.pbHasItem?(@stock[i])
|
||||
if GameData::Item.get(@stock[i]).is_important? && $PokemonBag.pbHasItem?(@stock[i])
|
||||
@stock[i]=nil
|
||||
end
|
||||
end
|
||||
@stock.compact!
|
||||
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
|
||||
if $PokemonBag
|
||||
if quantity>=10 && pbIsPokeBall?(item) && hasConst?(PBItems,:PREMIERBALL)
|
||||
if @adapter.addItem(getConst(PBItems,:PREMIERBALL))
|
||||
if quantity>=10 && GameData::Item.get(item).is_poke_ball? && GameData::Item.exists?(:PREMIERBALL)
|
||||
if @adapter.addItem(GameData::Item.get(:PREMIERBALL))
|
||||
pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too."))
|
||||
end
|
||||
end
|
||||
@@ -760,7 +753,7 @@ class PokemonMartScreen
|
||||
item=@scene.pbStartSellScene(@adapter.getInventory,@adapter)
|
||||
loop do
|
||||
item=@scene.pbChooseSellItem
|
||||
break if item==0
|
||||
break if !item
|
||||
itemname=@adapter.getDisplayName(item)
|
||||
price=@adapter.getPrice(item,true)
|
||||
if !@adapter.canSell?(item)
|
||||
@@ -798,11 +791,8 @@ end
|
||||
|
||||
def pbPokemonMart(stock,speech=nil,cantsell=false)
|
||||
for i in 0...stock.length
|
||||
stock[i] = getID(PBItems,stock[i])
|
||||
if !stock[i] || stock[i]==0 ||
|
||||
(pbIsImportantItem?(stock[i]) && $PokemonBag.pbHasItem?(stock[i]))
|
||||
stock[i] = nil
|
||||
end
|
||||
stock[i] = GameData::Item.get(stock[i]).id
|
||||
stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i])
|
||||
end
|
||||
stock.compact!
|
||||
commands = []
|
||||
@@ -880,7 +870,7 @@ class Interpreter
|
||||
end
|
||||
|
||||
def setPrice(item,buyprice=-1,sellprice=-1)
|
||||
item = getID(PBItems,item)
|
||||
item = GameData::Item.get(item).id
|
||||
$game_temp.mart_prices[item] = [-1,-1] if !$game_temp.mart_prices[item]
|
||||
$game_temp.mart_prices[item][0] = buyprice if buyprice>0
|
||||
if sellprice>=0 # 0=can't sell
|
||||
|
||||
@@ -61,7 +61,8 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
|
||||
params.setDefaultValue(type)
|
||||
params.setCancelValue(0)
|
||||
loop do
|
||||
newtype=pbMessageChooseNumber(_INTL("Choose a quantity."),params)
|
||||
newtype=pbMessageChooseNumber(_INTL("Choose a quantity of {1}.",
|
||||
GameData::Item.get(item).name),params)
|
||||
if newtype==0
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
else
|
||||
@@ -230,17 +231,17 @@ def pbManageMysteryGifts
|
||||
end
|
||||
end
|
||||
|
||||
def pbRefreshMGCommands(master,online)
|
||||
commands=[]
|
||||
def pbRefreshMGCommands(master, online)
|
||||
commands = []
|
||||
for gift in master
|
||||
itemname="BLANK"
|
||||
if gift[1]==0
|
||||
itemname=PBSpecies.getName(gift[2].species)
|
||||
elsif gift[1]>0
|
||||
itemname=PBItems.getName(gift[2])+sprintf(" x%d",gift[1])
|
||||
itemname = "BLANK"
|
||||
if gift[1] == 0
|
||||
itemname = PBSpecies.getName(gift[2].species)
|
||||
elsif gift[1] > 0
|
||||
itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1])
|
||||
end
|
||||
ontext=["[ ]","[X]"][(online.include?(gift[0])) ? 1 : 0]
|
||||
commands.push(_INTL("{1} {2}: {3} ({4})",ontext,gift[0],gift[3],itemname))
|
||||
ontext = ["[ ]", "[X]"][(online.include?(gift[0])) ? 1 : 0]
|
||||
commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname))
|
||||
end
|
||||
commands.push(_INTL("Export selected to file"))
|
||||
commands.push(_INTL("Cancel"))
|
||||
@@ -378,7 +379,7 @@ def pbReceiveMysteryGift(id)
|
||||
return false
|
||||
end
|
||||
gift=$Trainer.mysterygift[index]
|
||||
if gift[1]==0
|
||||
if gift[1]==0 # Pokémon
|
||||
pID=rand(256)
|
||||
pID|=rand(256)<<8
|
||||
pID|=rand(256)<<16
|
||||
@@ -401,15 +402,17 @@ def pbReceiveMysteryGift(id)
|
||||
$Trainer.mysterygift[index]=[id]
|
||||
return true
|
||||
end
|
||||
elsif gift[1]>0
|
||||
if $PokemonBag.pbCanStore?(gift[2],gift[1])
|
||||
$PokemonBag.pbStoreItem(gift[2],gift[1])
|
||||
item=gift[2]; qty=gift[1]
|
||||
itemname=(qty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
|
||||
if isConst?(item,PBItems,:LEFTOVERS)
|
||||
elsif gift[1]>0 # Item
|
||||
item=gift[2]
|
||||
qty=gift[1]
|
||||
if $PokemonBag.pbCanStore?(item,qty)
|
||||
$PokemonBag.pbStoreItem(item,qty)
|
||||
itm = GameData::Item.get(item)
|
||||
itemname=(qty>1) ? itm.name_plural : itm.name
|
||||
if item == :LEFTOVERS
|
||||
pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
|
||||
elsif pbIsMachine?(item) # TM or HM
|
||||
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item))))
|
||||
elsif itm.is_machine? # TM or HM
|
||||
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(itm.move)))
|
||||
elsif qty>1
|
||||
pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname))
|
||||
elsif itemname.starts_with_vowel?
|
||||
|
||||
@@ -627,7 +627,7 @@ class TriadScreen
|
||||
end
|
||||
|
||||
def pbQuantity(items,item)
|
||||
return ItemStorageHelper.pbQuantity(items,$PokemonGlobal.triads.maxSize,item)
|
||||
return ItemStorageHelper.pbQuantity(items, item)
|
||||
end
|
||||
|
||||
def pbAdd(items,item)
|
||||
@@ -635,8 +635,8 @@ class TriadScreen
|
||||
$PokemonGlobal.triads.maxPerSlot,item,1)
|
||||
end
|
||||
|
||||
def pbSubtract(items,item)
|
||||
return ItemStorageHelper.pbDeleteItem(items,$PokemonGlobal.triads.maxSize,item,1)
|
||||
def pbSubtract(items, item)
|
||||
return ItemStorageHelper.pbDeleteItem(items, item, 1)
|
||||
end
|
||||
|
||||
def flipBoard(x,y,attackerParam=nil,recurse=false)
|
||||
@@ -1041,7 +1041,7 @@ class TriadStorage
|
||||
end
|
||||
|
||||
def pbQuantity(item)
|
||||
return ItemStorageHelper.pbQuantity(@items,self.maxSize,item)
|
||||
return ItemStorageHelper.pbQuantity(@items, item)
|
||||
end
|
||||
|
||||
def pbCanStore?(item,qty=1)
|
||||
@@ -1052,8 +1052,8 @@ class TriadStorage
|
||||
return ItemStorageHelper.pbStoreItem(@items,self.maxSize,self.maxPerSlot,item,qty)
|
||||
end
|
||||
|
||||
def pbDeleteItem(item,qty=1)
|
||||
return ItemStorageHelper.pbDeleteItem(@items,self.maxSize,item,qty)
|
||||
def pbDeleteItem(item, qty = 1)
|
||||
return ItemStorageHelper.pbDeleteItem(@items, item, qty)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ end
|
||||
|
||||
|
||||
def pbSlotMachine(difficulty=1)
|
||||
if hasConst?(PBItems,:COINCASE) && !$PokemonBag.pbHasItem?(:COINCASE)
|
||||
if GameData::Item.exists?(:COINCASE) && !$PokemonBag.pbHasItem?(:COINCASE)
|
||||
pbMessage(_INTL("It's a Slot Machine."))
|
||||
elsif $PokemonGlobal.coins==0
|
||||
pbMessage(_INTL("You don't have any Coins to play!"))
|
||||
|
||||
@@ -614,7 +614,7 @@ end
|
||||
|
||||
|
||||
def pbVoltorbFlip
|
||||
if hasConst?(PBItems,:COINCASE) && !$PokemonBag.pbHasItem?(:COINCASE)
|
||||
if GameData::Item.exists?(:COINCASE) && !$PokemonBag.pbHasItem?(:COINCASE)
|
||||
pbMessage(_INTL("You can't play unless you have a Coin Case."))
|
||||
elsif $PokemonGlobal.coins==MAX_COINS
|
||||
pbMessage(_INTL("Your Coin Case is full!"))
|
||||
|
||||
@@ -498,7 +498,7 @@ class MiningGameScene
|
||||
revealeditems.dispose
|
||||
for index in revealed
|
||||
@items[index][3]=true
|
||||
item=getConst(PBItems,ITEMS[@items[index][0]][0])
|
||||
item=ITEMS[@items[index][0]][0]
|
||||
@itemswon.push(item)
|
||||
end
|
||||
end
|
||||
@@ -581,10 +581,10 @@ class MiningGameScene
|
||||
for i in @itemswon
|
||||
if $PokemonBag.pbStoreItem(i)
|
||||
pbMessage(_INTL("One {1} was obtained.\\se[Mining item get]\\wtnp[30]",
|
||||
PBItems.getName(i)))
|
||||
GameData::Item.get(i).name))
|
||||
else
|
||||
pbMessage(_INTL("One {1} was found, but you have no room for it.",
|
||||
PBItems.getName(i)))
|
||||
GameData::Item.get(i).name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,31 +18,17 @@ class PBPokemon
|
||||
attr_accessor :ev
|
||||
|
||||
def initialize(species,item,nature,move1,move2,move3,move4,ev)
|
||||
@species=species
|
||||
@item=item ? item : 0
|
||||
@nature=nature
|
||||
@move1=move1 ? move1 : 0
|
||||
@move2=move2 ? move2 : 0
|
||||
@move3=move3 ? move3 : 0
|
||||
@move4=move4 ? move4 : 0
|
||||
@ev=ev
|
||||
@species = species
|
||||
itm = GameData::Item.try_get(item)
|
||||
@item = itm ? itm.id : nil
|
||||
@nature = nature
|
||||
@move1 = move1 ? move1 : 0
|
||||
@move2 = move2 ? move2 : 0
|
||||
@move3 = move3 ? move3 : 0
|
||||
@move4 = move4 ? move4 : 0
|
||||
@ev = ev
|
||||
end
|
||||
|
||||
=begin
|
||||
def _dump(depth)
|
||||
return [@species,@item,@nature,@move1,@move2,
|
||||
@move3,@move4,@ev].pack("vvCvvvvC")
|
||||
end
|
||||
|
||||
def self._load(str)
|
||||
data=str.unpack("vvCvvvvC")
|
||||
return self.new(
|
||||
data[0],data[1],data[2],data[3],
|
||||
data[4],data[5],data[6],data[7]
|
||||
)
|
||||
end
|
||||
=end
|
||||
|
||||
def self.fromInspected(str)
|
||||
insp=str.gsub(/^\s+/,"").gsub(/\s+$/,"")
|
||||
pieces=insp.split(/\s*;\s*/)
|
||||
@@ -50,10 +36,7 @@ class PBPokemon
|
||||
if (PBSpecies.const_defined?(pieces[0]) rescue false)
|
||||
species=PBSpecies.const_get(pieces[0])
|
||||
end
|
||||
item=0
|
||||
if (PBItems.const_defined?(pieces[1]) rescue false)
|
||||
item=PBItems.const_get(pieces[1])
|
||||
end
|
||||
item = (GameData::Item.exists?(pieces[1])) ? GameData::Item.get(pieces[1]).id : nil
|
||||
nature=PBNatures.const_get(pieces[2])
|
||||
ev=pieces[3].split(/\s*,\s*/)
|
||||
evvalue=0
|
||||
@@ -87,33 +70,11 @@ class PBPokemon
|
||||
evvalue|=0x08 if pokemon.ev[3]>60
|
||||
evvalue|=0x10 if pokemon.ev[4]>60
|
||||
evvalue|=0x20 if pokemon.ev[5]>60
|
||||
return self.new(pokemon.species,pokemon.item,pokemon.nature,
|
||||
return self.new(pokemon.species,pokemon.item_id,pokemon.nature,
|
||||
pokemon.moves[0].id,pokemon.moves[1].id,pokemon.moves[2].id,
|
||||
pokemon.moves[3].id,evvalue)
|
||||
end
|
||||
|
||||
def inspect
|
||||
c1=getConstantName(PBSpecies,@species)
|
||||
c2=(@item==0) ? "" : getConstantName(PBItems,@item)
|
||||
c3=getConstantName(PBNatures,@nature)
|
||||
evlist=""
|
||||
for i in 0...@ev
|
||||
if ((@ev&(1<<i))!=0)
|
||||
evlist+="," if evlist.length>0
|
||||
evlist+=["HP","ATK","DEF","SPD","SA","SD"][i]
|
||||
end
|
||||
end
|
||||
c4=(@move1==0) ? "" : getConstantName(PBMoves,@move1)
|
||||
c5=(@move2==0) ? "" : getConstantName(PBMoves,@move2)
|
||||
c6=(@move3==0) ? "" : getConstantName(PBMoves,@move3)
|
||||
c7=(@move4==0) ? "" : getConstantName(PBMoves,@move4)
|
||||
return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}"
|
||||
end
|
||||
|
||||
def tocompact
|
||||
return "#{species},#{item},#{nature},#{move1},#{move2},#{move3},#{move4},#{ev}"
|
||||
end
|
||||
|
||||
def self.constFromStr(mod,str)
|
||||
maxconst=0
|
||||
for constant in mod.constants
|
||||
@@ -134,7 +95,7 @@ class PBPokemon
|
||||
def self.fromstring(str)
|
||||
s=str.split(/\s*,\s*/)
|
||||
species=self.constFromStr(PBSpecies,s[1])
|
||||
item=self.constFromStr(PBItems,s[2])
|
||||
item=s[2].to_sym
|
||||
nature=self.constFromStr(PBNatures,s[3])
|
||||
move1=self.constFromStr(PBMoves,s[4])
|
||||
move2=(s.length>=12) ? self.constFromStr(PBMoves,s[5]) : 0
|
||||
@@ -151,6 +112,43 @@ class PBPokemon
|
||||
return self.new(species,item,nature,move1,move2,move3,move4,ev)
|
||||
end
|
||||
|
||||
=begin
|
||||
def _dump(depth)
|
||||
return [@species,@item,@nature,@move1,@move2,
|
||||
@move3,@move4,@ev].pack("vvCvvvvC")
|
||||
end
|
||||
|
||||
def self._load(str)
|
||||
data=str.unpack("vvCvvvvC")
|
||||
return self.new(
|
||||
data[0],data[1],data[2],data[3],
|
||||
data[4],data[5],data[6],data[7]
|
||||
)
|
||||
end
|
||||
=end
|
||||
|
||||
def inspect
|
||||
c1=getConstantName(PBSpecies,@species)
|
||||
c2=(@item) ? GameData::Item.get(@item).name : ""
|
||||
c3=getConstantName(PBNatures,@nature)
|
||||
evlist=""
|
||||
for i in 0...@ev
|
||||
if ((@ev&(1<<i))!=0)
|
||||
evlist+="," if evlist.length>0
|
||||
evlist+=["HP","ATK","DEF","SPD","SA","SD"][i]
|
||||
end
|
||||
end
|
||||
c4=(@move1==0) ? "" : getConstantName(PBMoves,@move1)
|
||||
c5=(@move2==0) ? "" : getConstantName(PBMoves,@move2)
|
||||
c6=(@move3==0) ? "" : getConstantName(PBMoves,@move3)
|
||||
c7=(@move4==0) ? "" : getConstantName(PBMoves,@move4)
|
||||
return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}"
|
||||
end
|
||||
|
||||
def tocompact
|
||||
return "#{species},#{item},#{nature},#{move1},#{move2},#{move3},#{move4},#{ev}"
|
||||
end
|
||||
|
||||
def convertMove(move)
|
||||
if isConst?(move,PBMoves,:RETURN) && hasConst?(PBMoves,:FRUSTRATION)
|
||||
move=getConst(PBMoves,:FRUSTRATION)
|
||||
@@ -939,8 +937,8 @@ def pbOrganizedBattleEx(opponent,challengedata,endspeech,endspeechwin)
|
||||
# Remember original data, to be restored after battle
|
||||
challengedata = PokemonChallengeRules.new if !challengedata
|
||||
oldlevels = challengedata.adjustLevels($Trainer.party,opponent.party)
|
||||
olditems = $Trainer.party.transform { |p| p.item }
|
||||
olditems2 = opponent.party.transform { |p| p.item }
|
||||
olditems = $Trainer.party.transform { |p| p.item_id }
|
||||
olditems2 = opponent.party.transform { |p| p.item_id }
|
||||
# Create the battle scene (the visual side of it)
|
||||
scene = pbNewBattleScene
|
||||
# Create the battle class (the mechanics side of it)
|
||||
|
||||
@@ -333,15 +333,12 @@ class BannedItemRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBItems,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.any? { |s| species == s }
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
count=0
|
||||
if pokemon.item!=0 && isSpecies?(pokemon.item,@specieslist)
|
||||
if pokemon.item && isSpecies?(pokemon.item,@specieslist)
|
||||
count+=1
|
||||
end
|
||||
return count==0
|
||||
|
||||
@@ -72,13 +72,8 @@ def pbGetLegalMoves2(species,maxlevel)
|
||||
tmData=pbLoadSpeciesTMData
|
||||
if !$tmMoves
|
||||
$tmMoves=[]
|
||||
itemData=pbLoadItemsData
|
||||
for i in 0...itemData.length
|
||||
next if !itemData[i]
|
||||
atk=itemData[i][8]
|
||||
next if !atk || atk==0
|
||||
next if !tmData[atk]
|
||||
$tmMoves.push(atk)
|
||||
GameData::Item.each do |i|
|
||||
$tmMoves.push(i.move) if i.move && tmData[i.move]
|
||||
end
|
||||
end
|
||||
for atk in $tmMoves
|
||||
@@ -326,7 +321,7 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
end
|
||||
break
|
||||
end
|
||||
item=0
|
||||
item = nil
|
||||
$legalMoves=[] if level!=$legalMovesLevel
|
||||
$legalMoves[species]=pbGetLegalMoves2(species,level) if !$legalMoves[species]
|
||||
itemlist=[
|
||||
@@ -343,13 +338,12 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
# Most used: Leftovers, Life Orb, Choice Band, Choice Scarf, Focus Sash
|
||||
loop do
|
||||
if rand(40)==0
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
item = :LEFTOVERS
|
||||
break
|
||||
end
|
||||
itemsym=itemlist[rand(itemlist.length)]
|
||||
item=getID(PBItems,itemsym)
|
||||
next if item==0
|
||||
case itemsym
|
||||
item = itemlist[rand(itemlist.length)]
|
||||
next if !item
|
||||
case item
|
||||
when :LIGHTBALL
|
||||
next if !isConst?(species,PBSpecies,:PIKACHU)
|
||||
when :SHEDSHELL
|
||||
@@ -384,27 +378,24 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
next if !isConst?(species,PBSpecies,:CUBONE) &&
|
||||
!isConst?(species,PBSpecies,:MAROWAK)
|
||||
end
|
||||
if itemsym==:LIECHIBERRY && (ev&0x02)==0
|
||||
if item == :LIECHIBERRY && (ev&0x02)==0
|
||||
next if rand(2)==0
|
||||
ev|=0x02
|
||||
end
|
||||
if itemsym==:SALACBERRY && (ev&0x08)==0
|
||||
if item == :SALACBERRY && (ev&0x08)==0
|
||||
next if rand(2)==0
|
||||
ev|=0x08
|
||||
end
|
||||
if itemsym==:PETAYABERRY && (ev&0x10)==0
|
||||
if item == :PETAYABERRY && (ev&0x10)==0
|
||||
next if rand(2)==0
|
||||
ev|=0x10
|
||||
end
|
||||
break
|
||||
end
|
||||
if level<10
|
||||
item=(getConst(PBItems,:ORANBERRY) || item) if rand(40)==0 ||
|
||||
isConst?(item,PBItems,:SITRUSBERRY)
|
||||
end
|
||||
if level>20
|
||||
item=(getConst(PBItems,:SITRUSBERRY) || item) if rand(40)==0 ||
|
||||
isConst?(item,PBItems,:ORANBERRY)
|
||||
if level < 10 && GameData::Item.exists?(:ORANBERRY)
|
||||
item = :ORANBERRY if rand(40) == 0 || item == :SITRUSBERRY
|
||||
elsif level > 20 && GameData::Item.exists?(:SITRUSBERRY)
|
||||
item = :SITRUSBERRY if rand(40) == 0 || item == :ORANBERRY
|
||||
end
|
||||
moves=$legalMoves[species]
|
||||
sketch=false
|
||||
@@ -483,9 +474,7 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
ev|=0x10 if rand(10)<8 # Emphasize Special Attack
|
||||
ev&=~0x02 if rand(10)<8 # Deemphasize Attack
|
||||
end
|
||||
if !hasNormal && isConst?(item,PBItems,:SILKSCARF)
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
end
|
||||
item = :LEFTOVERS if !hasNormal && item == :SILKSCARF
|
||||
moves=newmoves
|
||||
break
|
||||
end
|
||||
@@ -493,33 +482,31 @@ def pbRandomPokemonFromRule(rule,trainer)
|
||||
for i in 0...4
|
||||
moves[i]=0 if !moves[i]
|
||||
end
|
||||
if isConst?(item,PBItems,:LIGHTCLAY) &&
|
||||
if item == :LIGHTCLAY &&
|
||||
!moves.include?((getConst(PBMoves,:LIGHTSCREEN) || -1)) &&
|
||||
!moves.include?((getConst(PBMoves,:REFLECT) || -1))
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
item = :LEFTOVERS
|
||||
end
|
||||
if isConst?(item,PBItems,:BLACKSLUDGE)
|
||||
if item == :BLACKSLUDGE
|
||||
type1 = pbGetSpeciesData(species,0,SpeciesData::TYPE1)
|
||||
type2 = pbGetSpeciesData(species,0,SpeciesData::TYPE2) || type1
|
||||
if !isConst?(type1,PBTypes,:POISON) && !isConst?(type2,PBTypes,:POISON)
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
item = :LEFTOVERS
|
||||
end
|
||||
end
|
||||
if isConst?(item,PBItems,:HEATROCK) &&
|
||||
!moves.include?((getConst(PBMoves,:SUNNYDAY) || -1))
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
if item == :HEATROCK && !moves.include?((getConst(PBMoves,:SUNNYDAY) || -1))
|
||||
item = :LEFTOVERS
|
||||
end
|
||||
if isConst?(item,PBItems,:DAMPROCK) &&
|
||||
!moves.include?((getConst(PBMoves,:RAINDANCE) || -1))
|
||||
item=getID(PBItems,:LEFTOVERS)
|
||||
if item == :DAMPROCK && !moves.include?((getConst(PBMoves,:RAINDANCE) || -1))
|
||||
item = :LEFTOVERS
|
||||
end
|
||||
if moves.include?((getConst(PBMoves,:REST) || -1))
|
||||
item=getID(PBItems,:LUMBERRY) if rand(3)==0
|
||||
item=getID(PBItems,:CHESTOBERRY) if rand(4)==0
|
||||
item = :LUMBERRY if rand(3)==0
|
||||
item = :CHESTOBERRY if rand(4)==0
|
||||
end
|
||||
pk=PBPokemon.new(species,item,nature,moves[0],moves[1],moves[2],moves[3],ev)
|
||||
pkmn=pk.createPokemon(level,31,trainer)
|
||||
i+=1
|
||||
pk = PBPokemon.new(species, item, nature, moves[0], moves[1], moves[2], moves[3], ev)
|
||||
pkmn = pk.createPokemon(level, 31, trainer)
|
||||
i += 1
|
||||
break if rule.ruleset.isPokemonValid?(pkmn)
|
||||
end
|
||||
return pkmn
|
||||
@@ -874,7 +861,7 @@ def pbDecideWinnerScore(party0,party1,rating)
|
||||
end
|
||||
basestatsum=baseStatTotal(party0[i].species)
|
||||
score+=basestatsum/10
|
||||
score+=10 if party0[i].item!=0 # Not in Battle Dome ranking
|
||||
score+=10 if party0[i].item # Not in Battle Dome ranking
|
||||
end
|
||||
score+=rating+rand(32)
|
||||
return score
|
||||
@@ -913,7 +900,7 @@ def pbRuledBattle(team1,team2,rule)
|
||||
p.level=level
|
||||
p.calcStats
|
||||
end
|
||||
items1[i]=p.item
|
||||
items1[i]=p.item_id
|
||||
trainer1.party.push(p)
|
||||
end
|
||||
team2.each_with_index do |p,i|
|
||||
@@ -922,7 +909,7 @@ def pbRuledBattle(team1,team2,rule)
|
||||
p.level=level
|
||||
p.calcStats
|
||||
end
|
||||
items2[i]=p.item
|
||||
items2[i]=p.item_id
|
||||
trainer2.party.push(p)
|
||||
end
|
||||
scene=PokeBattle_DebugSceneNoLogging.new
|
||||
|
||||
@@ -77,6 +77,8 @@ def pbSetUpSystem
|
||||
begin
|
||||
consts = pbSafeLoad("Data/Constants.rxdata")
|
||||
consts = [] if !consts
|
||||
GameData::Ability.load
|
||||
GameData::Item.load
|
||||
rescue
|
||||
consts = []
|
||||
end
|
||||
|
||||
@@ -259,18 +259,17 @@ end
|
||||
|
||||
#===============================================================================
|
||||
# Load item icons
|
||||
# TODO: Put these methods into GameData::Item.
|
||||
#===============================================================================
|
||||
def pbItemIconFile(item)
|
||||
return nil if !item
|
||||
bitmapFileName = nil
|
||||
if item==0
|
||||
bitmapFileName = sprintf("Graphics/Icons/itemBack")
|
||||
else
|
||||
bitmapFileName = sprintf("Graphics/Icons/item%s",getConstantName(PBItems,item)) rescue nil
|
||||
if item
|
||||
itm = GameData::Item.get(item)
|
||||
bitmapFileName = sprintf("Graphics/Icons/item%s",itm.id.to_s) rescue nil
|
||||
if !pbResolveBitmap(bitmapFileName)
|
||||
bitmapFileName = sprintf("Graphics/Icons/item%03d",item)
|
||||
if !pbResolveBitmap(bitmapFileName) && pbIsMachine?(item)
|
||||
move = pbGetMachine(item)
|
||||
bitmapFileName = sprintf("Graphics/Icons/item%03d",itm.id_number)
|
||||
if !pbResolveBitmap(bitmapFileName) && itm.is_machine?
|
||||
move = itm.move
|
||||
type = pbGetMoveData(move,MoveData::TYPE)
|
||||
bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil
|
||||
if !pbResolveBitmap(bitmapFileName)
|
||||
@@ -279,14 +278,16 @@ def pbItemIconFile(item)
|
||||
end
|
||||
bitmapFileName = "Graphics/Icons/item000" if !pbResolveBitmap(bitmapFileName)
|
||||
end
|
||||
else
|
||||
bitmapFileName = sprintf("Graphics/Icons/itemBack")
|
||||
end
|
||||
return bitmapFileName
|
||||
end
|
||||
|
||||
def pbHeldItemIconFile(item) # Used in the party screen
|
||||
return nil if !item || item==0
|
||||
namebase = (pbIsMail?(item)) ? "mail" : "item"
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%s",namebase,getConstantName(PBItems,item)) rescue nil
|
||||
namebase = (GameData::Item.get(item).is_mail?) ? "mail" : "item"
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%s",namebase,GameData::Item.get(item).id.to_s) rescue nil
|
||||
if !pbResolveBitmap(bitmapFileName)
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%03d",namebase,item)
|
||||
if !pbResolveBitmap(bitmapFileName)
|
||||
@@ -303,7 +304,7 @@ end
|
||||
#===============================================================================
|
||||
def pbMailBackFile(item)
|
||||
return nil if !item
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Mail/mail_%s",getConstantName(PBItems,item)) rescue nil
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Mail/mail_%s",GameData::Item.get(item).id.to_s) rescue nil
|
||||
if !pbResolveBitmap(bitmapFileName)
|
||||
bitmapFileName = sprintf("Graphics/Pictures/Mail/mail_%03d",item)
|
||||
end
|
||||
|
||||
@@ -495,7 +495,7 @@ def pbHasEgg?(species)
|
||||
return false if compat.include?(getConst(PBEggGroups,:Ditto))
|
||||
baby = pbGetBabySpecies(species)
|
||||
return true if species==baby # Is a basic species
|
||||
baby = pbGetBabySpecies(species,0,0)
|
||||
baby = pbGetBabySpecies(species,true)
|
||||
return true if species==baby # Is an egg species without incense
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -1064,22 +1064,21 @@ def pbChooseMove(pokemon,variableNumber,nameVarNumber)
|
||||
$game_map.need_refresh = true if $game_map
|
||||
end
|
||||
|
||||
def pbConvertItemToItem(variable,array)
|
||||
item = pbGet(variable)
|
||||
pbSet(variable,0)
|
||||
def pbConvertItemToItem(variable, array)
|
||||
item = GameData::Item.get(pbGet(variable))
|
||||
pbSet(variable, nil)
|
||||
for i in 0...(array.length/2)
|
||||
if isConst?(item,PBItems,array[2*i])
|
||||
pbSet(variable,getID(PBItems,array[2*i+1]))
|
||||
return
|
||||
end
|
||||
next if item != array[2 * i]
|
||||
pbSet(variable, array[2 * i + 1])
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def pbConvertItemToPokemon(variable,array)
|
||||
item = pbGet(variable)
|
||||
pbSet(variable,0)
|
||||
item = GameData::Item.get(pbGet(variable))
|
||||
pbSet(variable, 0)
|
||||
for i in 0...(array.length/2)
|
||||
next if !isConst?(item,PBItems,array[2*i])
|
||||
next if item != array[2 * i]
|
||||
pbSet(variable,getID(PBSpecies,array[2*i+1]))
|
||||
return
|
||||
end
|
||||
|
||||
@@ -490,16 +490,17 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
|
||||
# Item options
|
||||
#=============================================================================
|
||||
when "additem"
|
||||
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new(0)) { |button,item|
|
||||
if button==Input::C && item && item>0
|
||||
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new) { |button,item|
|
||||
if button==Input::C && item
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(1,BAG_MAX_PER_SLOT)
|
||||
params.setInitialValue(1)
|
||||
params.setCancelValue(0)
|
||||
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
|
||||
qty = pbMessageChooseNumber(_INTL("Add how many {1}?",
|
||||
GameData::Item.get(item).name_plural), params)
|
||||
if qty>0
|
||||
$PokemonBag.pbStoreItem(item,qty)
|
||||
pbMessage(_INTL("Gave {1}x {2}.",qty,PBItems.getName(item)))
|
||||
pbMessage(_INTL("Gave {1}x {2}.",qty,GameData::Item.get(item).name))
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -510,14 +511,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
|
||||
params.setCancelValue(0)
|
||||
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
|
||||
if qty>0
|
||||
itemconsts = []
|
||||
for i in PBItems.constants
|
||||
itemconsts.push(PBItems.const_get(i))
|
||||
end
|
||||
itemconsts.sort! { |a,b| a<=>b }
|
||||
for i in itemconsts
|
||||
$PokemonBag.pbStoreItem(i,qty)
|
||||
end
|
||||
GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) }
|
||||
pbMessage(_INTL("The Bag was filled with {1} of each item.",qty))
|
||||
end
|
||||
when "emptybag"
|
||||
@@ -731,6 +725,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
|
||||
#=============================================================================
|
||||
when "setmetadata"
|
||||
pbMetadataScreen(pbDefaultMap)
|
||||
# TODO: Only need to reload the metadata.
|
||||
pbClearData
|
||||
when "mapconnections"
|
||||
pbFadeOutIn { pbConnectionsEditor }
|
||||
@@ -745,8 +740,9 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
|
||||
pbEncounterEditorMap(encdata,map)
|
||||
end
|
||||
save_data(encdata,"Data/encounters.dat")
|
||||
# TODO: Only need to reload the encounters data.
|
||||
pbClearData
|
||||
pbSaveEncounterData
|
||||
pbSaveEncounterData # Rewrite PBS file encounters.txt
|
||||
when "trainertypes"
|
||||
pbFadeOutIn { pbTrainerTypeEditor }
|
||||
when "edittrainers"
|
||||
|
||||
@@ -433,7 +433,7 @@ module PokemonDebugMixin
|
||||
oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability"
|
||||
commands = []
|
||||
for i in abils
|
||||
commands.push(((i[1]<2) ? "" : "(H) ") + PokemonData::Ability.get(i[0]).name)
|
||||
commands.push(((i[1]<2) ? "" : "(H) ") + GameData::Ability.get(i[0]).name)
|
||||
end
|
||||
commands.push(_INTL("Remove override"))
|
||||
msg = [_INTL("Ability {1} is natural.",oldabil),
|
||||
@@ -615,8 +615,8 @@ module PokemonDebugMixin
|
||||
when "setpokeball"
|
||||
commands = []; balls = []
|
||||
for key in $BallTypes.keys
|
||||
item = getID(PBItems,$BallTypes[key])
|
||||
balls.push([key.to_i,PBItems.getName(item)]) if item && item>0
|
||||
item = GameData::Item.try_get($BallTypes[key])
|
||||
balls.push([key.to_i, item.name]) if item
|
||||
end
|
||||
balls.sort! { |a,b| a[1]<=>b[1] }
|
||||
cmd = 0
|
||||
@@ -629,7 +629,7 @@ module PokemonDebugMixin
|
||||
commands.push(i[1])
|
||||
end
|
||||
loop do
|
||||
oldball = PBItems.getName(pbBallTypeToItem(pkmn.ballused))
|
||||
oldball = pbBallTypeToItem(pkmn.ballused).name
|
||||
cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd)
|
||||
break if cmd<0
|
||||
pkmn.ballused = balls[cmd][0]
|
||||
|
||||
@@ -298,15 +298,17 @@ end
|
||||
def pbTrainerTypeEditor
|
||||
selection = 0
|
||||
trainerTypes = [
|
||||
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBTrainers::XXX.")],
|
||||
[_INTL("Trainer Name"),StringProperty,_INTL("Name of the trainer type as displayed by the game.")],
|
||||
[_INTL("Money Per Level"),LimitProperty.new(9999),_INTL("Player earns this amount times the highest level among the trainer's Pokémon.")],
|
||||
[_INTL("Battle BGM"),BGMProperty,_INTL("BGM played in battles against trainers of this type.")],
|
||||
[_INTL("Battle End ME"),MEProperty,_INTL("ME played when player wins battles against trainers of this type.")],
|
||||
[_INTL("Battle Intro ME"),MEProperty,_INTL("ME played before battles against trainers of this type.")],
|
||||
[_INTL("Gender"),EnumProperty.new([_INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),_INTL("Gender of this Trainer type.")],
|
||||
[_INTL("Skill"),LimitProperty.new(9999),_INTL("Skill level of this Trainer type.")],
|
||||
[_INTL("Skill Codes"),StringProperty,_INTL("Letters/phrases representing AI modifications of trainers of this type.")],
|
||||
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that appears in constructs like PBTrainers::XXX.")],
|
||||
[_INTL("Trainer Name"), StringProperty, _INTL("Name of the trainer type as displayed by the game.")],
|
||||
[_INTL("Money Per Level"), LimitProperty.new(9999), _INTL("Player earns this amount times the highest level among the trainer's Pokémon.")],
|
||||
[_INTL("Battle BGM"), BGMProperty, _INTL("BGM played in battles against trainers of this type.")],
|
||||
[_INTL("Battle End ME"), MEProperty, _INTL("ME played when player wins battles against trainers of this type.")],
|
||||
[_INTL("Battle Intro ME"), MEProperty, _INTL("ME played before battles against trainers of this type.")],
|
||||
[_INTL("Gender"), EnumProperty.new([
|
||||
_INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),
|
||||
_INTL("Gender of this Trainer type.")],
|
||||
[_INTL("Skill"), LimitProperty.new(9999), _INTL("Skill level of this Trainer type.")],
|
||||
[_INTL("Skill Codes"), StringProperty, _INTL("Letters/phrases representing AI modifications of trainers of this type.")],
|
||||
]
|
||||
pbListScreenBlock(_INTL("Trainer Types"),TrainerTypeLister.new(selection,true)) { |button,trtype|
|
||||
if trtype
|
||||
@@ -354,24 +356,24 @@ module TrainerBattleProperty
|
||||
def self.set(settingname,oldsetting)
|
||||
return nil if !oldsetting
|
||||
properties = [
|
||||
[_INTL("Trainer Type"),TrainerTypeProperty,_INTL("Name of the trainer type for this Trainer.")],
|
||||
[_INTL("Trainer Name"),StringProperty,_INTL("Name of the Trainer.")],
|
||||
[_INTL("Battle ID"),LimitProperty.new(9999),_INTL("ID used to distinguish Trainers with the same name and trainer type.")],
|
||||
[_INTL("Lose Text"),StringProperty,_INTL("Message shown in battle when the Trainer is defeated.")],
|
||||
[_INTL("Pokémon 1"),TrainerPokemonProperty,_INTL("First Pokémon.")],
|
||||
[_INTL("Pokémon 2"),TrainerPokemonProperty,_INTL("Second Pokémon.")],
|
||||
[_INTL("Pokémon 3"),TrainerPokemonProperty,_INTL("Third Pokémon.")],
|
||||
[_INTL("Pokémon 4"),TrainerPokemonProperty,_INTL("Fourth Pokémon.")],
|
||||
[_INTL("Pokémon 5"),TrainerPokemonProperty,_INTL("Fifth Pokémon.")],
|
||||
[_INTL("Pokémon 6"),TrainerPokemonProperty,_INTL("Sixth Pokémon.")],
|
||||
[_INTL("Item 1"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 2"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 3"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 4"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 5"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 6"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 7"),ItemProperty,_INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 8"),ItemProperty,_INTL("Item used by the Trainer during battle.")]
|
||||
[_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Name of the trainer type for this Trainer.")],
|
||||
[_INTL("Trainer Name"), StringProperty, _INTL("Name of the Trainer.")],
|
||||
[_INTL("Battle ID"), LimitProperty.new(9999), _INTL("ID used to distinguish Trainers with the same name and trainer type.")],
|
||||
[_INTL("Lose Text"), StringProperty, _INTL("Message shown in battle when the Trainer is defeated.")],
|
||||
[_INTL("Pokémon 1"), TrainerPokemonProperty, _INTL("First Pokémon.")],
|
||||
[_INTL("Pokémon 2"), TrainerPokemonProperty, _INTL("Second Pokémon.")],
|
||||
[_INTL("Pokémon 3"), TrainerPokemonProperty, _INTL("Third Pokémon.")],
|
||||
[_INTL("Pokémon 4"), TrainerPokemonProperty, _INTL("Fourth Pokémon.")],
|
||||
[_INTL("Pokémon 5"), TrainerPokemonProperty, _INTL("Fifth Pokémon.")],
|
||||
[_INTL("Pokémon 6"), TrainerPokemonProperty, _INTL("Sixth Pokémon.")],
|
||||
[_INTL("Item 1"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 2"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 3"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 4"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 5"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 6"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 7"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
|
||||
[_INTL("Item 8"), ItemProperty, _INTL("Item used by the Trainer during battle.")]
|
||||
]
|
||||
if !pbPropertyList(settingname,oldsetting,properties,true)
|
||||
return nil
|
||||
@@ -457,7 +459,7 @@ def pbTrainerBattleEditor
|
||||
trainerdata = [
|
||||
data[0],
|
||||
data[1],
|
||||
[data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17]].find_all { |i| i && i!=0 }, # Item list
|
||||
[data[10],data[11],data[12],data[13],data[14],data[15],data[16],data[17]].compact!, # Item list
|
||||
[data[4],data[5],data[6],data[7],data[8],data[9]].find_all { |i| i && i[TrainerData::SPECIES]!=0 }, # Pokémon list
|
||||
data[2],
|
||||
data[3]
|
||||
@@ -502,24 +504,24 @@ module TrainerPokemonProperty
|
||||
end
|
||||
mLevel = PBExperience.maxLevel
|
||||
properties = [
|
||||
[_INTL("Species"),SpeciesProperty,_INTL("Species of the Pokémon.")],
|
||||
[_INTL("Level"),NonzeroLimitProperty.new(mLevel),_INTL("Level of the Pokémon (1-{1}).",mLevel)],
|
||||
[_INTL("Held item"),ItemProperty,_INTL("Item held by the Pokémon.")],
|
||||
[_INTL("Move 1"),MoveProperty2.new(oldsetting),_INTL("First move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 2"),MoveProperty2.new(oldsetting),_INTL("Second move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 3"),MoveProperty2.new(oldsetting),_INTL("Third move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 4"),MoveProperty2.new(oldsetting),_INTL("Fourth move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Ability"),LimitProperty2.new(5),_INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
|
||||
[_INTL("Gender"),GenderProperty.new,_INTL("Gender of the Pokémon.")],
|
||||
[_INTL("Form"),LimitProperty2.new(999),_INTL("Form of the Pokémon.")],
|
||||
[_INTL("Shiny"),BooleanProperty2,_INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
|
||||
[_INTL("Nature"),NatureProperty,_INTL("Nature of the Pokémon.")],
|
||||
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
|
||||
[_INTL("Happiness"),LimitProperty2.new(255),_INTL("Happiness of the Pokémon (0-255).")],
|
||||
[_INTL("Nickname"),StringProperty,_INTL("Name of the Pokémon.")],
|
||||
[_INTL("Shadow"),BooleanProperty2,_INTL("If set to true, the Pokémon is a Shadow Pokémon.")],
|
||||
[_INTL("Ball"),BallProperty.new(oldsetting),_INTL("The kind of Poké Ball the Pokémon is kept in.")],
|
||||
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
|
||||
[_INTL("Species"), SpeciesProperty, _INTL("Species of the Pokémon.")],
|
||||
[_INTL("Level"), NonzeroLimitProperty.new(mLevel), _INTL("Level of the Pokémon (1-{1}).",mLevel)],
|
||||
[_INTL("Held item"), ItemProperty, _INTL("Item held by the Pokémon.")],
|
||||
[_INTL("Move 1"), MoveProperty2.new(oldsetting), _INTL("First move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 2"), MoveProperty2.new(oldsetting), _INTL("Second move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 3"), MoveProperty2.new(oldsetting), _INTL("Third move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Move 4"), MoveProperty2.new(oldsetting), _INTL("Fourth move. Leave all moves blank (use Z key) to give it a wild moveset.")],
|
||||
[_INTL("Ability"), LimitProperty2.new(5), _INTL("Ability flag. 0=first ability, 1=second ability, 2-5=hidden ability.")],
|
||||
[_INTL("Gender"), GenderProperty.new, _INTL("Gender of the Pokémon.")],
|
||||
[_INTL("Form"), LimitProperty2.new(999), _INTL("Form of the Pokémon.")],
|
||||
[_INTL("Shiny"), BooleanProperty2, _INTL("If set to true, the Pokémon is a different-colored Pokémon.")],
|
||||
[_INTL("Nature"), NatureProperty, _INTL("Nature of the Pokémon.")],
|
||||
[_INTL("IVs"), IVsProperty.new(Pokemon::IV_STAT_LIMIT), _INTL("Individual values for each of the Pokémon's stats.")],
|
||||
[_INTL("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
|
||||
[_INTL("Nickname"), StringProperty, _INTL("Name of the Pokémon.")],
|
||||
[_INTL("Shadow"), BooleanProperty2, _INTL("If set to true, the Pokémon is a Shadow Pokémon.")],
|
||||
[_INTL("Ball"), BallProperty.new(oldsetting), _INTL("The kind of Poké Ball the Pokémon is kept in.")],
|
||||
[_INTL("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
|
||||
]
|
||||
pbPropertyList(settingname,oldsetting,properties,false)
|
||||
return nil if !oldsetting[TrainerData::SPECIES] || oldsetting[TrainerData::SPECIES]==0
|
||||
@@ -535,7 +537,7 @@ module TrainerPokemonProperty
|
||||
end
|
||||
moves.compact!
|
||||
ret[TrainerData::MOVES] = moves if moves.length>0
|
||||
# Remove unnecessarily nils from the end of ret
|
||||
# Remove unnecessary nils from the end of ret
|
||||
ret.pop while ret.last.nil? && ret.size>0
|
||||
return ret
|
||||
end
|
||||
@@ -582,153 +584,142 @@ end
|
||||
def pbItemEditor
|
||||
selection = 0
|
||||
items = [
|
||||
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBItems::XXX.")],
|
||||
[_INTL("Item Name"),ItemNameProperty,_INTL("Name of the item as displayed by the game.")],
|
||||
[_INTL("Item Name Plural"),ItemNameProperty,_INTL("Plural name of the item as displayed by the game.")],
|
||||
[_INTL("Pocket"),PocketProperty,_INTL("Pocket in the bag where the item is stored.")],
|
||||
[_INTL("Purchase price"),LimitProperty.new(999999),_INTL("Purchase price of the item.")],
|
||||
[_INTL("Description"),StringProperty,_INTL("Description of the item")],
|
||||
[_INTL("Use Out of Battle"),EnumProperty.new([
|
||||
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("Use directly"),
|
||||
_INTL("TM"),_INTL("HM"),_INTL("On a Pokémon reusable")]),
|
||||
_INTL("Specifies how this item can be used outside of battle.")],
|
||||
[_INTL("Use In Battle"),EnumProperty.new([
|
||||
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("On Pokémon's move"),
|
||||
_INTL("On battler"),_INTL("On foe battler"),_INTL("Use directly"),
|
||||
_INTL("On a Pokémon reusable"),_INTL("On Pokémon's move reusable"),
|
||||
_INTL("On battler reusable"),_INTL("On foe battler reusable"),
|
||||
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that is used as a symbol like :XXX.")],
|
||||
[_INTL("Item Name"), ItemNameProperty, _INTL("Name of the item as displayed by the game.")],
|
||||
[_INTL("Item Name Plural"), ItemNameProperty, _INTL("Plural name of the item as displayed by the game.")],
|
||||
[_INTL("Pocket"), PocketProperty, _INTL("Pocket in the bag where the item is stored.")],
|
||||
[_INTL("Purchase price"), LimitProperty.new(999999), _INTL("Purchase price of the item.")],
|
||||
[_INTL("Description"), StringProperty, _INTL("Description of the item")],
|
||||
[_INTL("Use Out of Battle"), EnumProperty.new([
|
||||
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("Use directly"),
|
||||
_INTL("TM"), _INTL("HM"), _INTL("On a Pokémon reusable")]),
|
||||
_INTL("Specifies how this item can be used outside of battle.")],
|
||||
[_INTL("Use In Battle"), EnumProperty.new([
|
||||
_INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("On Pokémon's move"),
|
||||
_INTL("On battler"), _INTL("On foe battler"), _INTL("Use directly"),
|
||||
_INTL("On a Pokémon reusable"), _INTL("On Pokémon's move reusable"),
|
||||
_INTL("On battler reusable"), _INTL("On foe battler reusable"),
|
||||
_INTL("Use directly reusable")]),
|
||||
_INTL("Specifies how this item can be used within a battle.")],
|
||||
[_INTL("Special Items"),EnumProperty.new([
|
||||
_INTL("None of below"),_INTL("Mail"),_INTL("Mail with Pictures"),
|
||||
_INTL("Snag Ball"),_INTL("Poké Ball"),_INTL("Plantable Berry"),
|
||||
_INTL("Key Item"),_INTL("Evolution Stone"),_INTL("Fossil"),
|
||||
_INTL("Apricorn"),_INTL("Type-boosting Gem"),_INTL("Mulch"),
|
||||
_INTL("Specifies how this item can be used within a battle.")],
|
||||
[_INTL("Special Items"), EnumProperty.new([
|
||||
_INTL("None of below"), _INTL("Mail"), _INTL("Mail with Pictures"),
|
||||
_INTL("Snag Ball"), _INTL("Poké Ball"), _INTL("Plantable Berry"),
|
||||
_INTL("Key Item"), _INTL("Evolution Stone"), _INTL("Fossil"),
|
||||
_INTL("Apricorn"), _INTL("Type-boosting Gem"), _INTL("Mulch"),
|
||||
_INTL("Mega Stone")]),
|
||||
_INTL("For special kinds of items.")],
|
||||
[_INTL("Machine"),MoveProperty,_INTL("Move taught by this TM or HM.")]
|
||||
_INTL("For special kinds of items.")],
|
||||
[_INTL("Machine"), MoveProperty, _INTL("Move taught by this TM or HM.")]
|
||||
]
|
||||
pbListScreenBlock(_INTL("Items"),ItemLister.new(selection,true)) { |button,trtype|
|
||||
if trtype
|
||||
pbListScreenBlock(_INTL("Items"), ItemLister.new(selection, true)) { |button, item|
|
||||
if item
|
||||
if button==Input::A
|
||||
if trtype>=0
|
||||
if item.is_a?(Symbol)
|
||||
if pbConfirmMessageSerious("Delete this item?")
|
||||
data = pbLoadItemsData
|
||||
removeConstantValue(PBItems,trtype)
|
||||
data.delete_if { |item| item[0]==trtype }
|
||||
for x in data
|
||||
p x if data[0]==0
|
||||
end
|
||||
save_data(data,"Data/items.dat")
|
||||
$PokemonTemp.itemsData = nil
|
||||
id_number = GameData::Item.get(item).id_number
|
||||
GameData::Item::DATA.delete(item)
|
||||
GameData::Item::DATA.delete(id_number)
|
||||
GameData::Item.save
|
||||
pbSaveItems
|
||||
pbMessage(_INTL("The item was deleted."))
|
||||
end
|
||||
end
|
||||
elsif button==Input::C
|
||||
selection = trtype
|
||||
if selection<0
|
||||
newid = pbItemEditorNew(nil)
|
||||
if newid>=0
|
||||
selection = newid
|
||||
end
|
||||
else
|
||||
data = [getConstantName(PBItems,selection)]
|
||||
itemdata = pbLoadItemsData
|
||||
data.push(itemdata[selection][ItemData::NAME])
|
||||
data.push(itemdata[selection][ItemData::NAME_PLURAL])
|
||||
data.push(itemdata[selection][ItemData::POCKET])
|
||||
data.push(itemdata[selection][ItemData::PRICE])
|
||||
data.push(itemdata[selection][ItemData::DESCRIPTION])
|
||||
data.push(itemdata[selection][ItemData::FIELD_USE])
|
||||
data.push(itemdata[selection][ItemData::BATTLE_USE])
|
||||
data.push(itemdata[selection][ItemData::TYPE])
|
||||
data.push(itemdata[selection][ItemData::MOVE])
|
||||
save = pbPropertyList(data[ItemData::NAME],data,items,true)
|
||||
if item.is_a?(Symbol)
|
||||
itm = GameData::Item.get(item)
|
||||
data = [
|
||||
itm.id.to_s,
|
||||
itm.real_name,
|
||||
itm.real_name_plural,
|
||||
itm.pocket,
|
||||
itm.price,
|
||||
itm.real_description,
|
||||
itm.field_use,
|
||||
itm.battle_use,
|
||||
itm.type,
|
||||
itm.move || 0
|
||||
]
|
||||
save = pbPropertyList(itm.id.to_s, data, items, true)
|
||||
if save
|
||||
itemdata[selection][ItemData::NAME] = data[ItemData::NAME]
|
||||
itemdata[selection][ItemData::NAME_PLURAL] = data[ItemData::NAME_PLURAL]
|
||||
itemdata[selection][ItemData::POCKET] = data[ItemData::POCKET]
|
||||
itemdata[selection][ItemData::PRICE] = data[ItemData::PRICE]
|
||||
itemdata[selection][ItemData::DESCRIPTION] = data[ItemData::DESCRIPTION]
|
||||
itemdata[selection][ItemData::FIELD_USE] = data[ItemData::FIELD_USE]
|
||||
itemdata[selection][ItemData::BATTLE_USE] = data[ItemData::BATTLE_USE]
|
||||
itemdata[selection][ItemData::TYPE] = data[ItemData::TYPE]
|
||||
itemdata[selection][ItemData::MOVE] = data[ItemData::MOVE]
|
||||
save_data(itemdata,"Data/items.dat")
|
||||
$PokemonTemp.itemsData = nil
|
||||
# Construct item hash
|
||||
item_hash = {
|
||||
:id_number => itm.id_number,
|
||||
:id => itm.id,
|
||||
:name => data[1],
|
||||
:name_plural => data[2],
|
||||
:pocket => data[3],
|
||||
:price => data[4],
|
||||
:description => data[5],
|
||||
:field_use => data[6],
|
||||
:battle_use => data[7],
|
||||
:type => data[8],
|
||||
:move => (data[9] > 0) ? data[9] : nil
|
||||
}
|
||||
# Add item's data to records
|
||||
GameData::Item::DATA[itm.id_number] = GameData::Item::DATA[itm.id] = GameData::Item.new(item_hash)
|
||||
GameData::Item.save
|
||||
pbSaveItems
|
||||
end
|
||||
else # Add a new item
|
||||
pbItemEditorNew(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbItemEditorNew(defaultname)
|
||||
itemdata = pbLoadItemsData
|
||||
# Get the first blank ID for the new item to use.
|
||||
maxid = PBItems.maxValue+1
|
||||
index = maxid
|
||||
itemname = pbMessageFreeText(_INTL("Please enter the item's name."),
|
||||
(defaultname) ? defaultname.gsub(/_+/," ") : "",false,30)
|
||||
if itemname=="" && !defaultname
|
||||
return -1
|
||||
else
|
||||
# Create a default name if there is none.
|
||||
if !defaultname
|
||||
defaultname = itemname.gsub(/[^A-Za-z0-9_]/,"")
|
||||
defaultname = defaultname.sub(/^([a-z])/) { $1.upcase }
|
||||
if defaultname.length==0
|
||||
defaultname = sprintf("Item%03d",index)
|
||||
elsif !defaultname[0,1][/[A-Z]/]
|
||||
defaultname = "Item"+defaultname
|
||||
end
|
||||
end
|
||||
itemname = defaultname if itemname==""
|
||||
# Create an internal name based on the item name.
|
||||
cname = itemname.gsub(/é/,"e")
|
||||
cname = cname.gsub(/[^A-Za-z0-9_]/,"")
|
||||
cname = cname.upcase
|
||||
if hasConst?(PBItems,cname)
|
||||
suffix = 1
|
||||
100.times do
|
||||
tname = sprintf("%s_%d",cname,suffix)
|
||||
if !hasConst?(PBItems,tname)
|
||||
cname = tname
|
||||
break
|
||||
end
|
||||
suffix += 1
|
||||
end
|
||||
end
|
||||
if hasConst?(PBItems,cname)
|
||||
pbMessage(_INTL("Failed to create the item. Choose a different name."))
|
||||
return -1
|
||||
end
|
||||
pocket = PocketProperty.set("",0)
|
||||
return -1 if pocket==0
|
||||
price = LimitProperty.new(999999).set(_INTL("Purchase price"),-1)
|
||||
return -1 if price==-1
|
||||
desc = StringProperty.set(_INTL("Description"),"")
|
||||
# Item list will create record automatically
|
||||
itemdata[index][ItemData::ID] = index
|
||||
itemdata[index][ItemData::NAME] = itemname
|
||||
itemdata[index][ItemData::POCKET] = pocket
|
||||
itemdata[index][ItemData::PRICE] = price
|
||||
itemdata[index][ItemData::DESCRIPTION] = desc
|
||||
itemdata[index][ItemData::FIELD_USE] = 0
|
||||
itemdata[index][ItemData::BATTLE_USE] = 0
|
||||
itemdata[index][ItemData::TYPE] = 0
|
||||
itemdata[index][ItemData::MOVE] = 0
|
||||
PBItems.const_set(cname,index)
|
||||
save_data(itemdata,"Data/items.dat")
|
||||
$PokemonTemp.itemsData = nil
|
||||
pbSaveItems
|
||||
pbMessage(_INTL("The item was created (ID: {1}).",index))
|
||||
pbMessage(_ISPRINTF("Put the item's graphic (item{1:03d}.png or item{2:s}.png) in Graphics/Icons, or it will be blank.",
|
||||
index,getConstantName(PBItems,index)))
|
||||
return index
|
||||
def pbItemEditorNew(default_name)
|
||||
# Get an unused ID number for the new item
|
||||
max_id = 0
|
||||
GameData::Item.each { |i| max_id = i.id_number if max_id < i.id_number }
|
||||
id_number = max_id + 1
|
||||
# Choose a name
|
||||
name = pbMessageFreeText(_INTL("Please enter the item's name."),
|
||||
(default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
|
||||
if name == ""
|
||||
return if !default_name
|
||||
name = default_name
|
||||
end
|
||||
# Generate an ID based on the item name
|
||||
id = name.gsub(/é/, "e")
|
||||
id = id.gsub(/[^A-Za-z0-9_]/, "")
|
||||
id = id.upcase
|
||||
if GameData::Item.exists?(id)
|
||||
for i in 1..100
|
||||
trial_id = sprintf("%s_%d", id, i)
|
||||
next if GameData::Item.exists?(trial_id)
|
||||
id = trial_id
|
||||
break
|
||||
end
|
||||
end
|
||||
if GameData::Item.exists?(id)
|
||||
pbMessage(_INTL("Failed to create the item. Choose a different name."))
|
||||
return
|
||||
end
|
||||
# Choose a pocket
|
||||
pocket = PocketProperty.set("", 0)
|
||||
return if pocket == 0
|
||||
# Choose a price
|
||||
price = LimitProperty.new(999999).set(_INTL("Purchase price"), -1)
|
||||
return if price == -1
|
||||
# Choose a description
|
||||
description = StringProperty.set(_INTL("Description"), "")
|
||||
# Construct item hash
|
||||
item_hash = {
|
||||
:id_number => id_number,
|
||||
:id => id.to_sym,
|
||||
:name => name,
|
||||
:name_plural => name + "s",
|
||||
:pocket => pocket,
|
||||
:price => price,
|
||||
:description => description
|
||||
}
|
||||
# Add item's data to records
|
||||
GameData::Item::DATA[id_number] = GameData::Item::DATA[id.to_sym] = GameData::Item.new(item_hash)
|
||||
GameData::Item.save
|
||||
pbSaveItems
|
||||
pbMessage(_INTL("The item {1} was created (ID: {2}).", name, id.to_s))
|
||||
pbMessage(_ISPRINTF("Put the item's graphic (item{1:s}.png or item{2:03d}.png) in Graphics/Icons, or it will be blank.",
|
||||
id.to_s, id_number))
|
||||
end
|
||||
|
||||
|
||||
@@ -741,71 +732,71 @@ def pbPokemonEditor
|
||||
metrics = pbLoadSpeciesMetrics
|
||||
selection = 0
|
||||
species = [
|
||||
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")],
|
||||
[_INTL("InternalName"),ReadOnlyProperty,_INTL("Internal name of the Pokémon.")],
|
||||
[_INTL("Type1"),TypeProperty,_INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")],
|
||||
[_INTL("Type2"),TypeProperty,_INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")],
|
||||
[_INTL("BaseStats"),BaseStatsProperty,_INTL("Base stats of the Pokémon.")],
|
||||
[_INTL("GenderRate"),EnumProperty.new([
|
||||
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")],
|
||||
[_INTL("InternalName"), ReadOnlyProperty, _INTL("Internal name of the Pokémon.")],
|
||||
[_INTL("Type1"), TypeProperty, _INTL("Pokémon's type. If same as Type2, this Pokémon has a single type.")],
|
||||
[_INTL("Type2"), TypeProperty, _INTL("Pokémon's type. If same as Type1, this Pokémon has a single type.")],
|
||||
[_INTL("BaseStats"), BaseStatsProperty, _INTL("Base stats of the Pokémon.")],
|
||||
[_INTL("GenderRate"), EnumProperty.new([
|
||||
_INTL("Genderless"),_INTL("AlwaysMale"),_INTL("FemaleOneEighth"),
|
||||
_INTL("Female25Percent"),_INTL("Female50Percent"),_INTL("Female75Percent"),
|
||||
_INTL("FemaleSevenEighths"),_INTL("AlwaysFemale")]),
|
||||
_INTL("Proportion of males to females for this species.")],
|
||||
[_INTL("GrowthRate"),EnumProperty.new([
|
||||
_INTL("Proportion of males to females for this species.")],
|
||||
[_INTL("GrowthRate"), EnumProperty.new([
|
||||
_INTL("Medium"),_INTL("Erratic"),_INTL("Fluctuating"),_INTL("Parabolic"),
|
||||
_INTL("Fast"),_INTL("Slow")]),
|
||||
_INTL("Pokémon's growth rate.")],
|
||||
[_INTL("BaseEXP"),LimitProperty.new(9999),_INTL("Base experience earned when this species is defeated.")],
|
||||
[_INTL("EffortPoints"),EffortValuesProperty,_INTL("Effort Value points earned when this species is defeated.")],
|
||||
[_INTL("Rareness"),LimitProperty.new(255),_INTL("Catch rate of this species (0-255).")],
|
||||
[_INTL("Happiness"),LimitProperty.new(255),_INTL("Base happiness of this species (0-255).")],
|
||||
[_INTL("Ability1"),AbilityProperty,_INTL("One ability which the Pokémon can have.")],
|
||||
[_INTL("Ability2"),AbilityProperty,_INTL("Another ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 1"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 2"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 3"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 4"),AbilityProperty,_INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("Moves"),MovePoolProperty,_INTL("Moves which the Pokémon learns while levelling up.")],
|
||||
[_INTL("EggMoves"),EggMovesProperty,_INTL("Moves which the Pokémon can learn via breeding.")],
|
||||
[_INTL("Compat1"),EnumProperty.new([
|
||||
_INTL("Pokémon's growth rate.")],
|
||||
[_INTL("BaseEXP"), LimitProperty.new(9999), _INTL("Base experience earned when this species is defeated.")],
|
||||
[_INTL("EffortPoints"), EffortValuesProperty, _INTL("Effort Value points earned when this species is defeated.")],
|
||||
[_INTL("Rareness"), LimitProperty.new(255), _INTL("Catch rate of this species (0-255).")],
|
||||
[_INTL("Happiness"), LimitProperty.new(255), _INTL("Base happiness of this species (0-255).")],
|
||||
[_INTL("Ability1"), AbilityProperty, _INTL("One ability which the Pokémon can have.")],
|
||||
[_INTL("Ability2"), AbilityProperty, _INTL("Another ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 1"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 2"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 3"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("HiddenAbility 4"), AbilityProperty, _INTL("A secret ability which the Pokémon can have.")],
|
||||
[_INTL("Moves"), MovePoolProperty, _INTL("Moves which the Pokémon learns while levelling up.")],
|
||||
[_INTL("EggMoves"), EggMovesProperty, _INTL("Moves which the Pokémon can learn via breeding.")],
|
||||
[_INTL("Compat1"), EnumProperty.new([
|
||||
"Undiscovered","Monster","Water 1","Bug","Flying",
|
||||
"Field","Fairy","Grass","Human-like","Water 3",
|
||||
"Mineral","Amorphous","Water 2","Ditto","Dragon"]),
|
||||
_INTL("Compatibility group (egg group) for breeding purposes.")],
|
||||
[_INTL("Compat2"),EnumProperty.new([
|
||||
_INTL("Compatibility group (egg group) for breeding purposes.")],
|
||||
[_INTL("Compat2"), EnumProperty.new([
|
||||
"Undiscovered","Monster","Water 1","Bug","Flying",
|
||||
"Field","Fairy","Grass","Human-like","Water 3",
|
||||
"Mineral","Amorphous","Water 2","Ditto","Dragon"]),
|
||||
_INTL("Compatibility group (egg group) for breeding purposes.")],
|
||||
[_INTL("StepsToHatch"),LimitProperty.new(99999),_INTL("Number of steps until an egg of this species hatches.")],
|
||||
[_INTL("Height"),NonzeroLimitProperty.new(999),_INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
|
||||
[_INTL("Weight"),NonzeroLimitProperty.new(9999),_INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
|
||||
[_INTL("Color"),EnumProperty.new([
|
||||
_INTL("Compatibility group (egg group) for breeding purposes.")],
|
||||
[_INTL("StepsToHatch"), LimitProperty.new(99999), _INTL("Number of steps until an egg of this species hatches.")],
|
||||
[_INTL("Height"), NonzeroLimitProperty.new(999), _INTL("Height of the Pokémon in 0.1 metres (e.g. 42 = 4.2m).")],
|
||||
[_INTL("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
|
||||
[_INTL("Color"), EnumProperty.new([
|
||||
_INTL("Red"),_INTL("Blue"),_INTL("Yellow"),_INTL("Green"),_INTL("Black"),
|
||||
_INTL("Brown"),_INTL("Purple"),_INTL("Gray"),_INTL("White"),_INTL("Pink")]),
|
||||
_INTL("Pokémon's body color.")],
|
||||
[_INTL("Shape"),LimitProperty.new(14),_INTL("Body shape of this species (0-14).")],
|
||||
[_INTL("Habitat"),EnumProperty.new([
|
||||
_INTL("Pokémon's body color.")],
|
||||
[_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
|
||||
[_INTL("Habitat"), EnumProperty.new([
|
||||
_INTL("None"),_INTL("Grassland"),_INTL("Forest"),_INTL("WatersEdge"),
|
||||
_INTL("Sea"),_INTL("Cave"),_INTL("Mountain"),_INTL("RoughTerrain"),
|
||||
_INTL("Urban"),_INTL("Rare")]),
|
||||
_INTL("The habitat of this species.")],
|
||||
[_INTL("RegionalNumbers"),ReadOnlyProperty,_INTL("Regional Dex numbers for the Pokémon. These are edited elsewhere.")],
|
||||
[_INTL("Kind"),StringProperty,_INTL("Kind of Pokémon species.")],
|
||||
[_INTL("Pokédex"),StringProperty,_INTL("Description of the Pokémon as displayed in the Pokédex.")],
|
||||
[_INTL("FormName"),StringProperty,_INTL("Name of this form of the Pokémon.")],
|
||||
[_INTL("WildItemCommon"),ItemProperty,_INTL("Item commonly held by wild Pokémon of this species.")],
|
||||
[_INTL("WildItemUncommon"),ItemProperty,_INTL("Item uncommonly held by wild Pokémon of this species.")],
|
||||
[_INTL("WildItemRare"),ItemProperty,_INTL("Item rarely held by wild Pokémon of this species.")],
|
||||
[_INTL("BattlerPlayerX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerPlayerY"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerEnemyX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerEnemyY"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerAltitude"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerShadowX"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerShadowSize"),ReadOnlyProperty,_INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("Evolutions"),EvolutionsProperty.new,_INTL("Evolution paths of this species.")],
|
||||
[_INTL("Incense"),ItemProperty,_INTL("Item needed to be held by a parent to produce an egg of this species.")],
|
||||
_INTL("The habitat of this species.")],
|
||||
[_INTL("RegionalNumbers"), ReadOnlyProperty, _INTL("Regional Dex numbers for the Pokémon. These are edited elsewhere.")],
|
||||
[_INTL("Kind"), StringProperty, _INTL("Kind of Pokémon species.")],
|
||||
[_INTL("Pokédex"), StringProperty, _INTL("Description of the Pokémon as displayed in the Pokédex.")],
|
||||
[_INTL("FormName"), StringProperty, _INTL("Name of this form of the Pokémon.")],
|
||||
[_INTL("WildItemCommon"), ItemProperty, _INTL("Item commonly held by wild Pokémon of this species.")],
|
||||
[_INTL("WildItemUncommon"), ItemProperty, _INTL("Item uncommonly held by wild Pokémon of this species.")],
|
||||
[_INTL("WildItemRare"), ItemProperty, _INTL("Item rarely held by wild Pokémon of this species.")],
|
||||
[_INTL("BattlerPlayerX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerPlayerY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerEnemyX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerEnemyY"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerAltitude"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerShadowX"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("BattlerShadowSize"), ReadOnlyProperty, _INTL("Affects positioning of the Pokémon in battle. This is edited elsewhere.")],
|
||||
[_INTL("Evolutions"), EvolutionsProperty.new, _INTL("Evolution paths of this species.")],
|
||||
[_INTL("Incense"), ItemProperty, _INTL("Item needed to be held by a parent to produce an egg of this species.")],
|
||||
]
|
||||
pbListScreenBlock(_INTL("Pokémon species"),SpeciesLister.new(selection,false)) { |button,index|
|
||||
if index
|
||||
@@ -838,11 +829,11 @@ def pbPokemonEditor
|
||||
formname = messages.get(MessageTypes::FormNames,selection)
|
||||
abilities = speciesData[SpeciesData::ABILITIES]
|
||||
if abilities.is_a?(Array)
|
||||
ability1 = (abilities[0]) ? PokemonData::Ability.get(abilities[0]).id_number : 0
|
||||
ability2 = (abilities[1]) ? PokemonData::Ability.get(abilities[1]).id_number : 0
|
||||
ability1 = abilities[0]
|
||||
ability2 = abilities[1]
|
||||
else
|
||||
ability1 = (abilities) ? PokemonData::Ability.get(abilities).id_number : 0
|
||||
ability2 = 0
|
||||
ability1 = abilities
|
||||
ability2 = nil
|
||||
end
|
||||
color = speciesData[SpeciesData::COLOR]
|
||||
habitat = speciesData[SpeciesData::HABITAT]
|
||||
@@ -870,15 +861,15 @@ def pbPokemonEditor
|
||||
baseexp = speciesData[SpeciesData::BASE_EXP]
|
||||
hiddenAbils = speciesData[SpeciesData::HIDDEN_ABILITY]
|
||||
if hiddenAbils.is_a?(Array)
|
||||
hiddenability1 = (hiddenAbils[0]) ? PokemonData::Ability.get(hiddenAbils[0]).id_number : 0
|
||||
hiddenability2 = (hiddenAbils[1]) ? PokemonData::Ability.get(hiddenAbils[1]).id_number : 0
|
||||
hiddenability3 = (hiddenAbils[2]) ? PokemonData::Ability.get(hiddenAbils[2]).id_number : 0
|
||||
hiddenability4 = (hiddenAbils[3]) ? PokemonData::Ability.get(hiddenAbils[3]).id_number : 0
|
||||
hiddenability1 = hiddenAbils[0]
|
||||
hiddenability2 = hiddenAbils[1]
|
||||
hiddenability3 = hiddenAbils[2]
|
||||
hiddenability4 = hiddenAbils[3]
|
||||
else
|
||||
hiddenability1 = (hiddenAbils) ? PokemonData::Ability.get(hiddenAbils).id_number : 0
|
||||
hiddenability2 = 0
|
||||
hiddenability3 = 0
|
||||
hiddenability4 = 0
|
||||
hiddenability1 = hiddenAbils
|
||||
hiddenability2 = nil
|
||||
hiddenability3 = nil
|
||||
hiddenability4 = nil
|
||||
end
|
||||
item1 = speciesData[SpeciesData::WILD_ITEM_COMMON]
|
||||
item2 = speciesData[SpeciesData::WILD_ITEM_UNCOMMON]
|
||||
@@ -953,18 +944,13 @@ def pbPokemonEditor
|
||||
data[20] = data[19] if !data[20] || data[20]==0
|
||||
compats = (data[20] && data[20]>0) ? [data[19],data[20]] : data[19]
|
||||
# Make sure both Abilities are recorded correctly
|
||||
data[11] = data[12] if !data[11] || data[11]==0
|
||||
data[11] = 0 if !data[11]
|
||||
data[12] = 0 if data[11]==data[12]
|
||||
abils = (data[12] && data[12]>0) ? [data[11],data[12]] : data[11]
|
||||
data[11] = data[12] if !data[11]
|
||||
data[12] = nil if data[11] == data[12]
|
||||
abils = (data[12]) ? [data[11], data[12]] : data[11]
|
||||
# Make sure all Hidden Abilities are recorded correctly
|
||||
hiddenAbils = []; shouldArray = false
|
||||
for i in 13..17
|
||||
data[i] = nil if data[i] && data[i]==0
|
||||
hiddenAbils.push(data[i])
|
||||
shouldArray = true if i>13 && data[i]
|
||||
end
|
||||
hiddenAbils = hiddenAbils[0] if !shouldArray
|
||||
hiddenAbils = [data[13], data[14], data[15], data[16]]
|
||||
hiddenAbils.compact!
|
||||
hiddenAbils = hiddenAbils[0] if hiddenAbils.length <= 1
|
||||
# Save data
|
||||
speciesData[SpeciesData::ABILITIES] = abils
|
||||
speciesData[SpeciesData::COLOR] = data[24]
|
||||
@@ -1057,8 +1043,11 @@ def pbPokemonEditor
|
||||
save_data(evos,"Data/species_evolutions.dat")
|
||||
# Don't need to save metrics or regional numbers
|
||||
# because they can't be edited here
|
||||
# TODO: Only need to reload whichever sets of Pokémon data were
|
||||
# edited here (species, movesets, egg moves, evolutions).
|
||||
# These are likely to be merged into a single data file.
|
||||
pbClearData
|
||||
pbSavePokemonData
|
||||
pbSavePokemonData # Rewrite PBS files pokemon.txt and pokemonforms.txt
|
||||
pbMessage(_INTL("Data saved."))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,12 +55,12 @@ def pbSaveAbilities
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
PokemonData::Ability.each do |a|
|
||||
GameData::Ability.each do |a|
|
||||
f.write(sprintf("%d,%s,%s,%s\r\n",
|
||||
a.id_number,
|
||||
csvQuote(a.id.to_s),
|
||||
csvQuote(a.name),
|
||||
csvQuoteAlways(a.description)
|
||||
csvQuote(a.real_name),
|
||||
csvQuoteAlways(a.real_description)
|
||||
))
|
||||
end
|
||||
}
|
||||
@@ -228,41 +228,35 @@ end
|
||||
# Save item data to PBS file
|
||||
#===============================================================================
|
||||
def pbSaveItems
|
||||
itemData = pbLoadItemsData rescue nil
|
||||
return if !itemData || itemData.length==0
|
||||
File.open("PBS/items.txt","wb") { |f|
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
curpocket = 0
|
||||
for i in 0...itemData.length
|
||||
next if !itemData[i]
|
||||
data = itemData[i]
|
||||
cname = getConstantName(PBItems,i) rescue sprintf("ITEM%03d",i)
|
||||
next if !cname || cname=="" || data[0]==0
|
||||
if curpocket!=data[ItemData::POCKET]
|
||||
curpocket = data[ItemData::POCKET]
|
||||
current_pocket = 0
|
||||
GameData::Item.each do |i|
|
||||
if current_pocket != i.pocket
|
||||
current_pocket = i.pocket
|
||||
f.write("\#-------------------------------\r\n")
|
||||
end
|
||||
machine = ""
|
||||
if data[ItemData::MOVE]>0
|
||||
machine = getConstantName(PBMoves,data[ItemData::MOVE]) rescue pbGetMoveConst(data[ItemData::MOVE]) rescue ""
|
||||
move_name = ""
|
||||
if i.move
|
||||
move_name = getConstantName(PBMoves, i.move) rescue pbGetMoveConst(i.move) rescue ""
|
||||
end
|
||||
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s",
|
||||
data[ItemData::ID],
|
||||
csvQuote(cname),
|
||||
csvQuote(data[ItemData::NAME]),
|
||||
csvQuote(data[ItemData::NAME_PLURAL]),
|
||||
data[ItemData::POCKET],
|
||||
data[ItemData::PRICE],
|
||||
csvQuoteAlways(data[ItemData::DESCRIPTION]),
|
||||
data[ItemData::FIELD_USE],
|
||||
data[ItemData::BATTLE_USE],
|
||||
data[ItemData::TYPE],
|
||||
csvQuote(machine)))
|
||||
f.write("\r\n")
|
||||
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
|
||||
i.id_number,
|
||||
csvQuote(i.id.to_s),
|
||||
csvQuote(i.real_name),
|
||||
csvQuote(i.real_name_plural),
|
||||
i.pocket,
|
||||
i.price,
|
||||
csvQuoteAlways(i.real_description),
|
||||
i.field_use,
|
||||
i.battle_use,
|
||||
i.type,
|
||||
csvQuote(move_name)
|
||||
))
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -282,13 +276,12 @@ def pbSaveBerryPlants
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 0...berryPlantData.length
|
||||
next if !berryPlantData[i]
|
||||
data = berryPlantData[i]
|
||||
cname = getConstantName(PBItems,i) rescue sprintf("ITEM%03d",i)
|
||||
next if !cname || cname=="" || i==0
|
||||
keys = berryPlantData.keys.sort
|
||||
keys.each do |key|
|
||||
data = berryPlantData[key]
|
||||
next if !data || !GameData::Item.exists?(key)
|
||||
f.write(sprintf("%s = %d,%d,%d,%d",
|
||||
csvQuote(cname),data[0],data[1],data[2],data[3]))
|
||||
csvQuote(GameData::Item.get(key).id.to_s), data[0], data[1], data[2], data[3]))
|
||||
f.write("\r\n")
|
||||
end
|
||||
}
|
||||
@@ -368,7 +361,7 @@ def pbSaveEncounterData
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
sortedkeys = encdata.keys.sort { |a,b| a<=>b }
|
||||
sortedkeys = encdata.keys.sort
|
||||
for i in sortedkeys
|
||||
next if !encdata[i]
|
||||
e = encdata[i]
|
||||
@@ -461,10 +454,8 @@ def pbSaveTrainerBattles
|
||||
if trainer[2] && trainer[2].length>0
|
||||
itemstring = ""
|
||||
for i in 0...trainer[2].length
|
||||
itemname = getConstantName(PBItems,trainer[2][i]) rescue pbGetItemConst(trainer[2][i]) rescue nil
|
||||
next if !itemname
|
||||
itemstring.concat(",") if i>0
|
||||
itemstring.concat(itemname)
|
||||
itemstring.concat(",") if i > 0
|
||||
itemstring.concat(trainer[2][i].to_s)
|
||||
end
|
||||
f.write(sprintf("Items = %s\r\n",itemstring)) if itemstring!=""
|
||||
end
|
||||
@@ -502,11 +493,10 @@ def pbSaveTrainerBattles
|
||||
f.write(sprintf(" Moves = %s\r\n",movestring)) if movestring!=""
|
||||
end
|
||||
if poke[TrainerData::ABILITY]
|
||||
f.write(sprintf(" Ability = %d\r\n",poke[TrainerData::ABILITY]))
|
||||
f.write(sprintf(" Ability = %s\r\n",poke[TrainerData::ABILITY].to_s))
|
||||
end
|
||||
if poke[TrainerData::ITEM] && poke[TrainerData::ITEM]>0
|
||||
item = getConstantName(PBItems,poke[TrainerData::ITEM]) rescue pbGetItemConst(poke[TrainerData::ITEM]) rescue nil
|
||||
f.write(sprintf(" Item = %s\r\n",item)) if item
|
||||
if poke[TrainerData::ITEM]
|
||||
f.write(sprintf(" Item = %s\r\n",poke[TrainerData::ITEM].to_s))
|
||||
end
|
||||
if poke[TrainerData::NATURE]
|
||||
nature = getConstantName(PBNatures,poke[TrainerData::NATURE]) rescue nil
|
||||
@@ -688,10 +678,10 @@ def pbSavePokemonData
|
||||
hiddenability3 = nil
|
||||
hiddenability4 = nil
|
||||
end
|
||||
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
|
||||
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
|
||||
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0
|
||||
incense = speciesData[i][SpeciesData::INCENSE] || 0
|
||||
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
|
||||
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
|
||||
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
|
||||
incense = speciesData[i][SpeciesData::INCENSE]
|
||||
pokedata.write("\#-------------------------------\r\n")
|
||||
pokedata.write("[#{i}]\r\nName = #{speciesname}\r\n")
|
||||
pokedata.write("InternalName = #{cname}\r\n")
|
||||
@@ -711,12 +701,12 @@ def pbSavePokemonData
|
||||
pokedata.write("Happiness = #{happiness}\r\n")
|
||||
pokedata.write("Abilities = ")
|
||||
if ability1
|
||||
cability1 = PokemonData::Ability.get(ability1).name
|
||||
cability1 = GameData::Ability.get(ability1).id.to_s
|
||||
pokedata.write("#{cability1}")
|
||||
pokedata.write(",") if ability2
|
||||
end
|
||||
if ability2
|
||||
cability2 = PokemonData::Ability.get(ability2).name
|
||||
cability2 = GameData::Ability.get(ability2).id.to_s
|
||||
pokedata.write("#{cability2}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
@@ -724,22 +714,22 @@ def pbSavePokemonData
|
||||
pokedata.write("HiddenAbility = ")
|
||||
needcomma = false
|
||||
if hiddenability1
|
||||
cabilityh = PokemonData::Ability.get(hiddenability1).name
|
||||
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability2
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability2).name
|
||||
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability3
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability3).name
|
||||
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability4
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability4).name
|
||||
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
|
||||
pokedata.write("#{cabilityh}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
@@ -812,16 +802,16 @@ def pbSavePokemonData
|
||||
if formname && formname!=""
|
||||
pokedata.write("FormName = #{formname}\r\n")
|
||||
end
|
||||
if item1>0
|
||||
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1)
|
||||
if item1
|
||||
citem1 = GameData::Item.get(item1).id.to_s
|
||||
pokedata.write("WildItemCommon = #{citem1}\r\n")
|
||||
end
|
||||
if item2>0
|
||||
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2)
|
||||
if item2
|
||||
citem2 = GameData::Item.get(item2).id.to_s
|
||||
pokedata.write("WildItemUncommon = #{citem2}\r\n")
|
||||
end
|
||||
if item3>0
|
||||
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3)
|
||||
if item3
|
||||
citem3 = GameData::Item.get(item3).id.to_s
|
||||
pokedata.write("WildItemRare = #{citem3}\r\n")
|
||||
end
|
||||
if metrics && metrics.length>0
|
||||
@@ -849,8 +839,12 @@ def pbSavePokemonData
|
||||
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
|
||||
if has_param
|
||||
if param_type
|
||||
cparameter = (getConstantName(param_type, parameter) rescue parameter)
|
||||
pokedata.write("#{cparameter}")
|
||||
if [:Ability, :Item].include?(param_type)
|
||||
pokedata.write("#{parameter.to_s}")
|
||||
else
|
||||
cparameter = (getConstantName(param_type, parameter) rescue parameter)
|
||||
pokedata.write("#{cparameter}")
|
||||
end
|
||||
else
|
||||
pokedata.write("#{parameter}")
|
||||
end
|
||||
@@ -858,8 +852,8 @@ def pbSavePokemonData
|
||||
count += 1
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
if incense>0
|
||||
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense)
|
||||
if incense
|
||||
initem = GameData::Item.get(incense).id.to_s
|
||||
pokedata.write("Incense = #{initem}\r\n")
|
||||
end
|
||||
if i%20==0
|
||||
@@ -954,10 +948,10 @@ def pbSavePokemonFormsData
|
||||
origdata["hiddenability3"] = nil
|
||||
origdata["hiddenability4"] = nil
|
||||
end
|
||||
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0
|
||||
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0
|
||||
origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE] || 0
|
||||
origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0
|
||||
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON]
|
||||
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON]
|
||||
origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE]
|
||||
origdata["incense"] = speciesData[species][SpeciesData::INCENSE]
|
||||
abilities = speciesData[i][SpeciesData::ABILITIES]
|
||||
if abilities.is_a?(Array)
|
||||
ability1 = abilities[0]
|
||||
@@ -1047,16 +1041,16 @@ def pbSavePokemonFormsData
|
||||
hiddenability4==origdata["hiddenability4"]
|
||||
hiddenability1 = hiddenability2 = hiddenability3 = hiddenability4 = nil
|
||||
end
|
||||
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
|
||||
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
|
||||
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0
|
||||
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
|
||||
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
|
||||
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
|
||||
if item1==origdata["item1"] && item2==origdata["item2"] && item3==origdata["item3"]
|
||||
item1 = item2 = item3 = nil
|
||||
end
|
||||
incense = speciesData[i][SpeciesData::INCENSE] || 0
|
||||
incense = speciesData[i][SpeciesData::INCENSE]
|
||||
incense = nil if incense==origdata["incense"]
|
||||
pokedexform = speciesData[i][SpeciesData::POKEDEX_FORM] || 0 # No nil check
|
||||
megastone = speciesData[i][SpeciesData::MEGA_STONE] || 0 # No nil check
|
||||
megastone = speciesData[i][SpeciesData::MEGA_STONE] # No nil check
|
||||
megamove = speciesData[i][SpeciesData::MEGA_MOVE] || 0 # No nil check
|
||||
unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check
|
||||
megamessage = speciesData[i][SpeciesData::MEGA_MESSAGE] || 0 # No nil check
|
||||
@@ -1064,8 +1058,8 @@ def pbSavePokemonFormsData
|
||||
pokedata.write("[#{cname},#{form}]\r\n")
|
||||
pokedata.write("FormName = #{formname}\r\n") if formname && formname!=""
|
||||
pokedata.write("PokedexForm = #{pokedexform}\r\n") if pokedexform>0
|
||||
if megastone>0
|
||||
citem = getConstantName(PBItems,megastone) rescue pbGetItemConst(megastone)
|
||||
if megastone
|
||||
citem = GameData::Item.get(megastone).id.to_s
|
||||
pokedata.write("MegaStone = #{citem}\r\n")
|
||||
end
|
||||
if megamove>0
|
||||
@@ -1107,12 +1101,12 @@ def pbSavePokemonFormsData
|
||||
if ability1 || ability2
|
||||
pokedata.write("Abilities = ")
|
||||
if ability1
|
||||
cability1 = PokemonData::Ability.get(ability1).name
|
||||
cability1 = GameData::Ability.get(ability1).id.to_s
|
||||
pokedata.write("#{cability1}")
|
||||
pokedata.write(",") if ability2
|
||||
end
|
||||
if ability2
|
||||
cability2 = PokemonData::Ability.get(ability2).name
|
||||
cability2 = GameData::Ability.get(ability2).id.to_s
|
||||
pokedata.write("#{cability2}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
@@ -1122,22 +1116,22 @@ def pbSavePokemonFormsData
|
||||
pokedata.write("HiddenAbility = ")
|
||||
needcomma = false
|
||||
if hiddenability1
|
||||
cabilityh = PokemonData::Ability.get(hiddenability1).name
|
||||
cabilityh = GameData::Ability.get(hiddenability1).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability2
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability2).name
|
||||
cabilityh = GameData::Ability.get(hiddenability2).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability3
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability3).name
|
||||
cabilityh = GameData::Ability.get(hiddenability3).id.to_s
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability4
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = PokemonData::Ability.get(hiddenability4).name
|
||||
cabilityh = GameData::Ability.get(hiddenability4).id.to_s
|
||||
pokedata.write("#{cabilityh}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
@@ -1238,19 +1232,17 @@ def pbSavePokemonFormsData
|
||||
if entry!=nil
|
||||
pokedata.write("Pokedex = #{entry}\r\n")
|
||||
end
|
||||
if item1!=nil && item2!=nil && item3!=nil
|
||||
if item1>0
|
||||
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1)
|
||||
pokedata.write("WildItemCommon = #{citem1}\r\n")
|
||||
end
|
||||
if item2>0
|
||||
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2)
|
||||
pokedata.write("WildItemUncommon = #{citem2}\r\n")
|
||||
end
|
||||
if item3>0
|
||||
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3)
|
||||
pokedata.write("WildItemRare = #{citem3}\r\n")
|
||||
end
|
||||
if item1
|
||||
citem1 = GameData::Item.get(item1).id.to_s
|
||||
pokedata.write("WildItemCommon = #{citem1}\r\n")
|
||||
end
|
||||
if item2
|
||||
citem1 = GameData::Item.get(item2).id.to_s
|
||||
pokedata.write("WildItemUncommon = #{citem2}\r\n")
|
||||
end
|
||||
if item3
|
||||
citem1 = GameData::Item.get(item3).id.to_s
|
||||
pokedata.write("WildItemRare = #{citem3}\r\n")
|
||||
end
|
||||
if metrics && metrics.length>0
|
||||
for j in 0...6
|
||||
@@ -1322,11 +1314,9 @@ def pbSavePokemonFormsData
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
end
|
||||
if incense!=nil
|
||||
if incense>0
|
||||
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense)
|
||||
pokedata.write("Incense = #{initem}\r\n")
|
||||
end
|
||||
if incense
|
||||
initem = GameData::Item.get(incense).id.to_s
|
||||
pokedata.write("Incense = #{initem}\r\n")
|
||||
end
|
||||
if i%20==0
|
||||
Graphics.update
|
||||
@@ -1439,8 +1429,7 @@ end
|
||||
def pbFastInspect(pkmn,moves,species,items,natures)
|
||||
c1 = (species[pkmn.species]) ? species[pkmn.species] :
|
||||
(species[pkmn.species] = (getConstantName(PBSpecies,pkmn.species) rescue pbGetSpeciesConst(pkmn.species)))
|
||||
c2 = (items[pkmn.item]) ? items[pkmn.item] :
|
||||
(items[pkmn.item] = (getConstantName(PBItems,pkmn.item) rescue pbGetItemConst(pkmn.item)))
|
||||
c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s)
|
||||
c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] :
|
||||
(natures[pkmn.nature] = getConstantName(PBNatures,pkmn.nature))
|
||||
evlist = ""
|
||||
|
||||
@@ -352,9 +352,9 @@ end
|
||||
|
||||
|
||||
module ItemProperty
|
||||
def self.set(_settingname,oldsetting)
|
||||
ret = pbChooseItemList((oldsetting) ? oldsetting : 1)
|
||||
return (ret>0) ? ret : (oldsetting) ? oldsetting : nil
|
||||
def self.set(_settingname, oldsetting)
|
||||
ret = pbChooseItemList((oldsetting) ? oldsetting : nil)
|
||||
return ret || oldsetting
|
||||
end
|
||||
|
||||
def self.defaultValue
|
||||
@@ -362,7 +362,7 @@ module ItemProperty
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return (value) ? PBItems.getName(value) : "-"
|
||||
return (value && GameData::Item.exists?(value)) ? GameData::Item.get(value).real_name : "-"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -522,8 +522,7 @@ class BallProperty
|
||||
end
|
||||
|
||||
def format(value)
|
||||
return "-" if !value
|
||||
return PBItems.getName(pbBallTypeToItem(value))
|
||||
return (value) ? pbBallTypeToItem(value).name : "-"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -817,17 +816,17 @@ end
|
||||
|
||||
|
||||
module AbilityProperty
|
||||
def self.set(_settingname,oldsetting)
|
||||
ret = pbChooseAbilityList((oldsetting) ? oldsetting : 1)
|
||||
return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret
|
||||
def self.set(_settingname, oldsetting)
|
||||
ret = pbChooseAbilityList((oldsetting) ? oldsetting : nil)
|
||||
return ret || oldsetting
|
||||
end
|
||||
|
||||
def self.defaultValue
|
||||
return 0
|
||||
return nil
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return (value && PokemonData::Ability.exists?(value)) ? PokemonData::Ability.get(value).name : "-"
|
||||
return (value && GameData::Ability.exists?(value)) ? GameData::Ability.get(value).real_name : "-"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1253,7 +1252,7 @@ class EvolutionsProperty
|
||||
if has_param
|
||||
allow_zero = false
|
||||
case param_type
|
||||
when :PBItems
|
||||
when :Item
|
||||
newparam = pbChooseItemList
|
||||
when :PBMoves
|
||||
newparam = pbChooseMoveList
|
||||
@@ -1272,7 +1271,8 @@ class EvolutionsProperty
|
||||
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
|
||||
end
|
||||
end
|
||||
if !has_param || newparam > 0 || (allow_zero && newparam == 0)
|
||||
if !has_param || newparam.is_a?(Symbol) ||
|
||||
(newparam.is_a?(Integer) && (newparam > 0 || (allow_zero && newparam == 0)))
|
||||
havemove = -1
|
||||
for i in 0...realcmds.length
|
||||
havemove = realcmds[i][3] if realcmds[i][0]==newmethod &&
|
||||
@@ -1341,7 +1341,7 @@ class EvolutionsProperty
|
||||
if has_param
|
||||
allow_zero = false
|
||||
case param_type
|
||||
when :PBItems
|
||||
when :Item
|
||||
newparam = pbChooseItemList(entry[1])
|
||||
when :PBMoves
|
||||
newparam = pbChooseMoveList(entry[1])
|
||||
@@ -1360,7 +1360,8 @@ class EvolutionsProperty
|
||||
params.setCancelValue(-1)
|
||||
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
|
||||
end
|
||||
if newparam>0 || (allow_zero && newparam == 0)
|
||||
if newparam.is_a?(Symbol) ||
|
||||
(newparam.is_a?(Integer) && (newparam > 0 || (allow_zero && newparam == 0)))
|
||||
havemove = -1
|
||||
for i in 0...realcmds.length
|
||||
havemove = realcmds[i][3] if realcmds[i][0]==entry[0] &&
|
||||
|
||||
@@ -376,9 +376,9 @@ end
|
||||
|
||||
|
||||
class ItemLister
|
||||
def initialize(selection,includeNew=false)
|
||||
def initialize(selection=0,includeNew=false)
|
||||
@sprite = IconSprite.new(0,0)
|
||||
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,-1)
|
||||
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,nil)
|
||||
@sprite.z = 2
|
||||
@selection = selection
|
||||
@commands = []
|
||||
@@ -404,23 +404,18 @@ class ItemLister
|
||||
def commands # Sorted alphabetically
|
||||
@commands.clear
|
||||
@ids.clear
|
||||
@itemdata = pbLoadItemsData
|
||||
cmds = []
|
||||
for i in 1..PBItems.maxValue
|
||||
next if !@itemdata[i]
|
||||
name = @itemdata[i][ItemData::NAME]
|
||||
if name && name!="" && @itemdata[i][ItemData::POCKET]!=0
|
||||
cmds.push([i,name])
|
||||
end
|
||||
GameData::Item.each do |item|
|
||||
cmds.push([item.id_number, item.id, item.real_name])
|
||||
end
|
||||
cmds.sort! { |a,b| a[1]<=>b[1] }
|
||||
cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
|
||||
if @includeNew
|
||||
@commands.push(_INTL("[NEW ITEM]"))
|
||||
@ids.push(-1)
|
||||
@ids.push(true)
|
||||
end
|
||||
for i in cmds
|
||||
@commands.push(sprintf("%03d: %s",i[0],i[1]))
|
||||
@ids.push(i[0])
|
||||
@commands.push(sprintf("%03d: %s", i[0], i[2]))
|
||||
@ids.push(i[1])
|
||||
end
|
||||
@index = @selection
|
||||
@index = @commands.length-1 if @index>=@commands.length
|
||||
@@ -434,7 +429,7 @@ class ItemLister
|
||||
end
|
||||
|
||||
def refresh(index)
|
||||
@sprite.item = @ids[index]
|
||||
@sprite.item = (@ids[index].is_a?(Symbol)) ? @ids[index] : nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,16 +14,11 @@ def pbGetLegalMoves(species)
|
||||
return moves if !species || species<=0
|
||||
moveset = pbGetSpeciesMoveset(species)
|
||||
moveset.each { |m| moves.push(m[1]) }
|
||||
itemData = pbLoadItemsData
|
||||
tmdat = pbLoadSpeciesTMData
|
||||
for i in 0...itemData.length
|
||||
next if !itemData[i]
|
||||
atk = itemData[i][8]
|
||||
next if !atk || atk==0
|
||||
next if !tmdat[atk]
|
||||
if tmdat[atk].any? { |item| item==species }
|
||||
moves.push(atk)
|
||||
end
|
||||
GameData::Item.each do |i|
|
||||
next if !i.move
|
||||
atk = getConst(PBMoves, i.move)
|
||||
moves.push(atk) if tmdat[atk] && tmdat[atk].include?(species)
|
||||
end
|
||||
babyspecies = pbGetBabySpecies(species)
|
||||
eggMoves = pbGetSpeciesEggMoves(babyspecies)
|
||||
@@ -252,9 +247,10 @@ def pbGetMoveConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
|
||||
end
|
||||
|
||||
def pbGetItemConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
|
||||
end
|
||||
# Unused
|
||||
#def pbGetItemConst(i)
|
||||
# return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
|
||||
#end
|
||||
|
||||
def pbGetSpeciesConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Species,i,PBSpecies)
|
||||
@@ -346,48 +342,43 @@ end
|
||||
# if the selection was canceled). "default", if specified, is the ID of the item
|
||||
# to initially select. Pressing Input::A will toggle the list sorting between
|
||||
# numerical and alphabetical.
|
||||
def pbChooseItemList(default=0)
|
||||
def pbChooseItemList(default = nil)
|
||||
commands = []
|
||||
for i in 1..PBItems.maxValue
|
||||
cname = getConstantName(PBItems,i) rescue nil
|
||||
commands.push([i,PBItems.getName(i)]) if cname
|
||||
end
|
||||
return pbChooseList(commands,default,0,-1)
|
||||
GameData::Item.each { |i| commands.push([i.id_number, i.name, i.id]) }
|
||||
return pbChooseList(commands, default, nil, -1)
|
||||
end
|
||||
|
||||
# Displays a list of all abilities, and returns the ID of the ability selected
|
||||
# (or -1 if the selection was canceled). "default", if specified, is the ID of
|
||||
# the ability to initially select. Pressing Input::A will toggle the list
|
||||
# sorting between numerical and alphabetical.
|
||||
def pbChooseAbilityList(default=0)
|
||||
def pbChooseAbilityList(default = 0)
|
||||
commands = []
|
||||
PokemonData::Ability.each do |a|
|
||||
commands.push([a.id_number, a.name])
|
||||
end
|
||||
return pbChooseList(commands,default,0,-1)
|
||||
GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) }
|
||||
return pbChooseList(commands, default, nil, -1)
|
||||
end
|
||||
|
||||
def pbChooseBallList(defaultMoveID=-1)
|
||||
cmdwin = pbListWindow([],200)
|
||||
def pbChooseBallList(defaultMoveID = -1)
|
||||
cmdwin = pbListWindow([], 200)
|
||||
commands = []
|
||||
moveDefault = 0
|
||||
for key in $BallTypes.keys
|
||||
item = getID(PBItems,$BallTypes[key])
|
||||
commands.push([key,item,PBItems.getName(item)]) if item && item>0
|
||||
item = GameData::Item.try_get($BallTypes[key])
|
||||
balls.push([key.to_i, item.name]) if item
|
||||
end
|
||||
commands.sort! { |a,b| a[2]<=>b[2] }
|
||||
if defaultMoveID>=0
|
||||
commands.sort! { |a, b| a[1] <=> b[1] }
|
||||
if defaultMoveID >= 0
|
||||
for i in 0...commands.length
|
||||
moveDefault = i if defaultMoveID==commands[i][0]
|
||||
moveDefault = i if commands[i][0] == defaultMoveID
|
||||
end
|
||||
end
|
||||
realcommands = []
|
||||
for i in commands
|
||||
realcommands.push(i[2])
|
||||
realcommands.push(i[1])
|
||||
end
|
||||
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
|
||||
ret = pbCommands2(cmdwin, realcommands, -1, moveDefault, true)
|
||||
cmdwin.dispose
|
||||
return (ret>=0) ? commands[ret][0] : defaultMoveID
|
||||
return (ret >= 0) ? commands[ret][0] : defaultMoveID
|
||||
end
|
||||
|
||||
|
||||
@@ -486,39 +477,41 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseList(commands,default=0,cancelValue=-1,sortType=1)
|
||||
def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
|
||||
cmdwin = pbListWindow([])
|
||||
itemID = default
|
||||
itemIndex = 0
|
||||
sortMode = (sortType>=0) ? sortType : 0 # 0=ID, 1=alphabetical
|
||||
sortMode = (sortType >= 0) ? sortType : 0 # 0=ID, 1=alphabetical
|
||||
sorting = true
|
||||
loop do
|
||||
if sorting
|
||||
if sortMode==0
|
||||
commands.sort! { |a,b| a[0]<=>b[0] }
|
||||
elsif sortMode==1
|
||||
commands.sort! { |a,b| a[1]<=>b[1] }
|
||||
if sortMode == 0
|
||||
commands.sort! { |a, b| a[0] <=> b[0] }
|
||||
elsif sortMode == 1
|
||||
commands.sort! { |a, b| a[1] <=> b[1] }
|
||||
end
|
||||
if itemID>0
|
||||
commands.each_with_index { |command,i| itemIndex = i if command[0]==itemID }
|
||||
if itemID.is_a?(Symbol)
|
||||
commands.each_with_index { |command, i| itemIndex = i if command[2] == itemID }
|
||||
elsif itemID && itemID > 0
|
||||
commands.each_with_index { |command, i| itemIndex = i if command[0] == itemID }
|
||||
end
|
||||
realcommands = []
|
||||
for command in commands
|
||||
if sortType<=0
|
||||
realcommands.push(sprintf("%03d: %s",command[0],command[1]))
|
||||
if sortType <= 0
|
||||
realcommands.push(sprintf("%03d: %s", command[0], command[1]))
|
||||
else
|
||||
realcommands.push(command[1])
|
||||
end
|
||||
end
|
||||
sorting = false
|
||||
end
|
||||
cmd = pbCommandsSortable(cmdwin,realcommands,-1,itemIndex,(sortType<0))
|
||||
if cmd[0]==0 # Chose an option or cancelled
|
||||
itemID = (cmd[1]<0) ? cancelValue : commands[cmd[1]][0]
|
||||
cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0))
|
||||
if cmd[0] == 0 # Chose an option or cancelled
|
||||
itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0])
|
||||
break
|
||||
elsif cmd[0]==1 # Toggle sorting
|
||||
itemID = commands[cmd[1]][0]
|
||||
sortMode = (sortMode+1)%2
|
||||
elsif cmd[0] == 1 # Toggle sorting
|
||||
itemID = commands[cmd[1]][2] || commands[cmd[1]][0]
|
||||
sortMode = (sortMode + 1) % 2
|
||||
sorting = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -793,6 +793,7 @@ class MapScreenScene
|
||||
serializeConnectionData
|
||||
serializeMetadata
|
||||
save_data(@encdata,"Data/encounters.dat")
|
||||
# TODO: Only need to reload connections, metadata, encounter data.
|
||||
pbClearData
|
||||
pbSaveEncounterData
|
||||
end
|
||||
|
||||
@@ -311,8 +311,8 @@ module Compiler
|
||||
end
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if enumer == :Ability
|
||||
enumer = PokemonData.const_get(enumer.to_sym)
|
||||
if [:Ability, :Item].include?(enumer)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
begin
|
||||
if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport)
|
||||
@@ -353,8 +353,8 @@ module Compiler
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if enumer == :Ability
|
||||
enumer = PokemonData.const_get(enumer.to_sym)
|
||||
if [:Ability, :Item].include?(enumer)
|
||||
enumer = GameData.const_get(enumer.to_sym)
|
||||
return nil if ret == "" || !enumer.exists?(ret.to_sym)
|
||||
return ret.to_sym
|
||||
end
|
||||
@@ -566,7 +566,11 @@ module Compiler
|
||||
clonitem = item.upcase
|
||||
clonitem.sub!(/^\s*/,"")
|
||||
clonitem.sub!(/\s*$/,"")
|
||||
return pbGetConst(PBItems,clonitem,_INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers, and\r\nunderscores and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{1}",FileLineData.linereport))
|
||||
itm = GameData::Item.try_get(clonitem)
|
||||
if !itm
|
||||
raise _INTL("Undefined item constant name: %s\r\nName must consist only of letters, numbers and\r\nunderscores, and can't begin with a number.\r\nMake sure the item is defined in\r\nPBS/items.txt.\r\n{1}",FileLineData.linereport)
|
||||
end
|
||||
return itm.id.to_s
|
||||
end
|
||||
|
||||
def parseSpecies(item)
|
||||
@@ -623,17 +627,17 @@ module Compiler
|
||||
yield(_INTL("Compiling item data"))
|
||||
compile_items # Depends on PBMoves
|
||||
yield(_INTL("Compiling berry plant data"))
|
||||
compile_berry_plants # Depends on PBItems
|
||||
compile_berry_plants # Depends on Item
|
||||
yield(_INTL("Compiling Pokémon data"))
|
||||
compile_pokemon # Depends on PBMoves, PBItems, PBTypes, Ability
|
||||
compile_pokemon # Depends on PBMoves, Item, PBTypes, Ability
|
||||
yield(_INTL("Compiling Pokémon forms data"))
|
||||
compile_pokemon_forms # Depends on PBSpecies, PBMoves, PBItems, PBTypes, Ability
|
||||
compile_pokemon_forms # Depends on PBSpecies, PBMoves, Item, PBTypes, Ability
|
||||
yield(_INTL("Compiling machine data"))
|
||||
compile_move_compatibilities # Depends on PBSpecies, PBMoves
|
||||
yield(_INTL("Compiling Trainer type data"))
|
||||
compile_trainer_types # No dependencies
|
||||
yield(_INTL("Compiling Trainer data"))
|
||||
compile_trainers # Depends on PBSpecies, PBItems, PBMoves
|
||||
compile_trainers # Depends on PBSpecies, Item, PBMoves
|
||||
yield(_INTL("Compiling phone data"))
|
||||
compile_phone # Depends on PBTrainers
|
||||
yield(_INTL("Compiling metadata"))
|
||||
|
||||
@@ -140,7 +140,7 @@ module Compiler
|
||||
# Compile berry plants
|
||||
#=============================================================================
|
||||
def compile_berry_plants
|
||||
sections = []
|
||||
sections = {}
|
||||
if File.exists?("PBS/berryplants.txt")
|
||||
pbCompilerEachCommentedLine("PBS/berryplants.txt") { |line,_lineno|
|
||||
if line[ /^\s*(\w+)\s*=\s*(.*)$/ ]
|
||||
@@ -157,7 +157,7 @@ module Compiler
|
||||
end
|
||||
}
|
||||
end
|
||||
save_data(sections,"Data/berry_plants.dat")
|
||||
save_data(sections, "Data/berry_plants.dat")
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -326,15 +326,16 @@ module Compiler
|
||||
# Compile abilities
|
||||
#=============================================================================
|
||||
def compile_abilities
|
||||
GameData::Ability::DATA.clear
|
||||
ability_names = []
|
||||
ability_descriptions = []
|
||||
pbCompilerEachPreppedLine("PBS/abilities.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "vnss"])
|
||||
ability_number = line[0]
|
||||
ability_symbol = line[1].to_sym
|
||||
if PokemonData::Ability::DATA[ability_number]
|
||||
if GameData::Ability::DATA[ability_number]
|
||||
raise _INTL("Ability ID number '{1}' is used twice.\r\n{2}", ability_number, FileLineData.linereport)
|
||||
elsif PokemonData::Ability::DATA[ability_symbol]
|
||||
elsif GameData::Ability::DATA[ability_symbol]
|
||||
raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_symbol, FileLineData.linereport)
|
||||
end
|
||||
# Construct ability hash
|
||||
@@ -345,12 +346,12 @@ module Compiler
|
||||
:description => line[3]
|
||||
}
|
||||
# Add ability's data to records
|
||||
PokemonData::Ability::DATA[ability_number] = PokemonData::Ability::DATA[ability_symbol] = PokemonData::Ability.new(ability_hash)
|
||||
GameData::Ability::DATA[ability_number] = GameData::Ability::DATA[ability_symbol] = GameData::Ability.new(ability_hash)
|
||||
ability_names[ability_number] = ability_hash[:name]
|
||||
ability_descriptions[ability_number] = ability_hash[:description]
|
||||
}
|
||||
# Save all data
|
||||
PokemonData::Ability.save
|
||||
GameData::Ability.save
|
||||
MessageTypes.setMessages(MessageTypes::Abilities, ability_names)
|
||||
MessageTypes.setMessages(MessageTypes::AbilityDescs, ability_descriptions)
|
||||
Graphics.update
|
||||
@@ -408,58 +409,45 @@ module Compiler
|
||||
=end
|
||||
|
||||
def compile_items
|
||||
records = []
|
||||
constants = ""
|
||||
itemnames = []
|
||||
itempluralnames = []
|
||||
itemdescs = []
|
||||
maxValue = 0
|
||||
pbCompilerEachCommentedLine("PBS/items.txt") { |line,lineno|
|
||||
linerecord = pbGetCsvRecord(line,lineno,[0,"vnssuusuuUN"])
|
||||
id = linerecord[0]
|
||||
if records[id]
|
||||
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}",id,FileLineData.linereport)
|
||||
GameData::Item::DATA.clear
|
||||
item_names = []
|
||||
item_names_plural = []
|
||||
item_descriptions = []
|
||||
# Read each line of items.txt at a time and compile it into an item
|
||||
pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"])
|
||||
item_number = line[0]
|
||||
item_symbol = line[1].to_sym
|
||||
if GameData::Item::DATA[item_number]
|
||||
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}", item_number, FileLineData.linereport)
|
||||
elsif GameData::Item::DATA[item_symbol]
|
||||
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport)
|
||||
end
|
||||
record = []
|
||||
record[ItemData::ID] = id
|
||||
constant = linerecord[1]
|
||||
constants += "#{constant}=#{id}\r\n"
|
||||
record[ItemData::NAME] = linerecord[2]
|
||||
itemnames[id] = linerecord[2]
|
||||
record[ItemData::NAME_PLURAL] = linerecord[3]
|
||||
itempluralnames[id] = linerecord[3]
|
||||
record[ItemData::POCKET] = linerecord[4]
|
||||
record[ItemData::PRICE] = linerecord[5]
|
||||
record[ItemData::DESCRIPTION] = linerecord[6]
|
||||
itemdescs[id] = linerecord[6]
|
||||
record[ItemData::FIELD_USE] = linerecord[7]
|
||||
record[ItemData::BATTLE_USE] = linerecord[8]
|
||||
record[ItemData::TYPE] = linerecord[9]
|
||||
if record[ItemData::TYPE]!="" && linerecord[10]
|
||||
record[ItemData::MOVE] = parseMove(linerecord[10])
|
||||
else
|
||||
record[ItemData::MOVE] = 0
|
||||
end
|
||||
maxValue = [maxValue,id].max
|
||||
records[id] = record
|
||||
# Construct item hash
|
||||
item_hash = {
|
||||
:id_number => item_number,
|
||||
:id => item_symbol,
|
||||
:name => line[2],
|
||||
:name_plural => line[3],
|
||||
:pocket => line[4],
|
||||
:price => line[5],
|
||||
:description => line[6],
|
||||
:field_use => line[7],
|
||||
:battle_use => line[8],
|
||||
:type => line[9]
|
||||
}
|
||||
item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
|
||||
# Add item's data to records
|
||||
GameData::Item::DATA[item_number] = GameData::Item::DATA[item_symbol] = GameData::Item.new(item_hash)
|
||||
item_names[item_number] = item_hash[:name]
|
||||
item_names_plural[item_number] = item_hash[:name_plural]
|
||||
item_descriptions[item_number] = item_hash[:description]
|
||||
}
|
||||
MessageTypes.setMessages(MessageTypes::Items,itemnames)
|
||||
MessageTypes.setMessages(MessageTypes::ItemPlurals,itempluralnames)
|
||||
MessageTypes.setMessages(MessageTypes::ItemDescriptions,itemdescs)
|
||||
save_data(records,"Data/items.dat")
|
||||
code = "class PBItems\r\n"
|
||||
code += constants
|
||||
code += "def self.getName(id)\r\n"
|
||||
code += "id=getID(PBItems,id)\r\n"
|
||||
code += "return pbGetMessage(MessageTypes::Items,id); end\r\n"
|
||||
code += "def self.getNamePlural(id)\r\n"
|
||||
code += "id=getID(PBItems,id)\r\n"
|
||||
code += "return pbGetMessage(MessageTypes::ItemPlurals,id); end\r\n"
|
||||
code += "def self.getCount; return #{records.length}; end\r\n"
|
||||
code += "def self.maxValue; return #{maxValue}; end\r\n"
|
||||
code += "end\r\n"
|
||||
eval(code, TOPLEVEL_BINDING)
|
||||
pbAddScript(code,"PBItems")
|
||||
# Save all data
|
||||
GameData::Item.save
|
||||
MessageTypes.setMessages(MessageTypes::Items, item_names)
|
||||
MessageTypes.setMessages(MessageTypes::ItemPlurals, item_names_plural)
|
||||
MessageTypes.setMessages(MessageTypes::ItemDescriptions, item_descriptions)
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
@@ -1358,8 +1346,8 @@ module Compiler
|
||||
trainernames[trainerindex] = record[0]
|
||||
trainers[trainerindex][4] = record[1] if record[1]
|
||||
when 3 # Number of Pokémon, items
|
||||
record = pbGetCsvRecord(line,lineno,[0,"vEEEEEEEE",nil,PBItems,PBItems,
|
||||
PBItems,PBItems,PBItems,PBItems,PBItems,PBItems])
|
||||
record = pbGetCsvRecord(line,lineno,[0,"vEEEEEEEE",nil,
|
||||
Item,Item,Item,Item,Item,Item,Item,Item])
|
||||
record = [record] if record.is_a?(Integer)
|
||||
record.compact!
|
||||
oldcompilerlength += record[0]
|
||||
@@ -1369,7 +1357,7 @@ module Compiler
|
||||
pokemonindex += 1
|
||||
trainers[trainerindex][3][pokemonindex] = []
|
||||
record = pbGetCsvRecord(line,lineno,
|
||||
[0,"evEEEEEUEUBEUUSBU",PBSpecies,nil, PBItems,PBMoves,PBMoves,PBMoves,
|
||||
[0,"evEEEEEUEUBEUUSBU",PBSpecies,nil,Item,PBMoves,PBMoves,PBMoves,
|
||||
PBMoves,nil,{"M"=>0,"m"=>0,"Male"=>0,"male"=>0,
|
||||
"0"=>0,"F"=>1,"f"=>1,"Female"=>1,"female"=>1,
|
||||
"1"=>1},nil,nil,PBNatures,nil,nil,nil,nil,nil])
|
||||
|
||||
@@ -729,12 +729,12 @@ module Compiler
|
||||
hidden = false
|
||||
if name[/^HiddenItem\:\s*(\w+)\s*$/]
|
||||
itemName = $1
|
||||
return nil if !hasConst?(PBItems,itemName)
|
||||
return nil if !GameData::Item.exists?(itemName)
|
||||
ret.name = "HiddenItem"
|
||||
hidden = true
|
||||
elsif name[/^Item\:\s*(\w+)\s*$/]
|
||||
itemName = $1
|
||||
return nil if !hasConst?(PBItems,itemName)
|
||||
return nil if !GameData::Item.exists?(itemName)
|
||||
ret.name = "Item"
|
||||
else
|
||||
return nil
|
||||
@@ -953,7 +953,7 @@ module Compiler
|
||||
if params[0][/SellItem\s*\(\s*(\w+)\s*\,\s*(\d+)\s*\)/]
|
||||
itemname = $1
|
||||
cost = $2.to_i
|
||||
if hasConst?(PBItems,itemname)
|
||||
if GameData::Item.exists?(itemname)
|
||||
oldIndent = list[i].indent
|
||||
list.delete_at(i)
|
||||
newEvents = []
|
||||
|
||||
Reference in New Issue
Block a user