【概要】
RPGツクールXP用のデフォルト戦闘へオート戦闘コマンド(通常攻撃のみ)を追加するスクリプトです。
通常の"戦う"、"逃げる"の間に"オート"のコマンドが表示され、選択できるようになります。
内部ではコマンド選択後に"敵を通常攻撃する"ステータスをパーティに自動で付加します。
ターン終了と戦闘終了時にオートのステータスは自動で解除されます。
【使い方】
・まず、データベースのステートへオート用のステータスを新規で追加します。
・スクリプト内の上部にあるカスタマイズ要素の部分をお好みで変更します。
・スクリプトエディタを開き、Mainより上の位置にスクリプトをコピペするなどして挿入します。
・他の方が公開されているスクリプトとは共存できない場合があります。
【利用規約】
・本スクリプトは有償、無償に関わらず、ご自由にご利用いただけます。
・年齢制限のある作品でも利用が可能です。
・スクリプトの作者(naya)への利用報告は必要ありません。
・READMEテキスト等へのクレジットの表記も不要です。
・本スクリプトを自作した物として単独で公開、販売をすることはできません。
・本スクリプトを改造した物を公開する場合は引用元を明記した上で公開してください。
・本スクリプトを利用した事により発生するあらゆる問題に作者(naya)は一切の責任を負いません。
・以上の規約に同意していただける方のみ当スクリプトを利用する事ができます。
# 以下がスクリプトのテキストです。
#==============================================================================
# ★SimpleAutoBattleCommand(簡易オート戦闘コマンド)Ver1.0★
# 製作者:naya
# 作成日:2024/2/18
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# パーティーコマンドにオート(敵を通常攻撃する)を追加します。
# データベースのステータスにオートを追加で作成して
# $auto_stat_idにステータスのIDを入れます。
#==============================================================================
#カスタマイズ要素
$auto_stat_id = 17 #オート状態のステータスID
$auto_stat_name = "AUTO" #オート状態のステータス名
$auto_command_name = "自動戦闘" #オート戦闘のコマンド名
#==============================================================================
# ■ Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@commands = ["戦う", $auto_command_name, "逃げる"]
@item_max = 3
@column_max = 3
draw_item(0, normal_color)
draw_item(1, normal_color)
draw_item(2, $game_temp.battle_can_escape ? normal_color : disabled_color)
self.active = false
self.visible = false
self.index = 0
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(80 + index * 160 + 4, 0, 128 - 10, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(80 + index * 160, 0, 128, 32)
end
end
#==============================================================================
# ■ Scene_Battle (分割定義 2)
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● パーティコマンドフェーズ開始
#--------------------------------------------------------------------------
def start_phase2
set_auto_status
auto_remove
# フェーズ 2 に移行
@phase = 2
# アクターを非選択状態に設定
@actor_index = -1
@active_battler = nil
# パーティコマンドウィンドウを有効化
@party_command_window.active = true
@party_command_window.visible = true
# アクターコマンドウィンドウを無効化
@actor_command_window.active = false
@actor_command_window.visible = false
# メインフェーズフラグをクリア
$game_temp.battle_main_phase = false
# パーティ全員のアクションをクリア
$game_party.clear_actions
# コマンド入力不可能な場合
unless $game_party.inputable?
# メインフェーズ開始
start_phase4
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (パーティコマンドフェーズ)
#--------------------------------------------------------------------------
def update_phase2
# C ボタンが押された場合
if Input.trigger?(Input::C)
# パーティコマンドウィンドウのカーソル位置で分岐
case @party_command_window.index
when 0 # 戦う
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# アクターコマンドフェーズ開始
start_phase3
when 1 # オート
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
auto_add
# アクターコマンドフェーズ開始
start_phase3
when 2 # 逃げる
# 逃走可能ではない場合
if $game_temp.battle_can_escape == false
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 逃走処理
update_phase2_escape
end
return
end
end
#--------------------------------------------------------------------------
# ● アフターバトルフェーズ開始
#--------------------------------------------------------------------------
def start_phase5
auto_remove
# フェーズ 5 に移行
@phase = 5
# バトル終了 ME を演奏
$game_system.me_play($game_system.battle_end_me)
# バトル開始前の BGM に戻す
$game_system.bgm_play($game_temp.map_bgm)
# EXP、ゴールド、トレジャーを初期化
exp = 0
gold = 0
treasures = []
# ループ
for enemy in $game_troop.enemies
# エネミーが隠れ状態でない場合
unless enemy.hidden
# 獲得 EXP、ゴールドを追加
exp += enemy.exp
gold += enemy.gold
# トレジャー出現判定
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
# トレジャーの数を 6 個までに限定
treasures = treasures[0..5]
# EXP 獲得
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# ゴールド獲得
$game_party.gain_gold(gold)
# トレジャー獲得
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
when RPG::Armor
$game_party.gain_armor(item.id, 1)
end
end
# バトルリザルトウィンドウを作成
@result_window = Window_BattleResult.new(exp, gold, treasures)
# ウェイトカウントを設定
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
# ● ステータス情報を書き換える
#--------------------------------------------------------------------------
def set_auto_status
if $data_states[$auto_stat_id] != nil
$data_states[$auto_stat_id].name = $auto_stat_name
$data_states[$auto_stat_id].restriction = 2
$data_states[$auto_stat_id].nonresistance = true
$data_states[$auto_stat_id].rating = 10
end
end
#--------------------------------------------------------------------------
# ● オートステータスを強制的にオンにする
#--------------------------------------------------------------------------
def auto_add
actors_number = 0
for actor in $game_party.actors
if actor.exist?
actor.add_state($auto_stat_id, true)
actors_number += 1
end
end
@status_window.refresh
end
#--------------------------------------------------------------------------
# ● オートステータスを強制的にオフにする
#--------------------------------------------------------------------------
def auto_remove
actors_number = 0
for actor in $game_party.actors
if actor.exist?
actor.remove_state($auto_stat_id, true)
actors_number += 1
end
end
@status_window.refresh
end
end