mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
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:
@@ -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
|
||||
def initialize
|
||||
super(:PBSpecies)
|
||||
@@ -155,10 +206,7 @@ end
|
||||
|
||||
|
||||
|
||||
class AbilityHandlerHash < HandlerHash
|
||||
def initialize
|
||||
super(:PBAbilities)
|
||||
end
|
||||
class AbilityHandlerHash < HandlerHash2
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -190,9 +190,9 @@ module SpeciesData
|
||||
def self.optionalValues(compilingForms = false)
|
||||
ret = {
|
||||
"Type2" => [TYPE2, "e", :PBTypes],
|
||||
"Abilities" => [ABILITIES, "eE", :PBAbilities, :PBAbilities],
|
||||
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :PBAbilities, :PBAbilities,
|
||||
:PBAbilities, :PBAbilities],
|
||||
"Abilities" => [ABILITIES, "eE", :Ability, :Ability],
|
||||
"HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :Ability, :Ability,
|
||||
:Ability, :Ability],
|
||||
"Habitat" => [HABITAT, "e", :PBHabitats],
|
||||
"WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems],
|
||||
"WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems],
|
||||
|
||||
158
Data/Scripts/011_Data/014_Item_Data.rb
Normal file
158
Data/Scripts/011_Data/014_Item_Data.rb
Normal 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
|
||||
90
Data/Scripts/011_Data/015_Ability_Data.rb
Normal file
90
Data/Scripts/011_Data/015_Ability_Data.rb
Normal 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
|
||||
@@ -181,7 +181,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
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 pbThis(lowerCase=false)
|
||||
@@ -324,17 +324,12 @@ class PokeBattle_Battler
|
||||
return true
|
||||
end
|
||||
|
||||
def hasActiveAbility?(ability,ignoreFainted=false)
|
||||
def hasActiveAbility?(check_ability, ignoreFainted = false)
|
||||
return false if !abilityActive?(ignoreFainted)
|
||||
if ability.is_a?(Array)
|
||||
ability.each do |a|
|
||||
a = getID(PBAbilities,a)
|
||||
return true if a!=0 && a==@ability
|
||||
end
|
||||
return false
|
||||
if check_ability.is_a?(Array)
|
||||
return check_ability.any? { |a| a == @ability }
|
||||
end
|
||||
ability = getID(PBAbilities,ability)
|
||||
return ability!=0 && ability==@ability
|
||||
return check_ability == @ability
|
||||
end
|
||||
alias hasWorkingAbility hasActiveAbility?
|
||||
|
||||
@@ -358,10 +353,7 @@ class PokeBattle_Battler
|
||||
:COMATOSE,
|
||||
:RKSSYSTEM
|
||||
]
|
||||
abilityBlacklist.each do |a|
|
||||
return true if isConst?(abil, PBAbilities, a)
|
||||
end
|
||||
return false
|
||||
return abilityBlacklist.any? { |a| a == abil }
|
||||
end
|
||||
|
||||
# Applies to gaining the ability.
|
||||
@@ -386,10 +378,7 @@ class PokeBattle_Battler
|
||||
:COMATOSE,
|
||||
:RKSSYSTEM
|
||||
]
|
||||
abilityBlacklist.each do |a|
|
||||
return true if isConst?(abil, PBAbilities, a)
|
||||
end
|
||||
return false
|
||||
return abilityBlacklist.any? { |a| a == abil }
|
||||
end
|
||||
|
||||
def itemActive?(ignoreFainted=false)
|
||||
@@ -459,9 +448,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
|
||||
def canChangeType?
|
||||
return false if isConst?(@ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(@ability,PBAbilities,:RKSSYSTEM)
|
||||
return true
|
||||
return ![:MULTITYPE, :RKSSYSTEM].include?(@ability)
|
||||
end
|
||||
|
||||
def airborne?
|
||||
|
||||
@@ -21,7 +21,7 @@ class PokeBattle_Battler
|
||||
@level = 0
|
||||
@hp = @totalhp = 0
|
||||
@type1 = @type2 = 0
|
||||
@ability = 0
|
||||
@ability = nil
|
||||
@item = 0
|
||||
@gender = 0
|
||||
@attack = @defense = @spatk = @spdef = @speed = 0
|
||||
@@ -78,7 +78,7 @@ class PokeBattle_Battler
|
||||
@totalhp = pkmn.totalhp
|
||||
@type1 = pkmn.type1
|
||||
@type2 = pkmn.type2
|
||||
@ability = pkmn.ability
|
||||
@ability = pkmn.ability_id
|
||||
@item = pkmn.item
|
||||
@gender = pkmn.gender
|
||||
@attack = pkmn.attack
|
||||
@@ -297,7 +297,7 @@ class PokeBattle_Battler
|
||||
if fullChange
|
||||
@type1 = @pokemon.type1
|
||||
@type2 = @pokemon.type2
|
||||
@ability = @pokemon.ability
|
||||
@ability = @pokemon.ability_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -209,7 +209,7 @@ class PokeBattle_Battler
|
||||
# Form changes upon entering battle and when the weather changes
|
||||
pbCheckFormOnWeatherChange if !endOfRound
|
||||
# Darmanitan - Zen Mode
|
||||
if isSpecies?(:DARMANITAN) && isConst?(@ability,PBAbilities,:ZENMODE)
|
||||
if isSpecies?(:DARMANITAN) && @ability == :ZENMODE
|
||||
if @hp<=@totalhp/2
|
||||
if @form!=1
|
||||
@battle.pbShowAbilitySplash(self,true)
|
||||
@@ -223,7 +223,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Minior - Shields Down
|
||||
if isSpecies?(:MINIOR) && isConst?(@ability,PBAbilities,:SHIELDSDOWN)
|
||||
if isSpecies?(:MINIOR) && @ability == :SHIELDSDOWN
|
||||
if @hp>@totalhp/2 # Turn into Meteor form
|
||||
newForm = (@form>=7) ? @form-7 : @form
|
||||
if @form!=newForm
|
||||
@@ -240,7 +240,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Wishiwashi - Schooling
|
||||
if isSpecies?(:WISHIWASHI) && isConst?(@ability,PBAbilities,:SCHOOLING)
|
||||
if isSpecies?(:WISHIWASHI) && @ability == :SCHOOLING
|
||||
if @level>=20 && @hp>@totalhp/4
|
||||
if @form!=1
|
||||
@battle.pbShowAbilitySplash(self,true)
|
||||
@@ -254,8 +254,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Zygarde - Power Construct
|
||||
if isSpecies?(:ZYGARDE) && isConst?(@ability,PBAbilities,:POWERCONSTRUCT) &&
|
||||
endOfRound
|
||||
if isSpecies?(:ZYGARDE) && @ability == :POWERCONSTRUCT && endOfRound
|
||||
if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme
|
||||
newForm = @form+2
|
||||
@battle.pbDisplay(_INTL("You sense the presence of many!"))
|
||||
|
||||
@@ -75,9 +75,7 @@ class PokeBattle_Battler
|
||||
choices = []
|
||||
@battle.eachOtherSideBattler(@index) do |b|
|
||||
next if b.ungainableAbility? ||
|
||||
isConst?(b.ability, PBAbilities, :POWEROFALCHEMY) ||
|
||||
isConst?(b.ability, PBAbilities, :RECEIVER) ||
|
||||
isConst?(b.ability, PBAbilities, :TRACE)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability)
|
||||
choices.push(b)
|
||||
end
|
||||
if choices.length>0
|
||||
@@ -107,16 +105,16 @@ class PokeBattle_Battler
|
||||
# Ability change
|
||||
#=============================================================================
|
||||
def pbOnAbilityChanged(oldAbil)
|
||||
if @effects[PBEffects::Illusion] && isConst?(oldAbil,PBAbilities,:ILLUSION)
|
||||
if @effects[PBEffects::Illusion] && oldAbil == :ILLUSION
|
||||
@effects[PBEffects::Illusion] = nil
|
||||
if !@effects[PBEffects::Transform]
|
||||
@battle.scene.pbChangePokemon(self,@pokemon)
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!",pbThis,PBAbilities.getName(oldAbil)))
|
||||
@battle.scene.pbChangePokemon(self, @pokemon)
|
||||
@battle.pbDisplay(_INTL("{1}'s {2} wore off!", pbThis, Data::Ability.get(oldAbil).name))
|
||||
@battle.pbSetSeen(self)
|
||||
end
|
||||
end
|
||||
@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
|
||||
pbCheckFormOnWeatherChange
|
||||
# Check for end of primordial weather
|
||||
|
||||
@@ -216,7 +216,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
end
|
||||
# Stance Change
|
||||
if isSpecies?(:AEGISLASH) && isConst?(@ability,PBAbilities,:STANCECHANGE)
|
||||
if isSpecies?(:AEGISLASH) && @ability == :STANCECHANGE
|
||||
if move.damagingMove?
|
||||
pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis))
|
||||
elsif isConst?(move.id,PBMoves,:KINGSSHIELD)
|
||||
|
||||
@@ -96,8 +96,7 @@ class PokeBattle_Battler
|
||||
end
|
||||
# Greninja - Battle Bond
|
||||
if !user.fainted? && !user.effects[PBEffects::Transform] &&
|
||||
user.isSpecies?(:GRENINJA) &&
|
||||
isConst?(user.ability,PBAbilities,:BATTLEBOND)
|
||||
user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
|
||||
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
|
||||
!@battle.battleBond[user.index&1][user.pokemonIndex]
|
||||
numFainted = 0
|
||||
|
||||
@@ -165,7 +165,7 @@ class PokeBattle_Move
|
||||
end
|
||||
# Disguise will take the damage
|
||||
if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
|
||||
target.form==0 && isConst?(target.ability,PBAbilities,:DISGUISE)
|
||||
target.form==0 && target.ability == :DISGUISE
|
||||
target.damageState.disguise = true
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1997,7 +1997,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_063 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !hasConst?(PBAbilities,:SIMPLE) # Ability isn't defined
|
||||
if !Data::Ability.exists?(:SIMPLE)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2005,9 +2005,7 @@ class PokeBattle_Move_063 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if target.unstoppableAbility? ||
|
||||
isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason
|
||||
isConst?(target.ability, PBAbilities, :SIMPLE)
|
||||
if target.unstoppableAbility? || [:TRUANT, :SIMPLE].include?(target.ability)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2017,7 +2015,7 @@ class PokeBattle_Move_063 < PokeBattle_Move
|
||||
def pbEffectAgainstTarget(user,target)
|
||||
@battle.pbShowAbilitySplash(target,true,false)
|
||||
oldAbil = target.ability
|
||||
target.ability = getConst(PBAbilities,:SIMPLE)
|
||||
target.ability = :SIMPLE
|
||||
@battle.pbReplaceAbilitySplash(target)
|
||||
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
@@ -2032,7 +2030,7 @@ end
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_064 < PokeBattle_Move
|
||||
def pbMoveFailed?(user,targets)
|
||||
if !hasConst?(PBAbilities,:INSOMNIA) # Ability isn't defined
|
||||
if !Data::Ability.exists?(:INSOMNIA)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2040,9 +2038,7 @@ class PokeBattle_Move_064 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if target.unstoppableAbility? ||
|
||||
isConst?(target.ability, PBAbilities, :TRUANT) || # For some reason
|
||||
isConst?(target.ability, PBAbilities, :INSOMNIA)
|
||||
if target.unstoppableAbility? || [:TRUANT, :INSOMNIA].include?(target.ability)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2052,7 +2048,7 @@ class PokeBattle_Move_064 < PokeBattle_Move
|
||||
def pbEffectAgainstTarget(user,target)
|
||||
@battle.pbShowAbilitySplash(target,true,false)
|
||||
oldAbil = target.ability
|
||||
target.ability = getConst(PBAbilities,:INSOMNIA)
|
||||
target.ability = :INSOMNIA
|
||||
@battle.pbReplaceAbilitySplash(target)
|
||||
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
|
||||
@battle.pbHideAbilitySplash(target)
|
||||
@@ -2082,10 +2078,7 @@ class PokeBattle_Move_065 < PokeBattle_Move
|
||||
return true
|
||||
end
|
||||
if target.ungainableAbility? ||
|
||||
isConst?(target.ability, PBAbilities, :POWEROFALCHEMY) ||
|
||||
isConst?(target.ability, PBAbilities, :RECEIVER) ||
|
||||
isConst?(target.ability, PBAbilities, :TRACE) ||
|
||||
isConst?(target.ability, PBAbilities, :WONDERGUARD)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE, :WONDERGUARD].include?(target.ability)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2117,9 +2110,7 @@ class PokeBattle_Move_066 < PokeBattle_Move
|
||||
return true
|
||||
end
|
||||
if user.ungainableAbility? ||
|
||||
isConst?(user.ability, PBAbilities, :POWEROFALCHEMY) ||
|
||||
isConst?(user.ability, PBAbilities, :RECEIVER) ||
|
||||
isConst?(user.ability, PBAbilities, :TRACE)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(user.ability)
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2127,7 +2118,7 @@ class PokeBattle_Move_066 < PokeBattle_Move
|
||||
end
|
||||
|
||||
def pbFailsAgainstTarget?(user,target)
|
||||
if target.unstoppableAbility? || isConst?(target.ability, PBAbilities, :TRUANT)
|
||||
if target.unstoppableAbility? || target.ability == :TRUANT
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2163,7 +2154,7 @@ class PokeBattle_Move_067 < PokeBattle_Move
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
if user.ungainableAbility? || isConst?(user.ability, PBAbilities, :WONDERGUARD)
|
||||
if user.ungainableAbility? || user.ability == :WONDERGUARD
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
@@ -2180,7 +2171,7 @@ class PokeBattle_Move_067 < PokeBattle_Move
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
if target.ungainableAbility? || isConst?(target.ability, PBAbilities, :WONDERGUARD)
|
||||
if target.ungainableAbility? || target.ability == :WONDERGUARD
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -168,7 +168,7 @@ class PokeBattle_Battle
|
||||
@battlers[0].effects[PBEffects::Outrage]==0
|
||||
idxPartyForName = idxPartyNew
|
||||
enemyParty = pbParty(idxBattler)
|
||||
if isConst?(enemyParty[idxPartyNew].ability,PBAbilities,:ILLUSION)
|
||||
if enemyParty[idxPartyNew].ability == :ILLUSION
|
||||
idxPartyForName = pbLastInTeam(idxBattler)
|
||||
end
|
||||
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)
|
||||
party = pbParty(idxBattler)
|
||||
newPkmnName = party[idxParty].name
|
||||
if isConst?(party[idxParty].ability,PBAbilities,:ILLUSION)
|
||||
if party[idxParty].ability == :ILLUSION
|
||||
newPkmnName = party[pbLastInTeam(idxBattler)].name
|
||||
end
|
||||
if pbOwnedByPlayer?(idxBattler)
|
||||
|
||||
@@ -1308,8 +1308,7 @@ class PokeBattle_AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "05E"
|
||||
if isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
|
||||
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
|
||||
score -= 90
|
||||
else
|
||||
types = []
|
||||
@@ -1323,8 +1322,7 @@ class PokeBattle_AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "05F"
|
||||
if isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
|
||||
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
|
||||
score -= 90
|
||||
elsif target.lastMoveUsed<=0 ||
|
||||
PBTypes.isPseudoType?(pbGetMoveData(target.lastMoveUsed,MoveData::TYPE))
|
||||
@@ -1349,8 +1347,7 @@ class PokeBattle_AI
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "060"
|
||||
if isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
|
||||
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.mediumSkill
|
||||
envtypes = [
|
||||
@@ -1370,16 +1367,14 @@ class PokeBattle_AI
|
||||
#---------------------------------------------------------------------------
|
||||
when "061"
|
||||
if target.effects[PBEffects::Substitute]>0 ||
|
||||
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(target.ability,PBAbilities,:RKSSYSTEM)
|
||||
target.ability == :MULTITYPE || target.ability == :RKSSYSTEM
|
||||
score -= 90
|
||||
elsif target.pbHasType?(:WATER)
|
||||
score -= 90
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "062"
|
||||
if isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(user.ability,PBAbilities,:RKSSYSTEM)
|
||||
if user.ability == :MULTITYPE || user.ability == :RKSSYSTEM
|
||||
score -= 90
|
||||
elsif user.pbHasType?(target.type1) &&
|
||||
user.pbHasType?(target.type2) &&
|
||||
@@ -1392,10 +1387,7 @@ class PokeBattle_AI
|
||||
if target.effects[PBEffects::Substitute]>0
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.mediumSkill
|
||||
if isConst?(target.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
|
||||
isConst?(target.ability,PBAbilities,:SIMPLE) ||
|
||||
isConst?(target.ability,PBAbilities,:TRUANT)
|
||||
if [:MULTITYPE, :RKSSYSTEM, :SIMPLE, :TRUANT].include?(target.ability)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
@@ -1404,10 +1396,7 @@ class PokeBattle_AI
|
||||
if target.effects[PBEffects::Substitute]>0
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.mediumSkill
|
||||
if isConst?(target.ability,PBAbilities,:INSOMNIA) ||
|
||||
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
|
||||
isConst?(target.ability,PBAbilities,:TRUANT)
|
||||
if [:INSOMNIA, :MULTITYPE, :RKSSYSTEM, :TRUANT].include?(target.ability)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
@@ -1416,26 +1405,16 @@ class PokeBattle_AI
|
||||
score -= 40 # don't prefer this move
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
if target.ability==0 || user.ability==target.ability ||
|
||||
isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(user.ability,PBAbilities,:RKSSYSTEM) ||
|
||||
isConst?(target.ability,PBAbilities,:FLOWERGIFT) ||
|
||||
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)
|
||||
[:MULTITYPE, :RKSSYSTEM].include?(user.ability) ||
|
||||
[:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM,
|
||||
:TRACE, :WONDERGUARD, :ZENMODE].include?(target.ability)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
if isConst?(target.ability,PBAbilities,:TRUANT) &&
|
||||
user.opposes?(target)
|
||||
if target.ability == :TRUANT && user.opposes?(target)
|
||||
score -= 90
|
||||
elsif isConst?(target.ability,PBAbilities,:SLOWSTART) &&
|
||||
user.opposes?(target)
|
||||
elsif target.ability == :SLOWSTART && user.opposes?(target)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
@@ -1446,25 +1425,15 @@ class PokeBattle_AI
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.mediumSkill
|
||||
if user.ability==0 || user.ability==target.ability ||
|
||||
isConst?(target.ability,PBAbilities,:MULTITYPE) ||
|
||||
isConst?(target.ability,PBAbilities,:RKSSYSTEM) ||
|
||||
isConst?(target.ability,PBAbilities,:TRUANT) ||
|
||||
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)
|
||||
[:MULTITYPE, :RKSSYSTEM, :TRUANT].include?(target.ability) ||
|
||||
[:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM,
|
||||
:TRACE, :ZENMODE].include?(user.ability)
|
||||
score -= 90
|
||||
end
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
if isConst?(user.ability,PBAbilities,:TRUANT) &&
|
||||
user.opposes?(target)
|
||||
if user.ability == :TRUANT && user.opposes?(target)
|
||||
score += 90
|
||||
elsif isConst?(user.ability,PBAbilities,:SLOWSTART) &&
|
||||
user.opposes?(target)
|
||||
elsif user.ability == :SLOWSTART && user.opposes?(target)
|
||||
score += 90
|
||||
end
|
||||
end
|
||||
@@ -1475,23 +1444,15 @@ class PokeBattle_AI
|
||||
if skill>=PBTrainerAI.mediumSkill
|
||||
if (user.ability==0 && target.ability==0) ||
|
||||
user.ability==target.ability ||
|
||||
isConst?(user.ability,PBAbilities,:ILLUSION) ||
|
||||
isConst?(user.ability,PBAbilities,:MULTITYPE) ||
|
||||
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)
|
||||
[:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(user.ability) ||
|
||||
[:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(target.ability)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
if skill>=PBTrainerAI.highSkill
|
||||
if isConst?(target.ability,PBAbilities,:TRUANT) &&
|
||||
user.opposes?(target)
|
||||
if target.ability == :TRUANT && user.opposes?(target)
|
||||
score -= 90
|
||||
elsif isConst?(target.ability,PBAbilities,:SLOWSTART) &&
|
||||
user.opposes?(target)
|
||||
elsif target.ability == :SLOWSTART && user.opposes?(target)
|
||||
score -= 90
|
||||
end
|
||||
end
|
||||
@@ -1501,10 +1462,7 @@ class PokeBattle_AI
|
||||
target.effects[PBEffects::GastroAcid]
|
||||
score -= 90
|
||||
elsif skill>=PBTrainerAI.highSkill
|
||||
score -= 90 if isConst?(target.ability,PBAbilities,:MULTITYPE)
|
||||
score -= 90 if isConst?(target.ability,PBAbilities,:RKSSYSTEM)
|
||||
score -= 90 if isConst?(target.ability,PBAbilities,:SLOWSTART)
|
||||
score -= 90 if isConst?(target.ability,PBAbilities,:TRUANT)
|
||||
score -= 90 if [:MULTITYPE, :RKSSYSTEM, :SLOWSTART, :TRUANT].include?(target.ability)
|
||||
end
|
||||
#---------------------------------------------------------------------------
|
||||
when "069"
|
||||
|
||||
@@ -2419,10 +2419,7 @@ BattleHandlers::AbilityChangeOnBattlerFainting.add(:POWEROFALCHEMY,
|
||||
proc { |ability,battler,fainted,battle|
|
||||
next if battler.opposes?(fainted)
|
||||
next if fainted.ungainableAbility? ||
|
||||
isConst?(fainted.ability, PBAbilities, :POWEROFALCHEMY) ||
|
||||
isConst?(fainted.ability, PBAbilities, :RECEIVER) ||
|
||||
isConst?(fainted.ability, PBAbilities, :TRACE) ||
|
||||
isConst?(fainted.ability, PBAbilities, :WONDERGUARD)
|
||||
[:POWEROFALCHEMY, :RECEIVER, :TRACE, :WONDERGUARD].include?(fainted.ability)
|
||||
battle.pbShowAbilitySplash(battler,true)
|
||||
battler.ability = fainted.ability
|
||||
battle.pbReplaceAbilitySplash(battler)
|
||||
|
||||
@@ -277,7 +277,7 @@ Events.onStepTakenTransferPossible += proc { |_sender,e|
|
||||
if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD
|
||||
flashed = false
|
||||
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
|
||||
$game_screen.start_flash(Color.new(255,0,0,128), 4)
|
||||
flashed = true
|
||||
@@ -1161,9 +1161,7 @@ def pbFishingEnd
|
||||
end
|
||||
|
||||
def pbFishing(hasEncounter,rodType=1)
|
||||
speedup = ($Trainer.firstPokemon &&
|
||||
(isConst?($Trainer.firstPokemon.ability,PBAbilities,:STICKYHOLD) ||
|
||||
isConst?($Trainer.firstPokemon.ability,PBAbilities,:SUCTIONCUPS)))
|
||||
speedup = ($Trainer.firstPokemon && [:STICKYHOLD, :SUCTIONCUPS].include?($Trainer.firstPokemon.ability))
|
||||
biteChance = 20+(25*rodType) # 45, 70, 95
|
||||
biteChance *= 1.5 if speedup # 67.5, 100, 100
|
||||
hookChance = 100
|
||||
|
||||
@@ -243,9 +243,9 @@ class PokemonEncounters
|
||||
firstPkmn = $Trainer.firstPokemon
|
||||
if firstPkmn && rand(100)<50 # 50% chance of happening
|
||||
favoredType = -1
|
||||
if isConst?(firstPkmn.ability,PBAbilities,:STATIC) && hasConst?(PBTypes,:ELECTRIC)
|
||||
if firstPkmn.hasAbility?(:STATIC) && hasConst?(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)
|
||||
end
|
||||
if favoredType>=0
|
||||
@@ -289,9 +289,9 @@ class PokemonEncounters
|
||||
level = encounter[1]+rand(1+encounter[2]-encounter[1])
|
||||
# Some abilities alter the level of the wild Pokémon
|
||||
if firstPkmn && rand(100)<50 # 50% chance of happening
|
||||
if isConst?(firstPkmn.ability,PBAbilities,:HUSTLE) ||
|
||||
isConst?(firstPkmn.ability,PBAbilities,:VITALSPIRIT) ||
|
||||
isConst?(firstPkmn.ability,PBAbilities,:PRESSURE)
|
||||
if firstPkmn.hasAbility?(:HUSTLE) ||
|
||||
firstPkmn.hasAbility?(:PRESSURE) ||
|
||||
firstPkmn.hasAbility?(:VITALSPIRIT)
|
||||
level2 = encounter[1]+rand(1+encounter[2]-encounter[1])
|
||||
level = level2 if level2>level # Higher level is more likely
|
||||
end
|
||||
@@ -343,24 +343,24 @@ class PokemonEncounters
|
||||
elsif firstPkmn.hasItem?(:PUREINCENSE)
|
||||
encount = encount*2/3
|
||||
else # Ignore ability effects if an item effect applies
|
||||
if isConst?(firstPkmn.ability,PBAbilities,:STENCH)
|
||||
if firstPkmn.hasAbility?(:STENCH)
|
||||
encount = encount/2
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:WHITESMOKE)
|
||||
elsif firstPkmn.hasAbility?(:WHITESMOKE)
|
||||
encount = encount/2
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:QUICKFEET)
|
||||
elsif firstPkmn.hasAbility?(:QUICKFEET)
|
||||
encount = encount/2
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:SNOWCLOAK)
|
||||
elsif firstPkmn.hasAbility?(:SNOWCLOAK)
|
||||
encount = encount/2 if $game_screen.weather_type==PBFieldWeather::Snow ||
|
||||
$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
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:SWARM)
|
||||
elsif firstPkmn.hasAbility?(:SWARM)
|
||||
encount = encount*1.5
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:ILLUMINATE)
|
||||
elsif firstPkmn.hasAbility?(:ILLUMINATE)
|
||||
encount = encount*2
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:ARENATRAP)
|
||||
elsif firstPkmn.hasAbility?(:ARENATRAP)
|
||||
encount = encount*2
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:NOGUARD)
|
||||
elsif firstPkmn.hasAbility?(:NOGUARD)
|
||||
encount = encount*2
|
||||
end
|
||||
end
|
||||
@@ -373,8 +373,7 @@ class PokemonEncounters
|
||||
# Some abilities make wild encounters less likely if the wild Pokémon is
|
||||
# sufficiently weaker than the Pokémon with the ability
|
||||
if firstPkmn && rand(100)<50 # 50% chance of happening
|
||||
if isConst?(firstPkmn.ability,PBAbilities,:INTIMIDATE) ||
|
||||
isConst?(firstPkmn.ability,PBAbilities,:KEENEYE)
|
||||
if firstPkmn.hasAbility?(:INTIMIDATE) || firstPkmn.hasAbility?(:KEENEYE)
|
||||
return nil if encPkmn[1]<=firstPkmn.level-5 # 5 or more levels weaker
|
||||
end
|
||||
end
|
||||
@@ -409,7 +408,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
|
||||
items = genwildpoke.wildHoldItems
|
||||
firstPkmn = $Trainer.firstPokemon
|
||||
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)
|
||||
if (items[0]==items[1] && items[1]==items[2]) || itemrnd<chances[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
|
||||
# ability
|
||||
if firstPkmn
|
||||
if isConst?(firstPkmn.ability,PBAbilities,:CUTECHARM) && !genwildpoke.singleGendered?
|
||||
if firstPkmn.hasAbility?(:CUTECHARM) && !genwildpoke.singleGendered?
|
||||
if firstPkmn.male?
|
||||
(rand(3)<2) ? genwildpoke.makeFemale : genwildpoke.makeMale
|
||||
elsif firstPkmn.female?
|
||||
(rand(3)<2) ? genwildpoke.makeMale : genwildpoke.makeFemale
|
||||
end
|
||||
elsif isConst?(firstPkmn.ability,PBAbilities,:SYNCHRONIZE)
|
||||
elsif firstPkmn.hasAbility?(:SYNCHRONIZE)
|
||||
genwildpoke.setNature(firstPkmn.nature) if !isRoamer && rand(100)<50
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,28 +167,26 @@ def pbIsHiddenMove?(move)
|
||||
end
|
||||
|
||||
def pbIsUnlosableItem?(item,species,ability)
|
||||
return false if isConst?(species,PBSpecies,:ARCEUS) &&
|
||||
!isConst?(ability,PBAbilities,:MULTITYPE)
|
||||
return false if isConst?(species,PBSpecies,:SILVALLY) &&
|
||||
!isConst?(ability,PBAbilities,:RKSSYSTEM)
|
||||
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],
|
||||
: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,
|
||||
|
||||
@@ -1086,23 +1086,22 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
|
||||
|
||||
ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item,pkmn,scene|
|
||||
abils = pkmn.getAbilityList
|
||||
abil1 = 0; abil2 = 0
|
||||
abil1 = nil; abil2 = nil
|
||||
for i in abils
|
||||
abil1 = i[0] if i[1]==0
|
||||
abil2 = i[0] if i[1]==1
|
||||
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."))
|
||||
next false
|
||||
end
|
||||
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}?",
|
||||
pkmn.name,newabilname))
|
||||
pkmn.setAbility(newabil)
|
||||
scene.pbRefresh
|
||||
scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!",pkmn.name,
|
||||
PBAbilities.getName(pkmn.ability)))
|
||||
scene.pbDisplay(_INTL("{1}'s Ability changed to {2}!",pkmn.name,newabilname))
|
||||
next true
|
||||
end
|
||||
next false
|
||||
|
||||
@@ -279,17 +279,23 @@ class Pokemon
|
||||
return @abilityflag || (@personalID & 1)
|
||||
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
|
||||
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
|
||||
# Hidden ability
|
||||
if abilIndex >= 2
|
||||
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
|
||||
if hiddenAbil.is_a?(Array)
|
||||
ret = hiddenAbil[abilIndex - 2]
|
||||
return ret if ret && ret > 0
|
||||
else
|
||||
return hiddenAbil if abilIndex == 2 && hiddenAbil > 0
|
||||
return ret if Data::Ability.exists?(ret)
|
||||
elsif abilIndex == 2
|
||||
return hiddenAbil if Data::Ability.exists?(hiddenAbil)
|
||||
end
|
||||
abilIndex = (@personalID & 1)
|
||||
end
|
||||
@@ -297,10 +303,10 @@ class Pokemon
|
||||
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
|
||||
if abilities.is_a?(Array)
|
||||
ret = abilities[abilIndex]
|
||||
ret = abilities[(abilIndex + 1) % 2] if !ret || ret == 0
|
||||
return ret || 0
|
||||
ret = abilities[(abilIndex + 1) % 2] if !Data::Ability.exists?(ret)
|
||||
return ret
|
||||
end
|
||||
return abilities || 0
|
||||
return abilities
|
||||
end
|
||||
|
||||
# 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
|
||||
# @return [Boolean] whether this Pokémon has a particular ability or
|
||||
# an ability at all
|
||||
def hasAbility?(ability = 0)
|
||||
def hasAbility?(check_ability = nil)
|
||||
current_ability = self.ability
|
||||
return current_ability > 0 if ability == 0
|
||||
return current_ability == getID(PBAbilities, ability)
|
||||
return !current_ability.nil? if check_ability.nil?
|
||||
return current_ability == check_ability
|
||||
end
|
||||
|
||||
# Sets this Pokémon's ability index.
|
||||
@@ -323,7 +329,7 @@ class Pokemon
|
||||
# @return [Boolean] whether this Pokémon has a hidden ability
|
||||
def hasHiddenAbility?
|
||||
abil = abilityIndex
|
||||
return abil != nil && abil >= 2
|
||||
return abil >= 2
|
||||
end
|
||||
|
||||
# @return [Array<Array<Integer>>] the list of abilities this Pokémon can have,
|
||||
@@ -332,13 +338,13 @@ class Pokemon
|
||||
ret = []
|
||||
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
|
||||
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
|
||||
ret.push([abilities, 0]) if abilities > 0
|
||||
end
|
||||
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
|
||||
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
|
||||
ret.push([hiddenAbil, 2]) if hiddenAbil > 0
|
||||
end
|
||||
@@ -387,7 +393,7 @@ class Pokemon
|
||||
# @return [Boolean] whether this Pokémon is shiny (differently colored)
|
||||
def shiny?
|
||||
return @shinyflag if @shinyflag != nil
|
||||
a = @personalID ^ @trainerID
|
||||
a = @personalID ^ @owner.id
|
||||
b = a & 0xFFFF
|
||||
c = (a >> 16) & 0xFFFF
|
||||
d = b ^ c
|
||||
|
||||
@@ -336,25 +336,25 @@ MultipleForms.register(:SHAYMIN,{
|
||||
|
||||
MultipleForms.register(:ARCEUS,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next nil if !isConst?(pkmn.ability,PBAbilities,:MULTITYPE)
|
||||
next nil if !pkmn.hasAbility?(:MULTITYPE)
|
||||
typeArray = {
|
||||
1 => [:FISTPLATE,:FIGHTINIUMZ],
|
||||
2 => [:SKYPLATE,:FLYINIUMZ],
|
||||
3 => [:TOXICPLATE,:POISONIUMZ],
|
||||
4 => [:EARTHPLATE,:GROUNDIUMZ],
|
||||
5 => [:STONEPLATE,:ROCKIUMZ],
|
||||
6 => [:INSECTPLATE,:BUGINIUMZ],
|
||||
7 => [:SPOOKYPLATE,:GHOSTIUMZ],
|
||||
8 => [:IRONPLATE,:STEELIUMZ],
|
||||
10 => [:FLAMEPLATE,:FIRIUMZ],
|
||||
11 => [:SPLASHPLATE,:WATERIUMZ],
|
||||
12 => [:MEADOWPLATE,:GRASSIUMZ],
|
||||
13 => [:ZAPPLATE,:ELECTRIUMZ],
|
||||
14 => [:MINDPLATE,:PSYCHIUMZ],
|
||||
15 => [:ICICLEPLATE,:ICIUMZ],
|
||||
16 => [:DRACOPLATE,:DRAGONIUMZ],
|
||||
17 => [:DREADPLATE,:DARKINIUMZ],
|
||||
18 => [:PIXIEPLATE,:FAIRIUMZ]
|
||||
1 => [:FISTPLATE, :FIGHTINIUMZ],
|
||||
2 => [:SKYPLATE, :FLYINIUMZ],
|
||||
3 => [:TOXICPLATE, :POISONIUMZ],
|
||||
4 => [:EARTHPLATE, :GROUNDIUMZ],
|
||||
5 => [:STONEPLATE, :ROCKIUMZ],
|
||||
6 => [:INSECTPLATE, :BUGINIUMZ],
|
||||
7 => [:SPOOKYPLATE, :GHOSTIUMZ],
|
||||
8 => [:IRONPLATE, :STEELIUMZ],
|
||||
10 => [:FLAMEPLATE, :FIRIUMZ],
|
||||
11 => [:SPLASHPLATE, :WATERIUMZ],
|
||||
12 => [:MEADOWPLATE, :GRASSIUMZ],
|
||||
13 => [:ZAPPLATE, :ELECTRIUMZ],
|
||||
14 => [:MINDPLATE, :PSYCHIUMZ],
|
||||
15 => [:ICICLEPLATE, :ICIUMZ],
|
||||
16 => [:DRACOPLATE, :DRAGONIUMZ],
|
||||
17 => [:DREADPLATE, :DARKINIUMZ],
|
||||
18 => [:PIXIEPLATE, :FAIRIUMZ]
|
||||
}
|
||||
ret = 0
|
||||
typeArray.each do |f, items|
|
||||
@@ -573,7 +573,7 @@ MultipleForms.register(:WISHIWASHI,{
|
||||
|
||||
MultipleForms.register(:SILVALLY,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next nil if !isConst?(pkmn.ability,PBAbilities,:RKSSYSTEM)
|
||||
next nil if !pkmn.hasAbility?(:RKSSYSTEM)
|
||||
typeArray = {
|
||||
1 => [:FIGHTINGMEMORY],
|
||||
2 => [:FLYINGMEMORY],
|
||||
|
||||
@@ -259,7 +259,7 @@ end
|
||||
def pbCheckEvolutionEx(pokemon)
|
||||
return -1 if pokemon.species<=0 || pokemon.egg? || pokemon.shadowPokemon?
|
||||
return -1 if pokemon.hasItem?(:EVERSTONE)
|
||||
return -1 if isConst?(pokemon.ability,PBAbilities,:BATTLEBOND)
|
||||
return -1 if pokemon.hasAbility?(:BATTLEBOND)
|
||||
ret = -1
|
||||
for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form),true)
|
||||
ret = yield pokemon,form[0],form[1],form[2]
|
||||
|
||||
@@ -634,14 +634,16 @@ class PokemonSummary_Scene
|
||||
[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]],
|
||||
[sprintf("%d",@pokemon.speed),456,248,1,Color.new(64,64,64),Color.new(176,176,176)],
|
||||
[_INTL("Ability"),224,284,0,base,shadow],
|
||||
[PBAbilities.getName(@pokemon.ability),362,284,0,Color.new(64,64,64),Color.new(176,176,176)],
|
||||
[_INTL("Ability"),224,284,0,base,shadow]
|
||||
]
|
||||
# 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
|
||||
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
|
||||
if @pokemon.hp>0
|
||||
w = @pokemon.hp*96*1.0/@pokemon.totalhp
|
||||
|
||||
@@ -268,6 +268,7 @@ class PokemonLoadScreen
|
||||
$scene = nil
|
||||
return
|
||||
end
|
||||
Data::Ability.load
|
||||
commands = []
|
||||
cmdContinue = -1
|
||||
cmdNewGame = -1
|
||||
|
||||
@@ -1415,8 +1415,9 @@ class PokemonStorageScene
|
||||
end
|
||||
imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246])
|
||||
textstrings.push([pokemon.level.to_s,28,234,false,base,shadow])
|
||||
if pokemon.ability>0
|
||||
textstrings.push([PBAbilities.getName(pokemon.ability),86,306,2,base,shadow])
|
||||
ability = pokemon.ability
|
||||
if ability
|
||||
textstrings.push([ability.name,86,306,2,base,shadow])
|
||||
else
|
||||
textstrings.push([_INTL("No ability"),86,306,2,nonbase,nonshadow])
|
||||
end
|
||||
|
||||
@@ -219,8 +219,7 @@ Events.onStepTaken += proc { |_sender,_e|
|
||||
next if egg.eggsteps<=0
|
||||
egg.eggsteps -= 1
|
||||
for i in $Trainer.pokemonParty
|
||||
next if !isConst?(i.ability,PBAbilities,:FLAMEBODY) &&
|
||||
!isConst?(i.ability,PBAbilities,:MAGMAARMOR)
|
||||
next if !i.hasAbility?(:FLAMEBODY) && !i.hasAbility?(:MAGMAARMOR)
|
||||
egg.eggsteps -= 1
|
||||
break
|
||||
end
|
||||
|
||||
@@ -399,8 +399,7 @@ class StandardRestriction
|
||||
abilities = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::ABILITIES)
|
||||
abilities = [abilities] if !abilities.is_a?(Array)
|
||||
abilities.each do |a|
|
||||
return true if isConst?(a,PBAbilities,:TRUANT) ||
|
||||
isConst?(a,PBAbilities,:SLOWSTART)
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a)
|
||||
end
|
||||
# Certain named species are not banned
|
||||
speciesWhitelist = [:DRAGONITE,:SALAMENCE,:TYRANITAR]
|
||||
|
||||
@@ -836,10 +836,10 @@ def pbDecideWinnerEffectiveness(move,otype1,otype2,ability,scores)
|
||||
return 0 if data.basedamage==0
|
||||
atype=data.type
|
||||
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)
|
||||
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)
|
||||
mod2=PBTypeEffectiveness::NORMAL_EFFECTIVE_ONE if !PBTypes.superEffective?(mod2)
|
||||
end
|
||||
@@ -862,7 +862,7 @@ def pbDecideWinnerScore(party0,party1,rating)
|
||||
for j in 0...party1.length
|
||||
types1.push(party1[j].type1)
|
||||
types2.push(party1[j].type2)
|
||||
abilities.push(party1[j].ability)
|
||||
abilities.push(party1[j].ability_id)
|
||||
end
|
||||
for i in 0...party0.length
|
||||
for move in party0[i].moves
|
||||
|
||||
@@ -430,10 +430,10 @@ module PokemonDebugMixin
|
||||
cmd = 0
|
||||
loop do
|
||||
abils = pkmn.getAbilityList
|
||||
oldabil = PBAbilities.getName(pkmn.ability)
|
||||
oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability"
|
||||
commands = []
|
||||
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
|
||||
commands.push(_INTL("Remove override"))
|
||||
msg = [_INTL("Ability {1} is natural.",oldabil),
|
||||
|
||||
@@ -55,13 +55,13 @@ def pbSaveAbilities
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 1..(PBAbilities.maxValue rescue PBAbilities.getCount-1 rescue pbGetMessageCount(MessageTypes::Abilities)-1)
|
||||
abilname = getConstantName(PBAbilities,i) rescue pbGetAbilityConst(i)
|
||||
next if !abilname || abilname==""
|
||||
name = pbGetMessage(MessageTypes::Abilities,i)
|
||||
next if !name || name==""
|
||||
f.write(sprintf("%d,%s,%s,%s\r\n",i,csvQuote(abilname),csvQuote(name),
|
||||
csvQuoteAlways(pbGetMessage(MessageTypes::AbilityDescs,i))))
|
||||
Data::Ability.each do |a|
|
||||
f.write(sprintf("%d,%s,%s,%s\r\n",
|
||||
a.id_number,
|
||||
csvQuote(a.id.to_s),
|
||||
csvQuote(a.name),
|
||||
csvQuoteAlways(a.description)
|
||||
))
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -639,11 +639,11 @@ def pbSavePokemonData
|
||||
formname = messages.get(MessageTypes::FormNames,i)
|
||||
abilities = speciesData[i][SpeciesData::ABILITIES]
|
||||
if abilities.is_a?(Array)
|
||||
ability1 = abilities[0] || 0
|
||||
ability2 = abilities[1] || 0
|
||||
ability1 = abilities[0]
|
||||
ability2 = abilities[1]
|
||||
else
|
||||
ability1 = abilities || 0
|
||||
ability2 = 0
|
||||
ability1 = abilities
|
||||
ability2 = nil
|
||||
end
|
||||
color = speciesData[i][SpeciesData::COLOR] || 0
|
||||
habitat = speciesData[i][SpeciesData::HABITAT] || 0
|
||||
@@ -678,15 +678,15 @@ def pbSavePokemonData
|
||||
baseexp = speciesData[i][SpeciesData::BASE_EXP] || 0
|
||||
hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY]
|
||||
if hiddenAbils.is_a?(Array)
|
||||
hiddenability1 = hiddenAbils[0] || 0
|
||||
hiddenability2 = hiddenAbils[1] || 0
|
||||
hiddenability3 = hiddenAbils[2] || 0
|
||||
hiddenability4 = hiddenAbils[3] || 0
|
||||
hiddenability1 = hiddenAbils[0]
|
||||
hiddenability2 = hiddenAbils[1]
|
||||
hiddenability3 = hiddenAbils[2]
|
||||
hiddenability4 = hiddenAbils[3]
|
||||
else
|
||||
hiddenability1 = hiddenAbils || 0
|
||||
hiddenability2 = 0
|
||||
hiddenability3 = 0
|
||||
hiddenability4 = 0
|
||||
hiddenability1 = hiddenAbils
|
||||
hiddenability2 = nil
|
||||
hiddenability3 = nil
|
||||
hiddenability4 = nil
|
||||
end
|
||||
item1 = speciesData[i][SpeciesData::WILD_ITEM_COMMON] || 0
|
||||
item2 = speciesData[i][SpeciesData::WILD_ITEM_UNCOMMON] || 0
|
||||
@@ -710,36 +710,36 @@ def pbSavePokemonData
|
||||
pokedata.write("Rareness = #{rareness}\r\n")
|
||||
pokedata.write("Happiness = #{happiness}\r\n")
|
||||
pokedata.write("Abilities = ")
|
||||
if ability1!=0
|
||||
cability1 = getConstantName(PBAbilities,ability1) rescue pbGetAbilityConst(ability1)
|
||||
if ability1
|
||||
cability1 = Data::Ability.get(ability1).name
|
||||
pokedata.write("#{cability1}")
|
||||
pokedata.write(",") if ability2!=0
|
||||
pokedata.write(",") if ability2
|
||||
end
|
||||
if ability2!=0
|
||||
cability2 = getConstantName(PBAbilities,ability2) rescue pbGetAbilityConst(ability2)
|
||||
if ability2
|
||||
cability2 = Data::Ability.get(ability2).name
|
||||
pokedata.write("#{cability2}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
if hiddenability1>0 || hiddenability2>0 || hiddenability3>0 || hiddenability4>0
|
||||
if hiddenability1 || hiddenability2 || hiddenability3 || hiddenability4
|
||||
pokedata.write("HiddenAbility = ")
|
||||
needcomma = false
|
||||
if hiddenability1>0
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability1) rescue pbGetAbilityConst(hiddenability1)
|
||||
if hiddenability1
|
||||
cabilityh = Data::Ability.get(hiddenability1).name
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability2>0
|
||||
if hiddenability2
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability2) rescue pbGetAbilityConst(hiddenability2)
|
||||
cabilityh = Data::Ability.get(hiddenability2).name
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability3>0
|
||||
if hiddenability3
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability3) rescue pbGetAbilityConst(hiddenability3)
|
||||
cabilityh = Data::Ability.get(hiddenability3).name
|
||||
pokedata.write("#{cabilityh}"); needcomma = true
|
||||
end
|
||||
if hiddenability4>0
|
||||
if hiddenability4
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability4) rescue pbGetAbilityConst(hiddenability4)
|
||||
cabilityh = Data::Ability.get(hiddenability4).name
|
||||
pokedata.write("#{cabilityh}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
@@ -905,11 +905,11 @@ def pbSavePokemonFormsData
|
||||
origdata = {}
|
||||
abilities = speciesData[species][SpeciesData::ABILITIES]
|
||||
if abilities.is_a?(Array)
|
||||
origdata["ability1"] = abilities[0] || 0
|
||||
origdata["ability2"] = abilities[1] || 0
|
||||
origdata["ability1"] = abilities[0]
|
||||
origdata["ability2"] = abilities[1]
|
||||
else
|
||||
origdata["ability1"] = abilities || 0
|
||||
origdata["ability2"] = 0
|
||||
origdata["ability1"] = abilities
|
||||
origdata["ability2"] = nil
|
||||
end
|
||||
origdata["color"] = speciesData[species][SpeciesData::COLOR] || 0
|
||||
origdata["habitat"] = speciesData[species][SpeciesData::HABITAT] || 0
|
||||
@@ -944,15 +944,15 @@ def pbSavePokemonFormsData
|
||||
origdata["baseexp"] = speciesData[species][SpeciesData::BASE_EXP] || 0
|
||||
hiddenAbils = speciesData[species][SpeciesData::HIDDEN_ABILITY]
|
||||
if hiddenAbils.is_a?(Array)
|
||||
origdata["hiddenability1"] = hiddenAbils[0] || 0
|
||||
origdata["hiddenability2"] = hiddenAbils[1] || 0
|
||||
origdata["hiddenability3"] = hiddenAbils[2] || 0
|
||||
origdata["hiddenability4"] = hiddenAbils[3] || 0
|
||||
origdata["hiddenability1"] = hiddenAbils[0]
|
||||
origdata["hiddenability2"] = hiddenAbils[1]
|
||||
origdata["hiddenability3"] = hiddenAbils[2]
|
||||
origdata["hiddenability4"] = hiddenAbils[3]
|
||||
else
|
||||
origdata["hiddenability1"] = hiddenAbils || 0
|
||||
origdata["hiddenability2"] = 0
|
||||
origdata["hiddenability3"] = 0
|
||||
origdata["hiddenability4"] = 0
|
||||
origdata["hiddenability1"] = hiddenAbils
|
||||
origdata["hiddenability2"] = nil
|
||||
origdata["hiddenability3"] = nil
|
||||
origdata["hiddenability4"] = nil
|
||||
end
|
||||
origdata["item1"] = speciesData[species][SpeciesData::WILD_ITEM_COMMON] || 0
|
||||
origdata["item2"] = speciesData[species][SpeciesData::WILD_ITEM_UNCOMMON] || 0
|
||||
@@ -960,11 +960,11 @@ def pbSavePokemonFormsData
|
||||
origdata["incense"] = speciesData[species][SpeciesData::INCENSE] || 0
|
||||
abilities = speciesData[i][SpeciesData::ABILITIES]
|
||||
if abilities.is_a?(Array)
|
||||
ability1 = abilities[0] || 0
|
||||
ability2 = abilities[1] || 0
|
||||
ability1 = abilities[0]
|
||||
ability2 = abilities[1]
|
||||
else
|
||||
ability1 = abilities || 0
|
||||
ability2 = 0
|
||||
ability1 = abilities
|
||||
ability2 = nil
|
||||
end
|
||||
if ability1==origdata["ability1"] && ability2==origdata["ability2"]
|
||||
ability1 = ability2 = nil
|
||||
@@ -1031,15 +1031,15 @@ def pbSavePokemonFormsData
|
||||
baseexp = nil if baseexp==origdata["baseexp"]
|
||||
hiddenAbils = speciesData[i][SpeciesData::HIDDEN_ABILITY]
|
||||
if hiddenAbils.is_a?(Array)
|
||||
hiddenability1 = hiddenAbils[0] || 0
|
||||
hiddenability2 = hiddenAbils[1] || 0
|
||||
hiddenability3 = hiddenAbils[2] || 0
|
||||
hiddenability4 = hiddenAbils[3] || 0
|
||||
hiddenability1 = hiddenAbils[0]
|
||||
hiddenability2 = hiddenAbils[1]
|
||||
hiddenability3 = hiddenAbils[2]
|
||||
hiddenability4 = hiddenAbils[3]
|
||||
else
|
||||
hiddenability1 = hiddenAbils || 0
|
||||
hiddenability2 = 0
|
||||
hiddenability3 = 0
|
||||
hiddenability4 = 0
|
||||
hiddenability1 = hiddenAbils
|
||||
hiddenability2 = nil
|
||||
hiddenability3 = nil
|
||||
hiddenability4 = nil
|
||||
end
|
||||
if hiddenability1==origdata["hiddenability1"] &&
|
||||
hiddenability2==origdata["hiddenability2"] &&
|
||||
@@ -1104,40 +1104,40 @@ def pbSavePokemonFormsData
|
||||
if happiness!=nil
|
||||
pokedata.write("Happiness = #{happiness}\r\n")
|
||||
end
|
||||
if ability1!=nil && ability2!=nil
|
||||
if ability1 || ability2
|
||||
pokedata.write("Abilities = ")
|
||||
if ability1!=0
|
||||
cability1 = getConstantName(PBAbilities,ability1) rescue pbGetAbilityConst(ability1)
|
||||
if ability1
|
||||
cability1 = Data::Ability.get(ability1).name
|
||||
pokedata.write("#{cability1}")
|
||||
pokedata.write(",") if ability2!=0
|
||||
pokedata.write(",") if ability2
|
||||
end
|
||||
if ability2!=0
|
||||
cability2 = getConstantName(PBAbilities,ability2) rescue pbGetAbilityConst(ability2)
|
||||
if ability2
|
||||
cability2 = Data::Ability.get(ability2).name
|
||||
pokedata.write("#{cability2}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
end
|
||||
if hiddenability1!=nil
|
||||
if hiddenability1>0 || hiddenability2>0 || hiddenability3>0 || hiddenability4>0
|
||||
if hiddenability1 || hiddenability2 || hiddenability3 || hiddenability4
|
||||
pokedata.write("HiddenAbility = ")
|
||||
needcomma = false
|
||||
if hiddenability1>0
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability1) rescue pbGetAbilityConst(hiddenability1)
|
||||
if hiddenability1
|
||||
cabilityh = Data::Ability.get(hiddenability1).name
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability2>0
|
||||
if hiddenability2
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability2) rescue pbGetAbilityConst(hiddenability2)
|
||||
cabilityh = Data::Ability.get(hiddenability2).name
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability3>0
|
||||
if hiddenability3
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability3) rescue pbGetAbilityConst(hiddenability3)
|
||||
cabilityh = Data::Ability.get(hiddenability3).name
|
||||
pokedata.write("#{cabilityh}"); needcomma=true
|
||||
end
|
||||
if hiddenability4>0
|
||||
if hiddenability4
|
||||
pokedata.write(",") if needcomma
|
||||
cabilityh = getConstantName(PBAbilities,hiddenability4) rescue pbGetAbilityConst(hiddenability4)
|
||||
cabilityh = Data::Ability.get(hiddenability4).name
|
||||
pokedata.write("#{cabilityh}")
|
||||
end
|
||||
pokedata.write("\r\n")
|
||||
|
||||
@@ -827,7 +827,7 @@ module AbilityProperty
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return (value) ? PBAbilities.getName(value) : "-"
|
||||
return (value && Data::Ability.exists?(value)) ? Data::Ability.get(value).name : "-"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1262,7 +1262,7 @@ class EvolutionsProperty
|
||||
when :PBTypes
|
||||
allow_zero = true
|
||||
newparam = pbChooseTypeList
|
||||
when :PBAbilities
|
||||
when :Ability
|
||||
newparam = pbChooseAbilityList
|
||||
else
|
||||
allow_zero = true
|
||||
@@ -1350,7 +1350,7 @@ class EvolutionsProperty
|
||||
when :PBTypes
|
||||
allow_zero = true
|
||||
newparam = pbChooseTypeList(entry[1])
|
||||
when :PBAbilities
|
||||
when :Ability
|
||||
newparam = pbChooseAbilityList(entry[1])
|
||||
else
|
||||
allow_zero = true
|
||||
|
||||
@@ -243,9 +243,10 @@ def pbGetHabitatConst(i)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbGetAbilityConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
|
||||
end
|
||||
# Unused
|
||||
#def pbGetAbilityConst(i)
|
||||
# return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
|
||||
#end
|
||||
|
||||
def pbGetMoveConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
|
||||
@@ -360,9 +361,8 @@ end
|
||||
# sorting between numerical and alphabetical.
|
||||
def pbChooseAbilityList(default=0)
|
||||
commands = []
|
||||
for i in 1..PBAbilities.maxValue
|
||||
cname = getConstantName(PBAbilities,i) rescue nil
|
||||
commands.push([i,PBAbilities.getName(i)]) if cname
|
||||
Data::Ability.each do |a|
|
||||
commands.push([a.id_number, a.name])
|
||||
end
|
||||
return pbChooseList(commands,default,0,-1)
|
||||
end
|
||||
|
||||
@@ -311,6 +311,18 @@ module Compiler
|
||||
end
|
||||
return enumer.const_get(ret.to_sym)
|
||||
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)
|
||||
begin
|
||||
if ret=="" || !enumer.const_defined?(ret)
|
||||
@@ -341,6 +353,12 @@ module Compiler
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
if enumer == :Ability
|
||||
enumer = 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)
|
||||
return nil if ret=="" || !(enumer.const_defined?(ret) rescue false)
|
||||
return enumer.const_get(ret.to_sym)
|
||||
@@ -607,9 +625,9 @@ module Compiler
|
||||
yield(_INTL("Compiling berry plant data"))
|
||||
compile_berry_plants # Depends on PBItems
|
||||
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"))
|
||||
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"))
|
||||
compile_move_compatibilities # Depends on PBSpecies, PBMoves
|
||||
yield(_INTL("Compiling Trainer type data"))
|
||||
|
||||
@@ -326,34 +326,34 @@ module Compiler
|
||||
# Compile abilities
|
||||
#=============================================================================
|
||||
def compile_abilities
|
||||
records = []
|
||||
movenames = []
|
||||
movedescs = []
|
||||
maxValue = 0
|
||||
pbCompilerEachPreppedLine("PBS/abilities.txt") { |line,lineno|
|
||||
record = pbGetCsvRecord(line,lineno,[0,"vnss"])
|
||||
if movenames[record[0]]
|
||||
raise _INTL("Ability ID number '{1}' is used twice.\r\n{2}",record[0],FileLineData.linereport)
|
||||
ability_names = []
|
||||
ability_descriptions = []
|
||||
pbCompilerEachPreppedLine("PBS/abilities.txt") { |line, line_no|
|
||||
line = pbGetCsvRecord(line, line_no, [0, "vnss"])
|
||||
ability_number = line[0]
|
||||
ability_symbol = line[1].to_sym
|
||||
if Data::Ability::DATA[ability_number]
|
||||
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
|
||||
movenames[record[0]] = record[2]
|
||||
movedescs[record[0]] = record[3]
|
||||
maxValue = [maxValue,record[0]].max
|
||||
records.push(record)
|
||||
# Construct ability hash
|
||||
ability_hash = {
|
||||
:id => ability_symbol,
|
||||
:id_number => ability_number,
|
||||
:name => line[2],
|
||||
:description => line[3]
|
||||
}
|
||||
# Add ability's data to records
|
||||
Data::Ability::DATA[ability_number] = Data::Ability::DATA[ability_symbol] = Data::Ability.new(ability_hash)
|
||||
ability_names[ability_number] = ability_hash[:name]
|
||||
ability_descriptions[ability_number] = ability_hash[:description]
|
||||
}
|
||||
MessageTypes.setMessages(MessageTypes::Abilities,movenames)
|
||||
MessageTypes.setMessages(MessageTypes::AbilityDescs,movedescs)
|
||||
code = "class PBAbilities\r\n"
|
||||
for rec in records
|
||||
code += "#{rec[1]}=#{rec[0]}\r\n"
|
||||
end
|
||||
code += "def self.getName(id)\r\n"
|
||||
code += "id=getID(PBAbilities,id)\r\n"
|
||||
code += "return pbGetMessage(MessageTypes::Abilities,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,"PBAbilities")
|
||||
# Save all data
|
||||
Data::Ability.save
|
||||
MessageTypes.setMessages(MessageTypes::Abilities, ability_names)
|
||||
MessageTypes.setMessages(MessageTypes::AbilityDescs, ability_descriptions)
|
||||
Graphics.update
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
Reference in New Issue
Block a user