mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Created and implemented GameData::Species
This commit is contained in:
@@ -241,11 +241,11 @@ def pbWildBattleCore(*args)
|
||||
if arg.is_a?(Pokemon)
|
||||
foeParty.push(arg)
|
||||
elsif arg.is_a?(Array)
|
||||
species = getID(PBSpecies,arg[0])
|
||||
species = GameData::Species.get(arg[0]).id
|
||||
pkmn = pbGenerateWildPokemon(species,arg[1])
|
||||
foeParty.push(pkmn)
|
||||
elsif sp
|
||||
species = getID(PBSpecies,sp)
|
||||
species = GameData::Species.get(sp).id
|
||||
pkmn = pbGenerateWildPokemon(species,arg)
|
||||
foeParty.push(pkmn)
|
||||
sp = nil
|
||||
@@ -307,7 +307,7 @@ end
|
||||
#===============================================================================
|
||||
# Used when walking in tall grass, hence the additional code.
|
||||
def pbWildBattle(species, level, outcomeVar=1, canRun=true, canLose=false)
|
||||
species = getID(PBSpecies,species)
|
||||
species = GameData::Species.get(species).id
|
||||
# Potentially call a different pbWildBattle-type method instead (for roaming
|
||||
# Pokémon, Safari battles, Bug Contest battles)
|
||||
handled = [nil]
|
||||
@@ -605,7 +605,7 @@ def pbEvolutionCheck(currentLevels)
|
||||
next if !pkmn || (pkmn.hp==0 && !NEWEST_BATTLE_MECHANICS)
|
||||
next if currentLevels[i] && pkmn.level==currentLevels[i]
|
||||
newSpecies = pbCheckEvolution(pkmn)
|
||||
next if newSpecies<=0
|
||||
next if !newSpecies
|
||||
evo = PokemonEvolutionScene.new
|
||||
evo.pbStartScreen(pkmn,newSpecies)
|
||||
evo.pbEvolution
|
||||
|
||||
@@ -251,11 +251,11 @@ class PokemonEncounters
|
||||
if favoredType
|
||||
newEncList = []
|
||||
newChances = []
|
||||
speciesData = pbLoadSpeciesData
|
||||
for i in 0...encList.length
|
||||
t1 = speciesData[encList[i][0]][SpeciesData::TYPE1]
|
||||
t2 = speciesData[encList[i][0]][SpeciesData::TYPE2]
|
||||
next if t1!=favoredType && (!t2 || t2!=favoredType)
|
||||
speciesData = GameData::Species.get(encList[i][0])
|
||||
t1 = speciesData.type1
|
||||
t2 = speciesData.type2
|
||||
next if t1 != favoredType && (!t2 || t2 != favoredType)
|
||||
newEncList.push(encList[i])
|
||||
newChances.push(chances[i])
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ end
|
||||
|
||||
# Gets the roaming areas for a particular Pokémon.
|
||||
def pbRoamingAreas(idxRoamer)
|
||||
# [species symbol, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
roamData = ROAMING_SPECIES[idxRoamer]
|
||||
return roamData[5] if roamData && roamData[5]
|
||||
return ROAMING_AREAS
|
||||
@@ -46,8 +46,7 @@ def pbRoamPokemon
|
||||
if !$PokemonGlobal.roamPosition
|
||||
$PokemonGlobal.roamPosition = {}
|
||||
for i in 0...ROAMING_SPECIES.length
|
||||
species = getID(PBSpecies,ROAMING_SPECIES[i][0])
|
||||
next if !species || species<=0
|
||||
next if !GameData::Species.exists?(i[0])
|
||||
keys = pbRoamingAreas(i).keys
|
||||
$PokemonGlobal.roamPosition[i] = keys[rand(keys.length)]
|
||||
end
|
||||
@@ -61,12 +60,10 @@ end
|
||||
# Makes a single roaming Pokémon roam to another map. Doesn't roam if it isn't
|
||||
# currently possible to encounter it (i.e. its Game Switch is off).
|
||||
def pbRoamPokemonOne(idxRoamer)
|
||||
# [species symbol, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
roamData = ROAMING_SPECIES[idxRoamer]
|
||||
return if roamData[2]>0 && !$game_switches[roamData[2]] # Game Switch is off
|
||||
# Ensure species is a number rather than a string/symbol
|
||||
species = getID(PBSpecies,roamData[0])
|
||||
return if !species || species<=0
|
||||
return if !GameData::Species.exists?(roamData[0])
|
||||
# Get hash of area patrolled by the roaming Pokémon
|
||||
mapIDs = pbRoamingAreas(idxRoamer).keys
|
||||
return if !mapIDs || mapIDs.length==0 # No roaming area defined somehow
|
||||
@@ -163,13 +160,11 @@ EncounterModifier.register(proc { |encounter|
|
||||
# encounter it
|
||||
roamerChoices = []
|
||||
for i in 0...ROAMING_SPECIES.length
|
||||
# [species symbol, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
# [species ID, level, Game Switch, encounter type, battle BGM, area maps hash]
|
||||
roamData = ROAMING_SPECIES[i]
|
||||
next if roamData[2]>0 && !$game_switches[roamData[2]] # Game Switch is off
|
||||
next if $PokemonGlobal.roamPokemon[i]==true # Roaming Pokémon has been caught
|
||||
# Ensure species is a number rather than a string/symbol
|
||||
species = getID(PBSpecies,roamData[0])
|
||||
next if !species || species<=0
|
||||
next if !GameData::Species.exists?(roamData[0])
|
||||
# Get the roaming Pokémon's current map
|
||||
roamerMap = $PokemonGlobal.roamPosition[i]
|
||||
if !roamerMap
|
||||
@@ -191,7 +186,7 @@ EncounterModifier.register(proc { |encounter|
|
||||
# Check whether the roaming Pokémon's category of encounter is currently possible
|
||||
next if !pbRoamingMethodAllowed(roamData[3])
|
||||
# Add this roaming Pokémon to the list of possible roaming Pokémon to encounter
|
||||
roamerChoices.push([i,species,roamData[1],roamData[4]])
|
||||
roamerChoices.push([i,roamData[0],roamData[1],roamData[4]])
|
||||
end
|
||||
# No encounterable roaming Pokémon were found, just have the regular encounter
|
||||
next encounter if roamerChoices.length==0
|
||||
|
||||
@@ -119,7 +119,7 @@ def pbHiddenMoveAnimation(pokemon)
|
||||
sprite.visible=true
|
||||
if ptinterp.done?
|
||||
phase=3
|
||||
pbPlayCry(pokemon)
|
||||
GameData::Species.play_cry_from_pokemon(pokemon)
|
||||
frames=0
|
||||
end
|
||||
when 3 # Wait
|
||||
|
||||
@@ -105,14 +105,10 @@ end
|
||||
# Check compatibility of Pokémon in the Day Care.
|
||||
#===============================================================================
|
||||
def pbIsDitto?(pkmn)
|
||||
compat = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesData::COMPATIBILITY)
|
||||
if compat.is_a?(Array)
|
||||
return compat.include?(getConst(PBEggGroups,:Ditto))
|
||||
end
|
||||
return compat && isConst?(compat,PBEggGroups,:Ditto)
|
||||
return pkmn.species_data.egg_groups.include?(PBEggGroups::Ditto)
|
||||
end
|
||||
|
||||
def pbDayCareCompatibleGender(pkmn1,pkmn2)
|
||||
def pbDayCareCompatibleGender(pkmn1, pkmn2)
|
||||
return true if pkmn1.female? && pkmn2.male?
|
||||
return true if pkmn1.male? && pkmn2.female?
|
||||
ditto1 = pbIsDitto?(pkmn1)
|
||||
@@ -123,44 +119,28 @@ def pbDayCareCompatibleGender(pkmn1,pkmn2)
|
||||
end
|
||||
|
||||
def pbDayCareGetCompat
|
||||
return 0 if pbDayCareDeposited!=2
|
||||
return 0 if pbDayCareDeposited != 2
|
||||
pkmn1 = $PokemonGlobal.daycare[0][0]
|
||||
pkmn2 = $PokemonGlobal.daycare[1][0]
|
||||
return 0 if pkmn1.shadowPokemon?
|
||||
return 0 if pkmn2.shadowPokemon?
|
||||
# Insert code here if certain forms of certain species cannot breed
|
||||
compat1 = pbGetSpeciesData(pkmn1.species,pkmn1.form,SpeciesData::COMPATIBILITY)
|
||||
if compat1.is_a?(Array)
|
||||
compat10 = compat1[0] || 0
|
||||
compat11 = compat1[1] || compat10
|
||||
else
|
||||
compat10 = compat11 = compat || 0
|
||||
end
|
||||
compat2 = pbGetSpeciesData(pkmn2.species,pkmn2.form,SpeciesData::COMPATIBILITY)
|
||||
if compat2.is_a?(Array)
|
||||
compat20 = compat2[0] || 0
|
||||
compat21 = compat2[1] || compat20
|
||||
else
|
||||
compat20 = compat21 = compat || 0
|
||||
end
|
||||
return 0 if isConst?(compat10,PBEggGroups,:Undiscovered) ||
|
||||
isConst?(compat11,PBEggGroups,:Undiscovered) ||
|
||||
isConst?(compat20,PBEggGroups,:Undiscovered) ||
|
||||
isConst?(compat21,PBEggGroups,:Undiscovered)
|
||||
if compat10==compat20 || compat11==compat20 ||
|
||||
compat10==compat21 || compat11==compat21 ||
|
||||
isConst?(compat10,PBEggGroups,:Ditto) ||
|
||||
isConst?(compat11,PBEggGroups,:Ditto) ||
|
||||
isConst?(compat20,PBEggGroups,:Ditto) ||
|
||||
isConst?(compat21,PBEggGroups,:Ditto)
|
||||
if pbDayCareCompatibleGender(pkmn1,pkmn2)
|
||||
ret = 1
|
||||
ret += 1 if pkmn1.species == pkmn2.species
|
||||
ret += 1 if pkmn1.owner.id != pkmn2.owner.id
|
||||
return ret
|
||||
end
|
||||
end
|
||||
return 0
|
||||
# Shadow Pokémon cannot breed
|
||||
return 0 if pkmn1.shadowPokemon? || pkmn2.shadowPokemon?
|
||||
# Pokémon in the Undiscovered egg group cannot breed
|
||||
egg_groups1 = pkmn1.species_data.egg_groups
|
||||
egg_groups2 = pkmn2.species_data.egg_groups
|
||||
return 0 if egg_groups1.include?(PBEggGroups::Undiscovered) ||
|
||||
egg_groups2.include?(PBEggGroups::Undiscovered)
|
||||
# Pokémon that don't share an egg group (and neither is in the Ditto group)
|
||||
# cannot breed
|
||||
return 0 if !egg_groups1.include?(PBEggGroups::Ditto) &&
|
||||
!egg_groups2.include?(PBEggGroups::Ditto) &&
|
||||
(egg_groups1 & egg_groups2).length == 0
|
||||
# Pokémon with incompatible genders cannot breed
|
||||
return 0 if !pbDayCareCompatibleGender(pkmn1, pkmn2)
|
||||
# Pokémon can breed; calculate a compatibility factor
|
||||
ret = 1
|
||||
ret += 1 if pkmn1.species == pkmn2.species
|
||||
ret += 1 if pkmn1.owner.id != pkmn2.owner.id
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbDayCareGetCompatibility(variable)
|
||||
@@ -173,36 +153,37 @@ end
|
||||
# Generate an Egg based on Pokémon in the Day Care.
|
||||
#===============================================================================
|
||||
def pbDayCareGenerateEgg
|
||||
return if pbDayCareDeposited!=2
|
||||
raise _INTL("Can't store the egg") if $Trainer.party.length>=6
|
||||
pokemon0 = $PokemonGlobal.daycare[0][0]
|
||||
pokemon1 = $PokemonGlobal.daycare[1][0]
|
||||
return if pbDayCareDeposited != 2
|
||||
raise _INTL("Can't store the egg.") if $Trainer.party.length >= 6
|
||||
pkmn0 = $PokemonGlobal.daycare[0][0]
|
||||
pkmn1 = $PokemonGlobal.daycare[1][0]
|
||||
mother = nil
|
||||
father = nil
|
||||
babyspecies = 0
|
||||
ditto0 = pbIsDitto?(pokemon0)
|
||||
ditto1 = pbIsDitto?(pokemon1)
|
||||
if pokemon0.female? || ditto0
|
||||
babyspecies = (ditto0) ? pokemon1.species : pokemon0.species
|
||||
mother = pokemon0
|
||||
father = pokemon1
|
||||
babyspecies = nil
|
||||
ditto0 = pbIsDitto?(pkmn0)
|
||||
ditto1 = pbIsDitto?(pkmn1)
|
||||
if pkmn0.female? || ditto0
|
||||
mother = pkmn0
|
||||
father = pkmn1
|
||||
babyspecies = (ditto0) ? father.species : mother.species
|
||||
else
|
||||
babyspecies = (ditto1) ? pokemon0.species : pokemon1.species
|
||||
mother = pokemon1
|
||||
father = pokemon0
|
||||
mother = pkmn1
|
||||
father = pkmn0
|
||||
babyspecies = (ditto1) ? father.species : mother.species
|
||||
end
|
||||
# Determine the egg's species
|
||||
babyspecies = EvolutionHelper.baby_species(babyspecies, true, mother.item_id, father.item_id)
|
||||
if isConst?(babyspecies,PBSpecies,:MANAPHY) && hasConst?(PBSpecies,:PHIONE)
|
||||
babyspecies = getConst(PBSpecies,:PHIONE)
|
||||
elsif (isConst?(babyspecies,PBSpecies,:NIDORANfE) && hasConst?(PBSpecies,:NIDORANmA)) ||
|
||||
(isConst?(babyspecies,PBSpecies,:NIDORANmA) && hasConst?(PBSpecies,:NIDORANfE))
|
||||
babyspecies = [getConst(PBSpecies,:NIDORANmA),
|
||||
getConst(PBSpecies,:NIDORANfE)][rand(2)]
|
||||
elsif (isConst?(babyspecies,PBSpecies,:VOLBEAT) && hasConst?(PBSpecies,:ILLUMISE)) ||
|
||||
(isConst?(babyspecies,PBSpecies,:ILLUMISE) && hasConst?(PBSpecies,:VOLBEAT))
|
||||
babyspecies = [getConst(PBSpecies,:VOLBEAT),
|
||||
getConst(PBSpecies,:ILLUMISE)][rand(2)]
|
||||
case babyspecies
|
||||
when :MANAPHY
|
||||
babyspecies = :PHIONE if GameData::Species.exists?(:PHIONE)
|
||||
when :NIDORANfE, :NIDORANmA
|
||||
if GameData::Species.exists?(:NIDORANfE) && GameData::Species.exists?(:NIDORANmA)
|
||||
babyspecies = [:NIDORANfE, :NIDORANmA][rand(2)]
|
||||
end
|
||||
when :VOLBEAT, :ILLUMISE
|
||||
if GameData::Species.exists?(:VOLBEAT) && GameData::Species.exists?(:ILLUMISE)
|
||||
babyspecies = [:VOLBEAT, :ILLUMISE][rand(2)]
|
||||
end
|
||||
end
|
||||
# Generate egg
|
||||
egg = Pokemon.new(babyspecies,EGG_LEVEL)
|
||||
@@ -211,26 +192,13 @@ def pbDayCareGenerateEgg
|
||||
pid |= (rand(65536)<<16)
|
||||
egg.personalID = pid
|
||||
# Inheriting form
|
||||
if isConst?(babyspecies,PBSpecies,:BURMY) ||
|
||||
isConst?(babyspecies,PBSpecies,:SHELLOS) ||
|
||||
isConst?(babyspecies,PBSpecies,:BASCULIN) ||
|
||||
isConst?(babyspecies,PBSpecies,:FLABEBE) ||
|
||||
isConst?(babyspecies,PBSpecies,:PUMPKABOO) ||
|
||||
isConst?(babyspecies,PBSpecies,:ORICORIO) ||
|
||||
isConst?(babyspecies,PBSpecies,:ROCKRUFF) ||
|
||||
isConst?(babyspecies,PBSpecies,:MINIOR)
|
||||
if [:BURMY, :SHELLOS, :BASCULIN, :FLABEBE, :PUMPKABOO, :ORICORIO, :ROCKRUFF, :MINIOR].include?(babyspecies)
|
||||
newForm = mother.form
|
||||
newForm = 0 if mother.isSpecies?(:MOTHIM)
|
||||
egg.form = newForm
|
||||
end
|
||||
# Inheriting Alolan form
|
||||
if isConst?(babyspecies,PBSpecies,:RATTATA) ||
|
||||
isConst?(babyspecies,PBSpecies,:SANDSHREW) ||
|
||||
isConst?(babyspecies,PBSpecies,:VULPIX) ||
|
||||
isConst?(babyspecies,PBSpecies,:DIGLETT) ||
|
||||
isConst?(babyspecies,PBSpecies,:MEOWTH) ||
|
||||
isConst?(babyspecies,PBSpecies,:GEODUDE) ||
|
||||
isConst?(babyspecies,PBSpecies,:GRIMER)
|
||||
if [:RATTATA, :SANDSHREW, :VULPIX, :DIGLETT, :MEOWTH, :GEODUDE, :GRIMER].include?(babyspecies)
|
||||
if mother.form==1
|
||||
egg.form = 1 if mother.hasItem?(:EVERSTONE)
|
||||
elsif EvolutionHelper.baby_species(father.species, true, mother.item_id, father.item_id) == babyspecies
|
||||
@@ -240,17 +208,18 @@ def pbDayCareGenerateEgg
|
||||
# Inheriting Moves
|
||||
moves = []
|
||||
othermoves = []
|
||||
movefather = father; movemother = mother
|
||||
movefather = father
|
||||
movemother = mother
|
||||
if pbIsDitto?(movefather) && !mother.female?
|
||||
movefather = mother; movemother = father
|
||||
movefather = mother
|
||||
movemother = father
|
||||
end
|
||||
# Initial Moves
|
||||
initialmoves = egg.getMoveList
|
||||
for k in initialmoves
|
||||
if k[0]<=EGG_LEVEL
|
||||
moves.push(k[1])
|
||||
else
|
||||
next if !mother.hasMove?(k[1]) || !father.hasMove?(k[1])
|
||||
elsif mother.hasMove?(k[1]) && father.hasMove?(k[1])
|
||||
othermoves.push(k[1])
|
||||
end
|
||||
end
|
||||
@@ -269,7 +238,7 @@ def pbDayCareGenerateEgg
|
||||
end
|
||||
end
|
||||
# Inheriting Egg Moves
|
||||
babyEggMoves = pbGetSpeciesEggMoves(egg.species,egg.form)
|
||||
babyEggMoves = egg.species_data.egg_moves
|
||||
if movefather.male?
|
||||
babyEggMoves.each { |m| moves.push(m) if movefather.hasMove?(m) }
|
||||
end
|
||||
@@ -286,7 +255,7 @@ def pbDayCareGenerateEgg
|
||||
mother.hasItem?(:LIGHTBALL)
|
||||
lightball = true
|
||||
end
|
||||
if lightball && isConst?(babyspecies,PBSpecies,:PICHU) && GameData::Move.exists?(:VOLTTACKLE)
|
||||
if lightball && babyspecies == :PICHU && GameData::Move.exists?(:VOLTTACKLE)
|
||||
moves.push(:VOLTTACKLE)
|
||||
end
|
||||
moves = moves.reverse
|
||||
@@ -378,18 +347,12 @@ def pbDayCareGenerateEgg
|
||||
end
|
||||
# Set all stats
|
||||
egg.happiness = 120
|
||||
egg.iv[0] = ivs[0]
|
||||
egg.iv[1] = ivs[1]
|
||||
egg.iv[2] = ivs[2]
|
||||
egg.iv[3] = ivs[3]
|
||||
egg.iv[4] = ivs[4]
|
||||
egg.iv[5] = ivs[5]
|
||||
egg.iv = ivs
|
||||
egg.moves = finalmoves
|
||||
egg.calcStats
|
||||
egg.obtainText = _INTL("Day-Care Couple")
|
||||
egg.name = _INTL("Egg")
|
||||
eggSteps = pbGetSpeciesData(babyspecies,egg.form,SpeciesData::STEPS_TO_HATCH)
|
||||
egg.eggsteps = eggSteps
|
||||
egg.eggsteps = egg.species_data.hatch_steps
|
||||
egg.givePokerus if rand(65536)<POKERUS_CHANCE
|
||||
# Add egg to party
|
||||
$Trainer.party[$Trainer.party.length] = egg
|
||||
|
||||
Reference in New Issue
Block a user