Added class Data::Ability and made all code use symbols for abilities instead of numbers. Also added class Data::Item but it's unused.

This commit is contained in:
Maruno17
2020-11-01 20:10:28 +00:00
parent c4e69d0a2e
commit 213347b938
34 changed files with 590 additions and 345 deletions

View File

@@ -147,6 +147,57 @@ end
# A stripped-down version of class HandlerHash which only deals with symbols and
# doesn't care about whether those symbols actually relate to a defined thing.
class HandlerHash2
def initialize
@hash = {}
@add_ifs = []
end
def [](sym)
return @hash[sym] if sym && @hash[sym]
for add_if in @add_ifs
return add_if[1] if add_if[0].call(sym)
end
return nil
end
def addIf(conditionProc, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
end
@add_ifs.push([conditionProc, handler || handlerBlock])
end
def add(sym, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)"
end
@hash[sym] = handler || handlerBlock if sym
end
def copy(src, *dests)
handler = self[src]
return if !handler
for dest in dests
self.add(dest, handler)
end
end
def clear
@hash.clear
end
def trigger(sym, *args)
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
handler = self[sym]
return (handler) ? handler.call(sym, *args) : nil
end
end
class SpeciesHandlerHash < HandlerHash class SpeciesHandlerHash < HandlerHash
def initialize def initialize
super(:PBSpecies) super(:PBSpecies)
@@ -155,10 +206,7 @@ end
class AbilityHandlerHash < HandlerHash class AbilityHandlerHash < HandlerHash2
def initialize
super(:PBAbilities)
end
end end

View File

@@ -190,9 +190,9 @@ module SpeciesData
def self.optionalValues(compilingForms = false) def self.optionalValues(compilingForms = false)
ret = { ret = {
"Type2" => [TYPE2, "e", :PBTypes], "Type2" => [TYPE2, "e", :PBTypes],
"Abilities" => [ABILITIES, "eE", :PBAbilities, :PBAbilities], "Abilities" => [ABILITIES, "eE", :Ability, :Ability],
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :PBAbilities, :PBAbilities, "HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
:PBAbilities, :PBAbilities], :Ability, :Ability],
"Habitat" => [HABITAT, "e", :PBHabitats], "Habitat" => [HABITAT, "e", :PBHabitats],
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems], "WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems],
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems], "WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems],

View File

@@ -0,0 +1,158 @@
class Data
class Item
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :real_name_plural
attr_reader :pocket
attr_reader :price
attr_reader :real_description
attr_reader :field_use
attr_reader :battle_use
attr_reader :type
attr_reader :move
DATA = {}
def initialize(hash)
validate hash => Hash, hash[:id] => Symbol
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@real_name_plural = hash[:name_plural] || "Unnamed"
@pocket = hash[:pocket] || 1
@price = hash[:price] || 0
@real_description = hash[:description] || "???"
@field_use = hash[:field_use] || 0
@battle_use = hash[:battle_use] || 0
@type = hash[:type] || 0
@move = hash[:move]
end
# @return [String] the translated name of this item
def name
return pbGetMessage(MessageTypes::Items, @id_number)
end
# @return [String] the translated plural version of the name of this item
def name_plural
return pbGetMessage(MessageTypes::ItemPlurals, @id_number)
end
# @return [String] the translated description of this item
def description
return pbGetMessage(MessageTypes::ItemDescriptions, @id_number)
end
# @param other [Symbol, Item, Integer]
# @return [Boolean] whether other is the same as this item
def ==(other)
return false if other.nil?
validate other => [Symbol, Item, Integer]
if other.is_a?(Symbol)
return @id == other
elsif other.is_a?(Item)
return @id == other.id
elsif other.is_a?(Integer)
return @id_number == other
end
return false
end
# @param item_id [Symbol, Item, Integer]
# @return [Boolean] whether the given item_id is defined as an Item
def self.exists?(item_id)
return false if item_id.nil?
validate item_id => [Symbol, Item, Integer]
item_id = item_id.id if item_id.is_a?(Item)
return !DATA[item_id].nil?
end
# @param item_id [Symbol, Item, Integer]
# @return [Item]
def self.get(item_id)
validate item_id => [Symbol, Item, Integer]
return item_id if item_id.is_a?(Item)
# if item_id.is_a?(Integer)
# p "Please switch to symbols, thanks."
# end
raise "Unknown item ID #{item_id}." unless DATA.has_key?(item_id)
return DATA[item_id]
end
def self.try_get(item_id)
return nil if item_id.nil?
validate item_id => [Symbol, Item, Integer]
return item_id if item_id.is_a?(Item)
# if item_id.is_a?(Integer)
# p "Please switch to symbols, thanks."
# end
return (DATA.has_key?(item_id)) ? DATA[item_id] : nil
end
def self.each
DATA.keys.sort.each do |key|
yield DATA[key] if key.is_a?(Symbol)
end
end
def self.load
const_set(:DATA, load_data("Data/items.dat"))
end
def self.save
save_data(DATA, "Data/items.dat")
end
end
end
module Compiler
module_function
def compile_items
item_names = []
item_names_plural = []
item_descriptions = []
# Read each line of items.txt at a time and compile it into an item
pbCompilerEachCommentedLine("PBS/items.txt") { |line, line_no|
line = pbGetCsvRecord(line, line_no, [0, "vnssuusuuUN"])
item_number = line[0]
item_symbol = line[1].to_sym
if Data::Item::DATA[item_number]
raise _INTL("Item ID number '{1}' is used twice.\r\n{2}", item_number, FileLineData.linereport)
elsif Data::Item::DATA[item_symbol]
raise _INTL("Item ID '{1}' is used twice.\r\n{2}", item_symbol, FileLineData.linereport)
end
# Construct item hash
item_hash = {
:id_number => item_number,
:id => item_symbol,
:name => line[2],
:name_plural => line[3],
:pocket => line[4],
:price => line[5],
:description => line[6],
:field_use => line[7],
:battle_use => line[8],
:type => line[9]
}
item_hash[:move] = parseMove(line[10]) if !nil_or_empty?(line[10])
# Add item's data to records
Data::Item::DATA[item_number] = Data::Item::DATA[item_symbol] = Data::Item.new(item_hash)
item_names[item_number] = item_hash[:name]
item_names_plural[item_number] = item_hash[:name_plural]
item_descriptions[item_number] = item_hash[:description]
}
# Save all data
Data::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

View File

@@ -0,0 +1,90 @@
class Data
class Ability
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :real_description
DATA = {}
def initialize(hash)
validate hash => Hash, hash[:id] => Symbol
@id = hash[:id]
@id_number = hash[:id_number] || -1
@real_name = hash[:name] || "Unnamed"
@real_description = hash[:description] || "???"
end
# @return [String] the translated name of this ability
def name
return pbGetMessage(MessageTypes::Abilities, @id_number)
end
# @return [String] the translated description of this ability
def description
return pbGetMessage(MessageTypes::AbilityDescs, @id_number)
end
# @param other [Symbol, Ability, Integer]
# @return [Boolean] whether other is the same as this ability
def ==(other)
return false if other.nil?
validate other => [Symbol, Ability, Integer]
if other.is_a?(Symbol)
return @id == other
elsif other.is_a?(Ability)
return @id == other.id
elsif other.is_a?(Integer)
return @id_number == other
end
return false
end
# @param ability_id [Symbol, Ability, Integer]
# @return [Boolean] whether the given ability_id is defined as an Ability
def self.exists?(ability_id)
return false if ability_id.nil?
validate ability_id => [Symbol, Ability, Integer]
ability_id = ability_id.id if ability_id.is_a?(Ability)
return !DATA[ability_id].nil?
end
# @param ability_id [Symbol, Ability, Integer]
# @return [Ability]
def self.get(ability_id)
validate ability_id => [Symbol, Ability, Integer]
return ability_id if ability_id.is_a?(Ability)
# if ability_id.is_a?(Integer)
# p "Please switch to symbols, thanks."
# end
raise "Unknown ability ID #{ability_id}." unless DATA.has_key?(ability_id)
return DATA[ability_id]
end
def self.try_get(ability_id)
return nil if ability_id.nil?
validate ability_id => [Symbol, Ability, Integer]
return ability_id if ability_id.is_a?(Ability)
# if ability_id.is_a?(Integer)
# p "Please switch to symbols, thanks."
# end
return (DATA.has_key?(ability_id)) ? DATA[ability_id] : nil
end
def self.each
DATA.keys.sort.each do |key|
yield DATA[key] if key.is_a?(Symbol)
end
end
def self.load
const_set(:DATA, load_data("Data/abilities.dat"))
end
def self.save
save_data(DATA, "Data/abilities.dat")
end
end
end

View File

@@ -181,7 +181,7 @@ class PokeBattle_Battler
end end
alias owned owned? alias owned owned?
def abilityName; return PBAbilities.getName(@ability); end def abilityName; return Data::Ability.get(@ability).name; end
def itemName; return PBItems.getName(@item); end def itemName; return PBItems.getName(@item); end
def pbThis(lowerCase=false) def pbThis(lowerCase=false)
@@ -324,17 +324,12 @@ class PokeBattle_Battler
return true return true
end end
def hasActiveAbility?(ability,ignoreFainted=false) def hasActiveAbility?(check_ability, ignoreFainted = false)
return false if !abilityActive?(ignoreFainted) return false if !abilityActive?(ignoreFainted)
if ability.is_a?(Array) if check_ability.is_a?(Array)
ability.each do |a| return check_ability.any? { |a| a == @ability }
a = getID(PBAbilities,a)
return true if a!=0 && a==@ability
end end
return false return check_ability == @ability
end
ability = getID(PBAbilities,ability)
return ability!=0 && ability==@ability
end end
alias hasWorkingAbility hasActiveAbility? alias hasWorkingAbility hasActiveAbility?
@@ -358,10 +353,7 @@ class PokeBattle_Battler
:COMATOSE, :COMATOSE,
:RKSSYSTEM :RKSSYSTEM
] ]
abilityBlacklist.each do |a| return abilityBlacklist.any? { |a| a == abil }
return true if isConst?(abil, PBAbilities, a)
end
return false
end end
# Applies to gaining the ability. # Applies to gaining the ability.
@@ -386,10 +378,7 @@ class PokeBattle_Battler
:COMATOSE, :COMATOSE,
:RKSSYSTEM :RKSSYSTEM
] ]
abilityBlacklist.each do |a| return abilityBlacklist.any? { |a| a == abil }
return true if isConst?(abil, PBAbilities, a)
end
return false
end end
def itemActive?(ignoreFainted=false) def itemActive?(ignoreFainted=false)
@@ -459,9 +448,7 @@ class PokeBattle_Battler
end end
def canChangeType? def canChangeType?
return false if isConst?(@ability,PBAbilities,:MULTITYPE) || return ![:MULTITYPE, :RKSSYSTEM].include?(@ability)
isConst?(@ability,PBAbilities,:RKSSYSTEM)
return true
end end
def airborne? def airborne?

View File

@@ -21,7 +21,7 @@ class PokeBattle_Battler
@level = 0 @level = 0
@hp = @totalhp = 0 @hp = @totalhp = 0
@type1 = @type2 = 0 @type1 = @type2 = 0
@ability = 0 @ability = nil
@item = 0 @item = 0
@gender = 0 @gender = 0
@attack = @defense = @spatk = @spdef = @speed = 0 @attack = @defense = @spatk = @spdef = @speed = 0
@@ -78,7 +78,7 @@ class PokeBattle_Battler
@totalhp = pkmn.totalhp @totalhp = pkmn.totalhp
@type1 = pkmn.type1 @type1 = pkmn.type1
@type2 = pkmn.type2 @type2 = pkmn.type2
@ability = pkmn.ability @ability = pkmn.ability_id
@item = pkmn.item @item = pkmn.item
@gender = pkmn.gender @gender = pkmn.gender
@attack = pkmn.attack @attack = pkmn.attack
@@ -297,7 +297,7 @@ class PokeBattle_Battler
if fullChange if fullChange
@type1 = @pokemon.type1 @type1 = @pokemon.type1
@type2 = @pokemon.type2 @type2 = @pokemon.type2
@ability = @pokemon.ability @ability = @pokemon.ability_id
end end
end end
end end

View File

@@ -209,7 +209,7 @@ class PokeBattle_Battler
# Form changes upon entering battle and when the weather changes # Form changes upon entering battle and when the weather changes
pbCheckFormOnWeatherChange if !endOfRound pbCheckFormOnWeatherChange if !endOfRound
# Darmanitan - Zen Mode # Darmanitan - Zen Mode
if isSpecies?(:DARMANITAN) && isConst?(@ability,PBAbilities,:ZENMODE) if isSpecies?(:DARMANITAN) && @ability == :ZENMODE
if @hp<=@totalhp/2 if @hp<=@totalhp/2
if @form!=1 if @form!=1
@battle.pbShowAbilitySplash(self,true) @battle.pbShowAbilitySplash(self,true)
@@ -223,7 +223,7 @@ class PokeBattle_Battler
end end
end end
# Minior - Shields Down # Minior - Shields Down
if isSpecies?(:MINIOR) && isConst?(@ability,PBAbilities,:SHIELDSDOWN) if isSpecies?(:MINIOR) && @ability == :SHIELDSDOWN
if @hp>@totalhp/2 # Turn into Meteor form if @hp>@totalhp/2 # Turn into Meteor form
newForm = (@form>=7) ? @form-7 : @form newForm = (@form>=7) ? @form-7 : @form
if @form!=newForm if @form!=newForm
@@ -240,7 +240,7 @@ class PokeBattle_Battler
end end
end end
# Wishiwashi - Schooling # Wishiwashi - Schooling
if isSpecies?(:WISHIWASHI) && isConst?(@ability,PBAbilities,:SCHOOLING) if isSpecies?(:WISHIWASHI) && @ability == :SCHOOLING
if @level>=20 && @hp>@totalhp/4 if @level>=20 && @hp>@totalhp/4
if @form!=1 if @form!=1
@battle.pbShowAbilitySplash(self,true) @battle.pbShowAbilitySplash(self,true)
@@ -254,8 +254,7 @@ class PokeBattle_Battler
end end
end end
# Zygarde - Power Construct # Zygarde - Power Construct
if isSpecies?(:ZYGARDE) && isConst?(@ability,PBAbilities,:POWERCONSTRUCT) && if isSpecies?(:ZYGARDE) && @ability == :POWERCONSTRUCT && endOfRound
endOfRound
if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme
newForm = @form+2 newForm = @form+2
@battle.pbDisplay(_INTL("You sense the presence of many!")) @battle.pbDisplay(_INTL("You sense the presence of many!"))

View File

@@ -75,9 +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? ||
isConst?(b.ability, PBAbilities, :POWEROFALCHEMY) || [:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability)
isConst?(b.ability, PBAbilities, :RECEIVER) ||
isConst?(b.ability, PBAbilities, :TRACE)
choices.push(b) choices.push(b)
end end
if choices.length>0 if choices.length>0
@@ -107,16 +105,16 @@ class PokeBattle_Battler
# Ability change # Ability change
#============================================================================= #=============================================================================
def pbOnAbilityChanged(oldAbil) def pbOnAbilityChanged(oldAbil)
if @effects[PBEffects::Illusion] && isConst?(oldAbil,PBAbilities,:ILLUSION) if @effects[PBEffects::Illusion] && oldAbil == :ILLUSION
@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,PBAbilities.getName(oldAbil))) @battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, Data::Ability.get(oldAbil).name))
@battle.pbSetSeen(self) @battle.pbSetSeen(self)
end end
end end
@effects[PBEffects::GastroAcid] = false if unstoppableAbility? @effects[PBEffects::GastroAcid] = false if unstoppableAbility?
@effects[PBEffects::SlowStart] = 0 if !isConst?(@ability,PBAbilities,:SLOWSTART) @effects[PBEffects::SlowStart] = 0 if @ability != :SLOWSTART
# Revert form if Flower Gift/Forecast was lost # Revert form if Flower Gift/Forecast was lost
pbCheckFormOnWeatherChange pbCheckFormOnWeatherChange
# Check for end of primordial weather # Check for end of primordial weather

View File

@@ -216,7 +216,7 @@ class PokeBattle_Battler
end end
end end
# Stance Change # Stance Change
if isSpecies?(:AEGISLASH) && isConst?(@ability,PBAbilities,:STANCECHANGE) if isSpecies?(:AEGISLASH) && @ability == :STANCECHANGE
if move.damagingMove? if move.damagingMove?
pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis)) pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis))
elsif isConst?(move.id,PBMoves,:KINGSSHIELD) elsif isConst?(move.id,PBMoves,:KINGSSHIELD)

View File

@@ -96,8 +96,7 @@ class PokeBattle_Battler
end end
# Greninja - Battle Bond # Greninja - Battle Bond
if !user.fainted? && !user.effects[PBEffects::Transform] && if !user.fainted? && !user.effects[PBEffects::Transform] &&
user.isSpecies?(:GRENINJA) && user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
isConst?(user.ability,PBAbilities,:BATTLEBOND)
if !@battle.pbAllFainted?(user.idxOpposingSide) && if !@battle.pbAllFainted?(user.idxOpposingSide) &&
!@battle.battleBond[user.index&1][user.pokemonIndex] !@battle.battleBond[user.index&1][user.pokemonIndex]
numFainted = 0 numFainted = 0

View File

@@ -165,7 +165,7 @@ class PokeBattle_Move
end end
# Disguise will take the damage # Disguise will take the damage
if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) && if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
target.form==0 && isConst?(target.ability,PBAbilities,:DISGUISE) target.form==0 && target.ability == :DISGUISE
target.damageState.disguise = true target.damageState.disguise = true
return return
end end

View File

@@ -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 !hasConst?(PBAbilities,:SIMPLE) # Ability isn't defined if !Data::Ability.exists?(:SIMPLE)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2005,9 +2005,7 @@ class PokeBattle_Move_063 < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.unstoppableAbility? || if target.unstoppableAbility? || [:TRUANT, :SIMPLE].include?(target.ability)
isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason
isConst?(target.ability, PBAbilities, :SIMPLE)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2017,7 +2015,7 @@ class PokeBattle_Move_063 < PokeBattle_Move
def pbEffectAgainstTarget(user,target) def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false) @battle.pbShowAbilitySplash(target,true,false)
oldAbil = target.ability oldAbil = target.ability
target.ability = getConst(PBAbilities,:SIMPLE) target.ability = :SIMPLE
@battle.pbReplaceAbilitySplash(target) @battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName)) @battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbHideAbilitySplash(target) @battle.pbHideAbilitySplash(target)
@@ -2032,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 !hasConst?(PBAbilities,:INSOMNIA) # Ability isn't defined if !Data::Ability.exists?(:INSOMNIA)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2040,9 +2038,7 @@ class PokeBattle_Move_064 < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.unstoppableAbility? || if target.unstoppableAbility? || [:TRUANT, :INSOMNIA].include?(target.ability)
isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason
isConst?(target.ability, PBAbilities, :INSOMNIA)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2052,7 +2048,7 @@ class PokeBattle_Move_064 < PokeBattle_Move
def pbEffectAgainstTarget(user,target) def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false) @battle.pbShowAbilitySplash(target,true,false)
oldAbil = target.ability oldAbil = target.ability
target.ability = getConst(PBAbilities,:INSOMNIA) target.ability = :INSOMNIA
@battle.pbReplaceAbilitySplash(target) @battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName)) @battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbHideAbilitySplash(target) @battle.pbHideAbilitySplash(target)
@@ -2082,10 +2078,7 @@ class PokeBattle_Move_065 < PokeBattle_Move
return true return true
end end
if target.ungainableAbility? || if target.ungainableAbility? ||
isConst?(target.ability, PBAbilities, :POWEROFALCHEMY) || [:POWEROFALCHEMY, :RECEIVER, :TRACE, :WONDERGUARD].include?(target.ability)
isConst?(target.ability, PBAbilities, :RECEIVER) ||
isConst?(target.ability, PBAbilities, :TRACE) ||
isConst?(target.ability, PBAbilities, :WONDERGUARD)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2117,9 +2110,7 @@ class PokeBattle_Move_066 < PokeBattle_Move
return true return true
end end
if user.ungainableAbility? || if user.ungainableAbility? ||
isConst?(user.ability, PBAbilities, :POWEROFALCHEMY) || [:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(user.ability)
isConst?(user.ability, PBAbilities, :RECEIVER) ||
isConst?(user.ability, PBAbilities, :TRACE)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2127,7 +2118,7 @@ class PokeBattle_Move_066 < PokeBattle_Move
end end
def pbFailsAgainstTarget?(user,target) def pbFailsAgainstTarget?(user,target)
if target.unstoppableAbility? || isConst?(target.ability, PBAbilities, :TRUANT) if target.unstoppableAbility? || target.ability == :TRUANT
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2163,7 +2154,7 @@ class PokeBattle_Move_067 < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
if user.ungainableAbility? || isConst?(user.ability, PBAbilities, :WONDERGUARD) if user.ungainableAbility? || user.ability == :WONDERGUARD
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -2180,7 +2171,7 @@ class PokeBattle_Move_067 < PokeBattle_Move
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
if target.ungainableAbility? || isConst?(target.ability, PBAbilities, :WONDERGUARD) if target.ungainableAbility? || target.ability == :WONDERGUARD
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end

View File

@@ -168,7 +168,7 @@ class PokeBattle_Battle
@battlers[0].effects[PBEffects::Outrage]==0 @battlers[0].effects[PBEffects::Outrage]==0
idxPartyForName = idxPartyNew idxPartyForName = idxPartyNew
enemyParty = pbParty(idxBattler) enemyParty = pbParty(idxBattler)
if isConst?(enemyParty[idxPartyNew].ability,PBAbilities,:ILLUSION) if enemyParty[idxPartyNew].ability == :ILLUSION
idxPartyForName = pbLastInTeam(idxBattler) idxPartyForName = pbLastInTeam(idxBattler)
end end
if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?", if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?",
@@ -254,7 +254,7 @@ class PokeBattle_Battle
def pbMessagesOnReplace(idxBattler,idxParty) def pbMessagesOnReplace(idxBattler,idxParty)
party = pbParty(idxBattler) party = pbParty(idxBattler)
newPkmnName = party[idxParty].name newPkmnName = party[idxParty].name
if isConst?(party[idxParty].ability,PBAbilities,:ILLUSION) if party[idxParty].ability == :ILLUSION
newPkmnName = party[pbLastInTeam(idxBattler)].name newPkmnName = party[pbLastInTeam(idxBattler)].name
end end
if pbOwnedByPlayer?(idxBattler) if pbOwnedByPlayer?(idxBattler)

View File

@@ -1308,8 +1308,7 @@ class PokeBattle_AI
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "05E" when "05E"
if isConst?(user.ability,PBAbilities,:MULTITYPE) || if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
score -= 90 score -= 90
else else
types = [] types = []
@@ -1323,8 +1322,7 @@ class PokeBattle_AI
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "05F" when "05F"
if isConst?(user.ability,PBAbilities,:MULTITYPE) || if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
score -= 90 score -= 90
elsif target.lastMoveUsed<=0 || elsif target.lastMoveUsed<=0 ||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE)) PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
@@ -1349,8 +1347,7 @@ class PokeBattle_AI
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "060" when "060"
if isConst?(user.ability,PBAbilities,:MULTITYPE) || if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
score -= 90 score -= 90
elsif skill>=PBTrainerAI.mediumSkill elsif skill>=PBTrainerAI.mediumSkill
envtypes = [ envtypes = [
@@ -1370,16 +1367,14 @@ class PokeBattle_AI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "061" when "061"
if target.effects[PBEffects::Substitute]>0 || if target.effects[PBEffects::Substitute]>0 ||
isConst?(target.ability,PBAbilities,:MULTITYPE) || target.ability == :MULTITYPE || target.ability == :RKSSYSTEM
isConst?(target.ability,PBAbilities,:RKSSYSTEM)
score -= 90 score -= 90
elsif target.pbHasType?(:WATER) elsif target.pbHasType?(:WATER)
score -= 90 score -= 90
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "062" when "062"
if isConst?(user.ability,PBAbilities,:MULTITYPE) || if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
score -= 90 score -= 90
elsif user.pbHasType?(target.type1) && elsif user.pbHasType?(target.type1) &&
user.pbHasType?(target.type2) && user.pbHasType?(target.type2) &&
@@ -1392,10 +1387,7 @@ class PokeBattle_AI
if target.effects[PBEffects::Substitute]>0 if target.effects[PBEffects::Substitute]>0
score -= 90 score -= 90
elsif skill>=PBTrainerAI.mediumSkill elsif skill>=PBTrainerAI.mediumSkill
if isConst?(target.ability,PBAbilities,:MULTITYPE) || if [:MULTITYPE, :RKSSYSTEM, :SIMPLE, :TRUANT].include?(target.ability)
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(target.ability,PBAbilities,:SIMPLE) ||
isConst?(target.ability,PBAbilities,:TRUANT)
score -= 90 score -= 90
end end
end end
@@ -1404,10 +1396,7 @@ class PokeBattle_AI
if target.effects[PBEffects::Substitute]>0 if target.effects[PBEffects::Substitute]>0
score -= 90 score -= 90
elsif skill>=PBTrainerAI.mediumSkill elsif skill>=PBTrainerAI.mediumSkill
if isConst?(target.ability,PBAbilities,:INSOMNIA) || if [:INSOMNIA, :MULTITYPE, :RKSSYSTEM, :TRUANT].include?(target.ability)
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(target.ability,PBAbilities,:TRUANT)
score -= 90 score -= 90
end end
end end
@@ -1416,26 +1405,16 @@ class PokeBattle_AI
score -= 40 # don't prefer this move score -= 40 # don't prefer this move
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
if target.ability==0 || user.ability==target.ability || if target.ability==0 || user.ability==target.ability ||
isConst?(user.ability,PBAbilities,:MULTITYPE) || [:MULTITYPE, :RKSSYSTEM].include?(user.ability) ||
isConst?(user.ability,PBAbilities,:RKSSYSTEM) || [:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM,
isConst?(target.ability,PBAbilities,:FLOWERGIFT) || :TRACE, :WONDERGUARD, :ZENMODE].include?(target.ability)
isConst?(target.ability,PBAbilities,:FORECAST) ||
isConst?(target.ability,PBAbilities,:ILLUSION) ||
isConst?(target.ability,PBAbilities,:IMPOSTER) ||
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(target.ability,PBAbilities,:TRACE) ||
isConst?(target.ability,PBAbilities,:WONDERGUARD) ||
isConst?(target.ability,PBAbilities,:ZENMODE)
score -= 90 score -= 90
end end
end end
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
if isConst?(target.ability,PBAbilities,:TRUANT) && if target.ability == :TRUANT && user.opposes?(target)
user.opposes?(target)
score -= 90 score -= 90
elsif isConst?(target.ability,PBAbilities,:SLOWSTART) && elsif target.ability == :SLOWSTART && user.opposes?(target)
user.opposes?(target)
score -= 90 score -= 90
end end
end end
@@ -1446,25 +1425,15 @@ class PokeBattle_AI
score -= 90 score -= 90
elsif skill>=PBTrainerAI.mediumSkill elsif skill>=PBTrainerAI.mediumSkill
if user.ability==0 || user.ability==target.ability || if user.ability==0 || user.ability==target.ability ||
isConst?(target.ability,PBAbilities,:MULTITYPE) || [:MULTITYPE, :RKSSYSTEM, :TRUANT].include?(target.ability) ||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) || [:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM,
isConst?(target.ability,PBAbilities,:TRUANT) || :TRACE, :ZENMODE].include?(user.ability)
isConst?(user.ability,PBAbilities,:FLOWERGIFT) ||
isConst?(user.ability,PBAbilities,:FORECAST) ||
isConst?(user.ability,PBAbilities,:ILLUSION) ||
isConst?(user.ability,PBAbilities,:IMPOSTER) ||
isConst?(user.ability,PBAbilities,:MULTITYPE) ||
isConst?(user.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(user.ability,PBAbilities,:TRACE) ||
isConst?(user.ability,PBAbilities,:ZENMODE)
score -= 90 score -= 90
end end
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
if isConst?(user.ability,PBAbilities,:TRUANT) && if user.ability == :TRUANT && user.opposes?(target)
user.opposes?(target)
score += 90 score += 90
elsif isConst?(user.ability,PBAbilities,:SLOWSTART) && elsif user.ability == :SLOWSTART && user.opposes?(target)
user.opposes?(target)
score += 90 score += 90
end end
end end
@@ -1475,23 +1444,15 @@ class PokeBattle_AI
if skill>=PBTrainerAI.mediumSkill if skill>=PBTrainerAI.mediumSkill
if (user.ability==0 && target.ability==0) || if (user.ability==0 && target.ability==0) ||
user.ability==target.ability || user.ability==target.ability ||
isConst?(user.ability,PBAbilities,:ILLUSION) || [:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(user.ability) ||
isConst?(user.ability,PBAbilities,:MULTITYPE) || [:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(target.ability)
isConst?(user.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(user.ability,PBAbilities,:WONDERGUARD) ||
isConst?(target.ability,PBAbilities,:ILLUSION) ||
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
isConst?(target.ability,PBAbilities,:WONDERGUARD)
score -= 90 score -= 90
end end
end end
if skill>=PBTrainerAI.highSkill if skill>=PBTrainerAI.highSkill
if isConst?(target.ability,PBAbilities,:TRUANT) && if target.ability == :TRUANT && user.opposes?(target)
user.opposes?(target)
score -= 90 score -= 90
elsif isConst?(target.ability,PBAbilities,:SLOWSTART) && elsif target.ability == :SLOWSTART && user.opposes?(target)
user.opposes?(target)
score -= 90 score -= 90
end end
end end
@@ -1501,10 +1462,7 @@ class PokeBattle_AI
target.effects[PBEffects::GastroAcid] target.effects[PBEffects::GastroAcid]
score -= 90 score -= 90
elsif skill>=PBTrainerAI.highSkill elsif skill>=PBTrainerAI.highSkill
score -= 90 if isConst?(target.ability,PBAbilities,:MULTITYPE) score -= 90 if [:MULTITYPE, :RKSSYSTEM, :SLOWSTART, :TRUANT].include?(target.ability)
score -= 90 if isConst?(target.ability,PBAbilities,:RKSSYSTEM)
score -= 90 if isConst?(target.ability,PBAbilities,:SLOWSTART)
score -= 90 if isConst?(target.ability,PBAbilities,:TRUANT)
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
when "069" when "069"

View File

@@ -2419,10 +2419,7 @@ BattleHandlers::AbilityChangeOnBattlerFainting.add(:POWEROFALCHEMY,
proc { |ability,battler,fainted,battle| proc { |ability,battler,fainted,battle|
next if battler.opposes?(fainted) next if battler.opposes?(fainted)
next if fainted.ungainableAbility? || next if fainted.ungainableAbility? ||
isConst?(fainted.ability, PBAbilities, :POWEROFALCHEMY) || [:POWEROFALCHEMY, :RECEIVER, :TRACE, :WONDERGUARD].include?(fainted.ability)
isConst?(fainted.ability, PBAbilities, :RECEIVER) ||
isConst?(fainted.ability, PBAbilities, :TRACE) ||
isConst?(fainted.ability, PBAbilities, :WONDERGUARD)
battle.pbShowAbilitySplash(battler,true) battle.pbShowAbilitySplash(battler,true)
battler.ability = fainted.ability battler.ability = fainted.ability
battle.pbReplaceAbilitySplash(battler) battle.pbReplaceAbilitySplash(battler)

View File

@@ -277,7 +277,7 @@ Events.onStepTakenTransferPossible += proc { |_sender,e|
if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD
flashed = false flashed = false
for i in $Trainer.ablePokemonParty for i in $Trainer.ablePokemonParty
if i.status==PBStatuses::POISON && !isConst?(i.ability,PBAbilities,:IMMUNITY) if i.status==PBStatuses::POISON && !i.hasAbility?(:IMMUNITY)
if !flashed if !flashed
$game_screen.start_flash(Color.new(255,0,0,128), 4) $game_screen.start_flash(Color.new(255,0,0,128), 4)
flashed = true flashed = true
@@ -1161,9 +1161,7 @@ def pbFishingEnd
end end
def pbFishing(hasEncounter,rodType=1) def pbFishing(hasEncounter,rodType=1)
speedup = ($Trainer.firstPokemon && speedup = ($Trainer.firstPokemon && [:STICKYHOLD, :SUCTIONCUPS].include?($Trainer.firstPokemon.ability))
(isConst?($Trainer.firstPokemon.ability,PBAbilities,:STICKYHOLD) ||
isConst?($Trainer.firstPokemon.ability,PBAbilities,:SUCTIONCUPS)))
biteChance = 20+(25*rodType) # 45, 70, 95 biteChance = 20+(25*rodType) # 45, 70, 95
biteChance *= 1.5 if speedup # 67.5, 100, 100 biteChance *= 1.5 if speedup # 67.5, 100, 100
hookChance = 100 hookChance = 100

View File

@@ -243,9 +243,9 @@ class PokemonEncounters
firstPkmn = $Trainer.firstPokemon firstPkmn = $Trainer.firstPokemon
if firstPkmn && rand(100)<50 # 50% chance of happening if firstPkmn && rand(100)<50 # 50% chance of happening
favoredType = -1 favoredType = -1
if isConst?(firstPkmn.ability,PBAbilities,:STATIC) && hasConst?(PBTypes,:ELECTRIC) if firstPkmn.hasAbility?(:STATIC) && hasConst?(PBTypes,:ELECTRIC)
favoredType = getConst(PBTypes,:ELECTRIC) favoredType = getConst(PBTypes,:ELECTRIC)
elsif isConst?(firstPkmn.ability,PBAbilities,:MAGNETPULL) && hasConst?(PBTypes,:STEEL) elsif firstPkmn.hasAbility?(:MAGNETPULL) && hasConst?(PBTypes,:STEEL)
favoredType = getConst(PBTypes,:STEEL) favoredType = getConst(PBTypes,:STEEL)
end end
if favoredType>=0 if favoredType>=0
@@ -289,9 +289,9 @@ class PokemonEncounters
level = encounter[1]+rand(1+encounter[2]-encounter[1]) level = encounter[1]+rand(1+encounter[2]-encounter[1])
# Some abilities alter the level of the wild Pokémon # Some abilities alter the level of the wild Pokémon
if firstPkmn && rand(100)<50 # 50% chance of happening if firstPkmn && rand(100)<50 # 50% chance of happening
if isConst?(firstPkmn.ability,PBAbilities,:HUSTLE) || if firstPkmn.hasAbility?(:HUSTLE) ||
isConst?(firstPkmn.ability,PBAbilities,:VITALSPIRIT) || firstPkmn.hasAbility?(:PRESSURE) ||
isConst?(firstPkmn.ability,PBAbilities,:PRESSURE) firstPkmn.hasAbility?(:VITALSPIRIT)
level2 = encounter[1]+rand(1+encounter[2]-encounter[1]) level2 = encounter[1]+rand(1+encounter[2]-encounter[1])
level = level2 if level2>level # Higher level is more likely level = level2 if level2>level # Higher level is more likely
end end
@@ -343,24 +343,24 @@ class PokemonEncounters
elsif firstPkmn.hasItem?(:PUREINCENSE) elsif firstPkmn.hasItem?(:PUREINCENSE)
encount = encount*2/3 encount = encount*2/3
else # Ignore ability effects if an item effect applies else # Ignore ability effects if an item effect applies
if isConst?(firstPkmn.ability,PBAbilities,:STENCH) if firstPkmn.hasAbility?(:STENCH)
encount = encount/2 encount = encount/2
elsif isConst?(firstPkmn.ability,PBAbilities,:WHITESMOKE) elsif firstPkmn.hasAbility?(:WHITESMOKE)
encount = encount/2 encount = encount/2
elsif isConst?(firstPkmn.ability,PBAbilities,:QUICKFEET) elsif firstPkmn.hasAbility?(:QUICKFEET)
encount = encount/2 encount = encount/2
elsif isConst?(firstPkmn.ability,PBAbilities,:SNOWCLOAK) elsif firstPkmn.hasAbility?(:SNOWCLOAK)
encount = encount/2 if $game_screen.weather_type==PBFieldWeather::Snow || encount = encount/2 if $game_screen.weather_type==PBFieldWeather::Snow ||
$game_screen.weather_type==PBFieldWeather::Blizzard $game_screen.weather_type==PBFieldWeather::Blizzard
elsif isConst?(firstPkmn.ability,PBAbilities,:SANDVEIL) elsif firstPkmn.hasAbility?(:SANDVEIL)
encount = encount/2 if $game_screen.weather_type==PBFieldWeather::Sandstorm encount = encount/2 if $game_screen.weather_type==PBFieldWeather::Sandstorm
elsif isConst?(firstPkmn.ability,PBAbilities,:SWARM) elsif firstPkmn.hasAbility?(:SWARM)
encount = encount*1.5 encount = encount*1.5
elsif isConst?(firstPkmn.ability,PBAbilities,:ILLUMINATE) elsif firstPkmn.hasAbility?(:ILLUMINATE)
encount = encount*2 encount = encount*2
elsif isConst?(firstPkmn.ability,PBAbilities,:ARENATRAP) elsif firstPkmn.hasAbility?(:ARENATRAP)
encount = encount*2 encount = encount*2
elsif isConst?(firstPkmn.ability,PBAbilities,:NOGUARD) elsif firstPkmn.hasAbility?(:NOGUARD)
encount = encount*2 encount = encount*2
end end
end end
@@ -373,8 +373,7 @@ class PokemonEncounters
# Some abilities make wild encounters less likely if the wild Pokémon is # Some abilities make wild encounters less likely if the wild Pokémon is
# sufficiently weaker than the Pokémon with the ability # sufficiently weaker than the Pokémon with the ability
if firstPkmn && rand(100)<50 # 50% chance of happening if firstPkmn && rand(100)<50 # 50% chance of happening
if isConst?(firstPkmn.ability,PBAbilities,:INTIMIDATE) || if firstPkmn.hasAbility?(:INTIMIDATE) || firstPkmn.hasAbility?(:KEENEYE)
isConst?(firstPkmn.ability,PBAbilities,:KEENEYE)
return nil if encPkmn[1]<=firstPkmn.level-5 # 5 or more levels weaker return nil if encPkmn[1]<=firstPkmn.level-5 # 5 or more levels weaker
end end
end end
@@ -409,7 +408,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
items = genwildpoke.wildHoldItems items = genwildpoke.wildHoldItems
firstPkmn = $Trainer.firstPokemon firstPkmn = $Trainer.firstPokemon
chances = [50,5,1] chances = [50,5,1]
chances = [60,20,5] if firstPkmn && isConst?(firstPkmn.ability,PBAbilities,:COMPOUNDEYES) chances = [60,20,5] if firstPkmn && firstPkmn.hasAbility?(:COMPOUNDEYES)
itemrnd = rand(100) itemrnd = rand(100)
if (items[0]==items[1] && items[1]==items[2]) || itemrnd<chances[0] if (items[0]==items[1] && items[1]==items[2]) || itemrnd<chances[0]
genwildpoke.setItem(items[0]) genwildpoke.setItem(items[0])
@@ -432,13 +431,13 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
# Change wild Pokémon's gender/nature depending on the lead party Pokémon's # Change wild Pokémon's gender/nature depending on the lead party Pokémon's
# ability # ability
if firstPkmn if firstPkmn
if isConst?(firstPkmn.ability,PBAbilities,:CUTECHARM) && !genwildpoke.singleGendered? if firstPkmn.hasAbility?(:CUTECHARM) && !genwildpoke.singleGendered?
if firstPkmn.male? if firstPkmn.male?
(rand(3)<2) ? genwildpoke.makeFemale : genwildpoke.makeMale (rand(3)<2) ? genwildpoke.makeFemale : genwildpoke.makeMale
elsif firstPkmn.female? elsif firstPkmn.female?
(rand(3)<2) ? genwildpoke.makeMale : genwildpoke.makeFemale (rand(3)<2) ? genwildpoke.makeMale : genwildpoke.makeFemale
end end
elsif isConst?(firstPkmn.ability,PBAbilities,:SYNCHRONIZE) elsif firstPkmn.hasAbility?(:SYNCHRONIZE)
genwildpoke.setNature(firstPkmn.nature) if !isRoamer && rand(100)<50 genwildpoke.setNature(firstPkmn.nature) if !isRoamer && rand(100)<50
end end
end end

View File

@@ -167,10 +167,8 @@ def pbIsHiddenMove?(move)
end end
def pbIsUnlosableItem?(item,species,ability) def pbIsUnlosableItem?(item,species,ability)
return false if isConst?(species,PBSpecies,:ARCEUS) && return false if isConst?(species,PBSpecies,:ARCEUS) && ability != :MULTITYPE
!isConst?(ability,PBAbilities,:MULTITYPE) return false if isConst?(species,PBSpecies,:SILVALLY) && ability != :RKSSYSTEM
return false if isConst?(species,PBSpecies,:SILVALLY) &&
!isConst?(ability,PBAbilities,:RKSSYSTEM)
combos = { combos = {
:ARCEUS => [:FISTPLATE, :FIGHTINIUMZ, :ARCEUS => [:FISTPLATE, :FIGHTINIUMZ,
:SKYPLATE, :FLYINIUMZ, :SKYPLATE, :FLYINIUMZ,

View File

@@ -1086,23 +1086,22 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene| ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|
abils = pkmn.getAbilityList abils = pkmn.getAbilityList
abil1 = 0; abil2 = 0 abil1 = nil; abil2 = nil
for i in abils for i in abils
abil1 = i[0] if i[1]==0 abil1 = i[0] if i[1]==0
abil2 = i[0] if i[1]==1 abil2 = i[0] if i[1]==1
end end
if abil1<=0 || abil2<=0 || pkmn.hasHiddenAbility? || pkmn.isSpecies?(:ZYGARDE) if abil1.nil? || abil2.nil? || pkmn.hasHiddenAbility? || pkmn.isSpecies?(:ZYGARDE)
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
next false next false
end end
newabil = (pkmn.abilityIndex+1)%2 newabil = (pkmn.abilityIndex+1)%2
newabilname = PBAbilities.getName((newabil==0) ? abil1 : abil2) newabilname = Data::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)
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!",pkmn.name, scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!",pkmn.name,newabilname))
PBAbilities.getName(pkmn.ability)))
next true next true
end end
next false next false

View File

@@ -279,17 +279,23 @@ class Pokemon
return @abilityflag || (@personalID & 1) return @abilityflag || (@personalID & 1)
end end
# @return [Integer] the ID of this Pokémon's ability # @return [Data::Ability] an Ability object corresponding to this Pokémon's ability
def ability def ability
ret = ability_id
return Data::Ability.try_get(ret)
end
# @return [Symbol] the ability symbol of this Pokémon's ability
def ability_id
abilIndex = abilityIndex abilIndex = abilityIndex
# Hidden ability # Hidden ability
if abilIndex >= 2 if abilIndex >= 2
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 ret && ret > 0 return ret if Data::Ability.exists?(ret)
else elsif abilIndex == 2
return hiddenAbil if abilIndex == 2 && hiddenAbil > 0 return hiddenAbil if Data::Ability.exists?(hiddenAbil)
end end
abilIndex = (@personalID & 1) abilIndex = (@personalID & 1)
end end
@@ -297,10 +303,10 @@ 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 !ret || ret == 0 ret = abilities[(abilIndex + 1) % 2] if !Data::Ability.exists?(ret)
return ret || 0 return ret
end end
return abilities || 0 return abilities
end end
# Returns whether this Pokémon has a particular ability. If no value # Returns whether this Pokémon has a particular ability. If no value
@@ -308,10 +314,10 @@ class Pokemon
# @param ability [Integer] ability ID to check # @param 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?(ability = 0) def hasAbility?(check_ability = nil)
current_ability = self.ability current_ability = self.ability
return current_ability > 0 if ability == 0 return !current_ability.nil? if check_ability.nil?
return current_ability == getID(PBAbilities, ability) return current_ability == check_ability
end end
# Sets this Pokémon's ability index. # Sets this Pokémon's ability index.
@@ -323,7 +329,7 @@ class Pokemon
# @return [Boolean] whether this Pokémon has a hidden ability # @return [Boolean] whether this Pokémon has a hidden ability
def hasHiddenAbility? def hasHiddenAbility?
abil = abilityIndex abil = abilityIndex
return abil != nil && abil >= 2 return abil >= 2
end end
# @return [Array<Array<Integer>>] the list of abilities this Pokémon can have, # @return [Array<Array<Integer>>] the list of abilities this Pokémon can have,
@@ -332,13 +338,13 @@ class Pokemon
ret = [] ret = []
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES) abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
if abilities.is_a?(Array) if abilities.is_a?(Array)
abilities.each_with_index { |a, i| ret.push([a, i]) if a && a > 0 } abilities.each_with_index { |a, i| ret.push([a, i]) if a }
else else
ret.push([abilities, 0]) if abilities > 0 ret.push([abilities, 0]) if abilities > 0
end end
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY) hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
if hiddenAbil.is_a?(Array) if hiddenAbil.is_a?(Array)
hiddenAbil.each_with_index { |a, i| ret.push([a, i + 2]) if a && a > 0 } hiddenAbil.each_with_index { |a, i| ret.push([a, i + 2]) if a }
else else
ret.push([hiddenAbil, 2]) if hiddenAbil > 0 ret.push([hiddenAbil, 2]) if hiddenAbil > 0
end end
@@ -387,7 +393,7 @@ class Pokemon
# @return [Boolean] whether this Pokémon is shiny (differently colored) # @return [Boolean] whether this Pokémon is shiny (differently colored)
def shiny? def shiny?
return @shinyflag if @shinyflag != nil return @shinyflag if @shinyflag != nil
a = @personalID ^ @trainerID a = @personalID ^ @owner.id
b = a & 0xFFFF b = a & 0xFFFF
c = (a >> 16) & 0xFFFF c = (a >> 16) & 0xFFFF
d = b ^ c d = b ^ c

View File

@@ -336,7 +336,7 @@ MultipleForms.register(:SHAYMIN,{
MultipleForms.register(:ARCEUS,{ MultipleForms.register(:ARCEUS,{
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
next nil if !isConst?(pkmn.ability,PBAbilities,:MULTITYPE) next nil if !pkmn.hasAbility?(:MULTITYPE)
typeArray = { typeArray = {
1 => [:FISTPLATE, :FIGHTINIUMZ], 1 => [:FISTPLATE, :FIGHTINIUMZ],
2 => [:SKYPLATE, :FLYINIUMZ], 2 => [:SKYPLATE, :FLYINIUMZ],
@@ -573,7 +573,7 @@ MultipleForms.register(:WISHIWASHI,{
MultipleForms.register(:SILVALLY,{ MultipleForms.register(:SILVALLY,{
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
next nil if !isConst?(pkmn.ability,PBAbilities,:RKSSYSTEM) next nil if !pkmn.hasAbility?(:RKSSYSTEM)
typeArray = { typeArray = {
1 => [:FIGHTINGMEMORY], 1 => [:FIGHTINGMEMORY],
2 => [:FLYINGMEMORY], 2 => [:FLYINGMEMORY],

View File

@@ -259,7 +259,7 @@ end
def pbCheckEvolutionEx(pokemon) def pbCheckEvolutionEx(pokemon)
return -1 if pokemon.species<=0 || pokemon.egg? || pokemon.shadowPokemon? return -1 if pokemon.species<=0 || pokemon.egg? || pokemon.shadowPokemon?
return -1 if pokemon.hasItem?(:EVERSTONE) return -1 if pokemon.hasItem?(:EVERSTONE)
return -1 if isConst?(pokemon.ability,PBAbilities,:BATTLEBOND) return -1 if pokemon.hasAbility?(:BATTLEBOND)
ret = -1 ret = -1
for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form),true) for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form),true)
ret = yield pokemon,form[0],form[1],form[2] ret = yield pokemon,form[0],form[1],form[2]

View File

@@ -634,14 +634,16 @@ class PokemonSummary_Scene
[sprintf("%d",@pokemon.spdef),456,216,1,Color.new(64,64,64),Color.new(176,176,176)], [sprintf("%d",@pokemon.spdef),456,216,1,Color.new(64,64,64),Color.new(176,176,176)],
[_INTL("Speed"),248,248,0,base,statshadows[PBStats::SPEED]], [_INTL("Speed"),248,248,0,base,statshadows[PBStats::SPEED]],
[sprintf("%d",@pokemon.speed),456,248,1,Color.new(64,64,64),Color.new(176,176,176)], [sprintf("%d",@pokemon.speed),456,248,1,Color.new(64,64,64),Color.new(176,176,176)],
[_INTL("Ability"),224,284,0,base,shadow], [_INTL("Ability"),224,284,0,base,shadow]
[PBAbilities.getName(@pokemon.ability),362,284,0,Color.new(64,64,64),Color.new(176,176,176)],
] ]
# Draw ability name and description
ability = @pokemon.ability
if ability
textpos.push([ability.name,362,284,0,Color.new(64,64,64),Color.new(176,176,176)])
drawTextEx(overlay,224,316,282,2,ability.description,Color.new(64,64,64),Color.new(176,176,176))
end
# Draw all text # Draw all text
pbDrawTextPositions(overlay,textpos) pbDrawTextPositions(overlay,textpos)
# Draw ability description
abilitydesc = pbGetMessage(MessageTypes::AbilityDescs,@pokemon.ability)
drawTextEx(overlay,224,316,282,2,abilitydesc,Color.new(64,64,64),Color.new(176,176,176))
# Draw HP bar # Draw HP bar
if @pokemon.hp>0 if @pokemon.hp>0
w = @pokemon.hp*96*1.0/@pokemon.totalhp w = @pokemon.hp*96*1.0/@pokemon.totalhp

View File

@@ -268,6 +268,7 @@ class PokemonLoadScreen
$scene = nil $scene = nil
return return
end end
Data::Ability.load
commands = [] commands = []
cmdContinue = -1 cmdContinue = -1
cmdNewGame = -1 cmdNewGame = -1

View File

@@ -1415,8 +1415,9 @@ 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])
if pokemon.ability>0 ability = pokemon.ability
textstrings.push([PBAbilities.getName(pokemon.ability),86,306,2,base,shadow]) if ability
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

View File

@@ -219,8 +219,7 @@ Events.onStepTaken += proc { |_sender,_e|
next if egg.eggsteps<=0 next if egg.eggsteps<=0
egg.eggsteps -= 1 egg.eggsteps -= 1
for i in $Trainer.pokemonParty for i in $Trainer.pokemonParty
next if !isConst?(i.ability,PBAbilities,:FLAMEBODY) && next if !i.hasAbility?(:FLAMEBODY) && !i.hasAbility?(:MAGMAARMOR)
!isConst?(i.ability,PBAbilities,:MAGMAARMOR)
egg.eggsteps -= 1 egg.eggsteps -= 1
break break
end end

View File

@@ -399,8 +399,7 @@ class StandardRestriction
abilities = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::ABILITIES) abilities = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::ABILITIES)
abilities = [abilities] if !abilities.is_a?(Array) abilities = [abilities] if !abilities.is_a?(Array)
abilities.each do |a| abilities.each do |a|
return true if isConst?(a,PBAbilities,:TRUANT) || return true if [:TRUANT, :SLOWSTART].include?(a)
isConst?(a,PBAbilities,:SLOWSTART)
end end
# Certain named species are not banned # Certain named species are not banned
speciesWhitelist = [:DRAGONITE,:SALAMENCE,:TYRANITAR] speciesWhitelist = [:DRAGONITE,:SALAMENCE,:TYRANITAR]

View File

@@ -836,10 +836,10 @@ def pbDecideWinnerEffectiveness(move,otype1,otype2,ability,scores)
return 0 if data.basedamage==0 return 0 if data.basedamage==0
atype=data.type atype=data.type
typemod=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE*PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE typemod=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE*PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE
if !isConst?(ability,PBAbilities,:LEVITATE) || !isConst?(data.type,PBTypes,:GROUND) if ability != :LEVITATE || !isConst?(data.type,PBTypes,:GROUND)
mod1=PBTypes.getEffectiveness(atype,otype1) mod1=PBTypes.getEffectiveness(atype,otype1)
mod2=(otype1==otype2) ? PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE : PBTypes.getEffectiveness(atype,otype2) mod2=(otype1==otype2) ? PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE : PBTypes.getEffectiveness(atype,otype2)
if isConst?(ability,PBAbilities,:WONDERGUARD) if ability == :WONDERGUARD
mod1=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !PBTypes.superEffective?(mod1) mod1=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !PBTypes.superEffective?(mod1)
mod2=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !PBTypes.superEffective?(mod2) mod2=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !PBTypes.superEffective?(mod2)
end end
@@ -862,7 +862,7 @@ def pbDecideWinnerScore(party0,party1,rating)
for j in 0...party1.length for j in 0...party1.length
types1.push(party1[j].type1) types1.push(party1[j].type1)
types2.push(party1[j].type2) types2.push(party1[j].type2)
abilities.push(party1[j].ability) abilities.push(party1[j].ability_id)
end end
for i in 0...party0.length for i in 0...party0.length
for move in party0[i].moves for move in party0[i].moves

View File

@@ -430,10 +430,10 @@ module PokemonDebugMixin
cmd = 0 cmd = 0
loop do loop do
abils = pkmn.getAbilityList abils = pkmn.getAbilityList
oldabil = PBAbilities.getName(pkmn.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) ")+PBAbilities.getName(i[0])) commands.push(((i[1]<2) ? "" : "(H) ") + Data::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),

View File

@@ -55,13 +55,13 @@ 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")
for i in 1..(PBAbilities.maxValue rescue PBAbilities.getCount-1 rescue pbGetMessageCount(MessageTypes::Abilities)-1) Data::Ability.each do |a|
abilname = getConstantName(PBAbilities,i) rescue pbGetAbilityConst(i) f.write(sprintf("%d,%s,%s,%s\r\n",
next if !abilname || abilname=="" a.id_number,
name = pbGetMessage(MessageTypes::Abilities,i) csvQuote(a.id.to_s),
next if !name || name=="" csvQuote(a.name),
f.write(sprintf("%d,%s,%s,%s\r\n",i,csvQuote(abilname),csvQuote(name), csvQuoteAlways(a.description)
csvQuoteAlways(pbGetMessage(MessageTypes::AbilityDescs,i)))) ))
end end
} }
end end
@@ -639,11 +639,11 @@ def pbSavePokemonData
formname = messages.get(MessageTypes::FormNames,i) formname = messages.get(MessageTypes::FormNames,i)
abilities = speciesData[i][SpeciesData::ABILITIES] abilities = speciesData[i][SpeciesData::ABILITIES]
if abilities.is_a?(Array) if abilities.is_a?(Array)
ability1 = abilities[0] || 0 ability1 = abilities[0]
ability2 = abilities[1] || 0 ability2 = abilities[1]
else else
ability1 = abilities || 0 ability1 = abilities
ability2 = 0 ability2 = nil
end end
color = speciesData[i][SpeciesData::COLOR] || 0 color = speciesData[i][SpeciesData::COLOR] || 0
habitat = speciesData[i][SpeciesData::HABITAT] || 0 habitat = speciesData[i][SpeciesData::HABITAT] || 0
@@ -678,15 +678,15 @@ def pbSavePokemonData
baseexp = speciesData[i][SpeciesData::BASE_EXP] || 0 baseexp = speciesData[i][SpeciesData::BASE_EXP] || 0
hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY] hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY]
if hiddenAbils.is_a?(Array) if hiddenAbils.is_a?(Array)
hiddenability1 = hiddenAbils[0] || 0 hiddenability1 = hiddenAbils[0]
hiddenability2 = hiddenAbils[1] || 0 hiddenability2 = hiddenAbils[1]
hiddenability3 = hiddenAbils[2] || 0 hiddenability3 = hiddenAbils[2]
hiddenability4 = hiddenAbils[3] || 0 hiddenability4 = hiddenAbils[3]
else else
hiddenability1 = hiddenAbils || 0 hiddenability1 = hiddenAbils
hiddenability2 = 0 hiddenability2 = nil
hiddenability3 = 0 hiddenability3 = nil
hiddenability4 = 0 hiddenability4 = nil
end end
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0 item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0 item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
@@ -710,36 +710,36 @@ def pbSavePokemonData
pokedata.write("Rareness = #{rareness}\r\n") pokedata.write("Rareness = #{rareness}\r\n")
pokedata.write("Happiness = #{happiness}\r\n") pokedata.write("Happiness = #{happiness}\r\n")
pokedata.write("Abilities = ") pokedata.write("Abilities = ")
if ability1!=0 if ability1
cability1 = getConstantName(PBAbilities,ability1) rescue pbGetAbilityConst(ability1) cability1 = Data::Ability.get(ability1).name
pokedata.write("#{cability1}") pokedata.write("#{cability1}")
pokedata.write(",") if ability2!=0 pokedata.write(",") if ability2
end end
if ability2!=0 if ability2
cability2 = getConstantName(PBAbilities,ability2) rescue pbGetAbilityConst(ability2) cability2 = Data::Ability.get(ability2).name
pokedata.write("#{cability2}") pokedata.write("#{cability2}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
if hiddenability1>0 || hiddenability2>0 || hiddenability3>0 || hiddenability4>0 if hiddenability1 || hiddenability2 || hiddenability3 || hiddenability4
pokedata.write("HiddenAbility = ") pokedata.write("HiddenAbility = ")
needcomma = false needcomma = false
if hiddenability1>0 if hiddenability1
cabilityh = getConstantName(PBAbilities,hiddenability1) rescue pbGetAbilityConst(hiddenability1) cabilityh = Data::Ability.get(hiddenability1).name
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability2>0 if hiddenability2
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability2) rescue pbGetAbilityConst(hiddenability2) cabilityh = Data::Ability.get(hiddenability2).name
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability3>0 if hiddenability3
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability3) rescue pbGetAbilityConst(hiddenability3) cabilityh = Data::Ability.get(hiddenability3).name
pokedata.write("#{cabilityh}"); needcomma = true pokedata.write("#{cabilityh}"); needcomma = true
end end
if hiddenability4>0 if hiddenability4
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability4) rescue pbGetAbilityConst(hiddenability4) cabilityh = Data::Ability.get(hiddenability4).name
pokedata.write("#{cabilityh}") pokedata.write("#{cabilityh}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
@@ -905,11 +905,11 @@ def pbSavePokemonFormsData
origdata = {} origdata = {}
abilities = speciesData[species][SpeciesData::ABILITIES] abilities = speciesData[species][SpeciesData::ABILITIES]
if abilities.is_a?(Array) if abilities.is_a?(Array)
origdata["ability1"] = abilities[0] || 0 origdata["ability1"] = abilities[0]
origdata["ability2"] = abilities[1] || 0 origdata["ability2"] = abilities[1]
else else
origdata["ability1"] = abilities || 0 origdata["ability1"] = abilities
origdata["ability2"] = 0 origdata["ability2"] = nil
end end
origdata["color"] = speciesData[species][SpeciesData::COLOR] || 0 origdata["color"] = speciesData[species][SpeciesData::COLOR] || 0
origdata["habitat"] = speciesData[species][SpeciesData::HABITAT] || 0 origdata["habitat"] = speciesData[species][SpeciesData::HABITAT] || 0
@@ -944,15 +944,15 @@ def pbSavePokemonFormsData
origdata["baseexp"] = speciesData[species][SpeciesData::BASE_EXP] || 0 origdata["baseexp"] = speciesData[species][SpeciesData::BASE_EXP] || 0
hiddenAbils = speciesData[species][SpeciesData::HIDDEN_ABILITY] hiddenAbils = speciesData[species][SpeciesData::HIDDEN_ABILITY]
if hiddenAbils.is_a?(Array) if hiddenAbils.is_a?(Array)
origdata["hiddenability1"] = hiddenAbils[0] || 0 origdata["hiddenability1"] = hiddenAbils[0]
origdata["hiddenability2"] = hiddenAbils[1] || 0 origdata["hiddenability2"] = hiddenAbils[1]
origdata["hiddenability3"] = hiddenAbils[2] || 0 origdata["hiddenability3"] = hiddenAbils[2]
origdata["hiddenability4"] = hiddenAbils[3] || 0 origdata["hiddenability4"] = hiddenAbils[3]
else else
origdata["hiddenability1"] = hiddenAbils || 0 origdata["hiddenability1"] = hiddenAbils
origdata["hiddenability2"] = 0 origdata["hiddenability2"] = nil
origdata["hiddenability3"] = 0 origdata["hiddenability3"] = nil
origdata["hiddenability4"] = 0 origdata["hiddenability4"] = nil
end end
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0 origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0 origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0
@@ -960,11 +960,11 @@ def pbSavePokemonFormsData
origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0 origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0
abilities = speciesData[i][SpeciesData::ABILITIES] abilities = speciesData[i][SpeciesData::ABILITIES]
if abilities.is_a?(Array) if abilities.is_a?(Array)
ability1 = abilities[0] || 0 ability1 = abilities[0]
ability2 = abilities[1] || 0 ability2 = abilities[1]
else else
ability1 = abilities || 0 ability1 = abilities
ability2 = 0 ability2 = nil
end end
if ability1==origdata["ability1"] && ability2==origdata["ability2"] if ability1==origdata["ability1"] && ability2==origdata["ability2"]
ability1 = ability2 = nil ability1 = ability2 = nil
@@ -1031,15 +1031,15 @@ def pbSavePokemonFormsData
baseexp = nil if baseexp==origdata["baseexp"] baseexp = nil if baseexp==origdata["baseexp"]
hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY] hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY]
if hiddenAbils.is_a?(Array) if hiddenAbils.is_a?(Array)
hiddenability1 = hiddenAbils[0] || 0 hiddenability1 = hiddenAbils[0]
hiddenability2 = hiddenAbils[1] || 0 hiddenability2 = hiddenAbils[1]
hiddenability3 = hiddenAbils[2] || 0 hiddenability3 = hiddenAbils[2]
hiddenability4 = hiddenAbils[3] || 0 hiddenability4 = hiddenAbils[3]
else else
hiddenability1 = hiddenAbils || 0 hiddenability1 = hiddenAbils
hiddenability2 = 0 hiddenability2 = nil
hiddenability3 = 0 hiddenability3 = nil
hiddenability4 = 0 hiddenability4 = nil
end end
if hiddenability1==origdata["hiddenability1"] && if hiddenability1==origdata["hiddenability1"] &&
hiddenability2==origdata["hiddenability2"] && hiddenability2==origdata["hiddenability2"] &&
@@ -1104,40 +1104,40 @@ def pbSavePokemonFormsData
if happiness!=nil if happiness!=nil
pokedata.write("Happiness = #{happiness}\r\n") pokedata.write("Happiness = #{happiness}\r\n")
end end
if ability1!=nil && ability2!=nil if ability1 || ability2
pokedata.write("Abilities = ") pokedata.write("Abilities = ")
if ability1!=0 if ability1
cability1 = getConstantName(PBAbilities,ability1) rescue pbGetAbilityConst(ability1) cability1 = Data::Ability.get(ability1).name
pokedata.write("#{cability1}") pokedata.write("#{cability1}")
pokedata.write(",") if ability2!=0 pokedata.write(",") if ability2
end end
if ability2!=0 if ability2
cability2 = getConstantName(PBAbilities,ability2) rescue pbGetAbilityConst(ability2) cability2 = Data::Ability.get(ability2).name
pokedata.write("#{cability2}") pokedata.write("#{cability2}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")
end end
if hiddenability1!=nil if hiddenability1!=nil
if hiddenability1>0 || hiddenability2>0 || hiddenability3>0 || hiddenability4>0 if hiddenability1 || hiddenability2 || hiddenability3 || hiddenability4
pokedata.write("HiddenAbility = ") pokedata.write("HiddenAbility = ")
needcomma = false needcomma = false
if hiddenability1>0 if hiddenability1
cabilityh = getConstantName(PBAbilities,hiddenability1) rescue pbGetAbilityConst(hiddenability1) cabilityh = Data::Ability.get(hiddenability1).name
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability2>0 if hiddenability2
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability2) rescue pbGetAbilityConst(hiddenability2) cabilityh = Data::Ability.get(hiddenability2).name
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability3>0 if hiddenability3
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability3) rescue pbGetAbilityConst(hiddenability3) cabilityh = Data::Ability.get(hiddenability3).name
pokedata.write("#{cabilityh}"); needcomma=true pokedata.write("#{cabilityh}"); needcomma=true
end end
if hiddenability4>0 if hiddenability4
pokedata.write(",") if needcomma pokedata.write(",") if needcomma
cabilityh = getConstantName(PBAbilities,hiddenability4) rescue pbGetAbilityConst(hiddenability4) cabilityh = Data::Ability.get(hiddenability4).name
pokedata.write("#{cabilityh}") pokedata.write("#{cabilityh}")
end end
pokedata.write("\r\n") pokedata.write("\r\n")

View File

@@ -827,7 +827,7 @@ module AbilityProperty
end end
def self.format(value) def self.format(value)
return (value) ? PBAbilities.getName(value) : "-" return (value && Data::Ability.exists?(value)) ? Data::Ability.get(value).name : "-"
end end
end end
@@ -1262,7 +1262,7 @@ class EvolutionsProperty
when :PBTypes when :PBTypes
allow_zero = true allow_zero = true
newparam = pbChooseTypeList newparam = pbChooseTypeList
when :PBAbilities when :Ability
newparam = pbChooseAbilityList newparam = pbChooseAbilityList
else else
allow_zero = true allow_zero = true
@@ -1350,7 +1350,7 @@ class EvolutionsProperty
when :PBTypes when :PBTypes
allow_zero = true allow_zero = true
newparam = pbChooseTypeList(entry[1]) newparam = pbChooseTypeList(entry[1])
when :PBAbilities when :Ability
newparam = pbChooseAbilityList(entry[1]) newparam = pbChooseAbilityList(entry[1])
else else
allow_zero = true allow_zero = true

View File

@@ -243,9 +243,10 @@ def pbGetHabitatConst(i)
return ret return ret
end end
def pbGetAbilityConst(i) # Unused
return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities) #def pbGetAbilityConst(i)
end # return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
#end
def pbGetMoveConst(i) def pbGetMoveConst(i)
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves) return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
@@ -360,9 +361,8 @@ end
# sorting between numerical and alphabetical. # sorting between numerical and alphabetical.
def pbChooseAbilityList(default=0) def pbChooseAbilityList(default=0)
commands = [] commands = []
for i in 1..PBAbilities.maxValue Data::Ability.each do |a|
cname = getConstantName(PBAbilities,i) rescue nil commands.push([a.id_number, a.name])
commands.push([i,PBAbilities.getName(i)]) if cname
end end
return pbChooseList(commands,default,0,-1) return pbChooseList(commands,default,0,-1)
end end

View File

@@ -311,6 +311,18 @@ 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
enumer = Data.const_get(enumer.to_sym)
begin
if ret == "" || !enumer.exists?(ret.to_sym)
raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport)
end
rescue NameError
raise _INTL("Incorrect value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport)
end
return ret.to_sym
end
enumer = Object.const_get(enumer.to_sym) enumer = Object.const_get(enumer.to_sym)
begin begin
if ret=="" || !enumer.const_defined?(ret) if ret=="" || !enumer.const_defined?(ret)
@@ -341,6 +353,12 @@ 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
enumer = Data.const_get(enumer.to_sym)
return nil if ret == "" || !enumer.exists?(ret.to_sym)
return ret.to_sym
end
enumer = Object.const_get(enumer.to_sym) enumer = Object.const_get(enumer.to_sym)
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)
@@ -607,9 +625,9 @@ module Compiler
yield(_INTL("Compiling berry plant data")) yield(_INTL("Compiling berry plant data"))
compile_berry_plants # Depends on PBItems compile_berry_plants # Depends on PBItems
yield(_INTL("Compiling Pokémon data")) yield(_INTL("Compiling Pokémon data"))
compile_pokemon # Depends on PBMoves, PBItems, PBTypes, PBAbilities compile_pokemon # Depends on PBMoves, PBItems, 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, PBAbilities compile_pokemon_forms # Depends on PBSpecies, PBMoves, PBItems, 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"))

View File

@@ -326,34 +326,34 @@ module Compiler
# Compile abilities # Compile abilities
#============================================================================= #=============================================================================
def compile_abilities def compile_abilities
records = [] ability_names = []
movenames = [] ability_descriptions = []
movedescs = [] pbCompilerEachPreppedLine("PBS/abilities.txt") { |line, line_no|
maxValue = 0 line = pbGetCsvRecord(line, line_no, [0, "vnss"])
pbCompilerEachPreppedLine("PBS/abilities.txt") { |line,lineno| ability_number = line[0]
record = pbGetCsvRecord(line,lineno,[0,"vnss"]) ability_symbol = line[1].to_sym
if movenames[record[0]] if Data::Ability::DATA[ability_number]
raise _INTL("Ability ID number '{1}' is used twice.\r\n{2}",record[0],FileLineData.linereport) raise _INTL("Ability ID number '{1}' is used twice.\r\n{2}", ability_number, FileLineData.linereport)
elsif Data::Ability::DATA[ability_symbol]
raise _INTL("Ability ID '{1}' is used twice.\r\n{2}", ability_symbol, FileLineData.linereport)
end end
movenames[record[0]] = record[2] # Construct ability hash
movedescs[record[0]] = record[3] ability_hash = {
maxValue = [maxValue,record[0]].max :id => ability_symbol,
records.push(record) :id_number => ability_number,
:name => line[2],
:description => line[3]
} }
MessageTypes.setMessages(MessageTypes::Abilities,movenames) # Add ability's data to records
MessageTypes.setMessages(MessageTypes::AbilityDescs,movedescs) Data::Ability::DATA[ability_number] = Data::Ability::DATA[ability_symbol] = Data::Ability.new(ability_hash)
code = "class PBAbilities\r\n" ability_names[ability_number] = ability_hash[:name]
for rec in records ability_descriptions[ability_number] = ability_hash[:description]
code += "#{rec[1]}=#{rec[0]}\r\n" }
end # Save all data
code += "def self.getName(id)\r\n" Data::Ability.save
code += "id=getID(PBAbilities,id)\r\n" MessageTypes.setMessages(MessageTypes::Abilities, ability_names)
code += "return pbGetMessage(MessageTypes::Abilities,id); end\r\n" MessageTypes.setMessages(MessageTypes::AbilityDescs, ability_descriptions)
code += "def self.getCount; return #{records.length}; end\r\n" Graphics.update
code += "def self.maxValue; return #{maxValue}; end\r\n"
code += "end\r\n"
eval(code, TOPLEVEL_BINDING)
pbAddScript(code,"PBAbilities")
end end
#============================================================================= #=============================================================================