- その他の情報はコメント欄に追記していく
Last active
July 21, 2022 11:57
-
-
Save cacao-soft/5ce0b63265b13f2d9b795447e2ae44d2 to your computer and use it in GitHub Desktop.
RGSS3 共有マクロ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 全アイテム取得 | |
$data_items[1..-1].each {|item| $game_party.gain_item(item, 1) } | |
$data_weapons[1..-1].each {|item| $game_party.gain_item(item, 1) } | |
$data_armors[1..-1].each {|item| $game_party.gain_item(item, 1) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 戦闘テスト | |
if SceneManager.scene.is_a?(Scene_Map) | |
commands = $data_troops[1..-1].map(&:name) | |
res = InputCommand(commands: commands, window_width: 400, col_max: 2) | |
troop_id = (res || -1) + 1 | |
if $data_troops[troop_id] | |
BattleManager.setup(troop_id, true, true) | |
SceneManager.call(Scene_Battle) | |
else | |
# troop_id + 1 -> 0 -> $data_troops[0] -> nil | |
:continue | |
end | |
else | |
puts "<!> 戦闘テストは、マップ画面で実行してください。" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# コモンイベント実行 | |
# コモンイベント 1 をマクロとして使用する | |
event = $data_common_events[1] | |
# 注釈ごとに区切ってマクロとする | |
commands = {} | |
name = nil | |
list = [] | |
event.list.each do |cmd| | |
case cmd.code | |
when 108 | |
commands[name] = list if name && !list.empty? | |
name = cmd.parameters[0] | |
list = [] | |
when 408 | |
# Do Nothing | |
else | |
list << cmd | |
end | |
end | |
commands[name] = list if name && list.size > 1 | |
cmd_name = InputCommand( | |
commands: commands.keys, | |
result: -> { command_name(index) }, | |
col_max: 2, | |
window_width: 500 | |
) | |
if cmd_name | |
case SceneManager.scene | |
when Scene_Map | |
unless $game_map.interpreter.running? | |
$game_map.interpreter.setup(commands[cmd_name]) | |
end | |
when Scene_Battle | |
unless $game_troop.interpreter.running? | |
$game_troop.interpreter.setup(commands[cmd_name]) | |
end | |
else | |
interpreter = Game_Interpreter.new | |
interpreter.setup(commands[cmd_name]) | |
interpreter.update while interpreter.running? | |
end | |
else | |
:continue | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# エンカウントリストの確認 | |
puts "エンカウントリスト" | |
max = 0 | |
$game_map.encounter_list.tap {|ls| puts " [ なし ]" if ls.empty? } | |
.each_with_object([]) do |e,r| | |
name = $data_troops[e.troop_id].name | |
width = name.each_char.inject(0) {|r,c| r + (c.bytesize == 1 ? 1 : 2) } | |
max = width if max < width | |
r << [e, width] | |
end | |
.each do |e,w| | |
puts format( | |
" [ %<name>s%<space>s ] 重み: %<weight>2d 範囲: %<region>s", | |
name: $data_troops[e.troop_id].name, | |
space: " " * (max - w), | |
weight: e.weight, | |
region: e.region_set.tap {|r| break "全体" if r.empty? } | |
) | |
end | |
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 敵キャラ使用場所検索 | |
# バトルの処理で変数指定しているものはわからない | |
# 敵グループで変身している場合、そのグループの使用場所は探さない | |
# イベントのページや行数は表示しない | |
detective = Module.new | |
class << detective | |
def found? | |
@result | |
end | |
def check(command, pattern, *args) | |
label = command_name(command) | |
if label | |
@result = true | |
puts format(label, pattern, args) | |
end | |
end | |
attr_accessor :target_id | |
def target_troops | |
@target_troops ||= [] | |
end | |
def target_name | |
$data_enemies[target_id].name | |
end | |
def ljust(str, width) | |
str << ' ' * (width - str.each_char.inject(0) {|r,c| r+c.bytesize/2+1 } ) | |
end | |
def format(label, pattern, args) | |
" - #{ljust(label, 14)} #{pattern % args.map {|n| '%03d' % n }}" | |
end | |
def command_name(command) | |
return "エンカウント" if command == :encount | |
case command.code | |
when 301 # バトルの処理 | |
case command.parameters[0] | |
when 0 # 直接指定 | |
"バトルの処理" if target_troops.include?(command.parameters[1]) | |
when 1 # 変数で指定 | |
"バトルの処理(変数指定)" | |
end | |
when 336 # 敵キャラの変身 | |
"敵キャラの変身" if command.parameters[1] == target_id | |
end | |
end | |
end | |
index = InputCommand( | |
commands: $data_enemies[1..-1].map(&:name), | |
col_max: 2, | |
window_width: 500 | |
) | |
if index | |
detective.target_id = index + 1 | |
target_troops = detective.target_troops | |
puts "== 使用場所検索 [#{detective.target_name}]" | |
# メンバーになっている敵グループ | |
$data_troops.each do |troop| | |
next unless troop | |
# バトルイベントで出現するか | |
troop.pages.map(&:list).flatten.each do |command| | |
detective.check(command, "バトル: %s", troop.id) | |
end | |
# 敵グループを検索対象に追加 | |
if troop.members.find {|member| member.enemy_id == detective.target_id } | |
target_troops << troop.id | |
end | |
end | |
# マップ、イベントで出現するか | |
Dir.glob("Data/Map*.rvdata2") do |filename| | |
map_id = filename[/(\d{3})/, 1].tap {|n| break n.to_i if n } | |
next unless map_id | |
map = load_data(filename) | |
unless (target_troops & map.encounter_list.map(&:troop_id)).empty? | |
detective.check(:encount, "マップ: %s", map_id) | |
end | |
map.events.each do |event_id,event| | |
event.pages.map(&:list).flatten.each do |command| | |
detective.check(command, "マップ: %s イベント: %s", map_id, event_id) | |
end | |
end | |
end | |
# コモンイベントで出現するか | |
$data_common_events.each do |event| | |
event && event.list.each do |command| | |
detective.check(command, "コモン: %s", event.id) | |
end | |
end | |
puts " 使用されていません" unless detective.found? | |
puts | |
else | |
:continue | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items = | |
case InputCommand(commands: %w(アイテム 武器 防具), alignment: 1) | |
when nil | |
when 0 then $data_items | |
when 1 then $data_weapons | |
when 2 then $data_armors | |
end | |
if items | |
InputCommand( | |
window_width: 480, | |
col_max: 2, | |
commands: items[1..-1].map(&:name), | |
init: -> { | |
@main_window.define_singleton_method(:draw_item) do |index| | |
change_color(normal_color, command_enabled?(index)) | |
rect = item_rect_for_text(index) | |
draw_text(rect, command_name(index), alignment) | |
num = $game_party.item_number(items[index+1]) | |
draw_text(rect, ":%2d" % num, 2) | |
end | |
@main_window.refresh | |
}, | |
command: -> index { | |
$game_party.gain_item(items[@main_window.index+1], 1) | |
@main_window.redraw_current_item | |
} | |
) | |
else | |
:continue | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 「ラ」と「ル」をカウント | |
list = {} | |
list[" マップ "] = $data_mapinfos.inject([]) do |r,(map_id,info)| | |
map = load_data(sprintf("Data/Map%03d.rvdata2", map_id)) | |
r << map.display_name.tap {|name| break info.name if name.empty? } | |
end | |
{ | |
"アクター" => $data_actors, | |
"ク ラ ス" => $data_classes, | |
"ス キ ル" => $data_skills, | |
"アイテム" => $data_items, | |
" 武 器 " => $data_weapons, | |
" 防 具 " => $data_armors, | |
"エネミー" => $data_enemies, | |
}.each {|k,data| list[k] = data.inject([]) {|r,dt| dt ? r << dt.name : r } } | |
puts "「ラ」と「ル」を含む名前を検索" | |
total = list.inject(0) do |r,(k,ls)| | |
ls.uniq.count {|s| s.match(/[らラるル]/) } | |
.tap {|cnt| puts sprintf(" %s : %3d 個", k,cnt) } + r | |
end | |
puts " [ 合 計 ] #{total} 個" | |
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# セルフスイッチ操作 | |
Module.new do module_function | |
keys = %w[A B C D] | |
mapinfos = load_data("Data/MapInfos.rvdata2") | |
commands = [] | |
events = [] | |
mapinfos.each do |map_id,info| | |
commands[map_id] = info.name | |
path = sprintf("Data/Map%03d.rvdata2", map_id) | |
if File.exist?(path) | |
events[map_id] = load_data(path).events | |
events[map_id] = nil if events[map_id].empty? | |
end | |
end | |
InputList( # マップの選択 | |
commands: commands, | |
command_enabled?: -> x { events[x] }, | |
row_max: 5, | |
start_id: 1, | |
init: -> { @main_window.y = 30 } | |
) do |map_id| | |
r = InputList( # イベントの選択 | |
commands: events[map_id].values.map(&:name), | |
data: events[map_id].values, | |
command_data: -> id { | |
keys.map {|k| $game_self_switches[[map_id, @data[id].id, k]] ? '■' : '□' }.join | |
}, | |
row_max: 5, | |
start_id: 1, | |
init: -> { @main_window.y = 218 } | |
) do |index, event| | |
r = InputCommand( # スイッチの設定 | |
window_width: 100, | |
commands: keys, | |
draw_item: -> index { | |
key = [map_id, event.id, keys[index]] | |
change_color(normal_color, command_enabled?(index)) | |
rect = item_rect_for_text(index) | |
draw_text(rect, command_name(index)) | |
draw_text(rect, $game_self_switches[key] ? 'O N' : 'OFF', 2) | |
}, | |
command: -> index { | |
$game_self_switches[[map_id, event.id, keys[index]]] ^= true | |
@main_window.redraw_current_item | |
self.result = @main_window.result | |
return_scene(false) | |
} | |
) | |
@main_window.redraw_current_item | |
if r | |
self.result = @main_window.result | |
return_scene(false) | |
end | |
end | |
if r | |
return_scene(false) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# イベントコマンド「スクリプト」で特定の文字が使われている箇所を探します。 | |
# 検索結果は、コンソール画面に次のように表示されます。 | |
# | |
# == マップ名 | |
# イベント名 (座標) ページ番号 (行番号): "見つかった行のテキスト" | |
# | |
# 検索する文字 | |
word = InputBox("検索する文字を入力してください") | |
if word.empty? | |
:continue | |
else | |
result = {} | |
Dir.glob("Data/Map???.rvdata2") do |path| | |
next unless path[/Map(\d{3})\./] | |
map_id = $1.to_i | |
map = load_data(path) | |
map.events.each do |ev_id,ev| | |
ev.pages.each.with_index(1) do |page,i| | |
page.list.each.with_index(1) do |cmd,j| | |
next unless cmd.code == 355 || cmd.code == 655 | |
script = cmd.parameters[0] | |
if script.include?(word) | |
(result[map_id] ||= []) << | |
sprintf(" %s (%d,%d) Page %d (%d): \"%s\"\n", ev.name, ev.x, ev.y, i, j, script) | |
end | |
end | |
end | |
end | |
end | |
mapinfos = load_data("Data/MapInfos.rvdata2") | |
result.each do |map_id, list| | |
puts "== #{mapinfos[map_id].name}" | |
list.each(&:display) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# スイッチ操作 | |
Module.new do module_function | |
InputList( | |
commands: $data_system.switches, | |
data: $game_switches, | |
command_data: -> x { @data[x] ? "O N" : "OFF" }, | |
start_id: 1 | |
) do |switch_id| | |
if switch_id | |
index = InputCommand( | |
index: $game_switches[switch_id] ? 1 : 0, | |
commands: %w(ON OFF), | |
alignment: 1 | |
) | |
if index | |
$game_switches[switch_id] = index == 0 | |
@main_window.redraw_current_item | |
end | |
end | |
return_scene(false) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 変数操作 | |
Module.new do module_function | |
InputList(commands: $data_system.variables, data: $game_variables, start_id: 1) do |variable_id| | |
if variable_id | |
value = InputNumber( | |
number: $game_variables[variable_id], | |
item_max: 8, | |
signedness: true | |
) | |
if value | |
$game_variables[variable_id] = value | |
@main_window.redraw_current_item | |
end | |
end | |
return_scene(false) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
変数操作
スイッチ操作
セルフスイッチ