mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 06:34:59 +00:00
Implemented usage of GameData::Item
This commit is contained in:
@@ -46,8 +46,8 @@ class Pokemon
|
||||
attr_accessor :moves
|
||||
# @return [Array<Integer>] the IDs of moves known by this Pokémon when it was obtained
|
||||
attr_accessor :firstmoves
|
||||
# @return [Integer] the ID of the item held by this Pokémon (0 = no held item)
|
||||
attr_accessor :item
|
||||
# @return [Symbol] the ID of the item held by this Pokémon (nil = no held item)
|
||||
attr_accessor :item_id
|
||||
# @return [Integer] this Pokémon's current status (from PBStatuses)
|
||||
attr_reader :status
|
||||
# @return [Integer] sleep count / toxic flag / 0:
|
||||
@@ -279,13 +279,13 @@ class Pokemon
|
||||
return @abilityflag || (@personalID & 1)
|
||||
end
|
||||
|
||||
# @return [PokemonData::Ability] an Ability object corresponding to this Pokémon's ability
|
||||
# @return [GameData::Ability, nil] an Ability object corresponding to this Pokémon's ability
|
||||
def ability
|
||||
ret = ability_id
|
||||
return PokemonData::Ability.try_get(ret)
|
||||
return GameData::Ability.try_get(ret)
|
||||
end
|
||||
|
||||
# @return [Symbol] the ability symbol of this Pokémon's ability
|
||||
# @return [Symbol, nil] the ability symbol of this Pokémon's ability
|
||||
def ability_id
|
||||
abilIndex = abilityIndex
|
||||
# Hidden ability
|
||||
@@ -293,9 +293,9 @@ class Pokemon
|
||||
hiddenAbil = pbGetSpeciesData(@species, formSimple, SpeciesData::HIDDEN_ABILITY)
|
||||
if hiddenAbil.is_a?(Array)
|
||||
ret = hiddenAbil[abilIndex - 2]
|
||||
return ret if PokemonData::Ability.exists?(ret)
|
||||
return ret if GameData::Ability.exists?(ret)
|
||||
elsif abilIndex == 2
|
||||
return hiddenAbil if PokemonData::Ability.exists?(hiddenAbil)
|
||||
return hiddenAbil if GameData::Ability.exists?(hiddenAbil)
|
||||
end
|
||||
abilIndex = (@personalID & 1)
|
||||
end
|
||||
@@ -303,7 +303,7 @@ class Pokemon
|
||||
abilities = pbGetSpeciesData(@species, formSimple, SpeciesData::ABILITIES)
|
||||
if abilities.is_a?(Array)
|
||||
ret = abilities[abilIndex]
|
||||
ret = abilities[(abilIndex + 1) % 2] if !PokemonData::Ability.exists?(ret)
|
||||
ret = abilities[(abilIndex + 1) % 2] if !GameData::Ability.exists?(ret)
|
||||
return ret
|
||||
end
|
||||
return abilities
|
||||
@@ -311,7 +311,7 @@ class Pokemon
|
||||
|
||||
# Returns whether this Pokémon has a particular ability. If no value
|
||||
# is given, returns whether this Pokémon has an ability set.
|
||||
# @param ability [Integer] ability ID to check
|
||||
# @param check_ability [Symbol, GameData::Ability, Integer] ability ID to check
|
||||
# @return [Boolean] whether this Pokémon has a particular ability or
|
||||
# an ability at all
|
||||
def hasAbility?(check_ability = nil)
|
||||
@@ -727,21 +727,29 @@ class Pokemon
|
||||
# Items
|
||||
#=============================================================================
|
||||
|
||||
# @return [GameData::Item, nil] an Item object corresponding to this Pokémon's item
|
||||
def item
|
||||
ret = @item_id
|
||||
return GameData::Item.try_get(ret)
|
||||
end
|
||||
|
||||
# Returns whether this Pokémon is holding an item. If an item id is passed,
|
||||
# returns whether the Pokémon is holding that item.
|
||||
# @param item_id [Integer, Symbol, String] id of the item to check
|
||||
# @param check_item [Symbol, GameData::Item, Integer] item ID to check
|
||||
# @return [Boolean] whether the Pokémon is holding the specified item or
|
||||
# an item at all
|
||||
def hasItem?(item_id = 0)
|
||||
held_item = self.item
|
||||
return held_item > 0 if item_id == 0
|
||||
return held_item == getID(PBItems, item_id)
|
||||
def hasItem?(check_item = nil)
|
||||
current_item = self.item
|
||||
return !current_item.nil? if check_item.nil?
|
||||
return current_item == check_item
|
||||
end
|
||||
|
||||
# Gives an item to this Pokémon. Passing 0 as the argument removes the held item.
|
||||
# @param item_id [Integer, Symbol, String] id of the item to give to this Pokémon (0 removes held item)
|
||||
def setItem(item_id)
|
||||
self.item = getID(PBItems, item_id) || 0
|
||||
# @param value [Symbol, GameData::Item, Integer] id of the item to give to this
|
||||
# Pokémon (a non-valid value sets it to nil)
|
||||
def setItem(value)
|
||||
new_item = GameData::Item.try_get(value)
|
||||
@item_id = (new_item) ? new_item.id : nil
|
||||
end
|
||||
|
||||
# @return [Array<Integer>] the items this species can be found holding in the wild
|
||||
@@ -756,7 +764,7 @@ class Pokemon
|
||||
# @return [PokemonMail, nil] mail held by this Pokémon (nil if there is none)
|
||||
def mail
|
||||
return nil if !@mail
|
||||
@mail = nil if @mail.item == 0 || !hasItem?(@mail.item)
|
||||
@mail = nil if !@mail.item || !hasItem?(@mail.item)
|
||||
return @mail
|
||||
end
|
||||
|
||||
@@ -1075,7 +1083,7 @@ class Pokemon
|
||||
@moves = []
|
||||
@status = PBStatuses::NONE
|
||||
@statusCount = 0
|
||||
@item = 0
|
||||
@item_id = nil
|
||||
@mail = nil
|
||||
@fused = nil
|
||||
@ribbons = []
|
||||
|
||||
@@ -11,8 +11,8 @@ class Pokemon
|
||||
for i in 0...formData[@species].length
|
||||
fSpec = formData[@species][i]
|
||||
next if !fSpec || fSpec<=0
|
||||
megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE] || 0
|
||||
if megaStone>0 && self.hasItem?(megaStone)
|
||||
megaStone = speciesData[fSpec][SpeciesData::MEGA_STONE]
|
||||
if megaStone && self.hasItem?(megaStone)
|
||||
ret = i; break
|
||||
end
|
||||
if !checkItemOnly
|
||||
|
||||
@@ -350,10 +350,7 @@ class PokeBattle_Battle
|
||||
|
||||
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages=true)
|
||||
ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages)
|
||||
if ret && pkmn.hypermode &&
|
||||
!isConst?(item,PBItems,:JOYSCENT) &&
|
||||
!isConst?(item,PBItems,:EXCITESCENT) &&
|
||||
!isConst?(item,PBItems,:VIVIDSCENT)
|
||||
if ret && pkmn.hypermode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item)
|
||||
scene.pbDisplay(_INTL("This item can't be used on that Pokémon."))
|
||||
return false
|
||||
end
|
||||
@@ -477,21 +474,21 @@ ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT)
|
||||
ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-500)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-1000)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene|
|
||||
battler.pokemon.hypermode = false
|
||||
battler.pokemon.adjustHeart(-2000)
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,PBItems.getName(item)))
|
||||
scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name))
|
||||
next true
|
||||
})
|
||||
|
||||
|
||||
@@ -149,21 +149,21 @@ def pbGetPreviousForm(species) # Unused
|
||||
return species
|
||||
end
|
||||
|
||||
def pbGetBabySpecies(species,item1=-1,item2=-1)
|
||||
def pbGetBabySpecies(species, check_items = false, item1 = nil, item2 = nil)
|
||||
ret = species
|
||||
evoData = pbGetEvolutionData(species)
|
||||
return ret if !evoData || evoData.length==0
|
||||
return ret if !evoData || evoData.length == 0
|
||||
evoData.each do |evo|
|
||||
next if !evo[3]
|
||||
if item1>=0 && item2>=0
|
||||
incense = pbGetSpeciesData(evo[0],0,SpeciesData::INCENSE)
|
||||
ret = evo[0] if item1==incense || item2==incense
|
||||
next if !evo[3] # Not the prevolution
|
||||
if check_items
|
||||
incense = pbGetSpeciesData(evo[0], 0, SpeciesData::INCENSE)
|
||||
ret = evo[0] if !incense || item1 == incense || item2 == incense
|
||||
else
|
||||
ret = evo[0] # Species of prevolution
|
||||
end
|
||||
break
|
||||
end
|
||||
ret = pbGetBabySpecies(ret) if ret!=species
|
||||
ret = pbGetBabySpecies(ret) if ret != species
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -194,8 +194,6 @@ def pbGetEvolutionFamilyData(species)
|
||||
return ret
|
||||
end
|
||||
|
||||
# Used by the Moon Ball when checking if a Pokémon's evolution family includes
|
||||
# an evolution that uses the Moon Stone.
|
||||
def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
|
||||
species = pbGetBabySpecies(species)
|
||||
evos = pbGetEvolutionFamilyData(species)
|
||||
@@ -203,7 +201,7 @@ def pbCheckEvolutionFamilyForMethod(species, method, param = -1)
|
||||
for evo in evos
|
||||
if method.is_a?(Array)
|
||||
next if !method.include?(evo[1])
|
||||
elsif method>=0
|
||||
elsif method >= 0
|
||||
next if evo[1] != method
|
||||
end
|
||||
next if param >= 0 && evo[2] != param
|
||||
@@ -214,13 +212,13 @@ end
|
||||
|
||||
# Used by the Moon Ball when checking if a Pokémon's evolution family includes
|
||||
# an evolution that uses the Moon Stone.
|
||||
def pbCheckEvolutionFamilyForItemMethodItem(species, param = -1)
|
||||
def pbCheckEvolutionFamilyForItemMethodItem(species, param = nil)
|
||||
species = pbGetBabySpecies(species)
|
||||
evos = pbGetEvolutionFamilyData(species)
|
||||
return false if !evos || evos.length == 0
|
||||
for evo in evos
|
||||
next if !PBEvolution.hasFunction?(evo[1], "itemCheck")
|
||||
next if param >= 0 && evo[2] != param
|
||||
next if param && evo[2] != param
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@@ -270,14 +268,14 @@ end
|
||||
|
||||
# Checks whether a Pokemon can evolve now. If an item is used on the Pokémon,
|
||||
# checks whether the Pokemon can evolve with the given item.
|
||||
def pbCheckEvolution(pokemon,item=0)
|
||||
if item==0
|
||||
def pbCheckEvolution(pokemon,item=nil)
|
||||
if item
|
||||
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
|
||||
next pbMiniCheckEvolution(pokemon,evonib,level,poke)
|
||||
next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
|
||||
}
|
||||
else
|
||||
return pbCheckEvolutionEx(pokemon) { |pokemon,evonib,level,poke|
|
||||
next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
|
||||
next pbMiniCheckEvolution(pokemon,evonib,level,poke)
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -446,9 +444,9 @@ PBEvolution.register(:Shedinja, {
|
||||
"parameterType" => nil,
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if $Trainer.party.length>=6
|
||||
next false if !$PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL))
|
||||
next false if !$PokemonBag.pbHasItem?(:POKEBALL)
|
||||
PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species)
|
||||
$PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
|
||||
$PokemonBag.pbDeleteItem(:POKEBALL)
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -515,13 +513,13 @@ PBEvolution.register(:HappinessMoveType, {
|
||||
|
||||
PBEvolution.register(:HappinessHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.happiness >= 220
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -543,78 +541,78 @@ PBEvolution.register(:Beauty, { # Feebas
|
||||
|
||||
PBEvolution.register(:HoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemMale, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.male?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemFemale, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.female?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:DayHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && PBDayNight.isDay?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:NightHoldItem, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && PBDayNight.isNight?
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:HoldItemHappiness, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.item == parameter && pkmn.happiness >= 220
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
@@ -662,42 +660,42 @@ PBEvolution.register(:Region, {
|
||||
# Evolution methods that trigger when using an item on the Pokémon
|
||||
#===============================================================================
|
||||
PBEvolution.register(:Item, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemMale, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.male?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemFemale, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.female?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemDay, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && PBDayNight.isDay?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemNight, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"itemCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && PBDayNight.isNight?
|
||||
}
|
||||
})
|
||||
|
||||
PBEvolution.register(:ItemHappiness, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"levelUpCheck" => proc { |pkmn, parameter, item|
|
||||
next item == parameter && pkmn.happiness >= 220
|
||||
}
|
||||
@@ -742,13 +740,13 @@ PBEvolution.register(:TradeNight, {
|
||||
})
|
||||
|
||||
PBEvolution.register(:TradeItem, {
|
||||
"parameterType" => :PBItems,
|
||||
"parameterType" => :Item,
|
||||
"tradeCheck" => proc { |pkmn, parameter, other_pkmn|
|
||||
next pkmn.item == parameter
|
||||
},
|
||||
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
|
||||
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
|
||||
pkmn.setItem(0) # Item is now consumed
|
||||
pkmn.setItem(nil) # Item is now consumed
|
||||
next true
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user