Migrate a reorganizes bunch of files from PIF

This commit is contained in:
chardub
2025-04-24 19:46:52 -04:00
parent 682323e255
commit 95ef337de8
90 changed files with 31218 additions and 28195 deletions

View File

@@ -0,0 +1,323 @@
def getPokemonPositionInParty(pokemon)
for i in 0..$Trainer.party.length
if $Trainer.party[i] == pokemon
return i
end
end
return -1
end
# don't remember why there's two Supersplicers arguments.... probably a mistake
def pbDNASplicing(pokemon, scene, item = :DNASPLICERS)
is_supersplicer = isSuperSplicersMechanics(item)
playingBGM = $game_system.getPlayingBGM
dexNumber = pokemon.species_data.id_number
if (pokemon.species_data.id_number <= NB_POKEMON)
if pokemon.fused != nil
if $Trainer.party.length >= 6
scene.pbDisplay(_INTL("Your party is full! You can't unfuse {1}.", pokemon.name))
return false
else
$Trainer.party[$Trainer.party.length] = pokemon.fused
pokemon.fused = nil
pokemon.form = 0
scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pokemon.name))
return true
end
else
chosen = scene.pbChoosePokemon(_INTL("Fuse with which Pokémon?"))
if chosen >= 0
poke2 = $Trainer.party[chosen]
if (poke2.species_data.id_number <= NB_POKEMON) && poke2 != pokemon
# check if fainted
if pokemon.egg? || poke2.egg?
scene.pbDisplay(_INTL("It's impossible to fuse an egg!"))
return false
end
if pokemon.hp == 0 || poke2.hp == 0
scene.pbDisplay(_INTL("A fainted Pokémon cannot be fused!"))
return false
end
selectedHead = selectFusion(pokemon, poke2, is_supersplicer)
if selectedHead == -1 # cancelled
return false
end
if selectedHead == nil # can't fuse (egg, etc.)
scene.pbDisplay(_INTL("It won't have any effect."))
return false
end
selectedBase = selectedHead == pokemon ? poke2 : pokemon
firstOptionSelected = selectedHead == pokemon
if !firstOptionSelected
chosen = getPokemonPositionInParty(pokemon)
if chosen == -1
scene.pbDisplay(_INTL("There was an error..."))
return false
end
end
if (Kernel.pbConfirmMessage(_INTL("Fuse {1} and {2}?", selectedHead.name, selectedBase.name)))
pbFuse(selectedHead, selectedBase, item)
pbRemovePokemonAt(chosen)
scene.pbHardRefresh
pbBGMPlay(playingBGM)
return true
end
elsif pokemon == poke2
scene.pbDisplay(_INTL("{1} can't be fused with itself!", pokemon.name))
return false
else
scene.pbDisplay(_INTL("{1} can't be fused with {2}.", poke2.name, pokemon.name))
return false
end
else
return false
end
end
else
# UNFUSE
return true if pbUnfuse(pokemon, scene, is_supersplicer)
end
end
def selectFusion(pokemon, poke2, supersplicers = false)
return nil if !pokemon.is_a?(Pokemon) || !poke2.is_a?(Pokemon)
return nil if pokemon.egg? || poke2.egg?
selectorWindow = FusionPreviewScreen.new(poke2, pokemon, supersplicers) # PictureWindow.new(picturePath)
selectedHead = selectorWindow.getSelection
selectorWindow.dispose
return selectedHead
end
# firstOptionSelected= selectedHead == pokemon
# selectedBody = selectedHead == pokemon ? poke2 : pokemon
# newid = (selectedBody.species_data.id_number) * NB_POKEMON + selectedHead.species_data.id_number
# def pbFuse(pokemon, poke2, supersplicers = false)
# newid = (pokemon.species_data.id_number) * NB_POKEMON + poke2.species_data.id_number
# previewwindow = FusionPreviewScreen.new(pokemon, poke2)#PictureWindow.new(picturePath)
#
# if (Kernel.pbConfirmMessage(_INTL("Fuse the two Pokémon?", newid)))
# previewwindow.dispose
# fus = PokemonFusionScene.new
# if (fus.pbStartScreen(pokemon, poke2, newid))
# returnItemsToBag(pokemon, poke2)
# fus.pbFusionScreen(false, supersplicers)
# $game_variables[126] += 1 #fuse counter
# fus.pbEndScreen
# return true
# end
# else
# previewwindow.dispose
# return false
# end
# end
def pbFuse(pokemon_body, pokemon_head, splicer_item)
use_supersplicers_mechanics = isSuperSplicersMechanics(splicer_item)
newid = (pokemon_body.species_data.id_number) * NB_POKEMON + pokemon_head.species_data.id_number
fus = PokemonFusionScene.new
if (fus.pbStartScreen(pokemon_body, pokemon_head, newid, splicer_item))
returnItemsToBag(pokemon_body, pokemon_head)
fus.pbFusionScreen(false, use_supersplicers_mechanics)
$game_variables[VAR_FUSE_COUNTER] += 1 # fuse counter
fus.pbEndScreen
return true
end
end
# Todo: refactor this, holy shit this is a mess
def pbUnfuse(pokemon, scene, supersplicers, pcPosition = nil)
if pokemon.species_data.id_number > (NB_POKEMON * NB_POKEMON) + NB_POKEMON # triple fusion
scene.pbDisplay(_INTL("{1} cannot be unfused.", pokemon.name))
return false
end
if pokemon.owner.name == "RENTAL"
scene.pbDisplay(_INTL("You cannot unfuse a rental pokémon!"))
return
end
pokemon.spriteform_body = nil
pokemon.spriteform_head = nil
bodyPoke = getBasePokemonID(pokemon.species_data.id_number, true)
headPoke = getBasePokemonID(pokemon.species_data.id_number, false)
if (pokemon.foreign?($Trainer)) # && !canunfuse
scene.pbDisplay(_INTL("You can't unfuse a Pokémon obtained in a trade!"))
return false
else
if Kernel.pbConfirmMessageSerious(_INTL("Should {1} be unfused?", pokemon.name))
keepInParty = 0
if $Trainer.party.length >= 6 && !pcPosition
message = "Your party is full! Keep which Pokémon in party?"
message = "Your party is full! Keep which Pokémon in party? The other will be released." if isOnPinkanIsland()
scene.pbDisplay(_INTL(message))
selectPokemonMessage = "Select a Pokémon to keep in your party."
selectPokemonMessage = "Select a Pokémon to keep in your party. The other will be released" if isOnPinkanIsland()
choice = Kernel.pbMessage(selectPokemonMessage, [_INTL("{1}", PBSpecies.getName(bodyPoke)), _INTL("{1}", PBSpecies.getName(headPoke)), "Cancel"], 2)
if choice == 2
return false
else
keepInParty = choice
end
end
scene.pbDisplay(_INTL("Unfusing ... "))
scene.pbDisplay(_INTL(" ... "))
scene.pbDisplay(_INTL(" ... "))
if pokemon.exp_when_fused_head == nil || pokemon.exp_when_fused_body == nil
new_level = calculateUnfuseLevelOldMethod(pokemon, supersplicers)
body_level = new_level
head_level = new_level
poke1 = Pokemon.new(bodyPoke, body_level)
poke2 = Pokemon.new(headPoke, head_level)
else
exp_body = pokemon.exp_when_fused_body + pokemon.exp_gained_since_fused
exp_head = pokemon.exp_when_fused_head + pokemon.exp_gained_since_fused
poke1 = Pokemon.new(bodyPoke, pokemon.level)
poke2 = Pokemon.new(headPoke, pokemon.level)
poke1.exp = exp_body
poke2.exp = exp_head
end
body_level = poke1.level
head_level = poke2.level
pokemon.exp_gained_since_fused = 0
pokemon.exp_when_fused_head = nil
pokemon.exp_when_fused_body = nil
if pokemon.shiny?
pokemon.shiny = false
if pokemon.bodyShiny? && pokemon.headShiny?
pokemon.shiny = true
poke2.shiny = true
pokemon.natural_shiny = true if pokemon.natural_shiny && !pokemon.debug_shiny
poke2.natural_shiny = true if pokemon.natural_shiny && !pokemon.debug_shiny
elsif pokemon.bodyShiny?
pokemon.shiny = true
poke2.shiny = false
pokemon.natural_shiny = true if pokemon.natural_shiny && !pokemon.debug_shiny
elsif pokemon.headShiny?
poke2.shiny = true
pokemon.shiny = false
poke2.natural_shiny = true if pokemon.natural_shiny && !pokemon.debug_shiny
else
# shiny was obtained already fused
if rand(2) == 0
pokemon.shiny = true
else
poke2.shiny = true
end
end
end
fused_pokemon_learned_moved = pokemon.learned_moves
pokemon.learned_moves = fused_pokemon_learned_moved
poke2.learned_moves = fused_pokemon_learned_moved
pokemon.ability_index = pokemon.body_original_ability_index if pokemon.body_original_ability_index
poke2.ability_index = pokemon.head_original_ability_index if pokemon.head_original_ability_index
pokemon.ability2_index = nil
pokemon.ability2 = nil
poke2.ability2_index = nil
poke2.ability2 = nil
pokemon.debug_shiny = true if pokemon.debug_shiny && pokemon.body_shiny
poke2.debug_shiny = true if pokemon.debug_shiny && poke2.head_shiny
pokemon.body_shiny = false
pokemon.head_shiny = false
if !pokemon.shiny?
pokemon.debug_shiny = false
end
if !poke2.shiny?
poke2.debug_shiny = false
end
if $Trainer.party.length >= 6
if (keepInParty == 0)
if isOnPinkanIsland()
scene.pbDisplay(_INTL("{1} was released.", poke2.name))
else
$PokemonStorage.pbStoreCaught(poke2)
scene.pbDisplay(_INTL("{1} was sent to the PC.", poke2.name))
end
else
poke2 = Pokemon.new(bodyPoke, body_level)
poke1 = Pokemon.new(headPoke, head_level)
# Fusing from PC
if pcPosition != nil
box = pcPosition[0]
index = pcPosition[1]
# todo: store at next available position from current position
$PokemonStorage.pbStoreCaught(poke2)
else
# Fusing from party
if isOnPinkanIsland()
scene.pbDisplay(_INTL("{1} was released.", poke2.name))
else
$PokemonStorage.pbStoreCaught(poke2)
scene.pbDisplay(_INTL("{1} was sent to the PC.", poke2.name))
end
end
end
else
if pcPosition != nil
box = pcPosition[0]
index = pcPosition[1]
# todo: store at next available position from current position
$PokemonStorage.pbStoreCaught(poke2)
else
Kernel.pbAddPokemonSilent(poke2, poke2.level)
end
end
# On ajoute les poke au pokedex
$Trainer.pokedex.set_seen(poke1.species)
$Trainer.pokedex.set_owned(poke1.species)
$Trainer.pokedex.set_seen(poke2.species)
$Trainer.pokedex.set_owned(poke2.species)
pokemon.species = poke1.species
pokemon.level = poke1.level
pokemon.name = poke1.name
pokemon.moves = poke1.moves
pokemon.obtain_method = 0
poke1.obtain_method = 0
# scene.pbDisplay(_INTL(p1.to_s + " " + p2.to_s))
scene.pbHardRefresh
scene.pbDisplay(_INTL("Your Pokémon were successfully unfused! "))
return true
end
end
end# frozen_string_literal: true
def returnItemsToBag(pokemon, poke2)
it1 = pokemon.item
it2 = poke2.item
$PokemonBag.pbStoreItem(it1, 1) if it1 != nil
$PokemonBag.pbStoreItem(it2, 1) if it2 != nil
pokemon.item = nil
poke2.item = nil
end

View File

@@ -0,0 +1,403 @@
# module GameData
# class FusedSpecies < GameData::Species
# attr_reader :growth_rate
# attr_reader :body_pokemon
# attr_reader :head_pokemon
#
# def initialize(id)
# if id.is_a?(Integer)
# body_id = getBodyID(id)
# head_id = getHeadID(id, body_id)
# pokemon_id = getFusedPokemonIdFromDexNum(body_id, head_id)
# return GameData::FusedSpecies.new(pokemon_id)
# end
# head_id = get_head_number_from_symbol(id)
# body_id = get_body_number_from_symbol(id)
#
# @body_pokemon = GameData::Species.get(body_id)
# @head_pokemon = GameData::Species.get(head_id)
#
# @id = id
# @id_number = calculate_dex_number()
# @species = @id
# @form = 0
# @real_name = calculate_name()
# @real_form_name = nil
#
# @type1 = calculate_type1()
# @type2 = calculate_type2()
#
# #Stats
# @base_stats = calculate_base_stats()
# @evs = calculate_evs()
# adjust_stats_with_evs()
#
# @base_exp = calculate_base_exp()
# @growth_rate = calculate_growth_rate()
# @gender_ratio = calculate_gender() #todo
# @catch_rate = calculate_catch_rate()
# @happiness = calculate_base_happiness()
#
# #Moves
# @moves = calculate_moveset()
# @tutor_moves = calculate_tutor_moves() # hash[:tutor_moves] || []
# @egg_moves = calculate_egg_moves() # hash[:egg_moves] || []
#
# #Abilities
# @abilities = calculate_abilities() # hash[:abilities] || []
# @hidden_abilities = calculate_hidden_abilities() # hash[:hidden_abilities] || []
#
# #wild held items
# @wild_item_common = get_wild_item(@head_pokemon.wild_item_common, @body_pokemon.wild_item_common) # hash[:wild_item_common]
# @wild_item_uncommon = get_wild_item(@head_pokemon.wild_item_uncommon, @body_pokemon.wild_item_uncommon) # hash[:wild_item_uncommon]
# @wild_item_rare = get_wild_item(@head_pokemon.wild_item_rare, @body_pokemon.wild_item_rare) # hash[:wild_item_rare]
#
# @evolutions = calculate_evolutions() # hash[:evolutions] || []
#
# #breeding
# @egg_groups = [:Undiscovered] #calculate_egg_groups() # hash[:egg_groups] || [:Undiscovered]
# @hatch_steps = calculate_hatch_steps() # hash[:hatch_steps] || 1
# @incense = nil #hash[:incense]
#
# #pokedex
# @pokedex_form = @form #ignored
# @real_category = calculate_category()
# @real_pokedex_entry = calculate_dex_entry()
# @height = average_values(@head_pokemon.height, @body_pokemon.height)
# @weight = average_values(@head_pokemon.weight, @body_pokemon.weight)
# @color = @head_pokemon.color
# @shape = @body_pokemon.shape
#
# #sprite positioning
# @back_sprite_x = @body_pokemon.back_sprite_x
# @back_sprite_y = @body_pokemon.back_sprite_y
# @front_sprite_x = @body_pokemon.front_sprite_x
# @front_sprite_y = @body_pokemon.front_sprite_y
# @front_sprite_altitude = @body_pokemon.front_sprite_altitude
# @shadow_x = @body_pokemon.shadow_x
# @shadow_size = @body_pokemon.shadow_size
#
# # #unused attributes from Species class
# #
# # @shape = :Head
# # @habitat = :None
# # @generation = 0
# # @mega_stone = nil
# # @mega_move = nil
# # @unmega_form = 0
# # @mega_message = 0
# end
#
# def get_body_number_from_symbol(id)
# return id.to_s.match(/\d+/)[0].to_i
# end
#
# def get_head_number_from_symbol(id)
# return id.to_s.match(/(?<=H)\d+/)[0].to_i
# end
#
# def get_body_species
# return @body_pokemon.id_number
# end
#
# def get_head_species
# return @head_pokemon.id_number
# end
#
# def get_body_species_symbol
# return @body_pokemon.id
# end
#
# def get_head_species_symbol
# return @head_pokemon.id
# end
#
# def adjust_stats_with_evs
# GameData::Stat.each_main do |s|
# @base_stats[s.id] = 1 if !@base_stats[s.id] || @base_stats[s.id] <= 0
# @evs[s.id] = 0 if !@evs[s.id] || @evs[s.id] < 0
# end
# end
#
# #FUSION CALCULATIONS
# def calculate_dex_number()
# return (@body_pokemon.id_number * NB_POKEMON) + @head_pokemon.id_number
# end
#
# def calculate_type1()
# return @head_pokemon.type2 if @head_pokemon.type1 == :NORMAL && @head_pokemon.type2 == :FLYING
# return @head_pokemon.type1
# end
#
# def calculate_type2()
# return @body_pokemon.type1 if @body_pokemon.type2 == @type1
# return @body_pokemon.type2
# end
#
# def calculate_base_stats()
# head_stats = @head_pokemon.base_stats
# body_stats = @body_pokemon.base_stats
#
# fused_stats = {}
#
# #Head dominant stats
# fused_stats[:HP] = calculate_fused_stats(head_stats[:HP], body_stats[:HP])
# fused_stats[:SPECIAL_DEFENSE] = calculate_fused_stats(head_stats[:SPECIAL_DEFENSE], body_stats[:SPECIAL_DEFENSE])
# fused_stats[:SPECIAL_ATTACK] = calculate_fused_stats(head_stats[:SPECIAL_ATTACK], body_stats[:SPECIAL_ATTACK])
#
# #Body dominant stats
# fused_stats[:ATTACK] = calculate_fused_stats(body_stats[:ATTACK], head_stats[:ATTACK])
# fused_stats[:DEFENSE] = calculate_fused_stats(body_stats[:DEFENSE], head_stats[:DEFENSE])
# fused_stats[:SPEED] = calculate_fused_stats(body_stats[:SPEED], head_stats[:SPEED])
#
# return fused_stats
# end
#
# def calculate_base_exp()
# head_exp = @head_pokemon.base_exp
# body_exp = @body_pokemon.base_exp
# return average_values(head_exp, body_exp)
# end
#
# def calculate_catch_rate
# return get_lowest_value(@body_pokemon.catch_rate, @head_pokemon.catch_rate)
# end
#
# def calculate_base_happiness
# return @head_pokemon.happiness
# end
#
# def calculate_moveset
# return combine_arrays(@body_pokemon.moves, @head_pokemon.moves)
# end
#
# def calculate_egg_moves
# return combine_arrays(@body_pokemon.egg_moves, @head_pokemon.egg_moves)
# end
#
# def calculate_tutor_moves
# return combine_arrays(@body_pokemon.tutor_moves, @head_pokemon.tutor_moves)
# end
#
# def get_wild_item(body_item, head_item)
# rand_num = rand(2)
# if rand_num == 0
# return body_item
# else
# return head_item
# end
# end
#
# def calculate_abilities()
# abilities_hash = []
#
# ability1 = @body_pokemon.abilities[0]
# ability2 = @head_pokemon.abilities[0]
# abilities_hash << ability1
# abilities_hash << ability2
# return abilities_hash
# end
#
# # def calculate_abilities(pokemon1, pokemon2)
# # abilities_hash = []
# #
# # ability1 = pokemon1.abilities[0]
# # ability2 = pokemon2.abilities[1]
# # if !ability2
# # ability2 = pokemon2.abilities[0]
# # end
# # abilities_hash << ability1
# # abilities_hash << ability2
# # return abilities_hash
# # end
#
# def calculate_hidden_abilities()
# abilities_hash = []
#
# #First two spots are the other abilities of the two pokemon
# ability1 = @body_pokemon.abilities[1]
# ability2 = @head_pokemon.abilities[1]
# ability1 = @body_pokemon.abilities[0] if !ability1
# ability2 = @head_pokemon.abilities[0] if !ability2
#
# abilities_hash << ability1
# abilities_hash << ability2
#
# #add the hidden ability for the two base pokemon
# hiddenAbility1 = @body_pokemon.hidden_abilities[0]
# hiddenAbility1 = ability1 if !hiddenAbility1
#
# hiddenAbility2 = @head_pokemon.hidden_abilities[0]
# hiddenAbility2 = ability2 if !hiddenAbility2
#
# abilities_hash << hiddenAbility1
# abilities_hash << hiddenAbility2
# return abilities_hash
# end
#
# def calculate_name()
# body_nat_dex = GameData::NAT_DEX_MAPPING[@body_pokemon.id_number] ? GameData::NAT_DEX_MAPPING[@body_pokemon.id_number] : @body_pokemon.id_number
# head_nat_dex = GameData::NAT_DEX_MAPPING[@head_pokemon.id_number] ? GameData::NAT_DEX_MAPPING[@head_pokemon.id_number] : @head_pokemon.id_number
# begin
# prefix = GameData::SPLIT_NAMES[head_nat_dex][0]
# suffix = GameData::SPLIT_NAMES[body_nat_dex][1]
# if prefix[-1] == suffix[0]
# prefix = prefix[0..-2]
# end
# suffix = suffix.capitalize if prefix.end_with?(" ")
# return prefix + suffix
#
# rescue
# print("species with error: " + @species.to_s)
# end
#
# end
#
# def calculate_evolutions()
# body_evolutions = @body_pokemon.evolutions
# head_evolutions = @head_pokemon.evolutions
#
# fused_evolutions = []
#
# #body
# for evolution in body_evolutions
# evolutionSpecies = evolution[0]
# evolutionSpecies_dex = GameData::Species.get(evolutionSpecies).id_number
# fused_species = _INTL("B{1}H{2}", evolutionSpecies_dex, @head_pokemon.id_number)
# fused_evolutions << build_evolution_array(evolution, fused_species)
# end
#
# #head
# for evolution in head_evolutions
# evolutionSpecies = evolution[0]
# evolutionSpecies_dex = GameData::Species.get(evolutionSpecies).id_number
# fused_species = _INTL("B{1}H{2}", @body_pokemon.id_number, evolutionSpecies_dex)
# fused_evolutions << build_evolution_array(evolution, fused_species)
# end
#
# return fused_evolutions
# end
#
# #Change the evolution species depending if head & body and keep the rest of the data the same
# def build_evolution_array(evolution_data, new_species)
# fused_evolution_array = []
# fused_evolution_array << new_species.to_sym
#
# #add the rest
# for data in evolution_data
# next if evolution_data.index(data) == 0
# fused_evolution_array << data
# end
# return fused_evolution_array
# end
#
# def calculate_dex_entry
# body_entry = @body_pokemon.real_pokedex_entry.gsub(@body_pokemon.real_name, @real_name)
# head_entry = @head_pokemon.real_pokedex_entry.gsub(@head_pokemon.real_name, @real_name)
#
# return split_and_combine_text(body_entry, head_entry, ".")
# end
#
# def get_random_dex_entry()
# begin
# file_path = Settings::POKEDEX_ENTRIES_PATH
# json_data = File.read(file_path)
# all_body_entries = HTTPLite::JSON.parse(json_data)
#
#
# body_entry = all_body_entries[@body_pokemon.id_number.to_s].sample
# body_entry = body_entry.gsub(/#{@body_pokemon.real_name}/i, @real_name)
# body_entry = clean_json_string(body_entry).gsub(@body_pokemon.real_name, @real_name)
#
# head_entry = all_body_entries[@head_pokemon.id_number.to_s].sample
# head_entry = head_entry.gsub(/#{@head_pokemon.real_name}/i, @real_name)
# head_entry = clean_json_string(head_entry).gsub(@head_pokemon.real_name, @real_name)
# rescue
# body_entry = @body_pokemon.real_pokedex_entry.gsub(@body_pokemon.real_name, @real_name)
# head_entry = @head_pokemon.real_pokedex_entry.gsub(@head_pokemon.real_name, @real_name)
# end
# echoln body_entry
# echoln head_entry
# combined_entry = split_and_combine_text(body_entry, head_entry, ".")
# combined_entry += "." unless combined_entry.end_with?(".")
# return combined_entry
# end
#
# def calculate_egg_groups
# body_egg_groups = @body_pokemon.egg_groups
# head_egg_groups = @head_pokemon.egg_groups
# return :Undiscovered if body_egg_groups.include?(:Undiscovered) || head_egg_groups.include?(:Undiscovered)
# return combine_arrays(body_egg_groups, head_egg_groups)
# end
#
# def calculate_hatch_steps
# return average_values(@head_pokemon.hatch_steps, @body_pokemon.hatch_steps)
# end
#
# def calculate_evs()
# return average_map_values(@body_pokemon.evs, @head_pokemon.evs)
# end
#
# def calculate_category
# return split_and_combine_text(@body_pokemon.category, @head_pokemon.category, " ")
# end
#
# def calculate_growth_rate
# growth_rate_priority = [:Fast, :Medium, :Parabolic, :Fluctuating, :Erratic, :Slow] #todo rearrange order for balance?
# body_growth_rate = @body_pokemon.growth_rate
# head_growth_rate = @head_pokemon.growth_rate
# base_growth_rates = [body_growth_rate, head_growth_rate]
# for rate in growth_rate_priority
# return rate if base_growth_rates.include?(rate)
# end
# return :Medium
# end
#
# #TODO
# # ################## UNFINISHED ####################
# def calculate_gender
# return :Genderless
# end
#
# ############################# UTIL METHODS ###############################
#
# #Takes 2 strings, splits and combines them using the beginning of the first one and the end of the second one
# # (for example for pokedex entries)
# def split_and_combine_text(beginingText_full, endText_full, separator)
# beginingText_split = beginingText_full.split(separator, 2)
# endText_split = endText_full.split(separator, 2)
#
# beginningText = beginingText_split[0]
# endText = endText_split[1] && endText_split[1] != "" ? endText_split[1] : endText_split[0]
# return beginningText + separator + " " + endText
# end
#
# def calculate_fused_stats(dominantStat, otherStat)
# return ((2 * dominantStat) / 3) + (otherStat / 3).floor
# end
#
# def average_values(value1, value2)
# return ((value1 + value2) / 2).floor
# end
#
# def average_map_values(map1, map2)
# averaged_map = map1.merge(map2) do |key, value1, value2|
# ((value1 + value2) / 2.0).floor
# end
# return averaged_map
# end
#
# def get_highest_value(value1, value2)
# return value1 > value2 ? value1 : value2
# end
#
# def get_lowest_value(value1, value2)
# return value1 < value2 ? value1 : value2
# end
#
# def combine_arrays(array1, array2)
# return array1 + array2
# end
#
# end
# end

View File

@@ -0,0 +1,31 @@
# module GameData
# module ClassMethods
# def get(other)
# validate other => [Symbol, self, String, Integer]
# return other if other.is_a?(self)
# other = other.to_sym if other.is_a?(String)
#
# if other.to_s.match?(/\AB\d+H\d+\z/)
# species = GameData::FusedSpecies.new(other)
# return species
# end
#
# if other.is_a?(Integer) && self == GameData::Species
# if other > NB_POKEMON
# body_id = getBodyID(other)
# head_id = getHeadID(other, body_id)
# pokemon_id = getFusedPokemonIdFromDexNum(body_id, head_id)
# return GameData::FusedSpecies.new(pokemon_id)
# end
# end
#
# if !self::DATA.has_key?(other)
# # echoln _INTL("Unknown ID {1}.", other)
# return self::get(:PIKACHU)
# end
#
# raise "Unknown ID #{other}." unless self::DATA.has_key?(other)
# return self::DATA[other]
# end
# end
# end

View File

@@ -0,0 +1,410 @@
def is_fusion_of_any(species_id, pokemonList)
is_species = false
for fusionPokemon in pokemonList
if is_fusion_of(species_id, fusionPokemon)
is_species = true
end
end
return is_species
end
def is_fusion_of(checked_species, checked_against)
return species_has_body_of(checked_species, checked_against) || species_has_head_of(checked_species, checked_against)
end
def is_species(checked_species, checked_against)
return checked_species == checked_against
end
def species_has_body_of(checked_species, checked_against)
if !species_is_fusion(checked_species)
return is_species(checked_species, checked_against)
end
bodySpecies = get_body_species_from_symbol(checked_species)
ret = bodySpecies == checked_against
#echoln _INTL("{1} HAS BODY OF {2} : {3} (body is {4})",checked_species,checked_against,ret,bodySpecies)
return ret
end
def species_has_head_of(checked_species, checked_against)
if !species_is_fusion(checked_species)
return is_species(checked_species, checked_against)
end
headSpecies = get_head_species_from_symbol(checked_species)
ret = headSpecies == checked_against
#echoln _INTL("{1} HAS HEAD OF {2} : {3}",checked_species,checked_against,ret)
return ret
end
def species_is_fusion(species_id)
dex_number = get_dex_number(species_id)
return dex_number > NB_POKEMON && dex_number < Settings::ZAPMOLCUNO_NB
end
def get_dex_number(species_id)
return GameData::Species.get(species_id).id_number
end
def getBodyID(species, nb_pokemon = NB_POKEMON)
if species.is_a?(Integer)
dexNum = species
else
dexNum = getDexNumberForSpecies(species)
end
if dexNum % nb_pokemon == 0
return (dexNum / nb_pokemon) - 1
end
return (dexNum / nb_pokemon).round
end
def getHeadID(species, bodyId = nil, nb_pokemon = NB_POKEMON)
if species.is_a?(Integer)
fused_dexNum = species
else
fused_dexNum = getDexNumberForSpecies(species)
end
if bodyId == nil
bodyId = getBodyID(species)
end
body_dexNum = getDexNumberForSpecies(bodyId)
calculated_number = (fused_dexNum - (body_dexNum * nb_pokemon)).round
return calculated_number == 0 ? nb_pokemon : calculated_number
end
def get_fusion_id(head_number, body_number)
return "B#{body_number}H#{head_number}".to_sym
end
def get_body_id_from_symbol(id)
split_id = id.to_s.match(/\d+/)
if !split_id #non-fusion
return GameData::Species.get(id).id_number
end
return split_id[0].to_i
end
def get_head_id_from_symbol(id)
split_id = id.to_s.match(/(?<=H)\d+/)
if !split_id #non-fusion
return GameData::Species.get(id).id_number
end
return split_id[0].to_i
end
def obtainPokemonSpritePath(id, includeCustoms = true)
head = getBasePokemonID(param.to_i, false)
body = getBasePokemonID(param.to_i, true)
return obtainPokemonSpritePath(body, head, includeCustoms)
end
def obtainPokemonSpritePath(bodyId, headId, include_customs = true)
#download_pokemon_sprite_if_missing(bodyId, headId)
picturePath = _INTL("Graphics/Battlers/{1}/{1}.{2}.png", headId, bodyId)
if include_customs && customSpriteExistsBodyHead(bodyId, headId)
pathCustom = getCustomSpritePath(bodyId, headId)
if (pbResolveBitmap(pathCustom))
picturePath = pathCustom
end
end
return picturePath
end
def getCustomSpritePath(body, head)
return _INTL("#{Settings::CUSTOM_BATTLERS_FOLDER_INDEXED}{1}/{1}.{2}.png", head, body)
end
def customSpriteExistsForm(species, form_id_head = nil, form_id_body = nil)
head = getBasePokemonID(species, false)
body = getBasePokemonID(species, true)
folder = head.to_s
folder += "_" + form_id_head.to_s if form_id_head
spritename = head.to_s
spritename += "_" + form_id_head.to_s if form_id_head
spritename += "." + body.to_s
spritename += "_" + form_id_body.to_s if form_id_body
pathCustom = _INTL("Graphics/.CustomBattlers/indexed/{1}/{2}.png", folder, spritename)
return true if pbResolveBitmap(pathCustom) != nil
return download_custom_sprite(head, body) != nil
end
def get_fusion_spritename(head_id, body_id, alt_letter = "")
return "#{head_id}.#{body_id}#{alt_letter}"
end
def customSpriteExistsSpecies(species)
head = getBasePokemonID(species, false)
body = getBasePokemonID(species, true)
return customSpriteExists(body, head)
# pathCustom = getCustomSpritePath(body, head)
#
# return true if pbResolveBitmap(pathCustom) != nil
# return download_custom_sprite(head, body) != nil
end
def getRandomCustomFusion(returnRandomPokemonIfNoneFound = true, customPokeList = [], maxPoke = -1, recursionLimit = 3)
if customPokeList.length == 0
customPokeList = getCustomSpeciesList(false)
end
randPoke = []
if customPokeList.length >= 5000
chosen = false
i = 0 #loop pas plus que 3 fois pour pas lag
while chosen == false
fusedPoke = customPokeList[rand(customPokeList.length)]
poke1 = getBasePokemonID(fusedPoke, false)
poke2 = getBasePokemonID(fusedPoke, true)
if ((poke1 <= maxPoke && poke2 <= maxPoke) || i >= recursionLimit) || maxPoke == -1
randPoke << getBasePokemonID(fusedPoke, false)
randPoke << getBasePokemonID(fusedPoke, true)
chosen = true
end
end
else
if returnRandomPokemonIfNoneFound
randPoke << rand(maxPoke) + 1
randPoke << rand(maxPoke) + 1
end
end
return randPoke
end
def checkIfCustomSpriteExistsByPath(path)
return true if pbResolveBitmap(path) != nil
end
def customSpriteExistsBodyHead(body, head)
pathCustom = getCustomSpritePath(body, head)
return true if pbResolveBitmap(pathCustom) != nil
return download_custom_sprite(head, body) != nil
end
def customSpriteExistsSpecies(species)
body_id = getBodyID(species)
head_id = getHeadID(species, body_id)
fusion_id = get_fusion_symbol(head_id, body_id)
return $game_temp.custom_sprites_list.include?(fusion_id)
end
def customSpriteExists(body, head)
fusion_id = get_fusion_symbol(head, body)
return $game_temp.custom_sprites_list.include?(fusion_id)
end
#shortcut for using in game events because of script characters limit
def dexNum(species)
return getDexNumberForSpecies(species)
end
def isTripleFusion?(num)
return num >= Settings::ZAPMOLCUNO_NB
end
def isFusion(num)
return num > Settings::NB_POKEMON && !isTripleFusion?(num)
end
def isSpeciesFusion(species)
num = getDexNumberForSpecies(species)
return isFusion(num)
end
def getRandomLocalFusion()
spritesList = []
$PokemonGlobal.alt_sprite_substitutions.each_value do |value|
if value.is_a?(PIFSprite)
spritesList << value
end
end
return spritesList.sample
end
def getRandomFusionForIntro()
random_pokemon = $game_temp.custom_sprites_list.keys.sample || :PIKACHU
alt_letter = $game_temp.custom_sprites_list[random_pokemon]
body_id = get_body_number_from_symbol(random_pokemon)
head_id = get_head_number_from_symbol(random_pokemon)
return PIFSprite.new(:CUSTOM, head_id, body_id, alt_letter)
end
def getSpeciesIdForFusion(head_number, body_number)
return (body_number) * Settings::NB_POKEMON + head_number
end
def get_body_species_from_symbol(fused_id)
body_num = get_body_number_from_symbol(fused_id)
return GameData::Species.get(body_num).species
end
def get_head_species_from_symbol(fused_id)
head_num = get_head_number_from_symbol(fused_id)
return GameData::Species.get(head_num).species
end
def get_body_number_from_symbol(id)
dexNum = getDexNumberForSpecies(id)
return dexNum if !isFusion(dexNum)
id.to_s.match(/\d+/)[0]
return id.to_s.match(/\d+/)[0].to_i
end
def get_head_number_from_symbol(id)
dexNum = getDexNumberForSpecies(id)
return dexNum if !isFusion(dexNum)
return id.to_s.match(/(?<=H)\d+/)[0].to_i
end
def get_fusion_symbol(head_id, body_id)
return "B#{body_id}H#{head_id}".to_sym
end
def getFusionSpecies(body, head)
body_num = getDexNumberForSpecies(body)
head_num = getDexNumberForSpecies(head)
id = body_num * Settings::NB_POKEMON + head_num
return GameData::Species.get(id)
end
def getDexNumberForSpecies(species)
return species if species.is_a?(Integer)
if species.is_a?(Symbol)
dexNum = GameData::Species.get(species).id_number
elsif species.is_a?(Pokemon)
dexNum = GameData::Species.get(species.species).id_number
elsif species.is_a?(GameData::Species)
return species.id_number
else
dexNum = species
end
return dexNum
end
def getFusedPokemonIdFromDexNum(body_dex, head_dex)
return ("B" + body_dex.to_s + "H" + head_dex.to_s).to_sym
end
def getFusedPokemonIdFromSymbols(body_dex, head_dex)
bodyDexNum = GameData::Species.get(body_dex).id_number
headDexNum = GameData::Species.get(head_dex).id_number
return getFusedPokemonIdFromDexNum(bodyDexNum, headDexNum)
end
def generateFusionIcon(dexNum, path)
begin
IO.copy_stream(dexNum, path)
return true
rescue
return false
end
end
def ensureFusionIconExists
directory_name = "Graphics/Pokemon/FusionIcons"
Dir.mkdir(directory_name) unless File.exists?(directory_name)
end
def addNewTripleFusion(pokemon1, pokemon2, pokemon3, level = 1)
return if !pokemon1
return if !pokemon2
return if !pokemon3
if pbBoxesFull?
pbMessage(_INTL("There's no more room for Pokémon!\1"))
pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
return false
end
pokemon = TripleFusion.new(pokemon1, pokemon2, pokemon3, level)
pokemon.calc_stats
pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, pokemon.name))
pbNicknameAndStore(pokemon)
#$Trainer.pokedex.register(pokemon)
return true
end
def get_triple_fusion_components(species_id)
dex_num = GameData::Species.get(species_id).id_number
case dex_num
when Settings::ZAPMOLCUNO_NB
return [144,145,146]
when Settings::ZAPMOLCUNO_NB + 1
return [144,145,146]
when Settings::ZAPMOLCUNO_NB + 2
return [243,244,245]
when Settings::ZAPMOLCUNO_NB + 3
return [340,341,342]
when Settings::ZAPMOLCUNO_NB + 4
return [343,344,345]
when Settings::ZAPMOLCUNO_NB + 5
return [349,350,351]
when Settings::ZAPMOLCUNO_NB + 6
return [151,251,381]
when Settings::ZAPMOLCUNO_NB + 11
return [150,348,380]
#starters
when Settings::ZAPMOLCUNO_NB + 7
return [3,6,9]
when Settings::ZAPMOLCUNO_NB + 8
return [154,157,160]
when Settings::ZAPMOLCUNO_NB + 9
return [278,281,284]
when Settings::ZAPMOLCUNO_NB + 10
return [318,321,324]
#starters prevos
when Settings::ZAPMOLCUNO_NB + 12
return [1,4,7]
when Settings::ZAPMOLCUNO_NB + 13
return [2,5,8]
when Settings::ZAPMOLCUNO_NB + 14
return [152,155,158]
when Settings::ZAPMOLCUNO_NB + 15
return [153,156,159]
when Settings::ZAPMOLCUNO_NB + 16
return [276,279,282]
when Settings::ZAPMOLCUNO_NB + 17
return [277,280,283]
when Settings::ZAPMOLCUNO_NB + 18
return [316,319,322]
when Settings::ZAPMOLCUNO_NB + 19
return [317,320,323]
when Settings::ZAPMOLCUNO_NB + 20 #birdBoss Left
return []
when Settings::ZAPMOLCUNO_NB + 21 #birdBoss middle
return [144,145,146]
when Settings::ZAPMOLCUNO_NB + 22 #birdBoss right
return []
when Settings::ZAPMOLCUNO_NB + 23 #sinnohboss left
return []
when Settings::ZAPMOLCUNO_NB + 24 #sinnohboss middle
return [343,344,345]
when Settings::ZAPMOLCUNO_NB + 25 #sinnohboss right
return []
when Settings::ZAPMOLCUNO_NB + 25 #cardboard
return []
when Settings::ZAPMOLCUNO_NB + 26 #cardboard
return []
when Settings::ZAPMOLCUNO_NB + 27 #Triple regi
return [447,448,449]
#Triple Kalos 1
when Settings::ZAPMOLCUNO_NB + 28
return [479,482,485]
when Settings::ZAPMOLCUNO_NB + 29
return [480,483,486]
when Settings::ZAPMOLCUNO_NB + 30
return [481,484,487]
else
return [000]
end
end