Initial commit

This commit is contained in:
Maruno17
2020-09-04 22:00:59 +01:00
commit ba94119d02
300 changed files with 227558 additions and 0 deletions

View File

@@ -0,0 +1,866 @@
class CommandMenuList
attr_accessor :currentList
def initialize
@commands = []
@currentList = "main"
end
def add(parent,cmd,name,desc=nil)
@commands.push([parent,cmd,name,desc])
end
def list
ret = []
for i in @commands
ret.push(i[2]) if i[0]==@currentList
end
return ret
end
def getCommand(index)
count = 0
for i in @commands
if i[0]==@currentList
return i[1] if count==index
count += 1
end
end
return nil
end
def getDesc(index)
count = 0
for i in @commands
if i[0]==@currentList
return i[3] if count==index && i[3]
count += 1
end
end
return "<No description available>"
end
def hasSubMenu?(cmd)
for i in @commands
return true if i[0]==cmd
end
return false
end
def getParent
ret = nil
for i in @commands
if i[1]==@currentList
ret = i[0]; break
end
end
if ret
count = 0
for i in @commands
if i[0]==ret
return [ret,count] if i[1]==@currentList
count += 1
end
end
return [ret,0]
end
return nil
end
end
def pbDebugMenuCommands(showall=true)
commands = CommandMenuList.new
if showall
commands.add("main","fieldmenu",_INTL("Field options..."),
_INTL("Warp to maps, edit switches/variables, use the PC, edit Day Care, etc."))
commands.add("fieldmenu","warp",_INTL("Warp to Map"),
_INTL("Instantly warp to another map of your choice."))
# - Optional coordinates
commands.add("fieldmenu","refreshmap",_INTL("Refresh Map"),
_INTL("Make all events on this map, and common events, refresh themselves."))
commands.add("fieldmenu","switches",_INTL("Switches"),
_INTL("Edit all Game Switches (except Script Switches)."))
commands.add("fieldmenu","variables",_INTL("Variables"),
_INTL("Edit all Game Variables. Can set them to numbers or text."))
commands.add("fieldmenu","usepc",_INTL("Use PC"),
_INTL("Use a PC to access Pokémon storage and player's PC."))
commands.add("fieldmenu","togglewallpapers",_INTL("Toggle Storage Wallpapers"),
_INTL("Unlock and lock special wallpapers used in Pokémon storage."))
commands.add("fieldmenu","daycare",_INTL("Day Care"),
_INTL("View Pokémon in the Day Care and edit them."))
commands.add("fieldmenu","relicstone",_INTL("Use Relic Stone"),
_INTL("Shadow Pokémon. Choose a Pokémon to show to the Relic Stone for purification."))
commands.add("fieldmenu","purifychamber",_INTL("Use Purify Chamber"),
_INTL("Shadow Pokémon. Open the Purify Chamber for purification."))
commands.add("main","battlemenu",_INTL("Battle options..."),
_INTL("Start battles, reset this map's trainers, ready rematches, edit roamers, etc."))
commands.add("battlemenu","testwildbattle",_INTL("Test Wild Battle"),
_INTL("Start a single battle against a wild Pokémon. You choose the species/level."))
commands.add("battlemenu","testwildbattleadvanced",_INTL("Test Wild Battle Advanced"),
_INTL("Start a battle against 1 or more wild Pokémon. Battle size is your choice."))
commands.add("battlemenu","testtrainerbattle",_INTL("Test Trainer Battle"),
_INTL("Start a single battle against a trainer of your choice."))
commands.add("battlemenu","testtrainerbattleadvanced",_INTL("Test Trainer Battle Advanced"),
_INTL("Start a battle against 1 or more trainers with a battle size of your choice."))
commands.add("battlemenu","togglelogging",_INTL("Toggle Battle Logging"),
_INTL("Record debug logs for battles in Data/debuglog.txt."))
commands.add("battlemenu","resettrainers",_INTL("Reset Map's Trainers"),
_INTL("Turn off Self Switches A and B for all events with \"Trainer\" in their name."))
commands.add("battlemenu","readyrematches",_INTL("Ready All Phone Rematches"),
_INTL("Make all trainers in the phone ready for rematches."))
commands.add("battlemenu","roamers",_INTL("Roaming Pokémon"),
_INTL("Toggle and edit all roaming Pokémon."))
commands.add("main","itemsmenu",_INTL("Item options..."),
_INTL("Give and take items."))
commands.add("itemsmenu","additem",_INTL("Add Item"),
_INTL("Choose an item and a quantity of it to add to the Bag."))
commands.add("itemsmenu","fillbag",_INTL("Fill Bag"),
_INTL("Add a certain number of every item to the Bag."))
commands.add("itemsmenu","emptybag",_INTL("Empty Bag"),
_INTL("Remove all items from the Bag."))
commands.add("main","pokemonmenu",_INTL("Pokémon options..."),
_INTL("Give Pokémon, heal party, fill/empty PC storage, etc."))
commands.add("pokemonmenu","addpokemon",_INTL("Add Pokémon"),
_INTL("Give yourself a Pokémon of a chosen species/level. Goes to PC if party is full."))
commands.add("pokemonmenu","demoparty",_INTL("Give Demo Party"),
_INTL("Give yourself 6 preset Pokémon. They overwrite the current party."))
commands.add("pokemonmenu","healparty",_INTL("Heal Party"),
_INTL("Fully heal the HP/status/PP of all Pokémon in the party."))
commands.add("pokemonmenu","quickhatch",_INTL("Quick Hatch"),
_INTL("Make all eggs in the party require just one more step to hatch."))
commands.add("pokemonmenu","fillboxes",_INTL("Fill Storage Boxes"),
_INTL("Add one Pokémon of each species (at Level 50) to storage."))
commands.add("pokemonmenu","clearboxes",_INTL("Clear Storage Boxes"),
_INTL("Remove all Pokémon in storage."))
commands.add("pokemonmenu","openstorage",_INTL("Access Pokémon Storage"),
_INTL("Opens the Pokémon storage boxes in Organize Boxes mode."))
commands.add("main","playermenu",_INTL("Player options..."),
_INTL("Set money, badges, Pokédexes, player's appearance and name, etc."))
commands.add("playermenu","setbadges",_INTL("Set Badges"),
_INTL("Toggle possession of each Gym Badge."))
commands.add("playermenu","setmoney",_INTL("Set Money"),
_INTL("Edit how much money you have."))
commands.add("playermenu","setcoins",_INTL("Set Coins"),
_INTL("Edit how many Game Corner Coins you have."))
commands.add("playermenu","toggleshoes",_INTL("Toggle Running Shoes"),
_INTL("Toggle possession of running shoes."))
commands.add("playermenu","togglepokegear",_INTL("Toggle Pokégear"),
_INTL("Toggle possession of the Pokégear."))
commands.add("playermenu","dexlists",_INTL("Toggle Pokédex and Dexes"),
_INTL("Toggle possession of the Pokédex, and edit Regional Dex accessibility."))
commands.add("playermenu","setplayer",_INTL("Set Player Character"),
_INTL("Edit the player's character, as defined in \"metadata.txt\"."))
commands.add("playermenu","changeoutfit",_INTL("Set Player Outfit"),
_INTL("Edit the player's outfit number."))
commands.add("playermenu","renameplayer",_INTL("Set Player Name"),
_INTL("Rename the player."))
commands.add("playermenu","randomid",_INTL("Randomise Player ID"),
_INTL("Generate a random new ID for the player."))
end
commands.add("main","editorsmenu",_INTL("Information editors..."),
_INTL("Edit information in the PBS files, terrain tags, battle animations, etc."))
commands.add("editorsmenu","setmetadata",_INTL("Edit Metadata"),
_INTL("Edit global and map-specific metadata."))
commands.add("editorsmenu","mapconnections",_INTL("Edit Map Connections"),
_INTL("Connect maps using a visual interface. Can also edit map encounters/metadata."))
commands.add("editorsmenu","terraintags",_INTL("Edit Terrain Tags"),
_INTL("Edit the terrain tags of tiles in tilesets. Required for tags 8+."))
commands.add("editorsmenu","setencounters",_INTL("Edit Wild Encounters"),
_INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered."))
commands.add("editorsmenu","trainertypes",_INTL("Edit Trainer Types"),
_INTL("Edit the properties of trainer types."))
commands.add("editorsmenu","edittrainers",_INTL("Edit Individual Trainers"),
_INTL("Edit individual trainers, their Pokémon and items."))
commands.add("editorsmenu","edititems",_INTL("Edit Items"),
_INTL("Edit item data."))
commands.add("editorsmenu","editpokemon",_INTL("Edit Pokémon"),
_INTL("Edit Pokémon species data."))
commands.add("editorsmenu","editdexes",_INTL("Edit Regional Dexes"),
_INTL("Create, rearrange and delete Regional Pokédex lists."))
commands.add("editorsmenu","positionsprites",_INTL("Edit Pokémon Sprite Positions"),
_INTL("Reposition Pokémon sprites in battle."))
commands.add("editorsmenu","autopositionsprites",_INTL("Auto-Position All Sprites"),
_INTL("Automatically reposition all Pokémon sprites in battle. Don't use lightly."))
commands.add("editorsmenu","animeditor",_INTL("Battle Animation Editor"),
_INTL("Edit the battle animations."))
commands.add("editorsmenu","animorganiser",_INTL("Battle Animation Organiser"),
_INTL("Rearrange/add/delete battle animations."))
commands.add("editorsmenu","importanims",_INTL("Import All Battle Animations"),
_INTL("Import all battle animations from the \"Animations\" folder."))
commands.add("editorsmenu","exportanims",_INTL("Export All Battle Animations"),
_INTL("Export all battle animations individually to the \"Animations\" folder."))
commands.add("main","othermenu",_INTL("Other options..."),
_INTL("Mystery Gifts, translations, compile data, etc."))
commands.add("othermenu","mysterygift",_INTL("Manage Mystery Gifts"),
_INTL("Edit and enable/disable Mystery Gifts."))
commands.add("othermenu","extracttext",_INTL("Extract Text"),
_INTL("Extract all text in the game to a single file for translating."))
commands.add("othermenu","compiletext",_INTL("Compile Text"),
_INTL("Import text and converts it into a language file."))
commands.add("othermenu","compiledata",_INTL("Compile Data"),
_INTL("Fully compile all data."))
commands.add("othermenu","debugconsole",_INTL("Debug Console"),
_INTL("Open the Debug Console."))
return commands
end
def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil)
case cmd
#=============================================================================
# Field options
#=============================================================================
when "warp"
map = pbWarpToMap
if map
pbFadeOutAndHide(sprites)
pbDisposeMessageWindow(sprites["textbox"])
pbDisposeSpriteHash(sprites)
viewport.dispose
if $scene.is_a?(Scene_Map)
$game_temp.player_new_map_id = map[0]
$game_temp.player_new_x = map[1]
$game_temp.player_new_y = map[2]
$game_temp.player_new_direction = 2
$scene.transfer_player
$game_map.refresh
else
pbCancelVehicles
$MapFactory.setup(map[0])
$game_player.moveto(map[1],map[2])
$game_player.turn_down
$game_map.update
$game_map.autoplay
$game_map.refresh
end
return true # Closes the debug menu to allow the warp
end
when "refreshmap"
$game_map.need_refresh = true
pbMessage(_INTL("The map will refresh."))
when "switches"
pbDebugVariables(0)
when "variables"
pbDebugVariables(1)
when "usepc"
pbPokeCenterPC
when "togglewallpapers"
w = $PokemonStorage.allWallpapers
if w.length<=PokemonStorage::BASICWALLPAPERQTY
pbMessage(_INTL("There are no special wallpapers defined."))
else
paperscmd = 0
unlockarray = $PokemonStorage.unlockedWallpapers
loop do
paperscmds = []
paperscmds.push(_INTL("Unlock all"))
paperscmds.push(_INTL("Lock all"))
for i in PokemonStorage::BASICWALLPAPERQTY...w.length
paperscmds.push(_INTL("{1} {2}",unlockarray[i] ? "[Y]" : "[ ]",w[i]))
end
paperscmd = pbShowCommands(nil,paperscmds,-1,paperscmd)
break if paperscmd<0
if paperscmd==0 # Unlock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = true
end
elsif paperscmd==1 # Lock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = false
end
else
paperindex = paperscmd-2+PokemonStorage::BASICWALLPAPERQTY
unlockarray[paperindex] = !$PokemonStorage.unlockedWallpapers[paperindex]
end
end
end
when "daycare"
pbDebugDayCare
when "relicstone"
pbRelicStone
when "purifychamber"
pbPurifyChamber
#=============================================================================
# Battle options
#=============================================================================
when "testwildbattle"
species = pbChooseSpeciesList
if species!=0
params = ChooseNumberParams.new
params.setRange(1,PBExperience.maxLevel)
params.setInitialValue(5)
params.setCancelValue(0)
level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.",PBSpecies.getName(species)),params)
if level>0
$PokemonTemp.encounterType = -1
pbWildBattle(species,level)
end
end
when "testwildbattleadvanced"
pkmn = []
size0 = 1
pkmnCmd = 0
loop do
pkmnCmds = []
pkmn.each do |p|
pkmnCmds.push(sprintf("%s Lv.%d",p.name,p.level))
end
pkmnCmds.push(_INTL("[Add Pokémon]"))
pkmnCmds.push(_INTL("[Set player side size]"))
pkmnCmds.push(_INTL("[Start {1}v{2} battle]",size0,pkmn.length))
pkmnCmd = pbShowCommands(nil,pkmnCmds,-1,pkmnCmd)
break if pkmnCmd<0
if pkmnCmd==pkmnCmds.length-1 # Start battle
if pkmn.length==0
pbMessage(_INTL("No Pokémon were chosen, cannot start battle."))
next
end
setBattleRule(sprintf("%dv%d",size0,pkmn.length))
$PokemonTemp.encounterType = -1
pbWildBattleCore(*pkmn)
break
elsif pkmnCmd==pkmnCmds.length-2 # Set player side size
if !pbCanDoubleBattle?
pbMessage(_INTL("You only have one Pokémon."))
next
end
maxVal = (pbCanTripleBattle?) ? 3 : 2
params = ChooseNumberParams.new
params.setRange(1,maxVal)
params.setInitialValue(size0)
params.setCancelValue(0)
newSize = pbMessageChooseNumber(
_INTL("Choose the number of battlers on the player's side (max. {1}).",maxVal),params)
size0 = newSize if newSize>0
elsif pkmnCmd==pkmnCmds.length-3 # Add Pokémon
species = pbChooseSpeciesList
if species!=0
params = ChooseNumberParams.new
params.setRange(1,PBExperience.maxLevel)
params.setInitialValue(5)
params.setCancelValue(0)
level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.",PBSpecies.getName(species)),params)
if level>0
pkmn.push(pbNewPkmn(species,level))
end
end
else # Edit a Pokémon
if pbConfirmMessage(_INTL("Change this Pokémon?"))
scr = PokemonDebugPartyScreen.new
scr.pbPokemonDebug(pkmn[pkmnCmd],-1,nil,true)
scr.pbEndScreen
elsif pbConfirmMessage(_INTL("Delete this Pokémon?"))
pkmn[pkmnCmd] = nil
pkmn.compact!
end
end
end
when "testtrainerbattle"
battle = pbListScreen(_INTL("SINGLE TRAINER"),TrainerBattleLister.new(0,false))
if battle
trainerdata = battle[1]
pbTrainerBattle(trainerdata[0],trainerdata[1],"...",false,trainerdata[4],true)
end
when "testtrainerbattleadvanced"
trainers = []
size0 = 1
size1 = 1
trainerCmd = 0
loop do
trainerCmds = []
trainers.each do |t|
trainerCmds.push(sprintf("%s x%d",t[1][0].fullname,t[1][2].length))
end
trainerCmds.push(_INTL("[Add trainer]"))
trainerCmds.push(_INTL("[Set player side size]"))
trainerCmds.push(_INTL("[Set opponent side size]"))
trainerCmds.push(_INTL("[Start {1}v{2} battle]",size0,size1))
trainerCmd = pbShowCommands(nil,trainerCmds,-1,trainerCmd)
break if trainerCmd<0
if trainerCmd==trainerCmds.length-1 # Start battle
if trainers.length==0
pbMessage(_INTL("No trainers were chosen, cannot start battle."))
next
elsif size1<trainers.length
pbMessage(_INTL("Opposing side size is invalid. It should be at least {1}",trainers.length))
next
elsif size1>trainers.length && trainers[0][1][2].length==1
pbMessage(
_INTL("Opposing side size cannot be {1}, as that requires the first trainer to have 2 or more Pokémon, which they don't.",
size1))
next
end
setBattleRule(sprintf("%dv%d",size0,size1))
battleArgs = []
trainers.each do |t|
battleArgs.push([t[1][0],t[1][2],t[1][3],t[1][1]])
end
pbTrainerBattleCore(*battleArgs)
break
elsif trainerCmd==trainerCmds.length-2 # Set opponent side size
if trainers.length==0 || (trainers.length==1 && trainers[0][1][2].length==1)
pbMessage(_INTL("No trainers were chosen or trainer only has one Pokémon."))
next
end
maxVal = 2
maxVal = 3 if trainers.length>=3 ||
(trainers.length==2 && trainers[0][1][2].length>=2) ||
trainers[0][1][2].length>=3
params = ChooseNumberParams.new
params.setRange(1,maxVal)
params.setInitialValue(size1)
params.setCancelValue(0)
newSize = pbMessageChooseNumber(
_INTL("Choose the number of battlers on the opponent's side (max. {1}).",maxVal),params)
size1 = newSize if newSize>0
elsif trainerCmd==trainerCmds.length-3 # Set player side size
if !pbCanDoubleBattle?
pbMessage(_INTL("You only have one Pokémon."))
next
end
maxVal = (pbCanTripleBattle?) ? 3 : 2
params = ChooseNumberParams.new
params.setRange(1,maxVal)
params.setInitialValue(size0)
params.setCancelValue(0)
newSize = pbMessageChooseNumber(
_INTL("Choose the number of battlers on the player's side (max. {1}).",maxVal),params)
size0 = newSize if newSize>0
elsif trainerCmd==trainerCmds.length-4 # Add trainer
battle = pbListScreen(_INTL("CHOOSE A TRAINER"),TrainerBattleLister.new(0,false))
if battle
trainerdata = battle[1]
tr = pbLoadTrainer(trainerdata[0],trainerdata[1],trainerdata[4])
trainers.push([battle[0],tr])
end
else # Edit a trainer
if pbConfirmMessage(_INTL("Change this trainer?"))
battle = pbListScreen(_INTL("CHOOSE A TRAINER"),
TrainerBattleLister.new(trainers[trainerCmd][0],false))
if battle
trainerdata = battle[1]
tr = pbLoadTrainer(trainerdata[0],trainerdata[1],trainerdata[4])
trainers[trainerCmd] = [battle[0],tr]
end
elsif pbConfirmMessage(_INTL("Delete this trainer?"))
trainers[trainerCmd] = nil
trainers.compact!
end
end
end
when "togglelogging"
$INTERNAL = !$INTERNAL
pbMessage(_INTL("Debug logs for battles will be made in the Data folder.")) if $INTERNAL
pbMessage(_INTL("Debug logs for battles will not be made.")) if !$INTERNAL
when "resettrainers"
if $game_map
for event in $game_map.events.values
if event.name[/trainer/i]
$game_self_switches[[$game_map.map_id,event.id,"A"]] = false
$game_self_switches[[$game_map.map_id,event.id,"B"]] = false
end
end
$game_map.need_refresh = true
pbMessage(_INTL("All Trainers on this map were reset."))
else
pbMessage(_INTL("This command can't be used here."))
end
when "readyrematches"
if !$PokemonGlobal.phoneNumbers || $PokemonGlobal.phoneNumbers.length==0
pbMessage(_INTL("There are no trainers in the Phone."))
else
for i in $PokemonGlobal.phoneNumbers
if i.length==8 # A trainer with an event
i[4] = 2
pbSetReadyToBattle(i)
end
end
pbMessage(_INTL("All trainers in the Phone are now ready to rebattle."))
end
when "roamers"
pbDebugRoamers
#=============================================================================
# Item options
#=============================================================================
when "additem"
pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new(0)) { |button,item|
if button==Input::C && item && item>0
params = ChooseNumberParams.new
params.setRange(1,BAG_MAX_PER_SLOT)
params.setInitialValue(1)
params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
if qty>0
$PokemonBag.pbStoreItem(item,qty)
pbMessage(_INTL("Gave {1}x {2}.",qty,PBItems.getName(item)))
end
end
}
when "fillbag"
params = ChooseNumberParams.new
params.setRange(1,BAG_MAX_PER_SLOT)
params.setInitialValue(1)
params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params)
if qty>0
itemconsts = []
for i in PBItems.constants
itemconsts.push(PBItems.const_get(i))
end
itemconsts.sort! { |a,b| a<=>b }
for i in itemconsts
$PokemonBag.pbStoreItem(i,qty)
end
pbMessage(_INTL("The Bag was filled with {1} of each item.",qty))
end
when "emptybag"
$PokemonBag.clear
pbMessage(_INTL("The Bag was cleared."))
#=============================================================================
# Pokémon options
#=============================================================================
when "addpokemon"
species = pbChooseSpeciesList
if species!=0
params = ChooseNumberParams.new
params.setRange(1,PBExperience.maxLevel)
params.setInitialValue(5)
params.setCancelValue(0)
level = pbMessageChooseNumber(_INTL("Set the Pokémon's level."),params)
if level>0
pbAddPokemon(species,level)
end
end
when "demoparty"
pbCreatePokemon
pbMessage(_INTL("Filled party with demo Pokémon."))
when "healparty"
for i in $Trainer.party
i.heal
end
pbMessage(_INTL("Your Pokémon were fully healed."))
when "quickhatch"
for pokemon in $Trainer.party
pokemon.eggsteps = 1 if pokemon.egg?
end
pbMessage(_INTL("All eggs in your party now require one step to hatch."))
when "fillboxes"
$Trainer.formseen = [] if !$Trainer.formseen
$Trainer.formlastseen = [] if !$Trainer.formlastseen
added = 0; completed = true
speciesData = pbLoadSpeciesData
formdata = pbLoadFormToSpecies
for i in 1..PBSpecies.maxValue
if added>=NUM_STORAGE_BOXES*30
completed = false; break
end
cname = getConstantName(PBSpecies,i) rescue nil
next if !cname
pkmn = pbNewPkmn(i,50)
$PokemonStorage[(i-1)/$PokemonStorage.maxPokemon(0),
(i-1)%$PokemonStorage.maxPokemon(0)] = pkmn
# Record all forms of this Pokémon as seen and owned
$Trainer.seen[i] = true
$Trainer.owned[i] = true
$Trainer.formseen[i] = [[],[]]
formdata[i] = [i] if !formdata[i]
for form in 0...formdata[i].length
next if !formdata[i][form] || formdata[i][form]==0
fSpecies = pbGetFSpeciesFromForm(i,form)
formname = pbGetMessage(MessageTypes::FormNames,fSpecies)
genderRate = speciesData[i][SpeciesGenderRate] || 0
gender = (genderRate==PBGenderRates::AlwaysFemale) ? 1 : 0
if form==0
case genderRate
when PBGenderRates::AlwaysMale,
PBGenderRates::AlwaysFemale,
PBGenderRates::Genderless
$Trainer.formseen[i][gender][form] = true
$Trainer.formlastseen[i] = [gender,form]
else # Both male and female
$Trainer.formseen[i][0][form] = true
$Trainer.formseen[i][1][form] = true
$Trainer.formlastseen[i] = [0,form]
end
elsif formname && formname!=""
$Trainer.formseen[i][gender][form] = true
end
end
added += 1
end
pbMessage(_INTL("Storage boxes were filled with one Pokémon of each species."))
if !completed
pbMessage(_INTL("Note: The number of storage spaces ({1} boxes of 30) is less than the number of species.",NUM_STORAGE_BOXES))
end
when "clearboxes"
for i in 0...$PokemonStorage.maxBoxes
for j in 0...$PokemonStorage.maxPokemon(i)
$PokemonStorage[i,j] = nil
end
end
pbMessage(_INTL("The storage boxes were cleared."))
when "openstorage"
pbFadeOutIn {
scene = PokemonStorageScene.new
screen = PokemonStorageScreen.new(scene,$PokemonStorage)
screen.pbStartScreen(0)
}
#=============================================================================
# Player options
#=============================================================================
when "setbadges"
badgecmd = 0
loop do
badgecmds = []
badgecmds.push(_INTL("Give all"))
badgecmds.push(_INTL("Remove all"))
for i in 0...24
badgecmds.push(_INTL("{1} Badge {2}",$Trainer.badges[i] ? "[Y]" : "[ ]",i+1))
end
badgecmd = pbShowCommands(nil,badgecmds,-1,badgecmd)
break if badgecmd<0
if badgecmd==0 # Give all
for i in 0...24; $Trainer.badges[i] = true; end
elsif badgecmd==1 # Remove all
for i in 0...24; $Trainer.badges[i] = false; end
else
$Trainer.badges[badgecmd-2] = !$Trainer.badges[badgecmd-2]
end
end
when "setmoney"
params = ChooseNumberParams.new
params.setRange(0,MAX_MONEY)
params.setDefaultValue($Trainer.money)
$Trainer.money = pbMessageChooseNumber(_INTL("Set the player's money."),params)
pbMessage(_INTL("You now have ${1}.",$Trainer.money.to_s_formatted))
when "setcoins"
params = ChooseNumberParams.new
params.setRange(0,MAX_COINS)
params.setDefaultValue($PokemonGlobal.coins)
$PokemonGlobal.coins = pbMessageChooseNumber(_INTL("Set the player's Coin amount."),params)
pbMessage(_INTL("You now have {1} Coins.",$PokemonGlobal.coins.to_s_formatted))
when "toggleshoes"
$PokemonGlobal.runningShoes = !$PokemonGlobal.runningShoes
pbMessage(_INTL("Gave Running Shoes.")) if $PokemonGlobal.runningShoes
pbMessage(_INTL("Lost Running Shoes.")) if !$PokemonGlobal.runningShoes
when "togglepokegear"
$Trainer.pokegear = !$Trainer.pokegear
pbMessage(_INTL("Gave Pokégear.")) if $Trainer.pokegear
pbMessage(_INTL("Lost Pokégear.")) if !$Trainer.pokegear
when "dexlists"
dexescmd = 0
loop do
dexescmds = []
dexescmds.push(_INTL("Have Pokédex: {1}",$Trainer.pokedex ? "[YES]" : "[NO]"))
d = pbDexNames
for i in 0...d.length
name = d[i]
name = name[0] if name.is_a?(Array)
dexindex = i
unlocked = $PokemonGlobal.pokedexUnlocked[dexindex]
dexescmds.push(_INTL("{1} {2}",unlocked ? "[Y]" : "[ ]",name))
end
dexescmd = pbShowCommands(nil,dexescmds,-1,dexescmd)
break if dexescmd<0
dexindex = dexescmd-1
if dexindex<0 # Toggle Pokédex ownership
$Trainer.pokedex = !$Trainer.pokedex
else # Toggle Regional Dex accessibility
if $PokemonGlobal.pokedexUnlocked[dexindex]
pbLockDex(dexindex)
else
pbUnlockDex(dexindex)
end
end
end
when "setplayer"
limit = 0
for i in 0...8
meta = pbGetMetadata(0,MetadataPlayerA+i)
if !meta
limit = i; break
end
end
if limit<=1
pbMessage(_INTL("There is only one player defined."))
else
params = ChooseNumberParams.new
params.setRange(0,limit-1)
params.setDefaultValue($PokemonGlobal.playerID)
newid = pbMessageChooseNumber(_INTL("Choose the new player character."),params)
if newid!=$PokemonGlobal.playerID
pbChangePlayer(newid)
pbMessage(_INTL("The player character was changed."))
end
end
when "changeoutfit"
oldoutfit = $Trainer.outfit
params = ChooseNumberParams.new
params.setRange(0,99)
params.setDefaultValue(oldoutfit)
$Trainer.outfit = pbMessageChooseNumber(_INTL("Set the player's outfit."),params)
pbMessage(_INTL("Player's outfit was changed.")) if $Trainer.outfit!=oldoutfit
when "renameplayer"
trname = pbEnterPlayerName("Your name?",0,MAX_PLAYER_NAME_SIZE,$Trainer.name)
if trname=="" && pbConfirmMessage(_INTL("Give yourself a default name?"))
trainertype = pbGetPlayerTrainerType
gender = pbGetTrainerTypeGender(trainertype)
trname = pbSuggestTrainerName(gender)
end
if trname==""
pbMessage(_INTL("The player's name remained {1}.",$Trainer.name))
else
$Trainer.name = trname
pbMessage(_INTL("The player's name was changed to {1}.",$Trainer.name))
end
when "randomid"
$Trainer.id = rand(256)
$Trainer.id |= rand(256)<<8
$Trainer.id |= rand(256)<<16
$Trainer.id |= rand(256)<<24
pbMessage(_INTL("The player's ID was changed to {1} (full ID: {2}).",$Trainer.publicID,$Trainer.id))
#=============================================================================
# Information editors
#=============================================================================
when "setmetadata"
pbMetadataScreen(pbDefaultMap)
pbClearData
when "mapconnections"
pbFadeOutIn { pbConnectionsEditor }
when "terraintags"
pbFadeOutIn { pbTilesetScreen }
when "setencounters"
encdata = pbLoadEncountersData
oldencdata = Marshal.dump(encdata)
map = pbDefaultMap
loop do
map = pbListScreen(_INTL("SET ENCOUNTERS"),MapLister.new(map))
break if map<=0
pbEncounterEditorMap(encdata,map)
end
save_data(encdata,"Data/encounters.dat")
pbClearData
pbSaveEncounterData
when "trainertypes"
pbFadeOutIn { pbTrainerTypeEditor }
when "edittrainers"
pbFadeOutIn { pbTrainerBattleEditor }
when "edititems"
pbFadeOutIn { pbItemEditor }
when "editpokemon"
pbFadeOutIn { pbPokemonEditor }
when "editdexes"
pbFadeOutIn { pbRegionalDexEditorMain }
when "positionsprites"
pbFadeOutIn {
sp = SpritePositioner.new
sps = SpritePositionerScreen.new(sp)
sps.pbStart
}
when "autopositionsprites"
if pbConfirmMessage(_INTL("Are you sure you want to reposition all sprites?"))
msgwindow = pbCreateMessageWindow
pbMessageDisplay(msgwindow,_INTL("Repositioning all sprites. Please wait."),false)
Graphics.update
pbAutoPositionAll
pbDisposeMessageWindow(msgwindow)
end
when "animeditor"
pbFadeOutIn { pbAnimationEditor }
when "animorganiser"
pbFadeOutIn { pbAnimationsOrganiser }
when "importanims"
pbImportAllAnimations
when "exportanims"
pbExportAllAnimations
#=============================================================================
# Other options
#=============================================================================
when "mysterygift"
pbManageMysteryGifts
when "extracttext"
pbExtractText
when "compiletext"
pbCompileTextUI
when "compiledata"
msgwindow = pbCreateMessageWindow
pbCompileAllData(true) { |msg| pbMessageDisplay(msgwindow,msg,false) }
pbMessageDisplay(msgwindow,_INTL("All game data was compiled."))
pbDisposeMessageWindow(msgwindow)
when "debugconsole"
Console::setup_console
end
return false
end
def pbDebugMenu(showall=true)
commands = pbDebugMenuCommands(showall)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
sprites = {}
sprites["textbox"] = pbCreateMessageWindow
sprites["textbox"].letterbyletter = false
sprites["cmdwindow"] = Window_CommandPokemonEx.new(commands.list)
cmdwindow = sprites["cmdwindow"]
cmdwindow.x = 0
cmdwindow.y = 0
cmdwindow.width = Graphics.width
cmdwindow.height = Graphics.height-sprites["textbox"].height
cmdwindow.viewport = viewport
cmdwindow.visible = true
sprites["textbox"].text = commands.getDesc(cmdwindow.index)
pbFadeInAndShow(sprites)
ret = -1
refresh = true
loop do
loop do
oldindex = cmdwindow.index
cmdwindow.update
if refresh || cmdwindow.index!=oldindex
sprites["textbox"].text = commands.getDesc(cmdwindow.index)
refresh = false
end
Graphics.update
Input.update
if Input.trigger?(Input::B)
parent = commands.getParent
if parent
pbPlayCancelSE
commands.currentList = parent[0]
cmdwindow.commands = commands.list
cmdwindow.index = parent[1]
refresh = true
else
ret = -1
break
end
elsif Input.trigger?(Input::C)
pbPlayDecisionSE
ret = cmdwindow.index
break
end
end
break if ret<0
cmd = commands.getCommand(ret)
if commands.hasSubMenu?(cmd)
commands.currentList = cmd
cmdwindow.commands = commands.list
cmdwindow.index = 0
refresh = true
else
return if pbDebugMenuActions(cmd,sprites,viewport)
end
end
pbPlayCloseMenuSE
pbFadeOutAndHide(sprites)
pbDisposeMessageWindow(sprites["textbox"])
pbDisposeSpriteHash(sprites)
viewport.dispose
end

View File

@@ -0,0 +1,925 @@
#===============================================================================
#
#===============================================================================
def pbDefaultMap
return $game_map.map_id if $game_map
return $data_system.edit_map_id if $data_system
return 0
end
def pbWarpToMap
mapid = pbListScreen(_INTL("WARP TO MAP"),MapLister.new(pbDefaultMap))
if mapid>0
map = Game_Map.new
map.setup(mapid)
success = false
x = 0
y = 0
100.times do
x = rand(map.width)
y = rand(map.height)
next if !map.passableStrict?(x,y,0,$game_player)
blocked = false
for event in map.events.values
if event.x==x && event.y==y && !event.through
blocked = true if self!=$game_player || event.character_name!=""
end
end
next if blocked
success = true
break
end
if !success
x = rand(map.width)
y = rand(map.height)
end
return [mapid,x,y]
end
return nil
end
#===============================================================================
# Debug Variables screen
#===============================================================================
class SpriteWindow_DebugVariables < Window_DrawableCommand
attr_reader :mode
def initialize(viewport)
super(0,0,Graphics.width,Graphics.height,viewport)
end
def itemCount
return (@mode==0) ? $data_system.switches.size-1 : $data_system.variables.size-1
end
def mode=(mode)
@mode = mode
refresh
end
def shadowtext(x,y,w,h,t,align=0,colors=0)
width = self.contents.text_size(t).width
if align==1 # Right aligned
x += (w-width)
elsif align==2 # Centre aligned
x += (w/2)-(width/2)
end
base = Color.new(12*8,12*8,12*8)
if colors==1 # Red
base = Color.new(168,48,56)
elsif colors==2 # Green
base = Color.new(0,144,0)
end
pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8))
end
def drawItem(index,count,rect)
pbSetNarrowFont(self.contents)
colors = 0; codeswitch = false
if @mode==0
name = $data_system.switches[index+1]
codeswitch = (name[/^s\:/])
val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1]
if val==nil; status = "[-]"; colors = 0; codeswitch = true
elsif val; status = "[ON]"; colors = 2
else; status = "[OFF]"; colors = 1
end
else
name = $data_system.variables[index+1]
status = $game_variables[index+1].to_s
status = "\"__\"" if !status || status==""
end
name = '' if name==nil
id_text = sprintf("%04d:",index+1)
width = self.contents.text_size(id_text).width
rect = drawCursor(index,rect)
totalWidth = rect.width
idWidth = totalWidth*15/100
nameWidth = totalWidth*65/100
statusWidth = totalWidth*20/100
self.shadowtext(rect.x,rect.y,idWidth,rect.height,id_text)
self.shadowtext(rect.x+idWidth,rect.y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0)
self.shadowtext(rect.x+idWidth+nameWidth,rect.y,statusWidth,rect.height,status,1,colors)
end
end
def pbDebugSetVariable(id,diff)
$game_variables[id] = 0 if $game_variables[id]==nil
if $game_variables[id].is_a?(Numeric)
pbPlayCursorSE
$game_variables[id] = [$game_variables[id]+diff,99999999].min
$game_variables[id] = [$game_variables[id],-99999999].max
end
end
def pbDebugVariableScreen(id)
if $game_variables[id].is_a?(Numeric)
value = $game_variables[id]
params = ChooseNumberParams.new
params.setDefaultValue(value)
params.setMaxDigits(8)
params.setNegativesAllowed(true)
value = pbMessageChooseNumber(_INTL("Set variable {1}.",id),params)
$game_variables[id] = [value,99999999].min
$game_variables[id] = [$game_variables[id],-99999999].max
elsif $game_variables[id].is_a?(String)
value = pbMessageFreeText(_INTL("Set variable {1}.",id),
$game_variables[id],false,256,Graphics.width)
$game_variables[id] = value
end
end
def pbDebugVariables(mode)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
sprites = {}
sprites["right_window"] = SpriteWindow_DebugVariables.new(viewport)
right_window = sprites["right_window"]
right_window.mode = mode
right_window.active = true
loop do
Graphics.update
Input.update
pbUpdateSpriteHash(sprites)
if Input.trigger?(Input::B)
pbPlayCancelSE
break
end
current_id = right_window.index+1
if mode==0 # Switches
if Input.trigger?(Input::C)
pbPlayDecisionSE
$game_switches[current_id] = !$game_switches[current_id]
right_window.refresh
end
elsif mode==1 # Variables
if Input.repeat?(Input::LEFT)
pbDebugSetVariable(current_id,-1)
right_window.refresh
elsif Input.repeat?(Input::RIGHT)
pbDebugSetVariable(current_id,1)
right_window.refresh
elsif Input.trigger?(Input::A)
if $game_variables[current_id]==0
$game_variables[current_id] = ""
elsif $game_variables[current_id]==""
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(Numeric)
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(String)
$game_variables[current_id] = ""
end
right_window.refresh
elsif Input.trigger?(Input::C)
pbPlayDecisionSE
pbDebugVariableScreen(current_id)
right_window.refresh
end
end
end
pbDisposeSpriteHash(sprites)
viewport.dispose
end
#===============================================================================
# Debug Day Care screen
#===============================================================================
def pbDebugDayCare
commands = [_INTL("Withdraw Pokémon 1"),
_INTL("Withdraw Pokémon 2"),
_INTL("Deposit Pokémon"),
_INTL("Generate egg"),
_INTL("Collect egg")]
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
sprites = {}
addBackgroundPlane(sprites,"background","hatchbg",viewport)
sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,viewport)
pbSetSystemFont(sprites["overlay"].bitmap)
sprites["cmdwindow"] = Window_CommandPokemonEx.new(commands)
cmdwindow = sprites["cmdwindow"]
cmdwindow.x = 0
cmdwindow.y = Graphics.height-128
cmdwindow.width = Graphics.width
cmdwindow.height = 128
cmdwindow.viewport = viewport
cmdwindow.columns = 2
base = Color.new(248,248,248)
shadow = Color.new(104,104,104)
refresh = true
loop do
if refresh
if pbEggGenerated?
commands[3] = _INTL("Discard egg")
else
commands[3] = _INTL("Generate egg")
end
cmdwindow.commands = commands
sprites["overlay"].bitmap.clear
textpos = []
for i in 0...2
textpos.push([_INTL("Pokémon {1}",i+1),Graphics.width/4+i*Graphics.width/2,8,2,base,shadow])
end
for i in 0...pbDayCareDeposited
next if !$PokemonGlobal.daycare[i][0]
y = 40
pkmn = $PokemonGlobal.daycare[i][0]
initlevel = $PokemonGlobal.daycare[i][1]
leveldiff = pkmn.level-initlevel
textpos.push([pkmn.name+" ("+PBSpecies.getName(pkmn.species)+")",8+i*Graphics.width/2,y,0,base,shadow])
y += 32
if pkmn.male?
textpos.push([_INTL("Male ♂"),8+i*Graphics.width/2,y,0,Color.new(128,192,248),shadow])
elsif pkmn.female?
textpos.push([_INTL("Female ♀"),8+i*Graphics.width/2,y,0,Color.new(248,96,96),shadow])
else
textpos.push([_INTL("Genderless"),8+i*Graphics.width/2,y,0,base,shadow])
end
y += 32
if initlevel>=PBExperience.maxLevel
textpos.push(["Lv. #{initlevel} (max)",8+i*Graphics.width/2,y,0,base,shadow])
elsif leveldiff>0
textpos.push(["Lv. #{initlevel} -> #{pkmn.level} (+#{leveldiff})",
8+i*Graphics.width/2,y,0,base,shadow])
else
textpos.push(["Lv. #{initlevel} (no change)",8+i*Graphics.width/2,y,0,base,shadow])
end
y += 32
if pkmn.level<PBExperience.maxLevel
endexp = PBExperience.pbGetStartExperience(pkmn.level+1,pkmn.growthrate)
textpos.push(["To next Lv.: #{endexp-pkmn.exp}",8+i*Graphics.width/2,y,0,base,shadow])
y += 32
end
cost = pbDayCareGetCost(i)
textpos.push(["Cost: $#{cost}",8+i*Graphics.width/2,y,0,base,shadow])
end
if pbEggGenerated?
textpos.push(["Egg waiting for collection",Graphics.width/2,216,2,Color.new(248,248,0),shadow])
elsif pbDayCareDeposited==2
if pbDayCareGetCompat==0
textpos.push(["Pokémon cannot breed",Graphics.width/2,216,2,Color.new(248,96,96),shadow])
else
textpos.push(["Pokémon can breed",Graphics.width/2,216,2,Color.new(64,248,64),shadow])
end
end
pbDrawTextPositions(sprites["overlay"].bitmap,textpos)
refresh = false
end
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
if Input.trigger?(Input::B)
break
elsif Input.trigger?(Input::C)
ret = cmdwindow.index
case cmdwindow.index
when 0 # Withdraw Pokémon 1
if !$PokemonGlobal.daycare[0][0]
pbPlayBuzzerSE
elsif $Trainer.party.length>=6
pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
else
pbPlayDecisionSE
pbDayCareGetDeposited(0,3,4)
pbDayCareWithdraw(0)
refresh = true
end
when 1 # Withdraw Pokémon 2
if !$PokemonGlobal.daycare[1][0]
pbPlayBuzzerSE
elsif $Trainer.party.length>=6
pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
else
pbPlayDecisionSE
pbDayCareGetDeposited(1,3,4)
pbDayCareWithdraw(1)
refresh = true
end
when 2 # Deposit Pokémon
if pbDayCareDeposited==2
pbPlayBuzzerSE
elsif $Trainer.party.length==0
pbPlayBuzzerSE
pbMessage(_INTL("Party is empty, can't deposit Pokémon."))
else
pbPlayDecisionSE
pbChooseNonEggPokemon(1,3)
if pbGet(1)>=0
pbDayCareDeposit(pbGet(1))
refresh = true
end
end
when 3 # Generate/discard egg
if pbEggGenerated?
pbPlayDecisionSE
$PokemonGlobal.daycareEgg = 0
$PokemonGlobal.daycareEggSteps = 0
refresh = true
else
if pbDayCareDeposited!=2 || pbDayCareGetCompat==0
pbPlayBuzzerSE
else
pbPlayDecisionSE
$PokemonGlobal.daycareEgg = 1
refresh = true
end
end
when 4 # Collect egg
if $PokemonGlobal.daycareEgg!=1
pbPlayBuzzerSE
elsif $Trainer.party.length>=6
pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't collect the egg."))
else
pbPlayDecisionSE
pbDayCareGenerateEgg
$PokemonGlobal.daycareEgg = 0
$PokemonGlobal.daycareEggSteps = 0
pbMessage(_INTL("Collected the {1} egg.",
PBSpecies.getName($Trainer.lastParty.species)))
refresh = true
end
end
end
end
pbDisposeSpriteHash(sprites)
viewport.dispose
end
#===============================================================================
# Debug roaming Pokémon screen
#===============================================================================
class SpriteWindow_DebugRoamers < Window_DrawableCommand
def initialize(viewport)
super(0,0,Graphics.width,Graphics.height,viewport)
end
def roamerCount
return RoamingSpecies.length
end
def itemCount
return self.roamerCount+2
end
def shadowtext(t,x,y,w,h,align=0,colors=0)
width = self.contents.text_size(t).width
if align==1 ; x += (w-width) # Right aligned
elsif align==2; x += (w/2)-(width/2) # Centre aligned
end
base = Color.new(12*8,12*8,12*8)
if colors==1; base = Color.new(168,48,56) # Red
elsif colors==2; base = Color.new(0,144,0) # Green
end
pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8))
end
def drawItem(index,count,rect)
pbSetNarrowFont(self.contents)
rect = drawCursor(index,rect)
nameWidth = rect.width*50/100
statusWidth = rect.width*50/100
if index==self.itemCount-2
# Advance roaming
self.shadowtext(_INTL("[All roam to new locations]"),rect.x,rect.y,nameWidth,rect.height)
elsif index==self.itemCount-1
# Advance roaming
self.shadowtext(_INTL("[Clear all current roamer locations]"),rect.x,rect.y,nameWidth,rect.height)
else
pkmn = RoamingSpecies[index]
name = PBSpecies.getName(getID(PBSpecies,pkmn[0]))+" (Lv. #{pkmn[1]})"
status = ""
statuscolor = 0
if pkmn[2]<=0 || $game_switches[pkmn[2]]
status = $PokemonGlobal.roamPokemon[index]
if status==true
if $PokemonGlobal.roamPokemonCaught[index]
status = "[CAUGHT]"
else
status = "[DEFEATED]"
end
statuscolor = 1
else
# roaming
curmap = $PokemonGlobal.roamPosition[index]
if curmap
mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
status = "[ROAMING][#{curmap}: #{mapinfos[curmap].name}]"
else
status = "[ROAMING][map not set]"
end
statuscolor = 2
end
else
status = "[NOT ROAMING][Switch #{pkmn[2]} is off]"
end
self.shadowtext(name,rect.x,rect.y,nameWidth,rect.height)
self.shadowtext(status,rect.x+nameWidth,rect.y,statusWidth,rect.height,1,statuscolor)
end
end
end
def pbDebugRoamers
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
sprites = {}
sprites["cmdwindow"] = SpriteWindow_DebugRoamers.new(viewport)
cmdwindow = sprites["cmdwindow"]
cmdwindow.active = true
loop do
Graphics.update
Input.update
pbUpdateSpriteHash(sprites)
if Input.trigger?(Input::A) && cmdwindow.index<cmdwindow.roamerCount &&
(pkmn[2]<=0 || $game_switches[pkmn[2]]) &&
$PokemonGlobal.roamPokemon[cmdwindow.index]!=true
# Roam selected Pokémon
pbPlayDecisionSE
if Input.press?(Input::CTRL) # Roam to current map
if $PokemonGlobal.roamPosition[cmdwindow.index]==pbDefaultMap
$PokemonGlobal.roamPosition[cmdwindow.index] = nil
else
$PokemonGlobal.roamPosition[cmdwindow.index] = pbDefaultMap
end
cmdwindow.refresh
else # Roam to a random other map
oldmap = $PokemonGlobal.roamPosition[cmdwindow.index]
pbRoamPokemonOne(cmdwindow.index)
if $PokemonGlobal.roamPosition[cmdwindow.index] == oldmap
$PokemonGlobal.roamPosition[cmdwindow.index] = nil
pbRoamPokemonOne(cmdwindow.index)
end
$PokemonGlobal.roamedAlready = false
cmdwindow.refresh
end
elsif Input.trigger?(Input::B)
pbPlayCancelSE
break
elsif Input.trigger?(Input::C)
if cmdwindow.index<cmdwindow.roamerCount
pbPlayDecisionSE
# Toggle through roaming, not roaming, defeated
pkmn = RoamingSpecies[cmdwindow.index]
if pkmn[2]>0 && !$game_switches[pkmn[2]]
# not roaming -> roaming
$game_switches[pkmn[2]] = true
elsif $PokemonGlobal.roamPokemon[cmdwindow.index]!=true
# roaming -> defeated
$PokemonGlobal.roamPokemon[cmdwindow.index] = true
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false
elsif $PokemonGlobal.roamPokemon[cmdwindow.index] == true &&
!$PokemonGlobal.roamPokemonCaught[cmdwindow.index]
# defeated -> caught
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = true
elsif pkmn[2]>0
# caught -> not roaming (or roaming if Switch ID is 0
$game_switches[pkmn[2]] = false if pkmn[2]>0
$PokemonGlobal.roamPokemon[cmdwindow.index] = nil
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false
end
cmdwindow.refresh
elsif cmdwindow.index==cmdwindow.itemCount-2 # All roam
if RoamingSpecies.length==0
pbPlayBuzzerSE
else
pbPlayDecisionSE
pbRoamPokemon
$PokemonGlobal.roamedAlready = false
cmdwindow.refresh
end
else # Clear all roaming locations
if RoamingSpecies.length==0
pbPlayBuzzerSE
else
pbPlayDecisionSE
for i in 0...RoamingSpecies.length
$PokemonGlobal.roamPosition[i] = nil
end
$PokemonGlobal.roamedAlready = false
cmdwindow.refresh
end
end
end
end
pbDisposeSpriteHash(sprites)
viewport.dispose
end
#===============================================================================
# Give the player a party of Pokémon.
# For demonstration purposes only, not to be used in a real game.
#===============================================================================
def pbCreatePokemon
party = []
species = [:PIKACHU,:PIDGEOTTO,:KADABRA,:GYARADOS,:DIGLETT,:CHANSEY]
for id in species
party.push(getConst(PBSpecies,id)) if hasConst?(PBSpecies,id)
end
# Species IDs of the Pokémon to be created
for i in 0...party.length
species = party[i]
# Generate Pokémon with species and level 20
$Trainer.party[i] = pbNewPkmn(species,20)
$Trainer.seen[species] = true # Set this species to seen and owned
$Trainer.owned[species] = true
pbSeenForm($Trainer.party[i])
end
$Trainer.party[1].pbLearnMove(:FLY)
$Trainer.party[2].pbLearnMove(:FLASH)
$Trainer.party[2].pbLearnMove(:TELEPORT)
$Trainer.party[3].pbLearnMove(:SURF)
$Trainer.party[3].pbLearnMove(:DIVE)
$Trainer.party[3].pbLearnMove(:WATERFALL)
$Trainer.party[4].pbLearnMove(:DIG)
$Trainer.party[4].pbLearnMove(:CUT)
$Trainer.party[4].pbLearnMove(:HEADBUTT)
$Trainer.party[4].pbLearnMove(:ROCKSMASH)
$Trainer.party[5].pbLearnMove(:SOFTBOILED)
$Trainer.party[5].pbLearnMove(:STRENGTH)
$Trainer.party[5].pbLearnMove(:SWEETSCENT)
for i in 0...party.length
$Trainer.party[i].pbRecordFirstMoves
end
end
#===============================================================================
#
#===============================================================================
class PokemonDataCopy
attr_accessor :dataOldHash
attr_accessor :dataNewHash
attr_accessor :dataTime
attr_accessor :data
def crc32(x)
return Zlib::crc32(x)
end
def readfile(filename)
File.open(filename, "rb") { |f| f.read }
end
def writefile(str,filename)
File.open(filename, "wb") { |f| f.write(str) }
end
def filetime(filename)
File.open(filename, "r") { |f| f.mtime }
end
def initialize(data,datasave)
@datafile = data
@datasave = datasave
@data = readfile(@datafile)
@dataOldHash = crc32(@data)
@dataTime = filetime(@datafile)
end
def changed?
ts = readfile(@datafile)
tsDate = filetime(@datafile)
tsHash = crc32(ts)
return (tsHash!=@dataNewHash && tsHash!=@dataOldHash && tsDate>@dataTime)
end
def save(newtilesets)
newdata = Marshal.dump(newtilesets)
if !changed?
@data = newdata
@dataNewHash = crc32(newdata)
writefile(newdata,@datafile)
else
@dataOldHash = crc32(@data)
@dataNewHash = crc32(newdata)
@dataTime = filetime(@datafile)
@data = newdata
writefile(newdata,@datafile)
end
save_data(self,@datasave)
end
end
class PokemonDataWrapper
attr_reader :data
def initialize(file,savefile,prompt)
@savefile = savefile
@file = file
if pbRgssExists?(@savefile)
@ts = load_data(@savefile)
if !@ts.changed? || prompt.call==true
@data = Marshal.load(StringInput.new(@ts.data))
else
@ts = PokemonDataCopy.new(@file,@savefile)
@data = load_data(@file)
end
else
@ts = PokemonDataCopy.new(@file,@savefile)
@data = load_data(@file)
end
end
def save
@ts.save(@data)
end
end
#===============================================================================
# Text import/export for localisation
#===============================================================================
def pbExtractText
msgwindow = pbCreateMessageWindow
if safeExists?("intl.txt") &&
!pbConfirmMessageSerious(_INTL("intl.txt already exists. Overwrite it?"))
pbDisposeMessageWindow(msgwindow)
return
end
pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]"))
MessageTypes.extract("intl.txt")
pbMessageDisplay(msgwindow,_INTL("All text in the game was extracted and saved to intl.txt.\1"))
pbMessageDisplay(msgwindow,_INTL("To localize the text for a particular language, translate every second line in the file.\1"))
pbMessageDisplay(msgwindow,_INTL("After translating, choose \"Compile Text.\""))
pbDisposeMessageWindow(msgwindow)
end
def pbCompileTextUI
msgwindow = pbCreateMessageWindow
pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]"))
begin
pbCompileText
pbMessageDisplay(msgwindow,_INTL("Successfully compiled text and saved it to intl.dat.\1"))
pbMessageDisplay(msgwindow,_INTL("To use the file in a game, place the file in the Data folder under a different name, and edit the LANGUAGES array in the Settings script."))
rescue RuntimeError
pbMessageDisplay(msgwindow,_INTL("Failed to compile text: {1}",$!.message))
end
pbDisposeMessageWindow(msgwindow)
end
#===============================================================================
# Battle animations import/export
#===============================================================================
def pbExportAllAnimations
begin
Dir.mkdir("Animations") rescue nil
animations = pbLoadBattleAnimations
if animations
msgwindow = pbCreateMessageWindow
for anim in animations
next if !anim || anim.length==0 || anim.name==""
pbMessageDisplay(msgwindow,anim.name,false)
Graphics.update
safename = anim.name.gsub(/\W/,"_")
Dir.mkdir("Animations/#{safename}") rescue nil
File.open("Animations/#{safename}/#{safename}.anm","wb") { |f|
f.write(dumpBase64Anim(anim))
}
if anim.graphic && anim.graphic!=""
graphicname = RTP.getImagePath("Graphics/Animations/"+anim.graphic)
pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname))
end
for timing in anim.timing
if !timing.timingType || timing.timingType==0
if timing.name && timing.name!=""
audioName = RTP.getAudioPath("Audio/SE/Anim/"+timing.name)
pbSafeCopyFile(audioName,"Animations/#{safename}/"+File.basename(audioName))
end
elsif timing.timingType==1 || timing.timingType==3
if timing.name && timing.name!=""
graphicname = RTP.getImagePath("Graphics/Animations/"+timing.name)
pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname))
end
end
end
end
pbDisposeMessageWindow(msgwindow)
pbMessage(_INTL("All animations were extracted and saved to the Animations folder."))
else
pbMessage(_INTL("There are no animations to export."))
end
rescue
p $!.message,$!.backtrace
pbMessage(_INTL("The export failed."))
end
end
def pbImportAllAnimations
animationFolders = []
if safeIsDirectory?("Animations")
Dir.foreach("Animations") { |fb|
f = "Animations/"+fb
if safeIsDirectory?(f) && fb!="." && fb!=".."
animationFolders.push(f)
end
}
end
if animationFolders.length==0
pbMessage(_INTL("There are no animations to import. Put each animation in a folder within the Animations folder."))
else
msgwindow = pbCreateMessageWindow
animations = pbLoadBattleAnimations
animations = PBAnimations.new if !animations
for folder in animationFolders
pbMessageDisplay(msgwindow,folder,false)
Graphics.update
audios = []
files = Dir.glob(folder+"/*.*")
%w( wav ogg mid wma mp3 ).each { |ext|
upext = ext.upcase
audios.concat(files.find_all { |f| f[f.length-3,3]==ext })
audios.concat(files.find_all { |f| f[f.length-3,3]==upext })
}
for audio in audios
pbSafeCopyFile(audio,RTP.getAudioPath("Audio/SE/Anim/"+File.basename(audio)),"Audio/SE/Anim/"+File.basename(audio))
end
images = []
%w( png jpg bmp gif ).each { |ext|
upext = ext.upcase
images.concat(files.find_all { |f| f[f.length-3,3]==ext })
images.concat(files.find_all { |f| f[f.length-3,3]==upext })
}
for image in images
pbSafeCopyFile(image,RTP.getImagePath("Graphics/Animations/"+File.basename(image)),"Graphics/Animations/"+File.basename(image))
end
Dir.glob(folder+"/*.anm") { |f|
textdata = loadBase64Anim(IO.read(f)) rescue nil
if textdata && textdata.is_a?(PBAnimation)
index = pbAllocateAnimation(animations,textdata.name)
missingFiles = []
textdata.name = File.basename(folder) if textdata.name==""
textdata.id = -1 # This is not an RPG Maker XP animation
pbConvertAnimToNewFormat(textdata)
if textdata.graphic && textdata.graphic!=""
if !safeExists?(folder+"/"+textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/"+textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
end
for timing in textdata.timing
if timing.name && timing.name!=""
if !safeExists?(folder+"/"+timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/"+timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
end
end
animations[index] = textdata
end
}
end
save_data(animations,"Data/PkmnAnimations.rxdata")
$PokemonTemp.battleAnims = nil
pbDisposeMessageWindow(msgwindow)
pbMessage(_INTL("All animations were imported."))
end
end
#===============================================================================
# Pseudo-party screen for editing Pokémon being set up for a wild battle
#===============================================================================
class PokemonDebugPartyScreen
def initialize
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
@messageBox = Window_AdvancedTextPokemon.new("")
@messageBox.viewport = @viewport
@messageBox.visible = false
@messageBox.letterbyletter = true
pbBottomLeftLines(@messageBox,2)
@helpWindow = Window_UnformattedTextPokemon.new("")
@helpWindow.viewport = @viewport
@helpWindow.visible = true
pbBottomLeftLines(@helpWindow,1)
end
def pbEndScreen
@messageBox.dispose
@helpWindow.dispose
@viewport.dispose
end
def pbDisplay(text)
@messageBox.text = text
@messageBox.visible = true
@helpWindow.visible = false
pbPlayDecisionSE
loop do
Graphics.update
Input.update
pbUpdate
if @messageBox.busy?
if Input.trigger?(Input::C)
pbPlayDecisionSE if @messageBox.pausing?
@messageBox.resume
end
else
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
break
end
end
end
@messageBox.visible = false
@helpWindow.visible = true
end
def pbConfirm(text)
ret = -1
@messageBox.text = text
@messageBox.visible = true
@helpWindow.visible = false
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) {
cmdwindow.visible = false
pbBottomRight(cmdwindow)
cmdwindow.y -= @messageBox.height
cmdwindow.z = @viewport.z+1
loop do
Graphics.update
Input.update
cmdwindow.visible = true if !@messageBox.busy?
cmdwindow.update
pbUpdate
if !@messageBox.busy?
if Input.trigger?(Input::B)
ret = false
break
elsif Input.trigger?(Input::C) && @messageBox.resume
ret = (cmdwindow.index==0)
break
end
end
end
}
@messageBox.visible = false
@helpWindow.visible = true
return ret
end
def pbShowCommands(text,commands,index=0)
ret = -1
@helpWindow.visible = true
using(cmdwindow = Window_CommandPokemonColor.new(commands)) {
cmdwindow.z = @viewport.z+1
cmdwindow.index = index
pbBottomRight(cmdwindow)
@helpWindow.resizeHeightToFit(text,Graphics.width-cmdwindow.width)
@helpWindow.text = text
pbBottomLeft(@helpWindow)
loop do
Graphics.update
Input.update
cmdwindow.update
pbUpdate
if Input.trigger?(Input::B)
pbPlayCancelSE
ret = -1
break
elsif Input.trigger?(Input::C)
pbPlayDecisionSE
ret = cmdwindow.index
break
end
end
}
return ret
end
def pbChooseMove(pkmn,text,index=0)
moveNames = []
for i in pkmn.moves
break if i.id==0
if i.totalpp<=0
moveNames.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id)))
else
moveNames.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp))
end
end
return pbShowCommands(text,moveNames,index)
end
def pbRefreshSingle(index); end
def update
@messageBox.update
@helpWindow.update
end
alias pbUpdate update
end

View File

@@ -0,0 +1,866 @@
module PokemonDebugMixin
def pbPokemonDebugCommands(settingUpBattle=false)
commands = CommandMenuList.new
commands.add("main","hpstatusmenu",_INTL("HP/Status..."))
commands.add("hpstatusmenu","sethp",_INTL("Set HP"))
commands.add("hpstatusmenu","setstatus",_INTL("Set status"))
commands.add("hpstatusmenu","fullheal",_INTL("Fully heal"))
commands.add("hpstatusmenu","makefainted",_INTL("Make fainted"))
commands.add("hpstatusmenu","setpokerus",_INTL("Set Pokérus"))
commands.add("main","levelstats",_INTL("Level/stats..."))
commands.add("levelstats","setlevel",_INTL("Set level"))
commands.add("levelstats","setexp",_INTL("Set Exp"))
commands.add("levelstats","hiddenvalues",_INTL("EV/IV/pID..."))
commands.add("levelstats","sethappiness",_INTL("Set happiness"))
commands.add("levelstats","conteststats",_INTL("Contest stats..."))
commands.add("conteststats","setbeauty",_INTL("Set Beauty"))
commands.add("conteststats","setcool",_INTL("Set Cool"))
commands.add("conteststats","setcute",_INTL("Set Cute"))
commands.add("conteststats","setsmart",_INTL("Set Smart"))
commands.add("conteststats","settough",_INTL("Set Tough"))
commands.add("conteststats","setsheen",_INTL("Set Sheen"))
commands.add("main","moves",_INTL("Moves..."))
commands.add("moves","teachmove",_INTL("Teach move"))
commands.add("moves","forgetmove",_INTL("Forget move"))
commands.add("moves","resetmoves",_INTL("Reset moves"))
commands.add("moves","setmovepp",_INTL("Set move PP"))
commands.add("moves","setinitialmoves",_INTL("Reset initial moves"))
commands.add("main","setability",_INTL("Set ability"))
commands.add("main","setnature",_INTL("Set nature"))
commands.add("main","setgender",_INTL("Set gender"))
commands.add("main","speciesform",_INTL("Species/form..."))
commands.add("main","cosmetic",_INTL("Cosmetic info..."))
commands.add("cosmetic","setshininess",_INTL("Set shininess"))
commands.add("cosmetic","setpokeball",_INTL("Set Poké Ball"))
commands.add("cosmetic","setribbons",_INTL("Set ribbons"))
commands.add("cosmetic","setnickname",_INTL("Set nickname"))
commands.add("cosmetic","ownership",_INTL("Ownership..."))
commands.add("main","setegg",_INTL("Set egg"))
commands.add("main","shadowpkmn",_INTL("Shadow Pkmn..."))
if !settingUpBattle
commands.add("main","mysterygift",_INTL("Mystery Gift"))
commands.add("main","duplicate",_INTL("Duplicate"))
commands.add("main","delete",_INTL("Delete"))
end
return commands
end
def pbPokemonDebugActions(command,pkmn,pkmnid,heldpoke=nil,settingUpBattle=false)
case command
#===========================================================================
when "sethp"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
else
params = ChooseNumberParams.new
params.setRange(0,pkmn.totalhp)
params.setDefaultValue(pkmn.hp)
newhp = pbMessageChooseNumber(
_INTL("Set {1}'s HP (max. {2}).",pkmn.name,pkmn.totalhp),params) { pbUpdate }
if newhp!=pkmn.hp
pkmn.hp = newhp
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "setstatus"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
elsif pkmn.hp<=0
pbDisplay(_INTL("{1} is fainted, can't change status.",pkmn.name))
else
cmd = 0
loop do
cmd = pbShowCommands(_INTL("Set {1}'s status.",pkmn.name),[
_INTL("[Cure]"),
_INTL("Sleep"),
_INTL("Poison"),
_INTL("Burn"),
_INTL("Paralysis"),
_INTL("Frozen")
],cmd)
break if cmd<0
case cmd
when 0 # Cure
pkmn.healStatus
pbDisplay(_INTL("{1}'s status was cured.",pkmn.name))
pbRefreshSingle(pkmnid)
else # Give status problem
count = 0
cancel = false
if cmd==PBStatuses::SLEEP
params = ChooseNumberParams.new
params.setRange(0,9)
params.setDefaultValue(3)
count = pbMessageChooseNumber(
_INTL("Set the Pokémon's sleep count."),params) { pbUpdate }
cancel = true if count<=0
end
if !cancel
pkmn.status = cmd
pkmn.statusCount = count
pbRefreshSingle(pkmnid)
end
end
end
end
#===========================================================================
when "fullheal"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
else
pkmn.heal
pbDisplay(_INTL("{1} was fully healed.",pkmn.name))
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "makefainted"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
else
pkmn.hp = 0
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "setpokerus"
cmd = 0
loop do
pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0
msg = [_INTL("{1} doesn't have Pokérus.",pkmn.name),
_INTL("Has strain {1}, infectious for {2} more days.",pokerus/16,pokerus%16),
_INTL("Has strain {1}, not infectious.",pokerus/16)][pkmn.pokerusStage]
cmd = pbShowCommands(msg,[
_INTL("Give random strain"),
_INTL("Make not infectious"),
_INTL("Clear Pokérus")],cmd)
break if cmd<0
case cmd
when 0 # Give random strain
pkmn.givePokerus
pbRefreshSingle(pkmnid)
when 1 # Make not infectious
if pokerus>0
strain = pokerus/16
p = strain<<4
pkmn.pokerus = p
pbRefreshSingle(pkmnid)
end
when 2 # Clear Pokérus
pkmn.pokerus = 0
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "setlevel"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
else
mLevel = PBExperience.maxLevel
params = ChooseNumberParams.new
params.setRange(1,mLevel)
params.setDefaultValue(pkmn.level)
level = pbMessageChooseNumber(
_INTL("Set the Pokémon's level (max. {1}).",mLevel),params) { pbUpdate }
if level!=pkmn.level
pkmn.level = level
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "setexp"
if pkmn.egg?
pbDisplay(_INTL("{1} is an egg.",pkmn.name))
else
minxp = PBExperience.pbGetStartExperience(pkmn.level,pkmn.growthrate)
maxxp = PBExperience.pbGetStartExperience(pkmn.level+1,pkmn.growthrate)
if minxp==maxxp
pbDisplay(_INTL("{1} is at the maximum level.",pkmn.name))
else
params = ChooseNumberParams.new
params.setRange(minxp,maxxp-1)
params.setDefaultValue(pkmn.exp)
newexp = pbMessageChooseNumber(
_INTL("Set the Pokémon's Exp (range {1}-{2}).",minxp,maxxp-1),params) { pbUpdate }
if newexp!=pkmn.exp
pkmn.exp = newexp
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
end
end
#===========================================================================
when "hiddenvalues"
numstats = 6
cmd = 0
loop do
persid = sprintf("0x%08X",pkmn.personalID)
cmd = pbShowCommands(_INTL("Personal ID is {1}.",persid),[
_INTL("Set EVs"),
_INTL("Set IVs"),
_INTL("Randomise pID")],cmd)
break if cmd<0
case cmd
when 0 # Set EVs
cmd2 = 0
loop do
totalev = 0
evcommands = []
for i in 0...numstats
evcommands.push(PBStats.getName(i)+" (#{pkmn.ev[i]})")
totalev += pkmn.ev[i]
end
evcommands.push(_INTL("Randomise all"))
evcommands.push(_INTL("Max randomise all"))
cmd2 = pbShowCommands(_INTL("Change which EV?\nTotal: {1}/{2} ({3}%)",
totalev,PokeBattle_Pokemon::EV_LIMIT,
100*totalev/PokeBattle_Pokemon::EV_LIMIT),evcommands,cmd2)
break if cmd2<0
if cmd2<numstats
params = ChooseNumberParams.new
upperLimit = 0
for i in 0...numstats
upperLimit += pkmn.ev[i] if i!=cmd2
end
upperLimit = PokeBattle_Pokemon::EV_LIMIT-upperLimit
upperLimit = [upperLimit,PokeBattle_Pokemon::EV_STAT_LIMIT].min
thisValue = [pkmn.ev[cmd2],upperLimit].min
params.setRange(0,upperLimit)
params.setDefaultValue(thisValue)
params.setCancelValue(thisValue)
f = pbMessageChooseNumber(_INTL("Set the EV for {1} (max. {2}).",
PBStats.getName(cmd2),upperLimit),params) { pbUpdate }
if f!=pkmn.ev[cmd2]
pkmn.ev[cmd2] = f
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
elsif cmd2<evcommands.length # Randomise
evTotalTarget = PokeBattle_Pokemon::EV_LIMIT
if cmd2==evcommands.length-2
evTotalTarget = rand(PokeBattle_Pokemon::EV_LIMIT)
end
for i in 0...numstats
pkmn.ev[i] = 0
end
while evTotalTarget>0
r = rand(numstats)
next if pkmn.ev[r]>=PokeBattle_Pokemon::EV_STAT_LIMIT
addVal = 1+rand(PokeBattle_Pokemon::EV_STAT_LIMIT/4)
addVal = evTotalTarget if addVal>evTotalTarget
addVal = [addVal,PokeBattle_Pokemon::EV_STAT_LIMIT-pkmn.ev[r]].min
next if addVal==0
pkmn.ev[r] += addVal
evTotalTarget -= addVal
end
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
end
when 1 # Set IVs
cmd2 = 0
loop do
hiddenpower = pbHiddenPower(pkmn)
totaliv = 0
ivcommands = []
for i in 0...numstats
ivcommands.push(PBStats.getName(i)+" (#{pkmn.iv[i]})")
totaliv += pkmn.iv[i]
end
msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)",
PBTypes.getName(hiddenpower[0]),hiddenpower[1],totaliv,numstats*31,
100*totaliv/(numstats*31))
ivcommands.push(_INTL("Randomise all"))
cmd2 = pbShowCommands(msg,ivcommands,cmd2)
break if cmd2<0
if cmd2<numstats
params = ChooseNumberParams.new
params.setRange(0,31)
params.setDefaultValue(pkmn.iv[cmd2])
params.setCancelValue(pkmn.iv[cmd2])
f = pbMessageChooseNumber(_INTL("Set the IV for {1} (max. 31).",
PBStats.getName(cmd2)),params) { pbUpdate }
if f!=pkmn.iv[cmd2]
pkmn.iv[cmd2] = f
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
elsif cmd2==ivcommands.length-1 # Randomise
for i in 0...numstats
pkmn.iv[i] = rand(PokeBattle_Pokemon::IV_STAT_LIMIT+1)
end
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
end
when 2 # Randomise pID
pkmn.personalID = rand(256)
pkmn.personalID |= rand(256)<<8
pkmn.personalID |= rand(256)<<16
pkmn.personalID |= rand(256)<<24
pkmn.calcStats
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "sethappiness"
params = ChooseNumberParams.new
params.setRange(0,255)
params.setDefaultValue(pkmn.happiness)
h = pbMessageChooseNumber(
_INTL("Set the Pokémon's happiness (max. 255)."),params) { pbUpdate }
if h!=pkmn.happiness
pkmn.happiness = h
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "setbeauty", "setcool", "setcute", "setsmart", "settough", "setsheen"
case command
when "setbeauty"; statname = _INTL("Beauty"); defval = pkmn.beauty
when "setcool"; statname = _INTL("Cool"); defval = pkmn.cool
when "setcute"; statname = _INTL("Cute"); defval = pkmn.cute
when "setsmart"; statname = _INTL("Smart"); defval = pkmn.smart
when "settough"; statname = _INTL("Tough"); defval = pkmn.tough
when "setsheen"; statname = _INTL("Sheen"); defval = pkmn.sheen
end
params = ChooseNumberParams.new
params.setRange(0,255)
params.setDefaultValue(defval)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's {1} (max. 255).",statname),params) { pbUpdate }
if newval!=defval
case command
when "setbeauty"; pkmn.beauty = newval
when "setcool"; pkmn.cool = newval
when "setcute"; pkmn.cute = newval
when "setsmart"; pkmn.smart = newval
when "settough"; pkmn.tough = newval
when "setsheen"; pkmn.sheen = newval
end
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "teachmove"
move = pbChooseMoveList
if move!=0
pbLearnMove(pkmn,move)
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "forgetmove"
moveindex = pbChooseMove(pkmn,_INTL("Choose move to forget."))
if moveindex>=0
movename = PBMoves.getName(pkmn.moves[moveindex].id)
pkmn.pbDeleteMoveAtIndex(moveindex)
pbDisplay(_INTL("{1} forgot {2}.",pkmn.name,movename))
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "resetmoves"
pkmn.resetMoves
pbDisplay(_INTL("{1}'s moves were reset.",pkmn.name))
pbRefreshSingle(pkmnid)
#===========================================================================
when "setmovepp"
cmd = 0
loop do
commands = []
for i in pkmn.moves
break if i.id==0
if i.totalpp<=0
commands.push(_INTL("{1} (PP: ---)",PBMoves.getName(i.id)))
else
commands.push(_INTL("{1} (PP: {2}/{3})",PBMoves.getName(i.id),i.pp,i.totalpp))
end
end
commands.push(_INTL("Restore all PP"))
cmd = pbShowCommands(_INTL("Alter PP of which move?"),commands,cmd)
break if cmd<0
if cmd>=0 && cmd<commands.length-1 # Move
move = pkmn.moves[cmd]
movename = PBMoves.getName(move.id)
if move.totalpp<=0
pbDisplay(_INTL("{1} has infinite PP.",movename))
else
cmd2 = 0
loop do
msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)",movename,move.pp,move.totalpp,move.ppup)
cmd2 = pbShowCommands(msg,[
_INTL("Set PP"),
_INTL("Full PP"),
_INTL("Set PP Up")],cmd2)
break if cmd2<0
case cmd2
when 0 # Change PP
params = ChooseNumberParams.new
params.setRange(0,move.totalpp)
params.setDefaultValue(move.pp)
h = pbMessageChooseNumber(
_INTL("Set PP of {1} (max. {2}).",movename,move.totalpp),params) { pbUpdate }
move.pp = h
when 1 # Full PP
move.pp = move.totalpp
when 2 # Change PP Up
params = ChooseNumberParams.new
params.setRange(0,3)
params.setDefaultValue(move.ppup)
h = pbMessageChooseNumber(
_INTL("Set PP Up of {1} (max. 3).",movename),params) { pbUpdate }
move.ppup = h
move.pp = move.totalpp if move.pp>move.totalpp
end
end
end
elsif cmd==commands.length-1 # Restore all PP
pkmn.healPP
end
end
#===========================================================================
when "setinitialmoves"
pkmn.pbRecordFirstMoves
pbDisplay(_INTL("{1}'s moves were set as its first-known moves.",pkmn.name))
pbRefreshSingle(pkmnid)
#===========================================================================
when "setability"
cmd = 0
loop do
abils = pkmn.getAbilityList
oldabil = PBAbilities.getName(pkmn.ability)
commands = []
for i in abils
commands.push(((i[1]<2) ? "" : "(H) ")+PBAbilities.getName(i[0]))
end
commands.push(_INTL("Remove override"))
msg = [_INTL("Ability {1} is natural.",oldabil),
_INTL("Ability {1} is being forced.",oldabil)][pkmn.abilityflag!=nil ? 1 : 0]
cmd = pbShowCommands(msg,commands,cmd)
break if cmd<0
if cmd>=0 && cmd<abils.length # Set ability override
pkmn.setAbility(abils[cmd][1])
elsif cmd==abils.length # Remove override
pkmn.abilityflag = nil
end
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "setnature"
commands = []
(PBNatures.getCount).times do |i|
statUp = PBNatures.getStatRaised(i)
statDown = PBNatures.getStatLowered(i)
if statUp!=statDown
text = _INTL("{1} (+{2}, -{3})",PBNatures.getName(i),
PBStats.getNameBrief(statUp),PBStats.getNameBrief(statDown))
else
text = _INTL("{1} (---)",PBNatures.getName(i))
end
commands.push(text)
end
commands.push(_INTL("[Remove override]"))
cmd = pkmn.nature
loop do
oldnature = PBNatures.getName(pkmn.nature)
msg = [_INTL("Nature {1} is natural.",oldnature),
_INTL("Nature {1} is being forced.",oldnature)][pkmn.natureflag ? 1 : 0]
cmd = pbShowCommands(msg,commands,cmd)
break if cmd<0
if cmd>=0 && cmd<PBNatures.getCount # Set nature override
pkmn.setNature(cmd)
pkmn.calcStats
elsif cmd==PBNatures.getCount # Remove override
pkmn.natureflag = nil
end
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "setgender"
if pkmn.singleGendered?
pbDisplay(_INTL("{1} is single-gendered or genderless.",pkmn.speciesName))
else
cmd = 0
loop do
oldgender = (pkmn.male?) ? _INTL("male") : _INTL("female")
msg = [_INTL("Gender {1} is natural.",oldgender),
_INTL("Gender {1} is being forced.",oldgender)][pkmn.genderflag ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Make male"),
_INTL("Make female"),
_INTL("Remove override")],cmd)
break if cmd<0
case cmd
when 0 # Make male
pkmn.makeMale
if !pkmn.male?
pbDisplay(_INTL("{1}'s gender couldn't be changed.",pkmn.name))
end
when 1 # Make female
pkmn.makeFemale
if !pkmn.female?
pbDisplay(_INTL("{1}'s gender couldn't be changed.",pkmn.name))
end
when 2 # Remove override
pkmn.genderflag = nil
end
pbSeenForm(pkmn) if !settingUpBattle
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "speciesform"
cmd = 0
loop do
msg = [_INTL("Species {1}, form {2}.",pkmn.speciesName,pkmn.form),
_INTL("Species {1}, form {2} (forced).",pkmn.speciesName,pkmn.form)][(pkmn.forcedForm!=nil) ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Set species"),
_INTL("Set form"),
_INTL("Remove override")],cmd)
break if cmd<0
case cmd
when 0 # Set species
species = pbChooseSpeciesList(pkmn.species)
if species!=0 && species!=pkmn.species
pkmn.species = species
pbSeenForm(pkmn) if !settingUpBattle
pbRefreshSingle(pkmnid)
end
when 1 # Set form
cmd2 = 0
formcmds = [[],[]]
formdata = pbLoadFormToSpecies
formdata[pkmn.species] = [pkmn.species] if !formdata[pkmn.species]
for form in 0...formdata[pkmn.species].length
fSpecies = pbGetFSpeciesFromForm(pkmn.species,form)
formname = pbGetMessage(MessageTypes::FormNames,fSpecies)
formname = _INTL("Unnamed form") if !formname || formname==""
formname = _INTL("{1}: {2}",form,formname)
formcmds[0].push(form); formcmds[1].push(formname)
cmd2 = form if pkmn.form==form
end
if formcmds[0].length<=1
pbDisplay(_INTL("Species {1} only has one form.",pkmn.speciesName))
else
cmd2 = pbShowCommands(_INTL("Set the Pokémon's form."),formcmds[1],cmd2)
next if cmd2<0
f = formcmds[0][cmd2]
if f!=pkmn.form
if MultipleForms.hasFunction?(pkmn,"getForm")
next if !pbConfirm(_INTL("This species decides its own form. Override?"))
pkmn.forcedForm = f
end
pkmn.form = f
pbSeenForm(pkmn) if !settingUpBattle
pbRefreshSingle(pkmnid)
end
end
when 2 # Remove override
pkmn.forcedForm = nil
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "setshininess"
cmd = 0
loop do
oldshiny = (pkmn.shiny?) ? _INTL("shiny") : _INTL("normal")
msg = [_INTL("Shininess ({1}) is natural.",oldshiny),
_INTL("Shininess ({1}) is being forced.",oldshiny)][pkmn.shinyflag!=nil ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Make shiny"),
_INTL("Make normal"),
_INTL("Remove override")],cmd)
break if cmd<0
case cmd
when 0 # Make shiny
pkmn.makeShiny
when 1 # Make normal
pkmn.makeNotShiny
when 2 # Remove override
pkmn.shinyflag = nil
end
pbRefreshSingle(pkmnid)
end
#===========================================================================
when "setnickname"
cmd = 0
loop do
speciesname = PBSpecies.getName(pkmn.species)
msg = [_INTL("{1} has the nickname {2}.",speciesname,pkmn.name),
_INTL("{1} has no nickname.",speciesname)][pkmn.name==speciesname ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Rename"),
_INTL("Erase name")],cmd)
break if cmd<0
case cmd
when 0 # Rename
oldname = (pkmn.name && pkmn.name!=speciesname) ? pkmn.name : ""
newname = pbEnterPokemonName(_INTL("{1}'s nickname?",speciesname),
0,PokeBattle_Pokemon::MAX_POKEMON_NAME_SIZE,oldname,pkmn)
if newname && newname!=""
pkmn.name = newname
pbRefreshSingle(pkmnid)
end
when 1 # Erase name
pkmn.name = speciesname
pbRefreshSingle(pkmnid)
end
end
#===========================================================================
when "setpokeball"
commands = []; balls = []
for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key])
balls.push([key.to_i,PBItems.getName(item)]) if item && item>0
end
balls.sort! { |a,b| a[1]<=>b[1] }
cmd = 0
for i in 0...balls.length
if balls[i][0]==pkmn.ballused
cmd = i; break
end
end
for i in balls
commands.push(i[1])
end
loop do
oldball = PBItems.getName(pbBallTypeToItem(pkmn.ballused))
cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd)
break if cmd<0
pkmn.ballused = balls[cmd][0]
end
#===========================================================================
when "setribbons"
cmd = 0
loop do
commands = []
for i in 1..PBRibbons.maxValue
commands.push(_INTL("{1} {2}",
(pkmn.hasRibbon?(i)) ? "[Y]" : "[ ]",PBRibbons.getName(i)))
end
commands.push(_INTL("Give all"))
commands.push(_INTL("Clear all"))
cmd = pbShowCommands(_INTL("{1} ribbons.",pkmn.ribbonCount),commands,cmd)
break if cmd<0
if cmd>=0 && cmd<PBRibbons.maxValue # Toggle ribbon
if pkmn.hasRibbon?(cmd+1)
pkmn.takeRibbon(cmd+1)
else
pkmn.giveRibbon(cmd+1)
end
elsif cmd==commands.length-2 # Give all
for i in 1..PBRibbons.maxValue
pkmn.giveRibbon(i)
end
elsif cmd==commands.length-1 # Clear all
for i in 1..PBRibbons.maxValue
pkmn.takeRibbon(i)
end
end
end
#===========================================================================
when "ownership"
cmd = 0
loop do
gender = [_INTL("Male"),_INTL("Female"),_INTL("Unknown")][pkmn.otgender]
msg = [_INTL("Player's Pokémon\n{1}\n{2}\n{3} ({4})",pkmn.ot,gender,pkmn.publicID,pkmn.trainerID),
_INTL("Foreign Pokémon\n{1}\n{2}\n{3} ({4})",pkmn.ot,gender,pkmn.publicID,pkmn.trainerID)
][pkmn.foreign?($Trainer) ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Make player's"),
_INTL("Set OT's name"),
_INTL("Set OT's gender"),
_INTL("Random foreign ID"),
_INTL("Set foreign ID")],cmd)
break if cmd<0
case cmd
when 0 # Make player's
pkmn.trainerID = $Trainer.id
pkmn.ot = $Trainer.name
pkmn.otgender = $Trainer.gender
when 1 # Set OT's name
pkmn.ot = pbEnterPlayerName(_INTL("{1}'s OT's name?",pkmn.name),1,MAX_PLAYER_NAME_SIZE)
when 2 # Set OT's gender
cmd2 = pbShowCommands(_INTL("Set OT's gender."),
[_INTL("Male"),_INTL("Female"),_INTL("Unknown")],pkmn.otgender)
pkmn.otgender = cmd2 if cmd2>=0
when 3 # Random foreign ID
pkmn.trainerID = $Trainer.getForeignID
when 4 # Set foreign ID
params = ChooseNumberParams.new
params.setRange(0,65535)
params.setDefaultValue(pkmn.publicID)
val = pbMessageChooseNumber(
_INTL("Set the new ID (max. 65535)."),params) { pbUpdate }
pkmn.trainerID = val
pkmn.trainerID |= val<<16
end
end
#===========================================================================
when "setegg"
cmd = 0
loop do
msg = [_INTL("Not an egg"),
_INTL("Egg with eggsteps: {1}.",pkmn.eggsteps)][pkmn.egg? ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Make egg"),
_INTL("Make Pokémon"),
_INTL("Set eggsteps to 1")],cmd)
break if cmd<0
case cmd
when 0 # Make egg
if !pkmn.egg? && (pbHasEgg?(pkmn.species) ||
pbConfirm(_INTL("{1} cannot legally be an egg. Make egg anyway?",PBSpecies.getName(pkmn.species))))
pkmn.level = EGG_LEVEL
pkmn.calcStats
pkmn.name = _INTL("Egg")
pkmn.eggsteps = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesStepsToHatch)
pkmn.hatchedMap = 0
pkmn.obtainMode = 1
pbRefreshSingle(pkmnid)
end
when 1 # Make Pokémon
if pkmn.egg?
pkmn.name = PBSpecies.getName(pkmn.species)
pkmn.eggsteps = 0
pkmn.hatchedMap = 0
pkmn.obtainMode = 0
pbRefreshSingle(pkmnid)
end
when 2 # Set eggsteps to 1
pkmn.eggsteps = 1 if pkmn.egg?
end
end
#===========================================================================
when "shadowpkmn"
cmd = 0
loop do
msg = [_INTL("Not a Shadow Pokémon."),
_INTL("Heart gauge is {1} (stage {2}).",pkmn.heartgauge,pkmn.heartStage)
][pkmn.shadowPokemon? ? 1 : 0]
cmd = pbShowCommands(msg,[
_INTL("Make Shadow"),
_INTL("Set heart gauge")],cmd)
break if cmd<0
case cmd
when 0 # Make Shadow
if !pkmn.shadowPokemon?
pkmn.makeShadow
pbRefreshSingle(pkmnid)
else
pbDisplay(_INTL("{1} is already a Shadow Pokémon.",pkmn.name))
end
when 1 # Set heart gauge
if pkmn.shadowPokemon?
oldheart = pkmn.heartgauge
params = ChooseNumberParams.new
params.setRange(0,PokeBattle_Pokemon::HEARTGAUGESIZE)
params.setDefaultValue(pkmn.heartgauge)
val = pbMessageChooseNumber(
_INTL("Set the heart gauge (max. {1}).",PokeBattle_Pokemon::HEARTGAUGESIZE),
params) { pbUpdate }
if val!=oldheart
pkmn.adjustHeart(val-oldheart)
pbReadyToPurify(pkmn)
end
else
pbDisplay(_INTL("{1} is not a Shadow Pokémon.",pkmn.name))
end
end
end
#===========================================================================
when "mysterygift"
pbCreateMysteryGift(0,pkmn)
#===========================================================================
when "duplicate"
if pbConfirm(_INTL("Are you sure you want to copy this Pokémon?"))
clonedpkmn = pkmn.clone
if self.is_a?(PokemonPartyScreen)
pbStorePokemon(clonedpkmn)
pbHardRefresh
pbDisplay(_INTL("The Pokémon was duplicated."))
elsif self.is_a?(PokemonStorageScreen)
if @storage.pbMoveCaughtToParty(clonedpkmn)
if pkmnid[0]!=-1
pbDisplay(_INTL("The duplicated Pokémon was moved to your party."))
end
else
oldbox = @storage.currentBox
newbox = @storage.pbStoreCaught(clonedpkmn)
if newbox<0
pbDisplay(_INTL("All boxes are full."))
elsif newbox!=oldbox
pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"",@storage[newbox].name))
@storage.currentBox = oldbox
end
end
pbHardRefresh
end
return false
end
#===========================================================================
when "delete"
if pbConfirm(_INTL("Are you sure you want to delete this Pokémon?"))
if self.is_a?(PokemonPartyScreen)
@party[pkmnid] = nil
@party.compact!
pbHardRefresh
elsif self.is_a?(PokemonStorageScreen)
@scene.pbRelease(pkmnid,heldpoke)
(heldpoke) ? @heldpkmn = nil : @storage.pbDelete(pkmnid[0],pkmnid[1])
@scene.pbRefresh
end
return false
end
end
return true
end
def pbPokemonDebug(pkmn,pkmnid,heldpoke=nil,settingUpBattle=false)
command = 0
commands = pbPokemonDebugCommands(settingUpBattle)
loop do
command = pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands.list,command)
if command<0
parent = commands.getParent
if parent
commands.currentList = parent[0]
command = parent[1]
else
break
end
else
cmd = commands.getCommand(command)
if commands.hasSubMenu?(cmd)
commands.currentList = cmd
command = 0
else
cont = pbPokemonDebugActions(cmd,pkmn,pkmnid,heldpoke,settingUpBattle)
break if !cont
end
end
end
end
end
class PokemonPartyScreen
include PokemonDebugMixin
end
class PokemonStorageScreen
include PokemonDebugMixin
end
class PokemonDebugPartyScreen
include PokemonDebugMixin
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,618 @@
#===============================================================================
# Core lister script
#===============================================================================
def pbListWindow(cmds,width=Graphics.width/2)
list = Window_CommandPokemon.newWithSize(cmds,0,0,width,Graphics.height)
list.index = 0
list.rowHeight = 24
pbSetSmallFont(list.contents)
list.refresh
return list
end
def pbListScreen(title,lister)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
list = pbListWindow([])
list.viewport = viewport
list.z = 2
title = Window_UnformattedTextPokemon.new(title)
title.x = Graphics.width/2
title.y = 0
title.width = Graphics.width-title.x
title.height = 64
title.viewport = viewport
title.z = 2
lister.setViewport(viewport)
selectedmap = -1
commands = lister.commands
selindex = lister.startIndex
if commands.length==0
value = lister.value(-1)
lister.dispose
title.dispose
list.dispose
viewport.dispose
return value
end
list.commands = commands
list.index = selindex
loop do
Graphics.update
Input.update
list.update
if list.index!=selectedmap
lister.refresh(list.index)
selectedmap = list.index
end
if Input.trigger?(Input::B)
selectedmap = -1
break
elsif Input.trigger?(Input::C) || (list.doubleclick? rescue false)
break
end
end
value = lister.value(selectedmap)
lister.dispose
title.dispose
list.dispose
viewport.dispose
Input.update
return value
end
def pbListScreenBlock(title,lister)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
list = pbListWindow([],Graphics.width/2)
list.viewport = viewport
list.z = 2
title = Window_UnformattedTextPokemon.new(title)
title.x = Graphics.width/2
title.y = 0
title.width = Graphics.width-title.x
title.height = 64
title.viewport = viewport
title.z = 2
lister.setViewport(viewport)
selectedmap = -1
commands = lister.commands
selindex = lister.startIndex
if commands.length==0
value = lister.value(-1)
lister.dispose
title.dispose
list.dispose
viewport.dispose
return value
end
list.commands = commands
list.index = selindex
loop do
Graphics.update
Input.update
list.update
if list.index!=selectedmap
lister.refresh(list.index)
selectedmap = list.index
end
if Input.trigger?(Input::A)
yield(Input::A, lister.value(selectedmap))
list.commands = lister.commands
if list.index==list.commands.length
list.index = list.commands.length
end
lister.refresh(list.index)
elsif Input.trigger?(Input::B)
break
elsif Input.trigger?(Input::C) || (list.doubleclick? rescue false)
yield(Input::C, lister.value(selectedmap))
list.commands = lister.commands
if list.index==list.commands.length
list.index = list.commands.length
end
lister.refresh(list.index)
end
end
lister.dispose
title.dispose
list.dispose
viewport.dispose
Input.update
end
#===============================================================================
# General listers
#===============================================================================
class GraphicsLister
def initialize(folder,selection)
@sprite = IconSprite.new(0,0)
@sprite.bitmap = nil
@sprite.z = 2
@folder = folder
@selection = selection
@commands = []
@index = 0
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.dispose
end
def setViewport(viewport)
@sprite.viewport = viewport
end
def startIndex
return @index
end
def commands
@commands.clear
Dir.chdir(@folder) {
Dir.glob("*.png") { |f| @commands.push(f) }
Dir.glob("*.PNG") { |f| @commands.push(f) }
Dir.glob("*.gif") { |f| @commands.push(f) }
Dir.glob("*.GIF") { |f| @commands.push(f) }
# Dir.glob("*.bmp") { |f| @commands.push(f) }
# Dir.glob("*.BMP") { |f| @commands.push(f) }
# Dir.glob("*.jpg") { |f| @commands.push(f) }
# Dir.glob("*.JPG") { |f| @commands.push(f) }
# Dir.glob("*.jpeg") { |f| @commands.push(f) }
# Dir.glob("*.JPEG") { |f| @commands.push(f) }
}
@commands.sort!
@commands.length.times do |i|
@index = i if @commands[i]==@selection
end
pbMessage(_INTL("There are no files.")) if @commands.length==0
return @commands
end
def value(index)
return (index<0) ? "" : @commands[index]
end
def refresh(index)
return if index<0
@sprite.setBitmap(@folder+@commands[index])
ww = @sprite.bitmap.width
wh = @sprite.bitmap.height
sx = (Graphics.width-256).to_f/ww
sy = (Graphics.height-64).to_f/wh
if sx<1.0 || sy<1.0
if sx>sy
ww = sy*ww
wh = (Graphics.height-64).to_f
else
wh = sx*wh
ww = (Graphics.width-256).to_f
end
end
@sprite.x = (Graphics.width-((Graphics.width-256)/2))-(ww/2)
@sprite.y = (Graphics.height-((Graphics.height-64)/2))-(wh/2)
@sprite.zoom_x = ww*1.0/@sprite.bitmap.width
@sprite.zoom_y = wh*1.0/@sprite.bitmap.height
end
end
class MusicFileLister
def initialize(bgm,setting)
@oldbgm = getPlayingBGM
@commands = []
@bgm = bgm
@setting = setting
@index = 0
end
def dispose
pbPlayBGM(@oldbgm)
end
def setViewport(viewport)
end
def getPlayingBGM
($game_system) ? $game_system.getPlayingBGM : nil
end
def pbPlayBGM(bgm)
(bgm) ? pbBGMPlay(bgm) : pbBGMStop
end
def startIndex
return @index
end
def commands
folder = (@bgm) ? "Audio/BGM/" : "Audio/ME/"
@commands.clear
Dir.chdir(folder) {
Dir.glob("*.mp3") { |f| @commands.push(f) }
Dir.glob("*.MP3") { |f| @commands.push(f) }
Dir.glob("*.ogg") { |f| @commands.push(f) }
Dir.glob("*.OGG") { |f| @commands.push(f) }
Dir.glob("*.wav") { |f| @commands.push(f) }
Dir.glob("*.WAV") { |f| @commands.push(f) }
Dir.glob("*.mid") { |f| @commands.push(f) }
Dir.glob("*.MID") { |f| @commands.push(f) }
Dir.glob("*.midi") { |f| @commands.push(f) }
Dir.glob("*.MIDI") { |f| @commands.push(f) }
}
@commands.sort!
@commands.length.times do |i|
@index = i if @commands[i]==@setting
end
pbMessage(_INTL("There are no files.")) if @commands.length==0
return @commands
end
def value(index)
return (index<0) ? "" : @commands[index]
end
def refresh(index)
return if index<0
if @bgm
pbPlayBGM(@commands[index])
else
pbPlayBGM("../../Audio/ME/"+@commands[index])
end
end
end
class MapLister
def initialize(selmap,addGlobal=false)
@sprite = SpriteWrapper.new
@sprite.bitmap = nil
@sprite.z = 2
@commands = []
@maps = pbMapTree
@addGlobalOffset = (addGlobal) ? 1 : 0
@index = 0
for i in 0...@maps.length
@index = i+@addGlobalOffset if @maps[i][0]==selmap
end
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.dispose
end
def setViewport(viewport)
@sprite.viewport = viewport
end
def startIndex
return @index
end
def commands
@commands.clear
if @addGlobalOffset==1
@commands.push(_INTL("[GLOBAL]"))
end
for i in 0...@maps.length
@commands.push(sprintf("%s%03d %s",(" "*@maps[i][2]),@maps[i][0],@maps[i][1]))
end
return @commands
end
def value(index)
if @addGlobalOffset==1
return 0 if index==0
end
return (index<0) ? -1 : @maps[index-@addGlobalOffset][0]
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
return if index<0
return if index==0 && @addGlobalOffset==1
@sprite.bitmap = createMinimap(@maps[index-@addGlobalOffset][0])
@sprite.x = (Graphics.width-((Graphics.width-256)/2))-(@sprite.bitmap.width/2)
@sprite.y = (Graphics.height-((Graphics.height-64)/2))-(@sprite.bitmap.height/2)
end
end
class SpeciesLister
def initialize(selection,includeNew=false)
@selection = selection
@commands = []
@ids = []
@includeNew = includeNew
@trainers = nil
@index = 0
end
def dispose; end
def setViewport(viewport); end
def startIndex
return @index
end
def commands # Sorted alphabetically
@commands.clear
@ids.clear
cmds = []
for i in 1..PBSpecies.maxValue
cname = getConstantName(PBSpecies,i) rescue next
name = PBSpecies.getName(i)
cmds.push([i,name]) if name && name!=""
end
cmds.sort! { |a,b| a[1]<=>b[1] }
if @includeNew
@commands.push(_INTL("[NEW SPECIES]"))
@ids.push(-1)
end
for i in cmds
@commands.push(sprintf("%03d: %s",i[0],i[1]))
@ids.push(i[0])
end
@index = @selection
@index = @commands.length-1 if @index>=@commands.length
@index = 0 if @index<0
return @commands
end
def value(index)
return nil if index<0
return @ids[index]
end
def refresh(index); end
end
class ItemLister
def initialize(selection,includeNew=false)
@sprite = IconSprite.new(0,0)
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,-1)
@sprite.z = 2
@selection = selection
@commands = []
@ids = []
@includeNew = includeNew
@trainers = nil
@index = 0
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.dispose
end
def setViewport(viewport)
@sprite.viewport = viewport
end
def startIndex
return @index
end
def commands # Sorted alphabetically
@commands.clear
@ids.clear
@itemdata = pbLoadItemsData
cmds = []
for i in 1..PBItems.maxValue
name = @itemdata[i][ITEM_NAME]
if name && name!="" && @itemdata[i][ITEM_POCKET]!=0
cmds.push([i,name])
end
end
cmds.sort! { |a,b| a[1]<=>b[1] }
if @includeNew
@commands.push(_INTL("[NEW ITEM]"))
@ids.push(-1)
end
for i in cmds
@commands.push(sprintf("%03d: %s",i[0],i[1]))
@ids.push(i[0])
end
@index = @selection
@index = @commands.length-1 if @index>=@commands.length
@index = 0 if @index<0
return @commands
end
def value(index)
return nil if index<0
return @ids[index]
end
def refresh(index)
@sprite.item = @ids[index]
end
end
class TrainerTypeLister
def initialize(selection,includeNew)
@sprite = IconSprite.new(0,0)
@sprite.bitmap = nil
@sprite.z = 2
@selection = selection
@commands = []
@ids = []
@includeNew = includeNew
@trainers = nil
@index = 0
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.dispose
end
def setViewport(viewport)
@sprite.viewport = viewport
end
def startIndex
return @index
end
def commands
@commands.clear
@ids.clear
@trainers = pbLoadTrainerTypesData
if @includeNew
@commands.push(_INTL("[NEW TRAINER TYPE]"))
@ids.push(-1)
end
@trainers.length.times do |i|
next if !@trainers[i]
@commands.push(sprintf("%3d: %s",i,@trainers[i][2]))
@ids.push(@trainers[i][0])
end
@commands.length.times do |i|
@index = i if @ids[i]==@selection
end
return @commands
end
def value(index)
return nil if index<0
return [-1] if @ids[index]==-1
return @trainers[@ids[index]]
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
return if index<0
begin
@sprite.setBitmap(pbTrainerSpriteFile(@ids[index]),0)
rescue
@sprite.setBitmap(nil)
end
ww = @sprite.bitmap.width
wh = @sprite.bitmap.height
sx = (Graphics.width-256).to_f()/ww
sy = (Graphics.height-64).to_f()/wh
if sx<1.0 || sy<1.0
if sx>sy
ww = sy*ww
wh = (Graphics.height-64).to_f()
else
wh = sx*wh
ww = (Graphics.width-256).to_f()
end
end
@sprite.x = (Graphics.width-((Graphics.width-256)/2))-(ww/2)
@sprite.y = (Graphics.height-((Graphics.height-64)/2))-(wh/2)
@sprite.zoom_x = ww*1.0/@sprite.bitmap.width
@sprite.zoom_y = wh*1.0/@sprite.bitmap.height
end
end
class TrainerBattleLister
def initialize(selection,includeNew)
@sprite = IconSprite.new
@sprite.bitmap = nil
@sprite.x = Graphics.width*3/4
@sprite.y = (Graphics.height/2)+32
@sprite.z = 2
@pkmnList = Window_UnformattedTextPokemon.new()
@pkmnList.x = Graphics.width/2
@pkmnList.y = Graphics.height-64
@pkmnList.width = Graphics.width/2
@pkmnList.height = 64
@pkmnList.z = 3
@selection = selection
@commands = []
@ids = []
@includeNew = includeNew
@trainers = nil
@index = 0
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@sprite.dispose
@pkmnList.dispose
end
def setViewport(viewport)
@sprite.viewport = viewport
@pkmnList.viewport = viewport
end
def startIndex
return @index
end
def commands
@commands.clear
@ids.clear
@trainers = pbLoadTrainersData
if @includeNew
@commands.push(_INTL("[NEW TRAINER BATTLE]"))
@ids.push(-1)
end
@trainers.length.times do |i|
next if !@trainers[i]
if @trainers[i][4]>0
# TrainerType TrainerName (version) xPartySize
@commands.push(_ISPRINTF("{1:s} {2:s} ({3:d}) x{4:d}",
PBTrainers.getName(@trainers[i][0]),@trainers[i][1],@trainers[i][4],
@trainers[i][3].length))
else
# TrainerType TrainerName xPartySize
@commands.push(_ISPRINTF("{1:s} {2:s} x{3:d}",
PBTrainers.getName(@trainers[i][0]),@trainers[i][1],
@trainers[i][3].length))
end
# Trainer type ID
@ids.push(@trainers[i][0])
end
@index = @selection
@index = @commands.length-1 if @index>=@commands.length
@index = 0 if @index<0
return @commands
end
def value(index)
return nil if index<0
return [-1,nil] if index==0 && @includeNew
realIndex = (@includeNew) ? index-1 : index
return [realIndex,@trainers[realIndex]]
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
return if index<0
begin
@sprite.setBitmap(pbTrainerSpriteFile(@ids[index]),0)
rescue
@sprite.setBitmap(nil)
end
@sprite.ox = @sprite.bitmap.width/2
@sprite.oy = @sprite.bitmap.height
text = ""
if !@includeNew || index>0
@trainers[(@includeNew) ? index-1 : index][3].each_with_index do |p,i|
text += "\r\n" if i>0
text += sprintf("%s Lv.%d",PBSpecies.getName(p[TPSPECIES]),p[TPLEVEL])
end
end
@pkmnList.text = text
@pkmnList.resizeHeightToFit(text,Graphics.width/2)
@pkmnList.y = Graphics.height-@pkmnList.height
end
end

View File

@@ -0,0 +1,549 @@
def pbIsOldSpecialType?(type)
return isConst?(type,PBTypes,:FIRE) ||
isConst?(type,PBTypes,:WATER) ||
isConst?(type,PBTypes,:ICE) ||
isConst?(type,PBTypes,:GRASS) ||
isConst?(type,PBTypes,:ELECTRIC) ||
isConst?(type,PBTypes,:PSYCHIC) ||
isConst?(type,PBTypes,:DRAGON) ||
isConst?(type,PBTypes,:DARK)
end
def pbGetLegalMoves(species)
moves = []
return moves if !species || species<=0
moveset = pbGetSpeciesMoveset(species)
moveset.each { |m| moves.push(m[1]) }
itemData = pbLoadItemsData
tmdat = pbLoadSpeciesTMData
for i in 0...itemData.length
next if !itemData[i]
atk = itemData[i][8]
next if !atk || atk==0
next if !tmdat[atk]
if tmdat[atk].any? { |item| item==species }
moves.push(atk)
end
end
babyspecies = pbGetBabySpecies(species)
eggMoves = pbGetSpeciesEggMoves(babyspecies)
eggMoves.each { |m| moves.push(m) }
moves |= []
return moves
end
def pbSafeCopyFile(x,y,z=nil)
if safeExists?(x)
safetocopy = true
filedata = nil
if safeExists?(y)
different = false
if FileTest.size(x)!=FileTest.size(y)
different = true
else
filedata2 = ""
File.open(x,"rb") { |f| filedata = f.read }
File.open(y,"rb") { |f| filedata2 = f.read }
different = true if filedata!=filedata2
end
if different
safetocopy=pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?",y))
else
# No need to copy
return
end
end
if safetocopy
if !filedata
File.open(x,"rb") { |f| filedata = f.read }
end
File.open((z) ? z : y,"wb") { |f| f.write(filedata) }
end
end
end
def pbAllocateAnimation(animations,name)
for i in 1...animations.length
anim = animations[i]
return i if !anim
# if name && name!="" && anim.name==name
# # use animation with same name
# return i
# end
if anim.length==1 && anim[0].length==2 && anim.name==""
# assume empty
return i
end
end
oldlength = animations.length
animations.resize(10)
return oldlength
end
def pbMapTree
mapinfos = pbLoadRxData("Data/MapInfos")
maplevels = []
retarray = []
for i in mapinfos.keys
info = mapinfos[i]
level = -1
while info
info = mapinfos[info.parent_id]
level += 1
end
if level>=0
info = mapinfos[i]
maplevels.push([i,level,info.parent_id,info.order])
end
end
maplevels.sort! { |a,b|
next a[1]<=>b[1] if a[1]!=b[1] # level
next a[2]<=>b[2] if a[2]!=b[2] # parent ID
next a[3]<=>b[3] # order
}
stack = []
stack.push(0,0)
while stack.length>0
parent = stack[stack.length-1]
index = stack[stack.length-2]
if index>=maplevels.length
stack.pop
stack.pop
next
end
maplevel = maplevels[index]
stack[stack.length-2] += 1
if maplevel[2]!=parent
stack.pop
stack.pop
next
end
retarray.push([maplevel[0],mapinfos[maplevel[0]].name,maplevel[1]])
for i in index+1...maplevels.length
if maplevels[i][2]==maplevel[0]
stack.push(i)
stack.push(maplevel[0])
break
end
end
end
return retarray
end
#===============================================================================
# Make up internal names for things based on their actual names
#===============================================================================
module MakeshiftConsts
@@consts = []
def self.get(c,i,modname=nil)
@@consts[c] = [] if !@@consts[c]
return @@consts[c][i] if @@consts[c][i]
if modname
v = getConstantName(modname,i) rescue nil
if v
@@consts[c][i] = v
return v
end
end
trname = pbGetMessage(c,i)
trconst = trname.gsub(/é/,"e")
trconst = trconst.upcase
trconst = trconst.gsub(//,"fE")
trconst = trconst.gsub(//,"mA")
trconst = trconst.gsub(/[^A-Za-z0-9_]/,"")
if trconst.length==0
return nil if trname.length==0
trconst = sprintf("T_%03d",i)
elsif !trconst[0,1][/[A-Z]/]
trconst = "T_"+trconst
end
while @@consts[c].include?(trconst)
trconst = sprintf("%s_%03d",trconst,i)
end
@@consts[c][i] = trconst
return trconst
end
end
def pbGetTypeConst(i)
ret = MakeshiftConsts.get(MessageTypes::Types,i,PBTypes)
if !ret
ret = ["NORMAL","FIGHTING","FLYING","POISON","GROUND",
"ROCK","BUG","GHOST","STEEL","QMARKS",
"FIRE","WATER","GRASS","ELECTRIC","PSYCHIC",
"ICE","DRAGON","DARK"][i]
end
return ret
end
def pbGetEvolutionConst(i)
ret = MakeshiftConsts.get(50,i,PBEvolution)
if !ret
ret = ["None",
"Happiness","HappinessDay","HappinessNight","Level","Trade",
"TradeItem","Item","AttackGreater","AtkDefEqual","DefenseGreater",
"Silcoon","Cascoon","Ninjask","Shedinja","Beauty",
"ItemMale","ItemFemale","DayHoldItem","NightHoldItem","HasMove",
"HasInParty","LevelMale","LevelFemale","Location","TradeSpecies",
"Custom1","Custom2","Custom3","Custom4","Custom5"]
i = 0 if i>=ret.length || i<0
ret = ret[i]
end
return ret
end
def pbGetEggGroupConst(i)
ret = MakeshiftConsts.get(51,i,PBEggGroups)
if !ret
ret = ["Undiscovered",
"Monster","Water1","Bug","Flying","Field",
"Fairy","Grass","Humanlike","Water3","Mineral",
"Amorphous","Water2","Ditto","Dragon"][i]
i = 0 if i>=ret.length || i<0
ret = ret[i]
end
return ret
end
def pbGetColorConst(i)
ret = MakeshiftConsts.get(52,i,PBColors)
if !ret
ret = ["Red","Blue","Yellow","Green","Black","Brown","Purple","Gray","White","Pink"]
i = 0 if i>=ret.length || i<0
ret = ret[i]
end
return ret
end
def pbGetGenderConst(i)
ret = MakeshiftConsts.get(53,i,PBGenderRates)
if !ret
ret = ["Genderless","AlwaysMale","FemaleOneEighth","Female25Percent",
"Female50Percent","Female75Percent","FemaleSevenEighths",
"AlwaysFemale"]
i = 0 if i>=ret.length || i<0
ret = ret[i]
end
return ret
end
def pbGetAbilityConst(i)
return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
end
def pbGetMoveConst(i)
return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
end
def pbGetItemConst(i)
return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
end
def pbGetSpeciesConst(i)
return MakeshiftConsts.get(MessageTypes::Species,i,PBSpecies)
end
def pbGetTrainerConst(i)
return MakeshiftConsts.get(MessageTypes::TrainerTypes,i,PBTrainers)
end
#===============================================================================
# List all members of a class
#===============================================================================
# Displays a list of all Pokémon species, and returns the ID of the species
# selected (or 0 if the selection was canceled). "default", if specified, is the
# ID of the species to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical.
def pbChooseSpeciesList(default=0)
commands = []
for i in 1..PBSpecies.maxValue
cname = getConstantName(PBSpecies,i) rescue nil
commands.push([i,PBSpecies.getName(i)]) if cname
end
return pbChooseList(commands,default,-1)
end
# Displays an alphabetically sorted list of all moves, and returns the ID of the
# move selected (or 0 if the selection was canceled). "default", if specified,
# is the ID of the move to initially select.
def pbChooseMoveList(default=0)
commands = []
for i in 1..PBMoves.maxValue
cname = getConstantName(PBMoves,i) rescue nil
commands.push([i,PBMoves.getName(i)]) if cname
end
return pbChooseList(commands,default)
end
def pbChooseMoveListForSpecies(species,defaultMoveID=0)
cmdwin = pbListWindow([],200)
commands = []
moveDefault = 0
legalMoves = pbGetLegalMoves(species)
for move in legalMoves
commands.push([move,PBMoves.getName(move)])
end
commands.sort! { |a,b| a[1]<=>b[1] }
if defaultMoveID>0
commands.each_with_index do |item,i|
moveDefault = i if moveDefault==0 && i[0]==defaultMoveID
end
end
commands2 = []
for i in 1..PBMoves.maxValue
if PBMoves.getName(i)!=nil && PBMoves.getName(i)!=""
commands2.push([i,PBMoves.getName(i)])
end
end
commands2.sort! { |a,b| a[1]<=>b[1] }
if defaultMoveID>0
commands2.each_with_index do |item,i|
moveDefault = i if moveDefault==0 && i[0]==defaultMoveID
end
end
commands.concat(commands2)
realcommands = []
for command in commands
realcommands.push("#{command[1]}")
end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
cmdwin.dispose
return (ret>=0) ? commands[ret][0] : 0
end
# Displays an alphabetically sorted list of all types, and returns the ID of the
# type selected (or 0 if the selection was canceled). "default", if specified,
# is the ID of the type to initially select.
def pbChooseTypeList(default=0)
commands = []
for i in 0..PBTypes.maxValue
cname = getConstantName(PBTypes,i) rescue nil
commands.push([i,PBTypes.getName(i)]) if cname && !PBTypes.isPseudoType?(i)
end
return pbChooseList(commands,default)
end
# Displays a list of all items, and returns the ID of the item selected (or 0 if
# the selection was canceled). "default", if specified, is the ID of the item to
# initially select. Pressing Input::A will toggle the list sorting between
# numerical and alphabetical.
def pbChooseItemList(default=0)
commands = []
for i in 1..PBItems.maxValue
cname = getConstantName(PBItems,i) rescue nil
commands.push([i,PBItems.getName(i)]) if cname
end
return pbChooseList(commands,default,-1)
end
# Displays a list of all abilities, and returns the ID of the ability selected
# (or 0 if the selection was canceled). "default", if specified, is the ID of
# the ability to initially select. Pressing Input::A will toggle the list
# sorting between numerical and alphabetical.
def pbChooseAbilityList(default=0)
commands = []
for i in 1..PBAbilities.maxValue
cname = getConstantName(PBAbilities,i) rescue nil
commands.push([i,PBAbilities.getName(i)]) if cname
end
return pbChooseList(commands,default,-1)
end
def pbChooseBallList(defaultMoveID=-1)
cmdwin = pbListWindow([],200)
commands = []
moveDefault = 0
for key in $BallTypes.keys
item = getID(PBItems,$BallTypes[key])
commands.push([key,item,PBItems.getName(item)]) if item && item>0
end
commands.sort! { |a,b| a[2]<=>b[2] }
if defaultMoveID>=0
for i in 0...commands.length
moveDefault = i if defaultMoveID==commands[i][0]
end
end
realcommands = []
for i in commands
realcommands.push(i[2])
end
ret = pbCommands2(cmdwin,realcommands,-1,moveDefault,true)
cmdwin.dispose
return (ret>=0) ? commands[ret][0] : defaultMoveID
end
#===============================================================================
# General list methods
#===============================================================================
def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false)
cmdwindow.commands = commands
cmdwindow.index = defaultindex if defaultindex>=0
cmdwindow.x = 0
cmdwindow.y = 0
if !noresize
cmdwindow.width = 256
else
cmdwindow.height = Graphics.height
end
cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.active = true
ret = 0
command = 0
loop do
Graphics.update
Input.update
cmdwindow.update
if Input.trigger?(Input::B)
if cmdIfCancel>0
command = cmdIfCancel-1
break
elsif cmdIfCancel<0
command = cmdIfCancel
break
end
elsif Input.trigger?(Input::C) || (cmdwindow.doubleclick? rescue false)
command = cmdwindow.index
break
end
end
ret = command
cmdwindow.active = false
return ret
end
def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex=-1,noresize=false)
cmdwindow.commands = commands
cmdwindow.index = defaultindex if defaultindex>=0
cmdwindow.x = 0
cmdwindow.y = 0
if !noresize
cmdwindow.width = 256
else
cmdwindow.height = Graphics.height
end
cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.active = true
ret = []
command = 0
loop do
Graphics.update
Input.update
cmdwindow.update
if Input.trigger?(Input::F5)
command = [5,cmdwindow.index]
break
elsif Input.press?(Input::A)
if Input.repeat?(Input::UP)
command = [1,cmdwindow.index]
break
elsif Input.repeat?(Input::DOWN)
command = [2,cmdwindow.index]
break
elsif Input.press?(Input::LEFT)
command = [3,cmdwindow.index]
break
elsif Input.press?(Input::RIGHT)
command = [4,cmdwindow.index]
break
end
elsif Input.trigger?(Input::B)
if cmdIfCancel>0
command = [0,cmdIfCancel-1]
break
elsif cmdIfCancel<0
command = [0,cmdIfCancel]
break
end
elsif Input.trigger?(Input::C) || (cmdwindow.doubleclick? rescue false)
command = [0,cmdwindow.index]
break
end
end
ret = command
cmdwindow.active = false
return ret
end
def pbChooseList(commands,default=0,sortType=1)
cmdwin = pbListWindow([])
itemID = default
itemIndex = 0
sortMode = (sortType>=0) ? sortType : 0 # 0=ID, 1=alphabetical
sorting = true
loop do
if sorting
if sortMode==0
commands.sort! { |a,b| a[0]<=>b[0] }
elsif sortMode==1
commands.sort! { |a,b| a[1]<=>b[1] }
end
if itemID>0
commands.each_with_index { |command,i| itemIndex = i if command[0]==itemID }
end
realcommands = []
for command in commands
if sortType<0 || sortType==0
realcommands.push(sprintf("%03d: %s",command[0],command[1]))
else
realcommands.push(command[1])
end
end
sorting = false
end
cmd = pbCommandsSortable(cmdwin,realcommands,-1,itemIndex,(sortType<0))
if cmd[0]==0 # Chose an option or cancelled
itemID = (cmd[1]<0) ? 0 : commands[cmd[1]][0]
break
elsif cmd[0]==1 # Toggle sorting
itemID = commands[cmd[1]][0]
sortMode = (sortMode+1)%2
sorting = true
end
end
cmdwin.dispose
return (itemID>0) ? itemID : 0
end
def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex=-1,sortable=false)
cmdwindow.commands = commands
cmdwindow.index = defaultindex if defaultindex>=0
cmdwindow.x = 0
cmdwindow.y = 0
cmdwindow.width = 256 if cmdwindow.width<256
cmdwindow.height = Graphics.height
cmdwindow.z = 99999
cmdwindow.active = true
ret = nil
command = 0
loop do
Graphics.update
Input.update
cmdwindow.update
if Input.trigger?(Input::A) && sortable
command = [1,cmdwindow.index]
break
elsif Input.trigger?(Input::B)
command = [0,(cmdIfCancel>0) ? cmdIfCancel-1 : cmdIfCancel]
break
elsif Input.trigger?(Input::C) || (cmdwindow.doubleclick? rescue false)
command = [0,cmdwindow.index]
break
end
end
ret = command
cmdwindow.active = false
return ret
end

View File

@@ -0,0 +1,209 @@
#===============================================================================
# Edits the terrain tags of tiles in tilesets.
#===============================================================================
begin
def pbTilesetWrapper
return PokemonDataWrapper.new(
"Data/Tilesets.rxdata",
"Data/TilesetsTemp.rxdata",
Proc.new{
pbMessage(_INTL("The editor has detected that the tileset data was recently edited in RPG Maker XP."))
next !pbConfirmMessage(_INTL("Do you want to load those recent edits?"))
}
)
end
class PokemonTilesetScene
def pbUpdateTileset
@sprites["overlay"].bitmap.clear
textpos = []
@sprites["tileset"].src_rect = Rect.new(0,@topy,256,Graphics.height-64)
tilesize = @tileset.terrain_tags.xsize
for yy in 0...(Graphics.height-64)/32
ypos = (yy+(@topy/32))*8+384
next if ypos>=tilesize
for xx in 0...8
terr = ypos<384 ? @tileset.terrain_tags[xx*48] : @tileset.terrain_tags[ypos+xx]
if ypos<384
@tilehelper.bltTile(@sprites["overlay"].bitmap,xx*32,yy*32,xx*48)
end
textpos.push(["#{terr}",xx*32+16,yy*32,2,Color.new(80,80,80),Color.new(192,192,192)])
end
end
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy,32,4,Color.new(255,0,0))
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy,4,32,Color.new(255,0,0))
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy+28,32,4,Color.new(255,0,0))
@sprites["overlay"].bitmap.fill_rect(@x+28,@y-@topy,4,32,Color.new(255,0,0))
pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
end
def pbGetSelected(x,y)
return (y<0) ? 48*(x/32) : (y/32)*8+384+(x/32)
end
def pbSetSelected(i,value)
if i<384
for j in 0...48
@tileset.terrain_tags[i+j] = value
end
else
@tileset.terrain_tags[i] = value
end
end
def pbChooseTileset
commands = []
for i in 1...@tilesetwrapper.data.length
commands.push(sprintf("%03d %s",i,@tilesetwrapper.data[i].name))
end
ret = pbShowCommands(nil,commands,-1)
if ret>=0
@tileset = @tilesetwrapper.data[ret+1]
@tilehelper.dispose
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
@x = 0
@y = -32
@topy = -32
pbUpdateTileset
end
end
def pbStartScene
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
@tilesetwrapper = pbTilesetWrapper
@tileset = @tilesetwrapper.data[1]
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
@sprites = {}
@sprites["title"] = Window_UnformattedTextPokemon.new(_INTL("Tileset Editor (PgUp/PgDn: SCROLL; Z: MENU)"))
@sprites["title"].viewport = @viewport
@sprites["title"].x = 0
@sprites["title"].y = 0
@sprites["title"].width = Graphics.width
@sprites["title"].height = 64
@sprites["tileset"] = IconSprite.new(0,64,@viewport)
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
@sprites["tileset"].src_rect = Rect.new(0,0,256,Graphics.height-64)
@sprites["overlay"] = BitmapSprite.new(256,Graphics.height-64,@viewport)
@sprites["overlay"].x = 0
@sprites["overlay"].y = 64
pbSetSystemFont(@sprites["overlay"].bitmap)
@sprites["title"].visible = true
@sprites["tileset"].visible = true
@sprites["overlay"].visible = true
@x = 0
@y = -32
@topy = -32
pbUpdateTileset
pbFadeInAndShow(@sprites)
height = @sprites["tileset"].bitmap.height
########
loop do
Graphics.update
Input.update
if Input.repeat?(Input::UP)
@y -= 32
@y = -32 if @y<-32
@topy = @y if @y<@topy
pbUpdateTileset
elsif Input.repeat?(Input::DOWN)
@y += 32
@y = @sprites["tileset"].bitmap.height-32 if @y>=@sprites["tileset"].bitmap.height-32
@topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64
pbUpdateTileset
elsif Input.repeat?(Input::LEFT)
@x -= 32
@x = 0 if @x<0
pbUpdateTileset
elsif Input.repeat?(Input::RIGHT)
@x += 32
@x = 256-32 if @x>=256-32
pbUpdateTileset
elsif Input.repeat?(Input::L)
@y -= ((Graphics.height-64)/32)*32
@topy -= ((Graphics.height-64)/32)*32
@y = -32 if @y<-32
@topy = @y if @y<@topy
@topy = -32 if @topy<-32
pbUpdateTileset
elsif Input.repeat?(Input::R)
@y += ((Graphics.height-64)/32)*32
@topy += ((Graphics.height-64)/32)*32
@y = @sprites["tileset"].bitmap.height-32 if @y>=@sprites["tileset"].bitmap.height-32
@topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64
if @topy>=@sprites["tileset"].bitmap.height-(Graphics.height-64)
@topy = @sprites["tileset"].bitmap.height-(Graphics.height-64)
end
pbUpdateTileset
elsif Input.trigger?(Input::A)
commands = [
_INTL("Go to bottom"),
_INTL("Go to top"),
_INTL("Change tileset"),
_INTL("Cancel")
]
ret = pbShowCommands(nil,commands,-1)
case ret
when 0
@y = @sprites["tileset"].bitmap.height-32
@topy = @y-(Graphics.height-64)+32 if @y-@topy>=Graphics.height-64
pbUpdateTileset
when 1
@y = -32
@topy = @y if @y<@topy
pbUpdateTileset
when 2
pbChooseTileset
end
elsif Input.trigger?(Input::B)
if pbConfirmMessage(_INTL("Save changes?"))
@tilesetwrapper.save
$data_tilesets = @tilesetwrapper.data
if $game_map && $MapFactory
$MapFactory.setup($game_map.map_id)
$game_player.center($game_player.x,$game_player.y)
if $scene.is_a?(Scene_Map)
$scene.disposeSpritesets
$scene.createSpritesets
end
end
pbMessage(_INTL("To ensure that the changes remain, close and reopen RPG Maker XP."))
end
break if pbConfirmMessage(_INTL("Exit from the editor?"))
elsif Input.trigger?(Input::C)
selected = pbGetSelected(@x,@y)
params = ChooseNumberParams.new
params.setRange(0,99)
params.setDefaultValue(@tileset.terrain_tags[selected])
pbSetSelected(selected,pbMessageChooseNumber(_INTL("Set the terrain tag."),params))
pbUpdateTileset
end
end
########
pbFadeOutAndHide(@sprites)
pbDisposeSpriteHash(@sprites)
@viewport.dispose
@tilehelper.dispose
end
end
def pbTilesetScreen
pbFadeOutIn {
scene = PokemonTilesetScene.new
scene.pbStartScene
}
end
rescue Exception
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
raise $!
end
end

View File

@@ -0,0 +1,813 @@
#===============================================================================
# Miniature game map/Town Map drawing
#===============================================================================
class MapSprite
def initialize(map,viewport=nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=createMinimap(map)
@sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2)
@sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2)
end
def dispose
@sprite.bitmap.dispose
@sprite.dispose
end
def z=(value)
@sprite.z=value
end
def getXY
return nil if !Input.triggerex?(Input::LeftMouseKey)
mouse = Mouse::getMousePos(true)
return nil if !mouse
if mouse[0]<@sprite.x || mouse[0]>=@sprite.x+@sprite.bitmap.width
return nil
end
if mouse[1]<@sprite.y || mouse[1]>=@sprite.y+@sprite.bitmap.height
return nil
end
x = mouse[0]-@sprite.x
y = mouse[1]-@sprite.y
return [x/4,y/4]
end
end
class SelectionSprite < Sprite
def initialize(viewport=nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=nil
@sprite.z=2
@othersprite=nil
end
def disposed?
return @sprite.disposed?
end
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@othersprite=nil
@sprite.dispose
end
def othersprite=(value)
@othersprite=value
if @othersprite && !@othersprite.disposed? &&
@othersprite.bitmap && !@othersprite.bitmap.disposed?
@sprite.bitmap=pbDoEnsureBitmap(
@sprite.bitmap,@othersprite.bitmap.width,@othersprite.bitmap.height)
red=Color.new(255,0,0)
@sprite.bitmap.clear
@sprite.bitmap.fill_rect(0,0,@othersprite.bitmap.width,2,red)
@sprite.bitmap.fill_rect(0,@othersprite.bitmap.height-2,
@othersprite.bitmap.width,2,red)
@sprite.bitmap.fill_rect(0,0,2,@othersprite.bitmap.height,red)
@sprite.bitmap.fill_rect(@othersprite.bitmap.width-2,0,2,
@othersprite.bitmap.height,red)
end
end
def update
if @othersprite && !@othersprite.disposed?
@sprite.visible=@othersprite.visible
@sprite.x=@othersprite.x
@sprite.y=@othersprite.y
else
@sprite.visible=false
end
end
end
class RegionMapSprite
def initialize(map,viewport=nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=createRegionMap(map)
@sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2)
@sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2)
end
def dispose
@sprite.bitmap.dispose
@sprite.dispose
end
def z=(value)
@sprite.z=value
end
def getXY
return nil if !Input.triggerex?(Input::LeftMouseKey)
mouse=Mouse::getMousePos(true)
return nil if !mouse
if mouse[0]<@sprite.x||mouse[0]>=@sprite.x+@sprite.bitmap.width
return nil
end
if mouse[1]<@sprite.y||mouse[1]>=@sprite.y+@sprite.bitmap.height
return nil
end
x=mouse[0]-@sprite.x
y=mouse[1]-@sprite.y
return [x/8,y/8]
end
end
def createRegionMap(map)
@mapdata = pbLoadTownMapData
@map=@mapdata[map]
bitmap=AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}").deanimate
retbitmap=BitmapWrapper.new(bitmap.width/2,bitmap.height/2)
retbitmap.stretch_blt(
Rect.new(0,0,bitmap.width/2,bitmap.height/2),
bitmap,
Rect.new(0,0,bitmap.width,bitmap.height)
)
bitmap.dispose
return retbitmap
end
def getMapNameList
@mapdata = pbLoadTownMapData
ret=[]
for i in 0...@mapdata.length
next if !@mapdata[i]
ret.push(
[i,pbGetMessage(MessageTypes::RegionNames,i)]
)
end
return ret
end
def createMinimap2(mapid)
map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
return BitmapWrapper.new(32,32) if !map
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
black=Color.new(0,0,0)
bigmap=(map.width>40 && map.height>40)
tilesets=load_data("Data/Tilesets.rxdata")
tileset=tilesets[map.tileset_id]
return bitmap if !tileset
helper=TileDrawingHelper.fromTileset(tileset)
for y in 0...map.height
for x in 0...map.width
if bigmap
next if (x>8 && x<=map.width-8 && y>8 && y<=map.height-8)
end
for z in 0..2
id=map.data[x,y,z]
next if id==0 || !id
helper.bltSmallTile(bitmap,x*4,y*4,4,4,id)
end
end
end
bitmap.fill_rect(0,0,bitmap.width,1,black)
bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black)
bitmap.fill_rect(0,0,1,bitmap.height,black)
bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black)
return bitmap
end
def createMinimap(mapid)
map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil
return BitmapWrapper.new(32,32) if !map
bitmap=BitmapWrapper.new(map.width*4,map.height*4)
black=Color.new(0,0,0)
tilesets=load_data("Data/Tilesets.rxdata")
tileset=tilesets[map.tileset_id]
return bitmap if !tileset
helper=TileDrawingHelper.fromTileset(tileset)
for y in 0...map.height
for x in 0...map.width
for z in 0..2
id=map.data[x,y,z]
id=0 if !id
helper.bltSmallTile(bitmap,x*4,y*4,4,4,id)
end
end
end
bitmap.fill_rect(0,0,bitmap.width,1,black)
bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black)
bitmap.fill_rect(0,0,1,bitmap.height,black)
bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black)
return bitmap
end
def chooseMapPoint(map,rgnmap=false)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=99999
title=Window_UnformattedTextPokemon.new(_INTL("Click a point on the map."))
title.x=0
title.y=Graphics.height-64
title.width=Graphics.width
title.height=64
title.viewport=viewport
title.z=2
if rgnmap
sprite=RegionMapSprite.new(map,viewport)
else
sprite=MapSprite.new(map,viewport)
end
sprite.z=2
ret=nil
loop do
Graphics.update
Input.update
xy=sprite.getXY
if xy
ret=xy
break
end
if Input.trigger?(Input::B)
ret=nil
break
end
end
sprite.dispose
title.dispose
return ret
end
#===============================================================================
# Visual Editor (map connections)
#===============================================================================
class MapScreenScene
GLOBALMETADATA=[
["Home",MapCoordsFacingProperty,
_INTL("Map ID and X and Y coordinates of where the player goes if no Pokémon Center was entered after a loss.")],
["WildBattleBGM",BGMProperty,
_INTL("Default BGM for wild Pokémon battles.")],
["TrainerBattleBGM",BGMProperty,
_INTL("Default BGM for Trainer battles.")],
["WildVictoryME",MEProperty,
_INTL("Default ME played after winning a wild Pokémon battle.")],
["TrainerVictoryME",MEProperty,
_INTL("Default ME played after winning a Trainer battle.")],
["WildCaptureME",MEProperty,
_INTL("Default ME played after catching a Pokémon.")],
["SurfBGM",BGMProperty,
_INTL("BGM played while surfing.")],
["BicycleBGM",BGMProperty,
_INTL("BGM played while on a bicycle.")],
["PlayerA",PlayerProperty,
_INTL("Specifies player A.")],
["PlayerB",PlayerProperty,
_INTL("Specifies player B.")],
["PlayerC",PlayerProperty,
_INTL("Specifies player C.")],
["PlayerD",PlayerProperty,
_INTL("Specifies player D.")],
["PlayerE",PlayerProperty,
_INTL("Specifies player E.")],
["PlayerF",PlayerProperty,
_INTL("Specifies player F.")],
["PlayerG",PlayerProperty,
_INTL("Specifies player G.")],
["PlayerH",PlayerProperty,
_INTL("Specifies player H.")]
]
LOCALMAPS = [
["Outdoor",BooleanProperty,
_INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
["ShowArea",BooleanProperty,
_INTL("If true, the game will display the map's name upon entry.")],
["Bicycle",BooleanProperty,
_INTL("If true, the bicycle can be used on this map.")],
["BicycleAlways",BooleanProperty,
_INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
["HealingSpot",MapCoordsProperty,
_INTL("Map ID of this Pokémon Center's town, and X and Y coordinates of its entrance within that town.")],
["Weather",WeatherEffectProperty,
_INTL("Weather conditions in effect for this map.")],
["MapPosition",RegionMapCoordsProperty,
_INTL("Identifies the point on the regional map for this map.")],
["DiveMap",MapProperty,
_INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")],
["DarkMap",BooleanProperty,
_INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")],
["SafariMap",BooleanProperty,
_INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")],
["SnapEdges",BooleanProperty,
_INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")],
["Dungeon",BooleanProperty,
_INTL("If true, this map has a randomly generated layout. See the wiki for more information.")],
["BattleBack",StringProperty,
_INTL("PNG files named 'XXX_bg', 'XXX_base0', 'XXX_base1', 'XXX_message' in Battlebacks folder, where XXX is this property's value.")],
["WildBattleBGM",BGMProperty,
_INTL("Default BGM for wild Pokémon battles on this map.")],
["TrainerBattleBGM",BGMProperty,
_INTL("Default BGM for trainer battles on this map.")],
["WildVictoryME",MEProperty,
_INTL("Default ME played after winning a wild Pokémon battle on this map.")],
["TrainerVictoryME",MEProperty,
_INTL("Default ME played after winning a Trainer battle on this map.")],
["WildCaptureME",MEProperty,
_INTL("Default ME played after catching a wild Pokémon on this map.")],
["MapSize",MapSizeProperty,
_INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")],
["Environment",EnvironmentProperty,
_INTL("The default battle environment for battles on this map.")]
]
def getMapSprite(id)
if !@mapsprites[id]
@mapsprites[id]=Sprite.new(@viewport)
@mapsprites[id].z=0
@mapsprites[id].bitmap=nil
end
if !@mapsprites[id].bitmap || @mapsprites[id].bitmap.disposed?
@mapsprites[id].bitmap=createMinimap(id)
end
return @mapsprites[id]
end
def close
pbDisposeSpriteHash(@sprites)
pbDisposeSpriteHash(@mapsprites)
@viewport.dispose
end
def setMapSpritePos(id,x,y)
sprite=getMapSprite(id)
sprite.x=x
sprite.y=y
sprite.visible=true
end
def putNeighbors(id,sprites)
conns=@mapconns
mapsprite=getMapSprite(id)
dispx=mapsprite.x
dispy=mapsprite.y
for conn in conns
if conn[0]==id
b=sprites.any? { |i| i==conn[3] }
if !b
x=(conn[1]-conn[4])*4+dispx
y=(conn[2]-conn[5])*4+dispy
setMapSpritePos(conn[3],x,y)
sprites.push(conn[3])
putNeighbors(conn[3],sprites)
end
elsif conn[3]==id
b=sprites.any? { |i| i==conn[0] }
if !b
x=(conn[4]-conn[1])*4+dispx
y=(conn[5]-conn[2])*4+dispy
setMapSpritePos(conn[0],x,y)
sprites.push(conn[3])
putNeighbors(conn[0],sprites)
end
end
end
end
def hasConnections?(conns,id)
for conn in conns
return true if conn[0]==id || conn[3]==id
end
return false
end
def connectionsSymmetric?(conn1,conn2)
if conn1[0]==conn2[0]
# Equality
return false if conn1[1]!=conn2[1]
return false if conn1[2]!=conn2[2]
return false if conn1[3]!=conn2[3]
return false if conn1[4]!=conn2[4]
return false if conn1[5]!=conn2[5]
return true
elsif conn1[0]==conn2[3]
# Symmetry
return false if conn1[1]!=-conn2[1]
return false if conn1[2]!=-conn2[2]
return false if conn1[3]!=conn2[0]
return false if conn1[4]!=-conn2[4]
return false if conn1[5]!=-conn2[5]
return true
end
return false
end
def removeOldConnections(ret,mapid)
for i in 0...ret.length
ret[i]=nil if ret[i][0]==mapid || ret[i][3]==mapid
end
ret.compact!
end
# Returns the maps within _keys_ that are directly connected to this map, _map_.
def getDirectConnections(keys,map)
thissprite=getMapSprite(map)
thisdims=MapFactoryHelper.getMapDims(map)
ret=[]
for i in keys
next if i==map
othersprite=getMapSprite(i)
otherdims=MapFactoryHelper.getMapDims(i)
x1=(thissprite.x-othersprite.x)/4
y1=(thissprite.y-othersprite.y)/4
if (x1==otherdims[0] || x1==-thisdims[0] ||
y1==otherdims[1] || y1==-thisdims[1])
ret.push(i)
end
end
# If no direct connections, add an indirect connection
if ret.length==0
key=(map==keys[0]) ? keys[1] : keys[0]
ret.push(key)
end
return ret
end
def generateConnectionData
ret=[]
# Create a clone of current map connection
for conn in @mapconns
ret.push(conn.clone)
end
keys=@mapsprites.keys
return ret if keys.length<2
# Remove all connections containing any sprites on the canvas from the array
for i in keys
removeOldConnections(ret,i)
end
# Rebuild connections
for i in keys
refs=getDirectConnections(keys,i)
for refmap in refs
othersprite=getMapSprite(i)
refsprite=getMapSprite(refmap)
c1=(refsprite.x-othersprite.x)/4
c2=(refsprite.y-othersprite.y)/4
conn=[refmap,0,0,i,c1,c2]
j=0;while j<ret.length && !connectionsSymmetric?(ret[j],conn)
j+=1
end
if j==ret.length
ret.push(conn)
end
end
end
return ret
end
def serializeConnectionData
conndata=generateConnectionData()
pbSerializeConnectionData(conndata,@mapinfos)
@mapconns=conndata
end
def putSprite(id)
addSprite(id)
putNeighbors(id,[])
end
def addSprite(id)
mapsprite=getMapSprite(id)
x=(Graphics.width-mapsprite.bitmap.width)/2
y=(Graphics.height-mapsprite.bitmap.height)/2
mapsprite.x=x.to_i&~3
mapsprite.y=y.to_i&~3
end
def saveMapSpritePos
@mapspritepos.clear
for i in @mapsprites.keys
s=@mapsprites[i]
@mapspritepos[i]=[s.x,s.y] if s && !s.disposed?
end
end
def mapScreen
@sprites={}
@mapsprites={}
@mapspritepos={}
@viewport=Viewport.new(0,0,800,600)
@viewport.z=99999
@lasthitmap=-1
@lastclick=-1
@oldmousex=nil
@oldmousey=nil
@dragging=false
@dragmapid=-1
@dragOffsetX=0
@dragOffsetY=0
@selmapid=-1
addBackgroundPlane(@sprites,"background","Trainer Card/bg",@viewport)
@sprites["selsprite"]=SelectionSprite.new(@viewport)
@sprites["title"]=Window_UnformattedTextPokemon.new(_INTL("F: Help"))
@sprites["title"].x=0
@sprites["title"].y=600-64
@sprites["title"].width=800
@sprites["title"].height=64
@sprites["title"].viewport=@viewport
@sprites["title"].z=2
@mapinfos=load_data("Data/MapInfos.rxdata")
@encdata=pbLoadEncountersData
conns=MapFactoryHelper.getMapConnections
@mapconns=[]
for c in conns
@mapconns.push(c.clone)
end
@metadata=pbLoadMetadata
if $game_map
@currentmap=$game_map.map_id
else
system=load_data("Data/System.rxdata")
@currentmap=system.edit_map_id
end
putSprite(@currentmap)
end
def setTopSprite(id)
for i in @mapsprites.keys
if i==id
@mapsprites[i].z=1
else
@mapsprites[i].z=0
end
end
end
def getMetadata(mapid,metadataType)
return @metadata[mapid][metadataType] if @metadata[mapid]
end
def setMetadata(mapid,metadataType,data)
@metadata[mapid]=[] if !@metadata[mapid]
@metadata[mapid][metadataType]=data
end
def serializeMetadata
pbSerializeMetadata(@metadata,@mapinfos)
end
def helpWindow
helptext=_INTL("A: Add map to canvas\r\n")
helptext+=_INTL("DEL: Delete map from canvas\r\n")
helptext+=_INTL("S: Go to another map\r\n")
helptext+=_INTL("Click to select a map\r\n")
helptext+=_INTL("Double-click: Edit map's metadata\r\n")
helptext+=_INTL("E: Edit map's encounters\r\n")
helptext+=_INTL("Drag map to move it\r\n")
helptext+=_INTL("Arrow keys/drag canvas: Move around canvas")
title=Window_UnformattedTextPokemon.new(helptext)
title.x=0
title.y=0
title.width=800*8/10
title.height=600
title.viewport=@viewport
title.z=2
loop do
Graphics.update
Input.update
break if Input.trigger?(Input::B) || Input.trigger?(Input::C)
end
Input.update
title.dispose
end
def propertyList(map,properties)
infos=load_data("Data/MapInfos.rxdata")
mapname=(map==0) ? _INTL("Global Metadata") : infos[map].name
data=[]
for i in 0...properties.length
data.push(getMetadata(map,i+1))
end
pbPropertyList(mapname,data,properties)
for i in 0...properties.length
setMetadata(map,i+1,data[i])
end
end
def getMapRect(mapid)
sprite=getMapSprite(mapid)
if sprite
return [
sprite.x,
sprite.y,
sprite.x+sprite.bitmap.width,
sprite.y+sprite.bitmap.height
]
else
return nil
end
end
def onDoubleClick(mapid)
if mapid>=0
propertyList(mapid,LOCALMAPS)
else
propertyList(0,GLOBALMETADATA)
end
end
def onClick(mapid,x,y)
if @lastclick>0 && Graphics.frame_count-@lastclick<15
onDoubleClick(mapid)
@lastclick=-1
else
@lastclick=Graphics.frame_count
if mapid>=0
@dragging=true
@dragmapid=mapid
sprite=getMapSprite(mapid)
@sprites["selsprite"].othersprite=sprite
@selmapid=mapid
@dragOffsetX=sprite.x-x
@dragOffsetY=sprite.y-y
setTopSprite(mapid)
else
@sprites["selsprite"].othersprite=nil
@dragging=true
@dragmapid=mapid
@selmapid=-1
@dragOffsetX=x
@dragOffsetY=y
saveMapSpritePos
end
end
end
def onRightClick(mapid,x,y)
# echo("rightclick (#{mapid})\r\n")
end
def onMouseUp(mapid)
# echo("mouseup (#{mapid})\r\n")
@dragging=false if @dragging
end
def onRightMouseUp(mapid)
# echo("rightmouseup (#{mapid})\r\n")
end
def onMouseOver(mapid,x,y)
# echo("mouseover (#{mapid},#{x},#{y})\r\n")
end
def onMouseMove(mapid,x,y)
# echo("mousemove (#{mapid},#{x},#{y})\r\n")
if @dragging
if @dragmapid>=0
sprite=getMapSprite(@dragmapid)
x=x+@dragOffsetX
y=y+@dragOffsetY
sprite.x=x&~3
sprite.y=y&~3
@sprites["title"].text=_ISPRINTF("F: Help [{1:03d}: {2:s}]",mapid,@mapinfos[@dragmapid].name)
else
xpos=x-@dragOffsetX
ypos=y-@dragOffsetY
for i in @mapspritepos.keys
sprite=getMapSprite(i)
sprite.x=(@mapspritepos[i][0]+xpos)&~3
sprite.y=(@mapspritepos[i][1]+ypos)&~3
end
@sprites["title"].text=_INTL("F: Help")
end
else
if mapid>=0
@sprites["title"].text=_ISPRINTF("F: Help [{1:03d}: {2:s}]",mapid,@mapinfos[mapid].name)
else
@sprites["title"].text=_INTL("F: Help")
end
end
end
def hittest(x,y)
for i in @mapsprites.keys
sx=@mapsprites[i].x
sy=@mapsprites[i].y
sr=sx+@mapsprites[i].bitmap.width
sb=sy+@mapsprites[i].bitmap.height
return i if x>=sx && x<sr && y>=sy && y<sb
end
return -1
end
def chooseMapScreen(title,currentmap)
return pbListScreen(title,MapLister.new(currentmap))
end
def update
mousepos=Mouse::getMousePos
if mousepos
hitmap=hittest(mousepos[0],mousepos[1])
if Input.triggerex?(Input::LeftMouseKey)
onClick(hitmap,mousepos[0],mousepos[1])
elsif Input.triggerex?(Input::RightMouseKey)
onRightClick(hitmap,mousepos[0],mousepos[1])
elsif Input.releaseex?(Input::LeftMouseKey)
onMouseUp(hitmap)
elsif Input.releaseex?(Input::RightMouseKey)
onRightMouseUp(hitmap)
else
if @lasthitmap!=hitmap
onMouseOver(hitmap,mousepos[0],mousepos[1])
@lasthitmap=hitmap
end
if @oldmousex!=mousepos[0]||@oldmousey!=mousepos[1]
onMouseMove(hitmap,mousepos[0],mousepos[1])
@oldmousex=mousepos[0]
@oldmousey=mousepos[1]
end
end
end
if Input.press?(Input::UP)
for i in @mapsprites
next if !i
i[1].y+=4
end
end
if Input.press?(Input::DOWN)
for i in @mapsprites
next if !i
i[1].y-=4
end
end
if Input.press?(Input::LEFT)
for i in @mapsprites
next if !i
i[1].x+=4
end
end
if Input.press?(Input::RIGHT)
for i in @mapsprites
next if !i
i[1].x-=4
end
end
if Input.triggerex?("A"[0])
id=chooseMapScreen(_INTL("Add Map"),@currentmap)
if id>0
addSprite(id)
setTopSprite(id)
@mapconns=generateConnectionData
end
elsif Input.triggerex?("S"[0])
id=chooseMapScreen(_INTL("Go to Map"),@currentmap)
if id>0
@mapconns=generateConnectionData
pbDisposeSpriteHash(@mapsprites)
@mapsprites.clear
@sprites["selsprite"].othersprite=nil
@selmapid=-1
putSprite(id)
@currentmap=id
end
elsif Input.trigger?(Input::DELETE)
if @mapsprites.keys.length>1 && @selmapid>=0
@mapsprites[@selmapid].bitmap.dispose
@mapsprites[@selmapid].dispose
@mapsprites.delete(@selmapid)
@sprites["selsprite"].othersprite=nil
@selmapid=-1
end
elsif Input.triggerex?("E"[0])
pbEncounterEditorMap(@encdata,@selmapid) if @selmapid>=0
elsif Input.trigger?(Input::F5)
helpWindow
end
pbUpdateSpriteHash(@sprites)
end
def pbMapScreenLoop
loop do
Graphics.update
Input.update
update
if Input.trigger?(Input::B)
if pbConfirmMessage(_INTL("Save changes?"))
serializeConnectionData
serializeMetadata
save_data(@encdata,"Data/encounters.dat")
pbClearData
pbSaveEncounterData
end
break if pbConfirmMessage(_INTL("Exit from the editor?"))
end
end
end
end
def pbConnectionsEditor
pbCriticalCode {
mapscreen = MapScreenScene.new
mapscreen.mapScreen
mapscreen.pbMapScreenLoop
mapscreen.close
}
end

View File

@@ -0,0 +1,425 @@
#===============================================================================
#
#===============================================================================
def findBottom(bitmap)
return 0 if !bitmap
for i in 1..bitmap.height
for j in 0..bitmap.width-1
return bitmap.height-i if bitmap.get_pixel(j,bitmap.height-i).alpha>0
end
end
return 0
end
def pbAutoPositionAll
metrics = pbLoadSpeciesMetrics
for i in 1..PBSpecies.maxValueF
s = pbGetSpeciesFromFSpecies(i)
Graphics.update if i%50==0
bitmap1 = pbLoadSpeciesBitmap(s[0],false,s[1],false,false,true)
bitmap2 = pbLoadSpeciesBitmap(s[0],false,s[1])
metrics[MetricBattlerPlayerX][i] = 0 # Player's x
if bitmap1 && bitmap1.bitmap # Player's y
metrics[MetricBattlerPlayerY][i] = (bitmap1.height-(findBottom(bitmap1.bitmap)+1))/2
end
metrics[MetricBattlerEnemyX][i] = 0 # Foe's x
if bitmap2 && bitmap2.bitmap # Foe's y
metrics[MetricBattlerEnemyY][i] = (bitmap2.height-(findBottom(bitmap2.bitmap)+1))/2
metrics[MetricBattlerEnemyY][i] += 4 # Just because
end
metrics[MetricBattlerAltitude][i] = 0 # Foe's altitude, not used now
metrics[MetricBattlerShadowX][i] = 0 # Shadow's x
metrics[MetricBattlerShadowSize][i] = 2 # Shadow size
bitmap1.dispose if bitmap1
bitmap2.dispose if bitmap2
end
save_data(metrics,"Data/species_metrics.dat")
$PokemonTemp.speciesMetrics = nil
pbSavePokemonData
pbSavePokemonFormsData
end
#===============================================================================
#
#===============================================================================
class SpritePositioner
def pbOpen
@sprites = {}
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z = 99999
battlebg = "Graphics/Battlebacks/indoor1_bg"
playerbase = "Graphics/Battlebacks/indoor1_base0"
enemybase = "Graphics/Battlebacks/indoor1_base1"
@sprites["battle_bg"] = AnimatedPlane.new(@viewport)
@sprites["battle_bg"].setBitmap(battlebg)
@sprites["battle_bg"].z = 0
baseX, baseY = PokeBattle_SceneConstants.pbBattlerPosition(0)
@sprites["base_0"] = IconSprite.new(baseX,baseY,@viewport)
@sprites["base_0"].setBitmap(playerbase)
@sprites["base_0"].x -= @sprites["base_0"].bitmap.width/2 if @sprites["base_0"].bitmap
@sprites["base_0"].y -= @sprites["base_0"].bitmap.height if @sprites["base_0"].bitmap
@sprites["base_0"].z = 1
baseX, baseY = PokeBattle_SceneConstants.pbBattlerPosition(1)
@sprites["base_1"] = IconSprite.new(baseX,baseY,@viewport)
@sprites["base_1"].setBitmap(enemybase)
@sprites["base_1"].x -= @sprites["base_1"].bitmap.width/2 if @sprites["base_1"].bitmap
@sprites["base_1"].y -= @sprites["base_1"].bitmap.height/2 if @sprites["base_1"].bitmap
@sprites["base_1"].z = 1
@sprites["messageBox"] = IconSprite.new(0,Graphics.height-96,@viewport)
@sprites["messageBox"].setBitmap("Graphics/Pictures/Battle/debug_message")
@sprites["messageBox"].z = 2
@sprites["shadow_1"] = IconSprite.new(0,0,@viewport)
@sprites["shadow_1"].z = 3
@sprites["pokemon_0"] = PokemonSprite.new(@viewport)
@sprites["pokemon_0"].setOffset(PictureOrigin::Bottom)
@sprites["pokemon_0"].z = 4
@sprites["pokemon_1"] = PokemonSprite.new(@viewport)
@sprites["pokemon_1"].setOffset(PictureOrigin::Bottom)
@sprites["pokemon_1"].z = 4
@sprites["info"] = Window_UnformattedTextPokemon.new("")
@sprites["info"].viewport = @viewport
@sprites["info"].visible = false
@oldSpeciesIndex = 0
@species = 0
@metrics = pbLoadSpeciesMetrics
@metricsChanged = false
refresh
@starting = true
end
def pbClose
if @metricsChanged
if pbConfirmMessage(_INTL("Some metrics have been edited. Save changes?"))
pbSaveMetrics
@metricsChanged = false
end
end
pbFadeOutAndHide(@sprites) { update }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
def pbSaveMetrics
save_data(@metrics,"Data/species_metrics.dat")
$PokemonTemp.speciesMetrics = nil
pbSavePokemonData
pbSavePokemonFormsData
end
def update
pbUpdateSpriteHash(@sprites)
end
def refresh
if @species<=0
@sprites["pokemon_0"].visible = false
@sprites["pokemon_1"].visible = false
@sprites["shadow_1"].visible = false
return
end
for i in 0...2
pos = PokeBattle_SceneConstants.pbBattlerPosition(i,1)
@sprites["pokemon_#{i}"].x = pos[0]
@sprites["pokemon_#{i}"].y = pos[1]
pbApplyBattlerMetricsToSprite(@sprites["pokemon_#{i}"],i,@species,false,@metrics)
@sprites["pokemon_#{i}"].visible = true
if i==1
@sprites["shadow_1"].x = pos[0]
@sprites["shadow_1"].y = pos[1]
if @sprites["shadow_1"].bitmap
@sprites["shadow_1"].x -= @sprites["shadow_1"].bitmap.width/2
@sprites["shadow_1"].y -= @sprites["shadow_1"].bitmap.height/2
end
pbApplyBattlerMetricsToSprite(@sprites["shadow_1"],i,@species,true,@metrics)
@sprites["shadow_1"].visible = true
end
end
end
def pbAutoPosition
oldmetric1 = (@metrics[MetricBattlerPlayerY][@species] || 0)
oldmetric3 = (@metrics[MetricBattlerEnemyY][@species] || 0)
oldmetric4 = (@metrics[MetricBattlerAltitude][@species] || 0)
bitmap1 = @sprites["pokemon_0"].bitmap
bitmap2 = @sprites["pokemon_1"].bitmap
newmetric1 = (bitmap1.height-(findBottom(bitmap1)+1))/2
newmetric3 = (bitmap2.height-(findBottom(bitmap2)+1))/2
newmetric3 += 4 # Just because
if newmetric1!=oldmetric1 || newmetric3!=oldmetric3 || oldmetric4!=0
@metrics[MetricBattlerPlayerY][@species] = newmetric1
@metrics[MetricBattlerEnemyY][@species] = newmetric3
@metrics[MetricBattlerAltitude][@species] = 0
@metricsChanged = true
refresh
end
end
def pbChangeSpecies(species)
@species = species
spe,frm = pbGetSpeciesFromFSpecies(@species)
@sprites["pokemon_0"].setSpeciesBitmap(spe,false,frm,false,false,true)
@sprites["pokemon_1"].setSpeciesBitmap(spe,false,frm,false,false,false)
@sprites["shadow_1"].setBitmap(pbCheckPokemonShadowBitmapFiles(spe,frm,@metrics))
end
def pbShadowSize
pbChangeSpecies(@species)
refresh
oldval = (@metrics[MetricBattlerShadowSize][@species] || 2)
cmdvals = [0]; commands = [_INTL("None")]
defindex = 0
i = 0
loop do
i += 1
fn = sprintf("Graphics/Pictures/Battle/battler_shadow_%d",i)
break if !pbResolveBitmap(fn)
cmdvals.push(i); commands.push(i.to_s)
defindex = cmdvals.length-1 if oldval==i
end
cw = Window_CommandPokemon.new(commands)
cw.index = defindex
cw.viewport = @viewport
ret = false
oldindex = cw.index
loop do
Graphics.update
Input.update
cw.update
self.update
if cw.index!=oldindex
oldindex = cw.index
@metrics[MetricBattlerShadowSize][@species] = cmdvals[cw.index]
pbChangeSpecies(@species)
refresh
end
if Input.trigger?(Input::A) # Cycle to next option
pbPlayDecisionSE
@metricsChanged = true if @metrics[MetricBattlerShadowSize][@species]!=oldval
ret = true
break
elsif Input.trigger?(Input::B)
@metrics[MetricBattlerShadowSize][@species] = oldval
pbPlayCancelSE
break
elsif Input.trigger?(Input::C)
pbPlayDecisionSE
break
end
end
cw.dispose
return ret
end
def pbSetParameter(param)
return if @species<=0
if param==2
return pbShadowSize
elsif param==4
pbAutoPosition
return false
end
oldvalues = []
case param
when 0
sprite = @sprites["pokemon_0"]
xpos = (@metrics[MetricBattlerPlayerX][@species] || 0)
ypos = (@metrics[MetricBattlerPlayerY][@species] || 0)
when 1
sprite = @sprites["pokemon_1"]
xpos = (@metrics[MetricBattlerEnemyX][@species] || 0)
ypos = (@metrics[MetricBattlerEnemyY][@species] || 0)
when 3
sprite = @sprites["shadow_1"]
xpos = (@metrics[MetricBattlerShadowX][@species] || 0)
ypos = 0
end
oldxpos = xpos
oldypos = ypos
@sprites["info"].visible = true
ret = false
loop do
sprite.visible = (Graphics.frame_count%16)<12
Graphics.update
Input.update
self.update
case param
when 0; @sprites["info"].setTextToFit("Ally Position = #{xpos},#{ypos}")
when 1; @sprites["info"].setTextToFit("Enemy Position = #{xpos},#{ypos}")
when 3; @sprites["info"].setTextToFit("Shadow Position = #{xpos}")
end
if Input.repeat?(Input::UP) && param!=3
ypos -= 1
case param
when 0; @metrics[MetricBattlerPlayerY][@species] = ypos
when 1; @metrics[MetricBattlerEnemyY][@species] = ypos
end
refresh
elsif Input.repeat?(Input::DOWN) && param!=3
ypos += 1
case param
when 0; @metrics[MetricBattlerPlayerY][@species] = ypos
when 1; @metrics[MetricBattlerEnemyY][@species] = ypos
end
refresh
end
if Input.repeat?(Input::LEFT)
xpos -= 1
case param
when 0; @metrics[MetricBattlerPlayerX][@species] = xpos
when 1; @metrics[MetricBattlerEnemyX][@species] = xpos
when 3; @metrics[MetricBattlerShadowX][@species] = xpos
end
refresh
elsif Input.repeat?(Input::RIGHT)
xpos += 1
case param
when 0; @metrics[MetricBattlerPlayerX][@species] = xpos
when 1; @metrics[MetricBattlerEnemyX][@species] = xpos
when 3; @metrics[MetricBattlerShadowX][@species] = xpos
end
refresh
end
if Input.repeat?(Input::A) && param!=3 # Cycle to next option
@metricsChanged = true if xpos!=oldxpos || ypos!=oldypos
ret = true
pbPlayDecisionSE
break
elsif Input.repeat?(Input::B)
case param
when 0
@metrics[MetricBattlerPlayerX][@species] = oldxpos
@metrics[MetricBattlerPlayerY][@species] = oldypos
when 1
@metrics[MetricBattlerEnemyX][@species] = oldxpos
@metrics[MetricBattlerEnemyY][@species] = oldypos
when 3
@metrics[MetricBattlerShadowX][@species] = oldxpos
end
pbPlayCancelSE
refresh
break
elsif Input.repeat?(Input::C)
@metricsChanged = true if xpos!=oldxpos || (param!=3 && ypos!=oldypos)
pbPlayDecisionSE
break
end
end
@sprites["info"].visible = false
sprite.visible = true
return ret
end
def pbMenu(species)
pbChangeSpecies(species)
refresh
cw = Window_CommandPokemon.new([
_INTL("Set Ally Position"),
_INTL("Set Enemy Position"),
_INTL("Set Shadow Size"),
_INTL("Set Shadow Position"),
_INTL("Auto-Position Sprites")
])
cw.x = Graphics.width-cw.width
cw.y = Graphics.height-cw.height
cw.viewport = @viewport
ret = -1
loop do
Graphics.update
Input.update
cw.update
self.update
if Input.trigger?(Input::C)
pbPlayDecisionSE
ret = cw.index
break
elsif Input.trigger?(Input::B)
pbPlayCancelSE
break
end
end
cw.dispose
return ret
end
def pbChooseSpecies
if @starting
pbFadeInAndShow(@sprites) { update }
@starting = false
end
cw = Window_CommandPokemonEx.newEmpty(0,0,260,32+24*6,@viewport)
cw.rowHeight = 24
pbSetSmallFont(cw.contents)
cw.x = Graphics.width-cw.width
cw.y = Graphics.height-cw.height
allspecies = []
commands = []
for i in 1..PBSpecies.maxValueF
s = pbGetSpeciesFromFSpecies(i)
name = PBSpecies.getName(s[0])
name = _INTL("{1} (form {2})",name,s[1]) if s[1]>0
allspecies.push([i,s[0],name]) if name!=""
end
allspecies.sort! { |a,b| a[1]==b[1] ? a[0]<=>b[0] : a[2]<=>b[2] }
for s in allspecies
commands.push(_INTL("{1} - {2}",s[1],s[2]))
end
cw.commands = commands
cw.index = @oldSpeciesIndex
species = 0
oldindex = -1
loop do
Graphics.update
Input.update
cw.update
if cw.index!=oldindex
oldindex = cw.index
pbChangeSpecies(allspecies[cw.index][0])
refresh
end
self.update
if Input.trigger?(Input::B)
pbChangeSpecies(0)
refresh
break
elsif Input.trigger?(Input::C)
pbChangeSpecies(allspecies[cw.index][0])
species = allspecies[cw.index][0]
break
end
end
@oldSpeciesIndex = cw.index
cw.dispose
return species
end
end
#===============================================================================
#
#===============================================================================
class SpritePositionerScreen
def initialize(scene)
@scene = scene
end
def pbStart
@scene.pbOpen
loop do
species = @scene.pbChooseSpecies
break if species<=0
loop do
command = @scene.pbMenu(species)
break if command<0
loop do
par = @scene.pbSetParameter(command)
break if !par
command = (command+1)%3
end
end
end
@scene.pbClose
end
end

File diff suppressed because it is too large Load Diff