Implemented usage of GameData::Item

This commit is contained in:
Maruno17
2020-11-08 22:45:59 +00:00
parent ff70791104
commit 1955d3698e
82 changed files with 1986 additions and 2195 deletions
+4 -4
View File
@@ -14,17 +14,17 @@ def pbGetExceptionMessage(e,_script="")
end end
if emessage && !safeExists?("Game.rgssad") && !safeExists?("Game.rgss2a") if emessage && !safeExists?("Game.rgssad") && !safeExists?("Game.rgss2a")
emessage = emessage.gsub(/uninitialized constant PBItems\:\:(\S+)/) { 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/) { 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+)/) { emessage = emessage.gsub(/uninitialized constant PBTypes\:\:(\S+)/) {
"The type '#{$1}' is not valid. Please add the type\r\nto the PBS/types.txt file." } "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/) { 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." } "The type '#{$1}' is not valid. Please add the type\r\nto the PBS/types.txt file." }
emessage = emessage.gsub(/uninitialized constant PBTrainers\:\:(\S+)$/) { 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/) { 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+)$/) { 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." } "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/) { emessage = emessage.gsub(/undefined method `(\S+?)' for PBSpecies\:Module/) {
@@ -156,6 +156,7 @@ class HandlerHash2
end end
def [](sym) def [](sym)
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
return @hash[sym] if sym && @hash[sym] return @hash[sym] if sym && @hash[sym]
for add_if in @add_ifs for add_if in @add_ifs
return add_if[1] if add_if[0].call(sym) return add_if[1] if add_if[0].call(sym)
@@ -211,10 +212,7 @@ end
class ItemHandlerHash < HandlerHash class ItemHandlerHash < HandlerHash2
def initialize
super(:PBItems)
end
end end
+5 -5
View File
@@ -194,9 +194,9 @@ module SpeciesData
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability, "HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
:Ability, :Ability], :Ability, :Ability],
"Habitat" => [HABITAT, "e", :PBHabitats], "Habitat" => [HABITAT, "e", :PBHabitats],
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems], "WildItemCommon" => [WILD_ITEM_COMMON, "e", :Item],
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems], "WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :Item],
"WildItemRare" => [WILD_ITEM_RARE, "e", :PBItems], "WildItemRare" => [WILD_ITEM_RARE, "e", :Item],
"BattlerPlayerX" => [METRIC_PLAYER_X, "i"], "BattlerPlayerX" => [METRIC_PLAYER_X, "i"],
"BattlerPlayerY" => [METRIC_PLAYER_Y, "i"], "BattlerPlayerY" => [METRIC_PLAYER_Y, "i"],
"BattlerEnemyX" => [METRIC_ENEMY_X, "i"], "BattlerEnemyX" => [METRIC_ENEMY_X, "i"],
@@ -210,12 +210,12 @@ module SpeciesData
} }
if compilingForms if compilingForms
ret["PokedexForm"] = [POKEDEX_FORM, "u"] ret["PokedexForm"] = [POKEDEX_FORM, "u"]
ret["MegaStone"] = [MEGA_STONE, "e", :PBItems] ret["MegaStone"] = [MEGA_STONE, "e", :Item]
ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves] ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves]
ret["UnmegaForm"] = [UNMEGA_FORM, "u"] ret["UnmegaForm"] = [UNMEGA_FORM, "u"]
ret["MegaMessage"] = [MEGA_MESSAGE, "u"] ret["MegaMessage"] = [MEGA_MESSAGE, "u"]
else else
ret["Incense"] = [INCENSE, "e", :PBItems] ret["Incense"] = [INCENSE, "e", :Item]
ret["RegionalNumbers"] = [0, "*u"] ret["RegionalNumbers"] = [0, "*u"]
end end
return ret return ret
+7
View File
@@ -102,3 +102,10 @@ class PBMoveData
@flags = move_data[MoveData::FLAGS] @flags = move_data[MoveData::FLAGS]
end end
end end
def pbIsHiddenMove?(move)
GameData::Item.each do |i|
return true if i.is_HM? && move == i.move
end
return false
end
+18 -14
View File
@@ -1,22 +1,24 @@
module PokemonData module GameData
# A mixin module for data classes which provides common class methods (called # 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. # Assumes the data class's data is stored in a class constant hash called DATA.
module ClassMethods module ClassMethods
# @param other [Symbol, self, Integer] # @param other [Symbol, self, String, Integer]
# @return [Boolean] whether the given other is defined as a self # @return [Boolean] whether the given other is defined as a self
def exists?(other) def exists?(other)
return false if other.nil? return false if other.nil?
validate other => [Symbol, self.class, Integer] validate other => [Symbol, self, String, Integer]
other = other.id if other.is_a?(self.class) other = other.id if other.is_a?(self)
other = other.to_sym if other.is_a?(String)
return !self::DATA[other].nil? return !self::DATA[other].nil?
end end
# @param other [Symbol, self, Integer] # @param other [Symbol, self, String, Integer]
# @return [self] # @return [self]
def get(other) def get(other)
validate other => [Symbol, self.class, Integer] validate other => [Symbol, self, String, Integer]
return other if other.is_a?(self.class) return other if other.is_a?(self)
other = other.to_sym if other.is_a?(String)
# if other.is_a?(Integer) # if other.is_a?(Integer)
# p "Please switch to symbols, thanks." # p "Please switch to symbols, thanks."
# end # end
@@ -26,8 +28,9 @@ module PokemonData
def try_get(other) def try_get(other)
return nil if other.nil? return nil if other.nil?
validate other => [Symbol, self.class, Integer] validate other => [Symbol, self, String, Integer]
return other if other.is_a?(self.class) return other if other.is_a?(self)
other = other.to_sym if other.is_a?(String)
# if other.is_a?(Integer) # if other.is_a?(Integer)
# p "Please switch to symbols, thanks." # p "Please switch to symbols, thanks."
# end # end
@@ -35,8 +38,7 @@ module PokemonData
end end
def each def each
keys = self::DATA.keys keys = self::DATA.keys.sort { |a, b| self::DATA[a].id_number <=> self::DATA[b].id_number }
keys.sort! { |a, b| a.id_number <=> b.id_number }
keys.each do |key| keys.each do |key|
yield self::DATA[key] if key.is_a?(Symbol) yield self::DATA[key] if key.is_a?(Symbol)
end end
@@ -55,15 +57,17 @@ module PokemonData
# (called by thing.method) that analyse the data of a particular thing which # (called by thing.method) that analyse the data of a particular thing which
# the instance represents. # the instance represents.
module InstanceMethods 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 # @return [Boolean] whether other represents the same thing as this thing
def ==(other) def ==(other)
return false if other.nil? return false if other.nil?
validate other => [Symbol, self.class, Integer] validate other => [Symbol, self.class, String, Integer]
if other.is_a?(Symbol) if other.is_a?(Symbol)
return @id == other return @id == other
elsif other.is_a?(self.class) elsif other.is_a?(self.class)
return @id == other.id return @id == other.id
elsif other.is_a?(String)
return @id_number == other.to_sym
elsif other.is_a?(Integer) elsif other.is_a?(Integer)
return @id_number == other return @id_number == other
end end
+178 -45
View File
@@ -1,4 +1,4 @@
module PokemonData module GameData
class Item class Item
attr_reader :id attr_reader :id
attr_reader :id_number attr_reader :id_number
@@ -47,54 +47,187 @@ module PokemonData
def description def description
return pbGetMessage(MessageTypes::ItemDescriptions, @id_number) return pbGetMessage(MessageTypes::ItemDescriptions, @id_number)
end 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 def can_hold?; return !is_important?; end
module_function
def compile_items def unlosable?(species, ability)
item_names = [] return false if isConst?(species, PBSpecies, :ARCEUS) && ability != :MULTITYPE
item_names_plural = [] return false if isConst?(species, PBSpecies, :SILVALLY) && ability != :RKSSYSTEM
item_descriptions = [] combos = {
# Read each line of items.txt at a time and compile it into an item :ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no| :SKYPLATE, :FLYINIUMZ,
line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"]) :TOXICPLATE, :POISONIUMZ,
item_number = line[0] :EARTHPLATE, :GROUNDIUMZ,
item_symbol = line[1].to_sym :STONEPLATE, :ROCKIUMZ,
if PokemonData::Item::DATA[item_number] :INSECTPLATE, :BUGINIUMZ,
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}", item_number, FileLineData.linereport) :SPOOKYPLATE, :GHOSTIUMZ,
elsif PokemonData::Item::DATA[item_symbol] :IRONPLATE, :STEELIUMZ,
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport) :FLAMEPLATE, :FIRIUMZ,
end :SPLASHPLATE, :WATERIUMZ,
# Construct item hash :MEADOWPLATE, :GRASSIUMZ,
item_hash = { :ZAPPLATE, :ELECTRIUMZ,
:id_number => item_number, :MINDPLATE, :PSYCHIUMZ,
:id => item_symbol, :ICICLEPLATE, :ICIUMZ,
:name => line[2], :DRACOPLATE, :DRAGONIUMZ,
:name_plural => line[3], :DREADPLATE, :DARKINIUMZ,
:pocket => line[4], :PIXIEPLATE, :FAIRIUMZ],
:price => line[5], :SILVALLY => [:FIGHTINGMEMORY,
:description => line[6], :FLYINGMEMORY,
:field_use => line[7], :POISONMEMORY,
:battle_use => line[8], :GROUNDMEMORY,
:type => line[9] :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]) combos.each do |comboSpecies, items|
# Add item's data to records next if !isConst?(species, PBSpecies, comboSpecies)
PokemonData::Item::DATA[item_number] = PokemonData::Item::DATA[item_symbol] = PokemonData::Item.new(item_hash) return items.include?(@id)
item_names[item_number] = item_hash[:name] end
item_names_plural[item_number] = item_hash[:name_plural] return false
item_descriptions[item_number] = item_hash[:description] end
}
# 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
end 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 -1
View File
@@ -1,4 +1,4 @@
module PokemonData module GameData
class Ability class Ability
attr_reader :id attr_reader :id
attr_reader :id_number attr_reader :id_number
@@ -9,6 +9,7 @@ class PokeBattle_Battler
attr_accessor :type1 attr_accessor :type1
attr_accessor :type2 attr_accessor :type2
attr_accessor :ability_id attr_accessor :ability_id
attr_accessor :item_id
attr_accessor :moves attr_accessor :moves
attr_accessor :gender attr_accessor :gender
attr_accessor :iv attr_accessor :iv
@@ -60,19 +61,22 @@ class PokeBattle_Battler
end end
def ability def ability
return PokemonData::Ability.try_get(@ability_id) return GameData::Ability.try_get(@ability_id)
end end
def ability=(value) def ability=(value)
abil = PokemonData::Ability.try_get(value) new_ability = GameData::Ability.try_get(value)
@ability_id = (abil) ? abil.id : nil @ability_id = (new_ability) ? new_ability.id : nil
end end
attr_reader :item def item
return GameData::Item.try_get(@item_id)
end
def item=(value) def item=(value)
@item = value new_item = GameData::Item.try_get(value)
@pokemon.setItem(value) if @pokemon @item_id = (new_item) ? new_item.id : nil
@pokemon.setItem(@item_id) if @pokemon
end end
def defense def defense
@@ -195,7 +199,10 @@ class PokeBattle_Battler
return (abil) ? abil.name : "" return (abil) ? abil.name : ""
end end
def itemName; return PBItems.getName(@item); end def itemName
itm = self.item
return (itm) ? itm.name : ""
end
def pbThis(lowerCase=false) def pbThis(lowerCase=false)
if opposes? if opposes?
@@ -240,7 +247,7 @@ class PokeBattle_Battler
end end
# Item effects that alter calculated Speed # Item effects that alter calculated Speed
if itemActive? if itemActive?
speedMult = BattleHandlers.triggerSpeedCalcItem(@item,self,speedMult) speedMult = BattleHandlers.triggerSpeedCalcItem(self.item,self,speedMult)
end end
# Other effects # Other effects
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0 speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
@@ -266,7 +273,7 @@ class PokeBattle_Battler
ret = BattleHandlers.triggerWeightCalcAbility(self.ability,self,ret) ret = BattleHandlers.triggerWeightCalcAbility(self.ability,self,ret)
end end
if itemActive? if itemActive?
ret = BattleHandlers.triggerWeightCalcItem(@item,self,ret) ret = BattleHandlers.triggerWeightCalcItem(self.item,self,ret)
end end
return [ret,1].max return [ret,1].max
end end
@@ -331,14 +338,14 @@ class PokeBattle_Battler
# active, and the code for the two combined would cause an infinite loop # 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 # (regardless of whether any Pokémon actualy has either the ability or
# the item - the code existing is enough to cause the loop). # the item - the code existing is enough to cause the loop).
def abilityActive?(ignoreFainted=false) def abilityActive?(ignore_fainted = false)
return false if fainted? && !ignoreFainted return false if fainted? && !ignore_fainted
return false if @effects[PBEffects::GastroAcid] return false if @effects[PBEffects::GastroAcid]
return true return true
end end
def hasActiveAbility?(check_ability, ignoreFainted = false) def hasActiveAbility?(check_ability, ignore_fainted = false)
return false if !abilityActive?(ignoreFainted) return false if !abilityActive?(ignore_fainted)
return check_ability.include?(@ability_id) if check_ability.is_a?(Array) return check_ability.include?(@ability_id) if check_ability.is_a?(Array)
return check_ability == self.ability return check_ability == self.ability
end end
@@ -348,7 +355,7 @@ class PokeBattle_Battler
# having self's ability be negated. # having self's ability be negated.
def unstoppableAbility?(abil = nil) def unstoppableAbility?(abil = nil)
abil = @ability_id if !abil abil = @ability_id if !abil
abil = PokemonData::Ability.try_get(abil) abil = GameData::Ability.try_get(abil)
return false if !abil return false if !abil
ability_blacklist = [ ability_blacklist = [
# Form-changing abilities # Form-changing abilities
@@ -372,7 +379,7 @@ class PokeBattle_Battler
# Applies to gaining the ability. # Applies to gaining the ability.
def ungainableAbility?(abil = nil) def ungainableAbility?(abil = nil)
abil = @ability_id if !abil abil = @ability_id if !abil
abil = PokemonData::Ability.try_get(abil) abil = GameData::Ability.try_get(abil)
return false if !abil return false if !abil
ability_blacklist = [ ability_blacklist = [
# Form-changing abilities # Form-changing abilities
@@ -404,28 +411,21 @@ class PokeBattle_Battler
return true return true
end end
def hasActiveItem?(item,ignoreFainted=false) def hasActiveItem?(check_item, ignore_fainted = false)
return false if !itemActive?(ignoreFainted) return false if !itemActive?(ignore_fainted)
if item.is_a?(Array) return check_item.include?(@item_id) if check_item.is_a?(Array)
item.each do |i| return check_item == self.item
i = getID(PBItems,i)
return true if i!=0 && i==@item
end
return false
end
item = getID(PBItems,item)
return item!=0 && item==@item
end end
alias hasWorkingItem hasActiveItem? alias hasWorkingItem hasActiveItem?
# Returns whether the specified item will be unlosable for this Pokémon. # Returns whether the specified item will be unlosable for this Pokémon.
def unlosableItem?(check_item) def unlosableItem?(check_item)
return false if check_item <= 0 return false if !check_item
return true if pbIsMail?(check_item) return true if GameData::Item.get(check_item).is_mail?
return false if @effects[PBEffects::Transform] return false if @effects[PBEffects::Transform]
# Items that change a Pokémon's form # Items that change a Pokémon's form
return true if @pokemon && @pokemon.getMegaForm(true) > 0 # Mega Stone 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 end
def eachMove def eachMove
@@ -22,7 +22,7 @@ class PokeBattle_Battler
@hp = @totalhp = 0 @hp = @totalhp = 0
@type1 = @type2 = 0 @type1 = @type2 = 0
@ability_id = nil @ability_id = nil
@item = 0 @item_id = nil
@gender = 0 @gender = 0
@attack = @defense = @spatk = @spdef = @speed = 0 @attack = @defense = @spatk = @spdef = @speed = 0
@status = PBStatuses::NONE @status = PBStatuses::NONE
@@ -79,7 +79,7 @@ class PokeBattle_Battler
@type1 = pkmn.type1 @type1 = pkmn.type1
@type2 = pkmn.type2 @type2 = pkmn.type2
@ability_id = pkmn.ability_id @ability_id = pkmn.ability_id
@item = pkmn.item @item_id = pkmn.item_id
@gender = pkmn.gender @gender = pkmn.gender
@attack = pkmn.attack @attack = pkmn.attack
@defense = pkmn.defense @defense = pkmn.defense
@@ -188,7 +188,7 @@ class PokeBattle_Battler
@effects[PBEffects::FollowMe] = 0 @effects[PBEffects::FollowMe] = 0
@effects[PBEffects::Foresight] = false @effects[PBEffects::Foresight] = false
@effects[PBEffects::FuryCutter] = 0 @effects[PBEffects::FuryCutter] = 0
@effects[PBEffects::GemConsumed] = 0 @effects[PBEffects::GemConsumed] = nil
@effects[PBEffects::Grudge] = false @effects[PBEffects::Grudge] = false
@effects[PBEffects::HelpingHand] = false @effects[PBEffects::HelpingHand] = false
@effects[PBEffects::HyperBeam] = 0 @effects[PBEffects::HyperBeam] = 0
@@ -227,7 +227,7 @@ class PokeBattle_Battler
@effects[PBEffects::Nightmare] = false @effects[PBEffects::Nightmare] = false
@effects[PBEffects::Outrage] = 0 @effects[PBEffects::Outrage] = 0
@effects[PBEffects::ParentalBond] = 0 @effects[PBEffects::ParentalBond] = 0
@effects[PBEffects::PickupItem] = 0 @effects[PBEffects::PickupItem] = nil
@effects[PBEffects::PickupUse] = 0 @effects[PBEffects::PickupUse] = 0
@effects[PBEffects::Pinch] = false @effects[PBEffects::Pinch] = false
@effects[PBEffects::Powder] = false @effects[PBEffects::Powder] = false
@@ -17,7 +17,7 @@ class PokeBattle_Battler
@battle.pbEndPrimordialWeather @battle.pbEndPrimordialWeather
# Items that trigger upon switching in (Air Balloon message) # Items that trigger upon switching in (Air Balloon message)
if switchIn && itemActive? if switchIn && itemActive?
BattleHandlers.triggerItemOnSwitchIn(@item,self,@battle) BattleHandlers.triggerItemOnSwitchIn(self.item,self,@battle)
end end
# Berry check, status-curing ability check # Berry check, status-curing ability check
pbHeldItemTriggerCheck if switchIn pbHeldItemTriggerCheck if switchIn
@@ -75,7 +75,7 @@ class PokeBattle_Battler
choices = [] choices = []
@battle.eachOtherSideBattler(@index) do |b| @battle.eachOtherSideBattler(@index) do |b|
next if b.ungainableAbility? || next if b.ungainableAbility? ||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability) [:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
choices.push(b) choices.push(b)
end end
if choices.length>0 if choices.length>0
@@ -109,7 +109,7 @@ class PokeBattle_Battler
@effects[PBEffects::Illusion] = nil @effects[PBEffects::Illusion] = nil
if !@effects[PBEffects::Transform] if !@effects[PBEffects::Transform]
@battle.scene.pbChangePokemon(self, @pokemon) @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) @battle.pbSetSeen(self)
end end
end end
@@ -135,32 +135,32 @@ class PokeBattle_Battler
# permanent is whether the item is lost even after battle. Is false for Knock # permanent is whether the item is lost even after battle. Is false for Knock
# Off. # Off.
def pbRemoveItem(permanent=true) def pbRemoveItem(permanent = true)
@effects[PBEffects::ChoiceBand] = -1 @effects[PBEffects::ChoiceBand] = -1
@effects[PBEffects::Unburden] = true if @item>0 @effects[PBEffects::Unburden] = true if self.item
setInitialItem(0) if self.initialItem==@item && permanent setInitialItem(nil) if permanent && self.item == self.initialItem
self.item = 0 self.item = nil
end end
def pbConsumeItem(recoverable=true,symbiosis=true,belch=true) 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 if recoverable
setRecycleItem(@item) setRecycleItem(@item_id)
@effects[PBEffects::PickupItem] = @item @effects[PBEffects::PickupItem] = @item_id
@effects[PBEffects::PickupUse] = @battle.nextPickupUse @effects[PBEffects::PickupUse] = @battle.nextPickupUse
end end
setBelched if belch && pbIsBerry?(@item) setBelched if belch && self.item.is_berry?
pbRemoveItem pbRemoveItem
pbSymbiosis if symbiosis pbSymbiosis if symbiosis
end end
def pbSymbiosis def pbSymbiosis
return if fainted? return if fainted?
return if @item!=0 return if !self.item
@battle.pbPriority(true).each do |b| @battle.pbPriority(true).each do |b|
next if b.opposes? next if b.opposes?
next if !b.hasActiveAbility?(:SYMBIOSIS) 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) next if unlosableItem?(b.item)
@battle.pbShowAbilitySplash(b) @battle.pbShowAbilitySplash(b)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@@ -171,7 +171,7 @@ class PokeBattle_Battler
b.pbThis,b.abilityName,b.itemName,pbThis(true))) b.pbThis,b.abilityName,b.itemName,pbThis(true)))
end end
self.item = b.item self.item = b.item
b.item = 0 b.item = nil
b.effects[PBEffects::Unburden] = true b.effects[PBEffects::Unburden] = true
@battle.pbHideAbilitySplash(b) @battle.pbHideAbilitySplash(b)
pbHeldItemTriggerCheck pbHeldItemTriggerCheck
@@ -179,20 +179,22 @@ class PokeBattle_Battler
end end
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 # Cheek Pouch
if hasActiveAbility?(:CHEEKPOUCH) && pbIsBerry?(thisItem) && canHeal? if hasActiveAbility?(:CHEEKPOUCH) && GameData::Item.get(item_to_use).is_berry? && canHeal?
@battle.pbShowAbilitySplash(self) @battle.pbShowAbilitySplash(self)
pbRecoverHP(@totalhp/3) pbRecoverHP(@totalhp / 3)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH 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 else
@battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",pbThis,abilityName)) @battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", pbThis, abilityName))
end end
@battle.pbHideAbilitySplash(self) @battle.pbHideAbilitySplash(self)
end end
pbConsumeItem if forcedItem<=0 pbConsumeItem if own_item
pbSymbiosis if forcedItem>0 && !fling # Bug Bite/Pluck users trigger Symbiosis pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis
end 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 # 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 # it via Fling, will gain the effect of the item even if the Pokémon is
# affected by item-negating effects. # affected by item-negating effects.
# If forcedItem is -1, the Pokémon's held item is forced to be consumed. If it # item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
# is greater than 0, a different item (of that ID) is forced to be consumed # fling is for Fling only.
# (not the Pokémon's held one). def pbHeldItemTriggerCheck(item_to_use = nil, fling = false)
def pbHeldItemTriggerCheck(forcedItem=0,fling=false)
return if fainted? return if fainted?
return if forcedItem==0 && !itemActive? return if !item_to_use && !itemActive?
pbItemHPHealCheck(forcedItem,fling) pbItemHPHealCheck(item_to_use, fling)
pbItemStatusCureCheck(forcedItem,fling) pbItemStatusCureCheck(item_to_use, fling)
pbItemEndOfMoveCheck(forcedItem,fling) pbItemEndOfMoveCheck(item_to_use, fling)
# For Enigma Berry, Kee Berry and Maranga Berry, which have their effects # For Enigma Berry, Kee Berry and Maranga Berry, which have their effects
# when forcibly consumed by Pluck/Fling. # when forcibly consumed by Pluck/Fling.
if forcedItem!=0 if item_to_use
thisItem = (forcedItem>0) ? forcedItem : @item itm = item_to_use || self.item
if BattleHandlers.triggerTargetItemOnHitPositiveBerry(thisItem,self,@battle,true) if BattleHandlers.triggerTargetItemOnHitPositiveBerry(itm, self, @battle, true)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, false, fling)
end end
end 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. # fling is for Fling only.
def pbItemHPHealCheck(forcedItem=0,fling=false) def pbItemHPHealCheck(item_to_use = nil, fling = false)
return if forcedItem==0 && !itemActive? return if !item_to_use && !itemActive?
thisItem = (forcedItem>0) ? forcedItem : @item itm = item_to_use || self.item
if BattleHandlers.triggerHPHealItem(thisItem,self,@battle,(forcedItem!=0)) if BattleHandlers.triggerHPHealItem(itm, self, @battle, !item_to_use.nil?)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, item_to_use.nil?, fling)
elsif forcedItem==0 elsif !item_to_use
pbItemTerrainStatBoostCheck pbItemTerrainStatBoostCheck
end end
end end
# Cures status conditions, confusion, infatuation and the other effects cured # Cures status conditions, confusion, infatuation and the other effects cured
# by Mental Herb. # by Mental Herb.
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for # item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
# Fling only. # fling is for Fling only.
def pbItemStatusCureCheck(forcedItem=0,fling=false) def pbItemStatusCureCheck(item_to_use = nil, fling = false)
return if fainted? return if fainted?
return if forcedItem==0 && !itemActive? return if !item_to_use && !itemActive?
thisItem = (forcedItem>0) ? forcedItem : @item itm = item_to_use || self.item
if BattleHandlers.triggerStatusCureItem(thisItem,self,@battle,(forcedItem!=0)) if BattleHandlers.triggerStatusCureItem(itm, self, @battle, !item_to_use.nil?)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, item_to_use.nil?, fling)
end end
end end
# Called at the end of using a move. # Called at the end of using a move.
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for # item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
# Fling only. # fling is for Fling only.
def pbItemEndOfMoveCheck(forcedItem=0,fling=false) def pbItemEndOfMoveCheck(item_to_use = nil, fling = false)
return if fainted? return if fainted?
return if forcedItem==0 && !itemActive? return if !item_to_use && !itemActive?
thisItem = (forcedItem>0) ? forcedItem : @item itm = item_to_use || self.item
if BattleHandlers.triggerEndOfMoveItem(thisItem,self,@battle,(forcedItem!=0)) if BattleHandlers.triggerEndOfMoveItem(itm, self, @battle, !item_to_use.nil?)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, item_to_use.nil?, fling)
elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0)) elsif BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, item_to_use.nil?, fling)
end end
end end
# Used for White Herb (restore lowered stats). Only called by Moody and Sticky # 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 # 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. # 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 # item_to_use is an item ID for Bug Bite/Pluck and Fling, and nil otherwise.
# Fling only. # fling is for Fling only.
def pbItemStatRestoreCheck(forcedItem=0,fling=false) def pbItemStatRestoreCheck(item_to_use = nil, fling = false)
return if fainted? return if fainted?
return if forcedItem==0 && !itemActive? return if !item_to_use && !itemActive?
thisItem = (forcedItem>0) ? forcedItem : @item itm = item_to_use || self.item
if BattleHandlers.triggerEndOfMoveStatRestoreItem(thisItem,self,@battle,(forcedItem!=0)) if BattleHandlers.triggerEndOfMoveStatRestoreItem(itm, self, @battle, !item_to_use.nil?)
pbHeldItemTriggered(thisItem,forcedItem,fling) pbHeldItemTriggered(itm, item_to_use.nil?, fling)
end end
end end
# Called when the battle terrain changes and when a Pokémon loses HP. # 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 def pbItemTerrainStatBoostCheck
return if !itemActive? return if !itemActive?
if BattleHandlers.triggerTerrainStatBoostItem(@item,self,@battle) if BattleHandlers.triggerTerrainStatBoostItem(self.item, self, @battle)
pbHeldItemTriggered(@item) pbHeldItemTriggered(self.item)
end end
end end
# Used for Adrenaline Orb. Called when Intimidate is triggered (even if # Used for Adrenaline Orb. Called when Intimidate is triggered (even if
# Intimidate has no effect on the Pokémon). # 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 def pbItemOnIntimidatedCheck
return if !itemActive? return if !itemActive?
if BattleHandlers.triggerItemOnIntimidated(@item,self,@battle) if BattleHandlers.triggerItemOnIntimidated(self.item, self, @battle)
pbHeldItemTriggered(@item) pbHeldItemTriggered(self.item)
end end
end end
end end
@@ -116,7 +116,7 @@ class PokeBattle_Battler
end end
end end
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1 @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 @battle.eachBattler { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
end end
@@ -624,12 +624,12 @@ class PokeBattle_Battler
# Show move animation (for this hit) # Show move animation (for this hit)
move.pbShowAnimation(move.id,user,targets,hitNum) move.pbShowAnimation(move.id,user,targets,hitNum)
# Type-boosting Gem consume animation/message # 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 # NOTE: The consume animation and message for Gems are shown now, but the
# actual removal of the item happens in def pbEffectsAfterMove. # actual removal of the item happens in def pbEffectsAfterMove.
@battle.pbCommonAnimation("UseItem",user) @battle.pbCommonAnimation("UseItem",user)
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!", @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 end
# Messages about missed target(s) (relevant for multi-target moves only) # Messages about missed target(s) (relevant for multi-target moves only)
targets.each do |b| targets.each do |b|
@@ -111,7 +111,7 @@ class PokeBattle_Battler
end end
end end
# Consume user's Gem # 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 # NOTE: The consume animation and message for Gems are shown immediately
# after the move's animation, but the item is only consumed now. # after the move's animation, but the item is only consumed now.
user.pbConsumeItem user.pbConsumeItem
@@ -1997,7 +1997,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_063 < PokeBattle_Move class PokeBattle_Move_063 < PokeBattle_Move
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
if !PokemonData::Ability.exists?(:SIMPLE) if !GameData::Ability.exists?(:SIMPLE)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2030,7 +2030,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_064 < PokeBattle_Move class PokeBattle_Move_064 < PokeBattle_Move
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
if !PokemonData::Ability.exists?(:INSOMNIA) if !GameData::Ability.exists?(:INSOMNIA)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -93,7 +93,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_086 < PokeBattle_Move class PokeBattle_Move_086 < PokeBattle_Move
def pbBaseDamageMultiplier(damageMult,user,target) def pbBaseDamageMultiplier(damageMult,user,target)
damageMult *= 2 if user.item==0 damageMult *= 2 if !user.item
return damageMult return damageMult
end end
end end
@@ -473,13 +473,13 @@ class PokeBattle_Move_096 < PokeBattle_Move
:ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY, :JABOCABERRY, :ROWAPBERRY, :ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY, :JABOCABERRY, :ROWAPBERRY,
:KEEBERRY, :MARANGABERRY] :KEEBERRY, :MARANGABERRY]
} }
@berry = 0 @berry = nil
end end
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
# NOTE: Unnerve does not stop a Pokémon using this move. # NOTE: Unnerve does not stop a Pokémon using this move.
@berry = user.item @berry = user.item
if !pbIsBerry?(@berry) || !user.itemActive? if !@berry || !@berry.is_berry? || !user.itemActive?
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -492,14 +492,10 @@ class PokeBattle_Move_096 < PokeBattle_Move
# complex item movement is unlikely, perhaps this is good enough. # complex item movement is unlikely, perhaps this is good enough.
def pbBaseType(user) def pbBaseType(user)
ret = getID(PBTypes,:NORMAL) ret = getID(PBTypes,:NORMAL)
found = false
@typeArray.each do |type, items| @typeArray.each do |type, items|
items.each do |i| next if !items.include?(@berry.id)
next if !isConst?(@berry,PBItems,i) ret = getConst(PBTypes,type) || ret
ret = getConst(PBTypes,type) || ret break
found = true; break
end
break if found
end end
return ret return ret
end 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 # This is a separate method so that the AI can use it as well
def pbNaturalGiftBaseDamage(heldItem) def pbNaturalGiftBaseDamage(heldItem)
ret = 1 ret = 1
found = false
@damageArray.each do |dmg, items| @damageArray.each do |dmg, items|
items.each do |i| next if !items.include?(heldItem)
next if !isConst?(heldItem,PBItems,i) ret = dmg
ret = dmg ret += 20 if NEWEST_BATTLE_MECHANICS
ret += 20 if NEWEST_BATTLE_MECHANICS break
found = true; break
end
break if found
end end
return ret return ret
end end
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
return pbNaturalGiftBaseDamage(@berry) return pbNaturalGiftBaseDamage(@berry.id)
end end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers) 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 # missed. The item is not consumed if the target was switched out by
# an effect like a target's Red Card. # an effect like a target's Red Card.
# NOTE: There is no item consumption animation. # NOTE: There is no item consumption animation.
user.pbConsumeItem(true,true,false) if user.item>0 user.pbConsumeItem(true,true,false) if user.item
@berry = 0 @berry = nil
end end
end end
@@ -776,7 +768,7 @@ class PokeBattle_Move_09F < PokeBattle_Move
ret = getID(PBTypes,:NORMAL) ret = getID(PBTypes,:NORMAL)
if user.itemActive? if user.itemActive?
@itemTypes.each do |item, itemType| @itemTypes.each do |item, itemType|
next if !isConst?(user.item,PBItems,item) next if user.item != item
t = getConst(PBTypes,itemType) t = getConst(PBTypes,itemType)
ret = t || ret ret = t || ret
break break
@@ -3195,7 +3187,7 @@ end
class PokeBattle_Move_0F0 < PokeBattle_Move class PokeBattle_Move_0F0 < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
if NEWEST_BATTLE_MECHANICS && 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 # NOTE: Damage is still boosted even if target has Sticky Hold or a
# substitute. # substitute.
baseDmg = (baseDmg*1.5).round 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 @battle.wildBattle? && user.opposes? # Wild Pokémon can't knock off
return if user.fainted? return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute 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 return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
itemName = target.itemName itemName = target.itemName
target.pbRemoveItem(false) 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 @battle.wildBattle? && user.opposes? # Wild Pokémon can't thieve
return if user.fainted? return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute 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 target.unlosableItem?(target.item)
return if user.unlosableItem?(target.item) return if user.unlosableItem?(target.item)
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
@@ -3234,7 +3226,7 @@ class PokeBattle_Move_0F1 < PokeBattle_Move
user.item = target.item user.item = target.item
# Permanently steal the item from wild Pokémon # Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && if @battle.wildBattle? && target.opposes? &&
target.initialItem==target.item && user.initialItem==0 target.initialItem==target.item && !user.initialItem
user.setInitialItem(target.item) user.setInitialItem(target.item)
target.pbRemoveItem target.pbRemoveItem
else else
@@ -3261,7 +3253,7 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if user.item==0 && target.item==0 if !user.item && !target.item
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -3291,22 +3283,22 @@ class PokeBattle_Move_0F2 < PokeBattle_Move
oldTargetItem = target.item; oldTargetItemName = target.itemName oldTargetItem = target.item; oldTargetItemName = target.itemName
user.item = oldTargetItem user.item = oldTargetItem
user.effects[PBEffects::ChoiceBand] = -1 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.item = oldUserItem
target.effects[PBEffects::ChoiceBand] = -1 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 # Permanently steal the item from wild Pokémon
if @battle.wildBattle? && target.opposes? && if @battle.wildBattle? && target.opposes? &&
target.initialItem==oldTargetItem && user.initialItem==0 target.initialItem==oldTargetItem && !user.initialItem
user.setInitialItem(oldTargetItem) user.setInitialItem(oldTargetItem)
end end
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis)) @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)) @battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
elsif oldTargetItem>0 elsif oldTargetItem
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName)) @battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName))
end 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 user.pbHeldItemTriggerCheck
target.pbHeldItemTriggerCheck target.pbHeldItemTriggerCheck
end end
@@ -3325,7 +3317,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
end end
def pbMoveFailed?(user,targets) 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!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -3333,7 +3325,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) 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!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -3345,7 +3337,7 @@ class PokeBattle_Move_0F3 < PokeBattle_Move
target.item = user.item target.item = user.item
# Permanently steal the item from wild Pokémon # Permanently steal the item from wild Pokémon
if @battle.wildBattle? && user.opposes? && if @battle.wildBattle? && user.opposes? &&
user.initialItem==user.item && target.initialItem==0 user.initialItem==user.item && !target.initialItem
target.setInitialItem(user.item) target.setInitialItem(user.item)
user.pbRemoveItem user.pbRemoveItem
else else
@@ -3365,7 +3357,7 @@ class PokeBattle_Move_0F4 < PokeBattle_Move
def pbEffectAfterAllHits(user,target) def pbEffectAfterAllHits(user,target)
return if user.fainted? || target.fainted? return if user.fainted? || target.fainted?
return if target.damageState.unaffected || target.damageState.substitute 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 return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
item = target.item item = target.item
itemName = target.itemName itemName = target.itemName
@@ -3383,8 +3375,8 @@ end
class PokeBattle_Move_0F5 < PokeBattle_Move class PokeBattle_Move_0F5 < PokeBattle_Move
def pbEffectWhenDealingDamage(user,target) def pbEffectWhenDealingDamage(user,target)
return if target.damageState.substitute || target.damageState.berryWeakened return if target.damageState.substitute || target.damageState.berryWeakened
return if !pbIsBerry?(target.item) && return if !target.item || (!target.item.is_berry? &&
!(NEWEST_BATTLE_MECHANICS && pbIsGem?(target.item)) !(NEWEST_BATTLE_MECHANICS && target.item.is_gem?))
target.pbRemoveItem target.pbRemoveItem
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName)) @battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName))
end end
@@ -3397,7 +3389,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_Move_0F6 < PokeBattle_Move class PokeBattle_Move_0F6 < PokeBattle_Move
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
if user.recycleItem==0 if !user.recycleItem
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -3407,11 +3399,11 @@ class PokeBattle_Move_0F6 < PokeBattle_Move
def pbEffectGeneral(user) def pbEffectGeneral(user)
item = user.recycleItem item = user.recycleItem
user.item = item user.item = item
user.setInitialItem(item) if @battle.wildBattle? && user.initialItem==0 user.setInitialItem(item) if @battle.wildBattle? && !user.initialItem
user.setRecycleItem(0) user.setRecycleItem(nil)
user.effects[PBEffects::PickupItem] = 0 user.effects[PBEffects::PickupItem] = nil
user.effects[PBEffects::PickupUse] = 0 user.effects[PBEffects::PickupUse] = 0
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel? if itemName.starts_with_vowel?
@battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName)) @battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName))
else else
@@ -3545,20 +3537,18 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
def pbCheckFlingSuccess(user) def pbCheckFlingSuccess(user)
@willFail = false @willFail = false
@willFail = true if user.item==0 || !user.itemActive? || user.unlosableItem?(user.item) @willFail = true if !user.item || !user.itemActive? || user.unlosableItem?(user.item)
if pbIsBerry?(user.item) return if @willFail
@willFail = true if @battle.pbCheckOpposingAbility(:UNNERVE,user.index) if user.item.is_berry? && @battle.pbCheckOpposingAbility(:UNNERVE,user.index)
return @willFail = true
end end
return if pbIsMegaStone?(user.item) return if @willFail
return if user.item.is_mega_stone?
flingableItem = false flingableItem = false
@flingPowers.each do |_power,items| @flingPowers.each do |_power, items|
items.each do |i| next if !items.include?(user.item_id)
next if !isConst?(user.item,PBItems,i) flingableItem = true
flingableItem = true break
break
end
break if flingableItem
end end
@willFail = true if !flingableItem @willFail = true if !flingableItem
end end
@@ -3582,10 +3572,10 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
def pbNumHits(user,targets); return 1; end def pbNumHits(user,targets); return 1; end
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
return 10 if pbIsBerry?(user.item) return 10 if user.item && user.item.is_berry?
return 80 if pbIsMegaStone?(user.item) return 80 if user.item && user.item.is_mega_stone?
@flingPowers.each do |power,items| @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 end
return 10 return 10
end end
@@ -3593,16 +3583,16 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
def pbEffectAgainstTarget(user,target) def pbEffectAgainstTarget(user,target)
return if target.damageState.substitute return if target.damageState.substitute
return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker 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) 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) 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) 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) target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
elsif isConst?(user.item,PBItems,:KINGSROCK) || when :KINGSROCK, :RAZORFANG
isConst?(user.item,PBItems,:RAZORFANG)
target.pbFlinch(user) target.pbFlinch(user)
else else
target.pbHeldItemTriggerCheck(user.item,true) 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 # missed. The item is not consumed if the target was switched out by
# an effect like a target's Red Card. # an effect like a target's Red Card.
# NOTE: There is no item consumption animation. # 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
end end
@@ -15,7 +15,7 @@ module PokeBattle_BattleCommon
storedBox = @peer.pbStorePokemon(pbPlayer,pkmn) storedBox = @peer.pbStorePokemon(pbPlayer,pkmn)
if storedBox<0 if storedBox<0
pbDisplayPaused(_INTL("{1} has been added to your party.",pkmn.name)) 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 return
end end
# Messages saying the Pokémon was stored in a PC box # Messages saying the Pokémon was stored in a PC box
@@ -80,7 +80,7 @@ module PokeBattle_BattleCommon
end end
end end
# Messages # Messages
itemName = PBItems.getName(ball) itemName = GameData::Item.get(ball).name
if battler.fainted? if battler.fainted?
if itemName.starts_with_vowel? if itemName.starts_with_vowel?
pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName)) pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
@@ -97,7 +97,7 @@ module PokeBattle_BattleCommon
end end
# Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball # Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball
# at a Shadow Pokémon) # 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) @scene.pbThrowAndDeflect(ball,1)
pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!")) pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!"))
return return
@@ -140,7 +140,7 @@ module PokeBattle_BattleCommon
@decision = 4 if pbAllFainted?(battler.index) # Battle ended by capture @decision = 4 if pbAllFainted?(battler.index) # Battle ended by capture
end end
# Modify the Pokémon's properties because of the capture # 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) pkmn.owner = Pokemon::Owner.new_from_trainer(pbPlayer)
end end
BallHandlers.onCatch(ball,self,pkmn) BallHandlers.onCatch(ball,self,pkmn)
@@ -180,7 +180,7 @@ module PokeBattle_BattleCommon
battler.isSpecies?(:NAGANADEL) || battler.isSpecies?(:NAGANADEL) ||
battler.isSpecies?(:STAKATAKA) || battler.isSpecies?(:STAKATAKA) ||
battler.isSpecies?(:BLACEPHALON)) battler.isSpecies?(:BLACEPHALON))
if !ultraBeast || isConst?(ball,PBItems,:BEASTBALL) if !ultraBeast || ball == :BEASTBALL
rareness = BallHandlers.modifyCatchRate(ball,rareness,self,battler,ultraBeast) rareness = BallHandlers.modifyCatchRate(ball,rareness,self,battler,ultraBeast)
else else
rareness /= 10 rareness /= 10
@@ -144,13 +144,13 @@ class PokeBattle_Battle
[-1] * (@opponent ? @opponent.length : 1) [-1] * (@opponent ? @opponent.length : 1)
] ]
@initialItems = [ @initialItems = [
Array.new(@party1.length) { |i| (@party1[i]) ? @party1[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 : 0 } Array.new(@party2.length) { |i| (@party2[i]) ? @party2[i].item_id : nil }
] ]
@recycleItems = [Array.new(@party1.length,0),Array.new(@party2.length,0)] @recycleItems = [Array.new(@party1.length, nil), Array.new(@party2.length, nil)]
@belch = [Array.new(@party1.length,false),Array.new(@party2.length,false)] @belch = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
@battleBond = [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)] @usedInBattle = [Array.new(@party1.length, false), Array.new(@party2.length, false)]
@successStates = [] @successStates = []
@lastMoveUsed = -1 @lastMoveUsed = -1
@lastMoveUser = -1 @lastMoveUser = -1
@@ -478,7 +478,7 @@ class PokeBattle_Battle
pbParty(0).each_with_index do |pkmn,i| pbParty(0).each_with_index do |pkmn,i|
next if !pkmn next if !pkmn
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form @peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
pkmn.setItem(@initialItems[0][i] || 0) pkmn.setItem(@initialItems[0][i])
end end
return @decision return @decision
end end
@@ -8,7 +8,7 @@ class PokeBattle_Battle
return if !@internalBattle || !@expGain return if !@internalBattle || !@expGain
# Go through each battler in turn to find the Pokémon that participated in # Go through each battler in turn to find the Pokémon that participated in
# battle against it, and award those Pokémon Exp/EVs # 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) p1 = pbParty(0)
@battlers.each do |b| @battlers.each do |b|
next unless b && b.opposes? # Can only gain Exp from fainted foes next unless b && b.opposes? # Can only gain Exp from fainted foes
@@ -25,8 +25,7 @@ class PokeBattle_Battle
if !expAll if !expAll
eachInTeam(0,0) do |pkmn,i| eachInTeam(0,0) do |pkmn,i|
next if !pkmn.able? next if !pkmn.able?
next if !pkmn.hasItem?(:EXPSHARE) && next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
!isConst?(@initialItems[0][i],PBItems,:EXPSHARE)
expShare.push(i) expShare.push(i)
end end
end end
@@ -323,8 +323,7 @@ class PokeBattle_Battle
pbDisplay(_INTL("Oh!\nA Shadow Pokémon!")) pbDisplay(_INTL("Oh!\nA Shadow Pokémon!"))
end end
# Record money-doubling effect of Amulet Coin/Luck Incense # Record money-doubling effect of Amulet Coin/Luck Incense
if !battler.opposes? && (isConst?(battler.item,PBItems,:AMULETCOIN) || if !battler.opposes? && [:AMULETCOIN, :LUCKINCENSE].include?(battler.item_id)
isConst?(battler.item,PBItems,:LUCKINCENSE))
@field.effects[PBEffects::AmuletCoin] = true @field.effects[PBEffects::AmuletCoin] = true
end end
# Update battlers' participants (who will gain Exp/EVs when a battler faints) # 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 # below is one half of making this happen; the other half is in the
# ItemHandlers::CanUseInBattle for Poké Balls. # ItemHandlers::CanUseInBattle for Poké Balls.
def pbItemUsesAllActions?(item) def pbItemUsesAllActions?(item)
return true if pbIsPokeBall?(item) return true if GameData::Item.get(item).is_poke_ball?
return false return false
end end
@@ -40,9 +40,9 @@ class PokeBattle_Battle
# Using an item # Using an item
#============================================================================= #=============================================================================
def pbConsumeItemInBag(item,idxBattler) def pbConsumeItemInBag(item,idxBattler)
return if item==0 return if !item
useType = pbGetItemData(item,ItemData::BATTLE_USE) useType = GameData::Item.get(item).battle_use
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
if pbOwnedByPlayer?(idxBattler) if pbOwnedByPlayer?(idxBattler)
if !$PokemonBag.pbDeleteItem(item) if !$PokemonBag.pbDeleteItem(item)
raise _INTL("Tried to consume item that wasn't in the Bag somehow.") raise _INTL("Tried to consume item that wasn't in the Bag somehow.")
@@ -59,9 +59,9 @@ class PokeBattle_Battle
end end
def pbReturnUnusedItemToBag(item,idxBattler) def pbReturnUnusedItemToBag(item,idxBattler)
return if item==0 return if item!
useType = pbGetItemData(item,ItemData::BATTLE_USE) useType = GameData::Item.get(item).battle_use
return if !useType || useType==0 || (useType>=6 && useType<=10) # Not consumed upon use return if useType==0 || (useType>=6 && useType<=10) # Not consumed upon use
if pbOwnedByPlayer?(idxBattler) if pbOwnedByPlayer?(idxBattler)
if $PokemonBag && $PokemonBag.pbCanStore?(item) if $PokemonBag && $PokemonBag.pbCanStore?(item)
$PokemonBag.pbStoreItem(item) $PokemonBag.pbStoreItem(item)
@@ -75,7 +75,7 @@ class PokeBattle_Battle
end end
def pbUseItemMessage(item,trainerName) def pbUseItemMessage(item,trainerName)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel? if itemName.starts_with_vowel?
pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName)) pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName))
else else
@@ -92,7 +92,7 @@ class PokeBattle_Battle
ch = @choices[userBattler.index] ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene) ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene)
ch[1] = 0 # Delete item from choice ch[1] = nil # Delete item from choice
return return
end end
pbDisplay(_INTL("But it had no effect!")) pbDisplay(_INTL("But it had no effect!"))
@@ -109,7 +109,7 @@ class PokeBattle_Battle
ch = @choices[userBattler.index] ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene) ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
ch[1] = 0 # Delete item from choice ch[1] = nil # Delete item from choice
return return
end end
pbDisplay(_INTL("But it's not where this item can be used!")) 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 idxBattler = userBattler.index if idxBattler<0
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
ItemHandlers.triggerUseInBattle(item,battler,self) ItemHandlers.triggerUseInBattle(item,battler,self)
@choices[userBattler.index][1] = 0 # Delete item from choice @choices[userBattler.index][1] = nil # Delete item from choice
end end
# Uses an item in battle directly. # Uses an item in battle directly.
@@ -134,7 +134,7 @@ class PokeBattle_Battle
ch = @choices[userBattler.index] ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerUseInBattle(item,battler,self) ItemHandlers.triggerUseInBattle(item,battler,self)
ch[1] = 0 # Delete item from choice ch[1] = nil # Delete item from choice
return return
end end
pbDisplay(_INTL("But it had no effect!")) pbDisplay(_INTL("But it had no effect!"))
@@ -62,17 +62,14 @@ class PokeBattle_Battle
#============================================================================= #=============================================================================
def pbHasMegaRing?(idxBattler) def pbHasMegaRing?(idxBattler)
return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring
MEGA_RINGS.each do |item| MEGA_RINGS.each { |item| return true if $PokemonBag.pbHasItem?(item) }
return true if hasConst?(PBItems,item) && $PokemonBag.pbHasItem?(item)
end
return false return false
end end
def pbGetMegaRingName(idxBattler) def pbGetMegaRingName(idxBattler)
if pbOwnedByPlayer?(idxBattler) if pbOwnedByPlayer?(idxBattler)
MEGA_RINGS.each do |i| MEGA_RINGS.each do |item|
next if !hasConst?(PBItems,i) return GameData::Item.get(item).name if $PokemonBag.pbHasItem?(item)
return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbHasItem?(i)
end end
end end
# NOTE: Add your own Mega objects for particular NPC trainers here. # NOTE: Add your own Mega objects for particular NPC trainers here.
@@ -12,9 +12,9 @@ class PokeBattle_Battle
def pbCancelChoice(idxBattler) def pbCancelChoice(idxBattler)
# If idxBattler's choice was to use an item, return that item to the Bag # 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] item = @choices[idxBattler][1]
pbReturnUnusedItemToBag(item,idxBattler) if item && item>0 pbReturnUnusedItemToBag(item, idxBattler) if item
end end
# If idxBattler chose to Mega Evolve, cancel it # If idxBattler chose to Mega Evolve, cancel it
pbUnregisterMegaEvolution(idxBattler) pbUnregisterMegaEvolution(idxBattler)
@@ -104,7 +104,7 @@ class PokeBattle_Battle
end end
ret = false ret = false
@scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene| @scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene|
next false if item<0 next false if !item
battler = pkmn = nil battler = pkmn = nil
case useType case useType
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move
@@ -66,23 +66,23 @@ class PokeBattle_Battle
def pbAttackPhaseItems def pbAttackPhaseItems
pbPriority.each do |b| 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 b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
item = @choices[b.index][1] item = @choices[b.index][1]
next if !item || item<=0 next if !item
useType = pbGetItemData(item,ItemData::BATTLE_USE) case GameData::Item.get(item).battle_use
next if !useType
case useType
when 1, 2, 6, 7 # Use on Pokémon/Pokémon's move 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 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 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 when 5, 10 # Use directly
pbUseItemInBattle(item,@choices[b.index][2],b) pbUseItemInBattle(item, @choices[b.index][2], b)
else
next
end end
return if @decision>0 return if @decision > 0
end end
# pbCalculatePriority if NEWEST_BATTLE_MECHANICS # pbCalculatePriority if NEWEST_BATTLE_MECHANICS
end end
+77 -88
View File
@@ -5,24 +5,24 @@ class PokeBattle_AI
def pbEnemyShouldUseItem?(idxBattler) def pbEnemyShouldUseItem?(idxBattler)
user = @battle.battlers[idxBattler] user = @battle.battlers[idxBattler]
item, idxTarget = pbEnemyItemToUse(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) # Determine target of item (always the Pokémon choosing the action)
useType = pbGetItemData(item,ItemData::BATTLE_USE) useType = GameData::Item.get(item).battle_use
if useType && (useType==1 || useType==6) # Use on Pokémon if useType==1 || useType==6 # Use on Pokémon
idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon
end end
# Register use of item # Register use of item
@battle.pbRegisterItem(idxBattler,item,idxTarget) @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 return true
end end
# NOTE: The AI will only consider using an item on the Pokémon it's currently # NOTE: The AI will only consider using an item on the Pokémon it's currently
# choosing an action for. # choosing an action for.
def pbEnemyItemToUse(idxBattler) def pbEnemyItemToUse(idxBattler)
return 0 if !@battle.internalBattle return nil if !@battle.internalBattle
items = @battle.pbGetOwnerItems(idxBattler) 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) # Determine target of item (always the Pokémon choosing the action)
idxTarget = idxBattler # Battler using the item idxTarget = idxBattler # Battler using the item
battler = @battle.battlers[idxTarget] battler = @battle.battlers[idxTarget]
@@ -49,106 +49,95 @@ class PokeBattle_AI
:FULLRESTORE :FULLRESTORE
] ]
oneStatusItems = [ # Preferred over items that heal all status problems oneStatusItems = [ # Preferred over items that heal all status problems
:AWAKENING,:CHESTOBERRY,:BLUEFLUTE, :AWAKENING, :CHESTOBERRY, :BLUEFLUTE,
:ANTIDOTE,:PECHABERRY, :ANTIDOTE, :PECHABERRY,
:BURNHEAL,:RAWSTBERRY, :BURNHEAL, :RAWSTBERRY,
:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY, :PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY,
:ICEHEAL,:ASPEARBERRY :ICEHEAL, :ASPEARBERRY
] ]
allStatusItems = [ allStatusItems = [
:FULLHEAL,:LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE, :FULLHEAL, :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE,
:SHALOURSABLE,:BIGMALASADA,:LUMBERRY,:HEALPOWDER :SHALOURSABLE, :BIGMALASADA, :LUMBERRY, :HEALPOWDER
] ]
allStatusItems.push(:RAGECANDYBAR) if NEWEST_BATTLE_MECHANICS allStatusItems.push(:RAGECANDYBAR) if NEWEST_BATTLE_MECHANICS
xItems = { xItems = {
:XATTACK => [PBStats::ATTACK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XATTACK => [PBStats::ATTACK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XATTACK2 => [PBStats::ATTACK,2], :XATTACK2 => [PBStats::ATTACK, 2],
:XATTACK3 => [PBStats::ATTACK,3], :XATTACK3 => [PBStats::ATTACK, 3],
:XATTACK6 => [PBStats::ATTACK,6], :XATTACK6 => [PBStats::ATTACK, 6],
:XDEFENSE => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XDEFENSE => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XDEFENSE2 => [PBStats::DEFENSE,2], :XDEFENSE2 => [PBStats::DEFENSE, 2],
:XDEFENSE3 => [PBStats::DEFENSE,3], :XDEFENSE3 => [PBStats::DEFENSE, 3],
:XDEFENSE6 => [PBStats::DEFENSE,6], :XDEFENSE6 => [PBStats::DEFENSE, 6],
:XDEFEND => [PBStats::DEFENSE,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XDEFEND => [PBStats::DEFENSE, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XDEFEND2 => [PBStats::DEFENSE,2], :XDEFEND2 => [PBStats::DEFENSE, 2],
:XDEFEND3 => [PBStats::DEFENSE,3], :XDEFEND3 => [PBStats::DEFENSE, 3],
:XDEFEND6 => [PBStats::DEFENSE,6], :XDEFEND6 => [PBStats::DEFENSE, 6],
:XSPATK => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XSPATK => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XSPATK2 => [PBStats::SPATK,2], :XSPATK2 => [PBStats::SPATK, 2],
:XSPATK3 => [PBStats::SPATK,3], :XSPATK3 => [PBStats::SPATK, 3],
:XSPATK6 => [PBStats::SPATK,6], :XSPATK6 => [PBStats::SPATK, 6],
:XSPECIAL => [PBStats::SPATK,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XSPECIAL => [PBStats::SPATK, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XSPECIAL2 => [PBStats::SPATK,2], :XSPECIAL2 => [PBStats::SPATK, 2],
:XSPECIAL3 => [PBStats::SPATK,3], :XSPECIAL3 => [PBStats::SPATK, 3],
:XSPECIAL6 => [PBStats::SPATK,6], :XSPECIAL6 => [PBStats::SPATK, 6],
:XSPDEF => [PBStats::SPDEF,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XSPDEF => [PBStats::SPDEF, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XSPDEF2 => [PBStats::SPDEF,2], :XSPDEF2 => [PBStats::SPDEF, 2],
:XSPDEF3 => [PBStats::SPDEF,3], :XSPDEF3 => [PBStats::SPDEF, 3],
:XSPDEF6 => [PBStats::SPDEF,6], :XSPDEF6 => [PBStats::SPDEF, 6],
:XSPEED => [PBStats::SPEED,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XSPEED => [PBStats::SPEED, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XSPEED2 => [PBStats::SPEED,2], :XSPEED2 => [PBStats::SPEED, 2],
:XSPEED3 => [PBStats::SPEED,3], :XSPEED3 => [PBStats::SPEED, 3],
:XSPEED6 => [PBStats::SPEED,6], :XSPEED6 => [PBStats::SPEED, 6],
:XACCURACY => [PBStats::ACCURACY,(NEWEST_BATTLE_MECHANICS) ? 2 : 1], :XACCURACY => [PBStats::ACCURACY, (NEWEST_BATTLE_MECHANICS) ? 2 : 1],
:XACCURACY2 => [PBStats::ACCURACY,2], :XACCURACY2 => [PBStats::ACCURACY, 2],
:XACCURACY3 => [PBStats::ACCURACY,3], :XACCURACY3 => [PBStats::ACCURACY, 3],
:XACCURACY6 => [PBStats::ACCURACY,6] :XACCURACY6 => [PBStats::ACCURACY, 6]
} }
losthp = battler.totalhp-battler.hp losthp = battler.totalhp - battler.hp
preferFullRestore = (battler.hp<=battler.totalhp*2/3 && preferFullRestore = (battler.hp <= battler.totalhp * 2 / 3 &&
(battler.status!=PBStatuses::NONE || battler.effects[PBEffects::Confusion]>0)) (battler.status != PBStatuses::NONE || battler.effects[PBEffects::Confusion] > 0))
# Find all usable items # Find all usable items
usableHPItems = [] usableHPItems = []
usableStatusItems = [] usableStatusItems = []
usableXItems = [] usableXItems = []
items.each do |i| items.each do |i|
next if !i || i==0 next if !i
next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false) next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false)
next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil, next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil,
false,self,@battle.scene,false) false,self,@battle.scene,false)
checkedItem = false
# Log HP healing items # Log HP healing items
if losthp>0 if losthp > 0
hpItems.each do |item, power| power = hpItems[i]
next if !isConst?(i,PBItems,item) if power
checkedItem = true usableHPItems.push([i, 5, power])
usableHPItems.push([i,5,power]) next
end end
next if checkedItem
end end
# Log Full Restores (HP healer and status curer) # Log Full Restores (HP healer and status curer)
if losthp>0 || battler.status!=PBStatuses::NONE if losthp > 0 || battler.status != PBStatuses::NONE
fullRestoreItems.each do |item| if fullRestoreItems.include?(i)
next if !isConst?(i,PBItems,item) usableHPItems.push([i, (preferFullRestore) ? 3 : 7, 999])
checkedItem = true usableStatusItems.push([i, (preferFullRestore) ? 3 : 9])
usableHPItems.push([i,(preferFullRestore) ? 3 : 7,999]) next
usableStatusItems.push([i,(preferFullRestore) ? 3 : 9])
end end
next if checkedItem
end end
# Log single status-curing items # Log single status-curing items
if battler.status!=PBStatuses::NONE if oneStatusItems.include?(i)
oneStatusItems.each do |item| usableStatusItems.push([i, 5])
next if !isConst?(i,PBItems,item) next
checkedItem = true end
usableStatusItems.push([i,5]) # Log Full Heal-type items
end if allStatusItems.include?(i)
next if checkedItem usableStatusItems.push([i, 7])
# Log Full Heal-type items next
allStatusItems.each do |item|
next if !isConst?(i,PBItems,item)
checkedItem = true
usableStatusItems.push([i,7])
end
next if checkedItem
end end
# Log stat-raising items # Log stat-raising items
xItems.each do |item, data| if xItems[i]
next if !isConst?(i,PBItems,item) data = xItems[i]
checkedItem = true usableXItems.push([i, battler.stages[data[0]], data[1]])
usableXItems.push([i,battler.stages[data[0]],data[1]]) next
end end
next if checkedItem
end end
# Prioritise using a HP restoration item # Prioritise using a HP restoration item
if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 || 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] } usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
prevItem = nil prevItem = nil
usableHPItems.each do |i| usableHPItems.each do |i|
return i[0],idxTarget if i[2]>=losthp return i[0], idxTarget if i[2]>=losthp
prevItem = i prevItem = i
end end
return prevItem[0],idxTarget return prevItem[0], idxTarget
end end
# Next prioritise using a status-curing item # Next prioritise using a status-curing item
if usableStatusItems.length>0 && pbAIRandom(100)<40 if usableStatusItems.length>0 && pbAIRandom(100)<40
usableStatusItems.sort! { |a,b| a[1]<=>b[1] } usableStatusItems.sort! { |a,b| a[1]<=>b[1] }
return usableStatusItems[0][0],idxTarget return usableStatusItems[0][0], idxTarget
end end
# Next try using an X item # Next try using an X item
if usableXItems.length>0 && pbAIRandom(100)<30 if usableXItems.length>0 && pbAIRandom(100)<30
@@ -172,11 +161,11 @@ class PokeBattle_AI
prevItem = nil prevItem = nil
usableXItems.each do |i| usableXItems.each do |i|
break if prevItem && i[1]>prevItem[1] 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 prevItem = i
end end
return prevItem[0],idxTarget return prevItem[0], idxTarget
end end
return 0 return nil
end end
end end
@@ -1632,7 +1632,7 @@ class PokeBattle_AI
when "095" when "095"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "096" when "096"
score -= 90 if !pbIsBerry?(user.item) || !user.itemActive? score -= 90 if !user.item || !user.item.is_berry? || !user.itemActive?
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "097" when "097"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -2031,12 +2031,12 @@ class PokeBattle_AI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F0" when "0F0"
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
score += 20 if target.item!=0 score += 20 if target.item
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F1" when "0F1"
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
if user.item==0 && target.item!=0 if !user.item && target.item
score += 40 score += 40
else else
score -= 90 score -= 90
@@ -2046,19 +2046,19 @@ class PokeBattle_AI
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F2" when "0F2"
if user.item==0 && target.item==0 if !user.item && !target.item
score -= 90 score -= 90
elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD) elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD)
score -= 90 score -= 90
elsif user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL, elsif user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
:CHOICEBAND,:CHOICESCARF,:CHOICESPECS]) :CHOICEBAND,:CHOICESCARF,:CHOICESPECS])
score += 50 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 score -= 30 if pbGetMoveData(user.lastMoveUsed,MoveData::FUNCTION_CODE)=="0F2" # Trick/Switcheroo
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F3" when "0F3"
if user.item==0 || target.item!=0 if !user.item || target.item
score -= 90 score -= 90
else else
if user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL, if user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL,
@@ -2071,21 +2071,21 @@ class PokeBattle_AI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F4", "0F5" when "0F4", "0F5"
if target.effects[PBEffects::Substitute]==0 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 score += 30
end end
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F6" when "0F6"
if user.recycleItem==0 || user.item!=0 if !user.recycleItem || user.item
score -= 80 score -= 80
elsif user.recycleItem!=0 elsif user.recycleItem
score += 30 score += 30
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0F7" when "0F7"
if user.item==0 || !user.itemActive? || if !user.item || !user.itemActive? ||
user.unlosableItem?(user.item) || pbIsPokeBall?(user.item) user.unlosableItem?(user.item) || user.item.is_poke_ball?
score -= 90 score -= 90
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -2096,7 +2096,7 @@ class PokeBattle_AI
if @battle.field.effects[PBEffects::MagicRoom]>0 if @battle.field.effects[PBEffects::MagicRoom]>0
score -= 90 score -= 90
else else
score += 30 if user.item==0 && target.item!=0 score += 30 if !user.item && target.item
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "0FA" when "0FA"
@@ -186,7 +186,7 @@ class PokeBattle_AI
"098", "099", "09A", "0F7", "113" "098", "099", "09A", "0F7", "113"
baseDmg = move.pbBaseDamage(baseDmg,user,target) baseDmg = move.pbBaseDamage(baseDmg,user,target)
when "086" # Acrobatics when "086" # Acrobatics
baseDmg *= 2 if user.item==0 || user.hasActiveItem?(:FLYINGGEM) baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM)
when "08D" # Gyro Ball when "08D" # Gyro Ball
targetSpeed = pbRoughStat(target,PBStats::SPEED,skill) targetSpeed = pbRoughStat(target,PBStats::SPEED,skill)
userSpeed = pbRoughStat(user,PBStats::SPEED,skill) userSpeed = pbRoughStat(user,PBStats::SPEED,skill)
@@ -197,7 +197,7 @@ class PokeBattle_AI
baseDmg = 71 baseDmg = 71
baseDmg *= 2 if target.inTwoTurnAttack?("0CA") # Dig baseDmg *= 2 if target.inTwoTurnAttack?("0CA") # Dig
when "096" # Natural Gift when "096" # Natural Gift
baseDmg = move.pbNaturalGiftBaseDamage(user.item) baseDmg = move.pbNaturalGiftBaseDamage(user.item_id)
when "09B" # Heavy Slam when "09B" # Heavy Slam
baseDmg = move.pbBaseDamage(baseDmg,user,target) baseDmg = move.pbBaseDamage(baseDmg,user,target)
baseDmg *= 2 if NEWEST_BATTLE_MECHANICS && skill>=PBTrainerAI.mediumSkill && 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 # NOTE: These items aren't suitable for checking at the start of the
# round. # round.
itemBlacklist = [:EXPERTBELT,:LIFEORB] itemBlacklist = [:EXPERTBELT,:LIFEORB]
canCheck = true if !itemBlacklist.include?(user.item_id)
itemBlacklist.each do |i|
next if !isConst?(user.item,PBItems,i)
canCheck = false
break
end
if canCheck
BattleHandlers.triggerDamageCalcUserItem(user.item, BattleHandlers.triggerDamageCalcUserItem(user.item,
user,target,move,multipliers,baseDmg,type) user,target,move,multipliers,baseDmg,type)
end end
@@ -346,7 +340,7 @@ class PokeBattle_AI
if skill>=PBTrainerAI.bestSkill && target.itemActive? if skill>=PBTrainerAI.bestSkill && target.itemActive?
# NOTE: Type-weakening berries aren't suitable for checking at the start # NOTE: Type-weakening berries aren't suitable for checking at the start
# of the round. # of the round.
if !pbIsBerry?(target.item) if !target.item.is_berry?
BattleHandlers.triggerDamageCalcTargetItem(target.item, BattleHandlers.triggerDamageCalcTargetItem(target.item,
user,target,move,multipliers,baseDmg,type) user,target,move,multipliers,baseDmg,type)
end end
@@ -200,7 +200,7 @@ class PokeBattle_Scene
# Start Bag screen # Start Bag screen
itemScene = PokemonBag_Scene.new itemScene = PokemonBag_Scene.new
itemScene.pbStartScene($PokemonBag,true,Proc.new { |item| itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|
useType = pbGetItemData(item,ItemData::BATTLE_USE) useType = GameData::Item.get(item).battle_use
next useType && useType>0 next useType && useType>0
},false) },false)
# Loop while in Bag screen # Loop while in Bag screen
@@ -208,10 +208,11 @@ class PokeBattle_Scene
loop do loop do
# Select an item # Select an item
item = itemScene.pbChooseItem item = itemScene.pbChooseItem
break if item==0 break if !item
# Choose a command for the selected item # Choose a command for the selected item
itemName = PBItems.getName(item) item = GameData::Item.get(item)
useType = pbGetItemData(item,ItemData::BATTLE_USE) itemName = item.name
useType = item.battle_use
cmdUse = -1 cmdUse = -1
commands = [] commands = []
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0 commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
@@ -237,11 +238,11 @@ class PokeBattle_Scene
case useType case useType
when 1, 6 # Use on Pokémon when 1, 6 # Use on Pokémon
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1 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 end
when 3, 8 # Use on battler when 3, 8 # Use on battler
if @battle.pbPlayerBattlerCount==1 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
end end
# Fade out and hide Bag screen # Fade out and hide Bag screen
@@ -276,7 +277,7 @@ class PokeBattle_Scene
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?")) idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
next if idxMove<0 next if idxMove<0
end end
break if yield item, useType, idxPartyRet, idxMove, pkmnScene break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
end end
pkmnScene.pbEndScene pkmnScene.pbEndScene
break if idxParty>=0 break if idxParty>=0
@@ -286,7 +287,7 @@ class PokeBattle_Scene
idxTarget = -1 idxTarget = -1
if @battle.pbOpposingBattlerCount(idxBattler)==1 if @battle.pbOpposingBattlerCount(idxBattler)==1
@battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index } @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 else
wasTargeting = true wasTargeting = true
# Fade out and hide Bag screen # Fade out and hide Bag screen
@@ -297,7 +298,7 @@ class PokeBattle_Scene
tempVisibleSprites["targetWindow"] = true tempVisibleSprites["targetWindow"] = true
idxTarget = pbChooseTarget(idxBattler,PBTargets::Foe,tempVisibleSprites) idxTarget = pbChooseTarget(idxBattler,PBTargets::Foe,tempVisibleSprites)
if idxTarget>=0 if idxTarget>=0
break if yield item, useType, idxTarget, -1, self break if yield item.id, useType, idxTarget, -1, self
end end
# Target invalid/cancelled choosing a target; show the Bag screen again # Target invalid/cancelled choosing a target; show the Bag screen again
wasTargeting = false wasTargeting = false
@@ -305,7 +306,7 @@ class PokeBattle_Scene
itemScene.pbFadeInScene itemScene.pbFadeInScene
end end
when 5, 10 # Use with no target 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
end end
@bagLastPocket = $PokemonBag.lastpocket @bagLastPocket = $PokemonBag.lastpocket
@@ -492,7 +492,7 @@ FINAL_DMG_MULT = 3
def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg) def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
return false if !forced && !battler.canHeal? return false if !forced && !battler.canHeal?
return false if !forced && !battler.pbCanConsumeBerry?(item,false) return false if !forced && !battler.pbCanConsumeBerry?(item,false)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8) amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8)
if amt>0 if amt>0
@@ -515,7 +515,7 @@ end
def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1) def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1)
return false if !forced && !battler.pbCanConsumeBerry?(item) return false if !forced && !battler.pbCanConsumeBerry?(item)
return false if !battler.pbCanRaiseStatStage?(stat,battler) return false if !battler.pbCanRaiseStatStage?(stat,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if forced if forced
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
return battler.pbRaiseStatStage(stat,increment,battler) return battler.pbRaiseStatStage(stat,increment,battler)
@@ -576,7 +576,7 @@ def pbBattleGem(user,type,move,mults,moveType)
# Pledge moves never consume Gems # Pledge moves never consume Gems
return if move.is_a?(PokeBattle_PledgeMove) return if move.is_a?(PokeBattle_PledgeMove)
return if !isConst?(moveType,PBTypes,type) return if !isConst?(moveType,PBTypes,type)
user.effects[PBEffects::GemConsumed] = user.item user.effects[PBEffects::GemConsumed] = user.item_id
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
mults[BASE_DMG_MULT] *= 1.3 mults[BASE_DMG_MULT] *= 1.3
else else
@@ -427,7 +427,7 @@ class PokeBattle_SafariZone
pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name)) pbDisplayPaused(_INTL("Wild {1} appeared!",wildpoke.name))
@scene.pbSafariStart @scene.pbSafariStart
@scene.pbCommonAnimation(PBWeather.animationName(@weather)) @scene.pbCommonAnimation(PBWeather.animationName(@weather))
safariBall = getConst(PBItems,:SAFARIBALL) safariBall = GameData::Item.get(:SAFARIBALL).id
rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesData::RARENESS) rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesData::RARENESS)
catchFactor = (rareness*100)/1275 catchFactor = (rareness*100)/1275
catchFactor = [[catchFactor,3].max,20].min catchFactor = [[catchFactor,3].max,20].min
@@ -36,7 +36,7 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle
def initialize(*arg) def initialize(*arg)
@ballCount = 0 @ballCount = 0
@ballConst = getConst(PBItems,:SPORTBALL) || -1 @ballConst = GameData::Item.get(:SPORTBALL).id
super(*arg) super(*arg)
end end
@@ -50,7 +50,7 @@ BattleHandlers::SpeedCalcAbility.add(:SWIFTSWIM,
BattleHandlers::SpeedCalcAbility.add(:UNBURDEN, BattleHandlers::SpeedCalcAbility.add(:UNBURDEN,
proc { |ability,battler,mult| 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| proc { |ability,user,targets,move,battle|
next if !battle.futureSight next if !battle.futureSight
next if !move.pbDamagingMove? next if !move.pbDamagingMove?
next if user.item>0 next if user.item
next if battle.wildBattle? && user.opposes? next if battle.wildBattle? && user.opposes?
targets.each do |b| targets.each do |b|
next if b.damageState.unaffected || b.damageState.substitute 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) next if b.unlosableItem?(b.item) || user.unlosableItem?(b.item)
battle.pbShowAbilitySplash(user) battle.pbShowAbilitySplash(user)
if b.hasActiveAbility?(:STICKYHOLD) if b.hasActiveAbility?(:STICKYHOLD)
@@ -1689,11 +1689,11 @@ BattleHandlers::UserAbilityEndOfMove.add(:MAGICIAN,
next next
end end
user.item = b.item user.item = b.item
b.item = 0 b.item = nil
b.effects[PBEffects::Unburden] = true 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) user.setInitialItem(user.item)
b.setInitialItem(0) b.setInitialItem(nil)
end end
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis, battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,
@@ -1755,7 +1755,7 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
next if !move.contactMove? next if !move.contactMove?
next if switched.include?(user.index) next if switched.include?(user.index)
next if user.effects[PBEffects::Substitute]>0 || target.damageState.substitute 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) next if user.unlosableItem?(user.item) || target.unlosableItem?(user.item)
battle.pbShowAbilitySplash(target) battle.pbShowAbilitySplash(target)
if user.hasActiveAbility?(:STICKYHOLD) if user.hasActiveAbility?(:STICKYHOLD)
@@ -1768,11 +1768,11 @@ BattleHandlers::TargetAbilityAfterMoveUse.add(:PICKPOCKET,
next next
end end
target.item = user.item target.item = user.item
user.item = 0 user.item = nil
user.effects[PBEffects::Unburden] = true 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) target.setInitialItem(target.item)
user.setInitialItem(0) user.setInitialItem(nil)
end end
battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!",target.pbThis, battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!",target.pbThis,
user.pbThis(true),target.itemName)) user.pbThis(true),target.itemName))
@@ -1998,16 +1998,16 @@ BattleHandlers::EOREffectAbility.add(:SPEEDBOOST,
BattleHandlers::EORGainItemAbility.add(:HARVEST, BattleHandlers::EORGainItemAbility.add(:HARVEST,
proc { |ability,battler,battle| proc { |ability,battler,battle|
next if battler.item>0 next if battler.item
next if battler.recycleItem<=0 || !pbIsBerry?(battler.recycleItem) next if !battler.recycleItem || !GameData::Item.get(battler.recycleItem).is_berry?
curWeather = battle.pbWeather curWeather = battle.pbWeather
if curWeather!=PBWeather::Sun && curWeather!=PBWeather::HarshSun if curWeather!=PBWeather::Sun && curWeather!=PBWeather::HarshSun
next unless battle.pbRandom(100)<50 next unless battle.pbRandom(100)<50
end end
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
battler.item = battler.recycleItem battler.item = battler.recycleItem
battler.setRecycleItem(0) battler.setRecycleItem(nil)
battler.setInitialItem(battler.item) if battler.initialItem==0 battler.setInitialItem(battler.item) if !battler.initialItem
battle.pbDisplay(_INTL("{1} harvested one {2}!",battler.pbThis,battler.itemName)) battle.pbDisplay(_INTL("{1} harvested one {2}!",battler.pbThis,battler.itemName))
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
battler.pbHeldItemTriggerCheck battler.pbHeldItemTriggerCheck
@@ -2016,8 +2016,8 @@ BattleHandlers::EORGainItemAbility.add(:HARVEST,
BattleHandlers::EORGainItemAbility.add(:PICKUP, BattleHandlers::EORGainItemAbility.add(:PICKUP,
proc { |ability,battler,battle| proc { |ability,battler,battle|
next if battler.item>0 next if battler.item
foundItem = 0; fromBattler = nil; use = 0 foundItem = nil; fromBattler = nil; use = 0
battle.eachBattler do |b| battle.eachBattler do |b|
next if b.index==battler.index next if b.index==battler.index
next if b.effects[PBEffects::PickupUse]<=use next if b.effects[PBEffects::PickupUse]<=use
@@ -2025,15 +2025,15 @@ BattleHandlers::EORGainItemAbility.add(:PICKUP,
fromBattler = b fromBattler = b
use = b.effects[PBEffects::PickupUse] use = b.effects[PBEffects::PickupUse]
end end
next if foundItem<=0 next if !foundItem
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
battler.item = foundItem battler.item = foundItem
fromBattler.effects[PBEffects::PickupItem] = 0 fromBattler.effects[PBEffects::PickupItem] = nil
fromBattler.effects[PBEffects::PickupUse] = 0 fromBattler.effects[PBEffects::PickupUse] = 0
fromBattler.setRecycleItem(0) if fromBattler.recycleItem==foundItem fromBattler.setRecycleItem(nil) if fromBattler.recycleItem==foundItem
if battle.wildBattle? && battler.initialItem==0 && fromBattler.initialItem==foundItem if battle.wildBattle? && !battler.initialItem && fromBattler.initialItem==foundItem
battler.setInitialItem(foundItem) battler.setInitialItem(foundItem)
fromBattler.setInitialItem(0) fromBattler.setInitialItem(nil)
end end
battle.pbDisplay(_INTL("{1} found one {2}!",battler.pbThis,battler.itemName)) battle.pbDisplay(_INTL("{1} found one {2}!",battler.pbThis,battler.itemName))
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
@@ -2244,19 +2244,19 @@ BattleHandlers::AbilityOnSwitchIn.add(:FRISK,
next if !battler.pbOwnedByPlayer? next if !battler.pbOwnedByPlayer?
foes = [] foes = []
battle.eachOtherSideBattler(battler.index) do |b| battle.eachOtherSideBattler(battler.index) do |b|
foes.push(b) if b.item>0 foes.push(b) if b.item
end end
if foes.length>0 if foes.length>0
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
foes.each do |b| foes.each do |b|
battle.pbDisplay(_INTL("{1} frisked {2} and found its {3}!", 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 end
else else
foe = foes[battle.pbRandom(foes.length)] foe = foes[battle.pbRandom(foes.length)]
battle.pbDisplay(_INTL("{1} frisked the foe and found one {2}!", battle.pbDisplay(_INTL("{1} frisked the foe and found one {2}!",
battler.pbThis,PBItems.getName(foe.item))) battler.pbThis,foe.itemName))
end end
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
end end
@@ -48,7 +48,7 @@ BattleHandlers::WeightCalcItem.add(:FLOATSTONE,
BattleHandlers::HPHealItem.add(:AGUAVBERRY, BattleHandlers::HPHealItem.add(:AGUAVBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next pbBattleConfusionBerry(battler,battle,item,forced,4, 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| proc { |item,battler,battle,forced|
next false if !battler.canHeal? next false if !battler.canHeal?
next false if !forced && battler.hp>battler.totalhp/2 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 PBDebug.log("[Item triggered] Forced consuming of #{itemName}") if forced
battle.pbCommonAnimation("UseItem",battler) if !forced battle.pbCommonAnimation("UseItem",battler) if !forced
battler.pbRecoverHP(20) battler.pbRecoverHP(20)
@@ -78,7 +78,7 @@ BattleHandlers::HPHealItem.add(:BERRYJUICE,
BattleHandlers::HPHealItem.add(:FIGYBERRY, BattleHandlers::HPHealItem.add(:FIGYBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next pbBattleConfusionBerry(battler,battle,item,forced,0, 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, BattleHandlers::HPHealItem.add(:IAPAPABERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next pbBattleConfusionBerry(battler,battle,item,forced,1, 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 next false if battler.effects[PBEffects::FocusEnergy]>=2
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.effects[PBEffects::FocusEnergy] = 2 battler.effects[PBEffects::FocusEnergy] = 2
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if forced if forced
battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName)) battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName))
else else
@@ -120,7 +120,7 @@ BattleHandlers::HPHealItem.add(:LIECHIBERRY,
BattleHandlers::HPHealItem.add(:MAGOBERRY, BattleHandlers::HPHealItem.add(:MAGOBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next pbBattleConfusionBerry(battler,battle,item,forced,2, 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] next false if !battler.effects[PBEffects::MicleBerry]
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.effects[PBEffects::MicleBerry] = true battler.effects[PBEffects::MicleBerry] = true
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if forced if forced
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis)) 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 next false if !forced && battler.hp>battler.totalhp/2
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(10) battler.pbRecoverHP(10)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if forced if forced
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) 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 next false if !forced && battler.hp>battler.totalhp/2
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(battler.totalhp/4) battler.pbRecoverHP(battler.totalhp/4)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if forced if forced
PBDebug.log("[Item triggered] Forced consuming of #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
@@ -203,7 +203,7 @@ BattleHandlers::HPHealItem.add(:STARFBERRY,
BattleHandlers::HPHealItem.add(:WIKIBERRY, BattleHandlers::HPHealItem.add(:WIKIBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next pbBattleConfusionBerry(battler,battle,item,forced,3, 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| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status!=PBStatuses::FROZEN 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced) battler.pbCureStatus(forced)
@@ -228,7 +228,7 @@ BattleHandlers::StatusCureItem.add(:CHERIBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status!=PBStatuses::PARALYSIS 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced) battler.pbCureStatus(forced)
@@ -241,7 +241,7 @@ BattleHandlers::StatusCureItem.add(:CHESTOBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status!=PBStatuses::SLEEP 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced) battler.pbCureStatus(forced)
@@ -255,7 +255,7 @@ BattleHandlers::StatusCureItem.add(:LUMBERRY,
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status==PBStatuses::NONE && next false if battler.status==PBStatuses::NONE &&
battler.effects[PBEffects::Confusion]==0 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
oldStatus = battler.status oldStatus = battler.status
@@ -293,7 +293,7 @@ BattleHandlers::StatusCureItem.add(:MENTALHERB,
!battler.effects[PBEffects::Torment] && !battler.effects[PBEffects::Torment] &&
battler.effects[PBEffects::Disable]==0 && battler.effects[PBEffects::Disable]==0 &&
battler.effects[PBEffects::HealBlock]==0 battler.effects[PBEffects::HealBlock]==0
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}")
battle.pbCommonAnimation("UseItem",battler) if !forced battle.pbCommonAnimation("UseItem",battler) if !forced
if battler.effects[PBEffects::Attract]>=0 if battler.effects[PBEffects::Attract]>=0
@@ -324,7 +324,7 @@ BattleHandlers::StatusCureItem.add(:PECHABERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status!=PBStatuses::POISON 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced) battler.pbCureStatus(forced)
@@ -337,7 +337,7 @@ BattleHandlers::StatusCureItem.add(:PERSIMBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.effects[PBEffects::Confusion]==0 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureConfusion battler.pbCureConfusion
@@ -355,7 +355,7 @@ BattleHandlers::StatusCureItem.add(:RAWSTBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if battler.status!=PBStatuses::BURN 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbCureStatus(forced) battler.pbCureStatus(forced)
@@ -1124,14 +1124,14 @@ BattleHandlers::TargetItemOnHit.add(:SNOWBALL,
BattleHandlers::TargetItemOnHit.add(:STICKYBARB, BattleHandlers::TargetItemOnHit.add(:STICKYBARB,
proc { |item,user,target,move,battle| proc { |item,user,target,move,battle|
next if !move.pbContactMove?(user) || !user.affectedByContactEffect? next if !move.pbContactMove?(user) || !user.affectedByContactEffect?
next if user.fainted? || user.item>0 next if user.fainted? || user.item
user.item = target.item user.item = target.item
target.item = 0 target.item = nil
target.effects[PBEffects::Unburden] = true target.effects[PBEffects::Unburden] = true
if battle.wildBattle? && !user.opposes? if battle.wildBattle? && !user.opposes?
if user.initialItem==0 && target.initialItem==user.item if !user.initialItem && target.initialItem==user.item
user.setInitialItem(user.item) user.setInitialItem(user.item)
target.setInitialItem(0) target.setInitialItem(nil)
end end
end end
battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!", battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!",
@@ -1168,7 +1168,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:ENIGMABERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !battler.canHeal? next false if !battler.canHeal?
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(battler.totalhp/4) battler.pbRecoverHP(battler.totalhp/4)
@@ -1186,7 +1186,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:KEEBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if !forced if !forced
battle.pbCommonAnimation("EatBerry",battler) battle.pbCommonAnimation("EatBerry",battler)
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
@@ -1200,7 +1200,7 @@ BattleHandlers::TargetItemOnHitPositiveBerry.add(:MARANGABERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
if !forced if !forced
battle.pbCommonAnimation("EatBerry",battler) battle.pbCommonAnimation("EatBerry",battler)
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
@@ -1294,7 +1294,7 @@ BattleHandlers::EndOfMoveItem.add(:LEPPABERRY,
found.push(i) found.push(i)
end end
next false if found.length==0 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 PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
choice = found[battle.pbRandom(found.length)] choice = found[battle.pbRandom(found.length)]
@@ -1325,7 +1325,7 @@ BattleHandlers::EndOfMoveStatRestoreItem.add(:WHITEHERB,
reducedStats = true reducedStats = true
end end
next false if !reducedStats next false if !reducedStats
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced
battle.pbCommonAnimation("UseItem",battler) if !forced battle.pbCommonAnimation("UseItem",battler) if !forced
if forced if forced
@@ -1440,7 +1440,7 @@ BattleHandlers::TerrainStatBoostItem.add(:ELECTRICSEED,
proc { |item,battler,battle| proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Electric next false if battle.field.terrain!=PBBattleTerrains::Electric
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler) battle.pbCommonAnimation("UseItem",battler)
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
} }
@@ -1450,7 +1450,7 @@ BattleHandlers::TerrainStatBoostItem.add(:GRASSYSEED,
proc { |item,battler,battle| proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Grassy next false if battle.field.terrain!=PBBattleTerrains::Grassy
next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::DEFENSE,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler) battle.pbCommonAnimation("UseItem",battler)
next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::DEFENSE,1,battler,itemName)
} }
@@ -1460,7 +1460,7 @@ BattleHandlers::TerrainStatBoostItem.add(:MISTYSEED,
proc { |item,battler,battle| proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Misty next false if battle.field.terrain!=PBBattleTerrains::Misty
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler) battle.pbCommonAnimation("UseItem",battler)
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
} }
@@ -1470,7 +1470,7 @@ BattleHandlers::TerrainStatBoostItem.add(:PSYCHICSEED,
proc { |item,battler,battle| proc { |item,battler,battle|
next false if battle.field.terrain!=PBBattleTerrains::Psychic next false if battle.field.terrain!=PBBattleTerrains::Psychic
next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::SPDEF,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler) battle.pbCommonAnimation("UseItem",battler)
next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::SPDEF,1,battler,itemName)
} }
@@ -1577,7 +1577,7 @@ BattleHandlers::ItemOnSwitchIn.add(:AIRBALLOON,
BattleHandlers::ItemOnIntimidated.add(:ADRENALINEORB, BattleHandlers::ItemOnIntimidated.add(:ADRENALINEORB,
proc { |item,battler,battle| proc { |item,battler,battle|
next false if !battler.pbCanRaiseStatStage?(PBStats::SPEED,battler) next false if !battler.pbCanRaiseStatStage?(PBStats::SPEED,battler)
itemName = PBItems.getName(item) itemName = GameData::Item.get(item).name
battle.pbCommonAnimation("UseItem",battler) battle.pbCommonAnimation("UseItem",battler)
next battler.pbRaiseStatStageByCause(PBStats::SPEED,1,battler,itemName) next battler.pbRaiseStatStageByCause(PBStats::SPEED,1,battler,itemName)
} }
@@ -27,22 +27,18 @@ $BallTypes = {
25 => :BEASTBALL 25 => :BEASTBALL
} }
def pbBallTypeToItem(balltype) def pbBallTypeToItem(ball_type)
if $BallTypes[balltype] ret = GameData::Item.try_get($BallTypes[ball_type])
ret = getID(PBItems,$BallTypes[balltype]) return ret if ret
return ret if ret!=0 ret = GameData::Item.try_get($BallTypes[0])
end return ret if ret
if $BallTypes[0] return GameData::Item.get(:POKEBALL)
ret = getID(PBItems,$BallTypes[0])
return ret if ret!=0
end
return getID(PBItems,:POKEBALL)
end end
def pbGetBallType(ball) def pbGetBallType(ball)
ball = getID(PBItems,ball) ball = GameData::Item.try_get(ball)
$BallTypes.keys.each do |key| $BallTypes.keys.each do |key|
return key if isConst?(ball,PBItems,$BallTypes[key]) return key if ball == $BallTypes[key]
end end
return 0 return 0
end 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 # 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 # family can evolve with the Moon Stone, not whether the target itself
# can immediately evolve with the Moon Stone. # can immediately evolve with the Moon Stone.
if hasConst?(PBItems,:MOONSTONE) && moon_stone = GameData::Item.try_get(:MOONSTONE)
pbCheckEvolutionFamilyForItemMethodItem(battler.species,getConst(PBItems,:MOONSTONE)) if moon_stone && pbCheckEvolutionFamilyForItemMethodItem(battler.species, moon_stone.id)
catchRate *= 4 catchRate *= 4
end end
next [catchRate,255].min next [catchRate,255].min
+22 -20
View File
@@ -325,7 +325,7 @@ Events.onStepTakenFieldMovement += proc { |_sender,e|
break break
end end
end end
if sootlevel>=0 && hasConst?(PBItems,:SOOTSACK) if sootlevel>=0 && GameData::Item.exists?(:SOOTSACK)
$PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack $PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack
# map.data[thistile[1],thistile[2],sootlevel]=0 # map.data[thistile[1],thistile[2],sootlevel]=0
if event==$game_player && $PokemonBag.pbHasItem?(:SOOTSACK) if event==$game_player && $PokemonBag.pbHasItem?(:SOOTSACK)
@@ -1322,16 +1322,17 @@ end
# Picking up an item found on the ground # Picking up an item found on the ground
#=============================================================================== #===============================================================================
def pbItemBall(item,quantity=1) def pbItemBall(item,quantity=1)
item = getID(PBItems,item) item = GameData::Item.get(item)
return false if !item || item<=0 || quantity<1 return false if !item || quantity<1
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) itemname = (quantity>1) ? item.name_plural : item.name
pocket = pbGetPocket(item) pocket = item.pocket
move = item.move
if $PokemonBag.pbStoreItem(item,quantity) # If item can be picked up if $PokemonBag.pbStoreItem(item,quantity) # If item can be picked up
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get" meName = (item.is_key_item?) ? "Key item get" : "Item get"
if isConst?(item,PBItems,:LEFTOVERS) if item == :LEFTOVERS
pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
elsif pbIsMachine?(item) # TM or HM 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(pbGetMachine(item)))) pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move)))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -1344,10 +1345,10 @@ def pbItemBall(item,quantity=1)
return true return true
end end
# Can't add the item # 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)) pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
elsif pbIsMachine?(item) # TM or HM elsif item.is_machine? # TM or HM
pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(pbGetMachine(item)))) pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(move)))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname)) pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -1365,15 +1366,16 @@ end
# Being given an item # Being given an item
#=============================================================================== #===============================================================================
def pbReceiveItem(item,quantity=1) def pbReceiveItem(item,quantity=1)
item = getID(PBItems,item) item = GameData::Item.get(item)
return false if !item || item<=0 || quantity<1 return false if !item || quantity<1
itemname = (quantity>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) itemname = (quantity>1) ? item.name_plural : item.name
pocket = pbGetPocket(item) pocket = item.pocket
meName = (pbIsKeyItem?(item)) ? "Key item get" : "Item get" move = item.move
if isConst?(item,PBItems,:LEFTOVERS) 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)) pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname))
elsif pbIsMachine?(item) # TM or HM 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(pbGetMachine(item)))) pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,PBMoves.getName(move)))
elsif quantity>1 elsif quantity>1
pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -596,8 +596,7 @@ end
def pbDynamicItemList(*args) def pbDynamicItemList(*args)
ret = [] ret = []
for i in 0...args.length for i in 0...args.length
next if !hasConst?(PBItems,args[i]) ret.push(i) if GameData::Item.exists?(args[i])
ret.push(getConst(PBItems,args[i].to_sym))
end end
return ret return ret
end end
@@ -674,7 +673,7 @@ end
def pbHoneyGather(pkmn) def pbHoneyGather(pkmn)
return if pkmn.egg? || !pkmn.hasAbility?(:HONEYGATHER) return if pkmn.egg? || !pkmn.hasAbility?(:HONEYGATHER)
return if pkmn.hasItem? return if pkmn.hasItem?
return if !hasConst?(PBItems,:HONEY) return if !GameData::Item.exists?(:HONEY)
chance = 5+((pkmn.level-1)/10)*5 chance = 5+((pkmn.level-1)/10)*5
return unless rand(100)<chance return unless rand(100)<chance
pkmn.setItem(:HONEY) pkmn.setItem(:HONEY)
@@ -338,9 +338,10 @@ class PokemonEncounters
end end
firstPkmn = $Trainer.firstPokemon firstPkmn = $Trainer.firstPokemon
if firstPkmn if firstPkmn
if firstPkmn.hasItem?(:CLEANSETAG) case firstPkmn.item_id
when :CLEANSETAG
encount *= 2.0 / 3 encount *= 2.0 / 3
elsif firstPkmn.hasItem?(:PUREINCENSE) when :PUREINCENSE
encount *= 2.0 / 3 encount *= 2.0 / 3
else # Ignore ability effects if an item effect applies else # Ignore ability effects if an item effect applies
case firstPkmn.ability_id case firstPkmn.ability_id
@@ -411,7 +412,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
genwildpoke.setItem(items[2]) genwildpoke.setItem(items[2])
end end
# Shiny Charm makes shiny Pokémon more likely to generate # 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 2.times do # 3 times as likely
break if genwildpoke.shiny? break if genwildpoke.shiny?
genwildpoke.personalID = rand(65536)|(rand(65536)<<16) genwildpoke.personalID = rand(65536)|(rand(65536)<<16)
@@ -10,7 +10,7 @@ def pbLoadBerryPlantData
if pbRgssExists?("Data/berry_plants.dat") if pbRgssExists?("Data/berry_plants.dat")
$PokemonTemp.berryPlantData = load_data("Data/berry_plants.dat") $PokemonTemp.berryPlantData = load_data("Data/berry_plants.dat")
else else
$PokemonTemp.berryPlantData = [] $PokemonTemp.berryPlantData = {}
end end
end end
return $PokemonTemp.berryPlantData return $PokemonTemp.berryPlantData
@@ -19,7 +19,7 @@ end
def pbGetBerryPlantData(item) def pbGetBerryPlantData(item)
data = pbLoadBerryPlantData data = pbLoadBerryPlantData
return data[item] if data[item] 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 end
alias __berryPlant__pbClearData pbClearData alias __berryPlant__pbClearData pbClearData
@@ -77,7 +77,7 @@ class BerryPlantMoistureSprite
def update def update
return if !@light || !@event return if !@light || !@event
newmoisture=-1 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 # Berry was planted, show moisture patch
newmoisture=(@event.variable[4]>50) ? 2 : (@event.variable[4]>0) ? 1 : 0 newmoisture=(@event.variable[4]>50) ? 2 : (@event.variable[4]>0) ? 1 : 0
end end
@@ -153,16 +153,17 @@ class BerryPlantSprite
dryingrate=berryvalues[1] dryingrate=berryvalues[1]
maxreplants=REPLANTS maxreplants=REPLANTS
ripestages=4 ripestages=4
if isConst?(berryData[7],PBItems,:GROWTHMULCH) case berryData[7]
timeperstage=(timeperstage*0.75).to_i when :GROWTHMULCH
dryingrate=(dryingrate*1.5).ceil timeperstage = (timeperstage * 0.75).to_i
elsif isConst?(berryData[7],PBItems,:DAMPMULCH) dryingrate = (dryingrate * 1.5).ceil
timeperstage=(timeperstage*1.25).to_i when :DAMPMULCH
dryingrate=(dryingrate*0.5).floor timeperstage = (timeperstage * 1.25).to_i
elsif isConst?(berryData[7],PBItems,:GOOEYMULCH) dryingrate = (dryingrate * 0.5).floor
maxreplants=(maxreplants*1.5).ceil when :GOOEYMULCH
elsif isConst?(berryData[7],PBItems,:STABLEMULCH) maxreplants = (maxreplants * 1.5).ceil
ripestages=6 when :STABLEMULCH
ripestages = 6
end end
# Cycle through all replants since last check # Cycle through all replants since last check
loop do loop do
@@ -281,8 +282,10 @@ class BerryPlantSprite
@event.character_name="berrytreeplanted" # Common to all berries @event.character_name="berrytreeplanted" # Common to all berries
@event.turn_down @event.turn_down
else else
filename=sprintf("berrytree%s",getConstantName(PBItems,berryData[1])) rescue nil filename=sprintf("berrytree%s",GameData::Item.get(berryData[1]).id.to_s) rescue nil
filename=sprintf("berrytree%03d",berryData[1]) if !pbResolveBitmap("Graphics/Characters/"+filename) if !pbResolveBitmap("Graphics/Characters/"+filename)
filename=sprintf("berrytree%03d",GameData::Item.get(berryData[1]).id_number)
end
if pbResolveBitmap("Graphics/Characters/"+filename) if pbResolveBitmap("Graphics/Characters/"+filename)
@event.character_name=filename @event.character_name=filename
case berryData[0] case berryData[0]
@@ -310,9 +313,9 @@ def pbBerryPlant
berryData=interp.getVariable berryData=interp.getVariable
if !berryData if !berryData
if NEW_BERRY_PLANTS if NEW_BERRY_PLANTS
berryData=[0,0,0,0,0,0,0,0] berryData=[0,nil,0,0,0,0,0,0]
else else
berryData=[0,0,false,0,0,0] berryData=[0,nil,false,0,0,0]
end end
end end
# Stop the event turning towards the player # Stop the event turning towards the player
@@ -323,12 +326,7 @@ def pbBerryPlant
when 4; thisEvent.turn_right # X flowering when 4; thisEvent.turn_right # X flowering
when 5; thisEvent.turn_up # X berries when 5; thisEvent.turn_up # X berries
end end
watering=[] watering = [:SPRAYDUCK, :SQUIRTBOTTLE, :WAILMERPAIL, :SPRINKLOTAD]
watering.push(getConst(PBItems,:SPRAYDUCK))
watering.push(getConst(PBItems,:SQUIRTBOTTLE))
watering.push(getConst(PBItems,:WAILMERPAIL))
watering.push(getConst(PBItems,:SPRINKLOTAD))
watering.compact!
berry=berryData[1] berry=berryData[1]
case berryData[0] case berryData[0]
when 0 # empty when 0 # empty
@@ -344,19 +342,19 @@ def pbBerryPlant
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 ret
if pbIsMulch?(ret) if GameData::Item.get(ret).is_mulch?
berryData[7]=ret 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?")) if pbConfirmMessage(_INTL("Want to plant a Berry?"))
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 timenow=pbGetTimeNow
berryData[0]=1 # growth stage (1-5) berryData[0]=1 # growth stage (1-5)
berryData[1]=berry # item ID of planted berry berryData[1]=berry # item ID of planted berry
@@ -367,7 +365,7 @@ def pbBerryPlant
berryData[6]=0 # yield penalty berryData[6]=0 # yield penalty
$PokemonBag.pbDeleteItem(berry,1) $PokemonBag.pbDeleteItem(berry,1)
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.", pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
PBItems.getName(berry))) GameData::Item.get(berry).name))
end end
end end
interp.setVariable(berryData) interp.setVariable(berryData)
@@ -380,9 +378,9 @@ def pbBerryPlant
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 timenow=pbGetTimeNow
berryData[0]=1 # growth stage (1-5) berryData[0]=1 # growth stage (1-5)
berryData[1]=berry # item ID of planted berry berryData[1]=berry # item ID of planted berry
@@ -393,20 +391,20 @@ def pbBerryPlant
berryData[6]=0 # yield penalty berryData[6]=0 # yield penalty
$PokemonBag.pbDeleteItem(berry,1) $PokemonBag.pbDeleteItem(berry,1)
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.", pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
PBItems.getName(berry))) GameData::Item.get(berry).name))
interp.setVariable(berryData) interp.setVariable(berryData)
end end
return return
end end
else 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?")) if pbConfirmMessage(_INTL("Want to plant a Berry?"))
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 timenow=pbGetTimeNow
berryData[0]=1 # growth stage (1-5) berryData[0]=1 # growth stage (1-5)
berryData[1]=berry # item ID of planted berry berryData[1]=berry # item ID of planted berry
@@ -417,7 +415,7 @@ def pbBerryPlant
berryData[6]=0 # yield penalty berryData[6]=0 # yield penalty
$PokemonBag.pbDeleteItem(berry,1) $PokemonBag.pbDeleteItem(berry,1)
pbMessage(_INTL("The {1} was planted in the soft, earthy soil.", pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
PBItems.getName(berry))) GameData::Item.get(berry).name))
interp.setVariable(berryData) interp.setVariable(berryData)
end end
return return
@@ -429,9 +427,9 @@ def pbBerryPlant
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 timenow=pbGetTimeNow
berryData[0]=1 # growth stage (1-5) berryData[0]=1 # growth stage (1-5)
berryData[1]=berry # item ID of planted berry berryData[1]=berry # item ID of planted berry
@@ -442,33 +440,33 @@ def pbBerryPlant
berryData[6]=nil; berryData[7]=nil; berryData.compact! # for compatibility berryData[6]=nil; berryData[7]=nil; berryData.compact! # for compatibility
$PokemonBag.pbDeleteItem(berry,1) $PokemonBag.pbDeleteItem(berry,1)
pbMessage(_INTL("{1} planted a {2} in the soft loamy soil.", 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) interp.setVariable(berryData)
end end
return return
end end
end end
when 1 # X planted 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 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 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 when 4 # X flowering
if NEW_BERRY_PLANTS 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 else
case berryData[4] case berryData[4]
when 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 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 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 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 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
end end
when 5 # X berries when 5 # X berries
@@ -487,7 +485,9 @@ def pbBerryPlant
berrycount=berryvalues[2] berrycount=berryvalues[2]
end end
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 if berrycount>1
message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",berrycount,itemname) message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",berrycount,itemname)
else else
@@ -504,15 +504,14 @@ def pbBerryPlant
else else
pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname)) pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname))
end 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", 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])) $Trainer.name,itemname,pocket,PokemonBag.pocketNames()[pocket]))
if NEW_BERRY_PLANTS if NEW_BERRY_PLANTS
pbMessage(_INTL("The soil returned to its soft and earthy state.")) 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 else
pbMessage(_INTL("The soil returned to its soft and loamy state.")) 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 end
interp.setVariable(berryData) interp.setVariable(berryData)
end end
@@ -520,38 +519,37 @@ def pbBerryPlant
case berryData[0] case berryData[0]
when 1, 2, 3, 4 when 1, 2, 3, 4
for i in watering for i in watering
if i!=0 && $PokemonBag.pbHasItem?(i) next if !GameData::Item.exists?(i) || !$PokemonBag.pbHasItem?(i)
if pbConfirmMessage(_INTL("Want to sprinkle some water with the {1}?",PBItems.getName(i))) if pbConfirmMessage(_INTL("Want to sprinkle some water with the {1}?",GameData::Item.get(i).name))
if berryData.length>6 if berryData.length>6
# Gen 4 berry watering mechanics # Gen 4 berry watering mechanics
berryData[4]=100 berryData[4]=100
else else
# Gen 3 berry watering mechanics # Gen 3 berry watering mechanics
if berryData[2]==false if berryData[2]==false
berryData[4]+=1 berryData[4]+=1
berryData[2]=true 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."))
end end
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 end
break
end end
end end
end end
def pbPickBerry(berry,qty=1) def pbPickBerry(berry, qty = 1)
interp=pbMapInterpreter interp=pbMapInterpreter
thisEvent=interp.get_character(0) thisEvent=interp.get_character(0)
berryData=interp.getVariable berryData=interp.getVariable
berry=getID(PBItems,berry) berry=GameData::Item.get(berry)
itemname=(qty>1) ? PBItems.getNamePlural(berry) : PBItems.getName(berry) itemname=(qty>1) ? berry.name_plural : berry.name
if qty>1 if qty>1
message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",qty,itemname) message=_INTL("There are {1} \\c[1]{2}\\c[0]!\nWant to pick them?",qty,itemname)
else else
@@ -568,15 +566,15 @@ def pbPickBerry(berry,qty=1)
else else
pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname)) pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]",itemname))
end 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", 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])) $Trainer.name,itemname,pocket,PokemonBag.pocketNames()[pocket]))
if NEW_BERRY_PLANTS if NEW_BERRY_PLANTS
pbMessage(_INTL("The soil returned to its soft and earthy state.")) 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 else
pbMessage(_INTL("The soil returned to its soft and loamy state.")) 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 end
interp.setVariable(berryData) interp.setVariable(berryData)
pbSetSelfSwitch(thisEvent.id,"A",true) pbSetSelfSwitch(thisEvent.id,"A",true)
@@ -192,7 +192,7 @@ def pbDayCareGenerateEgg
father = pokemon0 father = pokemon0
end end
# Determine the egg's species # 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) if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
babyspecies = getConst(PBSpecies,:PHIONE) babyspecies = getConst(PBSpecies,:PHIONE)
elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) || elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) ||
@@ -233,7 +233,7 @@ def pbDayCareGenerateEgg
isConst?(babyspecies,PBSpecies,:GRIMER) isConst?(babyspecies,PBSpecies,:GRIMER)
if mother.form==1 if mother.form==1
egg.form = 1 if mother.hasItem?(:EVERSTONE) 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) egg.form = 1 if father.form==1 && father.hasItem?(:EVERSTONE)
end end
end end
@@ -260,11 +260,9 @@ def pbDayCareGenerateEgg
end end
# Inheriting Machine Moves # Inheriting Machine Moves
if !NEWEST_BATTLE_MECHANICS if !NEWEST_BATTLE_MECHANICS
itemsData = pbLoadItemsData GameData::Item.each do |i|
for i in 0...itemsData.length atk = i.move
next if !itemsData[i] next if !atk
atk = itemsData[i][ItemData::MOVE]
next if !atk || atk==0
next if !egg.compatibleWithMove?(atk) next if !egg.compatibleWithMove?(atk)
next if !movefather.hasMove?(atk) next if !movefather.hasMove?(atk)
moves.push(atk) moves.push(atk)
@@ -351,7 +349,7 @@ def pbDayCareGenerateEgg
# Masuda method and Shiny Charm # Masuda method and Shiny Charm
shinyretries = 0 shinyretries = 0
shinyretries += 5 if father.owner.language != mother.owner.language 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 if shinyretries>0
shinyretries.times do shinyretries.times do
break if egg.shiny? break if egg.shiny?
@@ -377,8 +375,7 @@ def pbDayCareGenerateEgg
end end
# Inheriting Poké Ball from the mother # Inheriting Poké Ball from the mother
if mother.female? && if mother.female? &&
!isConst?(pbBallTypeToItem(mother.ballused),PBItems,:MASTERBALL) && ![:MASTERBALL, :CHERISHBALL].include?(pbBallTypeToItem(mother.ballused).id)
!isConst?(pbBallTypeToItem(mother.ballused),PBItems,:CHERISHBALL)
egg.ballused = mother.ballused egg.ballused = mother.ballused
end end
# Set all stats # Set all stats
@@ -417,7 +414,7 @@ Events.onStepTaken += proc { |_sender,_e|
if $PokemonGlobal.daycareEggSteps==256 if $PokemonGlobal.daycareEggSteps==256
$PokemonGlobal.daycareEggSteps = 0 $PokemonGlobal.daycareEggSteps = 0
compatval = [0,20,50,70][pbDayCareGetCompat] 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] compatval = [0,40,80,88][pbDayCareGetCompat]
end end
$PokemonGlobal.daycareEgg = 1 if rand(100)<compatval # Egg is generated $PokemonGlobal.daycareEgg = 1 if rand(100)<compatval # Egg is generated
@@ -20,10 +20,10 @@ module TrainerData
LOSETEXT = 15 LOSETEXT = 15
SCHEMA = { SCHEMA = {
"Items" => [0, "eEEEEEEE", :PBItems, :PBItems, :PBItems, :PBItems, "Items" => [0, "eEEEEEEE", :Item, :Item, :Item, :Item,
:PBItems, :PBItems, :PBItems, :PBItems], :Item, :Item, :Item, :Item],
"Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level "Pokemon" => [SPECIES, "ev", :PBSpecies, nil], # Species, level
"Item" => [ITEM, "e", :PBItems], "Item" => [ITEM, "e", :Item],
"Moves" => [MOVES, "eEEE", :PBMoves, :PBMoves, :PBMoves, :PBMoves], "Moves" => [MOVES, "eEEE", :PBMoves, :PBMoves, :PBMoves, :PBMoves],
"Ability" => [ABILITY, "u"], "Ability" => [ABILITY, "u"],
"Gender" => [GENDER, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0, "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.forcedForm = poke[TrainerData::FORM] if MultipleForms.hasFunction?(pokemon.species,"getForm")
pokemon.formSimple = poke[TrainerData::FORM] pokemon.formSimple = poke[TrainerData::FORM]
end end
pokemon.setItem(poke[TrainerData::ITEM]) if poke[TrainerData::ITEM] pokemon.setItem(poke[TrainerData::ITEM])
if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0 if poke[TrainerData::MOVES] && poke[TrainerData::MOVES].length>0
for move in poke[TrainerData::MOVES] for move in poke[TrainerData::MOVES]
pokemon.pbLearnMove(move) pokemon.pbLearnMove(move)
+65 -275
View File
@@ -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 # 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 # Change a Pokémon's level
#=============================================================================== #===============================================================================
@@ -680,32 +469,34 @@ end
#=============================================================================== #===============================================================================
# Use an item from the Bag and/or on a Pokémon # 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) def pbUseItem(bag,item,bagscene=nil)
useType = pbGetItemData(item,ItemData::FIELD_USE) itm = GameData::Item.get(item)
if pbIsMachine?(item) # TM or HM useType = itm.field_use
if itm.is_machine? # TM or HM
if $Trainer.pokemonCount==0 if $Trainer.pokemonCount==0
pbMessage(_INTL("There is no Pokémon.")) pbMessage(_INTL("There is no Pokémon."))
return 0 return 0
end end
machine = pbGetMachine(item) machine = itm.move
return 0 if machine==nil return 0 if !machine
movename = PBMoves.getName(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)) if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename))
return 0 return 0
elsif pbMoveTutorChoose(machine,nil,true) elsif pbMoveTutorChoose(machine,nil,true)
bag.pbDeleteItem(item) if pbIsTechnicalMachine?(item) && !INFINITE_TMS bag.pbDeleteItem(item) if itm.is_TM? && !INFINITE_TMS
return 1 return 1
end end
return 0 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 if $Trainer.pokemonCount==0
pbMessage(_INTL("There is no Pokémon.")) pbMessage(_INTL("There is no Pokémon."))
return 0 return 0
end end
ret = false ret = false
annot = nil annot = nil
if pbIsEvolutionStone?(item) if itm.is_evolution_stone?
annot = [] annot = []
for pkmn in $Trainer.party for pkmn in $Trainer.party
elig = pbCheckEvolution(pkmn,item)>0 elig = pbCheckEvolution(pkmn,item)>0
@@ -729,7 +520,7 @@ def pbUseItem(bag,item,bagscene=nil)
if ret && useType==1 # Usable on Pokémon, consumed if ret && useType==1 # Usable on Pokémon, consumed
bag.pbDeleteItem(item) bag.pbDeleteItem(item)
if !bag.pbHasItem?(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 break
end end
end end
@@ -739,7 +530,7 @@ def pbUseItem(bag,item,bagscene=nil)
bagscene.pbRefresh if bagscene bagscene.pbRefresh if bagscene
} }
return (ret) ? 1 : 0 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) intret = ItemHandlers.triggerUseFromBag(item)
case intret case intret
when 0; return 0 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 # Only called when in the party screen and having chosen an item to be used on
# the selected Pokémon # the selected Pokémon
def pbUseItemOnPokemon(item,pkmn,scene) def pbUseItemOnPokemon(item,pkmn,scene)
itm = GameData::Item.get(item)
# TM or HM # TM or HM
if pbIsMachine?(item) if itm.is_machine?
machine = pbGetMachine(item) machine = itm.move
return false if machine==nil return false if !machine
movename = PBMoves.getName(machine) movename = PBMoves.getName(machine)
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate } pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate }
elsif !pkmn.compatibleWithMove?(machine) elsif !pkmn.compatibleWithMove?(machine)
pbMessage(_INTL("{1} can't learn {2}.",pkmn.name,movename)) { scene.pbUpdate } pbMessage(_INTL("{1} can't learn {2}.",pkmn.name,movename)) { scene.pbUpdate }
else 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 pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?",movename,pkmn.name)) { scene.pbUpdate }
if pbLearnMove(pkmn,machine,false,true) { 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 return true
end end
end end
@@ -782,11 +574,11 @@ def pbUseItemOnPokemon(item,pkmn,scene)
ret = ItemHandlers.triggerUseOnPokemon(item,pkmn,scene) ret = ItemHandlers.triggerUseOnPokemon(item,pkmn,scene)
scene.pbClearAnnotations scene.pbClearAnnotations
scene.pbHardRefresh scene.pbHardRefresh
useType = pbGetItemData(item,ItemData::FIELD_USE) useType = itm.field_use
if ret && useType && useType==1 # Usable on Pokémon, consumed if ret && useType==1 # Usable on Pokémon, consumed
$PokemonBag.pbDeleteItem(item) $PokemonBag.pbDeleteItem(item)
if !$PokemonBag.pbHasItem?(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
end end
return ret return ret
@@ -803,7 +595,7 @@ def pbUseKeyItemInField(item)
end end
def pbUseItemMessage(item) def pbUseItemMessage(item)
itemname = PBItems.getName(item) itemname = GameData::Item.get(item).name
if itemname.starts_with_vowel? if itemname.starts_with_vowel?
pbMessage(_INTL("You used an {1}.",itemname)) pbMessage(_INTL("You used an {1}.",itemname))
else else
@@ -819,7 +611,7 @@ end
# Give an item to a Pokémon to hold, and take a held item from a Pokémon # 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) def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
newitemname = PBItems.getName(item) newitemname = GameData::Item.get(item).name
if pkmn.egg? if pkmn.egg?
scene.pbDisplay(_INTL("Eggs can't hold items.")) scene.pbDisplay(_INTL("Eggs can't hold items."))
return false return false
@@ -828,7 +620,7 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
return false if !pbTakeItemFromPokemon(pkmn,scene) return false if !pbTakeItemFromPokemon(pkmn,scene)
end end
if pkmn.hasItem? if pkmn.hasItem?
olditemname = PBItems.getName(pkmn.item) olditemname = pkmn.item.name
if pkmn.hasItem?(:LEFTOVERS) if pkmn.hasItem?(:LEFTOVERS)
scene.pbDisplay(_INTL("{1} is already holding some {2}.\1",pkmn.name,olditemname)) scene.pbDisplay(_INTL("{1} is already holding some {2}.\1",pkmn.name,olditemname))
elsif newitemname.starts_with_vowel? elsif newitemname.starts_with_vowel?
@@ -844,7 +636,7 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid=0)
end end
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed."))
else else
if pbIsMail?(item) if GameData::Item.get(item).is_mail?
if pbWriteMail(item,pkmn,pkmnid,scene) if pbWriteMail(item,pkmn,pkmnid,scene)
pkmn.setItem(item) pkmn.setItem(item)
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pkmn.name,newitemname)) 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
end end
else else
if !pbIsMail?(item) || pbWriteMail(item,pkmn,pkmnid,scene) if !GameData::Item.get(item).is_mail? || pbWriteMail(item,pkmn,pkmnid,scene)
$PokemonBag.pbDeleteItem(item) $PokemonBag.pbDeleteItem(item)
pkmn.setItem(item) pkmn.setItem(item)
scene.pbDisplay(_INTL("{1} is now holding the {2}.",pkmn.name,newitemname)) 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.")) scene.pbDisplay(_INTL("Your PC's Mailbox is full."))
else else
scene.pbDisplay(_INTL("The mail was saved in your PC.")) scene.pbDisplay(_INTL("The mail was saved in your PC."))
pkmn.setItem(0) pkmn.setItem(nil)
ret = true ret = true
end end
elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?")) elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?"))
$PokemonBag.pbStoreItem(pkmn.item) $PokemonBag.pbStoreItem(pkmn.item)
itemname = PBItems.getName(pkmn.item) scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name))
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pkmn.name)) pkmn.setItem(nil)
pkmn.setItem(0)
pkmn.mail = nil pkmn.mail = nil
ret = true ret = true
end end
else else
$PokemonBag.pbStoreItem(pkmn.item) $PokemonBag.pbStoreItem(pkmn.item)
itemname = PBItems.getName(pkmn.item) scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name))
scene.pbDisplay(_INTL("Received the {1} from {2}.",itemname,pkmn.name)) pkmn.setItem(nil)
pkmn.setItem(0)
ret = true ret = true
end end
return ret return ret
@@ -908,61 +698,61 @@ end
#=============================================================================== #===============================================================================
# Choose an item from the Bag # Choose an item from the Bag
#=============================================================================== #===============================================================================
def pbChooseItem(var=0,*args) def pbChooseItem(var = 0, *args)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen ret = screen.pbChooseItemScreen
} }
$game_variables[var] = ret if var>0 $game_variables[var] = ret if var > 0
return ret return ret
end end
def pbChooseApricorn(var=0) def pbChooseApricorn(var = 0)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 return ret
end end
def pbChooseFossil(var=0) def pbChooseFossil(var = 0)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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 return ret
end end
# Shows a list of items to choose from, with the chosen item's ID being stored # 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. # in the given Global Variable. Only items which the player has are listed.
def pbChooseItemFromList(message,variable,*args) def pbChooseItemFromList(message, variable, *args)
commands = [] commands = []
itemid = [] itemid = []
for item in args for item in args
next if !hasConst?(PBItems,item) next if !GameData::Item.exists?(item)
id = getConst(PBItems,item) itm = GameData::Item.get(item)
next if !$PokemonBag.pbHasItem?(id) next if !$PokemonBag.pbHasItem?(itm)
commands.push(PBItems.getName(id)) commands.push(itm.name)
itemid.push(id) itemid.push(itm.id)
end end
if commands.length==0 if commands.length == 0
$game_variables[variable] = 0 $game_variables[variable] = 0
return 0 return nil
end end
commands.push(_INTL("Cancel")) commands.push(_INTL("Cancel"))
itemid.push(0) itemid.push(nil)
ret = pbMessage(message,commands,-1) ret = pbMessage(message, commands, -1)
if ret<0 || ret>=commands.length-1 if ret < 0 || ret >= commands.length-1
$game_variables[variable] = -1 $game_variables[variable] = nil
return -1 return nil
end end
$game_variables[variable] = itemid[ret] $game_variables[variable] = itemid[ret]
return itemid[ret] return itemid[ret]
@@ -121,17 +121,15 @@ Events.onStepTaken += proc {
$PokemonBag.pbHasItem?(:SUPERREPEL) || $PokemonBag.pbHasItem?(:SUPERREPEL) ||
$PokemonBag.pbHasItem?(:MAXREPEL) $PokemonBag.pbHasItem?(:MAXREPEL)
if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?")) if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?"))
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen(Proc.new { |item| ret = screen.pbChooseItemScreen(Proc.new { |item|
isConst?(item,PBItems,:REPEL) || [:REPEL, :SUPERREPEL, :MAXREPEL].include?(item)
isConst?(item,PBItems,:SUPERREPEL) ||
isConst?(item,PBItems,:MAXREPEL)
}) })
} }
pbUseItem($PokemonBag,ret) if ret>0 pbUseItem($PokemonBag,ret) if ret
end end
else else
pbMessage(_INTL("The repellent's effect wore off!")) pbMessage(_INTL("The repellent's effect wore off!"))
@@ -292,7 +290,7 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
$game_player.turn_right_90 $game_player.turn_right_90
end end
pbWait(Graphics.frame_rate*3/10) 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 else # Item is nearby, face towards it
direction = $game_player.direction direction = $game_player.direction
if offsetX.abs>offsetY.abs if offsetX.abs>offsetY.abs
@@ -307,7 +305,7 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item|
when 8; $game_player.turn_up when 8; $game_player.turn_up
end end
pbWait(Graphics.frame_rate*3/10) 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!")) pbMessage(_INTL("There's an item buried around here!"))
end end
end end
@@ -344,7 +342,7 @@ ItemHandlers::UseInField.add(:EXPALLOFF,proc { |item|
# Applies to all items defined as an evolution stone. # Applies to all items defined as an evolution stone.
# No need to add more code for new ones. # 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| proc { |item,pkmn,scene|
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
@@ -1096,7 +1094,7 @@ ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|
next false next false
end end
newabil = (pkmn.abilityIndex+1)%2 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}?", if scene.pbConfirm(_INTL("Would you like to change {1}'s Ability to {2}?",
pkmn.name,newabilname)) pkmn.name,newabilname))
pkmn.setAbility(newabil) 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.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| proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages|
if battle.pbPlayer.party.length>=6 && $PokemonStorage.full? if battle.pbPlayer.party.length>=6 && $PokemonStorage.full?
scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages 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 # than one unfainted opposing Pokémon. (Snag Balls can be thrown in
# this case, but only in trainer battles, and the trainer will deflect # this case, but only in trainer battles, and the trainer will deflect
# them if they are trying to catch a non-Shadow Pokémon.) # 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 if battle.pbOpposingBattlerCount==2
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages
else else
@@ -302,7 +302,7 @@ ItemHandlers::UseInBattle.add(:POKEFLUTE,proc { |item,battler,battle|
scene.pbDisplay(_INTL("All Pokémon were roused by the tune!")) 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| proc { |item,battler,battle|
battle.pbThrowPokeBall(battler.index,item) battle.pbThrowPokeBall(battler.index,item)
} }
+3 -2
View File
@@ -2,7 +2,8 @@
class PokemonMail class PokemonMail
attr_accessor :item,:message,:sender,:poke1,:poke2,:poke3 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 @item = item # Item represented by this mail
@message = message # Message text @message = message # Message text
@sender = sender # Name of the message's sender @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) sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
overlay = sprites["overlay"].bitmap overlay = sprites["overlay"].bitmap
pbSetSystemFont(overlay) pbSetSystemFont(overlay)
if pbIsMailWithPokemonIcons?(mail.item) if GameData::Item.get(mail.item).is_icon_mail?
if mail.poke1 if mail.poke1
sprites["bearer"] = IconSprite.new(64,288,viewport) sprites["bearer"] = IconSprite.new(64,288,viewport)
bitmapFileName = pbCheckPokemonIconFiles(mail.poke1,mail.poke1[5]) bitmapFileName = pbCheckPokemonIconFiles(mail.poke1,mail.poke1[5])
+24 -24
View File
@@ -14,10 +14,10 @@ class ItemIconSprite < SpriteWrapper
@frame = 0 @frame = 0
self.x = x self.x = x
self.y = y self.y = y
@blankzero = false
@forceitemchange = true @forceitemchange = true
self.item = item self.item = item
@forceitemchange = false @forceitemchange = false
@blankzero = false
end end
def dispose def dispose
@@ -71,8 +71,8 @@ class ItemIconSprite < SpriteWrapper
@item = value @item = value
@animbitmap.dispose if @animbitmap @animbitmap.dispose if @animbitmap
@animbitmap = nil @animbitmap = nil
if @item && !(@item==0 && @blankzero) if @item || !@blankzero
@animbitmap = AnimatedBitmap.new(pbItemIconFile(value)) @animbitmap = AnimatedBitmap.new(pbItemIconFile(@item))
self.bitmap = @animbitmap.bitmap self.bitmap = @animbitmap.bitmap
if self.bitmap.height==ANIM_ICON_SIZE if self.bitmap.height==ANIM_ICON_SIZE
@numframes = [(self.bitmap.width/ANIM_ICON_SIZE).floor,1].max @numframes = [(self.bitmap.width/ANIM_ICON_SIZE).floor,1].max
@@ -120,26 +120,8 @@ class HeldItemIconSprite < SpriteWrapper
self.x = x self.x = x
self.y = y self.y = y
@pokemon = pokemon @pokemon = pokemon
@item = 0 @item = nil
self.item = @pokemon.item self.item = @pokemon.item_id
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
end end
def dispose def dispose
@@ -147,9 +129,27 @@ class HeldItemIconSprite < SpriteWrapper
super super
end 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 def update
super super
self.item = @pokemon.item self.item = @pokemon.item_id
if @animbitmap if @animbitmap
@animbitmap.update @animbitmap.update
self.bitmap = @animbitmap.bitmap self.bitmap = @animbitmap.bitmap
+113 -155
View File
@@ -21,20 +21,20 @@ class PokemonBag
@choices[i] = 0 @choices[i] = 0
end end
@registeredItems = [] @registeredItems = []
@registeredIndex = [0,0,1] @registeredIndex = [0, 0, 1]
end end
def rearrange def rearrange
if (@pockets.length-1)!=PokemonBag.numPockets if (@pockets.length - 1) != PokemonBag.numPockets
newpockets = [] newpockets = []
for i in 0..PokemonBag.numPockets for i in 0..PokemonBag.numPockets
newpockets[i] = [] newpockets[i] = []
@choices[i] = 0 if !@choices[i] @choices[i] = 0 if !@choices[i]
end end
nump = PokemonBag.numPockets num_pockets = PokemonBag.numPockets
for i in 0...[@pockets.length,nump].min for i in 0...[@pockets.length, num_pockets].min
for item in @pockets[i] for item in @pockets[i]
p = pbGetPocket(item[0]) p = GameData::Item.get(item[0]).pocket
newpockets[p].push(item) newpockets[p].push(item)
end end
end end
@@ -43,9 +43,7 @@ class PokemonBag
end end
def clear def clear
for pocket in @pockets @pockets.each { |pocket| pocket.clear }
pocket.clear
end
end end
def pockets def pockets
@@ -61,25 +59,27 @@ class PokemonBag
# Gets the index of the current selected item in the pocket # Gets the index of the current selected item in the pocket
def getChoice(pocket) def getChoice(pocket)
if pocket<=0 || pocket>PokemonBag.numPockets if pocket <= 0 || pocket > PokemonBag.numPockets
raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) raise ArgumentError.new(_INTL("Invalid pocket: {1}", pocket.inspect))
end end
rearrange rearrange
return [@choices[pocket],@pockets[pocket].length].min || 0 return [@choices[pocket], @pockets[pocket].length].min || 0
end end
# Sets the index of the current selected item in the pocket # Sets the index of the current selected item in the pocket
def setChoice(pocket,value) def setChoice(pocket,value)
if pocket<=0 || pocket>PokemonBag.numPockets if pocket <= 0 || pocket > PokemonBag.numPockets
raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) raise ArgumentError.new(_INTL("Invalid pocket: {1}", pocket.inspect))
end end
rearrange rearrange
@choices[pocket] = value if value<=@pockets[pocket].length @choices[pocket] = value if value <= @pockets[pocket].length
end end
def getAllChoices def getAllChoices
ret = @choices.clone 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 return ret
end end
@@ -88,143 +88,98 @@ class PokemonBag
end end
def pbQuantity(item) def pbQuantity(item)
item = getID(PBItems,item) item = GameData::Item.get(item)
if !item || item<1 pocket = item.pocket
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) return ItemStorageHelper.pbQuantity(@pockets[pocket], item.id)
end
pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket)
maxsize = @pockets[pocket].length if maxsize<0
return ItemStorageHelper.pbQuantity(@pockets[pocket],maxsize,item)
end end
def pbHasItem?(item) def pbHasItem?(item)
return pbQuantity(item)>0 return pbQuantity(item) > 0
end end
def pbCanStore?(item,qty=1) def pbCanStore?(item, qty = 1)
item = getID(PBItems,item) item = GameData::Item.get(item)
if !item || item<1 pocket = item.pocket
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
end
pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
maxsize = @pockets[pocket].length+1 if maxsize<0 maxsize = @pockets[pocket].length + 1 if maxsize < 0
return ItemStorageHelper.pbCanStore?(@pockets[pocket],maxsize, return ItemStorageHelper.pbCanStore?(
BAG_MAX_PER_SLOT,item,qty) @pockets[pocket], maxsize, BAG_MAX_PER_SLOT, item.id, qty)
end end
def pbStoreAllOrNone(item,qty=1) def pbStoreItem(item, qty = 1)
item = getID(PBItems,item) item = GameData::Item.get(item)
if !item || item<1 pocket = item.pocket
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
end
pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
maxsize = @pockets[pocket].length+1 if maxsize<0 maxsize = @pockets[pocket].length + 1 if maxsize < 0
return ItemStorageHelper.pbStoreAllOrNone(@pockets[pocket],maxsize, return ItemStorageHelper.pbStoreItem(
BAG_MAX_PER_SLOT,item,qty) @pockets[pocket], maxsize, BAG_MAX_PER_SLOT, item.id, qty, true)
end end
def pbStoreItem(item,qty=1) def pbStoreAllOrNone(item, qty = 1)
item = getID(PBItems,item) return false if !pbCanStore?(item, qty)
if !item || item<1 return pbStoreItem(item, qty)
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)
end end
def pbChangeItem(olditem,newitem) def pbChangeItem(old_item, new_item)
olditem = getID(PBItems,olditem) old_item = GameData::Item.get(old_item)
newitem = getID(PBItems,newitem) new_item = GameData::Item.get(new_item)
if !olditem || olditem<1 pocket = old_item.pocket
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
ret = false ret = false
for i in 0...maxsize @pockets[pocket].each do |item|
itemslot = @pockets[pocket][i] next if !item || item[0] != old_item.id
if itemslot && itemslot[0]==olditem item[0] = new_item.id
itemslot[0] = newitem ret = true
ret = true
end
end end
return ret return ret
end end
def pbChangeQuantity(pocket,index,newqty=1) def pbChangeQuantity(pocket, index, newqty = 1)
return false if pocket<=0 || pocket>self.numPockets return false if pocket <= 0 || pocket > self.numPockets
return false if @pockets[pocket].length<index return false if !@pockets[pocket][index]
newqty = [newqty,maxPocketSize(pocket)].min newqty = [newqty, maxPocketSize(pocket)].min
@pockets[pocket][index][1] = newqty @pockets[pocket][index][1] = newqty
return true return true
end end
def pbDeleteItem(item,qty=1) def pbDeleteItem(item, qty = 1)
item = getID(PBItems,item) item = GameData::Item.get(item)
if !item || item<1 pocket = item.pocket
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket], item.id, qty)
end
pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket)
maxsize = @pockets[pocket].length if maxsize<0
ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty)
return ret return ret
end end
def registeredItems def registeredItems
@registeredItems = [] if !@registeredItems @registeredItems = [] if !@registeredItems
if @registeredItem && @registeredItem>0 && !@registeredItems.include?(@registeredItem)
@registeredItems.push(@registeredItem)
@registeredItem = nil
end
return @registeredItems return @registeredItems
end end
def registeredItem; return registeredItems; end
def pbIsRegistered?(item) def pbIsRegistered?(item)
item = GameData::Item.get(item).id
registeredlist = self.registeredItems registeredlist = self.registeredItems
return registeredlist.include?(item) return registeredlist.include?(item)
end end
# Registers the item in the Ready Menu. # Registers the item in the Ready Menu.
def pbRegisterItem(item) def pbRegisterItem(item)
item = getID(PBItems,item) item = GameData::Item.get(item).id
if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
end
registeredlist = self.registeredItems registeredlist = self.registeredItems
registeredlist.push(item) if !registeredlist.include?(item) registeredlist.push(item) if !registeredlist.include?(item)
end end
# Unregisters the item from the Ready Menu. # Unregisters the item from the Ready Menu.
def pbUnregisterItem(item) def pbUnregisterItem(item)
item = getID(PBItems,item) item = GameData::Item.get(item).id
if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
end
registeredlist = self.registeredItems registeredlist = self.registeredItems
if registeredlist.include?(item) for i in 0...registeredlist.length
for i in 0...registeredlist.length next if registeredlist[i] != item
next if registeredlist[i]!=item registeredlist[i] = nil
registeredlist[i] = nil break
break
end
registeredlist.compact!
end end
registeredlist.compact!
end end
def registeredIndex def registeredIndex
@registeredIndex = [0,0,1] if !@registeredIndex @registeredIndex = [0, 0, 1] if !@registeredIndex
return @registeredIndex return @registeredIndex
end end
end end
@@ -235,25 +190,25 @@ end
# The PC item storage object, which actually contains all the items # The PC item storage object, which actually contains all the items
#=============================================================================== #===============================================================================
class PCItemStorage class PCItemStorage
MAXSIZE = 50 # Number of different slots in storage MAX_SIZE = 999 # Number of different slots in storage
MAXPERSLOT = 999 # Max. number of items per slot MAX_PER_SLOT = 999 # Max. number of items per slot
def initialize def initialize
@items = [] @items = []
# Start storage with a Potion # Start storage with a Potion
pbStoreItem(getConst(PBItems,:POTION)) if hasConst?(PBItems,:POTION) pbStoreItem(:POTION) if GameData::Item.exists?(:POTION)
end end
def [](i) def [](i)
@items[i] return @items[i]
end end
def length def length
@items.length return @items.length
end end
def empty? def empty?
return @items.length==0 return @items.length == 0
end end
def clear def clear
@@ -261,27 +216,31 @@ class PCItemStorage
end end
def getItem(index) def getItem(index)
return (index<0 || index>=@items.length) ? 0 : @items[index][0] return (index < 0 || index >= @items.length) ? nil : @items[index][0]
end end
def getCount(index) def getCount(index)
return (index<0 || index>=@items.length) ? 0 : @items[index][1] return (index < 0 || index >= @items.length) ? 0 : @items[index][1]
end end
def pbQuantity(item) def pbQuantity(item)
return ItemStorageHelper.pbQuantity(@items,MAXSIZE,item) item = GameData::Item.get(item).id
return ItemStorageHelper.pbQuantity(@items, item)
end end
def pbCanStore?(item,qty=1) def pbCanStore?(item, qty = 1)
return ItemStorageHelper.pbCanStore?(@items,MAXSIZE,MAXPERSLOT,item,qty) item = GameData::Item.get(item).id
return ItemStorageHelper.pbCanStore?(@items, MAX_SIZE, MAX_PER_SLOT, item, qty)
end end
def pbStoreItem(item,qty=1) def pbStoreItem(item, qty = 1)
return ItemStorageHelper.pbStoreItem(@items,MAXSIZE,MAXPERSLOT,item,qty) item = GameData::Item.get(item).id
return ItemStorageHelper.pbStoreItem(@items, MAX_SIZE, MAX_PER_SLOT, item, qty)
end end
def pbDeleteItem(item,qty=1) def pbDeleteItem(item, qty = 1)
return ItemStorageHelper.pbDeleteItem(@items,MAXSIZE,item,qty) item = GameData::Item.get(item).id
return ItemStorageHelper.pbDeleteItem(@items, item, qty)
end end
end end
@@ -293,30 +252,26 @@ end
# Used by the Bag, PC item storage, and Triple Triad. # Used by the Bag, PC item storage, and Triple Triad.
#=============================================================================== #===============================================================================
module ItemStorageHelper module ItemStorageHelper
# Returns the quantity of the given item in the items array, maximum size per # Returns the quantity of check_item in item_array
# slot, and item ID def self.pbQuantity(item_array, check_item)
def self.pbQuantity(items,maxsize,item)
ret = 0 ret = 0
for i in 0...maxsize item_array.each { |i| ret += i[1] if i && i[0] == check_item }
itemslot = items[i]
ret += itemslot[1] if itemslot && itemslot[0]==item
end
return ret return ret
end end
# Deletes an item (items array, max. size per slot, item, no. of items to delete) # Deletes an item (items array, max. size per slot, item, no. of items to delete)
def self.pbDeleteItem(items,maxsize,item,qty) def self.pbDeleteItem(items, item, qty)
raise "Invalid value for qty: #{qty}" if qty<0 raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty==0 return true if qty == 0
ret = false ret = false
for i in 0...maxsize for i in 0...items.length
itemslot = items[i] itemslot = items[i]
next if !itemslot || itemslot[0]!=item next if !itemslot || itemslot[0] != item
amount = [qty,itemslot[1]].min amount = [qty, itemslot[1]].min
itemslot[1] -= amount itemslot[1] -= amount
qty -= amount qty -= amount
items[i] = nil if itemslot[1]==0 items[i] = nil if itemslot[1] == 0
next if qty>0 next if qty > 0
ret = true ret = true
break break
end end
@@ -324,41 +279,44 @@ module ItemStorageHelper
return ret return ret
end end
def self.pbCanStore?(items,maxsize,maxPerSlot,item,qty) def self.pbCanStore?(items, maxsize, maxPerSlot, item, qty)
raise "Invalid value for qty: #{qty}" if qty<0 raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty==0 return true if qty == 0
for i in 0...maxsize for i in 0...maxsize
itemslot = items[i] itemslot = items[i]
if !itemslot if !itemslot
qty -= [qty,maxPerSlot].min qty -= [qty, maxPerSlot].min
return true if qty==0 return true if qty == 0
elsif itemslot[0]==item && itemslot[1]<maxPerSlot elsif itemslot[0] == item && itemslot[1] < maxPerSlot
newamt = itemslot[1] newamt = itemslot[1]
newamt = [newamt+qty,maxPerSlot].min newamt = [newamt + qty, maxPerSlot].min
qty -= (newamt-itemslot[1]) qty -= (newamt - itemslot[1])
return true if qty==0 return true if qty == 0
end end
end end
return false return false
end end
def self.pbStoreItem(items,maxsize,maxPerSlot,item,qty,sorting=false) def self.pbStoreItem(items, maxsize, maxPerSlot, item, qty, sorting = false)
raise "Invalid value for qty: #{qty}" if qty<0 raise "Invalid value for qty: #{qty}" if qty < 0
return true if qty==0 return true if qty == 0
itemPocket = pbGetPocket(item) itm = GameData::Item.try_get(item)
itemPocket = (itm) ? itm.pocket : 0
for i in 0...maxsize for i in 0...maxsize
itemslot = items[i] itemslot = items[i]
if !itemslot if !itemslot
items[i] = [item,[qty,maxPerSlot].min] items[i] = [item, [qty, maxPerSlot].min]
qty -= items[i][1] qty -= items[i][1]
items.sort! if sorting && BAG_POCKET_AUTO_SORT[itemPocket] if itemPocket > 0 && sorting && BAG_POCKET_AUTO_SORT[itemPocket]
return true if qty==0 items.sort! { |a, b| GameData::Item.get(a[0]).id_number <=> GameData::Item.get(b[0]).id_number }
elsif itemslot[0]==item && itemslot[1]<maxPerSlot end
return true if qty == 0
elsif itemslot[0] == item && itemslot[1] < maxPerSlot
newamt = itemslot[1] newamt = itemslot[1]
newamt = [newamt+qty,maxPerSlot].min newamt = [newamt + qty, maxPerSlot].min
qty -= (newamt-itemslot[1]) qty -= (newamt - itemslot[1])
itemslot[1] = newamt itemslot[1] = newamt
return true if qty==0 return true if qty == 0
end end
end end
return false return false
+27 -19
View File
@@ -46,8 +46,8 @@ class Pokemon
attr_accessor :moves attr_accessor :moves
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained # @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
attr_accessor :firstmoves attr_accessor :firstmoves
# @return [Integer] the ID of the item held by this Pokémon (0 = no held item) # @return [Symbol] the ID of the item held by this Pokémon (nil = no held item)
attr_accessor :item attr_accessor :item_id
# @return [Integer] this Pokémon's current status (from PBStatuses) # @return [Integer] this Pokémon's current status (from PBStatuses)
attr_reader :status attr_reader :status
# @return [Integer] sleep count / toxic flag / 0: # @return [Integer] sleep count / toxic flag / 0:
@@ -279,13 +279,13 @@ class Pokemon
return @abilityflag || (@personalID & 1) return @abilityflag || (@personalID & 1)
end 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 def ability
ret = ability_id ret = ability_id
return PokemonData::Ability.try_get(ret) return GameData::Ability.try_get(ret)
end 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 def ability_id
abilIndex = abilityIndex abilIndex = abilityIndex
# Hidden ability # Hidden ability
@@ -293,9 +293,9 @@ class Pokemon
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY) hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
if hiddenAbil.is_a?(Array) if hiddenAbil.is_a?(Array)
ret = hiddenAbil[abilIndex - 2] ret = hiddenAbil[abilIndex - 2]
return ret if PokemonData::Ability.exists?(ret) return ret if GameData::Ability.exists?(ret)
elsif abilIndex == 2 elsif abilIndex == 2
return hiddenAbil if PokemonData::Ability.exists?(hiddenAbil) return hiddenAbil if GameData::Ability.exists?(hiddenAbil)
end end
abilIndex = (@personalID & 1) abilIndex = (@personalID & 1)
end end
@@ -303,7 +303,7 @@ class Pokemon
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES) abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
if abilities.is_a?(Array) if abilities.is_a?(Array)
ret = abilities[abilIndex] 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 return ret
end end
return abilities return abilities
@@ -311,7 +311,7 @@ class Pokemon
# Returns whether this Pokémon has a particular ability. If no value # Returns whether this Pokémon has a particular ability. If no value
# is given, returns whether this Pokémon has an ability set. # 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 # @return [Boolean] whether this Pokémon has a particular ability or
# an ability at all # an ability at all
def hasAbility?(check_ability = nil) def hasAbility?(check_ability = nil)
@@ -727,21 +727,29 @@ class Pokemon
# Items # 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 this Pokémon is holding an item. If an item id is passed,
# returns whether the Pokémon is holding that item. # 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 # @return [Boolean] whether the Pokémon is holding the specified item or
# an item at all # an item at all
def hasItem?(item_id = 0) def hasItem?(check_item = nil)
held_item = self.item current_item = self.item
return held_item > 0 if item_id == 0 return !current_item.nil? if check_item.nil?
return held_item == getID(PBItems, item_id) return current_item == check_item
end end
# Gives an item to this Pokémon. Passing 0 as the argument removes the held item. # 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) # @param value [Symbol, GameData::Item, Integer] id of the item to give to this
def setItem(item_id) # Pokémon (a non-valid value sets it to nil)
self.item = getID(PBItems, item_id) || 0 def setItem(value)
new_item = GameData::Item.try_get(value)
@item_id = (new_item) ? new_item.id : nil
end end
# @return [Array<Integer>] the items this species can be found holding in the wild # @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) # @return [PokemonMail, nil] mail held by this Pokémon (nil if there is none)
def mail def mail
return nil if !@mail return nil if !@mail
@mail = nil if @mail.item == 0 || !hasItem?(@mail.item) @mail = nil if !@mail.item || !hasItem?(@mail.item)
return @mail return @mail
end end
@@ -1075,7 +1083,7 @@ class Pokemon
@moves = [] @moves = []
@status = PBStatuses::NONE @status = PBStatuses::NONE
@statusCount = 0 @statusCount = 0
@item = 0 @item_id = nil
@mail = nil @mail = nil
@fused = nil @fused = nil
@ribbons = [] @ribbons = []
@@ -11,8 +11,8 @@ class Pokemon
for i in 0...formData[@species].length for i in 0...formData[@species].length
fSpec = formData[@species][i] fSpec = formData[@species][i]
next if !fSpec || fSpec<=0 next if !fSpec || fSpec<=0
megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE] || 0 megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE]
if megaStone>0 && self.hasItem?(megaStone) if megaStone && self.hasItem?(megaStone)
ret = i; break ret = i; break
end end
if !checkItemOnly if !checkItemOnly
@@ -350,10 +350,7 @@ class PokeBattle_Battle
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true) def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true)
ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages) ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages)
if ret && pkmn.hypermode && if ret && pkmn.hypermode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
!isConst?(item,PBItems,:JOYSCENT) &&
!isConst?(item,PBItems,:EXCITESCENT) &&
!isConst?(item,PBItems,:VIVIDSCENT)
scene.pbDisplay(_INTL("This item can't be used on that Pokémon.")) scene.pbDisplay(_INTL("This item can't be used on that Pokémon."))
return false return false
end end
@@ -477,21 +474,21 @@ ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT)
ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene| ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene|
battler.pokemon.hypermode = false battler.pokemon.hypermode = false
battler.pokemon.adjustHeart(-500) 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 next true
}) })
ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene| ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene|
battler.pokemon.hypermode = false battler.pokemon.hypermode = false
battler.pokemon.adjustHeart(-1000) 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 next true
}) })
ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene| ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene|
battler.pokemon.hypermode = false battler.pokemon.hypermode = false
battler.pokemon.adjustHeart(-2000) 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 next true
}) })
@@ -149,21 +149,21 @@ def pbGetPreviousForm(species) # Unused
return species return species
end end
def pbGetBabySpecies(species,item1=-1,item2=-1) def pbGetBabySpecies(species, check_items = false, item1 = nil, item2 = nil)
ret = species ret = species
evoData = pbGetEvolutionData(species) evoData = pbGetEvolutionData(species)
return ret if !evoData || evoData.length==0 return ret if !evoData || evoData.length == 0
evoData.each do |evo| evoData.each do |evo|
next if !evo[3] next if !evo[3] # Not the prevolution
if item1>=0 && item2>=0 if check_items
incense = pbGetSpeciesData(evo[0],0,SpeciesData::INCENSE) incense = pbGetSpeciesData(evo[0], 0, SpeciesData::INCENSE)
ret = evo[0] if item1==incense || item2==incense ret = evo[0] if !incense || item1 == incense || item2 == incense
else else
ret = evo[0] # Species of prevolution ret = evo[0] # Species of prevolution
end end
break break
end end
ret = pbGetBabySpecies(ret) if ret!=species ret = pbGetBabySpecies(ret) if ret != species
return ret return ret
end end
@@ -194,8 +194,6 @@ def pbGetEvolutionFamilyData(species)
return ret return ret
end 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) def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
species = pbGetBabySpecies(species) species = pbGetBabySpecies(species)
evos = pbGetEvolutionFamilyData(species) evos = pbGetEvolutionFamilyData(species)
@@ -203,7 +201,7 @@ def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
for evo in evos for evo in evos
if method.is_a?(Array) if method.is_a?(Array)
next if !method.include?(evo[1]) next if !method.include?(evo[1])
elsif method>=0 elsif method >= 0
next if evo[1] != method next if evo[1] != method
end end
next if param >= 0 && evo[2] != param 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 # Used by the Moon Ball when checking if a Pokémon's evolution family includes
# an evolution that uses the Moon Stone. # an evolution that uses the Moon Stone.
def pbCheckEvolutionFamilyForItemMethodItem(species, param = -1) def pbCheckEvolutionFamilyForItemMethodItem(species, param = nil)
species = pbGetBabySpecies(species) species = pbGetBabySpecies(species)
evos = pbGetEvolutionFamilyData(species) evos = pbGetEvolutionFamilyData(species)
return false if !evos || evos.length == 0 return false if !evos || evos.length == 0
for evo in evos for evo in evos
next if !PBEvolution.hasFunction?(evo[1], "itemCheck") next if !PBEvolution.hasFunction?(evo[1], "itemCheck")
next if param >= 0 && evo[2] != param next if param && evo[2] != param
return true return true
end end
return false 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 a Pokemon can evolve now. If an item is used on the Pokémon,
# checks whether the Pokemon can evolve with the given item. # checks whether the Pokemon can evolve with the given item.
def pbCheckEvolution(pokemon,item=0) def pbCheckEvolution(pokemon,item=nil)
if item==0 if item
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke| return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
next pbMiniCheckEvolution(pokemon,evonib,level,poke) next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
} }
else else
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke| return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item) next pbMiniCheckEvolution(pokemon,evonib,level,poke)
} }
end end
end end
@@ -446,9 +444,9 @@ PBEvolution.register(:Shedinja, {
"parameterType" => nil, "parameterType" => nil,
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if $Trainer.party.length>=6 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) PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species)
$PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL)) $PokemonBag.pbDeleteItem(:POKEBALL)
next true next true
} }
}) })
@@ -515,13 +513,13 @@ PBEvolution.register(:HappinessMoveType, {
PBEvolution.register(:HappinessHoldItem, { PBEvolution.register(:HappinessHoldItem, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && pkmn.happiness >= 220 next pkmn.item == parameter && pkmn.happiness >= 220
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
@@ -543,78 +541,78 @@ PBEvolution.register(:Beauty, { # Feebas
PBEvolution.register(:HoldItem, { PBEvolution.register(:HoldItem, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter next pkmn.item == parameter
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
PBEvolution.register(:HoldItemMale, { PBEvolution.register(:HoldItemMale, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && pkmn.male? next pkmn.item == parameter && pkmn.male?
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
PBEvolution.register(:HoldItemFemale, { PBEvolution.register(:HoldItemFemale, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && pkmn.female? next pkmn.item == parameter && pkmn.female?
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
PBEvolution.register(:DayHoldItem, { PBEvolution.register(:DayHoldItem, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && PBDayNight.isDay? next pkmn.item == parameter && PBDayNight.isDay?
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
PBEvolution.register(:NightHoldItem, { PBEvolution.register(:NightHoldItem, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && PBDayNight.isNight? next pkmn.item == parameter && PBDayNight.isNight?
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
PBEvolution.register(:HoldItemHappiness, { PBEvolution.register(:HoldItemHappiness, {
"minimumLevel" => 1, # Needs any level up "minimumLevel" => 1, # Needs any level up
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter| "levelUpCheck" => proc { |pkmn, parameter|
next pkmn.item == parameter && pkmn.happiness >= 220 next pkmn.item == parameter && pkmn.happiness >= 220
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
@@ -662,42 +660,42 @@ PBEvolution.register(:Region, {
# Evolution methods that trigger when using an item on the Pokémon # Evolution methods that trigger when using an item on the Pokémon
#=============================================================================== #===============================================================================
PBEvolution.register(:Item, { PBEvolution.register(:Item, {
"parameterType" => :PBItems, "parameterType" => :Item,
"itemCheck" => proc { |pkmn, parameter, item| "itemCheck" => proc { |pkmn, parameter, item|
next item == parameter next item == parameter
} }
}) })
PBEvolution.register(:ItemMale, { PBEvolution.register(:ItemMale, {
"parameterType" => :PBItems, "parameterType" => :Item,
"itemCheck" => proc { |pkmn, parameter, item| "itemCheck" => proc { |pkmn, parameter, item|
next item == parameter && pkmn.male? next item == parameter && pkmn.male?
} }
}) })
PBEvolution.register(:ItemFemale, { PBEvolution.register(:ItemFemale, {
"parameterType" => :PBItems, "parameterType" => :Item,
"itemCheck" => proc { |pkmn, parameter, item| "itemCheck" => proc { |pkmn, parameter, item|
next item == parameter && pkmn.female? next item == parameter && pkmn.female?
} }
}) })
PBEvolution.register(:ItemDay, { PBEvolution.register(:ItemDay, {
"parameterType" => :PBItems, "parameterType" => :Item,
"itemCheck" => proc { |pkmn, parameter, item| "itemCheck" => proc { |pkmn, parameter, item|
next item == parameter && PBDayNight.isDay? next item == parameter && PBDayNight.isDay?
} }
}) })
PBEvolution.register(:ItemNight, { PBEvolution.register(:ItemNight, {
"parameterType" => :PBItems, "parameterType" => :Item,
"itemCheck" => proc { |pkmn, parameter, item| "itemCheck" => proc { |pkmn, parameter, item|
next item == parameter && PBDayNight.isNight? next item == parameter && PBDayNight.isNight?
} }
}) })
PBEvolution.register(:ItemHappiness, { PBEvolution.register(:ItemHappiness, {
"parameterType" => :PBItems, "parameterType" => :Item,
"levelUpCheck" => proc { |pkmn, parameter, item| "levelUpCheck" => proc { |pkmn, parameter, item|
next item == parameter && pkmn.happiness >= 220 next item == parameter && pkmn.happiness >= 220
} }
@@ -742,13 +740,13 @@ PBEvolution.register(:TradeNight, {
}) })
PBEvolution.register(:TradeItem, { PBEvolution.register(:TradeItem, {
"parameterType" => :PBItems, "parameterType" => :Item,
"tradeCheck" => proc { |pkmn, parameter, other_pkmn| "tradeCheck" => proc { |pkmn, parameter, other_pkmn|
next pkmn.item == parameter next pkmn.item == parameter
}, },
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter) 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 next true
} }
}) })
+3 -3
View File
@@ -184,14 +184,14 @@ class PokemonPauseMenu
return return
end end
elsif cmdBag>=0 && command==cmdBag elsif cmdBag>=0 && command==cmdBag
item = 0 item = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) screen = PokemonBagScreen.new(scene,$PokemonBag)
item = screen.pbStartScreen item = screen.pbStartScreen
(item>0) ? @scene.pbEndScene : @scene.pbRefresh (item) ? @scene.pbEndScene : @scene.pbRefresh
} }
if item>0 if item
$game_temp.in_menu = false $game_temp.in_menu = false
pbUseKeyItemInField(item) pbUseKeyItemInField(item)
return return
+18 -17
View File
@@ -642,25 +642,26 @@ class PokemonParty_Scene
end end
def pbChooseItem(bag) def pbChooseItem(bag)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag) 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? yield if block_given?
} }
return ret return ret
end end
def pbUseItem(bag,pokemon) def pbUseItem(bag,pokemon)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag) screen = PokemonBagScreen.new(scene,bag)
ret = screen.pbChooseItemScreen(Proc.new { |item| ret = screen.pbChooseItemScreen(Proc.new { |item|
next false if !pbCanUseOnPokemon?(item) itm = GameData::Item.get(item)
if pbIsMachine?(item) next false if !pbCanUseOnPokemon?(itm)
move = pbGetMachine(item) if itm.is_machine?
move = itm.move
next false if pokemon.hasMove?(move) || !pokemon.compatibleWithMove?(move) next false if pokemon.hasMove?(move) || !pokemon.compatibleWithMove?(move)
end end
next true next true
@@ -1250,14 +1251,15 @@ class PokemonPartyScreen
itemcommands[cmdUseItem=itemcommands.length] = _INTL("Use") itemcommands[cmdUseItem=itemcommands.length] = _INTL("Use")
itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give") itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give")
itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem? 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") itemcommands[itemcommands.length] = _INTL("Cancel")
command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands) command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands)
if cmdUseItem>=0 && command==cmdUseItem # Use if cmdUseItem>=0 && command==cmdUseItem # Use
item = @scene.pbUseItem($PokemonBag,pkmn) { item = @scene.pbUseItem($PokemonBag,pkmn) {
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) @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) pbUseItemOnPokemon(item,pkmn,self)
pbRefreshSingle(pkmnid) pbRefreshSingle(pkmnid)
end end
@@ -1265,7 +1267,7 @@ class PokemonPartyScreen
item = @scene.pbChooseItem($PokemonBag) { item = @scene.pbChooseItem($PokemonBag) {
@scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) @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) if pbGiveItemToPokemon(item,pkmn,self,pkmnid)
pbRefreshSingle(pkmnid) pbRefreshSingle(pkmnid)
end end
@@ -1276,7 +1278,7 @@ class PokemonPartyScreen
end end
elsif cmdMoveItem>=0 && command==cmdMoveItem # Move elsif cmdMoveItem>=0 && command==cmdMoveItem # Move
item = pkmn.item item = pkmn.item
itemname = PBItems.getName(item) itemname = item.name
@scene.pbSetHelpText(_INTL("Move {1} to where?",itemname)) @scene.pbSetHelpText(_INTL("Move {1} to where?",itemname))
oldpkmnid = pkmnid oldpkmnid = pkmnid
loop do loop do
@@ -1284,23 +1286,22 @@ class PokemonPartyScreen
pkmnid = @scene.pbChoosePokemon(true,pkmnid) pkmnid = @scene.pbChoosePokemon(true,pkmnid)
break if pkmnid<0 break if pkmnid<0
newpkmn = @party[pkmnid] newpkmn = @party[pkmnid]
if pkmnid==oldpkmnid break if pkmnid==oldpkmnid
break if newpkmn.egg?
elsif newpkmn.egg?
pbDisplay(_INTL("Eggs can't hold items.")) pbDisplay(_INTL("Eggs can't hold items."))
elsif !newpkmn.hasItem? elsif !newpkmn.hasItem?
newpkmn.setItem(item) newpkmn.setItem(item)
pkmn.setItem(0) pkmn.setItem(nil)
@scene.pbClearSwitching @scene.pbClearSwitching
pbRefresh pbRefresh
pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname)) pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname))
break 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)) pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name))
else else
newitem = newpkmn.item newitem = newpkmn.item
newitemname = PBItems.getName(newitem) newitemname = newitem.name
if isConst?(newitem,PBItems,:LEFTOVERS) if newitem == :LEFTOVERS
pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname)) pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname))
elsif newitemname.starts_with_vowel? elsif newitemname.starts_with_vowel?
pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname)) pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname))
+9 -9
View File
@@ -123,7 +123,7 @@ class PokemonSummary_Scene
@sprites["pokeicon"].x = 46 @sprites["pokeicon"].x = 46
@sprites["pokeicon"].y = 92 @sprites["pokeicon"].y = 92
@sprites["pokeicon"].visible = false @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["itemicon"].blankzero = true
@sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
pbSetSystemFont(@sprites["overlay"].bitmap) pbSetSystemFont(@sprites["overlay"].bitmap)
@@ -287,7 +287,7 @@ class PokemonSummary_Scene
if @pokemon.egg? if @pokemon.egg?
drawPageOneEgg; return drawPageOneEgg; return
end end
@sprites["itemicon"].item = @pokemon.item @sprites["itemicon"].item = @pokemon.item_id
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
base = Color.new(248,248,248) base = Color.new(248,248,248)
@@ -330,7 +330,7 @@ class PokemonSummary_Scene
] ]
# Write the held item's name # Write the held item's name
if @pokemon.hasItem? 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 else
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)]) textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
end end
@@ -454,7 +454,7 @@ class PokemonSummary_Scene
end end
def drawPageOneEgg def drawPageOneEgg
@sprites["itemicon"].item = @pokemon.item @sprites["itemicon"].item = @pokemon.item_id
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
base = Color.new(248,248,248) base = Color.new(248,248,248)
@@ -475,7 +475,7 @@ class PokemonSummary_Scene
] ]
# Write the held item's name # Write the held item's name
if @pokemon.hasItem? 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 else
textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)]) textpos.push([_INTL("None"),16,352,0,Color.new(192,200,208),Color.new(208,216,224)])
end end
@@ -892,7 +892,7 @@ class PokemonSummary_Scene
def pbChangePokemon def pbChangePokemon
@pokemon = @party[@partyindex] @pokemon = @party[@partyindex]
@sprites["pokemon"].setPokemonBitmap(@pokemon) @sprites["pokemon"].setPokemonBitmap(@pokemon)
@sprites["itemicon"].item = @pokemon.item @sprites["itemicon"].item = @pokemon.item_id
pbSEStop pbSEStop
pbPlayCry(@pokemon) pbPlayCry(@pokemon)
end end
@@ -1169,13 +1169,13 @@ class PokemonSummary_Scene
commands[commands.length] = _INTL("Cancel") commands[commands.length] = _INTL("Cancel")
command = pbShowCommands(commands) command = pbShowCommands(commands)
if cmdGiveItem>=0 && command==cmdGiveItem if cmdGiveItem>=0 && command==cmdGiveItem
item = 0 item = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag) 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) dorefresh = pbGiveItemToPokemon(item,@pokemon,self,@partyindex)
end end
elsif cmdTakeItem>=0 && command==cmdTakeItem elsif cmdTakeItem>=0 && command==cmdTakeItem
+49 -42
View File
@@ -29,10 +29,10 @@ class Window_PokemonBag < Window_DrawableCommand
def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end
def item def item
return 0 if @filterlist && !@filterlist[@pocket][self.index] return nil if @filterlist && !@filterlist[@pocket][self.index]
thispocket = @bag.pockets[@pocket] thispocket = @bag.pockets[@pocket]
item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index] item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index]
return (item) ? item[0] : 0 return (item) ? item[0] : nil
end end
def itemCount def itemCount
@@ -76,13 +76,7 @@ class Window_PokemonBag < Window_DrawableCommand
textpos.push( textpos.push(
[@adapter.getDisplayName(item),rect.x,ypos,false,baseColor,shadowColor] [@adapter.getDisplayName(item),rect.x,ypos,false,baseColor,shadowColor]
) )
if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM) if GameData::Item.get(item).is_important?
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 @bag.pbIsRegistered?(item) if @bag.pbIsRegistered?(item)
pbDrawImagePositions(self.contents,[ pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,0,-1,24] ["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] ["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,24,-1,24]
]) ])
end 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
end end
pbDrawTextPositions(self.contents,textpos) pbDrawTextPositions(self.contents,textpos)
@@ -195,7 +194,7 @@ class PokemonBag_Scene
@sprites["itemlist"].index = @bag.getChoice(lastpocket) @sprites["itemlist"].index = @bag.getChoice(lastpocket)
@sprites["itemlist"].baseColor = ITEMLISTBASECOLOR @sprites["itemlist"].baseColor = ITEMLISTBASECOLOR
@sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR @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"] = Window_UnformattedTextPokemon.new("")
@sprites["itemtext"].x = 72 @sprites["itemtext"].x = 72
@sprites["itemtext"].y = 270 @sprites["itemtext"].y = 270
@@ -318,8 +317,9 @@ class PokemonBag_Scene
# Set the selected item's icon # Set the selected item's icon
@sprites["itemicon"].item = itemlist.item @sprites["itemicon"].item = itemlist.item
# Set the selected item's description # Set the selected item's description
@sprites["itemtext"].text = (itemlist.item==0) ? _INTL("Close bag.") : @sprites["itemtext"].text =
pbGetMessage(MessageTypes::ItemDescriptions,itemlist.item) (itemlist.item) ? GameData::Item.get(itemlist.item).description : _INTL("Close bag.")
end end
def pbRefreshFilter def pbRefreshFilter
@@ -379,8 +379,10 @@ class PokemonBag_Scene
loop do loop do
newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1 newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
break if !@choosing || newpocket==itemwindow.pocket break if !@choosing || newpocket==itemwindow.pocket
if @filterlist; break if @filterlist[newpocket].length>0 if @filterlist
else; break if @bag.pockets[newpocket].length>0 break if @filterlist[newpocket].length>0
else
break if @bag.pockets[newpocket].length>0
end end
end end
if itemwindow.pocket!=newpocket if itemwindow.pocket!=newpocket
@@ -395,8 +397,10 @@ class PokemonBag_Scene
loop do loop do
newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1 newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
break if !@choosing || newpocket==itemwindow.pocket break if !@choosing || newpocket==itemwindow.pocket
if @filterlist; break if @filterlist[newpocket].length>0 if @filterlist
else; break if @bag.pockets[newpocket].length>0 break if @filterlist[newpocket].length>0
else
break if @bag.pockets[newpocket].length>0
end end
end end
if itemwindow.pocket!=newpocket if itemwindow.pocket!=newpocket
@@ -428,9 +432,9 @@ class PokemonBag_Scene
end end
elsif Input.trigger?(Input::B) # Cancel the item screen elsif Input.trigger?(Input::B) # Cancel the item screen
pbPlayCloseMenuSE pbPlayCloseMenuSE
return 0 return nil
elsif Input.trigger?(Input::C) # Choose selected item elsif Input.trigger?(Input::C) # Choose selected item
(itemwindow.item==0) ? pbPlayCloseMenuSE : pbPlayDecisionSE (itemwindow.item) ? pbPlayDecisionSE : pbPlayCloseMenuSE
return itemwindow.item return itemwindow.item
end end
end end
@@ -452,10 +456,11 @@ class PokemonBagScreen
def pbStartScreen def pbStartScreen
@scene.pbStartScene(@bag) @scene.pbStartScene(@bag)
item = 0 item = nil
loop do loop do
item = @scene.pbChooseItem item = @scene.pbChooseItem
break if item==0 break if !item
itm = GameData::Item.get(item)
cmdRead = -1 cmdRead = -1
cmdUse = -1 cmdUse = -1
cmdRegister = -1 cmdRegister = -1
@@ -464,16 +469,16 @@ class PokemonBagScreen
cmdDebug = -1 cmdDebug = -1
commands = [] commands = []
# Generate command list # Generate command list
commands[cmdRead = commands.length] = _INTL("Read") if pbIsMail?(item) commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail?
if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0) if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $Trainer.party.length>0)
if ItemHandlers.hasUseText(item) if ItemHandlers.hasUseText(item)
commands[cmdUse = commands.length] = ItemHandlers.getUseText(item) commands[cmdUse = commands.length] = ItemHandlers.getUseText(item)
else else
commands[cmdUse = commands.length] = _INTL("Use") commands[cmdUse = commands.length] = _INTL("Use")
end end
end end
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && pbCanHoldItem?(item) commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemonParty.length>0 && itm.can_hold?
commands[cmdToss = commands.length] = _INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG commands[cmdToss = commands.length] = _INTL("Toss") if !itm.is_important? || $DEBUG
if @bag.pbIsRegistered?(item) if @bag.pbIsRegistered?(item)
commands[cmdRegister = commands.length] = _INTL("Deselect") commands[cmdRegister = commands.length] = _INTL("Deselect")
elsif pbCanRegisterItem?(item) elsif pbCanRegisterItem?(item)
@@ -482,7 +487,7 @@ class PokemonBagScreen
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
commands[commands.length] = _INTL("Cancel") commands[commands.length] = _INTL("Cancel")
# Show commands generated above # Show commands generated above
itemname = PBItems.getName(item) itemname = itm.name
command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands) command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
if cmdRead>=0 && command==cmdRead # Read mail if cmdRead>=0 && command==cmdRead # Read mail
pbFadeOutIn { pbFadeOutIn {
@@ -497,7 +502,7 @@ class PokemonBagScreen
elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
if $Trainer.pokemonCount==0 if $Trainer.pokemonCount==0
@scene.pbDisplay(_INTL("There is no Pokémon.")) @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)) @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
else else
pbFadeOutIn { pbFadeOutIn {
@@ -510,11 +515,11 @@ class PokemonBagScreen
elsif cmdToss>=0 && command==cmdToss # Toss item elsif cmdToss>=0 && command==cmdToss # Toss item
qty = @bag.pbQuantity(item) qty = @bag.pbQuantity(item)
if qty>1 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) qty = @scene.pbChooseNumber(helptext,qty)
end end
if qty>0 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)) if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname)) pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
qty.times { @bag.pbDeleteItem(item) } qty.times { @bag.pbDeleteItem(item) }
@@ -543,7 +548,7 @@ class PokemonBagScreen
### Change quantity ### ### Change quantity ###
when 0 when 0
qty = @bag.pbQuantity(item) qty = @bag.pbQuantity(item)
itemplural = PBItems.getNamePlural(item) itemplural = itm.name_plural
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0,BAG_MAX_PER_SLOT) params.setRange(0,BAG_MAX_PER_SLOT)
params.setDefaultValue(qty) params.setDefaultValue(qty)
@@ -596,9 +601,10 @@ class PokemonBagScreen
@scene.pbStartScene(storage) @scene.pbStartScene(storage)
loop do loop do
item = @scene.pbChooseItem item = @scene.pbChooseItem
break if item==0 break if !item
itm = GameData::Item.get(item)
qty = storage.pbQuantity(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) qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
end end
next if qty<=0 next if qty<=0
@@ -610,8 +616,8 @@ class PokemonBagScreen
raise "Can't withdraw items from storage" raise "Can't withdraw items from storage"
end end
@scene.pbRefresh @scene.pbRefresh
dispqty = (pbIsImportantItem?(item)) ? 1 : qty dispqty = (itm.is_important?) ? 1 : qty
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) itemname = (dispqty>1) ? itm.name_plural : itm.name
pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname)) pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname))
else else
pbDisplay(_INTL("There's no more room in the Bag.")) pbDisplay(_INTL("There's no more room in the Bag."))
@@ -627,12 +633,12 @@ class PokemonBagScreen
$PokemonGlobal.pcItemStorage = PCItemStorage.new $PokemonGlobal.pcItemStorage = PCItemStorage.new
end end
storage = $PokemonGlobal.pcItemStorage storage = $PokemonGlobal.pcItemStorage
item = 0
loop do loop do
item = @scene.pbChooseItem item = @scene.pbChooseItem
break if item==0 break if !item
itm = GameData::Item.get(item)
qty = @bag.pbQuantity(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) qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
end end
if qty>0 if qty>0
@@ -646,8 +652,8 @@ class PokemonBagScreen
raise "Can't deposit items to storage" raise "Can't deposit items to storage"
end end
@scene.pbRefresh @scene.pbRefresh
dispqty = (pbIsImportantItem?(item)) ? 1 : qty dispqty = (itm.is_important?) ? 1 : qty
itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) itemname = (dispqty>1) ? itm.name_plural : itm.name
pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname)) pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname))
end end
end end
@@ -664,14 +670,15 @@ class PokemonBagScreen
@scene.pbStartScene(storage) @scene.pbStartScene(storage)
loop do loop do
item = @scene.pbChooseItem item = @scene.pbChooseItem
break if item==0 break if !item
if pbIsImportantItem?(item) itm = GameData::Item.get(item)
if itm.is_important?
@scene.pbDisplay(_INTL("That's too important to toss out!")) @scene.pbDisplay(_INTL("That's too important to toss out!"))
next next
end end
qty = storage.pbQuantity(item) qty = storage.pbQuantity(item)
itemname = PBItems.getName(item) itemname = itm.name
itemnameplural = PBItems.getNamePlural(item) itemnameplural = itm.name_plural
if qty>1 if qty>1
qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty) qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty)
end end
-1
View File
@@ -268,7 +268,6 @@ class PokemonLoadScreen
$scene = nil $scene = nil
return return
end end
PokemonData::Ability.load
commands = [] commands = []
cmdContinue = -1 cmdContinue = -1
cmdNewGame = -1 cmdNewGame = -1
+9 -8
View File
@@ -66,12 +66,12 @@ class ReadyMenuButton < SpriteWrapper
self.bitmap.clear self.bitmap.clear
rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2) rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2)
self.bitmap.blt(0,0,@button.bitmap,rect) 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 = [ textpos = [
[@command[1],textx,18,2,Color.new(248,248,248),Color.new(40,40,40),1], [@command[1],textx,18,2,Color.new(248,248,248),Color.new(40,40,40),1],
] ]
if !@command[2] if !@command[2]
if !pbIsImportantItem?(@command[0]) if !GameData::Item.get(@command[0]).is_important?
qty = $PokemonBag.pbQuantity(@command[0]) qty = $PokemonBag.pbQuantity(@command[0])
if qty>99 if qty>99
textpos.push([_INTL(">99"),230,18,1, textpos.push([_INTL(">99"),230,18,1,
@@ -236,11 +236,11 @@ class PokemonReadyMenu
def pbStartReadyMenu(moves,items) def pbStartReadyMenu(moves,items)
commands = [[],[]] # Moves, items commands = [[],[]] # Moves, items
for i in moves 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 end
commands[0].sort! { |a,b| a[1]<=>b[1] } commands[0].sort! { |a,b| a[1]<=>b[1] }
for i in items for i in items
commands[1].push([i,PBItems.getName(i),false]) commands[1].push([i, GameData::Item.get(i).name, false])
end end
commands[1].sort! { |a,b| a[1]<=>b[1] } commands[1].sort! { |a,b| a[1]<=>b[1] }
@scene.pbStartScene(commands) @scene.pbStartScene(commands)
@@ -296,9 +296,9 @@ end
# Using a registered item # Using a registered item
#=============================================================================== #===============================================================================
def pbUseKeyItem def pbUseKeyItem
moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH, moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB,
:SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL, :ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT,
:WHIRLPOOL] :WATERFALL, :WHIRLPOOL]
realmoves = [] realmoves = []
for i in moves for i in moves
move = getID(PBMoves,i) move = getID(PBMoves,i)
@@ -312,7 +312,8 @@ def pbUseKeyItem
end end
realitems = [] realitems = []
for i in $PokemonBag.registeredItems 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 end
if realitems.length==0 && realmoves.length==0 if realitems.length==0 && realmoves.length==0
pbMessage(_INTL("An item in the Bag can be registered to this key for instant use.")) pbMessage(_INTL("An item in the Bag can be registered to this key for instant use."))
@@ -1205,11 +1205,11 @@ class PokemonStorageScene
end end
def pbChooseItem(bag) def pbChooseItem(bag)
ret = 0 ret = nil
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,bag) 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 return ret
end end
@@ -1415,14 +1415,13 @@ class PokemonStorageScene
end end
imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246]) imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246])
textstrings.push([pokemon.level.to_s,28,234,false,base,shadow]) textstrings.push([pokemon.level.to_s,28,234,false,base,shadow])
ability = pokemon.ability if pokemon.ability
if ability textstrings.push([pokemon.ability.name,86,306,2,base,shadow])
textstrings.push([ability.name,86,306,2,base,shadow])
else else
textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow]) textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow])
end end
if pokemon.item>0 if pokemon.item
textstrings.push([PBItems.getName(pokemon.item),86,342,2,base,shadow]) textstrings.push([pokemon.item.name,86,342,2,base,shadow])
else else
textstrings.push([_INTL("No item"),86,342,2,nonbase,nonshadow]) textstrings.push([_INTL("No item"),86,342,2,nonbase,nonshadow])
end end
@@ -1869,21 +1868,21 @@ class PokemonStorageScreen
pbDisplay(_INTL("Please remove the mail.")) pbDisplay(_INTL("Please remove the mail."))
return return
end end
if pokemon.item>0 if pokemon.item
itemname = PBItems.getName(pokemon.item) itemname = pokemon.item.name
if pbConfirm(_INTL("Take this {1}?",itemname)) if pbConfirm(_INTL("Take this {1}?",itemname))
if !$PokemonBag.pbStoreItem(pokemon.item) if !$PokemonBag.pbStoreItem(pokemon.item)
pbDisplay(_INTL("Can't store the {1}.",itemname)) pbDisplay(_INTL("Can't store the {1}.",itemname))
else else
pbDisplay(_INTL("Took the {1}.",itemname)) pbDisplay(_INTL("Took the {1}.",itemname))
pokemon.setItem(0) pokemon.setItem(nil)
@scene.pbHardRefresh @scene.pbHardRefresh
end end
end end
else else
item = scene.pbChooseItem($PokemonBag) item = scene.pbChooseItem($PokemonBag)
if item>0 if item
itemname = PBItems.getName(item) itemname = GameData::Item.get(item).name
pokemon.setItem(item) pokemon.setItem(item)
$PokemonBag.pbDeleteItem(item) $PokemonBag.pbDeleteItem(item)
pbDisplay(_INTL("{1} is now being held.",itemname)) pbDisplay(_INTL("{1} is now being held.",itemname))
+21 -21
View File
@@ -18,7 +18,7 @@ class Window_PokemonItemStorage < Window_DrawableCommand
def item def item
item = @bag[self.index] item = @bag[self.index]
return item ? item[0] : 0 return item ? item[0] : nil
end end
def itemCount def itemCount
@@ -34,12 +34,12 @@ class Window_PokemonItemStorage < Window_DrawableCommand
else else
item = @bag[index][0] item = @bag[index][0]
itemname = @adapter.getDisplayName(item) 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 baseColor = (index==@sortIndex) ? Color.new(248,24,24) : self.baseColor
textpos.push([itemname,rect.x,ypos,false,self.baseColor,self.shadowColor]) 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]) textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor])
end end
end end
@@ -73,7 +73,7 @@ class ItemStorage_Scene
@sprites = {} @sprites = {}
@sprites["background"] = IconSprite.new(0,0,@viewport) @sprites["background"] = IconSprite.new(0,0,@viewport)
@sprites["background"].setBitmap("Graphics/Pictures/pcItembg") @sprites["background"].setBitmap("Graphics/Pictures/pcItembg")
@sprites["icon"] = ItemIconSprite.new(50,334,-1,@viewport) @sprites["icon"] = ItemIconSprite.new(50,334,nil,@viewport)
# Item list # Item list
@sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32) @sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32)
@sprites["itemwindow"].viewport = @viewport @sprites["itemwindow"].viewport = @viewport
@@ -134,10 +134,10 @@ class ItemStorage_Scene
# Draw item icon # Draw item icon
@sprites["icon"].item = itemwindow.item @sprites["icon"].item = itemwindow.item
# Get item description # Get item description
if itemwindow.item==0 if itemwindow.item
@sprites["itemtextwindow"].text = _INTL("Close storage.") @sprites["itemtextwindow"].text = GameData::Item.get(itemwindow.item).description
else else
@sprites["itemtextwindow"].text = pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item) @sprites["itemtextwindow"].text = _INTL("Close storage.")
end end
itemwindow.refresh itemwindow.refresh
end end
@@ -155,13 +155,13 @@ class ItemStorage_Scene
self.update self.update
pbRefresh if itemwindow.item!=olditem pbRefresh if itemwindow.item!=olditem
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
return 0 return nil
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
if itemwindow.index<@bag.length if itemwindow.index<@bag.length
pbRefresh pbRefresh
return @bag[itemwindow.index][0] return @bag[itemwindow.index][0]
else else
return 0 return nil
end end
end end
end end
@@ -258,10 +258,10 @@ module UIHelper
(block_given?) ? yield : dw.update (block_given?) ? yield : dw.update
if !dw.busy? && dw.resume if !dw.busy? && dw.resume
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
pbPlayCancelSE() pbPlayCancelSE
break break
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
pbPlayDecisionSE() pbPlayDecisionSE
ret = (cw.index==0) ret = (cw.index==0)
break break
end end
@@ -294,32 +294,32 @@ module UIHelper
(block_given?) ? yield : helpwindow.update (block_given?) ? yield : helpwindow.update
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
ret = 0 ret = 0
pbPlayCancelSE() pbPlayCancelSE
break break
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
ret = curnumber ret = curnumber
pbPlayDecisionSE() pbPlayDecisionSE
break break
elsif Input.repeat?(Input::UP) elsif Input.repeat?(Input::UP)
curnumber += 1 curnumber += 1
curnumber = 1 if curnumber>maximum curnumber = 1 if curnumber>maximum
numwindow.text = _ISPRINTF("x{1:03d}",curnumber) numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE() pbPlayCursorSE
elsif Input.repeat?(Input::DOWN) elsif Input.repeat?(Input::DOWN)
curnumber -= 1 curnumber -= 1
curnumber = maximum if curnumber<1 curnumber = maximum if curnumber<1
numwindow.text = _ISPRINTF("x{1:03d}",curnumber) numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE() pbPlayCursorSE
elsif Input.repeat?(Input::LEFT) elsif Input.repeat?(Input::LEFT)
curnumber -= 10 curnumber -= 10
curnumber = 1 if curnumber<1 curnumber = 1 if curnumber<1
numwindow.text = _ISPRINTF("x{1:03d}",curnumber) numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE() pbPlayCursorSE
elsif Input.repeat?(Input::RIGHT) elsif Input.repeat?(Input::RIGHT)
curnumber += 10 curnumber += 10
curnumber = maximum if curnumber>maximum curnumber = maximum if curnumber>maximum
numwindow.text = _ISPRINTF("x{1:03d}",curnumber) numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
pbPlayCursorSE() pbPlayCursorSE
end end
end end
} }
@@ -347,12 +347,12 @@ module UIHelper
cmdwindow.update cmdwindow.update
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
ret = -1 ret = -1
pbPlayCancelSE() pbPlayCancelSE
break break
end end
if Input.trigger?(Input::C) if Input.trigger?(Input::C)
ret = cmdwindow.index ret = cmdwindow.index
pbPlayDecisionSE() pbPlayDecisionSE
break break
end end
end end
+1 -1
View File
@@ -614,7 +614,7 @@ class PokemonEvolutionScene
new_pkmn.name = PBSpecies.getName(new_species) new_pkmn.name = PBSpecies.getName(new_species)
new_pkmn.markings = 0 new_pkmn.markings = 0
new_pkmn.ballused = 0 new_pkmn.ballused = 0
new_pkmn.setItem(0) new_pkmn.setItem(nil)
new_pkmn.clearAllRibbons new_pkmn.clearAllRibbons
new_pkmn.calcStats new_pkmn.calcStats
new_pkmn.heal new_pkmn.heal
+256 -266
View File
@@ -18,21 +18,21 @@ class PokemonMartAdapter
return $PokemonBag return $PokemonBag
end end
def getDisplayName(item) def getName(item)
itemname = PBItems.getName(item) return GameData::Item.get(item).name
if pbIsMachine?(item)
machine = pbGetMachine(item)
itemname = _INTL("{1} {2}",itemname,PBMoves.getName(machine))
end
return itemname
end end
def getName(item) def getDisplayName(item)
return PBItems.getName(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 end
def getDescription(item) def getDescription(item)
return pbGetMessage(MessageTypes::ItemDescriptions,item) return GameData::Item.get(item).description
end end
def getItemIcon(item) def getItemIcon(item)
@@ -40,8 +40,9 @@ class PokemonMartAdapter
return pbItemIconFile(item) return pbItemIconFile(item)
end end
# Unused
def getItemIconRect(_item) def getItemIconRect(_item)
return Rect.new(0,0,48,48) return Rect.new(0, 0, 48, 48)
end end
def getQuantity(item) def getQuantity(item)
@@ -49,27 +50,27 @@ class PokemonMartAdapter
end end
def showQuantity?(item) def showQuantity?(item)
return !pbIsImportantItem?(item) return !GameData::Item.get(item).is_important?
end end
def getPrice(item,selling=false) def getPrice(item, selling = false)
if $game_temp.mart_prices && $game_temp.mart_prices[item] if $game_temp.mart_prices && $game_temp.mart_prices[item]
if selling 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 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
end end
return pbGetPrice(item) return GameData::Item.get(item).price
end end
def getDisplayPrice(item,selling=false) def getDisplayPrice(item, selling = false)
price = getPrice(item,selling).to_s_formatted price = getPrice(item, selling).to_s_formatted
return _INTL("$ {1}",price) return _INTL("$ {1}", price)
end end
def canSell?(item) def canSell?(item)
return (getPrice(item,true)>0 && !pbIsImportantItem?(item)) return getPrice(item, true) > 0 && !GameData::Item.get(item).is_important?
end end
def addItem(item) def addItem(item)
@@ -101,32 +102,31 @@ class RpgxpMartAdapter
$game_party.gain_gold(value) $game_party.gain_gold(value)
end end
def getPrice(item,_selling=false) def getPrice(item, _selling = false)
return item.price return item.price
end end
def getItemIcon(item) def getItemIcon(item)
return nil if !item return nil if !item
if item==0 if item == 0
return sprintf("Graphics/Icons/itemBack") return sprintf("Graphics/Icons/itemBack")
elsif item.respond_to?("icon_index") elsif item.respond_to?("icon_index")
return "Graphics/System/IconSet" return "Graphics/System/IconSet"
else else
return sprintf("Graphics/Icons/%s",item.icon_name) return sprintf("Graphics/Icons/%s", item.icon_name)
end end
end end
def getItemIconRect(item) def getItemIconRect(item)
if item && item.respond_to?("icon_index") if item && item.respond_to?("icon_index")
ix=item.icon_index % 16 * 24 ix = item.icon_index % 16 * 24
iy=item.icon_index / 16 * 24 iy = item.icon_index / 16 * 24
return Rect.new(ix,iy,24,24) return Rect.new(ix, iy, 24, 24)
else
return Rect.new(0,0,32,32)
end end
return Rect.new(0, 0, 32, 32)
end end
def getInventory() def getInventory
data = [] data = []
for i in 1...$data_items.size for i in 1...$data_items.size
data.push($data_items[i]) if getQuantity($data_items[i]) > 0 data.push($data_items[i]) if getQuantity($data_items[i]) > 0
@@ -141,7 +141,7 @@ class RpgxpMartAdapter
end end
def canSell?(item) def canSell?(item)
return item ? item.price>0 : false return item ? item.price > 0 : false
end end
def getName(item) def getName(item)
@@ -152,17 +152,17 @@ class RpgxpMartAdapter
return item ? item.name : "" return item ? item.name : ""
end end
def getDisplayPrice(item,_selling=false)
price=item.price
return price.to_s
end
def getDescription(item) def getDescription(item)
return item ? item.description : "" return item ? item.description : ""
end end
def getDisplayPrice(item, _selling = false)
price = item.price
return price.to_s
end
def addItem(item) def addItem(item)
ret=(getQuantity(item)<99) ret = (getQuantity(item) < 99)
if $game_party.respond_to?("gain_weapon") if $game_party.respond_to?("gain_weapon")
case item case item
when RPG::Item when RPG::Item
@@ -173,21 +173,21 @@ class RpgxpMartAdapter
$game_party.gain_armor(item.id, 1) if ret $game_party.gain_armor(item.id, 1) if ret
end end
else else
$game_party.gain_item(item,1) if ret $game_party.gain_item(item, 1) if ret
end end
return ret return ret
end end
def getQuantity(item) def getQuantity(item)
ret=0 ret = 0
if $game_party.respond_to?("weapon_number") if $game_party.respond_to?("weapon_number")
case item case item
when RPG::Item when RPG::Item
ret=$game_party.item_number(item.id) ret = $game_party.item_number(item.id)
when RPG::Weapon when RPG::Weapon
ret=($game_party.weapon_number(item.id)) ret = ($game_party.weapon_number(item.id))
when RPG::Armor when RPG::Armor
ret=($game_party.armor_number(item.id)) ret = ($game_party.armor_number(item.id))
end end
else else
return $game_party.item_number(item) return $game_party.item_number(item)
@@ -200,7 +200,7 @@ class RpgxpMartAdapter
end end
def removeItem(item) def removeItem(item)
ret=(getQuantity(item)>0) ret = (getQuantity(item) > 0)
if $game_party.respond_to?("lose_weapon") if $game_party.respond_to?("lose_weapon")
case item case item
when RPG::Item when RPG::Item
@@ -211,7 +211,7 @@ class RpgxpMartAdapter
$game_party.lose_armor(item.id, 1) if ret $game_party.lose_armor(item.id, 1) if ret
end end
else else
$game_party.lose_item(item,1) if ret $game_party.lose_item(item, 1) if ret
end end
return ret return ret
end end
@@ -223,7 +223,7 @@ end
#=============================================================================== #===============================================================================
class BuyAdapter class BuyAdapter
def initialize(adapter) def initialize(adapter)
@adapter=adapter @adapter = adapter
end end
def getDisplayName(item) def getDisplayName(item)
@@ -231,7 +231,7 @@ class BuyAdapter
end end
def getDisplayPrice(item) def getDisplayPrice(item)
@adapter.getDisplayPrice(item,false) @adapter.getDisplayPrice(item, false)
end end
def isSelling? def isSelling?
@@ -243,7 +243,7 @@ end
class SellAdapter class SellAdapter
def initialize(adapter) def initialize(adapter)
@adapter=adapter @adapter = adapter
end end
def getDisplayName(item) def getDisplayName(item)
@@ -252,7 +252,7 @@ class SellAdapter
def getDisplayPrice(item) def getDisplayPrice(item)
if @adapter.showQuantity?(item) if @adapter.showQuantity?(item)
return sprintf("x%d",@adapter.getQuantity(item)) return sprintf("x%d", @adapter.getQuantity(item))
else else
return "" return ""
end end
@@ -269,41 +269,40 @@ end
# Pokémon Mart # Pokémon Mart
#=============================================================================== #===============================================================================
class Window_PokemonMart < Window_DrawableCommand class Window_PokemonMart < Window_DrawableCommand
def initialize(stock,adapter,x,y,width,height,viewport=nil) def initialize(stock, adapter, x, y, width, height, viewport = nil)
@stock=stock @stock = stock
@adapter=adapter @adapter = adapter
super(x,y,width,height,viewport) super(x, y, width, height, viewport)
@selarrow=AnimatedBitmap.new("Graphics/Pictures/martSel") @selarrow = AnimatedBitmap.new("Graphics/Pictures/martSel")
@baseColor=Color.new(88,88,80) @baseColor = Color.new(88,88,80)
@shadowColor=Color.new(168,184,184) @shadowColor = Color.new(168,184,184)
self.windowskin=nil self.windowskin = nil
end end
def itemCount def itemCount
return @stock.length+1 return @stock.length + 1
end end
def item def item
return self.index>=@stock.length ? 0 : @stock[self.index] return (self.index >= @stock.length) ? nil : @stock[self.index]
end end
def drawItem(index,count,rect) def drawItem(index, count, rect)
textpos=[] textpos = []
rect=drawCursor(index,rect) rect = drawCursor(index, rect)
ypos=rect.y ypos = rect.y
if index==count-1 if index == count-1
textpos.push([_INTL("CANCEL"),rect.x,ypos+2,false, textpos.push([_INTL("CANCEL"), rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
self.baseColor,self.shadowColor])
else else
item=@stock[index] item = @stock[index]
itemname=@adapter.getDisplayName(item) itemname = @adapter.getDisplayName(item)
qty=@adapter.getDisplayPrice(item) qty = @adapter.getDisplayPrice(item)
sizeQty=self.contents.text_size(qty).width sizeQty = self.contents.text_size(qty).width
xQty=rect.x+rect.width-sizeQty-2-16 xQty = rect.x + rect.width - sizeQty - 2 - 16
textpos.push([itemname,rect.x,ypos+2,false,self.baseColor,self.shadowColor]) textpos.push([itemname, rect.x, ypos + 2, false, self.baseColor, self.shadowColor])
textpos.push([qty,xQty,ypos+2,false,self.baseColor,self.shadowColor]) textpos.push([qty, xQty, ypos + 2, false, self.baseColor, self.shadowColor])
end end
pbDrawTextPositions(self.contents,textpos) pbDrawTextPositions(self.contents, textpos)
end end
end end
@@ -319,112 +318,112 @@ class PokemonMart_Scene
if @subscene if @subscene
@subscene.pbRefresh @subscene.pbRefresh
else else
itemwindow=@sprites["itemwindow"] itemwindow = @sprites["itemwindow"]
@sprites["icon"].item=itemwindow.item @sprites["icon"].item = itemwindow.item
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @sprites["itemtextwindow"].text =
@adapter.getDescription(itemwindow.item) (itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
itemwindow.refresh itemwindow.refresh
end end
@sprites["moneywindow"].text=_INTL("Money:\r\n<r>{1}",@adapter.getMoneyString) @sprites["moneywindow"].text = _INTL("Money:\r\n<r>{1}", @adapter.getMoneyString)
end end
def pbStartBuyOrSellScene(buying,stock,adapter) def pbStartBuyOrSellScene(buying, stock, adapter)
# Scroll right before showing screen # Scroll right before showing screen
pbScrollMap(6,5,5) pbScrollMap(6, 5, 5)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z=99999 @viewport.z = 99999
@stock=stock @stock = stock
@adapter=adapter @adapter = adapter
@sprites={} @sprites = {}
@sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"] = IconSprite.new(0, 0, @viewport)
@sprites["background"].setBitmap("Graphics/Pictures/martScreen") @sprites["background"].setBitmap("Graphics/Pictures/martScreen")
@sprites["icon"]=ItemIconSprite.new(36,Graphics.height-50,-1,@viewport) @sprites["icon"] = ItemIconSprite.new(36, Graphics.height - 50, nil, @viewport)
winAdapter=buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter) winAdapter = buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
@sprites["itemwindow"]=Window_PokemonMart.new(stock,winAdapter, @sprites["itemwindow"] = Window_PokemonMart.new(stock, winAdapter,
Graphics.width-316-16,12,330+16,Graphics.height-126) Graphics.width - 316 - 16, 12, 330 + 16, Graphics.height - 126)
@sprites["itemwindow"].viewport=@viewport @sprites["itemwindow"].viewport = @viewport
@sprites["itemwindow"].index=0 @sprites["itemwindow"].index = 0
@sprites["itemwindow"].refresh @sprites["itemwindow"].refresh
@sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("") @sprites["itemtextwindow"] = Window_UnformattedTextPokemon.new("")
pbPrepareWindow(@sprites["itemtextwindow"]) pbPrepareWindow(@sprites["itemtextwindow"])
@sprites["itemtextwindow"].x=64 @sprites["itemtextwindow"].x = 64
@sprites["itemtextwindow"].y=Graphics.height-96-16 @sprites["itemtextwindow"].y = Graphics.height - 96 - 16
@sprites["itemtextwindow"].width=Graphics.width-64 @sprites["itemtextwindow"].width = Graphics.width - 64
@sprites["itemtextwindow"].height=128 @sprites["itemtextwindow"].height = 128
@sprites["itemtextwindow"].baseColor=Color.new(248,248,248) @sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248)
@sprites["itemtextwindow"].shadowColor=Color.new(0,0,0) @sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0)
@sprites["itemtextwindow"].visible=true @sprites["itemtextwindow"].visible = true
@sprites["itemtextwindow"].viewport=@viewport @sprites["itemtextwindow"].viewport = @viewport
@sprites["itemtextwindow"].windowskin=nil @sprites["itemtextwindow"].windowskin = nil
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") @sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["helpwindow"]) pbPrepareWindow(@sprites["helpwindow"])
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
@sprites["helpwindow"].viewport=@viewport @sprites["helpwindow"].viewport = @viewport
pbBottomLeftLines(@sprites["helpwindow"],1) pbBottomLeftLines(@sprites["helpwindow"], 1)
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") @sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["moneywindow"]) pbPrepareWindow(@sprites["moneywindow"])
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin") @sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
@sprites["moneywindow"].visible=true @sprites["moneywindow"].visible = true
@sprites["moneywindow"].viewport=@viewport @sprites["moneywindow"].viewport = @viewport
@sprites["moneywindow"].x=0 @sprites["moneywindow"].x = 0
@sprites["moneywindow"].y=0 @sprites["moneywindow"].y = 0
@sprites["moneywindow"].width=190 @sprites["moneywindow"].width = 190
@sprites["moneywindow"].height=96 @sprites["moneywindow"].height = 96
@sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
@sprites["moneywindow"].shadowColor=Color.new(168,184,184) @sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
pbDeactivateWindows(@sprites) pbDeactivateWindows(@sprites)
@buying=buying @buying = buying
pbRefresh pbRefresh
Graphics.frame_reset Graphics.frame_reset
end end
def pbStartBuyScene(stock,adapter) def pbStartBuyScene(stock, adapter)
pbStartBuyOrSellScene(true,stock,adapter) pbStartBuyOrSellScene(true, stock, adapter)
end end
def pbStartSellScene(bag,adapter) def pbStartSellScene(bag, adapter)
if $PokemonBag if $PokemonBag
pbStartSellScene2(bag,adapter) pbStartSellScene2(bag, adapter)
else else
pbStartBuyOrSellScene(false,bag,adapter) pbStartBuyOrSellScene(false, bag, adapter)
end end
end end
def pbStartSellScene2(bag,adapter) def pbStartSellScene2(bag, adapter)
@subscene=PokemonBag_Scene.new @subscene = PokemonBag_Scene.new
@adapter=adapter @adapter = adapter
@viewport2=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport2.z=99999 @viewport2.z = 99999
numFrames = Graphics.frame_rate*4/10 numFrames = Graphics.frame_rate * 4 / 10
alphaDiff = (255.0/numFrames).ceil alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames for j in 0..numFrames
col=Color.new(0,0,0,j*alphaDiff) col = Color.new(0, 0, 0, j * alphaDiff)
@viewport2.color=col @viewport2.color = col
Graphics.update Graphics.update
Input.update Input.update
end end
@subscene.pbStartScene(bag) @subscene.pbStartScene(bag)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z=99999 @viewport.z = 99999
@sprites={} @sprites = {}
@sprites["helpwindow"]=Window_AdvancedTextPokemon.new("") @sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["helpwindow"]) pbPrepareWindow(@sprites["helpwindow"])
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
@sprites["helpwindow"].viewport=@viewport @sprites["helpwindow"].viewport = @viewport
pbBottomLeftLines(@sprites["helpwindow"],1) pbBottomLeftLines(@sprites["helpwindow"], 1)
@sprites["moneywindow"]=Window_AdvancedTextPokemon.new("") @sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
pbPrepareWindow(@sprites["moneywindow"]) pbPrepareWindow(@sprites["moneywindow"])
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin") @sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
@sprites["moneywindow"].visible=false @sprites["moneywindow"].visible = false
@sprites["moneywindow"].viewport=@viewport @sprites["moneywindow"].viewport = @viewport
@sprites["moneywindow"].x=0 @sprites["moneywindow"].x = 0
@sprites["moneywindow"].y=0 @sprites["moneywindow"].y = 0
@sprites["moneywindow"].width=186 @sprites["moneywindow"].width = 186
@sprites["moneywindow"].height=96 @sprites["moneywindow"].height = 96
@sprites["moneywindow"].baseColor=Color.new(88,88,80) @sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
@sprites["moneywindow"].shadowColor=Color.new(168,184,184) @sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
pbDeactivateWindows(@sprites) pbDeactivateWindows(@sprites)
@buying=false @buying = false
pbRefresh pbRefresh
end end
@@ -432,82 +431,78 @@ class PokemonMart_Scene
pbDisposeSpriteHash(@sprites) pbDisposeSpriteHash(@sprites)
@viewport.dispose @viewport.dispose
# Scroll left after showing screen # Scroll left after showing screen
pbScrollMap(4,5,5) pbScrollMap(4, 5, 5)
end end
def pbEndSellScene def pbEndSellScene
if @subscene @subscene.pbEndScene if @subscene
@subscene.pbEndScene
end
pbDisposeSpriteHash(@sprites) pbDisposeSpriteHash(@sprites)
if @viewport2 if @viewport2
numFrames = Graphics.frame_rate*4/10 numFrames = Graphics.frame_rate * 4 / 10
alphaDiff = (255.0/numFrames).ceil alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames for j in 0..numFrames
col=Color.new(0,0,0,(numFrames-j)*alphaDiff) col = Color.new(0, 0, 0, (numFrames - j) * alphaDiff)
@viewport2.color=col @viewport2.color = col
Graphics.update Graphics.update
Input.update Input.update
end end
@viewport2.dispose @viewport2.dispose
end end
@viewport.dispose @viewport.dispose
if !@subscene pbScrollMap(4, 5, 5) if !@subscene
pbScrollMap(4,5,5)
end
end end
def pbPrepareWindow(window) def pbPrepareWindow(window)
window.visible=true window.visible = true
window.letterbyletter=false window.letterbyletter = false
end end
def pbShowMoney def pbShowMoney
pbRefresh pbRefresh
@sprites["moneywindow"].visible=true @sprites["moneywindow"].visible = true
end end
def pbHideMoney def pbHideMoney
pbRefresh pbRefresh
@sprites["moneywindow"].visible=false @sprites["moneywindow"].visible = false
end end
def pbDisplay(msg,brief=false) def pbDisplay(msg, brief = false)
cw=@sprites["helpwindow"] cw = @sprites["helpwindow"]
cw.letterbyletter=true cw.letterbyletter = true
cw.text=msg cw.text = msg
pbBottomLeftLines(cw,2) pbBottomLeftLines(cw, 2)
cw.visible=true cw.visible = true
i=0 i = 0
pbPlayDecisionSE() pbPlayDecisionSE
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
self.update self.update
if !cw.busy? if !cw.busy?
return if brief return if brief
pbRefresh if i==0 pbRefresh if i == 0
end end
if Input.trigger?(Input::C) && cw.busy? if Input.trigger?(Input::C) && cw.busy?
cw.resume cw.resume
end end
return if i>=Graphics.frame_rate*3/2 return if i >= Graphics.frame_rate * 3 / 2
i+=1 if !cw.busy? i += 1 if !cw.busy?
end end
end end
def pbDisplayPaused(msg) def pbDisplayPaused(msg)
cw=@sprites["helpwindow"] cw = @sprites["helpwindow"]
cw.letterbyletter=true cw.letterbyletter = true
cw.text=msg cw.text = msg
pbBottomLeftLines(cw,2) pbBottomLeftLines(cw, 2)
cw.visible=true cw.visible = true
yielded = false yielded = false
pbPlayDecisionSE() pbPlayDecisionSE
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
wasbusy=cw.busy? wasbusy = cw.busy?
self.update self.update
if !cw.busy? && !yielded if !cw.busy? && !yielded
yield if block_given? # For playing SE as soon as the message is all shown yield if block_given? # For playing SE as soon as the message is all shown
@@ -515,73 +510,73 @@ class PokemonMart_Scene
end end
pbRefresh if !cw.busy? && wasbusy pbRefresh if !cw.busy? && wasbusy
if Input.trigger?(Input::C) && cw.resume && !cw.busy? if Input.trigger?(Input::C) && cw.resume && !cw.busy?
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
return return
end end
end end
end end
def pbConfirm(msg) def pbConfirm(msg)
dw=@sprites["helpwindow"] dw = @sprites["helpwindow"]
dw.letterbyletter=true dw.letterbyletter = true
dw.text=msg dw.text = msg
dw.visible=true dw.visible = true
pbBottomLeftLines(dw,2) pbBottomLeftLines(dw, 2)
commands=[_INTL("Yes"),_INTL("No")] commands = [_INTL("Yes"), _INTL("No")]
cw = Window_CommandPokemon.new(commands) cw = Window_CommandPokemon.new(commands)
cw.viewport=@viewport cw.viewport = @viewport
pbBottomRight(cw) pbBottomRight(cw)
cw.y-=dw.height cw.y -= dw.height
cw.index=0 cw.index = 0
pbPlayDecisionSE() pbPlayDecisionSE
loop do loop do
cw.visible=!dw.busy? cw.visible = !dw.busy?
Graphics.update Graphics.update
Input.update Input.update
cw.update cw.update
self.update self.update
if Input.trigger?(Input::B) && dw.resume && !dw.busy? if Input.trigger?(Input::B) && dw.resume && !dw.busy?
cw.dispose cw.dispose
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
return false return false
end end
if Input.trigger?(Input::C) && dw.resume && !dw.busy? if Input.trigger?(Input::C) && dw.resume && !dw.busy?
cw.dispose cw.dispose
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
return (cw.index==0)?true:false return (cw.index == 0)
end end
end end
end end
def pbChooseNumber(helptext,item,maximum) def pbChooseNumber(helptext,item,maximum)
curnumber=1 curnumber = 1
ret=0 ret = 0
helpwindow=@sprites["helpwindow"] helpwindow = @sprites["helpwindow"]
itemprice=@adapter.getPrice(item,!@buying) itemprice = @adapter.getPrice(item, !@buying)
itemprice/=2 if !@buying itemprice /= 2 if !@buying
pbDisplay(helptext,true) pbDisplay(helptext, true)
using(numwindow=Window_AdvancedTextPokemon.new("")) { # Showing number of items using (numwindow = Window_AdvancedTextPokemon.new("")) { # Showing number of items
qty=@adapter.getQuantity(item) qty = @adapter.getQuantity(item)
using(inbagwindow=Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag using (inbagwindow = Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
pbPrepareWindow(numwindow) pbPrepareWindow(numwindow)
pbPrepareWindow(inbagwindow) pbPrepareWindow(inbagwindow)
numwindow.viewport=@viewport numwindow.viewport = @viewport
numwindow.width=224 numwindow.width = 224
numwindow.height=64 numwindow.height = 64
numwindow.baseColor=Color.new(88,88,80) numwindow.baseColor = Color.new(88, 88, 80)
numwindow.shadowColor=Color.new(168,184,184) numwindow.shadowColor = Color.new(168, 184, 184)
inbagwindow.visible=@buying inbagwindow.visible = @buying
inbagwindow.viewport=@viewport inbagwindow.viewport = @viewport
inbagwindow.width=190 inbagwindow.width = 190
inbagwindow.height=64 inbagwindow.height = 64
inbagwindow.baseColor=Color.new(88,88,80) inbagwindow.baseColor = Color.new(88, 88, 80)
inbagwindow.shadowColor=Color.new(168,184,184) inbagwindow.shadowColor = Color.new(168, 184, 184)
inbagwindow.text=_INTL("In Bag:<r>{1} ",qty) inbagwindow.text = _INTL("In Bag:<r>{1} ", qty)
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted) numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
pbBottomRight(numwindow) pbBottomRight(numwindow)
numwindow.y-=helpwindow.height numwindow.y -= helpwindow.height
pbBottomLeft(inbagwindow) pbBottomLeft(inbagwindow)
inbagwindow.y-=helpwindow.height inbagwindow.y -= helpwindow.height
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
@@ -589,65 +584,65 @@ class PokemonMart_Scene
inbagwindow.update inbagwindow.update
self.update self.update
if Input.repeat?(Input::LEFT) if Input.repeat?(Input::LEFT)
pbPlayCursorSE() pbPlayCursorSE
curnumber-=10 curnumber -= 10
curnumber=1 if curnumber<1 curnumber = 1 if curnumber < 1
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted) numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::RIGHT) elsif Input.repeat?(Input::RIGHT)
pbPlayCursorSE() pbPlayCursorSE
curnumber+=10 curnumber += 10
curnumber=maximum if curnumber>maximum curnumber = maximum if curnumber > maximum
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted) numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::UP) elsif Input.repeat?(Input::UP)
pbPlayCursorSE() pbPlayCursorSE
curnumber+=1 curnumber += 1
curnumber=1 if curnumber>maximum curnumber = 1 if curnumber > maximum
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted) numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.repeat?(Input::DOWN) elsif Input.repeat?(Input::DOWN)
pbPlayCursorSE() pbPlayCursorSE
curnumber-=1 curnumber -= 1
curnumber=maximum if curnumber<1 curnumber = maximum if curnumber < 1
numwindow.text=_INTL("x{1}<r>$ {2}",curnumber,(curnumber*itemprice).to_s_formatted) numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
pbPlayDecisionSE() pbPlayDecisionSE
ret=curnumber ret = curnumber
break break
elsif Input.trigger?(Input::B) elsif Input.trigger?(Input::B)
pbPlayCancelSE() pbPlayCancelSE
ret=0 ret = 0
break break
end end
end end
} }
} }
helpwindow.visible=false helpwindow.visible = false
return ret return ret
end end
def pbChooseBuyItem def pbChooseBuyItem
itemwindow=@sprites["itemwindow"] itemwindow = @sprites["itemwindow"]
@sprites["helpwindow"].visible=false @sprites["helpwindow"].visible = false
pbActivateWindow(@sprites,"itemwindow") { pbActivateWindow(@sprites, "itemwindow") {
pbRefresh pbRefresh
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
olditem=itemwindow.item olditem = itemwindow.item
self.update self.update
if itemwindow.item!=olditem if itemwindow.item != olditem
@sprites["icon"].item=itemwindow.item @sprites["icon"].item = itemwindow.item
@sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Quit shopping.") : @sprites["itemtextwindow"].text =
@adapter.getDescription(itemwindow.item) (itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
end end
if Input.trigger?(Input::B) if Input.trigger?(Input::B)
pbPlayCloseMenuSE pbPlayCloseMenuSE
return 0 return nil
elsif Input.trigger?(Input::C) elsif Input.trigger?(Input::C)
if itemwindow.index<@stock.length if itemwindow.index < @stock.length
pbRefresh pbRefresh
return @stock[itemwindow.index] return @stock[itemwindow.index]
else else
return 0 return nil
end end
end end
end end
@@ -688,18 +683,18 @@ class PokemonMartScreen
def pbBuyScreen def pbBuyScreen
@scene.pbStartBuyScene(@stock,@adapter) @scene.pbStartBuyScene(@stock,@adapter)
item=0 item=nil
loop do loop do
item=@scene.pbChooseBuyItem item=@scene.pbChooseBuyItem
break if !item
quantity=0 quantity=0
break if item==0
itemname=@adapter.getDisplayName(item) itemname=@adapter.getDisplayName(item)
price=@adapter.getPrice(item) price=@adapter.getPrice(item)
if @adapter.getMoney<price if @adapter.getMoney<price
pbDisplayPaused(_INTL("You don't have enough money.")) pbDisplayPaused(_INTL("You don't have enough money."))
next next
end end
if pbIsImportantItem?(item) if GameData::Item.get(item).is_important?
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?", if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
itemname,price.to_s_formatted)) itemname,price.to_s_formatted))
next next
@@ -723,9 +718,7 @@ class PokemonMartScreen
end end
added=0 added=0
quantity.times do quantity.times do
if !@adapter.addItem(item) break if !@adapter.addItem(item)
break
end
added+=1 added+=1
end end
if added!=quantity if added!=quantity
@@ -738,15 +731,15 @@ class PokemonMartScreen
else else
@adapter.setMoney(@adapter.getMoney-price) @adapter.setMoney(@adapter.getMoney-price)
for i in 0...@stock.length 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 @stock[i]=nil
end end
end end
@stock.compact! @stock.compact!
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") } pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
if $PokemonBag if $PokemonBag
if quantity>=10 && pbIsPokeBall?(item) && hasConst?(PBItems,:PREMIERBALL) if quantity>=10 && GameData::Item.get(item).is_poke_ball? && GameData::Item.exists?(:PREMIERBALL)
if @adapter.addItem(getConst(PBItems,:PREMIERBALL)) if @adapter.addItem(GameData::Item.get(:PREMIERBALL))
pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too.")) pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too."))
end end
end end
@@ -760,7 +753,7 @@ class PokemonMartScreen
item=@scene.pbStartSellScene(@adapter.getInventory,@adapter) item=@scene.pbStartSellScene(@adapter.getInventory,@adapter)
loop do loop do
item=@scene.pbChooseSellItem item=@scene.pbChooseSellItem
break if item==0 break if !item
itemname=@adapter.getDisplayName(item) itemname=@adapter.getDisplayName(item)
price=@adapter.getPrice(item,true) price=@adapter.getPrice(item,true)
if !@adapter.canSell?(item) if !@adapter.canSell?(item)
@@ -798,11 +791,8 @@ end
def pbPokemonMart(stock,speech=nil,cantsell=false) def pbPokemonMart(stock,speech=nil,cantsell=false)
for i in 0...stock.length for i in 0...stock.length
stock[i] = getID(PBItems,stock[i]) stock[i] = GameData::Item.get(stock[i]).id
if !stock[i] || stock[i]==0 || stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i])
(pbIsImportantItem?(stock[i]) && $PokemonBag.pbHasItem?(stock[i]))
stock[i] = nil
end
end end
stock.compact! stock.compact!
commands = [] commands = []
@@ -880,7 +870,7 @@ class Interpreter
end end
def setPrice(item,buyprice=-1,sellprice=-1) 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] = [-1,-1] if !$game_temp.mart_prices[item]
$game_temp.mart_prices[item][0] = buyprice if buyprice>0 $game_temp.mart_prices[item][0] = buyprice if buyprice>0
if sellprice>=0 # 0=can't sell if sellprice>=0 # 0=can't sell
+22 -19
View File
@@ -61,7 +61,8 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
params.setDefaultValue(type) params.setDefaultValue(type)
params.setCancelValue(0) params.setCancelValue(0)
loop do 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 if newtype==0
return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
else else
@@ -230,17 +231,17 @@ def pbManageMysteryGifts
end end
end end
def pbRefreshMGCommands(master,online) def pbRefreshMGCommands(master, online)
commands=[] commands = []
for gift in master for gift in master
itemname="BLANK" itemname = "BLANK"
if gift[1]==0 if gift[1] == 0
itemname=PBSpecies.getName(gift[2].species) itemname = PBSpecies.getName(gift[2].species)
elsif gift[1]>0 elsif gift[1] > 0
itemname=PBItems.getName(gift[2])+sprintf(" x%d",gift[1]) itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1])
end end
ontext=["[ ]","[X]"][(online.include?(gift[0])) ? 1 : 0] ontext = ["[ ]", "[X]"][(online.include?(gift[0])) ? 1 : 0]
commands.push(_INTL("{1} {2}: {3} ({4})",ontext,gift[0],gift[3],itemname)) commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname))
end end
commands.push(_INTL("Export selected to file")) commands.push(_INTL("Export selected to file"))
commands.push(_INTL("Cancel")) commands.push(_INTL("Cancel"))
@@ -378,7 +379,7 @@ def pbReceiveMysteryGift(id)
return false return false
end end
gift=$Trainer.mysterygift[index] gift=$Trainer.mysterygift[index]
if gift[1]==0 if gift[1]==0 # Pokémon
pID=rand(256) pID=rand(256)
pID|=rand(256)<<8 pID|=rand(256)<<8
pID|=rand(256)<<16 pID|=rand(256)<<16
@@ -401,15 +402,17 @@ def pbReceiveMysteryGift(id)
$Trainer.mysterygift[index]=[id] $Trainer.mysterygift[index]=[id]
return true return true
end end
elsif gift[1]>0 elsif gift[1]>0 # Item
if $PokemonBag.pbCanStore?(gift[2],gift[1]) item=gift[2]
$PokemonBag.pbStoreItem(gift[2],gift[1]) qty=gift[1]
item=gift[2]; qty=gift[1] if $PokemonBag.pbCanStore?(item,qty)
itemname=(qty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) $PokemonBag.pbStoreItem(item,qty)
if isConst?(item,PBItems,:LEFTOVERS) 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)) pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
elsif pbIsMachine?(item) # TM or HM 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(pbGetMachine(item)))) pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,PBMoves.getName(itm.move)))
elsif qty>1 elsif qty>1
pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname)) pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname))
elsif itemname.starts_with_vowel? elsif itemname.starts_with_vowel?
@@ -627,7 +627,7 @@ class TriadScreen
end end
def pbQuantity(items,item) def pbQuantity(items,item)
return ItemStorageHelper.pbQuantity(items,$PokemonGlobal.triads.maxSize,item) return ItemStorageHelper.pbQuantity(items, item)
end end
def pbAdd(items,item) def pbAdd(items,item)
@@ -635,8 +635,8 @@ class TriadScreen
$PokemonGlobal.triads.maxPerSlot,item,1) $PokemonGlobal.triads.maxPerSlot,item,1)
end end
def pbSubtract(items,item) def pbSubtract(items, item)
return ItemStorageHelper.pbDeleteItem(items,$PokemonGlobal.triads.maxSize,item,1) return ItemStorageHelper.pbDeleteItem(items, item, 1)
end end
def flipBoard(x,y,attackerParam=nil,recurse=false) def flipBoard(x,y,attackerParam=nil,recurse=false)
@@ -1041,7 +1041,7 @@ class TriadStorage
end end
def pbQuantity(item) def pbQuantity(item)
return ItemStorageHelper.pbQuantity(@items,self.maxSize,item) return ItemStorageHelper.pbQuantity(@items, item)
end end
def pbCanStore?(item,qty=1) def pbCanStore?(item,qty=1)
@@ -1052,8 +1052,8 @@ class TriadStorage
return ItemStorageHelper.pbStoreItem(@items,self.maxSize,self.maxPerSlot,item,qty) return ItemStorageHelper.pbStoreItem(@items,self.maxSize,self.maxPerSlot,item,qty)
end end
def pbDeleteItem(item,qty=1) def pbDeleteItem(item, qty = 1)
return ItemStorageHelper.pbDeleteItem(@items,self.maxSize,item,qty) return ItemStorageHelper.pbDeleteItem(@items, item, qty)
end end
end end
@@ -388,7 +388,7 @@ end
def pbSlotMachine(difficulty=1) 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.")) pbMessage(_INTL("It's a Slot Machine."))
elsif $PokemonGlobal.coins==0 elsif $PokemonGlobal.coins==0
pbMessage(_INTL("You don't have any Coins to play!")) pbMessage(_INTL("You don't have any Coins to play!"))
@@ -614,7 +614,7 @@ end
def pbVoltorbFlip 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.")) pbMessage(_INTL("You can't play unless you have a Coin Case."))
elsif $PokemonGlobal.coins==MAX_COINS elsif $PokemonGlobal.coins==MAX_COINS
pbMessage(_INTL("Your Coin Case is full!")) pbMessage(_INTL("Your Coin Case is full!"))
@@ -498,7 +498,7 @@ class MiningGameScene
revealeditems.dispose revealeditems.dispose
for index in revealed for index in revealed
@items[index][3]=true @items[index][3]=true
item=getConst(PBItems,ITEMS[@items[index][0]][0]) item=ITEMS[@items[index][0]][0]
@itemswon.push(item) @itemswon.push(item)
end end
end end
@@ -581,10 +581,10 @@ class MiningGameScene
for i in @itemswon for i in @itemswon
if $PokemonBag.pbStoreItem(i) if $PokemonBag.pbStoreItem(i)
pbMessage(_INTL("One {1} was obtained.\\se[Mining item get]\\wtnp[30]", pbMessage(_INTL("One {1} was obtained.\\se[Mining item get]\\wtnp[30]",
PBItems.getName(i))) GameData::Item.get(i).name))
else else
pbMessage(_INTL("One {1} was found, but you have no room for it.", pbMessage(_INTL("One {1} was found, but you have no room for it.",
PBItems.getName(i))) GameData::Item.get(i).name))
end end
end end
end end
@@ -18,31 +18,17 @@ class PBPokemon
attr_accessor :ev attr_accessor :ev
def initialize(species,item,nature,move1,move2,move3,move4,ev) def initialize(species,item,nature,move1,move2,move3,move4,ev)
@species=species @species = species
@item=item ? item : 0 itm = GameData::Item.try_get(item)
@nature=nature @item = itm ? itm.id : nil
@move1=move1 ? move1 : 0 @nature = nature
@move2=move2 ? move2 : 0 @move1 = move1 ? move1 : 0
@move3=move3 ? move3 : 0 @move2 = move2 ? move2 : 0
@move4=move4 ? move4 : 0 @move3 = move3 ? move3 : 0
@ev=ev @move4 = move4 ? move4 : 0
@ev = ev
end 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) def self.fromInspected(str)
insp=str.gsub(/^\s+/,"").gsub(/\s+$/,"") insp=str.gsub(/^\s+/,"").gsub(/\s+$/,"")
pieces=insp.split(/\s*;\s*/) pieces=insp.split(/\s*;\s*/)
@@ -50,10 +36,7 @@ class PBPokemon
if (PBSpecies.const_defined?(pieces[0]) rescue false) if (PBSpecies.const_defined?(pieces[0]) rescue false)
species=PBSpecies.const_get(pieces[0]) species=PBSpecies.const_get(pieces[0])
end end
item=0 item = (GameData::Item.exists?(pieces[1])) ? GameData::Item.get(pieces[1]).id : nil
if (PBItems.const_defined?(pieces[1]) rescue false)
item=PBItems.const_get(pieces[1])
end
nature=PBNatures.const_get(pieces[2]) nature=PBNatures.const_get(pieces[2])
ev=pieces[3].split(/\s*,\s*/) ev=pieces[3].split(/\s*,\s*/)
evvalue=0 evvalue=0
@@ -87,33 +70,11 @@ class PBPokemon
evvalue|=0x08 if pokemon.ev[3]>60 evvalue|=0x08 if pokemon.ev[3]>60
evvalue|=0x10 if pokemon.ev[4]>60 evvalue|=0x10 if pokemon.ev[4]>60
evvalue|=0x20 if pokemon.ev[5]>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[0].id,pokemon.moves[1].id,pokemon.moves[2].id,
pokemon.moves[3].id,evvalue) pokemon.moves[3].id,evvalue)
end 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) def self.constFromStr(mod,str)
maxconst=0 maxconst=0
for constant in mod.constants for constant in mod.constants
@@ -134,7 +95,7 @@ class PBPokemon
def self.fromstring(str) def self.fromstring(str)
s=str.split(/\s*,\s*/) s=str.split(/\s*,\s*/)
species=self.constFromStr(PBSpecies,s[1]) species=self.constFromStr(PBSpecies,s[1])
item=self.constFromStr(PBItems,s[2]) item=s[2].to_sym
nature=self.constFromStr(PBNatures,s[3]) nature=self.constFromStr(PBNatures,s[3])
move1=self.constFromStr(PBMoves,s[4]) move1=self.constFromStr(PBMoves,s[4])
move2=(s.length>=12) ? self.constFromStr(PBMoves,s[5]) : 0 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) return self.new(species,item,nature,move1,move2,move3,move4,ev)
end 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) def convertMove(move)
if isConst?(move,PBMoves,:RETURN) && hasConst?(PBMoves,:FRUSTRATION) if isConst?(move,PBMoves,:RETURN) && hasConst?(PBMoves,:FRUSTRATION)
move=getConst(PBMoves,:FRUSTRATION) move=getConst(PBMoves,:FRUSTRATION)
@@ -939,8 +937,8 @@ def pbOrganizedBattleEx(opponent,challengedata,endspeech,endspeechwin)
# Remember original data, to be restored after battle # Remember original data, to be restored after battle
challengedata = PokemonChallengeRules.new if !challengedata challengedata = PokemonChallengeRules.new if !challengedata
oldlevels = challengedata.adjustLevels($Trainer.party,opponent.party) oldlevels = challengedata.adjustLevels($Trainer.party,opponent.party)
olditems = $Trainer.party.transform { |p| p.item } olditems = $Trainer.party.transform { |p| p.item_id }
olditems2 = opponent.party.transform { |p| p.item } olditems2 = opponent.party.transform { |p| p.item_id }
# Create the battle scene (the visual side of it) # Create the battle scene (the visual side of it)
scene = pbNewBattleScene scene = pbNewBattleScene
# Create the battle class (the mechanics side of it) # Create the battle class (the mechanics side of it)
@@ -333,15 +333,12 @@ class BannedItemRestriction
end end
def isSpecies?(species,specieslist) def isSpecies?(species,specieslist)
for s in specieslist return specieslist.any? { |s| species == s }
return true if isConst?(species,PBItems,s)
end
return false
end end
def isValid?(pokemon) def isValid?(pokemon)
count=0 count=0
if pokemon.item!=0 && isSpecies?(pokemon.item,@specieslist) if pokemon.item && isSpecies?(pokemon.item,@specieslist)
count+=1 count+=1
end end
return count==0 return count==0
@@ -72,13 +72,8 @@ def pbGetLegalMoves2(species,maxlevel)
tmData=pbLoadSpeciesTMData tmData=pbLoadSpeciesTMData
if !$tmMoves if !$tmMoves
$tmMoves=[] $tmMoves=[]
itemData=pbLoadItemsData GameData::Item.each do |i|
for i in 0...itemData.length $tmMoves.push(i.move) if i.move && tmData[i.move]
next if !itemData[i]
atk=itemData[i][8]
next if !atk || atk==0
next if !tmData[atk]
$tmMoves.push(atk)
end end
end end
for atk in $tmMoves for atk in $tmMoves
@@ -326,7 +321,7 @@ def pbRandomPokemonFromRule(rule,trainer)
end end
break break
end end
item=0 item = nil
$legalMoves=[] if level!=$legalMovesLevel $legalMoves=[] if level!=$legalMovesLevel
$legalMoves[species]=pbGetLegalMoves2(species,level) if !$legalMoves[species] $legalMoves[species]=pbGetLegalMoves2(species,level) if !$legalMoves[species]
itemlist=[ itemlist=[
@@ -343,13 +338,12 @@ def pbRandomPokemonFromRule(rule,trainer)
# Most used: Leftovers, Life Orb, Choice Band, Choice Scarf, Focus Sash # Most used: Leftovers, Life Orb, Choice Band, Choice Scarf, Focus Sash
loop do loop do
if rand(40)==0 if rand(40)==0
item=getID(PBItems,:LEFTOVERS) item = :LEFTOVERS
break break
end end
itemsym=itemlist[rand(itemlist.length)] item = itemlist[rand(itemlist.length)]
item=getID(PBItems,itemsym) next if !item
next if item==0 case item
case itemsym
when :LIGHTBALL when :LIGHTBALL
next if !isConst?(species,PBSpecies,:PIKACHU) next if !isConst?(species,PBSpecies,:PIKACHU)
when :SHEDSHELL when :SHEDSHELL
@@ -384,27 +378,24 @@ def pbRandomPokemonFromRule(rule,trainer)
next if !isConst?(species,PBSpecies,:CUBONE) && next if !isConst?(species,PBSpecies,:CUBONE) &&
!isConst?(species,PBSpecies,:MAROWAK) !isConst?(species,PBSpecies,:MAROWAK)
end end
if itemsym==:LIECHIBERRY && (ev&0x02)==0 if item == :LIECHIBERRY && (ev&0x02)==0
next if rand(2)==0 next if rand(2)==0
ev|=0x02 ev|=0x02
end end
if itemsym==:SALACBERRY && (ev&0x08)==0 if item == :SALACBERRY && (ev&0x08)==0
next if rand(2)==0 next if rand(2)==0
ev|=0x08 ev|=0x08
end end
if itemsym==:PETAYABERRY && (ev&0x10)==0 if item == :PETAYABERRY && (ev&0x10)==0
next if rand(2)==0 next if rand(2)==0
ev|=0x10 ev|=0x10
end end
break break
end end
if level<10 if level < 10 && GameData::Item.exists?(:ORANBERRY)
item=(getConst(PBItems,:ORANBERRY) || item) if rand(40)==0 || item = :ORANBERRY if rand(40) == 0 || item == :SITRUSBERRY
isConst?(item,PBItems,:SITRUSBERRY) elsif level > 20 && GameData::Item.exists?(:SITRUSBERRY)
end item = :SITRUSBERRY if rand(40) == 0 || item == :ORANBERRY
if level>20
item=(getConst(PBItems,:SITRUSBERRY) || item) if rand(40)==0 ||
isConst?(item,PBItems,:ORANBERRY)
end end
moves=$legalMoves[species] moves=$legalMoves[species]
sketch=false sketch=false
@@ -483,9 +474,7 @@ def pbRandomPokemonFromRule(rule,trainer)
ev|=0x10 if rand(10)<8 # Emphasize Special Attack ev|=0x10 if rand(10)<8 # Emphasize Special Attack
ev&=~0x02 if rand(10)<8 # Deemphasize Attack ev&=~0x02 if rand(10)<8 # Deemphasize Attack
end end
if !hasNormal && isConst?(item,PBItems,:SILKSCARF) item = :LEFTOVERS if !hasNormal && item == :SILKSCARF
item=getID(PBItems,:LEFTOVERS)
end
moves=newmoves moves=newmoves
break break
end end
@@ -493,33 +482,31 @@ def pbRandomPokemonFromRule(rule,trainer)
for i in 0...4 for i in 0...4
moves[i]=0 if !moves[i] moves[i]=0 if !moves[i]
end end
if isConst?(item,PBItems,:LIGHTCLAY) && if item == :LIGHTCLAY &&
!moves.include?((getConst(PBMoves,:LIGHTSCREEN) || -1)) && !moves.include?((getConst(PBMoves,:LIGHTSCREEN) || -1)) &&
!moves.include?((getConst(PBMoves,:REFLECT) || -1)) !moves.include?((getConst(PBMoves,:REFLECT) || -1))
item=getID(PBItems,:LEFTOVERS) item = :LEFTOVERS
end end
if isConst?(item,PBItems,:BLACKSLUDGE) if item == :BLACKSLUDGE
type1 = pbGetSpeciesData(species,0,SpeciesData::TYPE1) type1 = pbGetSpeciesData(species,0,SpeciesData::TYPE1)
type2 = pbGetSpeciesData(species,0,SpeciesData::TYPE2) || type1 type2 = pbGetSpeciesData(species,0,SpeciesData::TYPE2) || type1
if !isConst?(type1,PBTypes,:POISON) && !isConst?(type2,PBTypes,:POISON) if !isConst?(type1,PBTypes,:POISON) && !isConst?(type2,PBTypes,:POISON)
item=getID(PBItems,:LEFTOVERS) item = :LEFTOVERS
end end
end end
if isConst?(item,PBItems,:HEATROCK) && if item == :HEATROCK && !moves.include?((getConst(PBMoves,:SUNNYDAY) || -1))
!moves.include?((getConst(PBMoves,:SUNNYDAY) || -1)) item = :LEFTOVERS
item=getID(PBItems,:LEFTOVERS)
end end
if isConst?(item,PBItems,:DAMPROCK) && if item == :DAMPROCK && !moves.include?((getConst(PBMoves,:RAINDANCE) || -1))
!moves.include?((getConst(PBMoves,:RAINDANCE) || -1)) item = :LEFTOVERS
item=getID(PBItems,:LEFTOVERS)
end end
if moves.include?((getConst(PBMoves,:REST) || -1)) if moves.include?((getConst(PBMoves,:REST) || -1))
item=getID(PBItems,:LUMBERRY) if rand(3)==0 item = :LUMBERRY if rand(3)==0
item=getID(PBItems,:CHESTOBERRY) if rand(4)==0 item = :CHESTOBERRY if rand(4)==0
end end
pk=PBPokemon.new(species,item,nature,moves[0],moves[1],moves[2],moves[3],ev) pk = PBPokemon.new(species, item, nature, moves[0], moves[1], moves[2], moves[3], ev)
pkmn=pk.createPokemon(level,31,trainer) pkmn = pk.createPokemon(level, 31, trainer)
i+=1 i += 1
break if rule.ruleset.isPokemonValid?(pkmn) break if rule.ruleset.isPokemonValid?(pkmn)
end end
return pkmn return pkmn
@@ -874,7 +861,7 @@ def pbDecideWinnerScore(party0,party1,rating)
end end
basestatsum=baseStatTotal(party0[i].species) basestatsum=baseStatTotal(party0[i].species)
score+=basestatsum/10 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 end
score+=rating+rand(32) score+=rating+rand(32)
return score return score
@@ -913,7 +900,7 @@ def pbRuledBattle(team1,team2,rule)
p.level=level p.level=level
p.calcStats p.calcStats
end end
items1[i]=p.item items1[i]=p.item_id
trainer1.party.push(p) trainer1.party.push(p)
end end
team2.each_with_index do |p,i| team2.each_with_index do |p,i|
@@ -922,7 +909,7 @@ def pbRuledBattle(team1,team2,rule)
p.level=level p.level=level
p.calcStats p.calcStats
end end
items2[i]=p.item items2[i]=p.item_id
trainer2.party.push(p) trainer2.party.push(p)
end end
scene=PokeBattle_DebugSceneNoLogging.new scene=PokeBattle_DebugSceneNoLogging.new
@@ -77,6 +77,8 @@ def pbSetUpSystem
begin begin
consts = pbSafeLoad("Data/Constants.rxdata") consts = pbSafeLoad("Data/Constants.rxdata")
consts = [] if !consts consts = [] if !consts
GameData::Ability.load
GameData::Item.load
rescue rescue
consts = [] consts = []
end end
@@ -259,18 +259,17 @@ end
#=============================================================================== #===============================================================================
# Load item icons # Load item icons
# TODO: Put these methods into GameData::Item.
#=============================================================================== #===============================================================================
def pbItemIconFile(item) def pbItemIconFile(item)
return nil if !item
bitmapFileName = nil bitmapFileName = nil
if item==0 if item
bitmapFileName = sprintf("Graphics/Icons/itemBack") itm = GameData::Item.get(item)
else bitmapFileName = sprintf("Graphics/Icons/item%s",itm.id.to_s) rescue nil
bitmapFileName = sprintf("Graphics/Icons/item%s",getConstantName(PBItems,item)) rescue nil
if !pbResolveBitmap(bitmapFileName) if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Icons/item%03d",item) bitmapFileName = sprintf("Graphics/Icons/item%03d",itm.id_number)
if !pbResolveBitmap(bitmapFileName) && pbIsMachine?(item) if !pbResolveBitmap(bitmapFileName) && itm.is_machine?
move = pbGetMachine(item) move = itm.move
type = pbGetMoveData(move,MoveData::TYPE) type = pbGetMoveData(move,MoveData::TYPE)
bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil bitmapFileName = sprintf("Graphics/Icons/itemMachine%s",getConstantName(PBTypes,type)) rescue nil
if !pbResolveBitmap(bitmapFileName) if !pbResolveBitmap(bitmapFileName)
@@ -279,14 +278,16 @@ def pbItemIconFile(item)
end end
bitmapFileName = "Graphics/Icons/item000" if !pbResolveBitmap(bitmapFileName) bitmapFileName = "Graphics/Icons/item000" if !pbResolveBitmap(bitmapFileName)
end end
else
bitmapFileName = sprintf("Graphics/Icons/itemBack")
end end
return bitmapFileName return bitmapFileName
end end
def pbHeldItemIconFile(item) # Used in the party screen def pbHeldItemIconFile(item) # Used in the party screen
return nil if !item || item==0 return nil if !item || item==0
namebase = (pbIsMail?(item)) ? "mail" : "item" namebase = (GameData::Item.get(item).is_mail?) ? "mail" : "item"
bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%s",namebase,getConstantName(PBItems,item)) rescue nil bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%s",namebase,GameData::Item.get(item).id.to_s) rescue nil
if !pbResolveBitmap(bitmapFileName) if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%03d",namebase,item) bitmapFileName = sprintf("Graphics/Pictures/Party/icon_%s_%03d",namebase,item)
if !pbResolveBitmap(bitmapFileName) if !pbResolveBitmap(bitmapFileName)
@@ -303,7 +304,7 @@ end
#=============================================================================== #===============================================================================
def pbMailBackFile(item) def pbMailBackFile(item)
return nil if !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) if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Pictures/Mail/mail_%03d",item) bitmapFileName = sprintf("Graphics/Pictures/Mail/mail_%03d",item)
end end
@@ -495,7 +495,7 @@ def pbHasEgg?(species)
return false if compat.include?(getConst(PBEggGroups,:Ditto)) return false if compat.include?(getConst(PBEggGroups,:Ditto))
baby = pbGetBabySpecies(species) baby = pbGetBabySpecies(species)
return true if species==baby # Is a basic 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 true if species==baby # Is an egg species without incense
return false return false
end end
@@ -1064,22 +1064,21 @@ def pbChooseMove(pokemon,variableNumber,nameVarNumber)
$game_map.need_refresh = true if $game_map $game_map.need_refresh = true if $game_map
end end
def pbConvertItemToItem(variable,array) def pbConvertItemToItem(variable, array)
item = pbGet(variable) item = GameData::Item.get(pbGet(variable))
pbSet(variable,0) pbSet(variable, nil)
for i in 0...(array.length/2) for i in 0...(array.length/2)
if isConst?(item,PBItems,array[2*i]) next if item != array[2 * i]
pbSet(variable,getID(PBItems,array[2*i+1])) pbSet(variable, array[2 * i + 1])
return return
end
end end
end end
def pbConvertItemToPokemon(variable,array) def pbConvertItemToPokemon(variable,array)
item = pbGet(variable) item = GameData::Item.get(pbGet(variable))
pbSet(variable,0) pbSet(variable, 0)
for i in 0...(array.length/2) 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])) pbSet(variable,getID(PBSpecies,array[2*i+1]))
return return
end end
+9 -13
View File
@@ -490,16 +490,17 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
# Item options # Item options
#============================================================================= #=============================================================================
when "additem" when "additem"
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new(0)) { |button,item| pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new) { |button,item|
if button==Input::C && item && item>0 if button==Input::C && item
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(1,BAG_MAX_PER_SLOT) params.setRange(1,BAG_MAX_PER_SLOT)
params.setInitialValue(1) params.setInitialValue(1)
params.setCancelValue(0) 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 if qty>0
$PokemonBag.pbStoreItem(item,qty) $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
end end
} }
@@ -510,14 +511,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
params.setCancelValue(0) params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params) qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
if qty>0 if qty>0
itemconsts = [] GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) }
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
pbMessage(_INTL("The Bag was filled with {1} of each item.",qty)) pbMessage(_INTL("The Bag was filled with {1} of each item.",qty))
end end
when "emptybag" when "emptybag"
@@ -731,6 +725,7 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
#============================================================================= #=============================================================================
when "setmetadata" when "setmetadata"
pbMetadataScreen(pbDefaultMap) pbMetadataScreen(pbDefaultMap)
# TODO: Only need to reload the metadata.
pbClearData pbClearData
when "mapconnections" when "mapconnections"
pbFadeOutIn { pbConnectionsEditor } pbFadeOutIn { pbConnectionsEditor }
@@ -745,8 +740,9 @@ def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
pbEncounterEditorMap(encdata,map) pbEncounterEditorMap(encdata,map)
end end
save_data(encdata,"Data/encounters.dat") save_data(encdata,"Data/encounters.dat")
# TODO: Only need to reload the encounters data.
pbClearData pbClearData
pbSaveEncounterData pbSaveEncounterData # Rewrite PBS file encounters.txt
when "trainertypes" when "trainertypes"
pbFadeOutIn { pbTrainerTypeEditor } pbFadeOutIn { pbTrainerTypeEditor }
when "edittrainers" when "edittrainers"
+4 -4
View File
@@ -433,7 +433,7 @@ module PokemonDebugMixin
oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability" oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability"
commands = [] commands = []
for i in abils 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 end
commands.push(_INTL("Remove override")) commands.push(_INTL("Remove override"))
msg = [_INTL("Ability {1} is natural.",oldabil), msg = [_INTL("Ability {1} is natural.",oldabil),
@@ -615,8 +615,8 @@ module PokemonDebugMixin
when "setpokeball" when "setpokeball"
commands = []; balls = [] commands = []; balls = []
for key in $BallTypes.keys for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key]) item = GameData::Item.try_get($BallTypes[key])
balls.push([key.to_i,PBItems.getName(item)]) if item && item>0 balls.push([key.to_i, item.name]) if item
end end
balls.sort! { |a,b| a[1]<=>b[1] } balls.sort! { |a,b| a[1]<=>b[1] }
cmd = 0 cmd = 0
@@ -629,7 +629,7 @@ module PokemonDebugMixin
commands.push(i[1]) commands.push(i[1])
end end
loop do loop do
oldball = PBItems.getName(pbBallTypeToItem(pkmn.ballused)) oldball = pbBallTypeToItem(pkmn.ballused).name
cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd) cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd)
break if cmd<0 break if cmd<0
pkmn.ballused = balls[cmd][0] pkmn.ballused = balls[cmd][0]
+236 -247
View File
@@ -298,15 +298,17 @@ end
def pbTrainerTypeEditor def pbTrainerTypeEditor
selection = 0 selection = 0
trainerTypes = [ trainerTypes = [
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBTrainers::XXX.")], [_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("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("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 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 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("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("Gender"), EnumProperty.new([
[_INTL("Skill"),LimitProperty.new(9999),_INTL("Skill level of this Trainer type.")], _INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),
[_INTL("Skill Codes"),StringProperty,_INTL("Letters/phrases representing AI modifications of trainers of this type.")], _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| pbListScreenBlock(_INTL("Trainer Types"),TrainerTypeLister.new(selection,true)) { |button,trtype|
if trtype if trtype
@@ -354,24 +356,24 @@ module TrainerBattleProperty
def self.set(settingname,oldsetting) def self.set(settingname,oldsetting)
return nil if !oldsetting return nil if !oldsetting
properties = [ properties = [
[_INTL("Trainer Type"),TrainerTypeProperty,_INTL("Name of the trainer type for this Trainer.")], [_INTL("Trainer Type"), TrainerTypeProperty, _INTL("Name of the trainer type for this Trainer.")],
[_INTL("Trainer Name"),StringProperty,_INTL("Name of the 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("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("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 1"), TrainerPokemonProperty, _INTL("First Pokémon.")],
[_INTL("Pokémon 2"),TrainerPokemonProperty,_INTL("Second Pokémon.")], [_INTL("Pokémon 2"), TrainerPokemonProperty, _INTL("Second Pokémon.")],
[_INTL("Pokémon 3"),TrainerPokemonProperty,_INTL("Third Pokémon.")], [_INTL("Pokémon 3"), TrainerPokemonProperty, _INTL("Third Pokémon.")],
[_INTL("Pokémon 4"),TrainerPokemonProperty,_INTL("Fourth Pokémon.")], [_INTL("Pokémon 4"), TrainerPokemonProperty, _INTL("Fourth Pokémon.")],
[_INTL("Pokémon 5"),TrainerPokemonProperty,_INTL("Fifth Pokémon.")], [_INTL("Pokémon 5"), TrainerPokemonProperty, _INTL("Fifth Pokémon.")],
[_INTL("Pokémon 6"),TrainerPokemonProperty,_INTL("Sixth 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 1"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 2"),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 3"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 4"),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 5"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 6"),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 7"), ItemProperty, _INTL("Item used by the Trainer during battle.")],
[_INTL("Item 8"),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) if !pbPropertyList(settingname,oldsetting,properties,true)
return nil return nil
@@ -457,7 +459,7 @@ def pbTrainerBattleEditor
trainerdata = [ trainerdata = [
data[0], data[0],
data[1], 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[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[2],
data[3] data[3]
@@ -502,24 +504,24 @@ module TrainerPokemonProperty
end end
mLevel = PBExperience.maxLevel mLevel = PBExperience.maxLevel
properties = [ properties = [
[_INTL("Species"),SpeciesProperty,_INTL("Species of the Pokémon.")], [_INTL("Species"), SpeciesProperty, _INTL("Species of the Pokémon.")],
[_INTL("Level"),NonzeroLimitProperty.new(mLevel),_INTL("Level of the Pokémon (1-{1}).",mLevel)], [_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("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 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 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 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("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("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("Gender"), GenderProperty.new, _INTL("Gender of the Pokémon.")],
[_INTL("Form"),LimitProperty2.new(999),_INTL("Form 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("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("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("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("Happiness"), LimitProperty2.new(255), _INTL("Happiness of the Pokémon (0-255).")],
[_INTL("Nickname"),StringProperty,_INTL("Name of the Pokémon.")], [_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("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("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("EVs"), EVsProperty.new(Pokemon::EV_STAT_LIMIT), _INTL("Effort values for each of the Pokémon's stats.")]
] ]
pbPropertyList(settingname,oldsetting,properties,false) pbPropertyList(settingname,oldsetting,properties,false)
return nil if !oldsetting[TrainerData::SPECIES] || oldsetting[TrainerData::SPECIES]==0 return nil if !oldsetting[TrainerData::SPECIES] || oldsetting[TrainerData::SPECIES]==0
@@ -535,7 +537,7 @@ module TrainerPokemonProperty
end end
moves.compact! moves.compact!
ret[TrainerData::MOVES] = moves if moves.length>0 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 ret.pop while ret.last.nil? && ret.size>0
return ret return ret
end end
@@ -582,153 +584,142 @@ end
def pbItemEditor def pbItemEditor
selection = 0 selection = 0
items = [ items = [
[_INTL("Internal Name"),ReadOnlyProperty,_INTL("Internal name that appears in constructs like PBItems::XXX.")], [_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"), 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("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("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("Purchase price"), LimitProperty.new(999999), _INTL("Purchase price of the item.")],
[_INTL("Description"),StringProperty,_INTL("Description of the item")], [_INTL("Description"), StringProperty, _INTL("Description of the item")],
[_INTL("Use Out of Battle"),EnumProperty.new([ [_INTL("Use Out of Battle"), EnumProperty.new([
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("Use directly"), _INTL("Can't Use"), _INTL("On a Pokémon"), _INTL("Use directly"),
_INTL("TM"),_INTL("HM"),_INTL("On a Pokémon reusable")]), _INTL("TM"), _INTL("HM"), _INTL("On a Pokémon reusable")]),
_INTL("Specifies how this item can be used outside of battle.")], _INTL("Specifies how this item can be used outside of battle.")],
[_INTL("Use In Battle"),EnumProperty.new([ [_INTL("Use In Battle"), EnumProperty.new([
_INTL("Can't Use"),_INTL("On a Pokémon"),_INTL("On Pokémon's move"), _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 battler"), _INTL("On foe battler"), _INTL("Use directly"),
_INTL("On a Pokémon reusable"),_INTL("On Pokémon's move reusable"), _INTL("On a Pokémon reusable"), _INTL("On Pokémon's move reusable"),
_INTL("On battler reusable"),_INTL("On foe battler reusable"), _INTL("On battler reusable"), _INTL("On foe battler reusable"),
_INTL("Use directly reusable")]), _INTL("Use directly reusable")]),
_INTL("Specifies how this item can be used within a battle.")], _INTL("Specifies how this item can be used within a battle.")],
[_INTL("Special Items"),EnumProperty.new([ [_INTL("Special Items"), EnumProperty.new([
_INTL("None of below"),_INTL("Mail"),_INTL("Mail with Pictures"), _INTL("None of below"), _INTL("Mail"), _INTL("Mail with Pictures"),
_INTL("Snag Ball"),_INTL("Poké Ball"),_INTL("Plantable Berry"), _INTL("Snag Ball"), _INTL("Poké Ball"), _INTL("Plantable Berry"),
_INTL("Key Item"),_INTL("Evolution Stone"),_INTL("Fossil"), _INTL("Key Item"), _INTL("Evolution Stone"), _INTL("Fossil"),
_INTL("Apricorn"),_INTL("Type-boosting Gem"),_INTL("Mulch"), _INTL("Apricorn"), _INTL("Type-boosting Gem"), _INTL("Mulch"),
_INTL("Mega Stone")]), _INTL("Mega Stone")]),
_INTL("For special kinds of items.")], _INTL("For special kinds of items.")],
[_INTL("Machine"),MoveProperty,_INTL("Move taught by this TM or HM.")] [_INTL("Machine"), MoveProperty, _INTL("Move taught by this TM or HM.")]
] ]
pbListScreenBlock(_INTL("Items"),ItemLister.new(selection,true)) { |button,trtype| pbListScreenBlock(_INTL("Items"), ItemLister.new(selection, true)) { |button, item|
if trtype if item
if button==Input::A if button==Input::A
if trtype>=0 if item.is_a?(Symbol)
if pbConfirmMessageSerious("Delete this item?") if pbConfirmMessageSerious("Delete this item?")
data = pbLoadItemsData id_number = GameData::Item.get(item).id_number
removeConstantValue(PBItems,trtype) GameData::Item::DATA.delete(item)
data.delete_if { |item| item[0]==trtype } GameData::Item::DATA.delete(id_number)
for x in data GameData::Item.save
p x if data[0]==0
end
save_data(data,"Data/items.dat")
$PokemonTemp.itemsData = nil
pbSaveItems pbSaveItems
pbMessage(_INTL("The item was deleted.")) pbMessage(_INTL("The item was deleted."))
end end
end end
elsif button==Input::C elsif button==Input::C
selection = trtype if item.is_a?(Symbol)
if selection<0 itm = GameData::Item.get(item)
newid = pbItemEditorNew(nil) data = [
if newid>=0 itm.id.to_s,
selection = newid itm.real_name,
end itm.real_name_plural,
else itm.pocket,
data = [getConstantName(PBItems,selection)] itm.price,
itemdata = pbLoadItemsData itm.real_description,
data.push(itemdata[selection][ItemData::NAME]) itm.field_use,
data.push(itemdata[selection][ItemData::NAME_PLURAL]) itm.battle_use,
data.push(itemdata[selection][ItemData::POCKET]) itm.type,
data.push(itemdata[selection][ItemData::PRICE]) itm.move || 0
data.push(itemdata[selection][ItemData::DESCRIPTION]) ]
data.push(itemdata[selection][ItemData::FIELD_USE]) save = pbPropertyList(itm.id.to_s, data, items, true)
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 save if save
itemdata[selection][ItemData::NAME] = data[ItemData::NAME] # Construct item hash
itemdata[selection][ItemData::NAME_PLURAL] = data[ItemData::NAME_PLURAL] item_hash = {
itemdata[selection][ItemData::POCKET] = data[ItemData::POCKET] :id_number => itm.id_number,
itemdata[selection][ItemData::PRICE] = data[ItemData::PRICE] :id => itm.id,
itemdata[selection][ItemData::DESCRIPTION] = data[ItemData::DESCRIPTION] :name => data[1],
itemdata[selection][ItemData::FIELD_USE] = data[ItemData::FIELD_USE] :name_plural => data[2],
itemdata[selection][ItemData::BATTLE_USE] = data[ItemData::BATTLE_USE] :pocket => data[3],
itemdata[selection][ItemData::TYPE] = data[ItemData::TYPE] :price => data[4],
itemdata[selection][ItemData::MOVE] = data[ItemData::MOVE] :description => data[5],
save_data(itemdata,"Data/items.dat") :field_use => data[6],
$PokemonTemp.itemsData = nil :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 pbSaveItems
end end
else # Add a new item
pbItemEditorNew(nil)
end end
end end
end end
} }
end end
def pbItemEditorNew(defaultname) def pbItemEditorNew(default_name)
itemdata = pbLoadItemsData # Get an unused ID number for the new item
# Get the first blank ID for the new item to use. max_id = 0
maxid = PBItems.maxValue+1 GameData::Item.each { |i| max_id = i.id_number if max_id < i.id_number }
index = maxid id_number = max_id + 1
itemname = pbMessageFreeText(_INTL("Please enter the item's name."), # Choose a name
(defaultname) ? defaultname.gsub(/_+/," ") : "",false,30) name = pbMessageFreeText(_INTL("Please enter the item's name."),
if itemname=="" && !defaultname (default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
return -1 if name == ""
else return if !default_name
# Create a default name if there is none. name = default_name
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
end 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 end
@@ -741,71 +732,71 @@ def pbPokemonEditor
metrics = pbLoadSpeciesMetrics metrics = pbLoadSpeciesMetrics
selection = 0 selection = 0
species = [ species = [
[_INTL("Name"), LimitStringProperty.new(Pokemon::MAX_NAME_SIZE), _INTL("Name of the Pokémon.")], [_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("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("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("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("BaseStats"), BaseStatsProperty, _INTL("Base stats of the Pokémon.")],
[_INTL("GenderRate"),EnumProperty.new([ [_INTL("GenderRate"), EnumProperty.new([
_INTL("Genderless"),_INTL("AlwaysMale"),_INTL("FemaleOneEighth"), _INTL("Genderless"),_INTL("AlwaysMale"),_INTL("FemaleOneEighth"),
_INTL("Female25Percent"),_INTL("Female50Percent"),_INTL("Female75Percent"), _INTL("Female25Percent"),_INTL("Female50Percent"),_INTL("Female75Percent"),
_INTL("FemaleSevenEighths"),_INTL("AlwaysFemale")]), _INTL("FemaleSevenEighths"),_INTL("AlwaysFemale")]),
_INTL("Proportion of males to females for this species.")], _INTL("Proportion of males to females for this species.")],
[_INTL("GrowthRate"),EnumProperty.new([ [_INTL("GrowthRate"), EnumProperty.new([
_INTL("Medium"),_INTL("Erratic"),_INTL("Fluctuating"),_INTL("Parabolic"), _INTL("Medium"),_INTL("Erratic"),_INTL("Fluctuating"),_INTL("Parabolic"),
_INTL("Fast"),_INTL("Slow")]), _INTL("Fast"),_INTL("Slow")]),
_INTL("Pokémon's growth rate.")], _INTL("Pokémon's growth rate.")],
[_INTL("BaseEXP"),LimitProperty.new(9999),_INTL("Base experience earned when this species is defeated.")], [_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("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("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("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("Ability1"), AbilityProperty, _INTL("One ability which the Pokémon can have.")],
[_INTL("Ability2"),AbilityProperty,_INTL("Another 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 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 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 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("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("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("EggMoves"), EggMovesProperty, _INTL("Moves which the Pokémon can learn via breeding.")],
[_INTL("Compat1"),EnumProperty.new([ [_INTL("Compat1"), EnumProperty.new([
"Undiscovered","Monster","Water 1","Bug","Flying", "Undiscovered","Monster","Water 1","Bug","Flying",
"Field","Fairy","Grass","Human-like","Water 3", "Field","Fairy","Grass","Human-like","Water 3",
"Mineral","Amorphous","Water 2","Ditto","Dragon"]), "Mineral","Amorphous","Water 2","Ditto","Dragon"]),
_INTL("Compatibility group (egg group) for breeding purposes.")], _INTL("Compatibility group (egg group) for breeding purposes.")],
[_INTL("Compat2"),EnumProperty.new([ [_INTL("Compat2"), EnumProperty.new([
"Undiscovered","Monster","Water 1","Bug","Flying", "Undiscovered","Monster","Water 1","Bug","Flying",
"Field","Fairy","Grass","Human-like","Water 3", "Field","Fairy","Grass","Human-like","Water 3",
"Mineral","Amorphous","Water 2","Ditto","Dragon"]), "Mineral","Amorphous","Water 2","Ditto","Dragon"]),
_INTL("Compatibility group (egg group) for breeding purposes.")], _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("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("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("Weight"), NonzeroLimitProperty.new(9999), _INTL("Weight of the Pokémon in 0.1 kilograms (e.g. 42 = 4.2kg).")],
[_INTL("Color"),EnumProperty.new([ [_INTL("Color"), EnumProperty.new([
_INTL("Red"),_INTL("Blue"),_INTL("Yellow"),_INTL("Green"),_INTL("Black"), _INTL("Red"),_INTL("Blue"),_INTL("Yellow"),_INTL("Green"),_INTL("Black"),
_INTL("Brown"),_INTL("Purple"),_INTL("Gray"),_INTL("White"),_INTL("Pink")]), _INTL("Brown"),_INTL("Purple"),_INTL("Gray"),_INTL("White"),_INTL("Pink")]),
_INTL("Pokémon's body color.")], _INTL("Pokémon's body color.")],
[_INTL("Shape"),LimitProperty.new(14),_INTL("Body shape of this species (0-14).")], [_INTL("Shape"), LimitProperty.new(14), _INTL("Body shape of this species (0-14).")],
[_INTL("Habitat"),EnumProperty.new([ [_INTL("Habitat"), EnumProperty.new([
_INTL("None"),_INTL("Grassland"),_INTL("Forest"),_INTL("WatersEdge"), _INTL("None"),_INTL("Grassland"),_INTL("Forest"),_INTL("WatersEdge"),
_INTL("Sea"),_INTL("Cave"),_INTL("Mountain"),_INTL("RoughTerrain"), _INTL("Sea"),_INTL("Cave"),_INTL("Mountain"),_INTL("RoughTerrain"),
_INTL("Urban"),_INTL("Rare")]), _INTL("Urban"),_INTL("Rare")]),
_INTL("The habitat 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("RegionalNumbers"), ReadOnlyProperty, _INTL("Regional Dex numbers for the Pokémon. These are edited elsewhere.")],
[_INTL("Kind"),StringProperty,_INTL("Kind of Pokémon species.")], [_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("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("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("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("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("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("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("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("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("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("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("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("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("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("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| pbListScreenBlock(_INTL("Pokémon species"),SpeciesLister.new(selection,false)) { |button,index|
if index if index
@@ -838,11 +829,11 @@ def pbPokemonEditor
formname = messages.get(MessageTypes::FormNames,selection) formname = messages.get(MessageTypes::FormNames,selection)
abilities = speciesData[SpeciesData::ABILITIES] abilities = speciesData[SpeciesData::ABILITIES]
if abilities.is_a?(Array) if abilities.is_a?(Array)
ability1 = (abilities[0]) ? PokemonData::Ability.get(abilities[0]).id_number : 0 ability1 = abilities[0]
ability2 = (abilities[1]) ? PokemonData::Ability.get(abilities[1]).id_number : 0 ability2 = abilities[1]
else else
ability1 = (abilities) ? PokemonData::Ability.get(abilities).id_number : 0 ability1 = abilities
ability2 = 0 ability2 = nil
end end
color = speciesData[SpeciesData::COLOR] color = speciesData[SpeciesData::COLOR]
habitat = speciesData[SpeciesData::HABITAT] habitat = speciesData[SpeciesData::HABITAT]
@@ -870,15 +861,15 @@ def pbPokemonEditor
baseexp = speciesData[SpeciesData::BASE_EXP] baseexp = speciesData[SpeciesData::BASE_EXP]
hiddenAbils = speciesData[SpeciesData::HIDDEN_ABILITY] hiddenAbils = speciesData[SpeciesData::HIDDEN_ABILITY]
if hiddenAbils.is_a?(Array) if hiddenAbils.is_a?(Array)
hiddenability1 = (hiddenAbils[0]) ? PokemonData::Ability.get(hiddenAbils[0]).id_number : 0 hiddenability1 = hiddenAbils[0]
hiddenability2 = (hiddenAbils[1]) ? PokemonData::Ability.get(hiddenAbils[1]).id_number : 0 hiddenability2 = hiddenAbils[1]
hiddenability3 = (hiddenAbils[2]) ? PokemonData::Ability.get(hiddenAbils[2]).id_number : 0 hiddenability3 = hiddenAbils[2]
hiddenability4 = (hiddenAbils[3]) ? PokemonData::Ability.get(hiddenAbils[3]).id_number : 0 hiddenability4 = hiddenAbils[3]
else else
hiddenability1 = (hiddenAbils) ? PokemonData::Ability.get(hiddenAbils).id_number : 0 hiddenability1 = hiddenAbils
hiddenability2 = 0 hiddenability2 = nil
hiddenability3 = 0 hiddenability3 = nil
hiddenability4 = 0 hiddenability4 = nil
end end
item1 = speciesData[SpeciesData::WILD_ITEM_COMMON] item1 = speciesData[SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[SpeciesData::WILD_ITEM_UNCOMMON] item2 = speciesData[SpeciesData::WILD_ITEM_UNCOMMON]
@@ -953,18 +944,13 @@ def pbPokemonEditor
data[20] = data[19] if !data[20] || data[20]==0 data[20] = data[19] if !data[20] || data[20]==0
compats = (data[20] && data[20]>0) ? [data[19],data[20]] : data[19] compats = (data[20] && data[20]>0) ? [data[19],data[20]] : data[19]
# Make sure both Abilities are recorded correctly # Make sure both Abilities are recorded correctly
data[11] = data[12] if !data[11] || data[11]==0 data[11] = data[12] if !data[11]
data[11] = 0 if !data[11] data[12] = nil if data[11] == data[12]
data[12] = 0 if data[11]==data[12] abils = (data[12]) ? [data[11], data[12]] : data[11]
abils = (data[12] && data[12]>0) ? [data[11],data[12]] : data[11]
# Make sure all Hidden Abilities are recorded correctly # Make sure all Hidden Abilities are recorded correctly
hiddenAbils = []; shouldArray = false hiddenAbils = [data[13], data[14], data[15], data[16]]
for i in 13..17 hiddenAbils.compact!
data[i] = nil if data[i] && data[i]==0 hiddenAbils = hiddenAbils[0] if hiddenAbils.length <= 1
hiddenAbils.push(data[i])
shouldArray = true if i>13 && data[i]
end
hiddenAbils = hiddenAbils[0] if !shouldArray
# Save data # Save data
speciesData[SpeciesData::ABILITIES] = abils speciesData[SpeciesData::ABILITIES] = abils
speciesData[SpeciesData::COLOR] = data[24] speciesData[SpeciesData::COLOR] = data[24]
@@ -1057,8 +1043,11 @@ def pbPokemonEditor
save_data(evos,"Data/species_evolutions.dat") save_data(evos,"Data/species_evolutions.dat")
# Don't need to save metrics or regional numbers # Don't need to save metrics or regional numbers
# because they can't be edited here # 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 pbClearData
pbSavePokemonData pbSavePokemonData # Rewrite PBS files pokemon.txt and pokemonforms.txt
pbMessage(_INTL("Data saved.")) pbMessage(_INTL("Data saved."))
end end
end end
+90 -101
View File
@@ -55,12 +55,12 @@ def pbSaveAbilities
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file.")) f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
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", f.write(sprintf("%d,%s,%s,%s\r\n",
a.id_number, a.id_number,
csvQuote(a.id.to_s), csvQuote(a.id.to_s),
csvQuote(a.name), csvQuote(a.real_name),
csvQuoteAlways(a.description) csvQuoteAlways(a.real_description)
)) ))
end end
} }
@@ -228,41 +228,35 @@ end
# Save item data to PBS file # Save item data to PBS file
#=============================================================================== #===============================================================================
def pbSaveItems def pbSaveItems
itemData = pbLoadItemsData rescue nil
return if !itemData || itemData.length==0
File.open("PBS/items.txt","wb") { |f| File.open("PBS/items.txt","wb") { |f|
f.write(0xEF.chr) f.write(0xEF.chr)
f.write(0xBB.chr) f.write(0xBB.chr)
f.write(0xBF.chr) f.write(0xBF.chr)
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file.")) f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
curpocket = 0 current_pocket = 0
for i in 0...itemData.length GameData::Item.each do |i|
next if !itemData[i] if current_pocket != i.pocket
data = itemData[i] current_pocket = i.pocket
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]
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
end end
machine = "" move_name = ""
if data[ItemData::MOVE]>0 if i.move
machine = getConstantName(PBMoves,data[ItemData::MOVE]) rescue pbGetMoveConst(data[ItemData::MOVE]) rescue "" move_name = getConstantName(PBMoves, i.move) rescue pbGetMoveConst(i.move) rescue ""
end end
f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s", f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
data[ItemData::ID], i.id_number,
csvQuote(cname), csvQuote(i.id.to_s),
csvQuote(data[ItemData::NAME]), csvQuote(i.real_name),
csvQuote(data[ItemData::NAME_PLURAL]), csvQuote(i.real_name_plural),
data[ItemData::POCKET], i.pocket,
data[ItemData::PRICE], i.price,
csvQuoteAlways(data[ItemData::DESCRIPTION]), csvQuoteAlways(i.real_description),
data[ItemData::FIELD_USE], i.field_use,
data[ItemData::BATTLE_USE], i.battle_use,
data[ItemData::TYPE], i.type,
csvQuote(machine))) csvQuote(move_name)
f.write("\r\n") ))
end end
} }
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("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
f.write("\#-------------------------------\r\n") f.write("\#-------------------------------\r\n")
for i in 0...berryPlantData.length keys = berryPlantData.keys.sort
next if !berryPlantData[i] keys.each do |key|
data = berryPlantData[i] data = berryPlantData[key]
cname = getConstantName(PBItems,i) rescue sprintf("ITEM%03d",i) next if !data || !GameData::Item.exists?(key)
next if !cname || cname=="" || i==0
f.write(sprintf("%s = %d,%d,%d,%d", 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") f.write("\r\n")
end end
} }
@@ -368,7 +361,7 @@ def pbSaveEncounterData
f.write(0xBF.chr) f.write(0xBF.chr)
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file.")) f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
f.write("\r\n") f.write("\r\n")
sortedkeys = encdata.keys.sort { |a,b| a<=>b } sortedkeys = encdata.keys.sort
for i in sortedkeys for i in sortedkeys
next if !encdata[i] next if !encdata[i]
e = encdata[i] e = encdata[i]
@@ -461,10 +454,8 @@ def pbSaveTrainerBattles
if trainer[2] && trainer[2].length>0 if trainer[2] && trainer[2].length>0
itemstring = "" itemstring = ""
for i in 0...trainer[2].length for i in 0...trainer[2].length
itemname = getConstantName(PBItems,trainer[2][i]) rescue pbGetItemConst(trainer[2][i]) rescue nil itemstring.concat(",") if i > 0
next if !itemname itemstring.concat(trainer[2][i].to_s)
itemstring.concat(",") if i>0
itemstring.concat(itemname)
end end
f.write(sprintf("Items = %s\r\n",itemstring)) if itemstring!="" f.write(sprintf("Items = %s\r\n",itemstring)) if itemstring!=""
end end
@@ -502,11 +493,10 @@ def pbSaveTrainerBattles
f.write(sprintf(" Moves = %s\r\n",movestring)) if movestring!="" f.write(sprintf(" Moves = %s\r\n",movestring)) if movestring!=""
end end
if poke[TrainerData::ABILITY] 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 end
if poke[TrainerData::ITEM] && poke[TrainerData::ITEM]>0 if poke[TrainerData::ITEM]
item = getConstantName(PBItems,poke[TrainerData::ITEM]) rescue pbGetItemConst(poke[TrainerData::ITEM]) rescue nil f.write(sprintf(" Item = %s\r\n",poke[TrainerData::ITEM].to_s))
f.write(sprintf(" Item = %s\r\n",item)) if item
end end
if poke[TrainerData::NATURE] if poke[TrainerData::NATURE]
nature = getConstantName(PBNatures,poke[TrainerData::NATURE]) rescue nil nature = getConstantName(PBNatures,poke[TrainerData::NATURE]) rescue nil
@@ -688,10 +678,10 @@ def pbSavePokemonData
hiddenability3 = nil hiddenability3 = nil
hiddenability4 = nil hiddenability4 = nil
end end
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0 item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0 item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0 item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
incense = speciesData[i][SpeciesData::INCENSE] || 0 incense = speciesData[i][SpeciesData::INCENSE]
pokedata.write("\#-------------------------------\r\n") pokedata.write("\#-------------------------------\r\n")
pokedata.write("[#{i}]\r\nName = #{speciesname}\r\n") pokedata.write("[#{i}]\r\nName = #{speciesname}\r\n")
pokedata.write("InternalName = #{cname}\r\n") pokedata.write("InternalName = #{cname}\r\n")
@@ -711,12 +701,12 @@ def pbSavePokemonData
pokedata.write("Happiness = #{happiness}\r\n") pokedata.write("Happiness = #{happiness}\r\n")
pokedata.write("Abilities = ") pokedata.write("Abilities = ")
if ability1 if ability1
cability1 = PokemonData::Ability.get(ability1).name cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}") pokedata.write("#{cability1}")
pokedata.write(",") if ability2 pokedata.write(",") if ability2
end end
if ability2 if ability2
cability2 = PokemonData::Ability.get(ability2).name cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}") pokedata.write("#{cability2}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
@@ -724,22 +714,22 @@ def pbSavePokemonData
pokedata.write("HiddenAbility = ") pokedata.write("HiddenAbility = ")
needcomma = false needcomma = false
if hiddenability1 if hiddenability1
cabilityh = PokemonData::Ability.get(hiddenability1).name cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability2 if hiddenability2
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability2).name cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability3 if hiddenability3
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability3).name cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability4 if hiddenability4
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability4).name cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}") pokedata.write("#{cabilityh}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
@@ -812,16 +802,16 @@ def pbSavePokemonData
if formname && formname!="" if formname && formname!=""
pokedata.write("FormName = #{formname}\r\n") pokedata.write("FormName = #{formname}\r\n")
end end
if item1>0 if item1
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1) citem1 = GameData::Item.get(item1).id.to_s
pokedata.write("WildItemCommon = #{citem1}\r\n") pokedata.write("WildItemCommon = #{citem1}\r\n")
end end
if item2>0 if item2
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2) citem2 = GameData::Item.get(item2).id.to_s
pokedata.write("WildItemUncommon = #{citem2}\r\n") pokedata.write("WildItemUncommon = #{citem2}\r\n")
end end
if item3>0 if item3
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3) citem3 = GameData::Item.get(item3).id.to_s
pokedata.write("WildItemRare = #{citem3}\r\n") pokedata.write("WildItemRare = #{citem3}\r\n")
end end
if metrics && metrics.length>0 if metrics && metrics.length>0
@@ -849,8 +839,12 @@ def pbSavePokemonData
has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil has_param = !PBEvolution.hasFunction?(method, "parameterType") || param_type != nil
if has_param if has_param
if param_type if param_type
cparameter = (getConstantName(param_type, parameter) rescue parameter) if [:Ability, :Item].include?(param_type)
pokedata.write("#{cparameter}") pokedata.write("#{parameter.to_s}")
else
cparameter = (getConstantName(param_type, parameter) rescue parameter)
pokedata.write("#{cparameter}")
end
else else
pokedata.write("#{parameter}") pokedata.write("#{parameter}")
end end
@@ -858,8 +852,8 @@ def pbSavePokemonData
count += 1 count += 1
end end
pokedata.write("\r\n") pokedata.write("\r\n")
if incense>0 if incense
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense) initem = GameData::Item.get(incense).id.to_s
pokedata.write("Incense = #{initem}\r\n") pokedata.write("Incense = #{initem}\r\n")
end end
if i%20==0 if i%20==0
@@ -954,10 +948,10 @@ def pbSavePokemonFormsData
origdata["hiddenability3"] = nil origdata["hiddenability3"] = nil
origdata["hiddenability4"] = nil origdata["hiddenability4"] = nil
end end
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0 origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON]
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0 origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON]
origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE] || 0 origdata["item3"] = speciesData[species][SpeciesData::WILD_ITEM_RARE]
origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0 origdata["incense"] = speciesData[species][SpeciesData::INCENSE]
abilities = speciesData[i][SpeciesData::ABILITIES] abilities = speciesData[i][SpeciesData::ABILITIES]
if abilities.is_a?(Array) if abilities.is_a?(Array)
ability1 = abilities[0] ability1 = abilities[0]
@@ -1047,16 +1041,16 @@ def pbSavePokemonFormsData
hiddenability4==origdata["hiddenability4"] hiddenability4==origdata["hiddenability4"]
hiddenability1 = hiddenability2 = hiddenability3 = hiddenability4 = nil hiddenability1 = hiddenability2 = hiddenability3 = hiddenability4 = nil
end end
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0 item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON]
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0 item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON]
item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE] || 0 item3 = speciesData[i][SpeciesData::WILD_ITEM_RARE]
if item1==origdata["item1"] && item2==origdata["item2"] && item3==origdata["item3"] if item1==origdata["item1"] && item2==origdata["item2"] && item3==origdata["item3"]
item1 = item2 = item3 = nil item1 = item2 = item3 = nil
end end
incense = speciesData[i][SpeciesData::INCENSE] || 0 incense = speciesData[i][SpeciesData::INCENSE]
incense = nil if incense==origdata["incense"] incense = nil if incense==origdata["incense"]
pokedexform = speciesData[i][SpeciesData::POKEDEX_FORM] || 0 # No nil check 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 megamove = speciesData[i][SpeciesData::MEGA_MOVE] || 0 # No nil check
unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check unmega = speciesData[i][SpeciesData::UNMEGA_FORM] || 0 # No nil check
megamessage = speciesData[i][SpeciesData::MEGA_MESSAGE] || 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("[#{cname},#{form}]\r\n")
pokedata.write("FormName = #{formname}\r\n") if formname && formname!="" pokedata.write("FormName = #{formname}\r\n") if formname && formname!=""
pokedata.write("PokedexForm = #{pokedexform}\r\n") if pokedexform>0 pokedata.write("PokedexForm = #{pokedexform}\r\n") if pokedexform>0
if megastone>0 if megastone
citem = getConstantName(PBItems,megastone) rescue pbGetItemConst(megastone) citem = GameData::Item.get(megastone).id.to_s
pokedata.write("MegaStone = #{citem}\r\n") pokedata.write("MegaStone = #{citem}\r\n")
end end
if megamove>0 if megamove>0
@@ -1107,12 +1101,12 @@ def pbSavePokemonFormsData
if ability1 || ability2 if ability1 || ability2
pokedata.write("Abilities = ") pokedata.write("Abilities = ")
if ability1 if ability1
cability1 = PokemonData::Ability.get(ability1).name cability1 = GameData::Ability.get(ability1).id.to_s
pokedata.write("#{cability1}") pokedata.write("#{cability1}")
pokedata.write(",") if ability2 pokedata.write(",") if ability2
end end
if ability2 if ability2
cability2 = PokemonData::Ability.get(ability2).name cability2 = GameData::Ability.get(ability2).id.to_s
pokedata.write("#{cability2}") pokedata.write("#{cability2}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
@@ -1122,22 +1116,22 @@ def pbSavePokemonFormsData
pokedata.write("HiddenAbility = ") pokedata.write("HiddenAbility = ")
needcomma = false needcomma = false
if hiddenability1 if hiddenability1
cabilityh = PokemonData::Ability.get(hiddenability1).name cabilityh = GameData::Ability.get(hiddenability1).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability2 if hiddenability2
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability2).name cabilityh = GameData::Ability.get(hiddenability2).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability3 if hiddenability3
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability3).name cabilityh = GameData::Ability.get(hiddenability3).id.to_s
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability4 if hiddenability4
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = PokemonData::Ability.get(hiddenability4).name cabilityh = GameData::Ability.get(hiddenability4).id.to_s
pokedata.write("#{cabilityh}") pokedata.write("#{cabilityh}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
@@ -1238,19 +1232,17 @@ def pbSavePokemonFormsData
if entry!=nil if entry!=nil
pokedata.write("Pokedex = #{entry}\r\n") pokedata.write("Pokedex = #{entry}\r\n")
end end
if item1!=nil && item2!=nil && item3!=nil if item1
if item1>0 citem1 = GameData::Item.get(item1).id.to_s
citem1 = getConstantName(PBItems,item1) rescue pbGetItemConst(item1) pokedata.write("WildItemCommon = #{citem1}\r\n")
pokedata.write("WildItemCommon = #{citem1}\r\n") end
end if item2
if item2>0 citem1 = GameData::Item.get(item2).id.to_s
citem2 = getConstantName(PBItems,item2) rescue pbGetItemConst(item2) pokedata.write("WildItemUncommon = #{citem2}\r\n")
pokedata.write("WildItemUncommon = #{citem2}\r\n") end
end if item3
if item3>0 citem1 = GameData::Item.get(item3).id.to_s
citem3 = getConstantName(PBItems,item3) rescue pbGetItemConst(item3) pokedata.write("WildItemRare = #{citem3}\r\n")
pokedata.write("WildItemRare = #{citem3}\r\n")
end
end end
if metrics && metrics.length>0 if metrics && metrics.length>0
for j in 0...6 for j in 0...6
@@ -1322,11 +1314,9 @@ def pbSavePokemonFormsData
end end
pokedata.write("\r\n") pokedata.write("\r\n")
end end
if incense!=nil if incense
if incense>0 initem = GameData::Item.get(incense).id.to_s
initem = getConstantName(PBItems,incense) rescue pbGetItemConst(incense) pokedata.write("Incense = #{initem}\r\n")
pokedata.write("Incense = #{initem}\r\n")
end
end end
if i%20==0 if i%20==0
Graphics.update Graphics.update
@@ -1439,8 +1429,7 @@ end
def pbFastInspect(pkmn,moves,species,items,natures) def pbFastInspect(pkmn,moves,species,items,natures)
c1 = (species[pkmn.species]) ? species[pkmn.species] : c1 = (species[pkmn.species]) ? species[pkmn.species] :
(species[pkmn.species] = (getConstantName(PBSpecies,pkmn.species) rescue pbGetSpeciesConst(pkmn.species))) (species[pkmn.species] = (getConstantName(PBSpecies,pkmn.species) rescue pbGetSpeciesConst(pkmn.species)))
c2 = (items[pkmn.item]) ? items[pkmn.item] : c2 = (items[pkmn.item]) ? items[pkmn.item] : (items[pkmn.item] = GameData::Item.get(pkmn.item).id.to_s)
(items[pkmn.item] = (getConstantName(PBItems,pkmn.item) rescue pbGetItemConst(pkmn.item)))
c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] : c3 = (natures[pkmn.nature]) ? natures[pkmn.nature] :
(natures[pkmn.nature] = getConstantName(PBNatures,pkmn.nature)) (natures[pkmn.nature] = getConstantName(PBNatures,pkmn.nature))
evlist = "" evlist = ""
+16 -15
View File
@@ -352,9 +352,9 @@ end
module ItemProperty module ItemProperty
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
ret = pbChooseItemList((oldsetting) ? oldsetting : 1) ret = pbChooseItemList((oldsetting) ? oldsetting : nil)
return (ret>0) ? ret : (oldsetting) ? oldsetting : nil return ret || oldsetting
end end
def self.defaultValue def self.defaultValue
@@ -362,7 +362,7 @@ module ItemProperty
end end
def self.format(value) def self.format(value)
return (value) ? PBItems.getName(value) : "-" return (value && GameData::Item.exists?(value)) ? GameData::Item.get(value).real_name : "-"
end end
end end
@@ -522,8 +522,7 @@ class BallProperty
end end
def format(value) def format(value)
return "-" if !value return (value) ? pbBallTypeToItem(value).name : "-"
return PBItems.getName(pbBallTypeToItem(value))
end end
end end
@@ -817,17 +816,17 @@ end
module AbilityProperty module AbilityProperty
def self.set(_settingname,oldsetting) def self.set(_settingname, oldsetting)
ret = pbChooseAbilityList((oldsetting) ? oldsetting : 1) ret = pbChooseAbilityList((oldsetting) ? oldsetting : nil)
return (ret<=0) ? (oldsetting) ? oldsetting : 0 : ret return ret || oldsetting
end end
def self.defaultValue def self.defaultValue
return 0 return nil
end end
def self.format(value) 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
end end
@@ -1253,7 +1252,7 @@ class EvolutionsProperty
if has_param if has_param
allow_zero = false allow_zero = false
case param_type case param_type
when :PBItems when :Item
newparam = pbChooseItemList newparam = pbChooseItemList
when :PBMoves when :PBMoves
newparam = pbChooseMoveList newparam = pbChooseMoveList
@@ -1272,7 +1271,8 @@ class EvolutionsProperty
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params) newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
end end
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 havemove = -1
for i in 0...realcmds.length for i in 0...realcmds.length
havemove = realcmds[i][3] if realcmds[i][0]==newmethod && havemove = realcmds[i][3] if realcmds[i][0]==newmethod &&
@@ -1341,7 +1341,7 @@ class EvolutionsProperty
if has_param if has_param
allow_zero = false allow_zero = false
case param_type case param_type
when :PBItems when :Item
newparam = pbChooseItemList(entry[1]) newparam = pbChooseItemList(entry[1])
when :PBMoves when :PBMoves
newparam = pbChooseMoveList(entry[1]) newparam = pbChooseMoveList(entry[1])
@@ -1360,7 +1360,8 @@ class EvolutionsProperty
params.setCancelValue(-1) params.setCancelValue(-1)
newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params) newparam = pbMessageChooseNumber(_INTL("Choose a parameter."),params)
end 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 havemove = -1
for i in 0...realcmds.length for i in 0...realcmds.length
havemove = realcmds[i][3] if realcmds[i][0]==entry[0] && havemove = realcmds[i][3] if realcmds[i][0]==entry[0] &&
+9 -14
View File
@@ -376,9 +376,9 @@ end
class ItemLister class ItemLister
def initialize(selection,includeNew=false) def initialize(selection=0,includeNew=false)
@sprite = IconSprite.new(0,0) @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 @sprite.z = 2
@selection = selection @selection = selection
@commands = [] @commands = []
@@ -404,23 +404,18 @@ class ItemLister
def commands # Sorted alphabetically def commands # Sorted alphabetically
@commands.clear @commands.clear
@ids.clear @ids.clear
@itemdata = pbLoadItemsData
cmds = [] cmds = []
for i in 1..PBItems.maxValue GameData::Item.each do |item|
next if !@itemdata[i] cmds.push([item.id_number, item.id, item.real_name])
name = @itemdata[i][ItemData::NAME]
if name && name!="" && @itemdata[i][ItemData::POCKET]!=0
cmds.push([i,name])
end
end end
cmds.sort! { |a,b| a[1]<=>b[1] } cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
if @includeNew if @includeNew
@commands.push(_INTL("[NEW ITEM]")) @commands.push(_INTL("[NEW ITEM]"))
@ids.push(-1) @ids.push(true)
end end
for i in cmds for i in cmds
@commands.push(sprintf("%03d: %s",i[0],i[1])) @commands.push(sprintf("%03d: %s", i[0], i[2]))
@ids.push(i[0]) @ids.push(i[1])
end end
@index = @selection @index = @selection
@index = @commands.length-1 if @index>=@commands.length @index = @commands.length-1 if @index>=@commands.length
@@ -434,7 +429,7 @@ class ItemLister
end end
def refresh(index) def refresh(index)
@sprite.item = @ids[index] @sprite.item = (@ids[index].is_a?(Symbol)) ? @ids[index] : nil
end end
end end
+42 -49
View File
@@ -14,16 +14,11 @@ def pbGetLegalMoves(species)
return moves if !species || species<=0 return moves if !species || species<=0
moveset = pbGetSpeciesMoveset(species) moveset = pbGetSpeciesMoveset(species)
moveset.each { |m| moves.push(m[1]) } moveset.each { |m| moves.push(m[1]) }
itemData = pbLoadItemsData
tmdat = pbLoadSpeciesTMData tmdat = pbLoadSpeciesTMData
for i in 0...itemData.length GameData::Item.each do |i|
next if !itemData[i] next if !i.move
atk = itemData[i][8] atk = getConst(PBMoves, i.move)
next if !atk || atk==0 moves.push(atk) if tmdat[atk] && tmdat[atk].include?(species)
next if !tmdat[atk]
if tmdat[atk].any? { |item| item==species }
moves.push(atk)
end
end end
babyspecies = pbGetBabySpecies(species) babyspecies = pbGetBabySpecies(species)
eggMoves = pbGetSpeciesEggMoves(babyspecies) eggMoves = pbGetSpeciesEggMoves(babyspecies)
@@ -252,9 +247,10 @@ def pbGetMoveConst(i)
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves) return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
end end
def pbGetItemConst(i) # Unused
return MakeshiftConsts.get(MessageTypes::Items,i,PBItems) #def pbGetItemConst(i)
end # return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
#end
def pbGetSpeciesConst(i) def pbGetSpeciesConst(i)
return MakeshiftConsts.get(MessageTypes::Species,i,PBSpecies) 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 # 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 # to initially select. Pressing Input::A will toggle the list sorting between
# numerical and alphabetical. # numerical and alphabetical.
def pbChooseItemList(default=0) def pbChooseItemList(default = nil)
commands = [] commands = []
for i in 1..PBItems.maxValue GameData::Item.each { |i| commands.push([i.id_number, i.name, i.id]) }
cname = getConstantName(PBItems,i) rescue nil return pbChooseList(commands, default, nil, -1)
commands.push([i,PBItems.getName(i)]) if cname
end
return pbChooseList(commands,default,0,-1)
end end
# Displays a list of all abilities, and returns the ID of the ability selected # 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 # (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 # the ability to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical. # sorting between numerical and alphabetical.
def pbChooseAbilityList(default=0) def pbChooseAbilityList(default = 0)
commands = [] commands = []
PokemonData::Ability.each do |a| GameData::Ability.each { |a| commands.push([a.id_number, a.name, a.id]) }
commands.push([a.id_number, a.name]) return pbChooseList(commands, default, nil, -1)
end
return pbChooseList(commands,default,0,-1)
end end
def pbChooseBallList(defaultMoveID=-1) def pbChooseBallList(defaultMoveID = -1)
cmdwin = pbListWindow([],200) cmdwin = pbListWindow([], 200)
commands = [] commands = []
moveDefault = 0 moveDefault = 0
for key in $BallTypes.keys for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key]) item = GameData::Item.try_get($BallTypes[key])
commands.push([key,item,PBItems.getName(item)]) if item && item>0 balls.push([key.to_i, item.name]) if item
end end
commands.sort! { |a,b| a[2]<=>b[2] } commands.sort! { |a, b| a[1] <=> b[1] }
if defaultMoveID>=0 if defaultMoveID >= 0
for i in 0...commands.length for i in 0...commands.length
moveDefault = i if defaultMoveID==commands[i][0] moveDefault = i if commands[i][0] == defaultMoveID
end end
end end
realcommands = [] realcommands = []
for i in commands for i in commands
realcommands.push(i[2]) realcommands.push(i[1])
end end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true) ret = pbCommands2(cmdwin, realcommands, -1, moveDefault, true)
cmdwin.dispose cmdwin.dispose
return (ret>=0) ? commands[ret][0] : defaultMoveID return (ret >= 0) ? commands[ret][0] : defaultMoveID
end end
@@ -486,39 +477,41 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false)
return ret return ret
end end
def pbChooseList(commands,default=0,cancelValue=-1,sortType=1) def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
cmdwin = pbListWindow([]) cmdwin = pbListWindow([])
itemID = default itemID = default
itemIndex = 0 itemIndex = 0
sortMode = (sortType>=0) ? sortType : 0 # 0=ID, 1=alphabetical sortMode = (sortType >= 0) ? sortType : 0 # 0=ID, 1=alphabetical
sorting = true sorting = true
loop do loop do
if sorting if sorting
if sortMode==0 if sortMode == 0
commands.sort! { |a,b| a[0]<=>b[0] } commands.sort! { |a, b| a[0] <=> b[0] }
elsif sortMode==1 elsif sortMode == 1
commands.sort! { |a,b| a[1]<=>b[1] } commands.sort! { |a, b| a[1] <=> b[1] }
end end
if itemID>0 if itemID.is_a?(Symbol)
commands.each_with_index { |command,i| itemIndex = i if command[0]==itemID } 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 end
realcommands = [] realcommands = []
for command in commands for command in commands
if sortType<=0 if sortType <= 0
realcommands.push(sprintf("%03d: %s",command[0],command[1])) realcommands.push(sprintf("%03d: %s", command[0], command[1]))
else else
realcommands.push(command[1]) realcommands.push(command[1])
end end
end end
sorting = false sorting = false
end end
cmd = pbCommandsSortable(cmdwin,realcommands,-1,itemIndex,(sortType<0)) cmd = pbCommandsSortable(cmdwin, realcommands, -1, itemIndex, (sortType < 0))
if cmd[0]==0 # Chose an option or cancelled if cmd[0] == 0 # Chose an option or cancelled
itemID = (cmd[1]<0) ? cancelValue : commands[cmd[1]][0] itemID = (cmd[1] < 0) ? cancelValue : (commands[cmd[1]][2] || commands[cmd[1]][0])
break break
elsif cmd[0]==1 # Toggle sorting elsif cmd[0] == 1 # Toggle sorting
itemID = commands[cmd[1]][0] itemID = commands[cmd[1]][2] || commands[cmd[1]][0]
sortMode = (sortMode+1)%2 sortMode = (sortMode + 1) % 2
sorting = true sorting = true
end end
end end
@@ -793,6 +793,7 @@ class MapScreenScene
serializeConnectionData serializeConnectionData
serializeMetadata serializeMetadata
save_data(@encdata,"Data/encounters.dat") save_data(@encdata,"Data/encounters.dat")
# TODO: Only need to reload connections, metadata, encounter data.
pbClearData pbClearData
pbSaveEncounterData pbSaveEncounterData
end end
+13 -9
View File
@@ -311,8 +311,8 @@ module Compiler
end end
return enumer.const_get(ret.to_sym) return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String) elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if enumer == :Ability if [:Ability, :Item].include?(enumer)
enumer = PokemonData.const_get(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym)
begin begin
if ret == "" || !enumer.exists?(ret.to_sym) if ret == "" || !enumer.exists?(ret.to_sym)
raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) 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 nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
return enumer.const_get(ret.to_sym) return enumer.const_get(ret.to_sym)
elsif enumer.is_a?(Symbol) || enumer.is_a?(String) elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
if enumer == :Ability if [:Ability, :Item].include?(enumer)
enumer = PokemonData.const_get(enumer.to_sym) enumer = GameData.const_get(enumer.to_sym)
return nil if ret == "" || !enumer.exists?(ret.to_sym) return nil if ret == "" || !enumer.exists?(ret.to_sym)
return ret.to_sym return ret.to_sym
end end
@@ -566,7 +566,11 @@ module Compiler
clonitem = item.upcase clonitem = item.upcase
clonitem.sub!(/^\s*/,"") clonitem.sub!(/^\s*/,"")
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 end
def parseSpecies(item) def parseSpecies(item)
@@ -623,17 +627,17 @@ module Compiler
yield(_INTL("Compiling item data")) yield(_INTL("Compiling item data"))
compile_items # Depends on PBMoves compile_items # Depends on PBMoves
yield(_INTL("Compiling berry plant data")) yield(_INTL("Compiling berry plant data"))
compile_berry_plants # Depends on PBItems compile_berry_plants # Depends on Item
yield(_INTL("Compiling Pokémon data")) 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")) 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")) yield(_INTL("Compiling machine data"))
compile_move_compatibilities # Depends on PBSpecies, PBMoves compile_move_compatibilities # Depends on PBSpecies, PBMoves
yield(_INTL("Compiling Trainer type data")) yield(_INTL("Compiling Trainer type data"))
compile_trainer_types # No dependencies compile_trainer_types # No dependencies
yield(_INTL("Compiling Trainer data")) yield(_INTL("Compiling Trainer data"))
compile_trainers # Depends on PBSpecies, PBItems, PBMoves compile_trainers # Depends on PBSpecies, Item, PBMoves
yield(_INTL("Compiling phone data")) yield(_INTL("Compiling phone data"))
compile_phone # Depends on PBTrainers compile_phone # Depends on PBTrainers
yield(_INTL("Compiling metadata")) yield(_INTL("Compiling metadata"))
+47 -59
View File
@@ -140,7 +140,7 @@ module Compiler
# Compile berry plants # Compile berry plants
#============================================================================= #=============================================================================
def compile_berry_plants def compile_berry_plants
sections = [] sections = {}
if File.exists?("PBS/berryplants.txt") if File.exists?("PBS/berryplants.txt")
pbCompilerEachCommentedLine("PBS/berryplants.txt") { |line,_lineno| pbCompilerEachCommentedLine("PBS/berryplants.txt") { |line,_lineno|
if line[ /^\s*(\w+)\s*=\s*(.*)$/ ] if line[ /^\s*(\w+)\s*=\s*(.*)$/ ]
@@ -157,7 +157,7 @@ module Compiler
end end
} }
end end
save_data(sections,"Data/berry_plants.dat") save_data(sections, "Data/berry_plants.dat")
end end
#============================================================================= #=============================================================================
@@ -326,15 +326,16 @@ module Compiler
# Compile abilities # Compile abilities
#============================================================================= #=============================================================================
def compile_abilities def compile_abilities
GameData::Ability::DATA.clear
ability_names = [] ability_names = []
ability_descriptions = [] ability_descriptions = []
pbCompilerEachPreppedLine("PBS/abilities.txt") { |line, line_no| pbCompilerEachPreppedLine("PBS/abilities.txt") { |line, line_no|
line = pbGetCsvRecord(line, line_no, [0, "vnss"]) line = pbGetCsvRecord(line, line_no, [0, "vnss"])
ability_number = line[0] ability_number = line[0]
ability_symbol = line[1].to_sym 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) 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) raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_symbol, FileLineData.linereport)
end end
# Construct ability hash # Construct ability hash
@@ -345,12 +346,12 @@ module Compiler
:description => line[3] :description => line[3]
} }
# Add ability's data to records # 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_names[ability_number] = ability_hash[:name]
ability_descriptions[ability_number] = ability_hash[:description] ability_descriptions[ability_number] = ability_hash[:description]
} }
# Save all data # Save all data
PokemonData::Ability.save GameData::Ability.save
MessageTypes.setMessages(MessageTypes::Abilities, ability_names) MessageTypes.setMessages(MessageTypes::Abilities, ability_names)
MessageTypes.setMessages(MessageTypes::AbilityDescs, ability_descriptions) MessageTypes.setMessages(MessageTypes::AbilityDescs, ability_descriptions)
Graphics.update Graphics.update
@@ -408,58 +409,45 @@ module Compiler
=end =end
def compile_items def compile_items
records = [] GameData::Item::DATA.clear
constants = "" item_names = []
itemnames = [] item_names_plural = []
itempluralnames = [] item_descriptions = []
itemdescs = [] # Read each line of items.txt at a time and compile it into an item
maxValue = 0 pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no|
pbCompilerEachCommentedLine("PBS/items.txt") { |line,lineno| line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"])
linerecord = pbGetCsvRecord(line,lineno,[0,"vnssuusuuUN"]) item_number = line[0]
id = linerecord[0] item_symbol = line[1].to_sym
if records[id] if GameData::Item::DATA[item_number]
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}",id,FileLineData.linereport) 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 end
record = [] # Construct item hash
record[ItemData::ID] = id item_hash = {
constant = linerecord[1] :id_number => item_number,
constants += "#{constant}=#{id}\r\n" :id => item_symbol,
record[ItemData::NAME] = linerecord[2] :name => line[2],
itemnames[id] = linerecord[2] :name_plural => line[3],
record[ItemData::NAME_PLURAL] = linerecord[3] :pocket => line[4],
itempluralnames[id] = linerecord[3] :price => line[5],
record[ItemData::POCKET] = linerecord[4] :description => line[6],
record[ItemData::PRICE] = linerecord[5] :field_use => line[7],
record[ItemData::DESCRIPTION] = linerecord[6] :battle_use => line[8],
itemdescs[id] = linerecord[6] :type => line[9]
record[ItemData::FIELD_USE] = linerecord[7] }
record[ItemData::BATTLE_USE] = linerecord[8] item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
record[ItemData::TYPE] = linerecord[9] # Add item's data to records
if record[ItemData::TYPE]!="" && linerecord[10] GameData::Item::DATA[item_number] = GameData::Item::DATA[item_symbol] = GameData::Item.new(item_hash)
record[ItemData::MOVE] = parseMove(linerecord[10]) item_names[item_number] = item_hash[:name]
else item_names_plural[item_number] = item_hash[:name_plural]
record[ItemData::MOVE] = 0 item_descriptions[item_number] = item_hash[:description]
end
maxValue = [maxValue,id].max
records[id] = record
} }
MessageTypes.setMessages(MessageTypes::Items,itemnames) # Save all data
MessageTypes.setMessages(MessageTypes::ItemPlurals,itempluralnames) GameData::Item.save
MessageTypes.setMessages(MessageTypes::ItemDescriptions,itemdescs) MessageTypes.setMessages(MessageTypes::Items, item_names)
save_data(records,"Data/items.dat") MessageTypes.setMessages(MessageTypes::ItemPlurals, item_names_plural)
code = "class PBItems\r\n" MessageTypes.setMessages(MessageTypes::ItemDescriptions, item_descriptions)
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")
Graphics.update Graphics.update
end end
@@ -1358,8 +1346,8 @@ module Compiler
trainernames[trainerindex] = record[0] trainernames[trainerindex] = record[0]
trainers[trainerindex][4] = record[1] if record[1] trainers[trainerindex][4] = record[1] if record[1]
when 3 # Number of Pokémon, items when 3 # Number of Pokémon, items
record = pbGetCsvRecord(line,lineno,[0,"vEEEEEEEE",nil,PBItems,PBItems, record = pbGetCsvRecord(line,lineno,[0,"vEEEEEEEE",nil,
PBItems,PBItems,PBItems,PBItems,PBItems,PBItems]) Item,Item,Item,Item,Item,Item,Item,Item])
record = [record] if record.is_a?(Integer) record = [record] if record.is_a?(Integer)
record.compact! record.compact!
oldcompilerlength += record[0] oldcompilerlength += record[0]
@@ -1369,7 +1357,7 @@ module Compiler
pokemonindex += 1 pokemonindex += 1
trainers[trainerindex][3][pokemonindex] = [] trainers[trainerindex][3][pokemonindex] = []
record = pbGetCsvRecord(line,lineno, 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, PBMoves,nil,{"M"=>0,"m"=>0,"Male"=>0,"male"=>0,
"0"=>0,"F"=>1,"f"=>1,"Female"=>1,"female"=>1, "0"=>0,"F"=>1,"f"=>1,"Female"=>1,"female"=>1,
"1"=>1},nil,nil,PBNatures,nil,nil,nil,nil,nil]) "1"=>1},nil,nil,PBNatures,nil,nil,nil,nil,nil])
@@ -729,12 +729,12 @@ module Compiler
hidden = false hidden = false
if name[/^HiddenItem\:\s*(\w+)\s*$/] if name[/^HiddenItem\:\s*(\w+)\s*$/]
itemName = $1 itemName = $1
return nil if !hasConst?(PBItems,itemName) return nil if !GameData::Item.exists?(itemName)
ret.name = "HiddenItem" ret.name = "HiddenItem"
hidden = true hidden = true
elsif name[/^Item\:\s*(\w+)\s*$/] elsif name[/^Item\:\s*(\w+)\s*$/]
itemName = $1 itemName = $1
return nil if !hasConst?(PBItems,itemName) return nil if !GameData::Item.exists?(itemName)
ret.name = "Item" ret.name = "Item"
else else
return nil return nil
@@ -953,7 +953,7 @@ module Compiler
if params[0][/SellItem\s*\(\s*(\w+)\s*\,\s*(\d+)\s*\)/] if params[0][/SellItem\s*\(\s*(\w+)\s*\,\s*(\d+)\s*\)/]
itemname = $1 itemname = $1
cost = $2.to_i cost = $2.to_i
if hasConst?(PBItems,itemname) if GameData::Item.exists?(itemname)
oldIndent = list[i].indent oldIndent = list[i].indent
list.delete_at(i) list.delete_at(i)
newEvents = [] newEvents = []