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

@@ -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

View File

@@ -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],

View File

@@ -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]