update 6.7

This commit is contained in:
chardub
2025-09-28 15:53:01 -04:00
parent ef5e023ae0
commit 318ff90d8d
696 changed files with 111759 additions and 198230 deletions

View File

@@ -0,0 +1,191 @@
module SwitchFinder
def self.search_switch_trigger(switch_id)
results = []
mapinfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
mapinfos.each_key do |map_id|
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
map.events.each_value do |event|
event.pages.each do |page,index|
# Check conditions for each page
if page.condition.switch1_id == switch_id || page.condition.switch2_id == switch_id
results.push("Map #{map_id}, Event #{event.id} (#{event.x},#{event.y}), Trigger for page #{index}")
end
# Check commands for switch control
page.list.each do |command|
if command.code == 122 && command.parameters[0] == switch_id
results.push("Map #{map_id}, Event #{event.id} (#{event.x},#{event.y}), Command #{command.code}")
end
end
end
end
end
echoln "Switch #{switch_id} found:" + results.to_s
end
def self.search_switch_anyUse(switch_id)
results = []
# Load map info based on RPG Maker version
mapinfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
# Iterate over each map
mapinfos.each_key do |map_id|
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
mapinfo = mapinfos[map_id]
# Iterate over each event in the map
map.events.each_value do |event|
# Iterate over each page in the event
event.pages.each_with_index do |page, page_index|
# Check conditions for each page
if page.condition.switch1_id == switch_id || page.condition.switch2_id == switch_id
results.push("Map #{map_id}: #{mapinfo.name}, Event #{event.id} (#{event.x},#{event.y}), Trigger for page #{page_index + 1}")
end
# Iterate over each command in the page
page.list.each_with_index do |command, command_index|
# Check commands for switch control
if command.code == 121
# Command 121 is Control Switches
range_start = command.parameters[0]
range_end = command.parameters[1]
value = command.parameters[2]
# Check if the switch is within the specified range
if range_start <= switch_id && switch_id <= range_end
action = value == 0 ? "ON" : "OFF"
results.push("Map #{map_id}: #{mapinfo.name}, Event #{event.id} (#{event.x},#{event.y}), Command #{command_index + 1}: Set Switch to #{action}")
end
# Check script calls for switch control
elsif command.code == 355
# Command 355 is Call Script
script_text = command.parameters[0]
# Collect multi-line scripts
next_command_index = command_index + 1
while page.list[next_command_index]&.code == 655
script_text += page.list[next_command_index].parameters[0]
next_command_index += 1
end
# Use a regular expression to find switch manipulations
if script_text.match?(/\$game_switches\[\s*#{switch_id}\s*\]/)
results.push("Map #{map_id}: #{mapinfo.name}, Event #{event.id} (#{event.x},#{event.y}), Command #{command_index + 1}: Script Manipulation")
end
end
end
end
end
end
# Output the results
results = "Switch #{switch_id} found:\n" + results.join("\n")
echoln results
return results
end
def self.find_unused_switches(total_switches)
unused_switches = []
# Check each switch from 1 to total_switches
(1..total_switches).each do |switch_id|
results = search_switch_anyUse(switch_id)
report = "Switch #{switch_id}:\n#{results}"
unused_switches << report
end
# Export to a text file
File.open("unused_switches.txt", "w") do |file|
file.puts "Unused Switches:"
unused_switches.each do |switch_id|
file.puts "\n\n#{switch_id}"
end
end
echoln "#{unused_switches.length} unused switches found. Exported to unused_switches.txt."
end
end
# Example usage: Replace 100 with the switch ID you want to search
# SwitchFinder.search_switch(100)
def search_event_scripts(target_string)
results = []
for map_id in 1..999 # Adjust based on your game's max map ID
map_filename = sprintf("Data/Map%03d.rxdata", map_id)
next unless File.exist?(map_filename) # Skip if map file doesn't exist
map_data = load_data(map_filename)
next unless map_data.events # Skip maps with no events
map_data.events.each do |event_id, event|
event.pages.each_with_index do |page, page_index|
next unless page.list # Skip pages with no commands
page.list.each_with_index do |command, cmd_index|
if command.code == 355 || command.code == 655 # Check script command (multi-line)
if command.parameters[0].include?(target_string)
results << {
map_id: map_id,
main_event_id: event_id,
page_index: page_index + 1,
command_index: cmd_index + 1
}
end
end
end
end
end
end
if results.empty?
echoln "No occurrences of '#{target_string}' found."
else
echoln "Found occurrences of '#{target_string}':"
results.each do |res|
echoln "Map #{res[:map_id]}, Event #{res[:main_event_id]}, Page #{res[:page_index]}, Command #{res[:command_index]}"
end
end
end
def print_map_tiles
# Define output file path
file_path = "/Users/chardub/Documents/infinitefusion/TileIDs_Output.txt"
# Open file for writing
File.open(file_path, "w") do |file|
map = $game_map
width = map.width
height = map.height
(0...3).each do |z| # For each layer: 0, 1, 2
file.puts("Layer #{z}:")
(0...height).each do |y|
row_ids = []
(0...width).each do |x|
tile_id = map.data[x, y, z]
row_ids << tile_id
end
file.puts(row_ids.join(", "))
end
file.puts("") # Add a blank line between layers
end
end
echoln("Tile IDs exported to #{file_path}")
end

View File

@@ -0,0 +1,38 @@
def export_music_use_map()
music_hash = Hash.new
for map_id in 1..796
mapInfos = load_data(sprintf("Data/Map%03d.rxdata", map_id))
bgm_name = mapInfos.bgm.name
map_name = Kernel.getMapName(map_id)
formatted_value = map_name + " [" + map_id.to_s + "]"
if music_hash.has_key?(bgm_name)
music_hash[bgm_name] << formatted_value
else
music_hash[bgm_name] = Array.new(1, formatted_value)
end
end
export_hash_to_csv(music_hash,"music_export.csv")
end
def export_hash_to_csv(hash, file_path)
# Open the file for writing
file = File.open(file_path, "w")
# Write the CSV header
file.puts "Key,Value"
# Write each key-value pair as a new line in the CSV file
hash.each do |key, values|
if key == ""
key = "(No value)"
end
# Join the values into a single string with newline characters
values_str = values.join("\n,")
file.puts "#{key},#{values_str}"
end
# Close the file
file.close
end

View File

@@ -0,0 +1,189 @@
# #==============================================================================#
# # Map Exporter #
# # by Marin #
# #==============================================================================#
# # Manually export a map using `pbExportMap(id)`, or go into the Debug menu and #
# # choose the `Export a Map` option that is now in there. #
# # #
# # `pbExportMap(id, options)`, where `options` is an array that can contain: #
# # - :events -> This will alsoEXPORTED_FILENAME = "export/"
# #
# # def exportAllMaps
# # options = [:events]
# # for id in 1..768
# # pbExportMap(id, options)
# # end
# # end export all events present on the map #
# # - :player -> This will also export the player if they're on that map #
# # `id` can be nil, which case it will use the current map the player is on. #
# #==============================================================================#
# # Please give credit when using this. #
# #==============================================================================#
#
# # This is where the map will be exported to once it has been created.
# # If this file already exists, it is overwritten.
# ExportedMapFilename = "export/"
#
# def exportAllMaps
# options = [:events]
# for id in 1..768
# begin
# pbExportMap(id,options)
# rescue
# echo "error in " +(id.to_s) +"\n"
# end
# end
# end
#
#
# def pbExportMap(id = nil, options = [])
# MarinMapExporter.new(id, options)
# end
#
# def pbExportAMap
# vp = Viewport.new(0, 0, Graphics.width, Graphics.height)
# vp.z = 99999
# s = Sprite.new(vp)
# s.bitmap = Bitmap.new(Graphics.width, Graphics.height)
# s.bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0,0,0))
# mapid = pbListScreen("Export Map",MapLister.new(pbDefaultMap))
# if mapid > 0
# player = $game_map.map_id == mapid
# if player
# cmds = ["Export", "[ ] Events", "[ ] Player", "Cancel"]
# else
# cmds = ["Export", "[ ] Events", "Cancel"]
# end
# cmd = 0
# loop do
# cmd = pbShowCommands(nil,cmds,-1,cmd)
# if cmd == 0
# Graphics.update
# options = []
# options << :events if cmds[1].split("")[1] == "X"
# options << :player if player && cmds[2].split("")[1] == "X"
# msgwindow = Window_AdvancedTextPokemon.newWithSize(
# "Saving... Please be patient.",
# 0, Graphics.height - 96, Graphics.width, 96, vp
# )
# msgwindow.setSkin(MessageConfig.pbGetSpeechFrame)
# Graphics.update
# pbExportMap(mapid, options)
# msgwindow.setText("Successfully exported the map.")
# 60.times { Graphics.update; Input.update }
# pbDisposeMessageWindow(msgwindow)
# break
# elsif cmd == 1
# if cmds[1].split("")[1] == " "
# cmds[1] = "[X] Events"
# else
# cmds[1] = "[ ] Events"
# end
# elsif cmd == 2 && player
# if cmds[2].split("")[1] == " "
# cmds[2] = "[X] Player"
# else
# cmds[2] = "[ ] Player"
# end
# elsif cmd == 3 || cmd == 2 && !player || cmd == -1
# break
# end
# end
# end
# s.bitmap.dispose
# s.dispose
# vp.dispose
# end
#
# DebugMenuCommands.register("exportmap", {
# "parent" => "fieldmenu",
# "name" => "Export a Map",
# "description" => "Choose a map to export it to a PNG.",
# "effect" => proc { |sprites, viewport|
# pbExportAMap
# }
# })
#
# class MarinMapExporter
# def initialize(id = nil, options = [])
# mapinfos = load_data("Data/MapInfos.rxdata")
# filename = id.to_s + "_" + mapinfos[id].name
#
#
#
# @id = id || $game_map.map_id
# @options = options
# @data = load_data("Data/Map#{@id.to_digits}.rxdata")
# @tiles = @data.data
# @result = Bitmap.new(32 * @tiles.xsize, 32 * @tiles.ysize)
# @tilesetdata = load_data("Data/Tilesets.rxdata")
# tilesetname = @tilesetdata[@data.tileset_id].tileset_name
# @tileset = Bitmap.new("Graphics/Tilesets/#{tilesetname}")
# @autotiles = @tilesetdata[@data.tileset_id].autotile_names
# .filter { |e| e && e.size > 0 }
# .map { |e| Bitmap.new("Graphics/Autotiles/#{e}") }
# for z in 0..2
# for y in 0...@tiles.ysize
# for x in 0...@tiles.xsize
# id = @tiles[x, y, z]
# next if id == 0
# if id < 384 # Autotile
# build_autotile(@result, x * 32, y * 32, id)
# else # Normal tile
# @result.blt(x * 32, y * 32, @tileset,
# Rect.new(32 * ((id - 384) % 8),32 * ((id - 384) / 8).floor,32,32))
# end
# end
# end
# end
# if @options.include?(:events)
# keys = @data.events.keys.sort { |a, b| @data.events[a].y <=> @data.events[b].y }
# keys.each do |id|
# event = @data.events[id]
# page = pbGetActiveEventPage(event, @id)
# if page && page.graphic && page.graphic.character_name && page.graphic.character_name.size > 0
# bmp = Bitmap.new("Graphics/Characters/#{page.graphic.character_name}")
# if bmp
# bmp = bmp.clone
# bmp.hue_change(page.graphic.character_hue) unless page.graphic.character_hue == 0
# ex = bmp.width / 4 * page.graphic.pattern
# ey = bmp.height / 4 * (page.graphic.direction / 2 - 1)
# @result.blt(event.x * 32 + 16 - bmp.width / 8, (event.y + 1) * 32 - bmp.height / 4, bmp,
# Rect.new(ex, ey, bmp.width / 4, bmp.height / 4))
# end
# bmp = nil
# end
# end
# end
# if @options.include?(:player) && $game_map.map_id == @id && $game_player.character_name &&
# $game_player.character_name.size > 0
# bmp = Bitmap.new("Graphics/Characters/#{$game_player.character_name}")
# dir = $game_player.direction
# @result.blt($game_player.x * 32 + 16 - bmp.width / 8, ($game_player.y + 1) * 32 - bmp.height / 4,
# bmp, Rect.new(0, bmp.height / 4 * (dir / 2 - 1), bmp.width / 4, bmp.height / 4))
# end
# @result.save_to_png(ExportedMapFilename + filename + ".png")
# echo (id.to_s) +"\n"
# Input.update
# end
#
# def build_autotile(bitmap, x, y, id)
# autotile = @autotiles[id / 48 - 1]
# return unless autotile
# if autotile.height == 32
# bitmap.blt(x,y,autotile,Rect.new(0,0,32,32))
# else
# id %= 48
# tiles = CustomTilemap::Autotiles[id >> 3][id & 7]
# src = Rect.new(0,0,0,0)
# halfTileWidth = halfTileHeight = halfTileSrcWidth = halfTileSrcHeight = 32 >> 1
# for i in 0...4
# tile_position = tiles[i] - 1
# src.set((tile_position % 6) * halfTileSrcWidth,
# (tile_position / 6) * halfTileSrcHeight, halfTileSrcWidth, halfTileSrcHeight)
# bitmap.blt(i % 2 * halfTileWidth + x, i / 2 * halfTileHeight + y,
# autotile, src)
# end
# end
# end
# end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,533 @@
EXPORT_EXCEPT_MAP_IDS= [768,722,723,724,720,809,816]
def exportAllMaps
for id in 817..830
begin
MapExporter.export(id, [:Events]) if !EXPORT_EXCEPT_MAP_IDS.include?(id)
rescue
echo "error in " +(id.to_s) +"\n"
end
end
end
def exportSpecificMaps(maps_to_export)
for id in maps_to_export
begin
MapExporter.export(id, [:Events])
rescue
echo "error in " +(id.to_s) +"\n"
end
end
end
module MapExporter
@@map = nil
@@bitmap = nil
@@helper = nil
module_function
def export(map_id, options)
map_name = pbGetMapNameFromId(map_id)
begin
@@map = $MapFactory.getMapForExport(map_id)
rescue
error("Map #{map_id} (#{map_name}) could not be loaded.")
end
@@bitmap = Bitmap.new(@@map.width * Game_Map::TILE_HEIGHT, @@map.height * Game_Map::TILE_WIDTH)
@@helper = TileDrawingHelper.fromTileset($data_tilesets[@@map.tileset_id])
set_map_options(options)
if options.include?(:Panorama)
if !nil_or_empty?(@@map.panorama_name)
draw_panorama
else
echoln "Map #{map_id} (#{map_name}) doesn't have a Panorama."
end
end
draw_reflective_tiles
draw_all_reflections(options)
draw_regular_tiles
if !draw_all_events(options)
draw_low_priority_tiles
end
draw_high_priority_tiles
draw_all_top_events(options)
if options.include?(:Fog)
if nil_or_empty?(@@map.fog_name)
echoln "Map #{map_id} (#{map_name}) doesn't have a Fog."
else
draw_fog
end
end
draw_watermark(options)
save_map_image
end
def draw_all_events(options)
include_player = options.include?(:Player) && $game_map.map_id == @@map.map_id
include_dep = options.include?(:DependentEvents) && $game_map.map_id == @@map.map_id
include_event = true#options.include?(:Events)
return false if !(include_player || include_dep || include_event)
for y in 0...@@map.height
for x in 0...@@map.width
event = nil
if include_event
event_hash = @@map.events.select {|_,e| e.x == x && e.y == y && !e.always_on_top }
event = event_hash.values.first if !event_hash.empty?
end
event = $game_player if !event && include_player && $game_player.x == x && $game_player.y == y && !$game_player.always_on_top
if include_dep
$PokemonTemp.dependentEvents.realEvents.each do |e|
next if !e || e.x != x || e.y != y
event = e
break
end
end
if event
deep_bush = @@map.bush?(x, y)
draw_event_bitmap(event, deep_bush)
end
for z in 0..2
tile_id = @@map.data[x, y, z] || 0
priority = @@map.priorities[tile_id]
next if priority == nil
next if priority != 1
tag_data = GameData::TerrainTag.try_get(@@map.terrain_tags[tile_id])
next if !tag_data || tag_data.shows_reflections
@@helper.bltTile(@@bitmap, x * Game_Map::TILE_WIDTH, y * Game_Map::TILE_HEIGHT, tile_id)
end
end
end
return true
end
def draw_all_top_events(options)
include_player = options.include?(:Player) && $game_map.map_id == @@map.map_id
include_event = options.include?(:Events)
return false if !(include_player || include_event)
for y in 0...@@map.height
for x in 0...@@map.width
event = nil
if include_event
event_hash = @@map.events.select {|_,e| e.x == x && e.y == y && e.always_on_top }
event = event_hash.values.first if !event_hash.empty?
end
event = $game_player if !event && include_player && $game_player.x == x && $game_player.y == y && $game_player.always_on_top
if event
deep_bush = @@map.bush?(x, y)
draw_event_bitmap(event, deep_bush)
end
end
end
return true
end
def draw_all_reflections(options)
include_player = options.include?(:Player) && $game_map.map_id == @@map.map_id
include_dep = options.include?(:DependentEvents) && $game_map.map_id == @@map.map_id
include_event = options.include?(:Events)
return false if !(include_player || include_dep || include_event)
for y in 0...@@map.height
for x in 0...@@map.width
dep = false
event = nil
if include_event
event_hash = @@map.events.select {|_,e| e.x == x && e.y == y }
event = event_hash.values.first if !event_hash.empty?
end
event = $game_player if !event && include_player && $game_player.x == x && $game_player.y == y
if include_dep && !event
$PokemonTemp.dependentEvents.realEvents.each do |e|
next if !e || e.x != x || e.y != y
event = e
dep = true
break
end
end
draw_event_reflection(event, dep) if event
end
end
return true
end
def draw_reflective_tiles
for y in 0...@@map.height
for x in 0...@@map.width
for z in 0..2
tile_id = @@map.data[x, y, z] || 0
tag_data = GameData::TerrainTag.try_get(@@map.terrain_tags[tile_id])
next if !tag_data || !tag_data.shows_reflections
@@helper.bltTile(@@bitmap, x * Game_Map::TILE_WIDTH, y * Game_Map::TILE_HEIGHT, tile_id)
end
end
end
end
def draw_regular_tiles
for y in 0...@@map.height
for x in 0...@@map.width
for z in 0..2
tile_id = @@map.data[x, y, z] || 0
priority = @@map.priorities[tile_id]
next if priority == nil
next if priority >= 1
tag_data = GameData::TerrainTag.try_get(@@map.terrain_tags[tile_id])
next if !tag_data || tag_data.shows_reflections
@@helper.bltTile(@@bitmap, x * Game_Map::TILE_WIDTH, y * Game_Map::TILE_HEIGHT, tile_id)
end
end
end
end
def draw_low_priority_tiles
for y in 0...@@map.height
for x in 0...@@map.width
for z in 0..2
tile_id = @@map.data[x, y, z] || 0
priority = @@map.priorities[tile_id]
next unless priority == 1
tag_data = GameData::TerrainTag.try_get(@@map.terrain_tags[tile_id])
next if !tag_data || tag_data.shows_reflections
@@helper.bltTile(@@bitmap, x * Game_Map::TILE_WIDTH, y * Game_Map::TILE_HEIGHT, tile_id)
end
end
end
end
def draw_high_priority_tiles
for y in 0...@@map.height
for x in 0...@@map.width
for z in 0..2
tile_id = @@map.data[x, y, z] || 0
priority = @@map.priorities[tile_id]
next if priority == nil
next if priority < 2
tag_data = GameData::TerrainTag.try_get(@@map.terrain_tags[tile_id])
next if !tag_data || tag_data.shows_reflections
@@helper.bltTile(@@bitmap, x * Game_Map::TILE_WIDTH, y * Game_Map::TILE_HEIGHT, tile_id)
end
end
end
end
def draw_event_bitmap(event, deep_bush)
hued = false
tile_bmp = false
if event.tile_id >= 384
bmp = pbGetTileBitmap(@@map.tileset_name, event.tile_id, event.character_hue, event.width, event.height)
hued = true
tile_bmp = true
elsif deep_bush
event.calculate_bush_depth
temp_bmp = AnimatedBitmap.new("Graphics/Characters/" + "#{event.character_name}", event.character_hue)
bushmap = BushBitmap.new(temp_bmp, false, event.bush_depth)
bmp = bushmap.bitmap.clone
bushmap.dispose
temp_bmp.dispose
hued = true
else
bmp = RPG::Cache.load_bitmap("Graphics/Characters/", "#{event.character_name}") rescue Bitmap.new(32,32)
end
if bmp
bmp = bmp.clone
bmp.hue_change(event.character_hue) if event.character_hue != 0 && !hued
final_x = (event.x * Game_Map::TILE_WIDTH) + ((event.width * Game_Map::TILE_WIDTH)/2) - bmp.width / 8
final_y = (event.y + 1) * Game_Map::TILE_HEIGHT - bmp.height / 4 + (event.bob_height)
final_y += 16 if event.character_name[/offset/i]
draw_event_shadow(event) if defined?(OWShadowSettings)
draw_surf_base(event) if event == $game_player
if !tile_bmp
ex = (bmp.width/4) * event.pattern
ey = (bmp.height/4) * (event.direction/2 - 1)
rect = Rect.new(ex, ey, bmp.width / 4, bmp.height / 4)
else
final_x += (bmp.width/8 - ((event.width * Game_Map::TILE_WIDTH)/2))
final_y += (bmp.height/4) - (Game_Map::TILE_HEIGHT * event.height)
rect = Rect.new(0, 0, bmp.width, bmp.height)
end
@@bitmap.blt(final_x, final_y, bmp, rect, event.opacity)
bmp.dispose
end
bmp = nil
end
def draw_event_shadow(event)
if OWShadowSettings::CASE_SENSITIVE_BLACKLISTS
remove = true if OWShadowSettings::SHADOWLESS_CHARACTER_NAME.any?{|e| event.character_name[/#{e}/]}
remove = true if event != $game_player && OWShadowSettings::SHADOWLESS_EVENT_NAME.any? {|e| event.name[/#{e}/]}
else
remove = true if OWShadowSettings::SHADOWLESS_CHARACTER_NAME.any?{|e| event.character_name[/#{e}/i]}
remove = true if event != $game_player && OWShadowSettings::SHADOWLESS_EVENT_NAME.any? {|e| event.name[/#{e}/i]}
end
terrain = @@map.terrain_tag(event.x, event.y)
remove = true if OWShadowSettings::SHADOWLESS_TERRAIN_NAME.any? {|e| terrain == e} if terrain
if !(nil_or_empty?(event.character_name) || event.transparent || remove)
if event == $game_player
shadow_name = OWShadowSettings::PLAYER_SHADOW_FILENAME
else
shadow_name = $~[1] if event.name[/shdw\((.*?)\)/]
end
shadow_name = OWShadowSettings::DEFAULT_SHADOW_FILENAME if nil_or_empty?(shadow_name)
shadow_bmp = RPG::Cache.load_bitmap("Graphics/Characters/Shadows/", "#{shadow_name}")
shadow_x = (event.x * Game_Map::TILE_WIDTH) + ((event.width * Game_Map::TILE_WIDTH)/2) - shadow_bmp.width/2
shadow_y = (event.y + 1) * Game_Map::TILE_HEIGHT - shadow_bmp.height + 2
@@bitmap.blt(shadow_x, shadow_y, shadow_bmp, Rect.new(0, 0, shadow_bmp.width, shadow_bmp.height), event.opacity)
shadow_bmp.dispose
end
end
def draw_event_reflection(event, forced = true)
tile_bmp = false
if event.tile_id >= 384
bmp = pbGetTileBitmap(@@map.tileset_name, event.tile_id, event.character_hue, event.width, event.height)
tile_bmp = true
else
bmp = RPG::Cache.load_bitmap("Graphics/Characters/", "#{event.character_name}") rescue Bitmap.new(32,32)
end
if bmp
bmp = bmp.clone
bmp.hue_change(event.character_hue) if event.character_hue != 0 && !tile_bmp
height = nil
fixed = false
if event == $game_player || forced
height = $PokemonGlobal.bridge
elsif event.name[/reflection/i]
height = 0
if event.name[/reflection\((\d+)\)/i]
height = $~[1].to_i || 0
else
height = $PokemonGlobal.bridge
end
end
if height
final_x = (event.x * Game_Map::TILE_WIDTH) + ((event.width * Game_Map::TILE_WIDTH)/2) - bmp.width/8
final_y = (event.y + 1) * Game_Map::TILE_HEIGHT - 3 - (event.bob_height)
final_y -= 32 if event.character_name[/offset/i]
if !tile_bmp
ex = (bmp.width/4) * event.pattern
ey = (bmp.height/4) * (event.direction/2 - 1)
rect = Rect.new(ex, ey, bmp.width/4, bmp.height/4)
else
final_x += (bmp.width/8 - ((event.width * Game_Map::TILE_WIDTH)/2))
rect = Rect.new(0, 0, bmp.width, bmp.height)
end
if height > 0
new_bmp = colorize_and_flip_bitmap(bmp, Color.new(48,96,160), 255, rect)
opacity = event.opacity
else
new_bmp = colorize_and_flip_bitmap(bmp, Color.new(224,224,224), 96, rect)
opacity = event.opacity*3/4
end
offset = [1.0, 0.95, 1.0, 1.05][(Graphics.frame_count%40)/10]
@@bitmap.stretch_blt(Rect.new(final_x, final_y, (new_bmp.width * offset), new_bmp.height), new_bmp, Rect.new(0, 0, new_bmp.width, new_bmp.height), opacity)
new_bmp.dispose
end
bmp.dispose
end
bmp = nil
end
def draw_surf_base(event)
return if !$PokemonGlobal.surfing && !$PokemonGlobal.diving
bmp = nil
if $PokemonGlobal.surfing
bmp = RPG::Cache.load_bitmap("Graphics/Characters/", "base_surf") rescue Bitmap.new(32,32)
elsif $PokemonGlobal.diving
bmp = RPG::Cache.load_bitmap("Graphics/Characters/", "base_dive") rescue Bitmap.new(32,32)
end
return if !bmp
sx = event.pattern_surf * bmp.width/4
sy = ((event.direction - 2)/2) * bmp.height/4
final_x = (event.x * Game_Map::TILE_WIDTH) + ((event.width * Game_Map::TILE_WIDTH)/2) - bmp.width/8
final_y = (event.y + 1) * Game_Map::TILE_HEIGHT - bmp.height / 4 + 16 + (event.bob_height)
@@bitmap.blt(final_x, final_y, bmp, Rect.new(sx,sy, bmp.width/4, bmp.height/4), event.opacity)
end
def draw_fog
fog_bmp = create_tiled_bitmap("Graphics/Fogs/#{@@map.fog_name}", @@map.fog_hue, @@map.fog_zoom/100.0)
@@bitmap.blt(0, 0, fog_bmp, Rect.new(0, 0, fog_bmp.width, fog_bmp.height), @@map.fog_opacity)
fog_bmp.dispose
end
def draw_panorama
pan_bmp = create_tiled_bitmap("Graphics/Panoramas/#{@@map.panorama_name}", @@map.panorama_hue)
@@bitmap.blt(0, 0, pan_bmp, Rect.new(0, 0, pan_bmp.width, pan_bmp.height))
pan_bmp.dispose
end
def draw_watermark(options)
return if !options.include?(:GameName) && !options.include?(:MapName)
map_name = nil_or_empty?(@@map.name)? pbGetMapNameFromId(@@map.map_id) : @@map.name
game_name = System.game_title
base_color = Color.new(248, 248, 248)
shadow_color = Color.new(64, 64, 64)
new_bmp = Bitmap.new(@@bitmap.width, @@bitmap.height)
if options.include?(:GameName)
if options.include?(:MapName)
pbSetSmallFont(new_bmp)
else
pbSetSystemFont(new_bmp)
end
pbDrawTextPositions(new_bmp, [[game_name, new_bmp.width - 8, new_bmp.height - 32, 1, base_color, shadow_color, true]])
new_font = (@@bitmap.text_size(map_name).height + 6)
else
new_font = 0
end
if options.include?(:MapName)
pbSetSystemFont(new_bmp)
pbDrawTextPositions(new_bmp, [[map_name, new_bmp.width - 8, new_bmp.height - new_font - 38, 1, base_color, shadow_color, true]])
end
scale_factor = get_name_scale
x = @@bitmap.width - (new_bmp.width * scale_factor) - (8 * (scale_factor - 1))
y = @@bitmap.height - (new_bmp.height * scale_factor) - (8 * (scale_factor - 1))
rect = Rect.new(x, y, (new_bmp.width * scale_factor), (new_bmp.height * scale_factor))
@@bitmap.stretch_blt(rect, new_bmp, Rect.new(0, 0, new_bmp.width, new_bmp.height))
new_bmp.dispose
end
def save_map_image
Dir.mkdir("Exported Maps/") if !safeExists?("Exported Maps/")
filestart = Time.now.strftime("[%Y-%m-%d %H-%M]")
map_name = nil_or_empty?(@@map.name)? pbGetMapNameFromId(@@map.map_id) : @@map.name
filename = sprintf("%03d - #{map_name} #{filestart}", @@map.map_id)
min_exists = 0
if safeExists?("Exported Maps/" + filename + ".png")
min_exists = 1
loop do
break if !safeExists?("Exported Maps/" + "#{filename}(#{min_exists})" + ".png")
min_exists += 1
end
end
filename = "#{filename}(#{min_exists})" if min_exists > 0
@@bitmap.to_file("Exported Maps/" + filename + ".png")
@@bitmap.dispose
@@bitmap = nil
@@map = nil
@@helper = nil
end
def create_tiled_bitmap(filename, hue, zoom = 1.0)
begin
bmp = RPG::Cache.load_bitmap("", filename)
rescue
error("Could not load image file at #{filename}")
end
new_bmp = Bitmap.new(@@map.width * Game_Map::TILE_HEIGHT, @@map.height * Game_Map::TILE_WIDTH)
i = 0
while i <= new_bmp.width
j = 0
while j <= new_bmp.height
new_bmp.stretch_blt(Rect.new(i, j, (bmp.width * zoom), (bmp.height * zoom)), bmp, Rect.new(0, 0, bmp.width, bmp.height))
j += (bmp.height * zoom)
end
i += (bmp.width * zoom)
end
bmp.dispose
new_bmp.hue_change(hue)
return new_bmp
end
def get_name_scale
scale = @@map.width/3
d = [0, -1 , -2, 2, 1, 0, -1, -2, 2, 1][scale%10]
scale = (scale + d)/10.0
return (scale < 1.0) ? 1.0 : scale
end
def colorize_and_flip_bitmap(bitmap, color, alpha = 255, rect = nil)
blankcolor = bitmap.get_pixel(0,0)
new_bmp = Bitmap.new(rect.width, rect.height)
temp_bmp = Bitmap.new(rect.width, rect.height)
temp_bmp.blt(0, 0, bitmap, rect)
for x in 0...temp_bmp.width
for y2 in 0...temp_bmp.height
y = temp_bmp.height - y2
newcolor = temp_bmp.get_pixel(x, y2)
new_bmp.set_pixel(x, y, newcolor) if newcolor
end
end
temp_bmp.dispose
shadowcolor = (color ? color : blankcolor)
colorlayer = Bitmap.new(new_bmp.width, new_bmp.height)
colorlayer.fill_rect(colorlayer.rect, shadowcolor)
new_bmp.blt(0, 0, colorlayer, colorlayer.rect, alpha)
shadowcolor = new_bmp.get_pixel(0,0)
for x in 0...new_bmp.width
for y in 0...new_bmp.height
if new_bmp.get_pixel(x,y) == shadowcolor
new_bmp.set_pixel(x, y, blankcolor)
end
end
end
colorlayer.dispose
return new_bmp
end
def set_map_options(options)
return if !options.include?(:Panorama) && !options.include?(:Fog)
@@map.events.each do |key, event|
for page in event.event.pages.reverse
c = page.condition
next if c.switch1_valid && !event.switchIsOn?(c.switch1_id)
next if c.switch2_valid && !event.switchIsOn?(c.switch2_id)
next if c.variable_valid && $game_variables[c.variable_id] < c.variable_value
if c.self_switch_valid
key = [event.map_id, event.id, c.self_switch_ch]
next if $game_self_switches[key] != true
end
page.list.each do |command|
if command.code == 204
case command.parameters[0]
when 0
next if !options.include?(:Panorama)
@@map.panorama_name = command.parameters[1] if !nil_or_empty?(@@map.panorama_name)
@@map.panorama_hue = command.parameters[2] if @@map.panorama_hue <= 0
when 1
next if !options.include?(:Fog)
@@map.fog_name = command.parameters[1] if nil_or_empty?(@@map.fog_name)
@@map.fog_hue = command.parameters[2] if @@map.fog_hue <= 0
@@map.fog_opacity = command.parameters[3] if @@map.fog_opacity < command.parameters[3]
@@map.fog_zoom = command.parameters[5]
end
elsif command.code == 205
next if !options.include?(:Fog)
@@map.fog_tone = command.parameters[0]
elsif command.code == 206
next if !options.include?(:Fog)
@@map.fog_opacity = command.parameters[0] if command.parameters[0] != 0
end
end
break
end
end
end
def error(message)
emessage = "Map Exporter EX Error:\n\n" + message
print(_INTL(emessage))
exit!
end
end
class Game_Map
def tileset_id; return @map.tileset_id; end
end
class DependentEvents
attr_accessor :realEvents
end
class Game_Character
attr_reader :event
attr_reader :always_on_top
end
class PokemonMapFactory
def getMapForExport(id)
map = Game_Map.new
map.setup(id)
return map
end
end

View File

@@ -0,0 +1,74 @@
#
# DebugMenuCommands.register("exportmap", {
# "parent" => "fieldmenu",
# "name" => "Export Map Image",
# "description" => "Select a map and save its image as a png.",
# "effect" => proc {
# pbExportMapSelection
# }
# })
#
# def pbExportMapSelection
# loop do
# map_id = pbListScreen("Export Map", MapLister.new(pbDefaultMap))
# break if map_id <= 0
# commands = ["Events", "Player", "Dependent Events", "Fog", "Panorama", "Map Name", "Game Name"]
# if $game_map.map_id != map_id
# commands.delete("Player")
# commands.delete("Dependent Events")
# end
# options = pbShowMapExportOptions(commands)
# if !options.include?(:Cancel)
# ret = MapExporter.export(map_id, options)
# mapname = pbGetMapNameFromId(map_id)
# pbMessage("Sucessfully exported map image of Map {1} ({2}) to the Exported Maps folder in the games's root.", map_id, mapname)
# return
# end
# end
# end
#
# def pbShowMapExportOptions(commands)
# sel_commands = []
# sym_commands = [:MapName, :GameName]
# cmdwindow = Window_CommandPokemonEx.new([])
# cmdwindow.z = 99999
# cmdwindow.visible = true
# cmdwindow.index = 0
# need_refresh = true
# loop do
# if need_refresh
# sel_commands = []
# commands.each_with_index do |s, i|
# cmd_sym = s.gsub(/\s+/, "").to_sym
# x = sym_commands.include?(cmd_sym) ? "[x]" : "[ ]"
# sel_commands.push("{1} {2}",x, s)
# end
# sel_commands.push("Export Map...")
# cmdwindow.commands = sel_commands
# cmdwindow.resizeToFit(cmdwindow.commands)
# need_refresh = false
# end
# Graphics.update
# Input.update
# cmdwindow.update
# yield if block_given?
# if Input.trigger?(Input::USE)
# break if cmdwindow.index == sel_commands.length - 1
# cmd_sym = commands[cmdwindow.index].gsub(/\s+/, "").to_sym
# if sym_commands.include?(cmd_sym)
# sym_commands.delete(cmd_sym)
# else
# sym_commands.push(cmd_sym)
# end
# sym_commands.uniq!
# need_refresh = true
# elsif Input.trigger?(Input::BACK)
# sym_commands = [:Cancel]
# break
# end
# pbUpdateSceneMap
# end
# cmdwindow.dispose
# Input.update
# return sym_commands
# end