Update 6.8

This commit is contained in:
chardub
2026-07-10 15:42:06 -04:00
parent 5b85e72cb2
commit 6a6f126a18
7871 changed files with 493194 additions and 224826 deletions
@@ -0,0 +1,66 @@
def generateEggGroupTeam(eggGroup)
teamComplete = false
generatedTeam = []
while !teamComplete
species = rand(PBSpecies.maxValue)
if getPokemonEggGroups(species).include?(eggGroup)
generatedTeam << species
end
teamComplete = generatedTeam.length == 3
end
return generatedTeam
end
def generateSimpleTrainerParty(teamSpecies, level)
team = []
for species in teamSpecies
poke = Pokemon.new(species, level)
team << poke
end
return team
end
def Kernel.getRoamingMap(roamingArrayPos)
curmap = $PokemonGlobal.roamPosition[roamingArrayPos]
mapinfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
text = mapinfos[curmap].name #,(curmap==$game_map.map_id) ? _INTL("(this map)") : "")
return text
end
def Kernel.getItemNamesAsString(list)
strList = ""
for i in 0..list.length - 1
id = list[i]
name = PBItems.getName(id)
strList += name
if i != list.length - 1 && list.length > 1
strList += ","
end
end
return strList
end
def getCurrentLevelCap()
if Settings::KANTO
current_max_level = Settings::LEVEL_CAPS_KANTO[$Trainer.badge_count]
else
current_max_level = Settings::LEVEL_CAPS_HOENN[$Trainer.badge_count]
end
current_max_level *= Settings::HARD_MODE_LEVEL_MODIFIER if $game_switches[SWITCH_GAME_DIFFICULTY_HARD]
current_max_level *= Settings::EASY_MODE_LEVEL_MODIFIER if $game_switches[SWITCH_GAME_DIFFICULTY_EASY] && Settings::HOENN
return current_max_level&.floor || 100
end
def pokemonExceedsLevelCap(pokemon)
return false if $Trainer.badge_count >= Settings::NB_BADGES
current_max_level = getCurrentLevelCap()
return pokemon.level >= current_max_level
end
def setForcedAltSprites(forcedSprites_map)
$PokemonTemp.forced_alt_sprites = forcedSprites_map
end
@@ -0,0 +1,37 @@
def reverseFusionSpecies(species)
dexId = getDexNumberForSpecies(species)
return species if dexId <= NB_POKEMON
return species if dexId > (NB_POKEMON * NB_POKEMON) + NB_POKEMON
body = getBasePokemonID(dexId, true)
head = getBasePokemonID(dexId, false)
newspecies = (head) * NB_POKEMON + body
return getPokemon(newspecies)
end
def replaceFusionSpecies(pokemon, speciesToChange, newSpecies)
currentBody = pokemon.species_data.get_body_species_symbol()
currentHead = pokemon.species_data.get_head_species_symbol()
should_update_body = currentBody == speciesToChange
should_update_head = currentHead == speciesToChange
echoln speciesToChange
echoln currentBody
echoln currentHead
return if !should_update_body && !should_update_head
newSpeciesBody = should_update_body ? newSpecies : currentBody
newSpeciesHead = should_update_head ? newSpecies : currentHead
newSpecies = getFusionSpecies(newSpeciesBody, newSpeciesHead)
echoln newSpecies.id_number
pokemon.species = newSpecies
end
def npc_fuse_screen(species_head,species_body)
head_pokemon = Pokemon.new(species_head,1)
body_pokemon = Pokemon.new(species_body,1)
return if head_pokemon.isFusion? || body_pokemon.isFusion?
npcTrainerFusionScreenPokemon(head_pokemon,body_pokemon)
end
@@ -0,0 +1,83 @@
def pbPokemonIconFile(pokemon)
bitmapFileName = pbCheckPokemonIconFiles(pokemon.species, pokemon.isEgg?)
return bitmapFileName
end
def pbCheckPokemonIconFiles(speciesID, egg = false, dna = false)
if egg
bitmapFileName = sprintf("Graphics/Icons/iconEgg")
return pbResolveBitmap(bitmapFileName)
else
bitmapFileName = "Graphics/Pokemon/Icons/#{speciesID}"
ret = pbResolveBitmap(bitmapFileName)
return ret if ret
end
ret = pbResolveBitmap("Graphics/Icons/iconDNA.png")
return ret if ret
return pbResolveBitmap("Graphics/Icons/iconDNA.png")
end
def addShinyStarsToGraphicsArray(imageArray, xPos, yPos, shinyBody, shinyHead, debugShiny, radarShiny, srcx = nil, srcy = nil, width = nil, height = nil,
showSecondStarUnder = false, showSecondStarAbove = false)
if debugShiny == true
color = debugShiny ? Color.new(0, 0, 0, 255) : nil
end
if radarShiny == true
color = radarShiny ? Color.new(0, 0, 255, 255) : nil
end
imageArray.push(["Graphics/Pictures/shiny", xPos, yPos, srcx, srcy, width, height, color])
if shinyBody && shinyHead
if showSecondStarUnder
yPos += 15
elsif showSecondStarAbove
yPos -= 15
else
xPos -= 15
end
imageArray.push(["Graphics/Pictures/shiny", xPos, yPos, srcx, srcy, width, height, color])
end
# if onlyOutline
# imageArray.push(["Graphics/Pictures/shiny_black",xPos,yPos,srcx,srcy,width,height,color])
# end
end
def pbBitmap(path)
resolved_path = pbResolveBitmap(path)
if !resolved_path.nil?
bmp = RPG::Cache.load_bitmap_path(resolved_path)
bmp.storedPath = resolved_path
else
p "Image located at '#{path}' was not found!" if $DEBUG
bmp = Bitmap.new(1, 1)
end
return bmp
end
# if need to play animation from event route
def playAnimation(animationId, x = nil, y = nil)
return if !$scene.is_a?(Scene_Map)
x = @event.x unless x
y = @event.y unless y
$scene.spriteset.addUserAnimation(animationId, x, y, true)
end
#Shows a picture, centered in the middle of the screen in a new viewport
# Returns the viewport. Use viewport.dispose to get rid of the picture
def showPicture(path,x,y,viewport_x=(Graphics.width / 4), viewport_y=0)
begin
echoln path
viewport = Viewport.new(viewport_x, viewport_y, Graphics.width, Graphics.height)
sprite = Sprite.new(viewport)
bitmap = AnimatedBitmap.new(path) if pbResolveBitmap(path)
sprite.bitmap = bitmap.bitmap
sprite.x = x
sprite.y = y
viewport.z = 99999
return viewport
rescue
end
end
@@ -0,0 +1,101 @@
def Kernel.getPlateType(item)
return :FIGHTING if item == PBItems::FISTPLATE
return :FLYING if item == PBItems::SKYPLATE
return :POISON if item == PBItems::TOXICPLATE
return :GROUND if item == PBItems::EARTHPLATE
return :ROCK if item == PBItems::STONEPLATE
return :BUG if item == PBItems::INSECTPLATE
return :GHOST if item == PBItems::SPOOKYPLATE
return :STEEL if item == PBItems::IRONPLATE
return :FIRE if item == PBItems::FLAMEPLATE
return :WATER if item == PBItems::SPLASHPLATE
return :GRASS if item == PBItems::MEADOWPLATE
return :ELECTRIC if item == PBItems::ZAPPLATE
return :PSYCHIC if item == PBItems::MINDPLATE
return :ICE if item == PBItems::ICICLEPLATE
return :DRAGON if item == PBItems::DRACOPLATE
return :DARK if item == PBItems::DREADPLATE
return :FAIRY if item == PBItems::PIXIEPLATE
return -1
end
def Kernel.listPlatesInBag()
list = []
list << PBItems::FISTPLATE if $PokemonBag.pbQuantity(:FISTPLATE) >= 1
list << PBItems::SKYPLATE if $PokemonBag.pbQuantity(:SKYPLATE) >= 1
list << PBItems::TOXICPLATE if $PokemonBag.pbQuantity(:TOXICPLATE) >= 1
list << PBItems::EARTHPLATE if $PokemonBag.pbQuantity(:EARTHPLATE) >= 1
list << PBItems::STONEPLATE if $PokemonBag.pbQuantity(:STONEPLATE) >= 1
list << PBItems::INSECTPLATE if $PokemonBag.pbQuantity(:INSECTPLATE) >= 1
list << PBItems::SPOOKYPLATE if $PokemonBag.pbQuantity(:SPOOKYPLATE) >= 1
list << PBItems::IRONPLATE if $PokemonBag.pbQuantity(:IRONPLATE) >= 1
list << PBItems::FLAMEPLATE if $PokemonBag.pbQuantity(:FLAMEPLATE) >= 1
list << PBItems::SPLASHPLATE if $PokemonBag.pbQuantity(:SPLASHPLATE) >= 1
list << PBItems::MEADOWPLATE if $PokemonBag.pbQuantity(:MEADOWPLATE) >= 1
list << PBItems::ZAPPLATE if $PokemonBag.pbQuantity(:ZAPPLATE) >= 1
list << PBItems::MINDPLATE if $PokemonBag.pbQuantity(:MINDPLATE) >= 1
list << PBItems::ICICLEPLATE if $PokemonBag.pbQuantity(:ICICLEPLATE) >= 1
list << PBItems::DRACOPLATE if $PokemonBag.pbQuantity(:DRACOPLATE) >= 1
list << PBItems::DREADPLATE if $PokemonBag.pbQuantity(:DREADPLATE) >= 1
list << PBItems::PIXIEPLATE if $PokemonBag.pbQuantity(:PIXIEPLATE) >= 1
return list
end
def getArceusPlateType(heldItem)
return :NORMAL if heldItem == nil
case heldItem
when :FISTPLATE
return :FIGHTING
when :SKYPLATE
return :FLYING
when :TOXICPLATE
return :POISON
when :EARTHPLATE
return :GROUND
when :STONEPLATE
return :ROCK
when :INSECTPLATE
return :BUG
when :SPOOKYPLATE
return :GHOST
when :IRONPLATE
return :STEEL
when :FLAMEPLATE
return :FIRE
when :SPLASHPLATE
return :WATER
when :MEADOWPLATE
return :GRASS
when :ZAPPLATE
return :ELECTRIC
when :MINDPLATE
return :PSYCHIC
when :ICICLEPLATE
return :ICE
when :DRACOPLATE
return :DRAGON
when :DREADPLATE
return :DARK
when :PIXIEPLATE
return :FAIRY
else
return :NORMAL
end
end
def hasFishingRod()
return hasItem?(:OLDROD) || hasItem?(:GOODROD) || hasItem?(:SUPERROD)
end
def list_all_item_names()
names = []
GameData::Item.list_all.each do |item|
names << item[1].name
end
return names
end
def hasItem?(item)
return $PokemonBag.pbQuantity(item) >= 1
end
@@ -0,0 +1,422 @@
def obtainBadgeMessage(badgeName)
Kernel.pbMessage(_INTL("\\me[Badge get]{1} obtained the {2}!", $Trainer.name, badgeName))
end
def pbSpendMoney(amount,showMessage=false,msgwindow=nil, goldwindow=nil)
pbReceiveMoney(0- amount,showMessage,msgwindow,goldwindow,)
end
def pbReceiveMoney(amount, showMessage=true, msgwindow=nil, goldwindow=nil)
msgwindow = pbCreateMessageWindow(nil) unless msgwindow
goldwindow = pbDisplayGoldWindow(msgwindow) unless goldwindow
if showMessage
if amount >= 0
pbMessage(_INTL("{1} received ${2}!", $Trainer.name, amount.to_s_formatted))
else
pbMessage(_INTL("{1} spent ${2}!", $Trainer.name, amount.abs.to_s_formatted))
end
end
# Show current money initial pause
15.times do
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
oldMoney = $Trainer.money
targetMoney = oldMoney + amount
step = [(amount.abs / 15), 1].max
current = oldMoney
# Count up/down animation
while (amount >= 0 ? current < targetMoney : current > targetMoney)
current += (amount >= 0 ? step : -step)
current = targetMoney if (amount >= 0 ? current > targetMoney : current < targetMoney)
color = amount >= 0 ? "00FF00" : "FF0000"
sign = amount >= 0 ? "+" : "-"
goldwindow.text = "Money:\n<ar>$#{current.to_s_formatted}</ar>\n<ar><c3=#{color}>#{sign}$#{amount.abs.to_s_formatted}</c3></ar>"
goldwindow.text = "Money:\n<ar>$#{current.to_s_formatted}</ar>\n<ar><c3=#{color}>#{sign}$#{amount.abs.to_s_formatted}</c3></ar>"
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
goldwindow.width = 160 if goldwindow.width <= 160
pbSEPlay("Mart buy item") if (amount >= 0 ? current < targetMoney : current > targetMoney)
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
$Trainer.money = targetMoney
# Final display text
goldwindow.text = "Money:\n<ar>$#{targetMoney.to_s_formatted}</ar>"
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
goldwindow.width = 160 if goldwindow.width <= 160
# Show final balance pause
20.times do
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
goldwindow.dispose
pbDisposeMessageWindow(msgwindow)
end
def pbSpendCosmeticMoney(amount,showMessage=false,msgwindow=nil, goldwindow=nil)
pbReceiveCosmeticsMoney(0- amount,showMessage,msgwindow,goldwindow,)
end
def pbReceiveCosmeticsMoney(amount, showMessage=true, msgwindow=nil, goldwindow=nil)
msgwindow = pbCreateMessageWindow(nil) unless msgwindow
goldwindow = pbDisplayCosmeticsMoneyWindow(msgwindow) unless goldwindow
if showMessage
if amount >= 0
pbMessage(_INTL("{1} received {2} {3}!", $Trainer.name, amount.to_s_formatted, COSMETIC_CURRENCY_NAME))
else
pbMessage(_INTL("{1} spent {2} {3}!", $Trainer.name, amount.abs.to_s_formatted, COSMETIC_CURRENCY_NAME))
end
end
# Show current cosmetic money initial pause
15.times do
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
oldMoney = $Trainer.cosmetics_money || 0
targetMoney = oldMoney + amount
step = [(amount.abs / 15), 1].max
current = oldMoney
# Count up/down animation
while (amount >= 0 ? current < targetMoney : current > targetMoney)
current += (amount >= 0 ? step : -step)
current = targetMoney if (amount >= 0 ? current > targetMoney : current < targetMoney)
color = amount >= 0 ? "00FF00" : "FF0000"
sign = amount >= 0 ? "+" : "-"
goldwindow.text = _INTL(
"{1}:\n<ar>{2}</ar>\n<ar><c3={3}>{4} {5}</c3></ar>",
COSMETIC_CURRENCY_NAME,
current.to_s_formatted,
color,
sign,
amount.abs.to_s_formatted
)
pbSEPlay("Mart buy item") if amount >= 0 ? current < targetMoney : current > targetMoney
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
$Trainer.cosmetics_money = targetMoney
# Final display text
goldwindow.text = _INTL(
"{1}:\n<ar>{2}</ar>",
COSMETIC_CURRENCY_NAME,
targetMoney.to_s_formatted
)
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
goldwindow.width = 160 if goldwindow.width <= 160
# Show final balance pause
20.times do
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
goldwindow.update
end
goldwindow.dispose
pbDisposeMessageWindow(msgwindow)
end
def promptCaughtPokemonAction(pokemon)
pickedOption = false
return pbStorePokemon(pokemon) if !$Trainer.party_full?
return promptKeepOrRelease(pokemon) if isOnPinkanIsland() && !$game_switches[SWITCH_PINKAN_FINISHED]
while !pickedOption
cmd_swap = _INTL("Add to your party")
cmd_fuse = _INTL("Fuse in party")
cmd_pc = _INTL("Store to PC")
options = []
options << cmd_swap
if !pokemon.isFusion? && playerHasFusionItems && hasUnfusedPokemonInParty(false)
options << cmd_fuse
end
options << cmd_pc
command = pbMessage(_INTL("\\ts[]Your team is full!"), options, options.length)
case options[command]
when cmd_swap
if swapCaughtPokemon(pokemon)
pickedOption = true
end
when cmd_fuse
if fuseCaughtPokemon(pokemon)
pickedOption = true
end
else
# STORE
pbStorePokemon(pokemon)
pickedOption = true
end
end
end
def promptKeepOrRelease(pokemon)
pickedOption = false
while !pickedOption
command = pbMessage(_INTL("\\ts[]Your team is full!"),
[_INTL("Release a party member"), _INTL("Release this {1}",pokemon.name),], 2)
case command
when 0 # SWAP
if swapReleaseCaughtPokemon(pokemon)
pickedOption = true
end
else
pickedOption = true
end
end
end
def fuseCaughtPokemon(caughtPokemon)
pbChoosePokemon(1, 2,
proc { |poke|
!poke.egg? &&
!(poke.isFusion? rescue false) &&
poke.hp > 0
})
partyPosition = pbGet(1)
return false if partyPosition == -1
splicerItem = selectSplicer()
return unless splicerItem
selected = $Trainer.party[partyPosition].clone
selectedHead, fusion_pif_sprite = selectFusion(caughtPokemon,selected)
return false unless selectedHead && fusion_pif_sprite
if (pbConfirmMessage(_INTL("Fuse the newly obtained {1} with {2}?", caughtPokemon.name, selected.name)))
if selectedHead == caughtPokemon
pbRemovePokemonAt(partyPosition)
pbAddPokemonSilent(caughtPokemon)
pbFuse(caughtPokemon, selected, splicerItem, fusion_pif_sprite)
else
actualPartyPokemon = $Trainer.party[partyPosition] # real reference, not clone
pbFuse(actualPartyPokemon, caughtPokemon, splicerItem, fusion_pif_sprite)
end
$PokemonBag.pbDeleteItem(splicerItem) if splicerItem == :DNASPLICERS || splicerItem == :SUPERSPLICERS
return true
end
return false
end
# def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false)
def swapCaughtPokemon(caughtPokemon)
pbChoosePokemon(1, 2,
proc { |poke|
!poke.egg? &&
!(poke.isShadow? rescue false)
})
index = pbGet(1)
return false if index == -1
$PokemonStorage.pbStoreCaught($Trainer.party[index])
pbRemovePokemonAt(index)
pbStorePokemon(caughtPokemon)
tmp = $Trainer.party[index]
$Trainer.party[index] = $Trainer.party[-1]
$Trainer.party[-1] = tmp
return true
end
def swapReleaseCaughtPokemon(caughtPokemon)
pbChoosePokemon(1, 2,
proc { |poke|
!poke.egg? &&
!(poke.isShadow? rescue false)
})
index = pbGet(1)
return false if index == -1
releasedPokemon = $Trainer.party[index]
pbMessage(_INTL("{1} was released.",releasedPokemon.name))
pbRemovePokemonAt(index)
pbStorePokemon(caughtPokemon)
tmp = $Trainer.party[index]
$Trainer.party[index] = $Trainer.party[-1]
$Trainer.party[-1] = tmp
return true
end
def select_any_pokemon()
commands = []
for dex_num in 1..NB_POKEMON
species = getPokemon(dex_num)
commands.push([dex_num - 1, species.real_name, species.id])
end
return pbChooseList(commands, 0, nil, 1)
end
# chosen pokemon is returned with this format:
#[[boxID, boxPosition],pokemon]
def pbChoosePokemonPC(positionVariableNumber, pokemonVarNumber, ableProc = nil)
chosen = nil
pokemon = nil
pbFadeOutIn {
scene = PokemonStorageScene.new
screen = PokemonStorageScreen.new(scene, $PokemonStorage)
screen.setFilter(ableProc) if ableProc
chosen = screen.choosePokemon
pokemon = $PokemonStorage[chosen[0]][chosen[1]] if chosen
scene.pbCloseBox
}
pbSet(positionVariableNumber, chosen)
pbSet(pokemonVarNumber, pokemon)
end
def set_player_birthday
date = selectDate(_INTL("Your birthday is on"))
$Trainer.birth_day = date.day
$Trainer.birth_month = date.month
end
def selectDate(confirm_text = _INTL("You chose "))
months_nb_days = {
:JANUARY => 31,
:FEBRUARY => 29,
:MARCH => 31,
:APRIL => 30,
:MAY => 31,
:JUNE => 30,
:JULY => 31,
:AUGUST => 31,
:SEPTEMBER => 30,
:OCTOBER => 31,
:NOVEMBER => 30,
:DECEMBER => 31,
}
month_names = {
:JANUARY => _INTL("January"),
:FEBRUARY => _INTL("February"),
:MARCH => _INTL("March"),
:APRIL => _INTL("April"),
:MAY => _INTL("May"),
:JUNE => _INTL("June"),
:JULY => _INTL("July"),
:AUGUST => _INTL("August"),
:SEPTEMBER => _INTL("September"),
:OCTOBER => _INTL("October"),
:NOVEMBER => _INTL("November"),
:DECEMBER => _INTL("December"),
}
pbMessage(_INTL("Which month?"))
selected = false
while !selected
chosen_month_index = optionsMenu(month_names.values)
month = month_names.keys[chosen_month_index]
nb_days = months_nb_days[month]
numberParams = ChooseNumberParams.new
numberParams.setRange(1,nb_days)
numberParams.setDefaultValue(1)
chosen_day = pbMessageChooseNumber(_INTL("Which day?"),numberParams)
chosen_month_name = month_names[month]
if pbConfirmMessage(_INTL("{1} \\C[1]{2} {3}\\C[0]. Is that correct?",confirm_text, chosen_month_name,chosen_day))
birthday = Time.new(2000,chosen_month_index+1,chosen_day)
return birthday
end
end
end
# Helper method to wrap text into multiple lines
def wrap_text(text, bitmap, max_width)
words = text.split(" ")
lines = []
line = ""
words.each do |word|
test_line = line.empty? ? word : "#{line} #{word}"
if bitmap.text_size(test_line).width > max_width
lines << line
line = word
else
line = test_line
end
end
lines << line unless line.empty?
return lines
end
def pbColor(color)
# Mix your own colors: http://www.rapidtables.com/web/color/RGB_Color.htm
return Color.new(0, 0, 0) if color == :BLACK
return Color.new(255, 255, 255) if color == :WHITE
return Color.new(255, 115, 115) if color == :LIGHTRED
return Color.new(245, 11, 11) if color == :RED
return Color.new(164, 3, 3) if color == :DARKRED
return Color.new(47, 46, 46) if color == :DARKGREY
return Color.new(47, 46, 46) if color == :DARKGREY
return Color.new(100, 92, 92) if color == :LIGHTGREY
return Color.new(226, 104, 250) if color == :PINK
return Color.new(243, 154, 154) if color == :PINKTWO
return Color.new(255, 160, 50) if color == :GOLD
return Color.new(255, 186, 107) if color == :LIGHTORANGE
return Color.new(95, 54, 6) if color == :BROWN
return Color.new(122, 76, 24) if color == :LIGHTBROWN
return Color.new(255, 246, 152) if color == :LIGHTYELLOW
return Color.new(242, 222, 42) if color == :YELLOW
return Color.new(80, 111, 6) if color == :DARKGREEN
return Color.new(154, 216, 8) if color == :GREEN
return Color.new(197, 252, 70) if color == :LIGHTGREEN
return Color.new(74, 146, 91) if color == :FADEDGREEN
return Color.new(6, 128, 92) if color == :DARKLIGHTBLUE
return Color.new(18, 235, 170) if color == :LIGHTBLUE
return Color.new(139, 247, 215) if color == :SUPERLIGHTBLUE
return Color.new(35, 203, 255) if color == :BLUE
return Color.new(3, 44, 114) if color == :DARKBLUE
return Color.new(7, 3, 114) if color == :SUPERDARKBLUE
return Color.new(63, 6, 121) if color == :DARKPURPLE
return Color.new(113, 16, 209) if color == :PURPLE
return Color.new(130, 50, 200) if color == :LIGHTPURPLE
return Color.new(219, 183, 37) if color == :ORANGE
return Color.new(255, 255, 255, 0) if color == :INVISIBLE
return MessageConfig::LIGHT_TEXT_MAIN_COLOR if color == :LIGHT_TEXT_MAIN_COLOR
return MessageConfig::LIGHT_TEXT_SHADOW_COLOR if color == :LIGHT_TEXT_SHADOW_COLOR
return MessageConfig::DARK_TEXT_MAIN_COLOR if color == :DARK_TEXT_MAIN_COLOR
return MessageConfig::DARK_TEXT_SHADOW_COLOR if color == :DARK_TEXT_SHADOW_COLOR
return Color.new(255, 255, 255)
end
def isDarkMode
return $Trainer&.pokenav&.darkMode
end
@@ -0,0 +1,219 @@
def unlock_easter_egg_hats()
if $Trainer.name.downcase == "ash"
$Trainer.hat = HAT_ASH
$Trainer.unlock_hat(HAT_ASH)
end
if $Trainer.name.downcase == "frogman"
$Trainer.hat = HAT_FROG
$Trainer.unlock_hat(HAT_FROG)
end
end
def getPlayerDefaultName(gender)
if gender == GENDER_MALE
return Settings::GAME_ID == :IF_HOENN ? pbGetMessageFromHash(MessageTypes::TrainerNames, "Brendan") : _INTL("Red")
else
return Settings::GAME_ID == :IF_HOENN ? pbGetMessageFromHash(MessageTypes::TrainerNames, "May") : _INTL("Green")
end
end
def getDefaultClothes(gender)
if gender == GENDER_MALE
return Settings::GAME_ID == :IF_HOENN ? CLOTHES_BRENDAN : DEFAULT_OUTFIT_MALE
else
return Settings::GAME_ID == :IF_HOENN ? CLOTHES_MAY : DEFAULT_OUTFIT_FEMALE
end
end
def getDefaultHat(gender=getPlayerGenderId())
if gender == GENDER_MALE
return Settings::GAME_ID == :IF_HOENN ? HAT_BRENDAN : DEFAULT_OUTFIT_MALE
else
return Settings::GAME_ID == :IF_HOENN ? HAT_MAY : DEFAULT_OUTFIT_FEMALE
end
end
def getDefaultHair(gender)
if gender == GENDER_MALE
return Settings::GAME_ID == :IF_HOENN ? HAIR_BRENDAN : DEFAULT_OUTFIT_MALE
else
return Settings::GAME_ID == :IF_HOENN ? HAIR_MAY : DEFAULT_OUTFIT_FEMALE
end
end
def setupStartingOutfit()
default_clothes_male = getDefaultClothes(GENDER_MALE)
default_clothes_female = getDefaultClothes(GENDER_FEMALE)
default_hat_male = getDefaultHat(GENDER_MALE)
default_hat_female = getDefaultHat(GENDER_FEMALE)
default_hair_male = getDefaultHair(GENDER_MALE)
default_hair_female = getDefaultHair(GENDER_FEMALE)
unlock_easter_egg_hats()
gender = pbGet(VAR_TRAINER_GENDER)
if gender == GENDER_FEMALE
$Trainer.unlock_clothes(default_clothes_female, true)
$Trainer.unlock_hat(default_hat_female, true) unless Settings::HOENN
$Trainer.hair = "3_" + default_hair_female if !$Trainer.hair # when migrating old savefiles
$Trainer.clothes = default_clothes_female
elsif gender == GENDER_MALE
$Trainer.unlock_clothes(default_clothes_male, true)
$Trainer.unlock_hat(default_hat_male, true) unless Settings::HOENN
$Trainer.hair = ("3_" + default_hair_male) if !$Trainer.hair # when migrating old savefiles
$Trainer.clothes = default_clothes_male
end
$Trainer.unlock_hair(default_hair_male, true)
$Trainer.unlock_hair(default_hair_female, true)
$Trainer.unlock_clothes(STARTING_OUTFIT, true)
$Trainer.hat = nil
if Settings::KANTO
$Trainer.clothes = STARTING_OUTFIT
end
end
def give_date_specific_hats()
current_date = Time.new
# Christmas
if (current_date.day == 24 || current_date.day == 25) && current_date.month == 12
if !$Trainer.unlocked_hats.include?(HAT_SANTA)
pbCallBub(2, @event_id, true)
pbMessage(_INTL("Hi! We're giving out a special hat today for the holidays season. Enjoy!"))
obtainHat(HAT_SANTA)
end
end
# April's fool
if (current_date.day == 1 && current_date.month == 4)
if !$Trainer.unlocked_hats.include?(HAT_CLOWN)
pbCallBub(2, @event_id, true)
pbMessage(_INTL("Hi! We're giving out this fun accessory for this special day. Enjoy!"))
obtainHat(HAT_CLOWN)
end
end
end
def check_obtain_hat_after_battle(species)
hat_chance = 1
if rand(1..100) <= hat_chance
hat = getHatForPokemon(species)
if hat
obtainHat(hat)
end
end
end
def qmarkMaskCheck()
if $Trainer.seen_qmarks_sprite
unless hasHat?(HAT_QMARKS)
obtainHat(HAT_QMARKS)
obtainClothes(CLOTHES_GLITCH)
end
end
end
def purchaseDyeKitMenu(hats_kit_price = 0, clothes_kit_price = 0)
commands = []
command_hats = _INTL("Hats Dye Kit (${1})",hats_kit_price)
command_clothes = _INTL("Clothes Dye Kit (${1})",clothes_kit_price)
command_cancel = _INTL("Cancel")
commands << command_hats if !$PokemonBag.pbHasItem?(:HATSDYEKIT)
commands << command_clothes if !$PokemonBag.pbHasItem?(:CLOTHESDYEKIT)
commands << command_cancel
if commands.length <= 1
pbCallBub(2, @event_id)
pbMessage(_INTL("\\C[1]Dye Kits\\C[0] can be used to dye clothes all sorts of colours!"))
pbCallBub(2, @event_id)
pbMessage(_INTL("You can use them at any time when you change clothes."))
return
end
pbCallBub(2, @event_id)
pbMessage(_INTL("Welcome! Are you interested in dyeing your outfits different colors?"))
pbCallBub(2, @event_id)
pbMessage(_INTL("I make handy \\C[1]Dye Kits\\C[0] from my Smeargle's paint that can be used to dye your outfits any color you want!"))
pbCallBub(2, @event_id)
pbMessage(_INTL("What's more is that it's reusable, so you can go completely wild with it if you want! Are you interested?"))
msgwindow = pbCreateMessageWindow(nil)
pbMessageDisplay(msgwindow, _INTL("Which dye kit would you like to purchase?"))
if Settings::HOENN
money = $Trainer.cosmetics_money
goldwindow = pbDisplayCosmeticsMoneyWindow(msgwindow,300)
else
money = $Trainer.money
goldwindow = pbDisplayGoldWindow(msgwindow,300)
end
choice = optionsMenu(commands, commands.length)
case commands[choice]
when command_hats
if money < hats_kit_price
pbCallBub(2, @event_id)
pbMessage(_INTL("Oh, you don't have enough money..."))
goldwindow.dispose
return
end
purchaseWindowAnimation(hats_kit_price,msgwindow,goldwindow)
Kernel.pbReceiveItem(:HATSDYEKIT)
pbCallBub(2, @event_id)
pbMessage(_INTL("Here you go! Have fun dyeing your hats!"))
when command_clothes
if money < clothes_kit_price
pbCallBub(2, @event_id)
pbMessage(_INTL("Oh, you don't have enough money..."))
goldwindow.dispose
return
end
#pbMessage(_INTL("\\PN purchased the dye kit."))
purchaseWindowAnimation(clothes_kit_price,msgwindow,goldwindow)
Kernel.pbReceiveItem(:CLOTHESDYEKIT)
pbCallBub(2, @event_id)
pbMessage(_INTL("Here you go! Have fun dyeing your clothes!"))
end
pbCallBub(2, @event_id)
pbMessage(_INTL("You can use \\C[1]Dye Kits\\C[0] at any time when you change clothes."))
msgwindow.dispose
goldwindow.dispose
end
def purchaseWindowAnimation(price, msgwindow,goldwindow)
if Settings::HOENN
pbSpendCosmeticMoney(price,false,msgwindow,goldwindow)
else
pbSpendMoney(price,false,msgwindow,goldwindow)
end
msgwindow.dispose
goldwindow.dispose
end
def get_hat_contest_tags(hat_id)
hat = $PokemonGlobal.hats_data[hat_id]
return hat&.contest_condition
end
def get_clothes_contest_tags(clothes_id)
clothes = $PokemonGlobal.clothes_data[clothes_id]
return clothes&.contest_condition
end
def isWearingTeamAquaOutfit()
return false if !$game_switches[SWITCH_JOINED_TEAM_AQUA]
return isWearingClothes(CLOTHES_TEAM_AQUA_F) || isWearingClothes(CLOTHES_TEAM_AQUA_M)
end
def isWearingTeamMagmaOutfit()
return false if !$game_switches[SWITCH_JOINED_TEAM_MAGMA]
return isWearingClothes(CLOTHES_TEAM_MAGMA_M) || isWearingClothes(CLOTHES_TEAM_MAGMA_F)
end
@@ -0,0 +1,408 @@
def pbAddPokemonID(pokemon_id, level = 1, see_form = true, skip_randomize = false)
return false if !pokemon_id
skip_randomize = true if $game_switches[SWITCH_CHOOSING_STARTER] # when choosing starters
skip_randomize = true if $game_switches[SWITCH_DONT_RANDOMIZE]
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
if pokemon_id.is_a?(Integer) && level.is_a?(Integer)
pokemon = Pokemon.new(pokemon_id, level)
species_name = pokemon.speciesName
end
# random species if randomized gift pokemon & wild poke
if $game_switches[SWITCH_RANDOM_GIFT_POKEMON] && $game_switches[SWITCH_RANDOM_WILD] && !skip_randomize
tryRandomizeGiftPokemon(pokemon, skip_randomize)
end
pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name))
pbNicknameAndStore(pokemon)
$Trainer.pokedex.register(pokemon) if see_form
return true
end
def pbHasSpecies?(species)
if species.is_a?(String) || species.is_a?(Symbol)
id = getID(PBSpecies, species)
elsif species.is_a?(Pokemon)
id = species.dexNum
end
for pokemon in $Trainer.party
next if pokemon.isEgg?
return true if pokemon.dexNum == id
end
return false
end
def getID(pbspecies_unused, species)
if species.is_a?(String)
return nil
elsif species.is_a?(Symbol)
return GameData::Species.get(species).id_number
elsif species.is_a?(Pokemon)
id = species.dexNum
end
end
# Check if the Pokemon can learn a TM
def CanLearnMove(pokemon, move)
species = getID(PBSpecies, pokemon)
return false if species <= 0
data = load_data("Data/tm.dat")
return false if !data[move]
return data[move].any? { |item| item == species }
end
def getPokemon(dexNum)
if dexNum.is_a?(Integer)
if dexNum > NB_POKEMON
body_id = getBodyID(dexNum)
head_id = getHeadID(dexNum, body_id)
pokemon_id = getFusedPokemonIdFromDexNum(body_id, head_id)
else
pokemon_id = dexNum
end
else
pokemon_id = dexNum
end
return GameData::Species.get(pokemon_id)
end
def getSpecies(dexnum)
return getPokemon(dexnum.species) if dexnum.is_a?(Pokemon)
return getPokemon(dexnum)
end
def getAbilityIndexFromID(abilityID, fusedPokemon)
abilityList = fusedPokemon.getAbilityList
for abilityArray in abilityList #ex: [:CHLOROPHYLL, 0]
ability = abilityArray[0]
index = abilityArray[1]
return index if ability == abilityID
end
return 0
end
def getPokemonEggGroups(species)
return GameData::Species.get(species).egg_groups
end
def getAllNonLegendaryPokemon()
list = []
for i in 1..143
list.push(i)
end
for i in 147..149
list.push(i)
end
for i in 152..242
list.push(i)
end
list.push(246)
list.push(247)
list.push(248)
for i in 252..314
list.push(i)
end
for i in 316..339
list.push(i)
end
for i in 352..377
list.push(i)
end
for i in 382..420
list.push(i)
end
return list
end
def isInKantoGeneration(dexNumber)
return dexNumber <= 151
end
def isKantoPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
return isInKantoGeneration(dexNum) || isInKantoGeneration(head_dex) || isInKantoGeneration(body_dex)
end
def isInJohtoGeneration(dexNumber)
return dexNumber > 151 && dexNumber <= 251
end
def isJohtoPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
return isInJohtoGeneration(dexNum) || isInJohtoGeneration(head_dex) || isInJohtoGeneration(body_dex)
end
def isAlolaPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
list = [
370, 373, 430, 431, 432, 433, 450, 451, 452,
453, 454, 455, 459, 460, 463, 464, 465, 469, 470,
471, 472, 473, 474, 475, 476, 477, 498, 499,
]
return list.include?(dexNum) || list.include?(head_dex) || list.include?(body_dex)
end
def isKalosPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
list =
[327, 328, 329, 339, 371, 372, 417, 418,
425, 426, 438, 439, 440, 441, 444, 445, 446,
456, 461, 462, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487,
489, 490, 491, 492, 500, 571, 572,
]
return list.include?(dexNum) || list.include?(head_dex) || list.include?(body_dex)
end
def isUnovaPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
list =
[
330, 331, 337, 338, 348, 349, 350, 351, 359, 360, 361,
362, 363, 364, 365, 366, 367, 368, 369, 374, 375, 376, 377,
397, 398, 399, 406, 407, 408, 409, 410, 411, 412, 413, 414,
415, 416, 419, 420,
422, 423, 424, 434, 435,
466, 467, 494, 493,
566, 567, 568, 569,570,
]
return list.include?(dexNum) || list.include?(head_dex) || list.include?(body_dex)
end
def isSinnohPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
list =
[254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 288, 294,
295, 296, 297, 298, 299, 305, 306, 307, 308, 315, 316, 317,
318, 319, 320, 321, 322, 323, 324, 326, 332, 343, 344, 345,
346, 347, 352, 353, 354, 358, 383, 384, 388, 389, 400, 402,
403, 429, 468, 573, 574, 575, 576]
return list.include?(dexNum) || list.include?(head_dex) || list.include?(body_dex)
end
def isHoennPokemon(species)
dexNum = getDexNumberForSpecies(species)
poke = getPokemon(species)
head_dex = getDexNumberForSpecies(poke.get_head_species())
body_dex = getDexNumberForSpecies(poke.get_body_species())
list = [252, 253, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 289, 290, 291, 292, 293, 300, 301, 302, 303,
304, 309, 310, 311, 312, 313, 314, 325, 333, 334, 335, 336, 340,
341, 342, 355, 356, 357, 378, 379, 380, 381, 382, 385, 386,
387, 390, 391, 392, 393, 394, 395, 396, 401, 404, 405, 421,
427, 428, 436, 437, 442, 443, 447, 448, 449, 457, 458, 488,
495, 496, 497, 501, 502, 503, 504, 505, 506, 507, 508, 509,
510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521,
522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533,
534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545,
546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557,
558, 559, 560, 561, 562, 563, 564, 565
]
return list.include?(dexNum) || list.include?(head_dex) || list.include?(body_dex)
end
def get_default_moves_at_level(species, level)
moveset = GameData::Species.get(species).moves
knowable_moves = []
moveset.each { |m| knowable_moves.push(m[1]) if m[0] <= level }
# Remove duplicates (retaining the latest copy of each move)
knowable_moves = knowable_moves.reverse
knowable_moves |= []
knowable_moves = knowable_moves.reverse
# Add all moves
moves = []
first_move_index = knowable_moves.length - MAX_MOVES
first_move_index = 0 if first_move_index < 0
for i in first_move_index...knowable_moves.length
#moves.push(Pokemon::Move.new(knowable_moves[i]))
moves << knowable_moves[i]
end
return moves
end
def listPokemonIDs()
for id in 0..NB_POKEMON
pokemon = GameData::Species.get(id).species
echoln id.to_s + ": " + "\"" + pokemon.to_s + "\"" + ", "
end
end
#IMPORTANT
#La méthode def pbCheckEvolution(pokemon,item=0)
#dans PokemonFusion (class PokemonFusionScene)
#a été modifiée et pour une raison ou une autre ca marche
#pas quand on la copie ici.
#Donc NE PAS OUBLIER DE LE COPIER AVEC
def isPartPokemon(src, target)
return Kernel.isPartPokemon(src, target)
end
#in: pokemon number
def Kernel.isPartPokemon(src, target)
src = getDexNumberForSpecies(src)
target = getDexNumberForSpecies(target)
return true if src == target
return false if src <= NB_POKEMON
bod = getBasePokemonID(src, true)
head = getBasePokemonID(src, false)
return bod == target || head == target
end
##EDITED HERE
#Retourne le pokemon de base
#param1 = int
#param2 = true pour body, false pour head
#return int du pokemon de base
def getBasePokemonID(pokemon, body = true)
if pokemon.is_a?(Symbol)
dex_number = GameData::Species.get(pokemon).id_number
pokemon = dex_number
end
return nil if pokemon <= 0
return nil if pokemon >= Settings::ZAPMOLCUNO_NB
# cname = getConstantName(PBSpecies, pokemon) rescue nil
cname = GameData::Species.get(pokemon).id.to_s
return pokemon if pokemon <= NB_POKEMON
return pokemon if cname == nil
arr = cname.split(/[B,H]/)
bod = arr[1]
head = arr[2]
return bod.to_i if body
return head.to_i
end
def getGenericPokemonCryText(dex_number)
return unless dex_number.is_a?(Integer)
case dex_number
when 25
return "Pika!"
when 16, 17, 18, 21, 22, 144, 145, 146, 227, 417, 418, 372 # birds
return "Squawk!"
when 163, 164
return "Hoot!" # owl
else
return "Guaugh!"
end
end
def setPokemonMoves(pokemon, move_ids = [])
moves = []
move_ids.each { |move_id|
moves << Pokemon::Move.new(move_id)
}
pokemon.moves = moves
end
def changeSpeciesSpecific(pokemon, newSpecies)
pokemon.species = newSpecies
$Trainer.pokedex.set_seen(newSpecies)
$Trainer.pokedex.set_owned(newSpecies)
end
def calculate_pokemon_weight(pokemon, nerf = 0)
base_weight = pokemon.weight
ivs = []
pokemon.iv.each { |iv|
ivs << iv[1]
}
level = pokemon.level
# Ensure IVs is an array of 6 values and level is between 1 and 100
raise "IVs array must have 6 values" if ivs.length != 6
raise "Level must be between 1 and 100" unless (1..100).include?(level)
# Calculate the IV Factor
iv_sum = ivs.sum
iv_factor = (iv_sum.to_f / 186) * 30 * 10
# Calculate the Level Factor
level_factor = (level.to_f / 100) * 5 * 10
# Calculate the weight
weight = base_weight * (1 + (iv_factor / 100) + (level_factor / 100))
weight -= base_weight
# Enforce the weight variation limits
max_weight = base_weight * 4.00 # 400% increase
min_weight = base_weight * 0.5 # 50% decrease
# Cap the weight between min and max values
weight = [[weight, min_weight].max, max_weight].min
weight -= nerf if weight - nerf > min_weight
return weight.round(2) # Round to 2 decimal places
end
def playCry(pokemonSpeciesSymbol)
species = GameData::Species.get(pokemonSpeciesSymbol).species
GameData::Species.play_cry_from_species(species)
end
def getHiddenPowerName(pokemon)
hiddenpower = pbHiddenPower(pokemon)
hiddenPowerType = hiddenpower[0]
echoln hiddenPowerType
if Settings::TRIPLE_TYPES.include?(hiddenPowerType)
return _INTL("Neutral")
end
return PBTypes.getName(hiddenPowerType)
end
def has_species_or_fusion?(species, form = -1)
return $Trainer.pokemon_party.any? { |p| p && p.isSpecies?(species) || p.isFusionOf(species) }
end
def delete_party_pokemon_multi(indexes=[],safe=true)
indexes.sort.reverse_each do |i|
echoln "Deleting #{$Trainer.party[i].name} (index #{i})"
if safe
$Trainer.remove_pokemon_at_index(i)
else
#Doesn't check if the player has at least 1 pokemon left
$Trainer.party.delete_at(i)
end
end
end
def format_pokemon_names(species_list=[])
names_list = []
species_list.each do |species|
species_data = GameData::Species.get(species)
names_list << species_data.name
end
return names_list.join(", ")
end
@@ -0,0 +1,278 @@
###################
## CONVERTER #
###################
def convertAllPokemon()
Kernel.pbMessage(_INTL("The game has detected that your previous savefile was from an earlier build of the game."))
Kernel.pbMessage(_INTL("In order to play this version, your Pokémon need to be converted to their new Pokédex numbers. "))
Kernel.pbMessage(_INTL("If you were playing Randomized mode, the trainers and wild Pokémon will also need to be reshuffled."))
if (Kernel.pbConfirmMessage(_INTL("Convert your Pokémon?")))
#get previous version
msgwindow = Kernel.pbCreateMessageWindow(nil)
msgwindow.text = _INTL("What is the last version of the game you played?")
choice = Kernel.pbShowCommands(msgwindow, [
_INTL("4.7 (September 2020)"),
_INTL("4.5-4.6.2 (2019-2020)"),
_INTL("4.2-4.4 (2019)"),
_INTL("4.0-4.1 (2018-2019)"),
_INTL("3.x or earlier (2015-2018)")], -1)
case choice
when 0
prev_total = 381
when 1
prev_total = 351
when 2
prev_total = 315
when 3
prev_total = 275
when 4
prev_total = 151
else
prev_total = 381
end
Kernel.pbDisposeMessageWindow(msgwindow)
pbEachPokemon { |poke, box|
if poke.species >= NB_POKEMON
pf = poke.species
pBody = (pf / prev_total).round
pHead = pf - (prev_total * pBody)
# Kernel.pbMessage("pbod {1} pHead {2}, species: {3})",pBody,pHead,pf)
prev_max_value = (prev_total * prev_total) + prev_total
if pf >= prev_max_value
newSpecies = convertTripleFusion(pf, prev_max_value)
if newSpecies == nil
boxname = box == -1 ? "Party" : box
Kernel.pbMessage(_INTL("Invalid Pokémon detected in box {1}:\n num. {2}, {3} (lv. {4})", boxname, pf, poke.name, poke.level))
if (Kernel.pbConfirmMessage(_INTL("Delete Pokémon and continue?")))
poke = nil
next
else
Kernel.pbMessage(_INTL("Conversion cancelled. Please restart the game."))
Graphics.freeze
end
end
end
newSpecies = pBody * NB_POKEMON + pHead
poke.species = newSpecies
end
}
Kernel.initRandomTypeArray()
if $game_switches[SWITCH_RANDOM_TRAINERS] #randomized trainers
Kernel.pbShuffleTrainers()
end
if $game_switches[956] #randomized pokemon
range = pbGet(197) == nil ? 25 : pbGet(197)
Kernel.pbShuffleDex(range, 1)
end
end
end
def convertTripleFusion(species, prev_max_value)
if prev_max_value == (351 * 351) + 351
case species
when 123553
return 145543
when 123554
return 145544
when 123555
return 145545
when 123556
return 145546
when 123557
return 145547
when 123558
return 145548
else
return nil
end
end
return nil
end
def convertTrainers()
if ($game_switches[SWITCH_RANDOM_TRAINERS])
Kernel.pbShuffleTrainers()
end
end
def convertAllPokemonManually()
if (Kernel.pbConfirmMessage(_INTL("When you last played the game, where there any gen 2 Pokémon?")))
#4.0
prev_total = 315
else
#3.0
prev_total = 151
end
convertPokemon(prev_total)
end
def convertPokemon(prev_total = 275)
pbEachPokemon { |poke, box|
if poke.species >= NB_POKEMON
pf = poke.species
pBody = (pf / prev_total).round
pHead = pf - (prev_total * pBody)
newSpecies = pBody * NB_POKEMON + pHead
poke.species = newSpecies
end
}
end
def fixMissedHMs()
# Flash
if $PokemonBag.pbQuantity(:HM08) < 1 && $PokemonGlobal.questRewardsObtained.include?(:HM08)
pbReceiveItem(:HM08)
end
# Cut
if $PokemonBag.pbQuantity(:HM01) < 1 && $game_switches[SWITCH_SS_ANNE_DEPARTED]
pbReceiveItem(:HM01)
end
# Strength
if $PokemonBag.pbQuantity(:HM04) < 1 && $game_switches[SWITCH_SNORLAX_GONE_ROUTE_12]
pbReceiveItem(:HM04)
end
# Surf
if $PokemonBag.pbQuantity(:HM03) < 1 && $game_self_switches[[107, 1, "A"]]
pbReceiveItem(:HM03)
end
# Teleport
if $PokemonBag.pbQuantity(:HM07) < 1 && $game_switches[SWITCH_TELEPORT_NPC]
pbReceiveItem(:HM07)
end
# Fly
if $PokemonBag.pbQuantity(:HM02) < 1 && $game_self_switches[[439, 1, "B"]]
pbReceiveItem(:HM02)
end
# Waterfall
if $PokemonBag.pbQuantity(:HM05) < 1 && $game_switches[SWITCH_GOT_WATERFALL]
pbReceiveItem(:HM05)
end
# Dive
if $PokemonBag.pbQuantity(:HM06) < 1 && $game_switches[SWITCH_GOT_DIVE]
pbReceiveItem(:HM06)
end
# Rock Climb
if $PokemonBag.pbQuantity(:HM10) < 1 && $game_switches[SWITCH_GOT_ROCK_CLIMB]
pbReceiveItem(:HM10)
end
end
def fixFinishedRocketQuests()
fix_broken_TR_quests()
var_tr_missions_cerulean = 288
switch_tr_mission_cerulean_4 = 1116
switch_tr_mission_celadon_1 = 1084
switch_tr_mission_celadon_2 = 1086
switch_tr_mission_celadon_3 = 1088
switch_tr_mission_celadon_4 = 1110
switch_pinkan_done = 1119
nb_cerulean_missions = pbGet(var_tr_missions_cerulean)
finishTRQuest("tr_cerulean_1", :SUCCESS, true) if nb_cerulean_missions >= 1 && !pbCompletedQuest?("tr_cerulean_1")
echoln pbCompletedQuest?("tr_cerulean_1")
finishTRQuest("tr_cerulean_2", :SUCCESS, true) if nb_cerulean_missions >= 2 && !pbCompletedQuest?("tr_cerulean_2")
finishTRQuest("tr_cerulean_3", :SUCCESS, true) if nb_cerulean_missions >= 3 && !pbCompletedQuest?("tr_cerulean_3")
finishTRQuest("tr_cerulean_4", :SUCCESS, true) if $game_switches[switch_tr_mission_cerulean_4] && !pbCompletedQuest?("tr_cerulean_4")
finishTRQuest("tr_celadon_1", :SUCCESS, true) if $game_switches[switch_tr_mission_celadon_1] && !pbCompletedQuest?("tr_celadon_1")
finishTRQuest("tr_celadon_2", :SUCCESS, true) if $game_switches[switch_tr_mission_celadon_2] && !pbCompletedQuest?("tr_celadon_2")
finishTRQuest("tr_celadon_3", :SUCCESS, true) if $game_switches[switch_tr_mission_celadon_3] && !pbCompletedQuest?("tr_celadon_3")
finishTRQuest("tr_celadon_4", :SUCCESS, true) if $game_switches[switch_tr_mission_celadon_4] && !pbCompletedQuest?("tr_celadon_4")
finishTRQuest("tr_pinkan", :SUCCESS, true) if $game_switches[switch_pinkan_done] && !pbCompletedQuest?("tr_pinkan")
end
def fix_broken_TR_quests()
for trainer_quest in $Trainer.quests
if trainer_quest.id == 0 # tr quests were all set to ID 0 instead of their real ID in v 6.4.0
for rocket_quest_id in TR_QUESTS.keys
rocket_quest = TR_QUESTS[rocket_quest_id]
next if !rocket_quest
if trainer_quest.name == rocket_quest.name
trainer_quest.id = rocket_quest_id
end
end
end
end
end
def fix_missing_infinite_splicers
return unless Settings::KANTO
obtained_infinite_splicers = $game_switches[275]
obtained_upgraded_infinite_splicers = $game_self_switches[[703,4,"A"]]
if obtained_infinite_splicers && pbQuantity(:INFINITESPLICERS) <= 0 && pbQuantity(:INFINITESPLICERS2) <= 0
pbReceiveItem(:INFINITESPLICERS)
end
if obtained_upgraded_infinite_splicers && pbQuantity(:INFINITESPLICERS2) <= 0
pbReceiveItem(:INFINITESPLICERS2)
end
end
#Called from the fix game npc common event.
# Would be nice to migrate all the stuff in there over here
SWITCH_HOENN_GOT_POKEBALLS = 2018
SWITCH_HOENN_BEAT_RIVAL_RT_110 = 2116
def fixStuff
if Settings::HOENN
if $game_switches[SWITCH_HOENN_GOT_POKEBALLS]
$Trainer.install_app(:QUESTS) unless $Trainer.pokenav.has_app(:QUESTS)
$Trainer.install_app(:MAP) unless $Trainer.pokenav.has_app(:MAP)
$Trainer.install_app(:DAYNIGHT) unless $Trainer.pokenav.has_app(:DAYNIGHT)
$Trainer.install_app(:REARRANGE) unless $Trainer.pokenav.has_app(:REARRANGE)
$Trainer.install_app(:CONTACTS) unless $Trainer.pokenav.has_app(:CONTACTS)
end
if $game_switches[SWITCH_HOENN_BEAT_RIVAL_RT_110]
$Trainer.install_app(:POKERADAR) unless $Trainer.pokenav.has_app(:POKERADAR)
end
if $game_variables[1033].is_a?(String) #graffiti/trick house variable mixup
$game_variables[1033] = 0
end
end
$PokemonGlobal.sliding=false
$game_player.walk_anime=true
$game_player.direction_fix=false
PokemonSelection.restore
$game_system.menu_disabled=false
clear_all_images
Kernel.initRandomTypeArray
#fixMissedHMs
# todo: make a hoenn version of missed HMs
$game_switches[SWITCH_CANNOT_CATCH_POKEMON] = false
$game_switches[SWITCH_AQUA_CAMP] = false
restoreDefaultCharacterSprite
Graphics.update
Input.update
pbUpdateSceneMap
end
@@ -0,0 +1,214 @@
def splitSpriteCredits(name, bitmap, max_width)
return [name] if bitmap.text_size(name).width <= max_width
parts = name.split(" & ")
lines = []
parts.each_with_index do |part, i|
segment = part
segment += " &" if i < parts.length - 1 # keep & with the left segment
# If this segment fits, just add it
if bitmap.text_size(segment).width <= max_width
lines << segment
next
end
# Otherwise split inside the segment
current = segment.dup
while bitmap.text_size(current).width > max_width
# Try to break at last space within limit
break_pos = nil
j = 0
while j = current.index(" ", j)
if bitmap.text_size(current[0, j]).width <= max_width
break_pos = j
else
break
end
j += 1
end
if break_pos
# split at last valid space
lines << current[0, break_pos].strip
current = current[break_pos + 1..].strip
else
# no spaces at all: hard split by characters
# find max chars that fit
k = current.length - 1
k -= 1 while bitmap.text_size(current[0, k]).width > max_width
lines << current[0, k]
current = current[k..].strip
end
end
lines << current unless current.empty?
end
lines
end
def pbLoadPokemonBitmapSpecies(pokemon, species, back = false, scale = POKEMONSPRITESCALE)
ret = nil
pokemon = pokemon.pokemon if pokemon.respond_to?(:pokemon)
if pokemon.isEgg?
bitmapFileName = getEggBitmapPath(pokemon)
bitmapFileName = pbResolveBitmap(bitmapFileName)
elsif pokemon.species >= ZAPMOLCUNO_NB #zapmolcuno
bitmapFileName = getSpecialSpriteName(pokemon.species) #sprintf("Graphics/Battlers/special/144.145.146")
bitmapFileName = pbResolveBitmap(bitmapFileName)
else
#edited here
isFusion = species > NB_POKEMON
if isFusion
poke1 = getBodyID(species)
poke2 = getHeadID(species, poke1)
else
poke1 = species
poke2 = species
end
bitmapFileName = GetSpritePath(poke1, poke2, isFusion)
# Alter bitmap if supported
alterBitmap = (MultipleForms.getFunction(species, "alterBitmap") rescue nil)
end
if bitmapFileName && alterBitmap
animatedBitmap = AnimatedBitmap.new(bitmapFileName)
copiedBitmap = animatedBitmap.copy
animatedBitmap.dispose
copiedBitmap.each { |bitmap| alterBitmap.call(pokemon, bitmap) }
ret = copiedBitmap
elsif bitmapFileName
ret = AnimatedBitmap.new(bitmapFileName)
end
return ret
end
def pbPokemonBitmapFile(species)
# Used by the Pokédex
# Load normal bitmap
#get body and head num
isFused = species > NB_POKEMON
if isFused
if species >= ZAPMOLCUNO_NB
path = getSpecialSpriteName(species) + ".png"
else
poke1 = getBodyID(species) #getBasePokemonID(species,true)
poke2 = getHeadID(species, poke1) #getBasePokemonID(species,false)
path = GetSpritePath(poke1, poke2, isFused)
end
else
path = GetSpritePath(species, species, false)
end
ret = sprintf(path) rescue nil
if !pbResolveBitmap(ret)
ret = "Graphics/Battlers/000.png"
end
return ret
end
def pbLoadPokemonBitmap(pokemon, species, back = false)
#species est utilisé par elitebattle mais ca sert a rien
return pbLoadPokemonBitmapSpecies(pokemon, pokemon.species, back)
end
def getEggBitmapPath(pokemon)
return "Graphics/Battlers/Eggs/000" if $PokemonSystem.hide_custom_eggs
bitmapFileName = sprintf("Graphics/Battlers/Eggs/%s", getConstantName(PBSpecies, pokemon.species)) rescue nil
if !pbResolveBitmap(bitmapFileName)
if pokemon.species >= NUM_ZAPMOLCUNO
bitmapFileName = "Graphics/Battlers/Eggs/egg_base"
else
bitmapFileName = sprintf("Graphics/Battlers/Eggs/%03d", pokemon.species)
if !pbResolveBitmap(bitmapFileName)
bitmapFileName = sprintf("Graphics/Battlers/Eggs/000")
end
end
end
return bitmapFileName
end
def GetSpritePath(poke1, poke2, isFused)
#Check if custom exists
spritename = GetSpriteName(poke1, poke2, isFused)
pathCustom = sprintf("Graphics/%s/indexed/%s/%s.png", DOSSIERCUSTOMSPRITES,poke2, spritename)
pathReg = sprintf("Graphics/%s/%s/%s.png", BATTLERSPATH, poke2, spritename)
path = pbResolveBitmap(pathCustom) && $game_variables[196] == 0 ? pathCustom : pathReg
return path
end
def GetSpritePathForced(poke1, poke2, isFused)
#Check if custom exists
spritename = GetSpriteName(poke1, poke2, isFused)
pathCustom = sprintf("Graphics/%s/indexed/%s/%s.png", DOSSIERCUSTOMSPRITES, poke2, spritename)
pathReg = sprintf("Graphics/%s/%s/%s.png", BATTLERSPATH, poke2, spritename)
path = pbResolveBitmap(pathCustom) ? pathCustom : pathReg
return path
end
def GetSpriteName(poke1, poke2, isFused)
ret = isFused ? sprintf("%d.%d", poke2, poke1) : sprintf("%d", poke2) rescue nil
return ret
end
def initialize_species_blacklist(species)
black_list = []
main_sprite_letters = list_main_sprites_letters_species(species)
unless $PokemonSystem.include_alt_sprites_in_random
@available.each_with_index do |pif_sprite, index|
alt_letter = pif_sprite.alt_letter
unless main_sprite_letters.include?(@available[index].alt_letter)
black_list << alt_letter
end
end
end
$PokemonSystem.sprites_blacklist[species] = black_list
return black_list
end
def export_sprites_blacklist
export_file_name = "Data/sprites/sprite_preferences.json"
return unless $PokemonSystem.sprites_blacklist
json =JSON.generate(sanitize_string($PokemonSystem.sprites_blacklist))
File.write(export_file_name, json)
pbMessage(_INTL("Your sprites settings were exported to #{export_file_name}.",))
pbMessage(_INTL("You can share this file with your friends to have them use the same sprites preferences as you."))
pbMessage(_INTL("Place this it in their Data/sprites folder and talk to the Update Man NPC to import them in their game.",))
end
def import_sprites_blacklist
export_file_name = "Data/sprites/sprite_preferences.json"
if File.exist?(export_file_name)
json = File.read(export_file_name)
new_settings = JSON.parse(json)
if $PokemonSystem.sprites_blacklist && !$PokemonSystem.sprites_blacklist.empty?
pbMessage(_INTL("You already have some sprite preferences defined."))
pbMessage(_INTL("Would you like to merge your existing settings with the ones you're importing and completely replace them?",-1))
cmd_merge = _INTL("Merge")
cmd_replace = _INTL("Replace")
cmd_cancel = _INTL("Cancel")
options = [cmd_merge, cmd_replace, cmd_cancel]
choice = optionsMenu(options,-1)
case options[choice]
when cmd_merge
$PokemonSystem.sprites_blacklist = $PokemonSystem.sprites_blacklist.merge(new_settings) do |key, old_arr, new_arr|
(old_arr + new_arr).uniq
end
pbMessage(_INTL("Your sprite settings have been merged! Make sure to save the game."))
when cmd_replace
$PokemonSystem.sprites_blacklist = new_settings
pbMessage(_INTL("Your sprite settings have been replaced! Make sure to save the game."))
end
end
else
pbMessage(_INTL("The game couldn't find a \"sprite_preferences.json\" file in the Data/sprites folder."))
pbMessage(_INTL("Export the sprites settings from the Update Man NPC and place the file in this folder to import them."))
end
#$PokemonSystem.sprites_blacklist = JSON.parse(json)
end
@@ -0,0 +1,130 @@
def pbGetSelfSwitch(eventId, switch)
return $game_self_switches[[@map_id, eventId, switch]]
end
def find_newer_available_version
latest_Version = fetch_latest_game_version
return nil if !latest_Version
return nil if is_higher_version(Settings::GAME_VERSION_NUMBER, latest_Version)
return latest_Version
end
def is_higher_version(gameVersion, latestVersion)
gameVersion_parts = gameVersion.split('.').map(&:to_i)
latestVersion_parts = latestVersion.split('.').map(&:to_i)
# Compare each part of the version numbers from left to right
gameVersion_parts.each_with_index do |part, i|
return true if (latestVersion_parts[i].nil? || part > latestVersion_parts[i])
return false if part < latestVersion_parts[i]
end
return latestVersion_parts.length <= gameVersion_parts.length
end
def get_current_game_difficulty
return :EASY if $game_switches[SWITCH_GAME_DIFFICULTY_EASY]
return :HARD if $game_switches[SWITCH_GAME_DIFFICULTY_HARD]
return :NORMAL
end
def get_difficulty_text
if $game_switches[SWITCH_GAME_DIFFICULTY_EASY]
return _INTL("Easy")
elsif $game_switches[SWITCH_GAME_DIFFICULTY_HARD]
return _INTL("Hard")
else
return _INTL("Normal")
end
end
def getLatestSpritepackDate()
return Time.new(Settings::NEWEST_SPRITEPACK_YEAR, Settings::NEWEST_SPRITEPACK_MONTH)
end
def new_spritepack_was_released()
current_spritepack_date = $PokemonGlobal.current_spritepack_date
latest_spritepack_date = getLatestSpritepackDate()
if !current_spritepack_date || (current_spritepack_date < latest_spritepack_date)
$PokemonGlobal.current_spritepack_date = latest_spritepack_date
return true
end
return false
end
def clearAllSelfSwitches(mapID, switch = "A", newValue = false)
map = $MapFactory.getMap(mapID, false)
map.events.each { |event_array|
event_id = event_array[0]
pbSetSelfSwitch(event_id, switch, newValue, mapID)
}
end
def openUrlInBrowser(url = "")
begin
# Open the URL in the default web browser
system("xdg-open", url) || system("open", url) || system("start", url)
rescue
Input.clipboard = url
pbMessage(_INTL("The game could not open the link in the browser"))
pbMessage(_INTL("The link has been copied to your clipboard instead"))
end
end
# todo: implement
def getMappedKeyFor(internalKey)
keybinding_fileName = "keybindings.mkxp1"
path = System.data_directory + keybinding_fileName
parse_keybindings(path)
# echoln Keybindings.new(path).bindings
end
def formatNumberToString(number)
return number.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
end
def optionsMenu(options = [], cmdIfCancel = -1, startingOption = 0)
$game_temp.message_window_showing = true
cmdIfCancel = -1 if !cmdIfCancel
result = pbShowCommands(nil, options, cmdIfCancel+1, startingOption) #+1 parce que pbShowCommands fait un "-1" pour être "user friendly"...
$game_temp.message_window_showing = false
return result
end
def displaySpriteWindowWithMessage(pif_sprite, message = "", x = 0, y = 0, z = 0)
spriteLoader = BattleSpriteLoader.new
sprite_bitmap = spriteLoader.load_pif_sprite_directly(pif_sprite)
if sprite_bitmap
pictureWindow = PictureWindow.new(sprite_bitmap.bitmap)
else
pictureWindow = PictureWindow.new("")
end
pictureWindow.opacity = 0
pictureWindow.z = z
pictureWindow.x = x
pictureWindow.y = y
pbMessage(message)
pictureWindow.dispose
end
def numeric_string?(str)
str.match?(/\A\d+\z/)
end
def timeDateGreaterThan(date1, date2)
return (
date1.year > date2.year ||
date1.month > date2.month && date1.year == date2.year ||
date1.day > date2.day && date1.month == date2.month && date1.year == date2.year
)
end
def transferBoxDisclaimer(event)
unless Settings::TRANSFER_BOX_DISCLAIMER_MESSAGE.empty?
pbMessage(_INTL(Settings::TRANSFER_BOX_DISCLAIMER_MESSAGE))
end
end