-
Amphilohiy
-
-
Вне сайта
-
Светлый дракон
-
- Сообщений: 547
- Спасибо получено: 666
-
-
|
Данный скрипт позволяет определить какие переменные и свитчи используются в игре, а какие не имеют никаких связей. Скрипт так же позволит определить сами связи, а именно: условия страниц (в обычных событиях, общих и боевых) и команд "control_switches", "control_variables", "conditional_branch". Так же, вплоть до строчки в коде, будет обозначатся местоположение связи.
Версия: релиз 2
Патч ноты:
Релиз 2:
- Переделан интерфейс (правая часть) возвращен русский язык
- Один скрипт работает как под VX Ace, так и под XP (и не спрашивайте зачем)
Демо не прилагается, по причине системы plug&play просто установите скрипт и в режиме дебага нажмите F8
Сам скрипт:
# Мониторинг Свитчей и переменных release 2
# Во время дебагинга нажмите F8
begin
some_var = DataManager
rescue
$maker_ver = :xp
else
$maker_ver = :vx_ace
end
module VarTest
def self.run
if $vartest_vars == nil and $vartest_switches == nil then
$vartest_vars = [:dummy]
$vartest_switches = [:dummy]
flefrm = ".rxdata" if $maker_ver == :xp
flefrm = ".rvdata2" if $maker_ver == :vx_ace
for ia in 0..999
if FileTest.exist?(sprintf("Data/Map%03d" + flefrm, ia)) then
@map = load_data(sprintf("Data/Map%03d" + flefrm, ia))
@map_id = ia
@map.events.each {|ib|
@page_id = 0
@event_id = ib[0]
@event = ib[1]
@event.pages.each {|ic|
@page_id += 1
@line_id = 0
@page = ic
@type_id = :map_cond
check_map_cond
@page.list.each {|id|
@line_id += 1
@line = id
@type_id = :map
check
}
}
}
end
end
@event_id = -1
$data_common_events.each{|ia|
@event_id += 1
@event = ia
if ia != nil then
@type_id = :common_cond
check_common_cond
@line_id = 0
@type_id = :common
ia.list.each {|ib|
@line_id += 1
@line = ib
check
}
end
}
@troop_id = 0
$data_troops.each{|ia|
if ia != nil then
@troop_id += 1
@troop = ia
@page_id = 0
ia.pages.each{|ib|
@page = ib
@page_id += 1
@type_id = :battle_cond
check_battle_cond
@line_id = 0
@type_id = :battle
@page.list.each{|ic|
@line = ic
@line_id += 1
check
}
}
end
}
end
end
def self.check_battle_cond
if @page.condition.switch_valid then
$vartest_switches[@page.condition.switch_id] = [] if $vartest_switches[@page.condition.switch_id] == nil
$vartest_switches[@page.condition.switch_id].push(make_data)
end
end
def self.check_map_cond
if @page.condition.variable_valid then
$vartest_vars[@page.condition.variable_id] = [] if $vartest_vars[@page.condition.variable_id] == nil
$vartest_vars[@page.condition.variable_id].push(make_data)
end
if @page.condition.switch1_valid then
$vartest_switches[@page.condition.switch1_id] = [] if $vartest_switches[@page.condition.switch1_id] == nil
$vartest_switches[@page.condition.switch1_id].push(make_data)
end
if @page.condition.switch2_valid then
$vartest_switches[@page.condition.switch1_id] = [] if $vartest_switches[@page.condition.switch1_id] == nil
$vartest_switches[@page.condition.switch1_id].push(make_data)
end
end
def self.check_common_cond
if @event.trigger != 0 then
$vartest_switches[@event.switch_id] = [] if $vartest_switches[@event.switch_id] == nil
$vartest_switches[@event.switch_id].push(make_data)
end
end
def self.make_data
case @type_id
when :map
{:type => @type_id, :map_id => @map_id, :event_id => @event_id, :page_id => @page_id, :line_id => @line_id, :code_id => @line.code}
when :map_cond
{:type => @type_id, :map_id => @map_id, :event_id => @event_id, :page_id => @page_id}
when :common
{:type => @type_id, :event_id => @event_id, :line_id => @line_id, :code_id => @line.code}
when :common_cond
{:type => @type_id, :event_id => @event_id}
when :battle
{:type => @type_id, :troop_id => @troop_id, :page_id => @page_id, :line_id => @line_id, :code_id => @line.code}
when :battle_cond
{:type => @type_id, :troop_id => @troop_id, :page_id => @page_id}
end
end
def self.check
if @line.code == 122 then
$vartest_vars[@line.parameters[0]] = [] if $vartest_vars[@line.parameters[0]] == nil
$vartest_vars[@line.parameters[0]].push(make_data)
end
if @line.code == 121 then
$vartest_switches[@line.parameters[0]] = [] if $vartest_switches[@line.parameters[0]] == nil
$vartest_switches[@line.parameters[0]].push(make_data)
end
if @line.code == 111 then
if @line.parameters[0] == 0 then
$vartest_switches[@line.parameters[1]] = [] if $vartest_switches[@line.parameters[1]] == nil
$vartest_switches[@line.parameters[1]].push(make_data)
elsif @line.parameters[0] == 1 then
$vartest_vars[@line.parameters[1]] = [] if $vartest_vars[@line.parameters[1]] == nil
$vartest_vars[@line.parameters[1]].push(make_data)
end
end
end
end
if $maker_ver == :xp then
class Scene_Map
alias update_vartest update
def update
update_vartest
if $DEBUG and Input.press?(Input::F8)
$scene = Scene_VarTest.new
end
end
end
class Scene_VarTest
def main
@spriteset = Spriteset_Map.new
@loading_wnd = Window_VarTest_Wait.new
Graphics.transition
@loading_wnd.update
VarTest.run
@loading_wnd.dispose
@left_wnd = Window_VarTest_Left.new
@right_wnd = Window_VarTest_Right.new
@bottom_wnd = Window_VarTest_Bottom.new
@right_wnd.help_window = @bottom_wnd
@left_wnd.help_window = @right_wnd
@right_wnd.active = false
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
@spriteset.dispose
@left_wnd.dispose
@right_wnd.dispose
@bottom_wnd.dispose
end
def act_left
@left_wnd.active = true
@right_wnd.active = false
end
def act_right
@left_wnd.active = false
@right_wnd.active = true
end
def update
@left_wnd.update
@right_wnd.update
end
end
class Window_VarTest_Wait < Window_Base
def initialize
super((640 - 320) / 2, (480 - 60) / 2, 320, 60)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(0, 0, width, 24, "Подождите, скрипт работает")
end
end
class Window_VarTest_Left < Window_Selectable # Pfffff
def initialize()
super(0, 0, 320, 480)
@item_max = $vartest_vars.size + $vartest_switches.size - 2
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
if index < $vartest_vars.size - 1
index += 1
text = "[V]" + sprintf("%04d", index) + ":" + $data_system.variables[index].to_s
if $vartest_vars[index] != nil
text += " (ЗАНЯТ)"
else
text += " (СВОБОДЕН)"
end
self.contents.draw_text(rect, text)
else
index -= $vartest_vars.size - 2
text = "[S]" + sprintf("%04d", index) + ":" + $data_system.switches[index].to_s
if $vartest_switches[index] != nil
text += " (ЗАНЯТ)"
else
text += " (СВОБОДЕН)"
end
self.contents.draw_text(rect, text)
end
end
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::C)
$game_system.se_play($data_system.decision_se )
$scene.act_right
end
end
if self.active
if Input.repeat?(Input::B)
$game_system.se_play($data_system.cancel_se )
$scene = Scene_Map.new
end
end
end
def update_help
@help_window.respond(self.index, $vartest_vars[self.index + 1]) if self.index < $vartest_vars.size - 1
@help_window.respond(self.index, $vartest_switches[self.index - $vartest_vars.size + 2]) if self.index >= $vartest_vars.size - 1
end
end
class Window_VarTest_Right < Window_Selectable
def initialize()
super(320, 0, 320, 480 - 32 * 3)
@item_max = 0
self.contents = Bitmap.new(320 - 32, [@item_max * 32, 1].max)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.index = 0
end
def respond(index, info)
if @index_ch != index && index != nil
@index_ch = index
@info = info
if @info
@item_max = @info.size
else
@item_max = 0
end
self.contents.dispose
self.contents = Bitmap.new(320 - 32, [@item_max * 32, 32].max)
self.index = 0
refresh
update_help
update_cursor_rect
end
end
def update
super
if self.active
if Input.repeat?(Input::B)
$game_system.se_play($data_system.cancel_se )
$scene.act_left
end
end
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
ia = @info[index]
case ia[:type]
when :common
text = "Общее событие, код"
when :battle
text = "Событие отряда, код"
when :battle_cond
text = "Событие отряда, условие"
when :common_cond
text = "Общее событие, условие"
when :map_cond
text = "Событие на карте, условие"
when :map
text = "Событие на карте, код"
end
self.contents.draw_text(rect, text)
end
def update_help
@help_window.respond(@info[self.index]) if @info != nil
@help_window.respond(nil) if @info == nil
end
end
class Window_VarTest_Bottom < Window_Base
def initialize
super(320, 480 - 32 * 3, 320, 32 * 3)
self.contents = Bitmap.new(320 - 32, 32 * 2)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end
def respond(info)
self.contents.clear
ia = info
if info != nil then
text = ""
text2 = ""
text += "Выражение" if ia[:code_id] == 122 or ia[:code_id] == 121
text += "Условие" if ia[:code_id] == 111
case ia[:type]
when :common
text += ", Номер " + ia[:event_id].to_s
text2 +="Строка " + ia[:line_id].to_s
when :battle
text += ", Отряд " + ia[:troop_id].to_s
text2 += "Страница " + ia[:page_id].to_s + ", Строка " + ia[:line_id].to_s
when :battle_cond
text += "Отряд " + ia[:troop_id].to_s
text2 += "Страница " + ia[:page_id].to_s
when :common_cond
text += "Событие " + ia[:event_id].to_s
when :map_cond
text += "Карта " + ia[:map_id].to_s
text2 += "Событие " + ia[:event_id].to_s + ", Страница " + ia[:page_id].to_s
when :map
text += ", Карта " + ia[:map_id].to_s + ",Событие " + ia[:event_id].to_s
text2 += "Страница " + ia[:page_id].to_s + ", Строка " + ia[:line_id].to_s
end
contents.draw_text(0, 0, 320 - 32, 32, text)
contents.draw_text(0, 32, 320 - 32, 32, text2)
else
contents.draw_text(0, 0, 320 - 32, 32 * 2, "*Перекати поле*")
end
end
end
else
class Scene_Map
alias update_call_debug_vartest update_call_debug
def update_call_debug
update_call_debug_vartest
SceneManager.call(Scene_VarTest) if $TEST && Input.press?(:F8)
end
end
class Scene_VarTest < Scene_Base
def start
super
create_background
@loading_wnd = Window_VarTest_Wait.new
Graphics.transition
VarTest.run
@loading_wnd.dispose
@loading_wnd = nil
end
def post_start
super
@left_wnd = Window_VarTest_Left.new
@right_wnd = Window_VarTest_Right.new
@bottom_wnd = Window_VarTest_Bottom.new
@right_wnd.help_window = @bottom_wnd
@left_wnd.help_window = @right_wnd
@left_wnd.activate
end
def terminate
super
dispose_background
end
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = SceneManager.background_bitmap
@background_sprite.color.set(16, 16, 16, 128)
end
def dispose_background
@background_sprite.dispose
end
def act_left
@left_wnd.active = true
@right_wnd.active = false
end
def act_right
@left_wnd.active = false
@right_wnd.active = true
end
end
class Window_VarTest_Wait < Window_Base
def initialize
super((Graphics.width - width) / 2, (Graphics.height - height) / 2, width, height)
self.contents = Bitmap.new(width - 2 * standard_padding, height - 2 * standard_padding)
refresh
end
def width
320
end
def height
line_height + 2 * standard_padding
end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, width, 24, "Подождите, скрипт работает")
end
end
class Window_VarTest_Left < Window_Selectable
def initialize()
super(0, 0, Graphics.width / 2, Graphics.height)
self.index = 0
set_handler(:ok, method(:on_ok))
set_handler(:cancel, method(:on_cancel))
refresh
end
def contents_width
width - standard_padding * 2
end
def contents_height
item_max * line_height
end
def item_max
$vartest_vars.size + $vartest_switches.size - 2
end
def draw_item(index)
rect = item_rect(index)
if index < $vartest_vars.size - 1
index += 1
text = "[V]" + sprintf("%04d", index) + ":" + $data_system.variables[index].to_s
if $vartest_vars[index] != nil
text += " (ЗАНЯТ)"
else
text += " (СВОБОДЕН)"
end
self.contents.draw_text(rect, text)
else
index -= $vartest_vars.size - 2
text = "[S]" + sprintf("%04d", index) + ":" + $data_system.switches[index].to_s
if $vartest_switches[index] != nil
text += " (ЗАНЯТ)"
else
text += " (СВОБОДЕН)"
end
self.contents.draw_text(rect, text)
end
end
def on_ok
Sound.play_ok
SceneManager.scene.act_right
end
def on_cancel
Sound.play_cancel
SceneManager.return
end
def update_help
@help_window.respond(self.index, $vartest_vars[self.index + 1]) if self.index < $vartest_vars.size - 1
@help_window.respond(self.index, $vartest_switches[self.index - $vartest_vars.size + 2]) if self.index >= $vartest_vars.size - 1
end
end
class Window_VarTest_Right < Window_Selectable
def initialize()
super(Graphics.width / 2, 0, Graphics.width / 2, Graphics.height - 2 * standard_padding - 2 * line_height)
self.index = 0
set_handler(:cancel, method(:on_cancel))
refresh
end
def contents_width
width - standard_padding * 2
end
def contents_height
item_max * line_height
end
def item_max
if @info
@info.size
else
0
end
end
def respond(index, info)
if @index_ch != index && index != nil
@index_ch = index
@info = info
self.index = 0
refresh
update_help
update_cursor
end
end
def on_cancel
Sound.play_cancel
SceneManager.scene.act_left
end
def refresh
create_contents
draw_all_items
end
def draw_item(index)
rect = item_rect(index)
ia = @info[index]
case ia[:type]
when :common
text = "Общее событие, код"
when :battle
text = "Событие отряда, код"
when :battle_cond
text = "Событие отряда, условие"
when :common_cond
text = "Общее событие, условие"
when :map_cond
text = "Событие на карте, условие"
when :map
text = "Событие на карте, код"
end
self.contents.draw_text(rect, text)
end
def update_help
@help_window.respond(@info[self.index]) if @info != nil
@help_window.respond(nil) if @info == nil
end
end
class Window_VarTest_Bottom < Window_Base
def initialize
super(Graphics.width / 2, Graphics.height - 2 * standard_padding - 2 * line_height, Graphics.width / 2, 2 * standard_padding + 2 * line_height)
self.contents = Bitmap.new(Graphics.width / 2 - 2 * standard_padding, 2 * line_height)
end
def respond(info)
self.contents.clear
ia = info
if info != nil then
text = ""
text2 = ""
text += "Выражение" if ia[:code_id] == 122 or ia[:code_id] == 121
text += "Условие" if ia[:code_id] == 111
case ia[:type]
when :common
text += ", Номер " + ia[:event_id].to_s
text2 +="Строка " + ia[:line_id].to_s
when :battle
text += ", Отряд " + ia[:troop_id].to_s
text2 += "Страница " + ia[:page_id].to_s + ", Строка " + ia[:line_id].to_s
when :battle_cond
text += "Отряд " + ia[:troop_id].to_s
text2 += "Страница " + ia[:page_id].to_s
when :common_cond
text += "Событие " + ia[:event_id].to_s
when :map_cond
text += "Карта " + ia[:map_id].to_s
text2 += "Событие " + ia[:event_id].to_s + ", Страница " + ia[:page_id].to_s
when :map
text += ", Карта " + ia[:map_id].to_s + ",Событие " + ia[:event_id].to_s
text2 += "Страница " + ia[:page_id].to_s + ", Строка " + ia[:line_id].to_s
end
contents.draw_text(0, 0, Graphics.width / 2 - 2 * standard_padding, line_height, text)
contents.draw_text(0, line_height, Graphics.width / 2 - 2 * standard_padding, line_height, text2)
else
contents.draw_text(0, 0, Graphics.width / 2 - 2 * standard_padding, line_height, "*Перекати поле*")
end
end
end
end
|