mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-23 14:56:00 +00:00
Merge pull request #9 from jonisavo/pokemon-use-hasItem
Refactor PokeBattle_Pokemon#hasItem? and use it instead of Object.isConst?
This commit is contained in:
@@ -595,11 +595,12 @@ class PokeBattle_Pokemon
|
||||
#=============================================================================
|
||||
# Items
|
||||
#=============================================================================
|
||||
# Returns whether this Pokémon has a hold item.
|
||||
def hasItem?(value=0)
|
||||
itm = self.item
|
||||
return itm>0 if value==0
|
||||
return itm==getID(PBItems,value)
|
||||
# Returns whether this Pokémon is holding an item. If an item id is passed,
|
||||
# returns whether the Pokémon is holding that item.
|
||||
def hasItem?(item_id = 0)
|
||||
held_item = self.item
|
||||
return held_item > 0 if item_id == 0
|
||||
return held_item == getID(PBItems,item_id)
|
||||
end
|
||||
|
||||
# Sets this Pokémon's item. Accepts symbols.
|
||||
|
||||
@@ -329,8 +329,7 @@ MultipleForms.register(:ROTOM,{
|
||||
MultipleForms.register(:GIRATINA,{
|
||||
"getForm" => proc { |pkmn|
|
||||
maps = [49,50,51,72,73] # Map IDs for Origin Forme
|
||||
if isConst?(pkmn.item,PBItems,:GRISEOUSORB) ||
|
||||
maps.include?($game_map.map_id)
|
||||
if pkmn.hasItem?(:GRISEOUSORB) || maps.include?($game_map.map_id)
|
||||
next 1
|
||||
end
|
||||
next 0
|
||||
@@ -368,8 +367,8 @@ MultipleForms.register(:ARCEUS,{
|
||||
}
|
||||
ret = 0
|
||||
typeArray.each do |f, items|
|
||||
for i in items
|
||||
next if !isConst?(pkmn.item,PBItems,i)
|
||||
for item in items
|
||||
next if !pkmn.hasItem?(item)
|
||||
ret = f
|
||||
break
|
||||
end
|
||||
@@ -459,10 +458,10 @@ MultipleForms.register(:MELOETTA,{
|
||||
|
||||
MultipleForms.register(:GENESECT,{
|
||||
"getForm" => proc { |pkmn|
|
||||
next 1 if isConst?(pkmn.item,PBItems,:SHOCKDRIVE)
|
||||
next 2 if isConst?(pkmn.item,PBItems,:BURNDRIVE)
|
||||
next 3 if isConst?(pkmn.item,PBItems,:CHILLDRIVE)
|
||||
next 4 if isConst?(pkmn.item,PBItems,:DOUSEDRIVE)
|
||||
next 1 if pkmn.hasItem?(:SHOCKDRIVE)
|
||||
next 2 if pkmn.hasItem?(:BURNDRIVE)
|
||||
next 3 if pkmn.hasItem?(:CHILLDRIVE)
|
||||
next 4 if pkmn.hasItem?(:DOUSEDRIVE)
|
||||
next 0
|
||||
}
|
||||
})
|
||||
@@ -605,8 +604,8 @@ MultipleForms.register(:SILVALLY,{
|
||||
}
|
||||
ret = 0
|
||||
typeArray.each do |f, items|
|
||||
for i in items
|
||||
next if !isConst?(pkmn.item,PBItems,i)
|
||||
for item in items
|
||||
next if !pkmn.hasItem?(item)
|
||||
ret = f
|
||||
break
|
||||
end
|
||||
|
||||
@@ -97,14 +97,14 @@ end
|
||||
|
||||
MultipleForms.register(:GROUDON,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if isConst?(pkmn.item,PBItems,:REDORB)
|
||||
next 1 if pkmn.hasItem?(:REDORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
MultipleForms.register(:KYOGRE,{
|
||||
"getPrimalForm" => proc { |pkmn|
|
||||
next 1 if isConst?(pkmn.item,PBItems,:BLUEORB)
|
||||
next 1 if pkmn.hasItem?(:BLUEORB)
|
||||
next
|
||||
}
|
||||
})
|
||||
|
||||
@@ -309,7 +309,7 @@ end
|
||||
# Pokemon to check; evolution type; level or other parameter; ID of the new species
|
||||
def pbCheckEvolutionEx(pokemon)
|
||||
return -1 if pokemon.species<=0 || pokemon.egg? || pokemon.shadowPokemon?
|
||||
return -1 if isConst?(pokemon.item,PBItems,:EVERSTONE)
|
||||
return -1 if pokemon.hasItem?(:EVERSTONE)
|
||||
return -1 if isConst?(pokemon.ability,PBAbilities,:BATTLEBOND)
|
||||
ret = -1
|
||||
for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form),true)
|
||||
|
||||
Reference in New Issue
Block a user