Cleaned up evolution method definitions, rewrote the "Fill Bag" Debug feature to make it much faster, removed all instances of changing the game window's title

This commit is contained in:
Maruno17
2021-07-22 22:46:43 +01:00
parent d21d3cb1fd
commit cb0220b751
15 changed files with 89 additions and 98 deletions

View File

@@ -43,8 +43,8 @@ module Kernel
end
def echoln(string)
echo(string)
echo("\r\n")
echo string
echo "\r\n"
end
end

View File

@@ -650,7 +650,7 @@ module PluginManager
# Check if plugins need compiling
#-----------------------------------------------------------------------------
def self.compilePlugins(order, plugins)
echo 'Compiling plugin scripts...'
echo "Compiling plugin scripts..."
scripts = []
# go through the entire order one by one
for o in order
@@ -672,8 +672,8 @@ module PluginManager
File.open("Data/PluginScripts.rxdata", 'wb') { |f| Marshal.dump(scripts, f) }
# collect garbage
GC.start
echoln ' done.'
echoln ''
echoln " done."
echoln ""
end
#-----------------------------------------------------------------------------
# Check if plugins need compiling
@@ -711,7 +711,7 @@ module PluginManager
end
end
end
echoln '' if !echoed_plugins.empty?
echoln "" if !echoed_plugins.empty?
end
#-----------------------------------------------------------------------------
end

View File

@@ -199,9 +199,9 @@ module SaveData
conversions_to_run.each do |conversion|
echo "#{conversion.title}..."
conversion.run(save_data)
echoln ' done.'
echoln " done."
end
echoln '' if conversions_to_run.length > 0
echoln "" if conversions_to_run.length > 0
save_data[:essentials_version] = Essentials::VERSION
save_data[:game_version] = Settings::GAME_VERSION
return true

View File

@@ -31,7 +31,7 @@ class PokemonMapFactory
return @maps[@mapIndex] if @maps[@mapIndex]
raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length==0
if @maps[0]
echoln("Using next map, may be incorrect (mapIndex=#{@mapIndex}, length=#{@maps.length})")
echoln "Using next map, may be incorrect (mapIndex=#{@mapIndex}, length=#{@maps.length})"
return @maps[0]
end
raise "No maps in save file... (all maps empty; mapIndex=#{@mapIndex})"

View File

@@ -9,21 +9,21 @@ class ClippableSprite < Sprite_Character
super
@_src_rect = self.src_rect
tmright = @tilemap.map_data.xsize*Game_Map::TILE_WIDTH-@tilemap.ox
echoln("x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}")
echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}"
if @tilemap.ox-self.ox<-self.x
# clipped on left
diff = -self.x-@tilemap.ox+self.ox
self.src_rect = Rect.new(@_src_rect.x+diff,@_src_rect.y,
@_src_rect.width-diff,@_src_rect.height)
echoln("clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}")
echoln "clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
elsif tmright-self.ox<self.x
# clipped on right
diff = self.x-tmright+self.ox
self.src_rect = Rect.new(@_src_rect.x,@_src_rect.y,
@_src_rect.width-diff,@_src_rect.height)
echoln("clipped out right: #{diff} #{tmright+self.ox} #{self.x}")
echoln "clipped out right: #{diff} #{tmright+self.ox} #{self.x}"
else
echoln("-not- clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}")
echoln "-not- clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}"
end
end
end

View File

@@ -38,7 +38,7 @@ module Graphics
if Graphics.frame_count % 40 == 0
count = 0
ObjectSpace.each_object(Object) { |o| count += 1 }
echoln("Objects: #{count}")
echoln "Objects: #{count}"
end
=end
@@transition.update if @@transition && !@@transition.disposed?

View File

@@ -4,7 +4,6 @@ module GameData
attr_reader :real_name
attr_reader :type # :land, :cave, :water, :fishing, :contest, :none
attr_reader :trigger_chance
attr_reader :old_slots
DATA = {}
@@ -19,7 +18,6 @@ module GameData
@real_name = hash[:id].to_s || "Unnamed"
@type = hash[:type] || :none
@trigger_chance = hash[:trigger_chance] || 0
@old_slots = hash[:old_slots]
end
end
end
@@ -29,169 +27,144 @@ end
GameData::EncounterType.register({
:id => :Land,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :LandDay,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :LandNight,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :LandMorning,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :LandAfternoon,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :LandEvening,
:type => :land,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})
GameData::EncounterType.register({
:id => :Cave,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :CaveDay,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :CaveNight,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :CaveMorning,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :CaveAfternoon,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :CaveEvening,
:type => :cave,
:trigger_chance => 5,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 5
})
GameData::EncounterType.register({
:id => :Water,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :WaterDay,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :WaterNight,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :WaterMorning,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :WaterAfternoon,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :WaterEvening,
:type => :water,
:trigger_chance => 2,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 2
})
GameData::EncounterType.register({
:id => :OldRod,
:type => :fishing,
:old_slots => [70, 30]
:type => :fishing
})
GameData::EncounterType.register({
:id => :GoodRod,
:type => :fishing,
:old_slots => [60, 20, 20]
:type => :fishing
})
GameData::EncounterType.register({
:id => :SuperRod,
:type => :fishing,
:old_slots => [40, 40, 15, 4, 1]
:type => :fishing
})
GameData::EncounterType.register({
:id => :RockSmash,
:type => :none,
:trigger_chance => 50,
:old_slots => [60, 30, 5, 4, 1]
:trigger_chance => 50
})
GameData::EncounterType.register({
:id => :HeadbuttLow,
:type => :none,
:old_slots => [30, 25, 20, 10, 5, 5, 4, 1]
:type => :none
})
GameData::EncounterType.register({
:id => :HeadbuttHigh,
:type => :none,
:old_slots => [30, 25, 20, 10, 5, 5, 4, 1]
:type => :none
})
GameData::EncounterType.register({
:id => :BugContest,
:type => :contest,
:trigger_chance => 21,
:old_slots => [20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1]
:trigger_chance => 21
})

View File

@@ -21,7 +21,7 @@ class PokemonBag
@choices[i] = 0
end
@registeredItems = []
@registeredIndex = [0, 0, 1]
@registeredIndex = [0, 0, 1] # Used by the Ready Menu to remember cursor positions
end
def rearrange
@@ -44,6 +44,9 @@ class PokemonBag
def clear
@pockets.each { |pocket| pocket.clear }
for i in 0..PokemonBag.numPockets
@choices[i] = 0
end
end
def pockets

View File

@@ -419,24 +419,24 @@ class MapScreenScene
end
def onRightClick(mapid,x,y)
# echoln("rightclick (#{mapid})")
# echoln "rightclick (#{mapid})"
end
def onMouseUp(mapid)
# echoln("mouseup (#{mapid})")
# echoln "mouseup (#{mapid})"
@dragging=false if @dragging
end
def onRightMouseUp(mapid)
# echoln("rightmouseup (#{mapid})")
# echoln "rightmouseup (#{mapid})"
end
def onMouseOver(mapid,x,y)
# echoln("mouseover (#{mapid},#{x},#{y})")
# echoln "mouseover (#{mapid},#{x},#{y})"
end
def onMouseMove(mapid,x,y)
# echoln("mousemove (#{mapid},#{x},#{y})")
# echoln "mousemove (#{mapid},#{x},#{y})"
if @dragging
if @dragmapid>=0
sprite=getMapSprite(@dragmapid)

View File

@@ -483,7 +483,7 @@ DebugMenuCommands.register("additem", {
DebugMenuCommands.register("fillbag", {
"parent" => "itemsmenu",
"name" => _INTL("Fill Bag"),
"description" => _INTL("Add a certain number of every item to the Bag."),
"description" => _INTL("Empties the Bag and then fills it with a certain number of every item."),
"effect" => proc {
params = ChooseNumberParams.new
params.setRange(1, Settings::BAG_MAX_PER_SLOT)
@@ -491,7 +491,19 @@ DebugMenuCommands.register("fillbag", {
params.setCancelValue(0)
qty = pbMessageChooseNumber(_INTL("Choose the number of items."), params)
if qty > 0
GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) }
$PokemonBag.clear
# NOTE: This doesn't simply use $PokemonBag.pbStoreItem for every item in
# turn, because that's really slow when done in bulk.
pocket_sizes = Settings::BAG_MAX_POCKET_SIZE
bag = $PokemonBag.pockets # Called here so that it only rearranges itself once
GameData::Item.each do |i|
next if !pocket_sizes[i.pocket] || pocket_sizes[i.pocket] == 0
next if bag[i.pocket].length >= pocket_sizes[i.pocket]
item_qty = (i.is_important?) ? 1 : qty
bag[i.pocket].push([i.id, item_qty])
end
# NOTE: Auto-sorting pockets don't need to be sorted afterwards, because
# items are added in the same order they would be sorted into.
pbMessage(_INTL("The Bag was filled with {1} of each item.", qty))
end
}
@@ -1081,7 +1093,7 @@ DebugMenuCommands.register("compiledata", {
"always_show" => true,
"effect" => proc {
msgwindow = pbCreateMessageWindow
Compiler.compile_all(true) { |msg| pbMessageDisplay(msgwindow, msg, false); echoln(msg) }
Compiler.compile_all(true) { |msg| echoln msg }
pbMessageDisplay(msgwindow, _INTL("All game data was compiled."))
pbDisposeMessageWindow(msgwindow)
}

View File

@@ -681,21 +681,22 @@ end
# Properly erases all non-existent tiles in maps (including event graphics)
#===============================================================================
def pbDebugFixInvalidTiles
num_errors = 0
total_errors = 0
num_error_maps = 0
tilesets = $data_tilesets
mapData = Compiler::MapData.new
t = Time.now.to_i
Graphics.update
total_maps = mapData.mapinfos.keys.length
echoln _INTL("Checking {1} maps for invalid tiles...", total_maps)
for id in mapData.mapinfos.keys.sort
if Time.now.to_i - t >= 5
Graphics.update
t = Time.now.to_i
end
changed = false
map_errors = 0
map = mapData.getMap(id)
next if !map || !mapData.mapinfos[id]
pbSetWindowText(_INTL("Processing map {1} ({2})", id, mapData.mapinfos[id].name))
passages = mapData.getTilesetPassages(map, id)
# Check all tiles in map for non-existent tiles
for x in 0...map.data.xsize
@@ -704,8 +705,7 @@ def pbDebugFixInvalidTiles
tile_id = map.data[x, y, i]
next if pbCheckTileValidity(tile_id, map, tilesets, passages)
map.data[x, y, i] = 0
changed = true
num_errors += 1
map_errors += 1
end
end
end
@@ -716,19 +716,22 @@ def pbDebugFixInvalidTiles
next if page.graphic.tile_id <= 0
next if pbCheckTileValidity(page.graphic.tile_id, map, tilesets, passages)
page.graphic.tile_id = 0
changed = true
num_errors += 1
map_errors += 1
end
end
next if !changed
next if map_errors == 0
# Map was changed; save it
echoln _INTL("{1} error tile(s) found on map {2}: {3}.", map_errors, id, mapData.mapinfos[id].name)
total_errors += map_errors
num_error_maps += 1
mapData.saveMap(id)
end
if num_error_maps == 0
echoln _INTL("Done. No errors found.")
pbMessage(_INTL("No invalid tiles were found."))
else
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", num_errors, num_error_maps))
echoln _INTL("Done. {1} errors found and fixed. Close RPG Maker XP to ensure fixes are applied.", total_errors)
pbMessage(_INTL("{1} error(s) were found across {2} map(s) and fixed.", total_errors, num_error_maps))
pbMessage(_INTL("Close RPG Maker XP to ensure the changes are applied properly."))
end
end

View File

@@ -123,7 +123,6 @@ module Compiler
end
lineno += 1
Graphics.update if lineno%1000==0
pbSetWindowText(_INTL("Processing {1} line {2}",FileLineData.file,lineno)) if lineno%200==0
}
yield lastsection,sectionname if havesection
end
@@ -726,7 +725,7 @@ module Compiler
compile_metadata # Depends on TrainerType
yield(_INTL("Compiling animations"))
compile_animations
yield(_INTL("Converting events"))
yield("")
compile_trainer_events(mustCompile)
yield(_INTL("Saving messages"))
pbSetTextMessages
@@ -736,7 +735,6 @@ module Compiler
echoln ""
echoln _INTL("*** Finished full compile ***")
echoln ""
pbSetWindowText(nil)
end
def main
@@ -828,7 +826,7 @@ module Compiler
end
end
# Recompile all data
compile_all(mustCompile) { |msg| pbSetWindowText(msg); echoln(msg) }
compile_all(mustCompile) { |msg| echoln msg }
rescue Exception
e = $!
raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit)

View File

@@ -908,7 +908,6 @@ module Compiler
raise _INTL("Dex list number {1} is defined at least twice.\r\n{2}", section, FileLineData.linereport)
end
dex_lists[section] = []
pbSetWindowText(_INTL("Processing {1} section [{2}]", FileLineData.file, section))
else
raise _INTL("Expected a section at the beginning of the file.\r\n{1}", FileLineData.linereport) if !section
species_list = line.split(",")
@@ -1031,7 +1030,7 @@ module Compiler
raise _INTL("Minimum level is greater than maximum level: {1}\r\n{2}", line, FileLineData.linereport)
end
encounter_hash[:types][current_type].push(values)
elsif line[/^\[\s*(.+)\s*\]$/] # Map ID line (new format)
elsif line[/^\[\s*(.+)\s*\]$/] # Map ID line
values = $~[1].split(',').collect! { |v| v.strip.to_i }
values[1] = 0 if !values[1]
map_number = values[0]

View File

@@ -248,12 +248,13 @@ module Compiler
# Save Pokémon data to PBS file
#=============================================================================
def write_pokemon
echo _INTL("Writing species")
File.open("PBS/pokemon.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::Species.each_species do |species|
echo "." if idx % 50 == 0
idx += 1
pbSetWindowText(_INTL("Writing species {1}...", idx))
Graphics.update if idx % 100 == 0
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s]\r\n", species.id))
@@ -335,7 +336,7 @@ module Compiler
f.write(sprintf("Incense = %s\r\n", species.incense)) if species.incense
end
}
pbSetWindowText(nil)
echoln _INTL("done")
Graphics.update
end
@@ -350,7 +351,6 @@ module Compiler
next if species.form == 0
base_species = GameData::Species.get(species.species)
idx += 1
pbSetWindowText(_INTL("Writing form {1}...", idx))
Graphics.update if idx % 100 == 0
f.write("\#-------------------------------\r\n")
f.write(sprintf("[%s,%d]\r\n", species.species, species.form))
@@ -441,7 +441,6 @@ module Compiler
end
end
}
pbSetWindowText(nil)
Graphics.update
end
@@ -573,12 +572,13 @@ module Compiler
# Save individual trainer data to PBS file
#=============================================================================
def write_trainers
echo _INTL("Writing trainers")
File.open("PBS/trainers.txt", "wb") { |f|
idx = 0
add_PBS_header_to_file(f)
GameData::Trainer.each do |trainer|
echo "." if idx % 50 == 0
idx += 1
pbSetWindowText(_INTL("Writing trainer {1}...", idx))
Graphics.update if idx % 50 == 0
f.write("\#-------------------------------\r\n")
if trainer.version > 0
@@ -617,7 +617,7 @@ module Compiler
end
end
}
pbSetWindowText(nil)
echoln _INTL("done")
Graphics.update
end

View File

@@ -1380,11 +1380,11 @@ module Compiler
t = Time.now.to_i
Graphics.update
trainerChecker = TrainerChecker.new
echo _INTL("Processing {1} maps...", mapData.mapinfos.keys.length)
for id in mapData.mapinfos.keys.sort
changed = false
map = mapData.getMap(id)
next if !map || !mapData.mapinfos[id]
pbSetWindowText(_INTL("Processing map {1} ({2})",id,mapData.mapinfos[id].name))
for key in map.events.keys
if Time.now.to_i-t>=5
Graphics.update
@@ -1415,12 +1415,15 @@ module Compiler
if changed
mapData.saveMap(id)
mapData.saveTilesets
echoln ""
echo _INTL("Map {1}: '{2}' modified and saved.", id, mapData.mapinfos[id].name)
end
end
echoln ""
changed = false
Graphics.update
commonEvents = load_data("Data/CommonEvents.rxdata")
pbSetWindowText(_INTL("Processing common events"))
echoln _INTL("Processing common events")
for key in 0...commonEvents.length
newevent = fix_event_use(commonEvents[key],0,mapData)
if newevent