Initial Commit
This commit is contained in:
commit
81d2cf8f0d
570 changed files with 959092 additions and 0 deletions
106
.gitignore
vendored
Normal file
106
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# Ignore all files
|
||||
*.*
|
||||
|
||||
# File Types
|
||||
!*.mps
|
||||
!*.dat
|
||||
!*.json
|
||||
!*.txt
|
||||
!*.project
|
||||
!*.js
|
||||
!*.zip
|
||||
!*.7z
|
||||
!*.csv
|
||||
!*.ain
|
||||
!*.fnl
|
||||
!*.ks
|
||||
!*.tjs
|
||||
!*.yaml
|
||||
!*.rb
|
||||
|
||||
# Other Needed Files
|
||||
!.gitignore
|
||||
!README.md
|
||||
!patch-config.txt
|
||||
!GAMEUPDATE.bat
|
||||
|
||||
# Ignore
|
||||
previous_patch_sha.txt
|
||||
kabe3_save.dat
|
||||
kabe3_system.dat
|
||||
psbpack.dat
|
||||
|
||||
# Images
|
||||
!hsb001.rpgmvp
|
||||
!hsh0.rpgmvp
|
||||
!hsh100.rpgmvp
|
||||
!hsh101.rpgmvp
|
||||
!hsh102.rpgmvp
|
||||
!hsh103.rpgmvp
|
||||
!hsh104.rpgmvp
|
||||
!hsh105.rpgmvp
|
||||
!hsh106.rpgmvp
|
||||
!hsh107.rpgmvp
|
||||
!hsh108.rpgmvp
|
||||
!hsh109.rpgmvp
|
||||
!hsh11.rpgmvp
|
||||
!hsh110.rpgmvp
|
||||
!hsh111.rpgmvp
|
||||
!hsh12.rpgmvp
|
||||
!hsh13.rpgmvp
|
||||
!hsh14.rpgmvp
|
||||
!hsh15.rpgmvp
|
||||
!hsh16.rpgmvp
|
||||
!hsh17.rpgmvp
|
||||
!hsh18.rpgmvp
|
||||
!hsh19.rpgmvp
|
||||
!hsh20.rpgmvp
|
||||
!hsh21.rpgmvp
|
||||
!hsh22.rpgmvp
|
||||
!hsh23.rpgmvp
|
||||
!hsh24.rpgmvp
|
||||
!hsh25.rpgmvp
|
||||
!hsh26.rpgmvp
|
||||
!hsh27.rpgmvp
|
||||
!hsh28.rpgmvp
|
||||
!hsh29.rpgmvp
|
||||
!hsh30.rpgmvp
|
||||
!hsh31.rpgmvp
|
||||
!hsh32.rpgmvp
|
||||
!hsh33.rpgmvp
|
||||
!hsh34.rpgmvp
|
||||
!hsh35.rpgmvp
|
||||
!hsh36.rpgmvp
|
||||
!hsh37.rpgmvp
|
||||
!hsh38.rpgmvp
|
||||
!hsh39.rpgmvp
|
||||
!hsh41.rpgmvp
|
||||
!hsh42.rpgmvp
|
||||
!hsh43.rpgmvp
|
||||
!hsh44.rpgmvp
|
||||
!hsh45.rpgmvp
|
||||
!hsh46.rpgmvp
|
||||
!hsh47.rpgmvp
|
||||
!hsh48.rpgmvp
|
||||
!hsh49.rpgmvp
|
||||
!hsh50.rpgmvp
|
||||
!hsh60.rpgmvp
|
||||
!hsh61.rpgmvp
|
||||
!hsh62.rpgmvp
|
||||
!hsh63.rpgmvp
|
||||
!hsh64.rpgmvp
|
||||
!hssa1.rpgmvp
|
||||
!hssb1.rpgmvp
|
||||
!hssc1.rpgmvp
|
||||
!hssd1.rpgmvp
|
||||
!hsse1.rpgmvp
|
||||
!hssf1.rpgmvp
|
||||
!hssg1.rpgmvp
|
||||
!hssh1.rpgmvp
|
||||
!hssi1.rpgmvp
|
||||
!sab04.rpgmvp
|
||||
!sab05.rpgmvp
|
||||
!sab06.rpgmvp
|
||||
!sab17.rpgmvp
|
||||
!sab18.rpgmvp
|
||||
!sab30.rpgmvp
|
||||
72
GAMEUPDATE.bat
Normal file
72
GAMEUPDATE.bat
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Check if patch-config.txt exists
|
||||
if not exist patch-config.txt (
|
||||
echo "Config file (patch-config.txt) not found! Assuming no patching needed."
|
||||
exit /b
|
||||
)
|
||||
|
||||
REM Read configuration from file
|
||||
for /f "tokens=1,2 delims==" %%a in (patch-config.txt) do (
|
||||
if "%%a"=="username" set "username=%%b"
|
||||
if "%%a"=="repo" set "repo=%%b"
|
||||
if "%%a"=="branch" set "branch=%%b"
|
||||
)
|
||||
|
||||
REM Get the latest hash
|
||||
echo "Getting latest commit SHA hash"
|
||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.github.com/repos/%username%/%repo%/branches/%branch%').Content | ConvertFrom-Json | Select-Object -ExpandProperty commit | Select-Object -ExpandProperty sha" > latest_patch_sha.txt
|
||||
|
||||
REM Read the latest SHA from the file
|
||||
set /p latest_patch_sha=<latest_patch_sha.txt
|
||||
|
||||
REM Check if previous_patch_sha.txt exists
|
||||
if not exist previous_patch_sha.txt (
|
||||
echo "Previous SHA hash not found!"
|
||||
echo "Assuming first time patching..."
|
||||
goto download_extract
|
||||
)
|
||||
|
||||
REM Read the stored SHA from previous check
|
||||
set /p previous_patch_sha=<previous_patch_sha.txt
|
||||
|
||||
REM Trim whitespace from SHA strings
|
||||
set "previous_patch_sha=%previous_patch_sha: =%"
|
||||
set "latest_patch_sha=%latest_patch_sha: =%"
|
||||
|
||||
REM Compare trimmed SHAs
|
||||
if "%latest_patch_sha%" neq "%previous_patch_sha%" (
|
||||
echo "Update found! Patching...
|
||||
goto download_extract
|
||||
) else (
|
||||
echo "Patch is up to date."
|
||||
)
|
||||
|
||||
REM Delete latest_patch_sha.txt
|
||||
del latest_patch_sha.txt
|
||||
|
||||
endlocal
|
||||
exit /b
|
||||
|
||||
:download_extract
|
||||
REM Download zip file
|
||||
echo "Downloading latest patch..."
|
||||
powershell -Command "Invoke-WebRequest -Uri 'https://codeload.github.com/%username%/%repo%/zip/refs/heads/%branch%' -OutFile 'repo.zip'"
|
||||
|
||||
REM Extract contents, overwriting conflicts
|
||||
echo "Extracting..."
|
||||
powershell -Command "Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
|
||||
echo "Applying patch..."
|
||||
xcopy /s /e /y "%repo%-%branch%\*" "."
|
||||
|
||||
REM Clean up
|
||||
echo "Cleaning up..."
|
||||
del repo.zip
|
||||
rmdir /s /q "%repo%-main"
|
||||
del latest_patch_sha.txt
|
||||
|
||||
REM Store latest SHA for next check
|
||||
echo %latest_patch_sha% > previous_patch_sha.txt
|
||||
endlocal
|
||||
exit /b
|
||||
392
Scripts/BattleManager.rb
Normal file
392
Scripts/BattleManager.rb
Normal file
|
|
@ -0,0 +1,392 @@
|
|||
#==============================================================================
|
||||
# ■ BattleManager
|
||||
#------------------------------------------------------------------------------
|
||||
# 戦闘の進行を管理するモジュールです。
|
||||
#==============================================================================
|
||||
|
||||
module BattleManager
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def self.setup(troop_id, can_escape = true, can_lose = false)
|
||||
init_members
|
||||
$game_troop.setup(troop_id)
|
||||
@can_escape = can_escape
|
||||
@can_lose = can_lose
|
||||
make_escape_ratio
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def self.init_members
|
||||
@phase = :init # 戦闘進行フェーズ
|
||||
@can_escape = false # 逃走可能フラグ
|
||||
@can_lose = false # 敗北可能フラグ
|
||||
@event_proc = nil # イベント用コールバック
|
||||
@preemptive = false # 先制攻撃フラグ
|
||||
@surprise = false # 不意打ちフラグ
|
||||
@actor_index = -1 # コマンド入力中のアクター
|
||||
@action_forced = nil # 戦闘行動の強制
|
||||
@map_bgm = nil # 戦闘前の BGM 記憶用
|
||||
@map_bgs = nil # 戦闘前の BGS 記憶用
|
||||
@action_battlers = [] # 行動順序リスト
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def self.on_encounter
|
||||
@preemptive = (rand < rate_preemptive)
|
||||
@surprise = (rand < rate_surprise && !@preemptive)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先制攻撃の確率取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.rate_preemptive
|
||||
$game_party.rate_preemptive($game_troop.agi)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 不意打ちの確率取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.rate_surprise
|
||||
$game_party.rate_surprise($game_troop.agi)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● BGM と BGS の保存
|
||||
#--------------------------------------------------------------------------
|
||||
def self.save_bgm_and_bgs
|
||||
@map_bgm = RPG::BGM.last
|
||||
@map_bgs = RPG::BGS.last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘 BGM の演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def self.play_battle_bgm
|
||||
$game_system.battle_bgm.play
|
||||
RPG::BGS.stop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了 ME の演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def self.play_battle_end_me
|
||||
$game_system.battle_end_me.play
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● BGM と BGS の再開
|
||||
#--------------------------------------------------------------------------
|
||||
def self.replay_bgm_and_bgs
|
||||
@map_bgm.replay unless $BTEST
|
||||
@map_bgs.replay unless $BTEST
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 逃走成功率の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.make_escape_ratio
|
||||
@escape_ratio = 2.2 - 1.0 * $game_troop.agi / $game_party.agi
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン実行中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.in_turn?
|
||||
@phase == :turn
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン終了中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.turn_end?
|
||||
@phase == :turn_end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘中断判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.aborting?
|
||||
@phase == :aborting
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 逃走許可の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.can_escape?
|
||||
@can_escape
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド入力中のアクターを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.actor
|
||||
@actor_index >= 0 ? $game_party.members[@actor_index] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド入力中のアクターをクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def self.clear_actor
|
||||
@actor_index = -1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def self.next_command
|
||||
begin
|
||||
if !actor || !actor.next_command
|
||||
@actor_index += 1
|
||||
return false if @actor_index >= $game_party.members.size
|
||||
end
|
||||
end until actor.inputable?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def self.prior_command
|
||||
begin
|
||||
if !actor || !actor.prior_command
|
||||
@actor_index -= 1
|
||||
return false if @actor_index < 0
|
||||
end
|
||||
end until actor.inputable?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントへのコールバック用 Proc の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.event_proc=(proc)
|
||||
@event_proc = proc
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト用メソッドの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.method_wait_for_message=(method)
|
||||
@method_wait_for_message = method
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージ表示が終わるまでウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def self.wait_for_message
|
||||
@method_wait_for_message.call if @method_wait_for_message
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘開始
|
||||
#--------------------------------------------------------------------------
|
||||
def self.battle_start
|
||||
$game_system.battle_count += 1
|
||||
$game_party.on_battle_start
|
||||
$game_troop.on_battle_start
|
||||
$game_troop.enemy_names.each do |name|
|
||||
$game_message.add(sprintf(Vocab::Emerge, name))
|
||||
end
|
||||
if @preemptive
|
||||
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
|
||||
elsif @surprise
|
||||
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
|
||||
end
|
||||
wait_for_message
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘中断
|
||||
#--------------------------------------------------------------------------
|
||||
def self.abort
|
||||
@phase = :aborting
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 勝敗判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.judge_win_loss
|
||||
if @phase
|
||||
return process_abort if $game_party.members.empty?
|
||||
return process_defeat if $game_party.all_dead?
|
||||
return process_victory if $game_troop.all_dead?
|
||||
return process_abort if aborting?
|
||||
end
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 勝利の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def self.process_victory
|
||||
play_battle_end_me
|
||||
replay_bgm_and_bgs
|
||||
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
|
||||
display_exp
|
||||
gain_gold
|
||||
gain_drop_items
|
||||
gain_exp
|
||||
SceneManager.return
|
||||
battle_end(0)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 逃走の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def self.process_escape
|
||||
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
|
||||
success = @preemptive ? true : (rand < @escape_ratio)
|
||||
Sound.play_escape
|
||||
if success
|
||||
process_abort
|
||||
else
|
||||
@escape_ratio += 0.1
|
||||
$game_message.add('\.' + Vocab::EscapeFailure)
|
||||
$game_party.clear_actions
|
||||
end
|
||||
wait_for_message
|
||||
return success
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 中断の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def self.process_abort
|
||||
replay_bgm_and_bgs
|
||||
SceneManager.return
|
||||
battle_end(1)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敗北の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def self.process_defeat
|
||||
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
|
||||
wait_for_message
|
||||
if @can_lose
|
||||
revive_battle_members
|
||||
replay_bgm_and_bgs
|
||||
SceneManager.return
|
||||
else
|
||||
SceneManager.goto(Scene_Gameover)
|
||||
end
|
||||
battle_end(2)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘メンバーの復活(敗北時)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.revive_battle_members
|
||||
$game_party.battle_members.each do |actor|
|
||||
actor.hp = 1 if actor.dead?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了
|
||||
# result : 結果(0:勝利 1:逃走 2:敗北)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.battle_end(result)
|
||||
@phase = nil
|
||||
@event_proc.call(result) if @event_proc
|
||||
$game_party.on_battle_end
|
||||
$game_troop.on_battle_end
|
||||
SceneManager.exit if $BTEST
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド入力開始
|
||||
#--------------------------------------------------------------------------
|
||||
def self.input_start
|
||||
if @phase != :input
|
||||
@phase = :input
|
||||
$game_party.make_actions
|
||||
$game_troop.make_actions
|
||||
clear_actor
|
||||
end
|
||||
return !@surprise && $game_party.inputable?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン開始
|
||||
#--------------------------------------------------------------------------
|
||||
def self.turn_start
|
||||
@phase = :turn
|
||||
clear_actor
|
||||
$game_troop.increase_turn
|
||||
make_action_orders
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン終了
|
||||
#--------------------------------------------------------------------------
|
||||
def self.turn_end
|
||||
@phase = :turn_end
|
||||
@preemptive = false
|
||||
@surprise = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 獲得した経験値の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def self.display_exp
|
||||
if $game_troop.exp_total > 0
|
||||
text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
|
||||
$game_message.add('\.' + text)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● お金の獲得と表示
|
||||
#--------------------------------------------------------------------------
|
||||
def self.gain_gold
|
||||
if $game_troop.gold_total > 0
|
||||
text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
|
||||
$game_message.add('\.' + text)
|
||||
$game_party.gain_gold($game_troop.gold_total)
|
||||
end
|
||||
wait_for_message
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ドロップアイテムの獲得と表示
|
||||
#--------------------------------------------------------------------------
|
||||
def self.gain_drop_items
|
||||
$game_troop.make_drop_items.each do |item|
|
||||
$game_party.gain_item(item, 1)
|
||||
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
|
||||
end
|
||||
wait_for_message
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の獲得とレベルアップの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def self.gain_exp
|
||||
$game_party.all_members.each do |actor|
|
||||
actor.gain_exp($game_troop.exp_total)
|
||||
end
|
||||
wait_for_message
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動順序の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.make_action_orders
|
||||
@action_battlers = []
|
||||
@action_battlers += $game_party.members unless @surprise
|
||||
@action_battlers += $game_troop.members unless @preemptive
|
||||
@action_battlers.each {|battler| battler.make_speed }
|
||||
@action_battlers.sort! {|a,b| b.speed - a.speed }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の強制
|
||||
#--------------------------------------------------------------------------
|
||||
def self.force_action(battler)
|
||||
@action_forced = battler
|
||||
@action_battlers.delete(battler)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の強制状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.action_forced?
|
||||
@action_forced != nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動が強制されたバトラーを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.action_forced_battler
|
||||
@action_forced
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の強制をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def self.clear_action_force
|
||||
@action_forced = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次の行動主体の取得
|
||||
# 行動順序リストの先頭からバトラーを取得する。
|
||||
# 現在パーティにいないアクターを取得した場合(index が nil, バトルイベ
|
||||
# ントでの離脱直後などに発生)は、それをスキップする。
|
||||
#--------------------------------------------------------------------------
|
||||
def self.next_subject
|
||||
loop do
|
||||
battler = @action_battlers.shift
|
||||
return nil unless battler
|
||||
next unless battler.index && battler.alive?
|
||||
return battler
|
||||
end
|
||||
end
|
||||
end
|
||||
134
Scripts/Cache.rb
Normal file
134
Scripts/Cache.rb
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
#==============================================================================
|
||||
# ■ Cache
|
||||
#------------------------------------------------------------------------------
|
||||
# 各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
|
||||
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
|
||||
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
|
||||
# を返すようになっています。
|
||||
#==============================================================================
|
||||
|
||||
module Cache
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーション グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.animation(filename, hue)
|
||||
load_bitmap("Graphics/Animations/", filename, hue)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.battleback1(filename)
|
||||
load_bitmap("Graphics/Battlebacks1/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.battleback2(filename)
|
||||
load_bitmap("Graphics/Battlebacks2/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.battler(filename, hue)
|
||||
load_bitmap("Graphics/Battlers/", filename, hue)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩行グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.character(filename)
|
||||
load_bitmap("Graphics/Characters/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 顔グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.face(filename)
|
||||
load_bitmap("Graphics/Faces/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.parallax(filename)
|
||||
load_bitmap("Graphics/Parallaxes/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャ グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.picture(filename)
|
||||
load_bitmap("Graphics/Pictures/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● システム グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.system(filename)
|
||||
load_bitmap("Graphics/System/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルセット グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.tileset(filename)
|
||||
load_bitmap("Graphics/Tilesets/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル(背景)グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.title1(filename)
|
||||
load_bitmap("Graphics/Titles1/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル(枠)グラフィックの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.title2(filename)
|
||||
load_bitmap("Graphics/Titles2/", filename)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビットマップの読み込み
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_bitmap(folder_name, filename, hue = 0)
|
||||
@cache ||= {}
|
||||
if filename.empty?
|
||||
empty_bitmap
|
||||
elsif hue == 0
|
||||
normal_bitmap(folder_name + filename)
|
||||
else
|
||||
hue_changed_bitmap(folder_name + filename, hue)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 空のビットマップを作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.empty_bitmap
|
||||
Bitmap.new(32, 32)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常のビットマップを作成/取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.normal_bitmap(path)
|
||||
@cache[path] = Bitmap.new(path) unless include?(path)
|
||||
@cache[path]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色相変化済みビットマップを作成/取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.hue_changed_bitmap(path, hue)
|
||||
key = [path, hue]
|
||||
unless include?(key)
|
||||
@cache[key] = normal_bitmap(path).clone
|
||||
@cache[key].hue_change(hue)
|
||||
end
|
||||
@cache[key]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャッシュ存在チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def self.include?(key)
|
||||
@cache[key] && !@cache[key].disposed?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャッシュのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def self.clear
|
||||
@cache ||= {}
|
||||
@cache.clear
|
||||
GC.start
|
||||
end
|
||||
end
|
||||
267
Scripts/DataManager.rb
Normal file
267
Scripts/DataManager.rb
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
#==============================================================================
|
||||
# ■ DataManager
|
||||
#------------------------------------------------------------------------------
|
||||
# データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
|
||||
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
|
||||
#==============================================================================
|
||||
|
||||
module DataManager
|
||||
#--------------------------------------------------------------------------
|
||||
# ● モジュールのインスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
@last_savefile_index = 0 # 最後にアクセスしたファイル
|
||||
#--------------------------------------------------------------------------
|
||||
# ● モジュール初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def self.init
|
||||
@last_savefile_index = 0
|
||||
load_database
|
||||
create_game_objects
|
||||
setup_battle_test if $BTEST
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● データベースのロード
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_database
|
||||
if $BTEST
|
||||
load_battle_test_database
|
||||
else
|
||||
load_normal_database
|
||||
check_player_location
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常のデータベースをロード
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_normal_database
|
||||
$data_actors = load_data("Data/Actors.rvdata2")
|
||||
$data_classes = load_data("Data/Classes.rvdata2")
|
||||
$data_skills = load_data("Data/Skills.rvdata2")
|
||||
$data_items = load_data("Data/Items.rvdata2")
|
||||
$data_weapons = load_data("Data/Weapons.rvdata2")
|
||||
$data_armors = load_data("Data/Armors.rvdata2")
|
||||
$data_enemies = load_data("Data/Enemies.rvdata2")
|
||||
$data_troops = load_data("Data/Troops.rvdata2")
|
||||
$data_states = load_data("Data/States.rvdata2")
|
||||
$data_animations = load_data("Data/Animations.rvdata2")
|
||||
$data_tilesets = load_data("Data/Tilesets.rvdata2")
|
||||
$data_common_events = load_data("Data/CommonEvents.rvdata2")
|
||||
$data_system = load_data("Data/System.rvdata2")
|
||||
$data_mapinfos = load_data("Data/MapInfos.rvdata2")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘テスト用のデータベースをロード
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_battle_test_database
|
||||
$data_actors = load_data("Data/BT_Actors.rvdata2")
|
||||
$data_classes = load_data("Data/BT_Classes.rvdata2")
|
||||
$data_skills = load_data("Data/BT_Skills.rvdata2")
|
||||
$data_items = load_data("Data/BT_Items.rvdata2")
|
||||
$data_weapons = load_data("Data/BT_Weapons.rvdata2")
|
||||
$data_armors = load_data("Data/BT_Armors.rvdata2")
|
||||
$data_enemies = load_data("Data/BT_Enemies.rvdata2")
|
||||
$data_troops = load_data("Data/BT_Troops.rvdata2")
|
||||
$data_states = load_data("Data/BT_States.rvdata2")
|
||||
$data_animations = load_data("Data/BT_Animations.rvdata2")
|
||||
$data_tilesets = load_data("Data/BT_Tilesets.rvdata2")
|
||||
$data_common_events = load_data("Data/BT_CommonEvents.rvdata2")
|
||||
$data_system = load_data("Data/BT_System.rvdata2")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーの初期位置存在チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def self.check_player_location
|
||||
if $data_system.start_map_id == 0
|
||||
msgbox(Vocab::PlayerPosError)
|
||||
exit
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 各種ゲームオブジェクトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.create_game_objects
|
||||
$game_temp = Game_Temp.new
|
||||
$game_system = Game_System.new
|
||||
$game_timer = Game_Timer.new
|
||||
$game_message = Game_Message.new
|
||||
$game_switches = Game_Switches.new
|
||||
$game_variables = Game_Variables.new
|
||||
$game_self_switches = Game_SelfSwitches.new
|
||||
$game_actors = Game_Actors.new
|
||||
$game_party = Game_Party.new
|
||||
$game_troop = Game_Troop.new
|
||||
$game_map = Game_Map.new
|
||||
$game_player = Game_Player.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ニューゲームのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def self.setup_new_game
|
||||
create_game_objects
|
||||
$game_party.setup_starting_members
|
||||
$game_map.setup($data_system.start_map_id)
|
||||
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
||||
$game_player.refresh
|
||||
Graphics.frame_count = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘テストのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def self.setup_battle_test
|
||||
$game_party.setup_battle_test
|
||||
BattleManager.setup($data_system.test_troop_id)
|
||||
BattleManager.play_battle_bgm
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの存在判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.save_file_exists?
|
||||
!Dir.glob('Save*.rvdata2').empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの最大数
|
||||
#--------------------------------------------------------------------------
|
||||
def self.savefile_max
|
||||
return 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ファイル名の作成
|
||||
# index : ファイルインデックス
|
||||
#--------------------------------------------------------------------------
|
||||
def self.make_filename(index)
|
||||
sprintf("Save%02d.rvdata2", index + 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブの実行
|
||||
#--------------------------------------------------------------------------
|
||||
def self.save_game(index)
|
||||
begin
|
||||
save_game_without_rescue(index)
|
||||
rescue
|
||||
delete_save_file(index)
|
||||
false
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロードの実行
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_game(index)
|
||||
load_game_without_rescue(index) rescue false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブヘッダのロード
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_header(index)
|
||||
load_header_without_rescue(index) rescue nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブの実行(例外処理なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.save_game_without_rescue(index)
|
||||
File.open(make_filename(index), "wb") do |file|
|
||||
$game_system.on_before_save
|
||||
Marshal.dump(make_save_header, file)
|
||||
Marshal.dump(make_save_contents, file)
|
||||
@last_savefile_index = index
|
||||
end
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロードの実行(例外処理なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_game_without_rescue(index)
|
||||
File.open(make_filename(index), "rb") do |file|
|
||||
Marshal.load(file)
|
||||
extract_save_contents(Marshal.load(file))
|
||||
reload_map_if_updated
|
||||
@last_savefile_index = index
|
||||
end
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブヘッダのロード(例外処理なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.load_header_without_rescue(index)
|
||||
File.open(make_filename(index), "rb") do |file|
|
||||
return Marshal.load(file)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの削除
|
||||
#--------------------------------------------------------------------------
|
||||
def self.delete_save_file(index)
|
||||
File.delete(make_filename(index)) rescue nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブヘッダの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.make_save_header
|
||||
header = {}
|
||||
header[:characters] = $game_party.characters_for_savefile
|
||||
header[:playtime_s] = $game_system.playtime_s
|
||||
header
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブ内容の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.make_save_contents
|
||||
contents = {}
|
||||
contents[:system] = $game_system
|
||||
contents[:timer] = $game_timer
|
||||
contents[:message] = $game_message
|
||||
contents[:switches] = $game_switches
|
||||
contents[:variables] = $game_variables
|
||||
contents[:self_switches] = $game_self_switches
|
||||
contents[:actors] = $game_actors
|
||||
contents[:party] = $game_party
|
||||
contents[:troop] = $game_troop
|
||||
contents[:map] = $game_map
|
||||
contents[:player] = $game_player
|
||||
contents
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブ内容の展開
|
||||
#--------------------------------------------------------------------------
|
||||
def self.extract_save_contents(contents)
|
||||
$game_system = contents[:system]
|
||||
$game_timer = contents[:timer]
|
||||
$game_message = contents[:message]
|
||||
$game_switches = contents[:switches]
|
||||
$game_variables = contents[:variables]
|
||||
$game_self_switches = contents[:self_switches]
|
||||
$game_actors = contents[:actors]
|
||||
$game_party = contents[:party]
|
||||
$game_troop = contents[:troop]
|
||||
$game_map = contents[:map]
|
||||
$game_player = contents[:player]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● データが更新されている場合はマップを再読み込み
|
||||
#--------------------------------------------------------------------------
|
||||
def self.reload_map_if_updated
|
||||
if $game_system.version_id != $data_system.version_id
|
||||
$game_map.setup($game_map.map_id)
|
||||
$game_player.center($game_player.x, $game_player.y)
|
||||
$game_player.make_encounter_count
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの更新日時を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.savefile_time_stamp(index)
|
||||
File.mtime(make_filename(index)) rescue Time.at(0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 更新日時が最新のファイルインデックスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.latest_savefile_index
|
||||
savefile_max.times.max_by {|i| savefile_time_stamp(i) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最後にアクセスしたファイルのインデックスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.last_savefile_index
|
||||
@last_savefile_index
|
||||
end
|
||||
end
|
||||
74
Scripts/FMS_.rb
Normal file
74
Scripts/FMS_.rb
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
=begin =======================================================================
|
||||
☆ 命中率の仕様変更 by 白雪レイカ
|
||||
-------------------------------------------------------------------------------
|
||||
キャラクターの命中率の合計が100%以上であれば、余剰分で相手の
|
||||
回避率を減算することができるようにします。
|
||||
また、魔法命中率を定義することができるようになります。
|
||||
魔法は基本的に必中なので、命中率がプラスだと相手の回避率を減算、
|
||||
マイナスだと相手の回避率を加算という感じの処理になります。
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
◆使い方
|
||||
・魔法命中率の定義
|
||||
アクター/エネミー/ステート/装備/職業のメモ欄に
|
||||
|
||||
<魔法命中率(またはm_hit) (数値:%)>
|
||||
|
||||
と記述することで、
|
||||
そのアクターetcに魔法命中率が数値分だけ加算されます。
|
||||
数値にはマイナスの値を入れることもできます。
|
||||
その場合、魔法命中率が減算されることになります。
|
||||
|
||||
◆おことわり
|
||||
改造・再配布等自由です。
|
||||
再配布の際には作者の明示をお願いします。
|
||||
バグを発見したら速やかにご報告ください。
|
||||
|
||||
=end
|
||||
|
||||
class Game_Battler
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの回避率計算(再定義)
|
||||
#--------------------------------------------------------------------------
|
||||
def item_eva(user, item)
|
||||
if item.physical?
|
||||
return eva if user.hit <= 1
|
||||
return eva - (user.hit - 1)
|
||||
end
|
||||
return mev - user.magical_hit if item.magical?
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 魔法命中率を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def magical_hit
|
||||
hit = 0
|
||||
self.states.each do |state|
|
||||
hit += state.magical_hit
|
||||
end
|
||||
if self.actor?
|
||||
hit += actor.magical_hit
|
||||
hit += self.class.magical_hit
|
||||
self.equips.each do |equip|
|
||||
next unless equip
|
||||
hit += equip.magical_hit
|
||||
end
|
||||
else
|
||||
hit += enemy.magical_hit
|
||||
end
|
||||
return hit
|
||||
end
|
||||
end
|
||||
|
||||
class RPG::BaseItem
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 魔法命中率の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def magical_hit
|
||||
@note.each_line do |line|
|
||||
line.scan(/(?:m_hit|魔法命中率)\s*(\-*\d+)/)
|
||||
return $1.to_i * 0.01 if $1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
end
|
||||
261
Scripts/Game_Action.rb
Normal file
261
Scripts/Game_Action.rb
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Action
|
||||
#------------------------------------------------------------------------------
|
||||
# 戦闘行動を扱うクラスです。このクラスは Game_Battler クラスの内部で使用され
|
||||
# ます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Action
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :subject # 行動主体
|
||||
attr_reader :forcing # 戦闘行動の強制フラグ
|
||||
attr_reader :item # スキル / アイテム
|
||||
attr_accessor :target_index # 対象インデックス
|
||||
attr_reader :value # 自動戦闘用 評価値
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(subject, forcing = false)
|
||||
@subject = subject
|
||||
@forcing = forcing
|
||||
clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
@item = Game_BaseItem.new
|
||||
@target_index = -1
|
||||
@value = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 味方ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def friends_unit
|
||||
subject.friends_unit
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def opponents_unit
|
||||
subject.opponents_unit
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラの戦闘行動を設定
|
||||
# action : RPG::Enemy::Action
|
||||
#--------------------------------------------------------------------------
|
||||
def set_enemy_action(action)
|
||||
if action
|
||||
set_skill(action.skill_id)
|
||||
else
|
||||
clear
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃を設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_attack
|
||||
set_skill(subject.attack_skill_id)
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御を設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_guard
|
||||
set_skill(subject.guard_skill_id)
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_skill(skill_id)
|
||||
@item.object = $data_skills[skill_id]
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_item(item_id)
|
||||
@item.object = $data_items[item_id]
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムオブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item
|
||||
@item.object
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃判定
|
||||
#--------------------------------------------------------------------------
|
||||
def attack?
|
||||
item == $data_skills[subject.attack_skill_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ランダムターゲット
|
||||
#--------------------------------------------------------------------------
|
||||
def decide_random_target
|
||||
if item.for_dead_friend?
|
||||
target = friends_unit.random_dead_target
|
||||
elsif item.for_friend?
|
||||
target = friends_unit.random_target
|
||||
else
|
||||
target = opponents_unit.random_target
|
||||
end
|
||||
if target
|
||||
@target_index = target.index
|
||||
else
|
||||
clear
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 混乱行動を設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_confusion
|
||||
set_attack
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動準備
|
||||
#--------------------------------------------------------------------------
|
||||
def prepare
|
||||
set_confusion if subject.confusion? && !forcing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動が有効か否かの判定
|
||||
# イベントコマンドによる [戦闘行動の強制] ではないとき、ステートの制限
|
||||
# やアイテム切れなどで予定の行動ができなければ false を返す。
|
||||
#--------------------------------------------------------------------------
|
||||
def valid?
|
||||
(forcing && item) || subject.usable?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動速度の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def speed
|
||||
speed = subject.agi + rand(5 + subject.agi / 4)
|
||||
speed += item.speed if item
|
||||
speed += subject.atk_speed if attack?
|
||||
speed
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターゲットの配列作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_targets
|
||||
if !forcing && subject.confusion?
|
||||
[confusion_target]
|
||||
elsif item.for_opponent?
|
||||
targets_for_opponents
|
||||
elsif item.for_friend?
|
||||
targets_for_friends
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 混乱時のターゲット
|
||||
#--------------------------------------------------------------------------
|
||||
def confusion_target
|
||||
case subject.confusion_level
|
||||
when 1
|
||||
opponents_unit.random_target
|
||||
when 2
|
||||
if rand(2) == 0
|
||||
opponents_unit.random_target
|
||||
else
|
||||
friends_unit.random_target
|
||||
end
|
||||
else
|
||||
friends_unit.random_target
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵に対するターゲット
|
||||
#--------------------------------------------------------------------------
|
||||
def targets_for_opponents
|
||||
if item.for_random?
|
||||
Array.new(item.number_of_targets) { opponents_unit.random_target }
|
||||
elsif item.for_one?
|
||||
num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
|
||||
if @target_index < 0
|
||||
[opponents_unit.random_target] * num
|
||||
else
|
||||
[opponents_unit.smooth_target(@target_index)] * num
|
||||
end
|
||||
else
|
||||
opponents_unit.alive_members
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 味方に対するターゲット
|
||||
#--------------------------------------------------------------------------
|
||||
def targets_for_friends
|
||||
if item.for_user?
|
||||
[subject]
|
||||
elsif item.for_dead_friend?
|
||||
if item.for_one?
|
||||
[friends_unit.smooth_dead_target(@target_index)]
|
||||
else
|
||||
friends_unit.dead_members
|
||||
end
|
||||
elsif item.for_friend?
|
||||
if item.for_one?
|
||||
[friends_unit.smooth_target(@target_index)]
|
||||
else
|
||||
friends_unit.alive_members
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動の価値評価(自動戦闘用)
|
||||
# @value および @target_index を自動的に設定する。
|
||||
#--------------------------------------------------------------------------
|
||||
def evaluate
|
||||
@value = 0
|
||||
evaluate_item if valid?
|
||||
@value += rand if @value > 0
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの評価
|
||||
#--------------------------------------------------------------------------
|
||||
def evaluate_item
|
||||
item_target_candidates.each do |target|
|
||||
value = evaluate_item_with_target(target)
|
||||
if item.for_all?
|
||||
@value += value
|
||||
elsif value > @value
|
||||
@value = value
|
||||
@target_index = target.index
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用対象候補を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_target_candidates
|
||||
if item.for_opponent?
|
||||
opponents_unit.alive_members
|
||||
elsif item.for_user?
|
||||
[subject]
|
||||
elsif item.for_dead_friend?
|
||||
friends_unit.dead_members
|
||||
else
|
||||
friends_unit.alive_members
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの評価(ターゲット指定)
|
||||
#--------------------------------------------------------------------------
|
||||
def evaluate_item_with_target(target)
|
||||
target.result.clear
|
||||
target.make_damage_value(subject, item)
|
||||
if item.for_opponent?
|
||||
return target.result.hp_damage.to_f / [target.hp, 1].max
|
||||
else
|
||||
recovery = [-target.result.hp_damage, target.mhp - target.hp].min
|
||||
return recovery.to_f / target.mhp
|
||||
end
|
||||
end
|
||||
end
|
||||
159
Scripts/Game_ActionResult.rb
Normal file
159
Scripts/Game_ActionResult.rb
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
#==============================================================================
|
||||
# ■ Game_ActionResult
|
||||
#------------------------------------------------------------------------------
|
||||
# 戦闘行動の結果を扱うクラスです。このクラスは Game_Battler クラスの内部で
|
||||
# 使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_ActionResult
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :used # 使用フラグ
|
||||
attr_accessor :missed # 命中失敗フラグ
|
||||
attr_accessor :evaded # 回避成功フラグ
|
||||
attr_accessor :critical # クリティカルフラグ
|
||||
attr_accessor :success # 成功フラグ
|
||||
attr_accessor :hp_damage # HP ダメージ
|
||||
attr_accessor :mp_damage # MP ダメージ
|
||||
attr_accessor :tp_damage # TP ダメージ
|
||||
attr_accessor :hp_drain # HP 吸収
|
||||
attr_accessor :mp_drain # MP 吸収
|
||||
attr_accessor :added_states # 付加されたステート
|
||||
attr_accessor :removed_states # 解除されたステート
|
||||
attr_accessor :added_buffs # 付加された能力強化
|
||||
attr_accessor :added_debuffs # 付加された能力弱体
|
||||
attr_accessor :removed_buffs # 解除された強化/弱体
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(battler)
|
||||
@battler = battler
|
||||
clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
clear_hit_flags
|
||||
clear_damage_values
|
||||
clear_status_effects
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 命中系フラグのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_hit_flags
|
||||
@used = false
|
||||
@missed = false
|
||||
@evaded = false
|
||||
@critical = false
|
||||
@success = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ値のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_damage_values
|
||||
@hp_damage = 0
|
||||
@mp_damage = 0
|
||||
@tp_damage = 0
|
||||
@hp_drain = 0
|
||||
@mp_drain = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_damage(value, item)
|
||||
@critical = false if value == 0
|
||||
@hp_damage = value if item.damage.to_hp?
|
||||
@mp_damage = value if item.damage.to_mp?
|
||||
@mp_damage = [@battler.mp, @mp_damage].min
|
||||
@hp_drain = @hp_damage if item.damage.drain?
|
||||
@mp_drain = @mp_damage if item.damage.drain?
|
||||
@hp_drain = [@battler.hp, @hp_drain].min
|
||||
@success = true if item.damage.to_hp? || @mp_damage != 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータス効果のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_status_effects
|
||||
@added_states = []
|
||||
@removed_states = []
|
||||
@added_buffs = []
|
||||
@added_debuffs = []
|
||||
@removed_buffs = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 付加されたステートをオブジェクトの配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def added_state_objects
|
||||
@added_states.collect {|id| $data_states[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解除されたステートをオブジェクトの配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def removed_state_objects
|
||||
@removed_states.collect {|id| $data_states[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 何らかのステータス(能力値かステート)が影響を受けたかの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def status_affected?
|
||||
!(@added_states.empty? && @removed_states.empty? &&
|
||||
@added_buffs.empty? && @added_debuffs.empty? && @removed_buffs.empty?)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最終的に命中したか否かを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def hit?
|
||||
@used && !@missed && !@evaded
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP ダメージの文章を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def hp_damage_text
|
||||
if @hp_drain > 0
|
||||
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
|
||||
sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
|
||||
elsif @hp_damage > 0
|
||||
fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
|
||||
sprintf(fmt, @battler.name, @hp_damage)
|
||||
elsif @hp_damage < 0
|
||||
fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
|
||||
sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
|
||||
else
|
||||
fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
|
||||
sprintf(fmt, @battler.name)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP ダメージの文章を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def mp_damage_text
|
||||
if @mp_drain > 0
|
||||
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
|
||||
sprintf(fmt, @battler.name, Vocab::mp, @mp_drain)
|
||||
elsif @mp_damage > 0
|
||||
fmt = @battler.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
|
||||
sprintf(fmt, @battler.name, Vocab::mp, @mp_damage)
|
||||
elsif @mp_damage < 0
|
||||
fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
|
||||
sprintf(fmt, @battler.name, Vocab::mp, -@mp_damage)
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP ダメージの文章を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tp_damage_text
|
||||
if @tp_damage > 0
|
||||
fmt = @battler.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
|
||||
sprintf(fmt, @battler.name, Vocab::tp, @tp_damage)
|
||||
elsif @tp_damage < 0
|
||||
fmt = @battler.actor? ? Vocab::ActorGain : Vocab::EnemyGain
|
||||
sprintf(fmt, @battler.name, Vocab::tp, -@tp_damage)
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
end
|
||||
692
Scripts/Game_Actor.rb
Normal file
692
Scripts/Game_Actor.rb
Normal file
|
|
@ -0,0 +1,692 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Actor
|
||||
#------------------------------------------------------------------------------
|
||||
# アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
|
||||
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Actor < Game_Battler
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :name # 名前
|
||||
attr_accessor :nickname # 二つ名
|
||||
attr_reader :character_name # 歩行グラフィック ファイル名
|
||||
attr_reader :character_index # 歩行グラフィック インデックス
|
||||
attr_reader :face_name # 顔グラフィック ファイル名
|
||||
attr_reader :face_index # 顔グラフィック インデックス
|
||||
attr_reader :class_id # 職業 ID
|
||||
attr_reader :level # レベル
|
||||
attr_reader :action_input_index # 入力中の戦闘行動番号
|
||||
attr_reader :last_skill # カーソル記憶用 : スキル
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(actor_id)
|
||||
super()
|
||||
setup(actor_id)
|
||||
@last_skill = Game_BaseItem.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup(actor_id)
|
||||
@actor_id = actor_id
|
||||
@name = actor.name
|
||||
@nickname = actor.nickname
|
||||
init_graphics
|
||||
@class_id = actor.class_id
|
||||
@level = actor.initial_level
|
||||
@exp = {}
|
||||
@equips = []
|
||||
init_exp
|
||||
init_skills
|
||||
init_equips(actor.equips)
|
||||
clear_param_plus
|
||||
recover_all
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターオブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def actor
|
||||
$data_actors[@actor_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● グラフィックの初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_graphics
|
||||
@character_name = actor.character_name
|
||||
@character_index = actor.character_index
|
||||
@face_name = actor.face_name
|
||||
@face_index = actor.face_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定レベルに上がるのに必要な累計経験値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def exp_for_level(level)
|
||||
self.class.exp_for_level(level)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_exp
|
||||
@exp[@class_id] = current_level_exp
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def exp
|
||||
@exp[@class_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のレベルの最低経験値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_level_exp
|
||||
exp_for_level(@level)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次のレベルの経験値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def next_level_exp
|
||||
exp_for_level(@level + 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最大レベル
|
||||
#--------------------------------------------------------------------------
|
||||
def max_level
|
||||
actor.max_level
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最大レベル判定
|
||||
#--------------------------------------------------------------------------
|
||||
def max_level?
|
||||
@level >= max_level
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_skills
|
||||
@skills = []
|
||||
self.class.learnings.each do |learning|
|
||||
learn_skill(learning.skill_id) if learning.level <= @level
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備品の初期化
|
||||
# equips : 初期装備の配列
|
||||
#--------------------------------------------------------------------------
|
||||
def init_equips(equips)
|
||||
@equips = Array.new(equip_slots.size) { Game_BaseItem.new }
|
||||
equips.each_with_index do |item_id, i|
|
||||
etype_id = index_to_etype_id(i)
|
||||
slot_id = empty_slot(etype_id)
|
||||
@equips[slot_id].set_equip(etype_id == 0, item_id) if slot_id
|
||||
end
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エディタで設定されたインデックスを装備タイプ ID に変換
|
||||
#--------------------------------------------------------------------------
|
||||
def index_to_etype_id(index)
|
||||
index == 1 && dual_wield? ? 0 : index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備タイプからスロット ID のリストに変換
|
||||
#--------------------------------------------------------------------------
|
||||
def slot_list(etype_id)
|
||||
result = []
|
||||
equip_slots.each_with_index {|e, i| result.push(i) if e == etype_id }
|
||||
result
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備タイプからスロット ID に変換(空きを優先)
|
||||
#--------------------------------------------------------------------------
|
||||
def empty_slot(etype_id)
|
||||
list = slot_list(etype_id)
|
||||
list.find {|i| @equips[i].is_nil? } || list[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備スロットの配列を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_slots
|
||||
return [0,0,2,3,4] if dual_wield? # 二刀流
|
||||
return [0,1,2,3,4] # 通常
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 武器オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def weapons
|
||||
@equips.select {|item| item.is_weapon? }.collect {|item| item.object }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防具オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def armors
|
||||
@equips.select {|item| item.is_armor? }.collect {|item| item.object }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備品オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def equips
|
||||
@equips.collect {|item| item.object }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備変更の可能判定
|
||||
# slot_id : 装備スロット ID
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_change_ok?(slot_id)
|
||||
return false if equip_type_fixed?(equip_slots[slot_id])
|
||||
return false if equip_type_sealed?(equip_slots[slot_id])
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備の変更
|
||||
# slot_id : 装備スロット ID
|
||||
# item : 武器/防具(nil なら装備解除)
|
||||
#--------------------------------------------------------------------------
|
||||
def change_equip(slot_id, item)
|
||||
return unless trade_item_with_party(item, equips[slot_id])
|
||||
return if item && equip_slots[slot_id] != item.etype_id
|
||||
@equips[slot_id].object = item
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備の強制変更
|
||||
# slot_id : 装備スロット ID
|
||||
# item : 武器/防具(nil なら装備解除)
|
||||
#--------------------------------------------------------------------------
|
||||
def force_change_equip(slot_id, item)
|
||||
@equips[slot_id].object = item
|
||||
release_unequippable_items(false)
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティとアイテムを交換する
|
||||
# new_item : パーティから取り出すアイテム
|
||||
# old_item : パーティに返すアイテム
|
||||
#--------------------------------------------------------------------------
|
||||
def trade_item_with_party(new_item, old_item)
|
||||
return false if new_item && !$game_party.has_item?(new_item)
|
||||
$game_party.gain_item(old_item, 1)
|
||||
$game_party.lose_item(new_item, 1)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備の変更(ID で指定)
|
||||
# slot_id : 装備スロット ID
|
||||
# item_id : 武器/防具 ID
|
||||
#--------------------------------------------------------------------------
|
||||
def change_equip_by_id(slot_id, item_id)
|
||||
if equip_slots[slot_id] == 0
|
||||
change_equip(slot_id, $data_weapons[item_id])
|
||||
else
|
||||
change_equip(slot_id, $data_armors[item_id])
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備の破棄
|
||||
# item : 破棄する武器/防具
|
||||
#--------------------------------------------------------------------------
|
||||
def discard_equip(item)
|
||||
slot_id = equips.index(item)
|
||||
@equips[slot_id].object = nil if slot_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備できない装備品を外す
|
||||
# item_gain : 外した装備品をパーティに戻す
|
||||
#--------------------------------------------------------------------------
|
||||
def release_unequippable_items(item_gain = true)
|
||||
@equips.each_with_index do |item, i|
|
||||
if !equippable?(item.object) || item.object.etype_id != equip_slots[i]
|
||||
trade_item_with_party(nil, item.object) if item_gain
|
||||
item.object = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備を全て外す
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_equipments
|
||||
equip_slots.size.times do |i|
|
||||
change_equip(i, nil) if equip_change_ok?(i)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最強装備
|
||||
#--------------------------------------------------------------------------
|
||||
def optimize_equipments
|
||||
clear_equipments
|
||||
equip_slots.size.times do |i|
|
||||
next if !equip_change_ok?(i)
|
||||
items = $game_party.equip_items.select do |item|
|
||||
item.etype_id == equip_slots[i] &&
|
||||
equippable?(item) && item.performance >= 0
|
||||
end
|
||||
change_equip(i, items.max_by {|item| item.performance })
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの必要武器を装備しているか
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_wtype_ok?(skill)
|
||||
wtype_id1 = skill.required_wtype_id1
|
||||
wtype_id2 = skill.required_wtype_id2
|
||||
return true if wtype_id1 == 0 && wtype_id2 == 0
|
||||
return true if wtype_id1 > 0 && wtype_equipped?(wtype_id1)
|
||||
return true if wtype_id2 > 0 && wtype_equipped?(wtype_id2)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特定のタイプの武器を装備しているか
|
||||
#--------------------------------------------------------------------------
|
||||
def wtype_equipped?(wtype_id)
|
||||
weapons.any? {|weapon| weapon.wtype_id == wtype_id }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
release_unequippable_items
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターか否かの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def actor?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 味方ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def friends_unit
|
||||
$game_party
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def opponents_unit
|
||||
$game_troop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター ID 取得
|
||||
#--------------------------------------------------------------------------
|
||||
def id
|
||||
@actor_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● インデックス取得
|
||||
#--------------------------------------------------------------------------
|
||||
def index
|
||||
$game_party.members.index(self)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトルメンバー判定
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_member?
|
||||
$game_party.battle_members.include?(self)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 職業オブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def class
|
||||
$data_classes[@class_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルオブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def skills
|
||||
(@skills | added_skills).sort.collect {|id| $data_skills[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在使用できるスキルの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def usable_skills
|
||||
skills.select {|skill| usable?(skill) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴を保持する全オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def feature_objects
|
||||
super + [actor] + [self.class] + equips.compact
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃時属性の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_elements
|
||||
set = super
|
||||
set |= [1] if weapons.compact.empty? # 素手:物理属性
|
||||
return set
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の最大値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_max(param_id)
|
||||
return 9999 if param_id == 0 # MHP
|
||||
return super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の基本値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_base(param_id)
|
||||
self.class.params[param_id, @level]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の加算値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_plus(param_id)
|
||||
equips.compact.inject(super) {|r, item| r += item.params[param_id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃 アニメーション ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_animation_id1
|
||||
if dual_wield?
|
||||
return weapons[0].animation_id if weapons[0]
|
||||
return weapons[1] ? 0 : 1
|
||||
else
|
||||
return weapons[0] ? weapons[0].animation_id : 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃 アニメーション ID の取得(二刀流:武器2)
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_animation_id2
|
||||
if dual_wield?
|
||||
return weapons[1] ? weapons[1].animation_id : 0
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の変更
|
||||
# show : レベルアップ表示フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
def change_exp(exp, show)
|
||||
@exp[@class_id] = [exp, 0].max
|
||||
last_level = @level
|
||||
last_skills = skills
|
||||
level_up while !max_level? && self.exp >= next_level_exp
|
||||
level_down while self.exp < current_level_exp
|
||||
display_level_up(skills - last_skills) if show && @level > last_level
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def exp
|
||||
@exp[@class_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● レベルアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def level_up
|
||||
@level += 1
|
||||
self.class.learnings.each do |learning|
|
||||
learn_skill(learning.skill_id) if learning.level == @level
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● レベルダウン
|
||||
#--------------------------------------------------------------------------
|
||||
def level_down
|
||||
@level -= 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● レベルアップメッセージの表示
|
||||
# new_skills : 新しく習得したスキルの配列
|
||||
#--------------------------------------------------------------------------
|
||||
def display_level_up(new_skills)
|
||||
$game_message.new_page
|
||||
$game_message.add(sprintf(Vocab::LevelUp, @name, Vocab::level, @level))
|
||||
new_skills.each do |skill|
|
||||
$game_message.add(sprintf(Vocab::ObtainSkill, skill.name))
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の獲得(経験獲得率を考慮)
|
||||
#--------------------------------------------------------------------------
|
||||
def gain_exp(exp)
|
||||
change_exp(self.exp + (exp * final_exp_rate).to_i, true)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最終的な経験獲得率の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def final_exp_rate
|
||||
exr * (battle_member? ? 1 : reserve_members_exp_rate)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 控えメンバーの経験獲得率を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def reserve_members_exp_rate
|
||||
$data_system.opt_extra_exp ? 1 : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● レベルの変更
|
||||
# show : レベルアップ表示フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
def change_level(level, show)
|
||||
level = [[level, max_level].min, 1].max
|
||||
change_exp(exp_for_level(level), show)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルを覚える
|
||||
#--------------------------------------------------------------------------
|
||||
def learn_skill(skill_id)
|
||||
unless skill_learn?($data_skills[skill_id])
|
||||
@skills.push(skill_id)
|
||||
@skills.sort!
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルを忘れる
|
||||
#--------------------------------------------------------------------------
|
||||
def forget_skill(skill_id)
|
||||
@skills.delete(skill_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの習得済み判定
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_learn?(skill)
|
||||
skill.is_a?(RPG::Skill) && @skills.include?(skill.id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 説明の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def description
|
||||
actor.description
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 職業の変更
|
||||
# keep_exp : 経験値を引き継ぐ
|
||||
#--------------------------------------------------------------------------
|
||||
def change_class(class_id, keep_exp = false)
|
||||
@exp[class_id] = exp if keep_exp
|
||||
@class_id = class_id
|
||||
change_exp(@exp[@class_id] || 0, false)
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● グラフィックの変更
|
||||
#--------------------------------------------------------------------------
|
||||
def set_graphic(character_name, character_index, face_name, face_index)
|
||||
@character_name = character_name
|
||||
@character_index = character_index
|
||||
@face_name = face_name
|
||||
@face_index = face_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトを使うか?
|
||||
#--------------------------------------------------------------------------
|
||||
def use_sprite?
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ効果の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_damage_effect
|
||||
$game_troop.screen.start_shake(5, 5, 10)
|
||||
@sprite_effect_type = :blink
|
||||
Sound.play_actor_damage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コラプス効果の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_collapse_effect
|
||||
if $game_party.in_battle
|
||||
@sprite_effect_type = :collapse
|
||||
Sound.play_actor_collapse
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動戦闘用の行動候補リストを作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_action_list
|
||||
list = []
|
||||
list.push(Game_Action.new(self).set_attack.evaluate)
|
||||
usable_skills.each do |skill|
|
||||
list.push(Game_Action.new(self).set_skill(skill.id).evaluate)
|
||||
end
|
||||
list
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動戦闘時の戦闘行動を作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_auto_battle_actions
|
||||
@actions.size.times do |i|
|
||||
@actions[i] = make_action_list.max {|action| action.value }
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 混乱時の戦闘行動を作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_confusion_actions
|
||||
@actions.size.times do |i|
|
||||
@actions[i].set_confusion
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_actions
|
||||
super
|
||||
if auto_battle?
|
||||
make_auto_battle_actions
|
||||
elsif confusion?
|
||||
make_confusion_actions
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーが 1 歩動いたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_player_walk
|
||||
@result.clear
|
||||
check_floor_effect
|
||||
if $game_player.normal_walk?
|
||||
turn_end_on_map
|
||||
states.each {|state| update_state_steps(state) }
|
||||
show_added_states
|
||||
show_removed_states
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの歩数カウントを更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_state_steps(state)
|
||||
if state.remove_by_walking
|
||||
@state_steps[state.id] -= 1 if @state_steps[state.id] > 0
|
||||
remove_state(state.id) if @state_steps[state.id] == 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 付加されたステートの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show_added_states
|
||||
@result.added_state_objects.each do |state|
|
||||
$game_message.add(name + state.message1) unless state.message1.empty?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解除されたステートの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show_removed_states
|
||||
@result.removed_state_objects.each do |state|
|
||||
$game_message.add(name + state.message4) unless state.message4.empty?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 何歩歩いたときに戦闘中の 1 ターン相当とみなすか
|
||||
#--------------------------------------------------------------------------
|
||||
def steps_for_turn
|
||||
return 20
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ画面上でのターン終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_end_on_map
|
||||
if $game_party.steps % steps_for_turn == 0
|
||||
on_turn_end
|
||||
perform_map_damage_effect if @result.hp_damage > 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 床効果判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_floor_effect
|
||||
execute_floor_damage if $game_player.on_damage_floor?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 床ダメージの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def execute_floor_damage
|
||||
damage = (basic_floor_damage * fdr).to_i
|
||||
self.hp -= [damage, max_floor_damage].min
|
||||
perform_map_damage_effect if damage > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 床ダメージの基本値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def basic_floor_damage
|
||||
return 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 床ダメージの最大値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_floor_damage
|
||||
$data_system.opt_floor_death ? hp : [hp - 1, 0].max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ上でのダメージ効果の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_map_damage_effect
|
||||
$game_map.screen.start_flash_for_damage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_actions
|
||||
super
|
||||
@action_input_index = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力中の戦闘行動を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def input
|
||||
@actions[@action_input_index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def next_command
|
||||
return false if @action_input_index >= @actions.size - 1
|
||||
@action_input_index += 1
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def prior_command
|
||||
return false if @action_input_index <= 0
|
||||
@action_input_index -= 1
|
||||
return true
|
||||
end
|
||||
end
|
||||
22
Scripts/Game_Actors.rb
Normal file
22
Scripts/Game_Actors.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Actors
|
||||
#------------------------------------------------------------------------------
|
||||
# アクターの配列のラッパーです。このクラスのインスタンスは $game_actors で参
|
||||
# 照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Actors
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@data = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](actor_id)
|
||||
return nil unless $data_actors[actor_id]
|
||||
@data[actor_id] ||= Game_Actor.new(actor_id)
|
||||
end
|
||||
end
|
||||
50
Scripts/Game_BaseItem.rb
Normal file
50
Scripts/Game_BaseItem.rb
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#==============================================================================
|
||||
# ■ Game_BaseItem
|
||||
#------------------------------------------------------------------------------
|
||||
# スキル、アイテム、武器、防具を統一的に扱うクラスです。セーブデータに含める
|
||||
# ことができるように、データベースオブジェクト自体への参照は保持しません。
|
||||
#==============================================================================
|
||||
|
||||
class Game_BaseItem
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@class = nil
|
||||
@item_id = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クラス判定
|
||||
#--------------------------------------------------------------------------
|
||||
def is_skill?; @class == RPG::Skill; end
|
||||
def is_item?; @class == RPG::Item; end
|
||||
def is_weapon?; @class == RPG::Weapon; end
|
||||
def is_armor?; @class == RPG::Armor; end
|
||||
def is_nil?; @class == nil; end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムオブジェクトの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def object
|
||||
return $data_skills[@item_id] if is_skill?
|
||||
return $data_items[@item_id] if is_item?
|
||||
return $data_weapons[@item_id] if is_weapon?
|
||||
return $data_armors[@item_id] if is_armor?
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムオブジェクトの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def object=(item)
|
||||
@class = item ? item.class : nil
|
||||
@item_id = item ? item.id : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備品を ID で設定
|
||||
# is_weapon : 武器かどうか
|
||||
# item_id : 武器/防具 ID
|
||||
#--------------------------------------------------------------------------
|
||||
def set_equip(is_weapon, item_id)
|
||||
@class = is_weapon ? RPG::Weapon : RPG::Armor
|
||||
@item_id = item_id
|
||||
end
|
||||
end
|
||||
822
Scripts/Game_Battler.rb
Normal file
822
Scripts/Game_Battler.rb
Normal file
|
|
@ -0,0 +1,822 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Battler
|
||||
#------------------------------------------------------------------------------
|
||||
# スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
|
||||
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Battler < Game_BattlerBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数(使用効果)
|
||||
#--------------------------------------------------------------------------
|
||||
EFFECT_RECOVER_HP = 11 # HP 回復
|
||||
EFFECT_RECOVER_MP = 12 # MP 回復
|
||||
EFFECT_GAIN_TP = 13 # TP 増加
|
||||
EFFECT_ADD_STATE = 21 # ステート付加
|
||||
EFFECT_REMOVE_STATE = 22 # ステート解除
|
||||
EFFECT_ADD_BUFF = 31 # 能力強化
|
||||
EFFECT_ADD_DEBUFF = 32 # 能力弱体
|
||||
EFFECT_REMOVE_BUFF = 33 # 能力強化の解除
|
||||
EFFECT_REMOVE_DEBUFF = 34 # 能力弱体の解除
|
||||
EFFECT_SPECIAL = 41 # 特殊効果
|
||||
EFFECT_GROW = 42 # 成長
|
||||
EFFECT_LEARN_SKILL = 43 # スキル習得
|
||||
EFFECT_COMMON_EVENT = 44 # コモンイベント
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数(特殊効果)
|
||||
#--------------------------------------------------------------------------
|
||||
SPECIAL_EFFECT_ESCAPE = 0 # 逃げる
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :battler_name # 戦闘グラフィック ファイル名
|
||||
attr_reader :battler_hue # 戦闘グラフィック 色相
|
||||
attr_reader :action_times # 行動回数
|
||||
attr_reader :actions # 戦闘行動(行動側)
|
||||
attr_reader :speed # 行動速度
|
||||
attr_reader :result # 行動結果(対象側)
|
||||
attr_accessor :last_target_index # ラストターゲット
|
||||
attr_accessor :animation_id # アニメーション ID
|
||||
attr_accessor :animation_mirror # アニメーション 左右反転フラグ
|
||||
attr_accessor :sprite_effect_type # スプライトのエフェクト
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@battler_name = ""
|
||||
@battler_hue = 0
|
||||
@actions = []
|
||||
@speed = 0
|
||||
@result = Game_ActionResult.new(self)
|
||||
@last_target_index = 0
|
||||
@guarding = false
|
||||
clear_sprite_effects
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトのエフェクトをクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_sprite_effects
|
||||
@animation_id = 0
|
||||
@animation_mirror = false
|
||||
@sprite_effect_type = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_actions
|
||||
@actions.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート情報をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_states
|
||||
super
|
||||
@result.clear_status_effects
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの付加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_state(state_id)
|
||||
if state_addable?(state_id)
|
||||
add_new_state(state_id) unless state?(state_id)
|
||||
reset_state_counts(state_id)
|
||||
@result.added_states.push(state_id).uniq!
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの付加可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def state_addable?(state_id)
|
||||
alive? && $data_states[state_id] && !state_resist?(state_id) &&
|
||||
!state_removed?(state_id) && !state_restrict?(state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 同一行動内で解除済みのステートを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def state_removed?(state_id)
|
||||
@result.removed_states.include?(state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動制約によって無効化されるステートを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def state_restrict?(state_id)
|
||||
$data_states[state_id].remove_by_restriction && restriction > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 新しいステートの付加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_new_state(state_id)
|
||||
die if state_id == death_state_id
|
||||
@states.push(state_id)
|
||||
on_restrict if restriction > 0
|
||||
sort_states
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動制約が生じたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_restrict
|
||||
clear_actions
|
||||
states.each do |state|
|
||||
remove_state(state.id) if state.remove_by_restriction
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートのカウント(ターン数および歩数)をリセット
|
||||
#--------------------------------------------------------------------------
|
||||
def reset_state_counts(state_id)
|
||||
state = $data_states[state_id]
|
||||
variance = 1 + [state.max_turns - state.min_turns, 0].max
|
||||
@state_turns[state_id] = state.min_turns + rand(variance)
|
||||
@state_steps[state_id] = state.steps_to_remove
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_state(state_id)
|
||||
if state?(state_id)
|
||||
revive if state_id == death_state_id
|
||||
erase_state(state_id)
|
||||
refresh
|
||||
@result.removed_states.push(state_id).uniq!
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能になる
|
||||
#--------------------------------------------------------------------------
|
||||
def die
|
||||
@hp = 0
|
||||
clear_states
|
||||
clear_buffs
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能から復活
|
||||
#--------------------------------------------------------------------------
|
||||
def revive
|
||||
@hp = 1 if @hp == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 逃げる
|
||||
#--------------------------------------------------------------------------
|
||||
def escape
|
||||
hide if $game_party.in_battle
|
||||
clear_actions
|
||||
clear_states
|
||||
Sound.play_escape
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化
|
||||
#--------------------------------------------------------------------------
|
||||
def add_buff(param_id, turns)
|
||||
return unless alive?
|
||||
@buffs[param_id] += 1 unless buff_max?(param_id)
|
||||
erase_buff(param_id) if debuff?(param_id)
|
||||
overwrite_buff_turns(param_id, turns)
|
||||
@result.added_buffs.push(param_id).uniq!
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力弱体
|
||||
#--------------------------------------------------------------------------
|
||||
def add_debuff(param_id, turns)
|
||||
return unless alive?
|
||||
@buffs[param_id] -= 1 unless debuff_max?(param_id)
|
||||
erase_buff(param_id) if buff?(param_id)
|
||||
overwrite_buff_turns(param_id, turns)
|
||||
@result.added_debuffs.push(param_id).uniq!
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化/弱体の解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_buff(param_id)
|
||||
return unless alive?
|
||||
return if @buffs[param_id] == 0
|
||||
erase_buff(param_id)
|
||||
@buff_turns.delete(param_id)
|
||||
@result.removed_buffs.push(param_id).uniq!
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化/弱体の消去
|
||||
#--------------------------------------------------------------------------
|
||||
def erase_buff(param_id)
|
||||
@buffs[param_id] = 0
|
||||
@buff_turns[param_id] = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化状態の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def buff?(param_id)
|
||||
@buffs[param_id] > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力弱体状態の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def debuff?(param_id)
|
||||
@buffs[param_id] < 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化が最大の段階か否かを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def buff_max?(param_id)
|
||||
@buffs[param_id] == 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力弱体が最大の段階か否かを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def debuff_max?(param_id)
|
||||
@buffs[param_id] == -2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化/弱体のターン数上書き
|
||||
# ターン数が短くなる場合は上書きしない。
|
||||
#--------------------------------------------------------------------------
|
||||
def overwrite_buff_turns(param_id, turns)
|
||||
@buff_turns[param_id] = turns if @buff_turns[param_id].to_i < turns
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートのターンカウント更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_state_turns
|
||||
states.each do |state|
|
||||
@state_turns[state.id] -= 1 if @state_turns[state.id] > 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強化/弱体のターンカウント更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_buff_turns
|
||||
@buff_turns.keys.each do |param_id|
|
||||
@buff_turns[param_id] -= 1 if @buff_turns[param_id] > 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘用ステートの解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_battle_states
|
||||
states.each do |state|
|
||||
remove_state(state.id) if state.remove_at_battle_end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強化/弱体の全解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_all_buffs
|
||||
@buffs.size.times {|param_id| remove_buff(param_id) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート自動解除
|
||||
# timing : タイミング(1:行動終了 2:ターン終了)
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_states_auto(timing)
|
||||
states.each do |state|
|
||||
if @state_turns[state.id] == 0 && state.auto_removal_timing == timing
|
||||
remove_state(state.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強化/弱体の自動解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_buffs_auto
|
||||
@buffs.size.times do |param_id|
|
||||
next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0
|
||||
remove_buff(param_id)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージによるステート解除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_states_by_damage
|
||||
states.each do |state|
|
||||
if state.remove_by_damage && rand(100) < state.chance_by_damage
|
||||
remove_state(state.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動回数の決定
|
||||
#--------------------------------------------------------------------------
|
||||
def make_action_times
|
||||
action_plus_set.inject(1) {|r, p| rand < p ? r + 1 : r }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_actions
|
||||
clear_actions
|
||||
return unless movable?
|
||||
@actions = Array.new(make_action_times) { Game_Action.new(self) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動速度の決定
|
||||
#--------------------------------------------------------------------------
|
||||
def make_speed
|
||||
@speed = @actions.collect {|action| action.speed }.min || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在の戦闘行動を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_action
|
||||
@actions[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在の戦闘行動を除去
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_current_action
|
||||
@actions.shift
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の強制
|
||||
#--------------------------------------------------------------------------
|
||||
def force_action(skill_id, target_index)
|
||||
clear_actions
|
||||
action = Game_Action.new(self, true)
|
||||
action.set_skill(skill_id)
|
||||
if target_index == -2
|
||||
action.target_index = last_target_index
|
||||
elsif target_index == -1
|
||||
action.decide_random_target
|
||||
else
|
||||
action.target_index = target_index
|
||||
end
|
||||
@actions.push(action)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ計算
|
||||
#--------------------------------------------------------------------------
|
||||
def make_damage_value(user, item)
|
||||
value = item.damage.eval(user, self, $game_variables)
|
||||
value *= item_element_rate(user, item)
|
||||
value *= pdr if item.physical?
|
||||
value *= mdr if item.magical?
|
||||
value *= rec if item.damage.recover?
|
||||
value = apply_critical(value) if @result.critical
|
||||
value = apply_variance(value, item.damage.variance)
|
||||
value = apply_guard(value)
|
||||
@result.make_damage(value.to_i, item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの属性修正値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_element_rate(user, item)
|
||||
if item.damage.element_id < 0
|
||||
user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements)
|
||||
else
|
||||
element_rate(item.damage.element_id)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 属性の最大修正値の取得
|
||||
# elements : 属性 ID の配列
|
||||
# 与えられた属性の中で最も有効な修正値を返す
|
||||
#--------------------------------------------------------------------------
|
||||
def elements_max_rate(elements)
|
||||
elements.inject([0.0]) {|r, i| r.push(element_rate(i)) }.max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリティカルの適用
|
||||
#--------------------------------------------------------------------------
|
||||
def apply_critical(damage)
|
||||
damage * 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 分散度の適用
|
||||
#--------------------------------------------------------------------------
|
||||
def apply_variance(damage, variance)
|
||||
amp = [damage.abs * variance / 100, 0].max.to_i
|
||||
var = rand(amp + 1) + rand(amp + 1) - amp
|
||||
damage >= 0 ? damage + var : damage - var
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御修正の適用
|
||||
#--------------------------------------------------------------------------
|
||||
def apply_guard(damage)
|
||||
damage / (damage > 0 && guard? ? 2 * grd : 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージの処理
|
||||
# 呼び出し前に @result.hp_damage @result.mp_damage @result.hp_drain
|
||||
# @result.mp_drain が設定されていること。
|
||||
#--------------------------------------------------------------------------
|
||||
def execute_damage(user)
|
||||
on_damage(@result.hp_damage) if @result.hp_damage > 0
|
||||
self.hp -= @result.hp_damage
|
||||
self.mp -= @result.mp_damage
|
||||
user.hp += @result.hp_drain
|
||||
user.mp += @result.mp_drain
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用
|
||||
# 行動側に対して呼び出され、使用対象以外に対する効果を適用する。
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item(item)
|
||||
pay_skill_cost(item) if item.is_a?(RPG::Skill)
|
||||
consume_item(item) if item.is_a?(RPG::Item)
|
||||
item.effects.each {|effect| item_global_effect_apply(effect) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの消耗
|
||||
#--------------------------------------------------------------------------
|
||||
def consume_item(item)
|
||||
$game_party.consume_item(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用対象以外に対する使用効果の適用
|
||||
#--------------------------------------------------------------------------
|
||||
def item_global_effect_apply(effect)
|
||||
if effect.code == EFFECT_COMMON_EVENT
|
||||
$game_temp.reserve_common_event(effect.data_id)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの適用テスト
|
||||
# 使用対象が全快しているときの回復禁止などを判定する。
|
||||
#--------------------------------------------------------------------------
|
||||
def item_test(user, item)
|
||||
return false if item.for_dead_friend? != dead?
|
||||
return true if $game_party.in_battle
|
||||
return true if item.for_opponent?
|
||||
return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
|
||||
return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
|
||||
return true if item_has_any_valid_effects?(user, item)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムに有効な使用効果が一つでもあるかを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_has_any_valid_effects?(user, item)
|
||||
item.effects.any? {|effect| item_effect_test(user, item, effect) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの反撃率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def item_cnt(user, item)
|
||||
return 0 unless item.physical? # 命中タイプが物理ではない
|
||||
return 0 unless opposite?(user) # 味方には反撃しない
|
||||
return cnt # 反撃率を返す
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの反射率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def item_mrf(user, item)
|
||||
return mrf if item.magical? # 魔法攻撃なら魔法反射率を返す
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの命中率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def item_hit(user, item)
|
||||
rate = item.success_rate * 0.01 # 成功率を取得
|
||||
rate *= user.hit if item.physical? # 物理攻撃:命中率を乗算
|
||||
return rate # 計算した命中率を返す
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの回避率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def item_eva(user, item)
|
||||
return eva if item.physical? # 物理攻撃なら回避率を返す
|
||||
return mev if item.magical? # 魔法攻撃なら魔法回避率を返す
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの会心率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def item_cri(user, item)
|
||||
item.damage.critical ? user.cri * (1 - cev) : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃の効果適用
|
||||
#--------------------------------------------------------------------------
|
||||
def attack_apply(attacker)
|
||||
item_apply(attacker, $data_skills[attacker.attack_skill_id])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの効果適用
|
||||
#--------------------------------------------------------------------------
|
||||
def item_apply(user, item)
|
||||
@result.clear
|
||||
@result.used = item_test(user, item)
|
||||
@result.missed = (@result.used && rand >= item_hit(user, item))
|
||||
@result.evaded = (!@result.missed && rand < item_eva(user, item))
|
||||
if @result.hit?
|
||||
unless item.damage.none?
|
||||
@result.critical = (rand < item_cri(user, item))
|
||||
make_damage_value(user, item)
|
||||
execute_damage(user)
|
||||
end
|
||||
item.effects.each {|effect| item_effect_apply(user, item, effect) }
|
||||
item_user_effect(user, item)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果のテスト
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_test(user, item, effect)
|
||||
case effect.code
|
||||
when EFFECT_RECOVER_HP
|
||||
hp < mhp || effect.value1 < 0 || effect.value2 < 0
|
||||
when EFFECT_RECOVER_MP
|
||||
mp < mmp || effect.value1 < 0 || effect.value2 < 0
|
||||
when EFFECT_ADD_STATE
|
||||
!state?(effect.data_id)
|
||||
when EFFECT_REMOVE_STATE
|
||||
state?(effect.data_id)
|
||||
when EFFECT_ADD_BUFF
|
||||
!buff_max?(effect.data_id)
|
||||
when EFFECT_ADD_DEBUFF
|
||||
!debuff_max?(effect.data_id)
|
||||
when EFFECT_REMOVE_BUFF
|
||||
buff?(effect.data_id)
|
||||
when EFFECT_REMOVE_DEBUFF
|
||||
debuff?(effect.data_id)
|
||||
when EFFECT_LEARN_SKILL
|
||||
actor? && !skills.include?($data_skills[effect.data_id])
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果の適用
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_apply(user, item, effect)
|
||||
method_table = {
|
||||
EFFECT_RECOVER_HP => :item_effect_recover_hp,
|
||||
EFFECT_RECOVER_MP => :item_effect_recover_mp,
|
||||
EFFECT_GAIN_TP => :item_effect_gain_tp,
|
||||
EFFECT_ADD_STATE => :item_effect_add_state,
|
||||
EFFECT_REMOVE_STATE => :item_effect_remove_state,
|
||||
EFFECT_ADD_BUFF => :item_effect_add_buff,
|
||||
EFFECT_ADD_DEBUFF => :item_effect_add_debuff,
|
||||
EFFECT_REMOVE_BUFF => :item_effect_remove_buff,
|
||||
EFFECT_REMOVE_DEBUFF => :item_effect_remove_debuff,
|
||||
EFFECT_SPECIAL => :item_effect_special,
|
||||
EFFECT_GROW => :item_effect_grow,
|
||||
EFFECT_LEARN_SKILL => :item_effect_learn_skill,
|
||||
EFFECT_COMMON_EVENT => :item_effect_common_event,
|
||||
}
|
||||
method_name = method_table[effect.code]
|
||||
send(method_name, user, item, effect) if method_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[HP 回復]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_recover_hp(user, item, effect)
|
||||
value = (mhp * effect.value1 + effect.value2) * rec
|
||||
value *= user.pha if item.is_a?(RPG::Item)
|
||||
value = value.to_i
|
||||
@result.hp_damage -= value
|
||||
@result.success = true
|
||||
self.hp += value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[MP 回復]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_recover_mp(user, item, effect)
|
||||
value = (mmp * effect.value1 + effect.value2) * rec
|
||||
value *= user.pha if item.is_a?(RPG::Item)
|
||||
value = value.to_i
|
||||
@result.mp_damage -= value
|
||||
@result.success = true if value != 0
|
||||
self.mp += value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[TP 増加]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_gain_tp(user, item, effect)
|
||||
value = effect.value1.to_i
|
||||
@result.tp_damage -= value
|
||||
@result.success = true if value != 0
|
||||
self.tp += value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[ステート付加]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_add_state(user, item, effect)
|
||||
if effect.data_id == 0
|
||||
item_effect_add_state_attack(user, item, effect)
|
||||
else
|
||||
item_effect_add_state_normal(user, item, effect)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[ステート付加]:通常攻撃
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_add_state_attack(user, item, effect)
|
||||
user.atk_states.each do |state_id|
|
||||
chance = effect.value1
|
||||
chance *= state_rate(state_id)
|
||||
chance *= user.atk_states_rate(state_id)
|
||||
chance *= luk_effect_rate(user)
|
||||
if rand < chance
|
||||
add_state(state_id)
|
||||
@result.success = true
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[ステート付加]:通常
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_add_state_normal(user, item, effect)
|
||||
chance = effect.value1
|
||||
chance *= state_rate(effect.data_id) if opposite?(user)
|
||||
chance *= luk_effect_rate(user) if opposite?(user)
|
||||
if rand < chance
|
||||
add_state(effect.data_id)
|
||||
@result.success = true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[ステート解除]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_remove_state(user, item, effect)
|
||||
chance = effect.value1
|
||||
if rand < chance
|
||||
remove_state(effect.data_id)
|
||||
@result.success = true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[能力強化]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_add_buff(user, item, effect)
|
||||
add_buff(effect.data_id, effect.value1)
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[能力弱体]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_add_debuff(user, item, effect)
|
||||
chance = debuff_rate(effect.data_id) * luk_effect_rate(user)
|
||||
if rand < chance
|
||||
add_debuff(effect.data_id, effect.value1)
|
||||
@result.success = true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[能力強化の解除]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_remove_buff(user, item, effect)
|
||||
remove_buff(effect.data_id) if @buffs[effect.data_id] > 0
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[能力弱体の解除]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_remove_debuff(user, item, effect)
|
||||
remove_buff(effect.data_id) if @buffs[effect.data_id] < 0
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[特殊効果]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_special(user, item, effect)
|
||||
case effect.data_id
|
||||
when SPECIAL_EFFECT_ESCAPE
|
||||
escape
|
||||
end
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[成長]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_grow(user, item, effect)
|
||||
add_param(effect.data_id, effect.value1.to_i)
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[スキル習得]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_learn_skill(user, item, effect)
|
||||
learn_skill(effect.data_id) if actor?
|
||||
@result.success = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 使用効果[コモンイベント]
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effect_common_event(user, item, effect)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用者側への効果
|
||||
#--------------------------------------------------------------------------
|
||||
def item_user_effect(user, item)
|
||||
user.tp += item.tp_gain * user.tcr
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 運による有効度変化率の取得■■■■■■■■
|
||||
#--------------------------------------------------------------------------
|
||||
def luk_effect_rate(user)
|
||||
[1.0 + (user.luk - luk) * 0.005, 0.0].max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵対関係の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def opposite?(battler)
|
||||
actor? != battler.actor?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ上でダメージを受けたときの効果
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_map_damage_effect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_tp
|
||||
self.tp = rand * 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_tp
|
||||
self.tp = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 被ダメージによる TP チャージ
|
||||
#--------------------------------------------------------------------------
|
||||
def charge_tp_by_damage(damage_rate)
|
||||
self.tp += 5 * damage_rate * tcr
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の再生
|
||||
#--------------------------------------------------------------------------
|
||||
def regenerate_hp
|
||||
damage = -(mhp * hrg).to_i
|
||||
perform_map_damage_effect if $game_party.in_battle && damage > 0
|
||||
@result.hp_damage = [damage, max_slip_damage].min
|
||||
self.hp -= @result.hp_damage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スリップダメージの最大値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_slip_damage
|
||||
$data_system.opt_slip_death ? hp : [hp - 1, 0].max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP の再生
|
||||
#--------------------------------------------------------------------------
|
||||
def regenerate_mp
|
||||
@result.mp_damage = -(mmp * mrg).to_i
|
||||
self.mp -= @result.mp_damage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の再生
|
||||
#--------------------------------------------------------------------------
|
||||
def regenerate_tp
|
||||
self.tp += 100 * trg
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ての再生
|
||||
#--------------------------------------------------------------------------
|
||||
def regenerate_all
|
||||
if alive?
|
||||
regenerate_hp
|
||||
regenerate_mp
|
||||
regenerate_tp
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_battle_start
|
||||
init_tp unless preserve_tp?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動終了時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_action_end
|
||||
@result.clear
|
||||
remove_states_auto(1)
|
||||
remove_buffs_auto
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_turn_end
|
||||
@result.clear
|
||||
regenerate_all
|
||||
update_state_turns
|
||||
update_buff_turns
|
||||
remove_states_auto(2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_battle_end
|
||||
@result.clear
|
||||
remove_battle_states
|
||||
remove_all_buffs
|
||||
clear_actions
|
||||
clear_tp unless preserve_tp?
|
||||
appear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 被ダメージ時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_damage(value)
|
||||
remove_states_by_damage
|
||||
charge_tp_by_damage(value.to_f / mhp)
|
||||
end
|
||||
end
|
||||
730
Scripts/Game_BattlerBase.rb
Normal file
730
Scripts/Game_BattlerBase.rb
Normal file
|
|
@ -0,0 +1,730 @@
|
|||
#==============================================================================
|
||||
# ■ Game_BattlerBase
|
||||
#------------------------------------------------------------------------------
|
||||
# バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ
|
||||
# のクラスは Game_Battler クラスのスーパークラスとして使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_BattlerBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数(特徴)
|
||||
#--------------------------------------------------------------------------
|
||||
FEATURE_ELEMENT_RATE = 11 # 属性有効度
|
||||
FEATURE_DEBUFF_RATE = 12 # 弱体有効度
|
||||
FEATURE_STATE_RATE = 13 # ステート有効度
|
||||
FEATURE_STATE_RESIST = 14 # ステート無効化
|
||||
FEATURE_PARAM = 21 # 通常能力値
|
||||
FEATURE_XPARAM = 22 # 追加能力値
|
||||
FEATURE_SPARAM = 23 # 特殊能力値
|
||||
FEATURE_ATK_ELEMENT = 31 # 攻撃時属性
|
||||
FEATURE_ATK_STATE = 32 # 攻撃時ステート
|
||||
FEATURE_ATK_SPEED = 33 # 攻撃速度補正
|
||||
FEATURE_ATK_TIMES = 34 # 攻撃追加回数
|
||||
FEATURE_STYPE_ADD = 41 # スキルタイプ追加
|
||||
FEATURE_STYPE_SEAL = 42 # スキルタイプ封印
|
||||
FEATURE_SKILL_ADD = 43 # スキル追加
|
||||
FEATURE_SKILL_SEAL = 44 # スキル封印
|
||||
FEATURE_EQUIP_WTYPE = 51 # 武器タイプ装備
|
||||
FEATURE_EQUIP_ATYPE = 52 # 防具タイプ装備
|
||||
FEATURE_EQUIP_FIX = 53 # 装備固定
|
||||
FEATURE_EQUIP_SEAL = 54 # 装備封印
|
||||
FEATURE_SLOT_TYPE = 55 # スロットタイプ
|
||||
FEATURE_ACTION_PLUS = 61 # 行動回数追加
|
||||
FEATURE_SPECIAL_FLAG = 62 # 特殊フラグ
|
||||
FEATURE_COLLAPSE_TYPE = 63 # 消滅エフェクト
|
||||
FEATURE_PARTY_ABILITY = 64 # パーティ能力
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数(特殊フラグ)
|
||||
#--------------------------------------------------------------------------
|
||||
FLAG_ID_AUTO_BATTLE = 0 # 自動戦闘
|
||||
FLAG_ID_GUARD = 1 # 防御
|
||||
FLAG_ID_SUBSTITUTE = 2 # 身代わり
|
||||
FLAG_ID_PRESERVE_TP = 3 # TP持ち越し
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数(能力強化/弱体アイコンの開始番号)
|
||||
#--------------------------------------------------------------------------
|
||||
ICON_BUFF_START = 64 # 強化(16 個)
|
||||
ICON_DEBUFF_START = 80 # 弱体(16 個)
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :hp # HP
|
||||
attr_reader :mp # MP
|
||||
attr_reader :tp # TP
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 各種能力値の略称によるアクセスメソッド
|
||||
#--------------------------------------------------------------------------
|
||||
def mhp; param(0); end # 最大HP Maximum Hit Point
|
||||
def mmp; param(1); end # 最大MP Maximum Magic Point
|
||||
def atk; param(2); end # 攻撃力 ATtacK power
|
||||
def def; param(3); end # 防御力 DEFense power
|
||||
def mat; param(4); end # 魔法力 Magic ATtack power
|
||||
def mdf; param(5); end # 魔法防御 Magic DeFense power
|
||||
def agi; param(6); end # 敏捷性 AGIlity
|
||||
def luk; param(7); end # 運 LUcK
|
||||
def hit; xparam(0); end # 命中率 HIT rate
|
||||
def eva; xparam(1); end # 回避率 EVAsion rate
|
||||
def cri; xparam(2); end # 会心率 CRItical rate
|
||||
def cev; xparam(3); end # 会心回避率 Critical EVasion rate
|
||||
def mev; xparam(4); end # 魔法回避率 Magic EVasion rate
|
||||
def mrf; xparam(5); end # 魔法反射率 Magic ReFlection rate
|
||||
def cnt; xparam(6); end # 反撃率 CouNTer attack rate
|
||||
def hrg; xparam(7); end # HP再生率 Hp ReGeneration rate
|
||||
def mrg; xparam(8); end # MP再生率 Mp ReGeneration rate
|
||||
def trg; xparam(9); end # TP再生率 Tp ReGeneration rate
|
||||
def tgr; sparam(0); end # 狙われ率 TarGet Rate
|
||||
def grd; sparam(1); end # 防御効果率 GuaRD effect rate
|
||||
def rec; sparam(2); end # 回復効果率 RECovery effect rate
|
||||
def pha; sparam(3); end # 薬の知識 PHArmacology
|
||||
def mcr; sparam(4); end # MP消費率 Mp Cost Rate
|
||||
def tcr; sparam(5); end # TPチャージ率 Tp Charge Rate
|
||||
def pdr; sparam(6); end # 物理ダメージ率 Physical Damage Rate
|
||||
def mdr; sparam(7); end # 魔法ダメージ率 Magical Damage Rate
|
||||
def fdr; sparam(8); end # 床ダメージ率 Floor Damage Rate
|
||||
def exr; sparam(9); end # 経験獲得率 EXperience Rate
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@hp = @mp = @tp = 0
|
||||
@hidden = false
|
||||
clear_param_plus
|
||||
clear_states
|
||||
clear_buffs
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力値に加算する値をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_param_plus
|
||||
@param_plus = [0] * 8
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート情報をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_states
|
||||
@states = []
|
||||
@state_turns = {}
|
||||
@state_steps = {}
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの消去
|
||||
#--------------------------------------------------------------------------
|
||||
def erase_state(state_id)
|
||||
@states.delete(state_id)
|
||||
@state_turns.delete(state_id)
|
||||
@state_steps.delete(state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化情報をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_buffs
|
||||
@buffs = Array.new(8) { 0 }
|
||||
@buff_turns = {}
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの検査
|
||||
#--------------------------------------------------------------------------
|
||||
def state?(state_id)
|
||||
@states.include?(state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能ステートの検査
|
||||
#--------------------------------------------------------------------------
|
||||
def death_state?
|
||||
state?(death_state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能のステート ID を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def death_state_id
|
||||
return 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のステートをオブジェクトの配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def states
|
||||
@states.collect {|id| $data_states[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のステートをアイコン番号の配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def state_icons
|
||||
icons = states.collect {|state| state.icon_index }
|
||||
icons.delete(0)
|
||||
icons
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在の強化/弱体をアイコン番号の配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def buff_icons
|
||||
icons = []
|
||||
@buffs.each_with_index {|lv, i| icons.push(buff_icon_index(lv, i)) }
|
||||
icons.delete(0)
|
||||
icons
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強化/弱体に対応するアイコン番号を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def buff_icon_index(buff_level, param_id)
|
||||
if buff_level > 0
|
||||
return ICON_BUFF_START + (buff_level - 1) * 8 + param_id
|
||||
elsif buff_level < 0
|
||||
return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴を保持する全オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def feature_objects
|
||||
states
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ての特徴オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_features
|
||||
feature_objects.inject([]) {|r, obj| r + obj.features }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴オブジェクトの配列取得(特徴コードを限定)
|
||||
#--------------------------------------------------------------------------
|
||||
def features(code)
|
||||
all_features.select {|ft| ft.code == code }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴オブジェクトの配列取得(特徴コードとデータ ID を限定)
|
||||
#--------------------------------------------------------------------------
|
||||
def features_with_id(code, id)
|
||||
all_features.select {|ft| ft.code == code && ft.data_id == id }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴値の総乗計算
|
||||
#--------------------------------------------------------------------------
|
||||
def features_pi(code, id)
|
||||
features_with_id(code, id).inject(1.0) {|r, ft| r *= ft.value }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴値の総和計算(データ ID を指定)
|
||||
#--------------------------------------------------------------------------
|
||||
def features_sum(code, id)
|
||||
features_with_id(code, id).inject(0.0) {|r, ft| r += ft.value }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴値の総和計算(データ ID は非指定)
|
||||
#--------------------------------------------------------------------------
|
||||
def features_sum_all(code)
|
||||
features(code).inject(0.0) {|r, ft| r += ft.value }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴の集合和計算
|
||||
#--------------------------------------------------------------------------
|
||||
def features_set(code)
|
||||
features(code).inject([]) {|r, ft| r |= [ft.data_id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の基本値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_base(param_id)
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の加算値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_plus(param_id)
|
||||
@param_plus[param_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の最小値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_min(param_id)
|
||||
return 0 if param_id == 1 # MMP
|
||||
return 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の最大値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_max(param_id)
|
||||
return 999999 if param_id == 0 # MHP
|
||||
return 9999 if param_id == 1 # MMP
|
||||
return 999
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の変化率取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_rate(param_id)
|
||||
features_pi(FEATURE_PARAM, param_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の強化/弱体による変化率取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_buff_rate(param_id)
|
||||
@buffs[param_id] * 0.25 + 1.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param(param_id)
|
||||
value = param_base(param_id) + param_plus(param_id)
|
||||
value *= param_rate(param_id) * param_buff_rate(param_id)
|
||||
[[value, param_max(param_id)].min, param_min(param_id)].max.to_i
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 追加能力値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def xparam(xparam_id)
|
||||
features_sum(FEATURE_XPARAM, xparam_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特殊能力値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def sparam(sparam_id)
|
||||
features_pi(FEATURE_SPARAM, sparam_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 属性有効度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def element_rate(element_id)
|
||||
features_pi(FEATURE_ELEMENT_RATE, element_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 弱体有効度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def debuff_rate(param_id)
|
||||
features_pi(FEATURE_DEBUFF_RATE, param_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート有効度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def state_rate(state_id)
|
||||
features_pi(FEATURE_STATE_RATE, state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 無効化するステートの配列を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def state_resist_set
|
||||
features_set(FEATURE_STATE_RESIST)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 無効化されているステートの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def state_resist?(state_id)
|
||||
state_resist_set.include?(state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃時属性の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_elements
|
||||
features_set(FEATURE_ATK_ELEMENT)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃時ステートの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_states
|
||||
features_set(FEATURE_ATK_STATE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃時ステートの発動率取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_states_rate(state_id)
|
||||
features_sum(FEATURE_ATK_STATE, state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃速度補正の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_speed
|
||||
features_sum_all(FEATURE_ATK_SPEED)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃追加回数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def atk_times_add
|
||||
[features_sum_all(FEATURE_ATK_TIMES), 0].max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 追加スキルタイプの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def added_skill_types
|
||||
features_set(FEATURE_STYPE_ADD)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルタイプ封印の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_type_sealed?(stype_id)
|
||||
features_set(FEATURE_STYPE_SEAL).include?(stype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 追加スキルの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def added_skills
|
||||
features_set(FEATURE_SKILL_ADD)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル封印の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_sealed?(skill_id)
|
||||
features_set(FEATURE_SKILL_SEAL).include?(skill_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 武器装備可能の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_wtype_ok?(wtype_id)
|
||||
features_set(FEATURE_EQUIP_WTYPE).include?(wtype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防具装備可能の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_atype_ok?(atype_id)
|
||||
features_set(FEATURE_EQUIP_ATYPE).include?(atype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備固定の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_type_fixed?(etype_id)
|
||||
features_set(FEATURE_EQUIP_FIX).include?(etype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備封印の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_type_sealed?(etype_id)
|
||||
features_set(FEATURE_EQUIP_SEAL).include?(etype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スロットタイプの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def slot_type
|
||||
features_set(FEATURE_SLOT_TYPE).max || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 二刀流の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def dual_wield?
|
||||
slot_type == 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動回数追加確率の配列を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def action_plus_set
|
||||
features(FEATURE_ACTION_PLUS).collect {|ft| ft.value }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特殊フラグ判定
|
||||
#--------------------------------------------------------------------------
|
||||
def special_flag(flag_id)
|
||||
features(FEATURE_SPECIAL_FLAG).any? {|ft| ft.data_id == flag_id }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 消滅エフェクトの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def collapse_type
|
||||
features_set(FEATURE_COLLAPSE_TYPE).max || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティ能力判定
|
||||
#--------------------------------------------------------------------------
|
||||
def party_ability(ability_id)
|
||||
features(FEATURE_PARTY_ABILITY).any? {|ft| ft.data_id == ability_id }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動戦闘の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def auto_battle?
|
||||
special_flag(FLAG_ID_AUTO_BATTLE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御の判定
|
||||
#--------------------------------------------------------------------------
|
||||
def guard?
|
||||
special_flag(FLAG_ID_GUARD) && movable?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 身代わりの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def substitute?
|
||||
special_flag(FLAG_ID_SUBSTITUTE) && movable?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP持ち越しの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def preserve_tp?
|
||||
special_flag(FLAG_ID_PRESERVE_TP)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力値の加算
|
||||
#--------------------------------------------------------------------------
|
||||
def add_param(param_id, value)
|
||||
@param_plus[param_id] += value
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def hp=(hp)
|
||||
@hp = hp
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def mp=(mp)
|
||||
@mp = mp
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の増減(イベント用)
|
||||
# value : 増減値
|
||||
# enable_death : 戦闘不能を許可
|
||||
#--------------------------------------------------------------------------
|
||||
def change_hp(value, enable_death)
|
||||
if !enable_death && @hp + value <= 0
|
||||
self.hp = 1
|
||||
else
|
||||
self.hp += value
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def tp=(tp)
|
||||
@tp = [[tp, max_tp].min, 0].max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の最大値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_tp
|
||||
return 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
state_resist_set.each {|state_id| erase_state(state_id) }
|
||||
@hp = [[@hp, mhp].min, 0].max
|
||||
@mp = [[@mp, mmp].min, 0].max
|
||||
@hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全回復
|
||||
#--------------------------------------------------------------------------
|
||||
def recover_all
|
||||
clear_states
|
||||
@hp = mhp
|
||||
@mp = mmp
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の割合を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def hp_rate
|
||||
@hp.to_f / mhp
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP の割合を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def mp_rate
|
||||
mmp > 0 ? @mp.to_f / mmp : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の割合を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tp_rate
|
||||
@tp.to_f / 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 隠れる
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
@hidden = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現れる
|
||||
#--------------------------------------------------------------------------
|
||||
def appear
|
||||
@hidden = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 隠れ状態取得
|
||||
#--------------------------------------------------------------------------
|
||||
def hidden?
|
||||
@hidden
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 存在判定
|
||||
#--------------------------------------------------------------------------
|
||||
def exist?
|
||||
!hidden?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def dead?
|
||||
exist? && death_state?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 生存判定
|
||||
#--------------------------------------------------------------------------
|
||||
def alive?
|
||||
exist? && !death_state?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 正常判定
|
||||
#--------------------------------------------------------------------------
|
||||
def normal?
|
||||
exist? && restriction == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド入力可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def inputable?
|
||||
normal? && !auto_battle?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def movable?
|
||||
exist? && restriction < 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 混乱状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def confusion?
|
||||
exist? && restriction >= 1 && restriction <= 3
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 混乱レベル取得
|
||||
#--------------------------------------------------------------------------
|
||||
def confusion_level
|
||||
confusion? ? restriction : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターか否かの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def actor?
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラか否かの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def enemy?
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの並び替え
|
||||
# 配列 @states の内容を表示優先度の大きい順に並び替える。
|
||||
#--------------------------------------------------------------------------
|
||||
def sort_states
|
||||
@states = @states.sort_by {|id| [-$data_states[id].priority, id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制約の取得
|
||||
# 現在付加されているステートから最大の restriction を取得する。
|
||||
#--------------------------------------------------------------------------
|
||||
def restriction
|
||||
states.collect {|state| state.restriction }.push(0).max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最重要のステート継続メッセージを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def most_important_state_text
|
||||
states.each {|state| return state.message3 unless state.message3.empty? }
|
||||
return ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの必要武器を装備しているか
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_wtype_ok?(skill)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの消費 MP 計算
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_mp_cost(skill)
|
||||
(skill.mp_cost * mcr).to_i
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの消費 TP 計算
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_tp_cost(skill)
|
||||
skill.tp_cost
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル使用コストの支払い可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_cost_payable?(skill)
|
||||
tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル使用コストの支払い
|
||||
#--------------------------------------------------------------------------
|
||||
def pay_skill_cost(skill)
|
||||
self.mp -= skill_mp_cost(skill)
|
||||
self.tp -= skill_tp_cost(skill)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用可能時チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def occasion_ok?(item)
|
||||
$game_party.in_battle ? item.battle_ok? : item.menu_ok?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの共通使用可能条件チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def usable_item_conditions_met?(item)
|
||||
movable? && occasion_ok?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの使用可能条件チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def skill_conditions_met?(skill)
|
||||
usable_item_conditions_met?(skill) &&
|
||||
skill_wtype_ok?(skill) && skill_cost_payable?(skill) &&
|
||||
!skill_sealed?(skill.id) && !skill_type_sealed?(skill.stype_id)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用可能条件チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def item_conditions_met?(item)
|
||||
usable_item_conditions_met?(item) && $game_party.has_item?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def usable?(item)
|
||||
return skill_conditions_met?(item) if item.is_a?(RPG::Skill)
|
||||
return item_conditions_met?(item) if item.is_a?(RPG::Item)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def equippable?(item)
|
||||
return false unless item.is_a?(RPG::EquipItem)
|
||||
return false if equip_type_sealed?(item.etype_id)
|
||||
return equip_wtype_ok?(item.wtype_id) if item.is_a?(RPG::Weapon)
|
||||
return equip_atype_ok?(item.atype_id) if item.is_a?(RPG::Armor)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃のスキル ID を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def attack_skill_id
|
||||
return 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御のスキル ID を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def guard_skill_id
|
||||
return 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常攻撃の使用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def attack_usable?
|
||||
usable?($data_skills[attack_skill_id])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御の使用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def guard_usable?
|
||||
usable?($data_skills[guard_skill_id])
|
||||
end
|
||||
end
|
||||
395
Scripts/Game_Character.rb
Normal file
395
Scripts/Game_Character.rb
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Character
|
||||
#------------------------------------------------------------------------------
|
||||
# 主に移動ルートなどの処理を追加したキャラクターのクラスです。Game_Player、
|
||||
# Game_Follower、GameVehicle、Game_Event のスーパークラスとして使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Character < Game_CharacterBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数
|
||||
#--------------------------------------------------------------------------
|
||||
ROUTE_END = 0 # 移動ルートの終端
|
||||
ROUTE_MOVE_DOWN = 1 # 下に移動
|
||||
ROUTE_MOVE_LEFT = 2 # 左に移動
|
||||
ROUTE_MOVE_RIGHT = 3 # 右に移動
|
||||
ROUTE_MOVE_UP = 4 # 上に移動
|
||||
ROUTE_MOVE_LOWER_L = 5 # 左下に移動
|
||||
ROUTE_MOVE_LOWER_R = 6 # 右下に移動
|
||||
ROUTE_MOVE_UPPER_L = 7 # 左上に移動
|
||||
ROUTE_MOVE_UPPER_R = 8 # 右上に移動
|
||||
ROUTE_MOVE_RANDOM = 9 # ランダムに移動
|
||||
ROUTE_MOVE_TOWARD = 10 # プレイヤーに近づく
|
||||
ROUTE_MOVE_AWAY = 11 # プレイヤーから遠ざかる
|
||||
ROUTE_MOVE_FORWARD = 12 # 一歩前進
|
||||
ROUTE_MOVE_BACKWARD = 13 # 一歩後退
|
||||
ROUTE_JUMP = 14 # ジャンプ
|
||||
ROUTE_WAIT = 15 # ウェイト
|
||||
ROUTE_TURN_DOWN = 16 # 下を向く
|
||||
ROUTE_TURN_LEFT = 17 # 左を向く
|
||||
ROUTE_TURN_RIGHT = 18 # 右を向く
|
||||
ROUTE_TURN_UP = 19 # 上を向く
|
||||
ROUTE_TURN_90D_R = 20 # 右に 90 度回転
|
||||
ROUTE_TURN_90D_L = 21 # 左に 90 度回転
|
||||
ROUTE_TURN_180D = 22 # 180 度回転
|
||||
ROUTE_TURN_90D_R_L = 23 # 右か左に 90 度回転
|
||||
ROUTE_TURN_RANDOM = 24 # ランダムに方向転換
|
||||
ROUTE_TURN_TOWARD = 25 # プレイヤーの方を向く
|
||||
ROUTE_TURN_AWAY = 26 # プレイヤーの逆を向く
|
||||
ROUTE_SWITCH_ON = 27 # スイッチ ON
|
||||
ROUTE_SWITCH_OFF = 28 # スイッチ OFF
|
||||
ROUTE_CHANGE_SPEED = 29 # 移動速度の変更
|
||||
ROUTE_CHANGE_FREQ = 30 # 移動頻度の変更
|
||||
ROUTE_WALK_ANIME_ON = 31 # 歩行アニメ ON
|
||||
ROUTE_WALK_ANIME_OFF = 32 # 歩行アニメ OFF
|
||||
ROUTE_STEP_ANIME_ON = 33 # 足踏みアニメ ON
|
||||
ROUTE_STEP_ANIME_OFF = 34 # 足踏みアニメ OFF
|
||||
ROUTE_DIR_FIX_ON = 35 # 向き固定 ON
|
||||
ROUTE_DIR_FIX_OFF = 36 # 向き固定 OFF
|
||||
ROUTE_THROUGH_ON = 37 # すり抜け ON
|
||||
ROUTE_THROUGH_OFF = 38 # すり抜け OFF
|
||||
ROUTE_TRANSPARENT_ON = 39 # 透明化 ON
|
||||
ROUTE_TRANSPARENT_OFF = 40 # 透明化 OFF
|
||||
ROUTE_CHANGE_GRAPHIC = 41 # グラフィック変更
|
||||
ROUTE_CHANGE_OPACITY = 42 # 不透明度の変更
|
||||
ROUTE_CHANGE_BLENDING = 43 # 合成方法の変更
|
||||
ROUTE_PLAY_SE = 44 # SE の演奏
|
||||
ROUTE_SCRIPT = 45 # スクリプト
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :move_route_forcing # 移動ルート強制フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_public_members
|
||||
super
|
||||
@move_route_forcing = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 非公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_private_members
|
||||
super
|
||||
@move_route = nil # 移動ルート
|
||||
@move_route_index = 0 # 移動ルートの実行位置
|
||||
@original_move_route = nil # 元の移動ルート
|
||||
@original_move_route_index = 0 # 元の移動ルートの実行位置
|
||||
@wait_count = 0 # ウェイトカウント
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動ルートの記憶
|
||||
#--------------------------------------------------------------------------
|
||||
def memorize_move_route
|
||||
@original_move_route = @move_route
|
||||
@original_move_route_index = @move_route_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動ルートの復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def restore_move_route
|
||||
@move_route = @original_move_route
|
||||
@move_route_index = @original_move_route_index
|
||||
@original_move_route = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動ルートの強制
|
||||
#--------------------------------------------------------------------------
|
||||
def force_move_route(move_route)
|
||||
memorize_move_route unless @original_move_route
|
||||
@move_route = move_route
|
||||
@move_route_index = 0
|
||||
@move_route_forcing = true
|
||||
@prelock_direction = 0
|
||||
@wait_count = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_stop
|
||||
super
|
||||
update_routine_move if @move_route_forcing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ルートに沿った移動の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_routine_move
|
||||
if @wait_count > 0
|
||||
@wait_count -= 1
|
||||
else
|
||||
@move_succeed = true
|
||||
command = @move_route.list[@move_route_index]
|
||||
if command
|
||||
process_move_command(command)
|
||||
advance_move_route_index
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動コマンドの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_move_command(command)
|
||||
params = command.parameters
|
||||
case command.code
|
||||
when ROUTE_END; process_route_end
|
||||
when ROUTE_MOVE_DOWN; move_straight(2)
|
||||
when ROUTE_MOVE_LEFT; move_straight(4)
|
||||
when ROUTE_MOVE_RIGHT; move_straight(6)
|
||||
when ROUTE_MOVE_UP; move_straight(8)
|
||||
when ROUTE_MOVE_LOWER_L; move_diagonal(4, 2)
|
||||
when ROUTE_MOVE_LOWER_R; move_diagonal(6, 2)
|
||||
when ROUTE_MOVE_UPPER_L; move_diagonal(4, 8)
|
||||
when ROUTE_MOVE_UPPER_R; move_diagonal(6, 8)
|
||||
when ROUTE_MOVE_RANDOM; move_random
|
||||
when ROUTE_MOVE_TOWARD; move_toward_player
|
||||
when ROUTE_MOVE_AWAY; move_away_from_player
|
||||
when ROUTE_MOVE_FORWARD; move_forward
|
||||
when ROUTE_MOVE_BACKWARD; move_backward
|
||||
when ROUTE_JUMP; jump(params[0], params[1])
|
||||
when ROUTE_WAIT; @wait_count = params[0] - 1
|
||||
when ROUTE_TURN_DOWN; set_direction(2)
|
||||
when ROUTE_TURN_LEFT; set_direction(4)
|
||||
when ROUTE_TURN_RIGHT; set_direction(6)
|
||||
when ROUTE_TURN_UP; set_direction(8)
|
||||
when ROUTE_TURN_90D_R; turn_right_90
|
||||
when ROUTE_TURN_90D_L; turn_left_90
|
||||
when ROUTE_TURN_180D; turn_180
|
||||
when ROUTE_TURN_90D_R_L; turn_right_or_left_90
|
||||
when ROUTE_TURN_RANDOM; turn_random
|
||||
when ROUTE_TURN_TOWARD; turn_toward_player
|
||||
when ROUTE_TURN_AWAY; turn_away_from_player
|
||||
when ROUTE_SWITCH_ON; $game_switches[params[0]] = true
|
||||
when ROUTE_SWITCH_OFF; $game_switches[params[0]] = false
|
||||
when ROUTE_CHANGE_SPEED; @move_speed = params[0]
|
||||
when ROUTE_CHANGE_FREQ; @move_frequency = params[0]
|
||||
when ROUTE_WALK_ANIME_ON; @walk_anime = true
|
||||
when ROUTE_WALK_ANIME_OFF; @walk_anime = false
|
||||
when ROUTE_STEP_ANIME_ON; @step_anime = true
|
||||
when ROUTE_STEP_ANIME_OFF; @step_anime = false
|
||||
when ROUTE_DIR_FIX_ON; @direction_fix = true
|
||||
when ROUTE_DIR_FIX_OFF; @direction_fix = false
|
||||
when ROUTE_THROUGH_ON; @through = true
|
||||
when ROUTE_THROUGH_OFF; @through = false
|
||||
when ROUTE_TRANSPARENT_ON; @transparent = true
|
||||
when ROUTE_TRANSPARENT_OFF; @transparent = false
|
||||
when ROUTE_CHANGE_GRAPHIC; set_graphic(params[0], params[1])
|
||||
when ROUTE_CHANGE_OPACITY; @opacity = params[0]
|
||||
when ROUTE_CHANGE_BLENDING; @blend_type = params[0]
|
||||
when ROUTE_PLAY_SE; params[0].play
|
||||
when ROUTE_SCRIPT; eval(params[0])
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● X 方向の距離計算
|
||||
#--------------------------------------------------------------------------
|
||||
def distance_x_from(x)
|
||||
result = @x - x
|
||||
if $game_map.loop_horizontal? && result.abs > $game_map.width / 2
|
||||
if result < 0
|
||||
result += $game_map.width
|
||||
else
|
||||
result -= $game_map.width
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● Y 方向の距離計算
|
||||
#--------------------------------------------------------------------------
|
||||
def distance_y_from(y)
|
||||
result = @y - y
|
||||
if $game_map.loop_vertical? && result.abs > $game_map.height / 2
|
||||
if result < 0
|
||||
result += $game_map.height
|
||||
else
|
||||
result -= $game_map.height
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ランダムに移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move_random
|
||||
move_straight(2 + rand(4) * 2, false)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターに近づく
|
||||
#--------------------------------------------------------------------------
|
||||
def move_toward_character(character)
|
||||
sx = distance_x_from(character.x)
|
||||
sy = distance_y_from(character.y)
|
||||
if sx.abs > sy.abs
|
||||
move_straight(sx > 0 ? 4 : 6)
|
||||
move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
|
||||
elsif sy != 0
|
||||
move_straight(sy > 0 ? 8 : 2)
|
||||
move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターから遠ざかる
|
||||
#--------------------------------------------------------------------------
|
||||
def move_away_from_character(character)
|
||||
sx = distance_x_from(character.x)
|
||||
sy = distance_y_from(character.y)
|
||||
if sx.abs > sy.abs
|
||||
move_straight(sx > 0 ? 6 : 4)
|
||||
move_straight(sy > 0 ? 2 : 8) if !@move_succeed && sy != 0
|
||||
elsif sy != 0
|
||||
move_straight(sy > 0 ? 2 : 8)
|
||||
move_straight(sx > 0 ? 6 : 4) if !@move_succeed && sx != 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターの方を向く
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_toward_character(character)
|
||||
sx = distance_x_from(character.x)
|
||||
sy = distance_y_from(character.y)
|
||||
if sx.abs > sy.abs
|
||||
set_direction(sx > 0 ? 4 : 6)
|
||||
elsif sy != 0
|
||||
set_direction(sy > 0 ? 8 : 2)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターの逆を向く
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_away_from_character(character)
|
||||
sx = distance_x_from(character.x)
|
||||
sy = distance_y_from(character.y)
|
||||
if sx.abs > sy.abs
|
||||
set_direction(sx > 0 ? 6 : 4)
|
||||
elsif sy != 0
|
||||
set_direction(sy > 0 ? 2 : 8)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーの方を向く
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_toward_player
|
||||
turn_toward_character($game_player)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーの逆を向く
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_away_from_player
|
||||
turn_away_from_character($game_player)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーに近づく
|
||||
#--------------------------------------------------------------------------
|
||||
def move_toward_player
|
||||
move_toward_character($game_player)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーから遠ざかる
|
||||
#--------------------------------------------------------------------------
|
||||
def move_away_from_player
|
||||
move_away_from_character($game_player)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一歩前進
|
||||
#--------------------------------------------------------------------------
|
||||
def move_forward
|
||||
move_straight(@direction)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一歩後退
|
||||
#--------------------------------------------------------------------------
|
||||
def move_backward
|
||||
last_direction_fix = @direction_fix
|
||||
@direction_fix = true
|
||||
move_straight(reverse_dir(@direction), false)
|
||||
@direction_fix = last_direction_fix
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ジャンプ
|
||||
# x_plus : X 座標加算値
|
||||
# y_plus : Y 座標加算値
|
||||
#--------------------------------------------------------------------------
|
||||
def jump(x_plus, y_plus)
|
||||
if x_plus.abs > y_plus.abs
|
||||
set_direction(x_plus < 0 ? 4 : 6) if x_plus != 0
|
||||
else
|
||||
set_direction(y_plus < 0 ? 8 : 2) if y_plus != 0
|
||||
end
|
||||
@x += x_plus
|
||||
@y += y_plus
|
||||
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
|
||||
@jump_peak = 10 + distance - @move_speed
|
||||
@jump_count = @jump_peak * 2
|
||||
@stop_count = 0
|
||||
straighten
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動ルート終端の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_route_end
|
||||
if @move_route.repeat
|
||||
@move_route_index = -1
|
||||
elsif @move_route_forcing
|
||||
@move_route_forcing = false
|
||||
restore_move_route
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動ルートの実行位置を進める
|
||||
#--------------------------------------------------------------------------
|
||||
def advance_move_route_index
|
||||
@move_route_index += 1 if @move_succeed || @move_route.skippable
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右に 90 度回転
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_right_90
|
||||
case @direction
|
||||
when 2; set_direction(4)
|
||||
when 4; set_direction(8)
|
||||
when 6; set_direction(2)
|
||||
when 8; set_direction(6)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 左に 90 度回転
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_left_90
|
||||
case @direction
|
||||
when 2; set_direction(6)
|
||||
when 4; set_direction(2)
|
||||
when 6; set_direction(8)
|
||||
when 8; set_direction(4)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 180 度回転
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_180
|
||||
set_direction(reverse_dir(@direction))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右か左に 90 度回転
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_right_or_left_90
|
||||
case rand(2)
|
||||
when 0; turn_right_90
|
||||
when 1; turn_left_90
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ランダムに方向転換
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_random
|
||||
set_direction(2 + rand(4) * 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターの位置を交換
|
||||
#--------------------------------------------------------------------------
|
||||
def swap(character)
|
||||
new_x = character.x
|
||||
new_y = character.y
|
||||
character.moveto(x, y)
|
||||
moveto(new_x, new_y)
|
||||
end
|
||||
end
|
||||
443
Scripts/Game_CharacterBase.rb
Normal file
443
Scripts/Game_CharacterBase.rb
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
#==============================================================================
|
||||
# ■ Game_CharacterBase
|
||||
#------------------------------------------------------------------------------
|
||||
# キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
|
||||
# ラフィックなどの基本的な情報を保持します。
|
||||
#==============================================================================
|
||||
|
||||
class Game_CharacterBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :id # ID
|
||||
attr_reader :x # マップ X 座標(論理座標)
|
||||
attr_reader :y # マップ Y 座標(論理座標)
|
||||
attr_reader :real_x # マップ X 座標(実座標)
|
||||
attr_reader :real_y # マップ Y 座標(実座標)
|
||||
attr_reader :tile_id # タイル ID(0 なら無効)
|
||||
attr_reader :character_name # 歩行グラフィック ファイル名
|
||||
attr_reader :character_index # 歩行グラフィック インデックス
|
||||
attr_reader :move_speed # 移動速度
|
||||
attr_reader :move_frequency # 移動頻度
|
||||
attr_reader :walk_anime # 歩行アニメ
|
||||
attr_reader :step_anime # 足踏みアニメ
|
||||
attr_reader :direction_fix # 向き固定
|
||||
attr_reader :opacity # 不透明度
|
||||
attr_reader :blend_type # 合成方法
|
||||
attr_reader :direction # 向き
|
||||
attr_reader :pattern # パターン
|
||||
attr_reader :priority_type # プライオリティタイプ
|
||||
attr_reader :through # すり抜け
|
||||
attr_reader :bush_depth # 茂み深さ
|
||||
attr_accessor :animation_id # アニメーション ID
|
||||
attr_accessor :balloon_id # フキダシアイコン ID
|
||||
attr_accessor :transparent # 透明状態
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
init_public_members
|
||||
init_private_members
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_public_members
|
||||
@id = 0
|
||||
@x = 0
|
||||
@y = 0
|
||||
@real_x = 0
|
||||
@real_y = 0
|
||||
@tile_id = 0
|
||||
@character_name = ""
|
||||
@character_index = 0
|
||||
@move_speed = 4
|
||||
@move_frequency = 6
|
||||
@walk_anime = true
|
||||
@step_anime = false
|
||||
@direction_fix = false
|
||||
@opacity = 255
|
||||
@blend_type = 0
|
||||
@direction = 2
|
||||
@pattern = 1
|
||||
@priority_type = 1
|
||||
@through = false
|
||||
@bush_depth = 0
|
||||
@animation_id = 0
|
||||
@balloon_id = 0
|
||||
@transparent = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 非公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_private_members
|
||||
@original_direction = 2 # 元の向き
|
||||
@original_pattern = 1 # 元のパターン
|
||||
@anime_count = 0 # アニメカウント
|
||||
@stop_count = 0 # 停止カウント
|
||||
@jump_count = 0 # ジャンプカウント
|
||||
@jump_peak = 0 # ジャンプの頂点のカウント
|
||||
@locked = false # ロックフラグ
|
||||
@prelock_direction = 0 # ロック前の向き
|
||||
@move_succeed = true # 移動成功フラグ
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 座標一致判定
|
||||
#--------------------------------------------------------------------------
|
||||
def pos?(x, y)
|
||||
@x == x && @y == y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 座標一致と「すり抜け OFF」判定(nt = No Through)
|
||||
#--------------------------------------------------------------------------
|
||||
def pos_nt?(x, y)
|
||||
pos?(x, y) && !@through
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プライオリティ[通常キャラと同じ]判定
|
||||
#--------------------------------------------------------------------------
|
||||
def normal_priority?
|
||||
@priority_type == 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def moving?
|
||||
@real_x != @x || @real_y != @y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ジャンプ中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def jumping?
|
||||
@jump_count > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ジャンプの高さを計算
|
||||
#--------------------------------------------------------------------------
|
||||
def jump_height
|
||||
(@jump_peak * @jump_peak - (@jump_count - @jump_peak).abs ** 2) / 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def stopping?
|
||||
!moving? && !jumping?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動速度の取得(ダッシュを考慮)
|
||||
#--------------------------------------------------------------------------
|
||||
def real_move_speed
|
||||
@move_speed + (dash? ? 1 : 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 1 フレームあたりの移動距離を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def distance_per_frame
|
||||
2 ** real_move_speed / 256.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダッシュ状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def dash?
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● デバッグすり抜け状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def debug_through?
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 姿勢の矯正
|
||||
#--------------------------------------------------------------------------
|
||||
def straighten
|
||||
@pattern = 1 if @walk_anime || @step_anime
|
||||
@anime_count = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 逆方向の取得
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def reverse_dir(d)
|
||||
return 10 - d
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通行可能判定
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def passable?(x, y, d)
|
||||
x2 = $game_map.round_x_with_direction(x, d)
|
||||
y2 = $game_map.round_y_with_direction(y, d)
|
||||
return false unless $game_map.valid?(x2, y2)
|
||||
return true if @through || debug_through?
|
||||
return false unless map_passable?(x, y, d)
|
||||
return false unless map_passable?(x2, y2, reverse_dir(d))
|
||||
return false if collide_with_characters?(x2, y2)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 斜めの通行可能判定
|
||||
# horz : 横方向(4 or 6)
|
||||
# vert : 縦方向(2 or 8)
|
||||
#--------------------------------------------------------------------------
|
||||
def diagonal_passable?(x, y, horz, vert)
|
||||
x2 = $game_map.round_x_with_direction(x, horz)
|
||||
y2 = $game_map.round_y_with_direction(y, vert)
|
||||
(passable?(x, y, vert) && passable?(x, y2, horz)) ||
|
||||
(passable?(x, y, horz) && passable?(x2, y, vert))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ通行可能判定
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def map_passable?(x, y, d)
|
||||
$game_map.passable?(x, y, d)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターとの衝突判定
|
||||
#--------------------------------------------------------------------------
|
||||
def collide_with_characters?(x, y)
|
||||
collide_with_events?(x, y) || collide_with_vehicles?(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントとの衝突判定
|
||||
#--------------------------------------------------------------------------
|
||||
def collide_with_events?(x, y)
|
||||
$game_map.events_xy_nt(x, y).any? do |event|
|
||||
event.normal_priority? || self.is_a?(Game_Event)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物との衝突判定
|
||||
#--------------------------------------------------------------------------
|
||||
def collide_with_vehicles?(x, y)
|
||||
$game_map.boat.pos_nt?(x, y) || $game_map.ship.pos_nt?(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定位置に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def moveto(x, y)
|
||||
@x = x % $game_map.width
|
||||
@y = y % $game_map.height
|
||||
@real_x = @x
|
||||
@real_y = @y
|
||||
@prelock_direction = 0
|
||||
straighten
|
||||
update_bush_depth
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定方向に向き変更
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def set_direction(d)
|
||||
@direction = d if !@direction_fix && d != 0
|
||||
@stop_count = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイル判定
|
||||
#--------------------------------------------------------------------------
|
||||
def tile?
|
||||
@tile_id > 0 && @priority_type == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクトキャラクター判定
|
||||
#--------------------------------------------------------------------------
|
||||
def object_character?
|
||||
@tile_id > 0 || @character_name[0, 1] == '!'
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルの位置から上にずらすピクセル数を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def shift_y
|
||||
object_character? ? 0 : 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面 X 座標の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_x
|
||||
$game_map.adjust_x(@real_x) * 32 + 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面 Y 座標の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_y
|
||||
$game_map.adjust_y(@real_y) * 32 + 32 - shift_y - jump_height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面 Z 座標の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_z
|
||||
@priority_type * 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_animation
|
||||
return update_jump if jumping?
|
||||
return update_move if moving?
|
||||
return update_stop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ジャンプ時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_jump
|
||||
@jump_count -= 1
|
||||
@real_x = (@real_x * @jump_count + @x) / (@jump_count + 1.0)
|
||||
@real_y = (@real_y * @jump_count + @y) / (@jump_count + 1.0)
|
||||
update_bush_depth
|
||||
if @jump_count == 0
|
||||
@real_x = @x = $game_map.round_x(@x)
|
||||
@real_y = @y = $game_map.round_y(@y)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_move
|
||||
@real_x = [@real_x - distance_per_frame, @x].max if @x < @real_x
|
||||
@real_x = [@real_x + distance_per_frame, @x].min if @x > @real_x
|
||||
@real_y = [@real_y - distance_per_frame, @y].max if @y < @real_y
|
||||
@real_y = [@real_y + distance_per_frame, @y].min if @y > @real_y
|
||||
update_bush_depth unless moving?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_stop
|
||||
@stop_count += 1 unless @locked
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩行/足踏みアニメの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_animation
|
||||
update_anime_count
|
||||
if @anime_count > 18 - real_move_speed * 2
|
||||
update_anime_pattern
|
||||
@anime_count = 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメカウントの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_anime_count
|
||||
if moving? && @walk_anime
|
||||
@anime_count += 1.5
|
||||
elsif @step_anime || @pattern != @original_pattern
|
||||
@anime_count += 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメパターンの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_anime_pattern
|
||||
if !@step_anime && @stop_count > 0
|
||||
@pattern = @original_pattern
|
||||
else
|
||||
@pattern = (@pattern + 1) % 4
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 梯子判定
|
||||
#--------------------------------------------------------------------------
|
||||
def ladder?
|
||||
$game_map.ladder?(@x, @y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 茂み深さの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_bush_depth
|
||||
if normal_priority? && !object_character? && bush? && !jumping?
|
||||
@bush_depth = 8 unless moving?
|
||||
else
|
||||
@bush_depth = 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 茂み判定
|
||||
#--------------------------------------------------------------------------
|
||||
def bush?
|
||||
$game_map.bush?(@x, @y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 地形タグの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def terrain_tag
|
||||
$game_map.terrain_tag(@x, @y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リージョン ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def region_id
|
||||
$game_map.region_id(@x, @y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩数増加
|
||||
#--------------------------------------------------------------------------
|
||||
def increase_steps
|
||||
set_direction(8) if ladder?
|
||||
@stop_count = 0
|
||||
update_bush_depth
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● グラフィックの変更
|
||||
# character_name : 新しい歩行グラフィック ファイル名
|
||||
# character_index : 新しい歩行グラフィック インデックス
|
||||
#--------------------------------------------------------------------------
|
||||
def set_graphic(character_name, character_index)
|
||||
@tile_id = 0
|
||||
@character_name = character_name
|
||||
@character_index = character_index
|
||||
@original_pattern = 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 正面の接触イベントの起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_touch_front
|
||||
x2 = $game_map.round_x_with_direction(@x, @direction)
|
||||
y2 = $game_map.round_y_with_direction(@y, @direction)
|
||||
check_event_trigger_touch(x2, y2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 接触イベントの起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_touch(x, y)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● まっすぐに移動
|
||||
# d : 方向(2,4,6,8)
|
||||
# turn_ok : その場での向き変更を許可
|
||||
#--------------------------------------------------------------------------
|
||||
def move_straight(d, turn_ok = true)
|
||||
@move_succeed = passable?(@x, @y, d)
|
||||
if @move_succeed
|
||||
set_direction(d)
|
||||
@x = $game_map.round_x_with_direction(@x, d)
|
||||
@y = $game_map.round_y_with_direction(@y, d)
|
||||
@real_x = $game_map.x_with_direction(@x, reverse_dir(d))
|
||||
@real_y = $game_map.y_with_direction(@y, reverse_dir(d))
|
||||
increase_steps
|
||||
elsif turn_ok
|
||||
set_direction(d)
|
||||
check_event_trigger_touch_front
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 斜めに移動
|
||||
# horz : 横方向(4 or 6)
|
||||
# vert : 縦方向(2 or 8)
|
||||
#--------------------------------------------------------------------------
|
||||
def move_diagonal(horz, vert)
|
||||
@move_succeed = diagonal_passable?(x, y, horz, vert)
|
||||
if @move_succeed
|
||||
@x = $game_map.round_x_with_direction(@x, horz)
|
||||
@y = $game_map.round_y_with_direction(@y, vert)
|
||||
@real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
|
||||
@real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
|
||||
increase_steps
|
||||
end
|
||||
set_direction(horz) if @direction == reverse_dir(horz)
|
||||
set_direction(vert) if @direction == reverse_dir(vert)
|
||||
end
|
||||
end
|
||||
41
Scripts/Game_CommonEvent.rb
Normal file
41
Scripts/Game_CommonEvent.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#==============================================================================
|
||||
# ■ Game_CommonEvent
|
||||
#------------------------------------------------------------------------------
|
||||
# コモンイベントを扱うクラスです。並列処理イベントを実行する機能を持っていま
|
||||
# す。このクラスは Game_Map クラス($game_map)の内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_CommonEvent
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(common_event_id)
|
||||
@event = $data_common_events[common_event_id]
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
if active?
|
||||
@interpreter ||= Game_Interpreter.new
|
||||
else
|
||||
@interpreter = nil
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 有効状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def active?
|
||||
@event.parallel? && $game_switches[@event.switch_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
if @interpreter
|
||||
@interpreter.setup(@event.list) unless @interpreter.running?
|
||||
@interpreter.update
|
||||
end
|
||||
end
|
||||
end
|
||||
264
Scripts/Game_Enemy.rb
Normal file
264
Scripts/Game_Enemy.rb
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Enemy
|
||||
#------------------------------------------------------------------------------
|
||||
# 敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の
|
||||
# 内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Enemy < Game_Battler
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :index # 敵グループ内インデックス
|
||||
attr_reader :enemy_id # 敵キャラ ID
|
||||
attr_reader :original_name # 元の名前
|
||||
attr_accessor :letter # 名前につける ABC の文字
|
||||
attr_accessor :plural # 複数出現フラグ
|
||||
attr_accessor :screen_x # バトル画面 X 座標
|
||||
attr_accessor :screen_y # バトル画面 Y 座標
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(index, enemy_id)
|
||||
super()
|
||||
@index = index
|
||||
@enemy_id = enemy_id
|
||||
enemy = $data_enemies[@enemy_id]
|
||||
@original_name = enemy.name
|
||||
@letter = ""
|
||||
@plural = false
|
||||
@screen_x = 0
|
||||
@screen_y = 0
|
||||
@battler_name = enemy.battler_name
|
||||
@battler_hue = enemy.battler_hue
|
||||
@hp = mhp
|
||||
@mp = mmp
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラか否かの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def enemy?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 味方ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def friends_unit
|
||||
$game_troop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵ユニットを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def opponents_unit
|
||||
$game_party
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラオブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def enemy
|
||||
$data_enemies[@enemy_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特徴を保持する全オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def feature_objects
|
||||
super + [enemy]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def name
|
||||
@original_name + (@plural ? letter : "")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常能力値の基本値取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_base(param_id)
|
||||
enemy.params[param_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def exp
|
||||
enemy.exp
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● お金の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def gold
|
||||
enemy.gold
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ドロップアイテムの配列作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_drop_items
|
||||
enemy.drop_items.inject([]) do |r, di|
|
||||
if di.kind > 0 && rand * di.denominator < drop_item_rate
|
||||
r.push(item_object(di.kind, di.data_id))
|
||||
else
|
||||
r
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ドロップアイテム取得率の倍率を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def drop_item_rate
|
||||
$game_party.drop_item_double? ? 2 : 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムオブジェクトの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_object(kind, data_id)
|
||||
return $data_items [data_id] if kind == 1
|
||||
return $data_weapons[data_id] if kind == 2
|
||||
return $data_armors [data_id] if kind == 3
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトを使うか?
|
||||
#--------------------------------------------------------------------------
|
||||
def use_sprite?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトル画面 Z 座標の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_z
|
||||
return 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ効果の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_damage_effect
|
||||
@sprite_effect_type = :blink
|
||||
Sound.play_enemy_damage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コラプス効果の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_collapse_effect
|
||||
case collapse_type
|
||||
when 0
|
||||
@sprite_effect_type = :collapse
|
||||
Sound.play_enemy_collapse
|
||||
when 1
|
||||
@sprite_effect_type = :boss_collapse
|
||||
Sound.play_boss_collapse1
|
||||
when 2
|
||||
@sprite_effect_type = :instant_collapse
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 変身
|
||||
#--------------------------------------------------------------------------
|
||||
def transform(enemy_id)
|
||||
@enemy_id = enemy_id
|
||||
if enemy.name != @original_name
|
||||
@original_name = enemy.name
|
||||
@letter = ""
|
||||
@plural = false
|
||||
end
|
||||
@battler_name = enemy.battler_name
|
||||
@battler_hue = enemy.battler_hue
|
||||
refresh
|
||||
make_actions unless @actions.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定
|
||||
# action : RPG::Enemy::Action
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met?(action)
|
||||
method_table = {
|
||||
1 => :conditions_met_turns?,
|
||||
2 => :conditions_met_hp?,
|
||||
3 => :conditions_met_mp?,
|
||||
4 => :conditions_met_state?,
|
||||
5 => :conditions_met_party_level?,
|
||||
6 => :conditions_met_switch?,
|
||||
}
|
||||
method_name = method_table[action.condition_type]
|
||||
if method_name
|
||||
send(method_name, action.condition_param1, action.condition_param2)
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[ターン数]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_turns?(param1, param2)
|
||||
n = $game_troop.turn_count
|
||||
if param2 == 0
|
||||
n == param1
|
||||
else
|
||||
n > 0 && n >= param1 && n % param2 == param1 % param2
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[HP]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_hp?(param1, param2)
|
||||
hp_rate >= param1 && hp_rate <= param2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[MP]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_mp?(param1, param2)
|
||||
mp_rate >= param1 && mp_rate <= param2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[ステート]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_state?(param1, param2)
|
||||
state?(param1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[パーティレベル]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_party_level?(param1, param2)
|
||||
$game_party.highest_level >= param1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動条件合致判定[スイッチ]
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met_switch?(param1, param2)
|
||||
$game_switches[param1]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在の状況で戦闘行動が有効か否かを判定
|
||||
# action : RPG::Enemy::Action
|
||||
#--------------------------------------------------------------------------
|
||||
def action_valid?(action)
|
||||
conditions_met?(action) && usable?($data_skills[action.skill_id])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動をランダムに選択
|
||||
# action_list : RPG::Enemy::Action の配列
|
||||
# rating_zero : ゼロとみなすレーティング値
|
||||
#--------------------------------------------------------------------------
|
||||
def select_enemy_action(action_list, rating_zero)
|
||||
sum = action_list.inject(0) {|r, a| r += a.rating - rating_zero }
|
||||
return nil if sum <= 0
|
||||
value = rand(sum)
|
||||
action_list.each do |action|
|
||||
return action if value < action.rating - rating_zero
|
||||
value -= action.rating - rating_zero
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_actions
|
||||
super
|
||||
return if @actions.empty?
|
||||
action_list = enemy.actions.select {|a| action_valid?(a) }
|
||||
return if action_list.empty?
|
||||
rating_max = action_list.collect {|a| a.rating }.max
|
||||
rating_zero = rating_max - 3
|
||||
action_list.reject! {|a| a.rating <= rating_zero }
|
||||
@actions.each do |action|
|
||||
action.set_enemy_action(select_enemy_action(action_list, rating_zero))
|
||||
end
|
||||
end
|
||||
end
|
||||
307
Scripts/Game_Event.rb
Normal file
307
Scripts/Game_Event.rb
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Event
|
||||
#------------------------------------------------------------------------------
|
||||
# イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
|
||||
# イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Event < Game_Character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :trigger # トリガー
|
||||
attr_reader :list # 実行内容
|
||||
attr_reader :starting # 起動中フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# event : RPG::Event
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(map_id, event)
|
||||
super()
|
||||
@map_id = map_id
|
||||
@event = event
|
||||
@id = @event.id
|
||||
moveto(@event.x, @event.y)
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_public_members
|
||||
super
|
||||
@trigger = 0
|
||||
@list = nil
|
||||
@starting = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 非公開メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_private_members
|
||||
super
|
||||
@move_type = 0 # 移動タイプ
|
||||
@erased = false # 一時消去フラグ
|
||||
@page = nil # イベントページ
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターとの衝突判定
|
||||
#--------------------------------------------------------------------------
|
||||
def collide_with_characters?(x, y)
|
||||
super || collide_with_player_characters?(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーとの衝突判定(フォロワーを含む)
|
||||
#--------------------------------------------------------------------------
|
||||
def collide_with_player_characters?(x, y)
|
||||
normal_priority? && $game_player.collide?(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロック(実行中のイベントが立ち止まる処理)
|
||||
#--------------------------------------------------------------------------
|
||||
def lock
|
||||
unless @locked
|
||||
@prelock_direction = @direction
|
||||
turn_toward_player
|
||||
@locked = true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロック解除
|
||||
#--------------------------------------------------------------------------
|
||||
def unlock
|
||||
if @locked
|
||||
@locked = false
|
||||
set_direction(@prelock_direction)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_stop
|
||||
super
|
||||
update_self_movement unless @move_route_forcing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自律移動の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_self_movement
|
||||
if near_the_screen? && @stop_count > stop_count_threshold
|
||||
case @move_type
|
||||
when 1; move_type_random
|
||||
when 2; move_type_toward_player
|
||||
when 3; move_type_custom
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面の可視領域付近にいるか判定
|
||||
# dx : 画面中央から左右何マス以内を判定するか
|
||||
# dy : 画面中央から上下何マス以内を判定するか
|
||||
#--------------------------------------------------------------------------
|
||||
def near_the_screen?(dx = 12, dy = 8)
|
||||
ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
|
||||
ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
|
||||
ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自律移動を開始する停止カウントの閾値を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def stop_count_threshold
|
||||
30 * (5 - @move_frequency)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動タイプ : ランダム
|
||||
#--------------------------------------------------------------------------
|
||||
def move_type_random
|
||||
case rand(6)
|
||||
when 0..1; move_random
|
||||
when 2..4; move_forward
|
||||
when 5; @stop_count = 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動タイプ : 近づく
|
||||
#--------------------------------------------------------------------------
|
||||
def move_type_toward_player
|
||||
if near_the_player?
|
||||
case rand(6)
|
||||
when 0..3; move_toward_player
|
||||
when 4; move_random
|
||||
when 5; move_forward
|
||||
end
|
||||
else
|
||||
move_random
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーの近くにいるか判定
|
||||
#--------------------------------------------------------------------------
|
||||
def near_the_player?
|
||||
sx = distance_x_from($game_player.x).abs
|
||||
sy = distance_y_from($game_player.y).abs
|
||||
sx + sy < 20
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動タイプ : カスタム
|
||||
#--------------------------------------------------------------------------
|
||||
def move_type_custom
|
||||
update_routine_move
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 起動中フラグのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_starting_flag
|
||||
@starting = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 実行内容が空か否かを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def empty?
|
||||
!@list || @list.size <= 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定されたトリガーのいずれかか否かを判定
|
||||
# triggers : トリガーの配列
|
||||
#--------------------------------------------------------------------------
|
||||
def trigger_in?(triggers)
|
||||
triggers.include?(@trigger)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベント起動
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
return if empty?
|
||||
@starting = true
|
||||
lock if trigger_in?([0,1,2])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一時消去
|
||||
#--------------------------------------------------------------------------
|
||||
def erase
|
||||
@erased = true
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
new_page = @erased ? nil : find_proper_page
|
||||
setup_page(new_page) if !new_page || new_page != @page
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 条件に合うイベントページを見つける
|
||||
#--------------------------------------------------------------------------
|
||||
def find_proper_page
|
||||
@event.pages.reverse.find {|page| conditions_met?(page) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントページの条件合致判定
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met?(page)
|
||||
c = page.condition
|
||||
if c.switch1_valid
|
||||
return false unless $game_switches[c.switch1_id]
|
||||
end
|
||||
if c.switch2_valid
|
||||
return false unless $game_switches[c.switch2_id]
|
||||
end
|
||||
if c.variable_valid
|
||||
return false if $game_variables[c.variable_id] < c.variable_value
|
||||
end
|
||||
if c.self_switch_valid
|
||||
key = [@map_id, @event.id, c.self_switch_ch]
|
||||
return false if $game_self_switches[key] != true
|
||||
end
|
||||
if c.item_valid
|
||||
item = $data_items[c.item_id]
|
||||
return false unless $game_party.has_item?(item)
|
||||
end
|
||||
if c.actor_valid
|
||||
actor = $game_actors[c.actor_id]
|
||||
return false unless $game_party.members.include?(actor)
|
||||
end
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントページのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_page(new_page)
|
||||
@page = new_page
|
||||
if @page
|
||||
setup_page_settings
|
||||
else
|
||||
clear_page_settings
|
||||
end
|
||||
update_bush_depth
|
||||
clear_starting_flag
|
||||
check_event_trigger_auto
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントページの設定をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_page_settings
|
||||
@tile_id = 0
|
||||
@character_name = ""
|
||||
@character_index = 0
|
||||
@move_type = 0
|
||||
@through = true
|
||||
@trigger = nil
|
||||
@list = nil
|
||||
@interpreter = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントページの設定をセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_page_settings
|
||||
@tile_id = @page.graphic.tile_id
|
||||
@character_name = @page.graphic.character_name
|
||||
@character_index = @page.graphic.character_index
|
||||
if @original_direction != @page.graphic.direction
|
||||
@direction = @page.graphic.direction
|
||||
@original_direction = @direction
|
||||
@prelock_direction = 0
|
||||
end
|
||||
if @original_pattern != @page.graphic.pattern
|
||||
@pattern = @page.graphic.pattern
|
||||
@original_pattern = @pattern
|
||||
end
|
||||
@move_type = @page.move_type
|
||||
@move_speed = @page.move_speed
|
||||
@move_frequency = @page.move_frequency
|
||||
@move_route = @page.move_route
|
||||
@move_route_index = 0
|
||||
@move_route_forcing = false
|
||||
@walk_anime = @page.walk_anime
|
||||
@step_anime = @page.step_anime
|
||||
@direction_fix = @page.direction_fix
|
||||
@through = @page.through
|
||||
@priority_type = @page.priority_type
|
||||
@trigger = @page.trigger
|
||||
@list = @page.list
|
||||
@interpreter = @trigger == 4 ? Game_Interpreter.new : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 接触イベントの起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_touch(x, y)
|
||||
return if $game_map.interpreter.running?
|
||||
if @trigger == 2 && $game_player.pos?(x, y)
|
||||
start if !jumping? && normal_priority?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動イベントの起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_auto
|
||||
start if @trigger == 3
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
check_event_trigger_auto
|
||||
return unless @interpreter
|
||||
@interpreter.setup(@list, @event.id) unless @interpreter.running?
|
||||
@interpreter.update
|
||||
end
|
||||
end
|
||||
73
Scripts/Game_Follower.rb
Normal file
73
Scripts/Game_Follower.rb
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Follower
|
||||
#------------------------------------------------------------------------------
|
||||
# フォロワーを扱うクラスです。フォロワーとは、隊列歩行で表示する、先頭以外の
|
||||
# 仲間キャラクターのことです。Game_Followers クラスの内部で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Follower < Game_Character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(member_index, preceding_character)
|
||||
super()
|
||||
@member_index = member_index
|
||||
@preceding_character = preceding_character
|
||||
@transparent = $data_system.opt_transparent
|
||||
@through = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
@character_name = visible? ? actor.character_name : ""
|
||||
@character_index = visible? ? actor.character_index : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 対応するアクターの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def actor
|
||||
$game_party.battle_members[@member_index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 可視判定
|
||||
#--------------------------------------------------------------------------
|
||||
def visible?
|
||||
actor && $game_player.followers.visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
@move_speed = $game_player.real_move_speed
|
||||
@transparent = $game_player.transparent
|
||||
@walk_anime = $game_player.walk_anime
|
||||
@step_anime = $game_player.step_anime
|
||||
@direction_fix = $game_player.direction_fix
|
||||
@opacity = $game_player.opacity
|
||||
@blend_type = $game_player.blend_type
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先導キャラクターを追う
|
||||
#--------------------------------------------------------------------------
|
||||
def chase_preceding_character
|
||||
unless moving?
|
||||
sx = distance_x_from(@preceding_character.x)
|
||||
sy = distance_y_from(@preceding_character.y)
|
||||
if sx != 0 && sy != 0
|
||||
move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2)
|
||||
elsif sx != 0
|
||||
move_straight(sx > 0 ? 4 : 6)
|
||||
elsif sy != 0
|
||||
move_straight(sy > 0 ? 8 : 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先導キャラクターと同位置にいるかを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def gather?
|
||||
!moving? && pos?(@preceding_character.x, @preceding_character.y)
|
||||
end
|
||||
end
|
||||
111
Scripts/Game_Followers.rb
Normal file
111
Scripts/Game_Followers.rb
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Followers
|
||||
#------------------------------------------------------------------------------
|
||||
# フォロワーの配列のラッパーです。このクラスは Game_Player クラスの内部で使
|
||||
# 用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Followers
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :visible # 可視状態 (真なら隊列歩行 ON)
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# leader : 先頭のキャラクター
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(leader)
|
||||
@visible = $data_system.opt_followers
|
||||
@gathering = false # 集合処理中フラグ
|
||||
@data = []
|
||||
@data.push(Game_Follower.new(1, leader))
|
||||
(2...$game_party.max_battle_members).each do |index|
|
||||
@data.push(Game_Follower.new(index, @data[-1]))
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フォロワーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](index)
|
||||
@data[index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イテレータ
|
||||
#--------------------------------------------------------------------------
|
||||
def each
|
||||
@data.each {|follower| yield follower } if block_given?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イテレータ(逆順)
|
||||
#--------------------------------------------------------------------------
|
||||
def reverse_each
|
||||
@data.reverse.each {|follower| yield follower } if block_given?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
each {|follower| follower.refresh }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
if gathering?
|
||||
move unless moving? || moving?
|
||||
@gathering = false if gather?
|
||||
end
|
||||
each {|follower| follower.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move
|
||||
reverse_each {|follower| follower.chase_preceding_character }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 同期
|
||||
#--------------------------------------------------------------------------
|
||||
def synchronize(x, y, d)
|
||||
each do |follower|
|
||||
follower.moveto(x, y)
|
||||
follower.set_direction(d)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 集合
|
||||
#--------------------------------------------------------------------------
|
||||
def gather
|
||||
@gathering = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 集合中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def gathering?
|
||||
@gathering
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示中のフォロワーの配列を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_folloers
|
||||
@data.select {|follower| follower.visible? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def moving?
|
||||
visible_folloers.any? {|follower| follower.moving? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 集合済み判定
|
||||
#--------------------------------------------------------------------------
|
||||
def gather?
|
||||
visible_folloers.all? {|follower| follower.gather? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 衝突判定
|
||||
#--------------------------------------------------------------------------
|
||||
def collide?(x, y)
|
||||
visible_folloers.any? {|follower| follower.pos?(x, y) }
|
||||
end
|
||||
end
|
||||
1411
Scripts/Game_Interpreter.rb
Normal file
1411
Scripts/Game_Interpreter.rb
Normal file
File diff suppressed because it is too large
Load diff
698
Scripts/Game_Map.rb
Normal file
698
Scripts/Game_Map.rb
Normal file
|
|
@ -0,0 +1,698 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Map
|
||||
#------------------------------------------------------------------------------
|
||||
# マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
|
||||
# このクラスのインスタンスは $game_map で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Map
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :screen # マップ画面の状態
|
||||
attr_reader :interpreter # マップイベント用インタプリタ
|
||||
attr_reader :events # イベント
|
||||
attr_reader :display_x # 表示 X 座標
|
||||
attr_reader :display_y # 表示 Y 座標
|
||||
attr_reader :parallax_name # 遠景 ファイル名
|
||||
attr_reader :vehicles # 乗り物
|
||||
attr_reader :battleback1_name # 戦闘背景(床)ファイル名
|
||||
attr_reader :battleback2_name # 戦闘背景(壁)ファイル名
|
||||
attr_accessor :name_display # マップ名表示フラグ
|
||||
attr_accessor :need_refresh # リフレッシュ要求フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@screen = Game_Screen.new
|
||||
@interpreter = Game_Interpreter.new
|
||||
@map_id = 0
|
||||
@events = {}
|
||||
@display_x = 0
|
||||
@display_y = 0
|
||||
create_vehicles
|
||||
@name_display = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup(map_id)
|
||||
@map_id = map_id
|
||||
@map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
|
||||
@tileset_id = @map.tileset_id
|
||||
@display_x = 0
|
||||
@display_y = 0
|
||||
referesh_vehicles
|
||||
setup_events
|
||||
setup_scroll
|
||||
setup_parallax
|
||||
setup_battleback
|
||||
@need_refresh = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_vehicles
|
||||
@vehicles = []
|
||||
@vehicles[0] = Game_Vehicle.new(:boat)
|
||||
@vehicles[1] = Game_Vehicle.new(:ship)
|
||||
@vehicles[2] = Game_Vehicle.new(:airship)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物のリフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def referesh_vehicles
|
||||
@vehicles.each {|vehicle| vehicle.refresh }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def vehicle(type)
|
||||
return @vehicles[0] if type == :boat
|
||||
return @vehicles[1] if type == :ship
|
||||
return @vehicles[2] if type == :airship
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 小型船の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def boat
|
||||
@vehicles[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 大型船の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def ship
|
||||
@vehicles[1]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def airship
|
||||
@vehicles[2]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_events
|
||||
@events = {}
|
||||
@map.events.each do |i, event|
|
||||
@events[i] = Game_Event.new(@map_id, event)
|
||||
end
|
||||
@common_events = parallel_common_events.collect do |common_event|
|
||||
Game_CommonEvent.new(common_event.id)
|
||||
end
|
||||
refresh_tile_events
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 並列処理コモンイベントの配列を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def parallel_common_events
|
||||
$data_common_events.select {|event| event && event.parallel? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロールのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_scroll
|
||||
@scroll_direction = 2
|
||||
@scroll_rest = 0
|
||||
@scroll_speed = 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景のセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_parallax
|
||||
@parallax_name = @map.parallax_name
|
||||
@parallax_loop_x = @map.parallax_loop_x
|
||||
@parallax_loop_y = @map.parallax_loop_y
|
||||
@parallax_sx = @map.parallax_sx
|
||||
@parallax_sy = @map.parallax_sy
|
||||
@parallax_x = 0
|
||||
@parallax_y = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景のセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_battleback
|
||||
if @map.specify_battleback
|
||||
@battleback1_name = @map.battleback1_name
|
||||
@battleback2_name = @map.battleback2_name
|
||||
else
|
||||
@battleback1_name = nil
|
||||
@battleback2_name = nil
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示位置の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_display_pos(x, y)
|
||||
x = [0, [x, width - screen_tile_x].min].max unless loop_horizontal?
|
||||
y = [0, [y, height - screen_tile_y].min].max unless loop_vertical?
|
||||
@display_x = (x + width) % width
|
||||
@display_y = (y + height) % height
|
||||
@parallax_x = x
|
||||
@parallax_y = y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景表示の原点 X 座標の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def parallax_ox(bitmap)
|
||||
if @parallax_loop_x
|
||||
@parallax_x * 16
|
||||
else
|
||||
w1 = [bitmap.width - Graphics.width, 0].max
|
||||
w2 = [width * 32 - Graphics.width, 1].max
|
||||
@parallax_x * 16 * w1 / w2
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景表示の原点 Y 座標の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def parallax_oy(bitmap)
|
||||
if @parallax_loop_y
|
||||
@parallax_y * 16
|
||||
else
|
||||
h1 = [bitmap.height - Graphics.height, 0].max
|
||||
h2 = [height * 32 - Graphics.height, 1].max
|
||||
@parallax_y * 16 * h1 / h2
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def map_id
|
||||
@map_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルセットの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tileset
|
||||
$data_tilesets[@tileset_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def display_name
|
||||
@map.display_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def width
|
||||
@map.width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def height
|
||||
@map.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 横方向にループするか?
|
||||
#--------------------------------------------------------------------------
|
||||
def loop_horizontal?
|
||||
@map.scroll_type == 2 || @map.scroll_type == 3
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 縦方向にループするか?
|
||||
#--------------------------------------------------------------------------
|
||||
def loop_vertical?
|
||||
@map.scroll_type == 1 || @map.scroll_type == 3
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダッシュ禁止か否かの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def disable_dash?
|
||||
@map.disable_dashing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウントリストの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_list
|
||||
@map.encounter_list
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント歩数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_step
|
||||
@map.encounter_step
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップデータの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def data
|
||||
@map.data
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フィールドタイプか否か
|
||||
#--------------------------------------------------------------------------
|
||||
def overworld?
|
||||
tileset.mode == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面の横タイル数
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_tile_x
|
||||
Graphics.width / 32
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面の縦タイル数
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_tile_y
|
||||
Graphics.height / 32
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示座標を差し引いた X 座標の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def adjust_x(x)
|
||||
if loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
|
||||
x - @display_x + @map.width
|
||||
else
|
||||
x - @display_x
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示座標を差し引いた Y 座標の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def adjust_y(y)
|
||||
if loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
|
||||
y - @display_y + @map.height
|
||||
else
|
||||
y - @display_y
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ループ補正後の X 座標計算
|
||||
#--------------------------------------------------------------------------
|
||||
def round_x(x)
|
||||
loop_horizontal? ? (x + width) % width : x
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ループ補正後の Y 座標計算
|
||||
#--------------------------------------------------------------------------
|
||||
def round_y(y)
|
||||
loop_vertical? ? (y + height) % height : y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特定の方向に 1 マスずらした X 座標の計算(ループ補正なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def x_with_direction(x, d)
|
||||
x + (d == 6 ? 1 : d == 4 ? -1 : 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特定の方向に 1 マスずらした Y 座標の計算(ループ補正なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def y_with_direction(y, d)
|
||||
y + (d == 2 ? 1 : d == 8 ? -1 : 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特定の方向に 1 マスずらした X 座標の計算(ループ補正あり)
|
||||
#--------------------------------------------------------------------------
|
||||
def round_x_with_direction(x, d)
|
||||
round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 特定の方向に 1 マスずらした Y 座標の計算(ループ補正あり)
|
||||
#--------------------------------------------------------------------------
|
||||
def round_y_with_direction(y, d)
|
||||
round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● BGM / BGS 自動切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def autoplay
|
||||
@map.bgm.play if @map.autoplay_bgm
|
||||
@map.bgs.play if @map.autoplay_bgs
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
@events.each_value {|event| event.refresh }
|
||||
@common_events.each {|event| event.refresh }
|
||||
refresh_tile_events
|
||||
@need_refresh = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイル扱いイベントの配列をリフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh_tile_events
|
||||
@tile_events = @events.values.select {|event| event.tile? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標に存在するイベントの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def events_xy(x, y)
|
||||
@events.values.select {|event| event.pos?(x, y) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標に存在するイベント(すり抜け以外)の配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def events_xy_nt(x, y)
|
||||
@events.values.select {|event| event.pos_nt?(x, y) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tile_events_xy(x, y)
|
||||
@tile_events.select {|event| event.pos_nt?(x, y) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標に存在するイベントの ID 取得(一つのみ)
|
||||
#--------------------------------------------------------------------------
|
||||
def event_id_xy(x, y)
|
||||
list = events_xy(x, y)
|
||||
list.empty? ? 0 : list[0].id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 下にスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def scroll_down(distance)
|
||||
if loop_vertical?
|
||||
@display_y += distance
|
||||
@display_y %= @map.height
|
||||
@parallax_y += distance if @parallax_loop_y
|
||||
else
|
||||
last_y = @display_y
|
||||
@display_y = [@display_y + distance, height - screen_tile_y].min
|
||||
@parallax_y += @display_y - last_y
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 左にスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def scroll_left(distance)
|
||||
if loop_horizontal?
|
||||
@display_x += @map.width - distance
|
||||
@display_x %= @map.width
|
||||
@parallax_x -= distance if @parallax_loop_x
|
||||
else
|
||||
last_x = @display_x
|
||||
@display_x = [@display_x - distance, 0].max
|
||||
@parallax_x += @display_x - last_x
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右にスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def scroll_right(distance)
|
||||
if loop_horizontal?
|
||||
@display_x += distance
|
||||
@display_x %= @map.width
|
||||
@parallax_x += distance if @parallax_loop_x
|
||||
else
|
||||
last_x = @display_x
|
||||
@display_x = [@display_x + distance, (width - screen_tile_x)].min
|
||||
@parallax_x += @display_x - last_x
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 上にスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def scroll_up(distance)
|
||||
if loop_vertical?
|
||||
@display_y += @map.height - distance
|
||||
@display_y %= @map.height
|
||||
@parallax_y -= distance if @parallax_loop_y
|
||||
else
|
||||
last_y = @display_y
|
||||
@display_y = [@display_y - distance, 0].max
|
||||
@parallax_y += @display_y - last_y
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 有効座標判定
|
||||
#--------------------------------------------------------------------------
|
||||
def valid?(x, y)
|
||||
x >= 0 && x < width && y >= 0 && y < height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通行チェック
|
||||
# bit : 調べる通行禁止ビット
|
||||
#--------------------------------------------------------------------------
|
||||
def check_passage(x, y, bit)
|
||||
all_tiles(x, y).each do |tile_id|
|
||||
flag = tileset.flags[tile_id]
|
||||
next if flag & 0x10 != 0 # [☆] : 通行に影響しない
|
||||
return true if flag & bit == 0 # [○] : 通行可
|
||||
return false if flag & bit == bit # [×] : 通行不可
|
||||
end
|
||||
return false # 通行不可
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標にあるタイル ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tile_id(x, y, z)
|
||||
@map.data[x, y, z] || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標にある全レイヤーのタイル(上から順)を配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def layered_tiles(x, y)
|
||||
[2, 1, 0].collect {|z| tile_id(x, y, z) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標にある全てのタイル(イベント含む)を配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_tiles(x, y)
|
||||
tile_events_xy(x, y).collect {|ev| ev.tile_id } + layered_tiles(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標にあるオートタイルの種類を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def autotile_type(x, y, z)
|
||||
tile_id(x, y, z) >= 2048 ? (tile_id(x, y, z) - 2048) / 48 : -1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常キャラの通行可能判定
|
||||
# d : 方向(2,4,6,8)
|
||||
# 指定された座標のタイルが指定方向に通行可能かを判定する。
|
||||
#--------------------------------------------------------------------------
|
||||
def passable?(x, y, d)
|
||||
check_passage(x, y, (1 << (d / 2 - 1)) & 0x0f)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 小型船の通行可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def boat_passable?(x, y)
|
||||
check_passage(x, y, 0x0200)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 大型船の通行可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def ship_passable?(x, y)
|
||||
check_passage(x, y, 0x0400)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の着陸可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def airship_land_ok?(x, y)
|
||||
check_passage(x, y, 0x0800) && check_passage(x, y, 0x0f)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定座標の全レイヤーのフラグ判定
|
||||
#--------------------------------------------------------------------------
|
||||
def layered_tiles_flag?(x, y, bit)
|
||||
layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 梯子判定
|
||||
#--------------------------------------------------------------------------
|
||||
def ladder?(x, y)
|
||||
valid?(x, y) && layered_tiles_flag?(x, y, 0x20)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 茂み判定
|
||||
#--------------------------------------------------------------------------
|
||||
def bush?(x, y)
|
||||
valid?(x, y) && layered_tiles_flag?(x, y, 0x40)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カウンター判定
|
||||
#--------------------------------------------------------------------------
|
||||
def counter?(x, y)
|
||||
valid?(x, y) && layered_tiles_flag?(x, y, 0x80)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ床判定
|
||||
#--------------------------------------------------------------------------
|
||||
def damage_floor?(x, y)
|
||||
valid?(x, y) && layered_tiles_flag?(x, y, 0x100)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 地形タグの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def terrain_tag(x, y)
|
||||
return 0 unless valid?(x, y)
|
||||
layered_tiles(x, y).each do |tile_id|
|
||||
tag = tileset.flags[tile_id] >> 12
|
||||
return tag if tag > 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リージョン ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def region_id(x, y)
|
||||
valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロールの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_scroll(direction, distance, speed)
|
||||
@scroll_direction = direction
|
||||
@scroll_rest = distance
|
||||
@scroll_speed = speed
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロール中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def scrolling?
|
||||
@scroll_rest > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
# main : インタプリタ更新フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
def update(main = false)
|
||||
refresh if @need_refresh
|
||||
update_interpreter if main
|
||||
update_scroll
|
||||
update_events
|
||||
update_vehicles
|
||||
update_parallax
|
||||
@screen.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロールの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_scroll
|
||||
return unless scrolling?
|
||||
last_x = @display_x
|
||||
last_y = @display_y
|
||||
do_scroll(@scroll_direction, scroll_distance)
|
||||
if @display_x == last_x && @display_y == last_y
|
||||
@scroll_rest = 0
|
||||
else
|
||||
@scroll_rest -= scroll_distance
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロール距離の計算
|
||||
#--------------------------------------------------------------------------
|
||||
def scroll_distance
|
||||
2 ** @scroll_speed / 256.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロールの実行
|
||||
#--------------------------------------------------------------------------
|
||||
def do_scroll(direction, distance)
|
||||
case direction
|
||||
when 2; scroll_down (distance)
|
||||
when 4; scroll_left (distance)
|
||||
when 6; scroll_right(distance)
|
||||
when 8; scroll_up (distance)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_events
|
||||
@events.each_value {|event| event.update }
|
||||
@common_events.each {|event| event.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_vehicles
|
||||
@vehicles.each {|vehicle| vehicle.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_parallax
|
||||
@parallax_x += @parallax_sx / 64.0 if @parallax_loop_x
|
||||
@parallax_y += @parallax_sy / 64.0 if @parallax_loop_y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルセットの変更
|
||||
#--------------------------------------------------------------------------
|
||||
def change_tileset(tileset_id)
|
||||
@tileset_id = tileset_id
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def change_battleback(battleback1_name, battleback2_name)
|
||||
@battleback1_name = battleback1_name
|
||||
@battleback2_name = battleback2_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def change_parallax(name, loop_x, loop_y, sx, sy)
|
||||
@parallax_name = name
|
||||
@parallax_x = 0 if @parallax_loop_x && !loop_x
|
||||
@parallax_y = 0 if @parallax_loop_y && !loop_y
|
||||
@parallax_loop_x = loop_x
|
||||
@parallax_loop_y = loop_y
|
||||
@parallax_sx = sx
|
||||
@parallax_sy = sy
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● インタプリタの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_interpreter
|
||||
loop do
|
||||
@interpreter.update
|
||||
return if @interpreter.running?
|
||||
if @interpreter.event_id > 0
|
||||
unlock_event(@interpreter.event_id)
|
||||
@interpreter.clear
|
||||
end
|
||||
return unless setup_starting_event
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントのロック解除
|
||||
#--------------------------------------------------------------------------
|
||||
def unlock_event(event_id)
|
||||
@events[event_id].unlock if @events[event_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 起動中イベントのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_starting_event
|
||||
refresh if @need_refresh
|
||||
return true if @interpreter.setup_reserved_common_event
|
||||
return true if setup_starting_map_event
|
||||
return true if setup_autorun_common_event
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 起動中マップイベントの存在判定
|
||||
#--------------------------------------------------------------------------
|
||||
def any_event_starting?
|
||||
@events.values.any? {|event| event.starting }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 起動中のマップイベントを検出/セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_starting_map_event
|
||||
event = @events.values.find {|event| event.starting }
|
||||
event.clear_starting_flag if event
|
||||
@interpreter.setup(event.list, event.id) if event
|
||||
event
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動実行のコモンイベントを検出/セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_autorun_common_event
|
||||
event = $data_common_events.find do |event|
|
||||
event && event.autorun? && $game_switches[event.switch_id]
|
||||
end
|
||||
@interpreter.setup(event.list) if event
|
||||
event
|
||||
end
|
||||
end
|
||||
101
Scripts/Game_Message.rb
Normal file
101
Scripts/Game_Message.rb
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Message
|
||||
#------------------------------------------------------------------------------
|
||||
# 文章や選択肢などを表示するメッセージウィンドウの状態を扱うクラスです。この
|
||||
# クラスのインスタンスは $game_message で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Message
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :texts # 文章の配列(行単位)
|
||||
attr_reader :choices # 選択肢の配列
|
||||
attr_accessor :face_name # 顔グラフィック ファイル名
|
||||
attr_accessor :face_index # 顔グラフィック インデックス
|
||||
attr_accessor :background # 背景タイプ
|
||||
attr_accessor :position # 表示位置
|
||||
attr_accessor :choice_proc # 選択肢 コールバック(Proc)
|
||||
attr_accessor :choice_cancel_type # 選択肢 キャンセルの場合
|
||||
attr_accessor :num_input_variable_id # 数値入力 変数 ID
|
||||
attr_accessor :num_input_digits_max # 数値入力 桁数
|
||||
attr_accessor :item_choice_variable_id # アイテム選択 変数 ID
|
||||
attr_accessor :scroll_mode # スクロール文章フラグ
|
||||
attr_accessor :scroll_speed # スクロール文章:速度
|
||||
attr_accessor :scroll_no_fast # スクロール文章:早送り無効
|
||||
attr_accessor :visible # メッセージ表示中
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
clear
|
||||
@visible = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
@texts = []
|
||||
@choices = []
|
||||
@face_name = ""
|
||||
@face_index = 0
|
||||
@background = 0
|
||||
@position = 2
|
||||
@choice_cancel_type = 0
|
||||
@choice_proc = nil
|
||||
@num_input_variable_id = 0
|
||||
@num_input_digits_max = 0
|
||||
@item_choice_variable_id = 0
|
||||
@scroll_mode = false
|
||||
@scroll_speed = 2
|
||||
@scroll_no_fast = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキストの追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add(text)
|
||||
@texts.push(text)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキストの存在判定
|
||||
#--------------------------------------------------------------------------
|
||||
def has_text?
|
||||
@texts.size > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択肢モード判定
|
||||
#--------------------------------------------------------------------------
|
||||
def choice?
|
||||
@choices.size > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 数値入力モード判定
|
||||
#--------------------------------------------------------------------------
|
||||
def num_input?
|
||||
@num_input_variable_id > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム選択モード判定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_choice?
|
||||
@item_choice_variable_id > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビジー判定
|
||||
#--------------------------------------------------------------------------
|
||||
def busy?
|
||||
has_text? || choice? || num_input? || item_choice?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改ページ
|
||||
#--------------------------------------------------------------------------
|
||||
def new_page
|
||||
@texts[-1] += "\f" if @texts.size > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改行込みの全テキストを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_text
|
||||
@texts.inject("") {|r, text| r += text + "\n" }
|
||||
end
|
||||
end
|
||||
416
Scripts/Game_Party.rb
Normal file
416
Scripts/Game_Party.rb
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Party
|
||||
#------------------------------------------------------------------------------
|
||||
# パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
|
||||
# スのインスタンスは $game_party で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Party < Game_Unit
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 定数
|
||||
#--------------------------------------------------------------------------
|
||||
ABILITY_ENCOUNTER_HALF = 0 # エンカウント半減
|
||||
ABILITY_ENCOUNTER_NONE = 1 # エンカウント無効
|
||||
ABILITY_CANCEL_SURPRISE = 2 # 不意打ち無効
|
||||
ABILITY_RAISE_PREEMPTIVE = 3 # 先制攻撃率アップ
|
||||
ABILITY_GOLD_DOUBLE = 4 # 獲得金額二倍
|
||||
ABILITY_DROP_ITEM_DOUBLE = 5 # アイテム入手率二倍
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :gold # 所持金
|
||||
attr_reader :steps # 歩数
|
||||
attr_reader :last_item # カーソル記憶用 : アイテム
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super
|
||||
@gold = 0
|
||||
@steps = 0
|
||||
@last_item = Game_BaseItem.new
|
||||
@menu_actor_id = 0
|
||||
@target_actor_id = 0
|
||||
@actors = []
|
||||
init_all_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全アイテムリストの初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_all_items
|
||||
@items = {}
|
||||
@weapons = {}
|
||||
@armors = {}
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 存在判定
|
||||
#--------------------------------------------------------------------------
|
||||
def exists
|
||||
!@actors.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def members
|
||||
in_battle ? battle_members : all_members
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全メンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_members
|
||||
@actors.collect {|id| $game_actors[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトルメンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_members
|
||||
all_members[0, max_battle_members].select {|actor| actor.exist? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトルメンバーの最大数を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_battle_members
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リーダーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def leader
|
||||
battle_members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムオブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def items
|
||||
@items.keys.sort.collect {|id| $data_items[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 武器オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def weapons
|
||||
@weapons.keys.sort.collect {|id| $data_weapons[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防具オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def armors
|
||||
@armors.keys.sort.collect {|id| $data_armors[id] }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ての装備品オブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def equip_items
|
||||
weapons + armors
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全てのアイテムオブジェクトの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_items
|
||||
items + equip_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムのクラスに対応するコンテナオブジェクトを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_container(item_class)
|
||||
return @items if item_class == RPG::Item
|
||||
return @weapons if item_class == RPG::Weapon
|
||||
return @armors if item_class == RPG::Armor
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 初期パーティのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_starting_members
|
||||
@actors = $data_system.party_members.clone
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティ名の取得
|
||||
# 一人ならそのアクターの名前、複数なら "○○たち" を返す。
|
||||
#--------------------------------------------------------------------------
|
||||
def name
|
||||
return "" if battle_members.size == 0
|
||||
return leader.name if battle_members.size == 1
|
||||
return sprintf(Vocab::PartyName, leader.name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘テストのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_battle_test
|
||||
setup_battle_test_members
|
||||
setup_battle_test_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘テスト用パーティのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_battle_test_members
|
||||
$data_system.test_battlers.each do |battler|
|
||||
actor = $game_actors[battler.actor_id]
|
||||
actor.change_level(battler.level, false)
|
||||
actor.init_equips(battler.equips)
|
||||
actor.recover_all
|
||||
add_actor(actor.id)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘テスト用アイテムのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_battle_test_items
|
||||
$data_items.each do |item|
|
||||
gain_item(item, max_item_number(item)) if item && !item.name.empty?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティメンバーの最も高いレベルの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def highest_level
|
||||
lv = members.collect {|actor| actor.level }.max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターを加える
|
||||
#--------------------------------------------------------------------------
|
||||
def add_actor(actor_id)
|
||||
@actors.push(actor_id) unless @actors.include?(actor_id)
|
||||
$game_player.refresh
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターを外す
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_actor(actor_id)
|
||||
@actors.delete(actor_id)
|
||||
$game_player.refresh
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 所持金の増加(減少)
|
||||
#--------------------------------------------------------------------------
|
||||
def gain_gold(amount)
|
||||
@gold = [[@gold + amount, 0].max, max_gold].min
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 所持金の減少
|
||||
#--------------------------------------------------------------------------
|
||||
def lose_gold(amount)
|
||||
gain_gold(-amount)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 所持金の最大値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_gold
|
||||
return 99999999
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩数増加
|
||||
#--------------------------------------------------------------------------
|
||||
def increase_steps
|
||||
@steps += 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの所持数取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_number(item)
|
||||
container = item_container(item.class)
|
||||
container ? container[item.id] || 0 : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの最大所持数取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_item_number(item)
|
||||
return 99
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムを最大まで所持しているか判定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max?(item)
|
||||
item_number(item) >= max_item_number(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの所持判定
|
||||
# include_equip : 装備品も含める
|
||||
#--------------------------------------------------------------------------
|
||||
def has_item?(item, include_equip = false)
|
||||
return true if item_number(item) > 0
|
||||
return include_equip ? members_equip_include?(item) : false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定アイテムがメンバーの装備品に含まれているかを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def members_equip_include?(item)
|
||||
members.any? {|actor| actor.equips.include?(item) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの増加(減少)
|
||||
# include_equip : 装備品も含める
|
||||
#--------------------------------------------------------------------------
|
||||
def gain_item(item, amount, include_equip = false)
|
||||
container = item_container(item.class)
|
||||
return unless container
|
||||
last_number = item_number(item)
|
||||
new_number = last_number + amount
|
||||
container[item.id] = [[new_number, 0].max, max_item_number(item)].min
|
||||
container.delete(item.id) if container[item.id] == 0
|
||||
if include_equip && new_number < 0
|
||||
discard_members_equip(item, -new_number)
|
||||
end
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバーの装備品を破棄する
|
||||
#--------------------------------------------------------------------------
|
||||
def discard_members_equip(item, amount)
|
||||
n = amount
|
||||
members.each do |actor|
|
||||
while n > 0 && actor.equips.include?(item)
|
||||
actor.discard_equip(item)
|
||||
n -= 1
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの減少
|
||||
# include_equip : 装備品も含める
|
||||
#--------------------------------------------------------------------------
|
||||
def lose_item(item, amount, include_equip = false)
|
||||
gain_item(item, -amount, include_equip)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの消耗
|
||||
# 指定されたオブジェクトが消耗アイテムであれば、所持数を 1 減らす。
|
||||
#--------------------------------------------------------------------------
|
||||
def consume_item(item)
|
||||
lose_item(item, 1) if item.is_a?(RPG::Item) && item.consumable
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def usable?(item)
|
||||
members.any? {|actor| actor.usable?(item) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘時コマンド入力可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def inputable?
|
||||
members.any? {|actor| actor.inputable? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全滅判定
|
||||
#--------------------------------------------------------------------------
|
||||
def all_dead?
|
||||
super && ($game_party.in_battle || members.size > 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーが 1 歩動いたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_player_walk
|
||||
members.each {|actor| actor.on_player_walk }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メニュー画面で選択中のアクターを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def menu_actor
|
||||
$game_actors[@menu_actor_id] || members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メニュー画面で選択中のアクターを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def menu_actor=(actor)
|
||||
@menu_actor_id = actor.id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メニュー画面で次のアクターを選択
|
||||
#--------------------------------------------------------------------------
|
||||
def menu_actor_next
|
||||
index = members.index(menu_actor) || -1
|
||||
index = (index + 1) % members.size
|
||||
self.menu_actor = members[index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メニュー画面で前のアクターを選択
|
||||
#--------------------------------------------------------------------------
|
||||
def menu_actor_prev
|
||||
index = members.index(menu_actor) || 1
|
||||
index = (index + members.size - 1) % members.size
|
||||
self.menu_actor = members[index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用対象となったアクターを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def target_actor
|
||||
$game_actors[@target_actor_id] || members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用対象となったアクターを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def target_actor=(actor)
|
||||
@target_actor_id = actor.id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 順序入れ替え
|
||||
#--------------------------------------------------------------------------
|
||||
def swap_order(index1, index2)
|
||||
@actors[index1], @actors[index2] = @actors[index2], @actors[index1]
|
||||
$game_player.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイル表示用のキャラクター画像情報
|
||||
#--------------------------------------------------------------------------
|
||||
def characters_for_savefile
|
||||
battle_members.collect do |actor|
|
||||
[actor.character_name, actor.character_index]
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティ能力判定
|
||||
#--------------------------------------------------------------------------
|
||||
def party_ability(ability_id)
|
||||
battle_members.any? {|actor| actor.party_ability(ability_id) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント半減?
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_half?
|
||||
party_ability(ABILITY_ENCOUNTER_HALF)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント無効?
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_none?
|
||||
party_ability(ABILITY_ENCOUNTER_NONE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 不意打ち無効?
|
||||
#--------------------------------------------------------------------------
|
||||
def cancel_surprise?
|
||||
party_ability(ABILITY_CANCEL_SURPRISE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先制攻撃率アップ?
|
||||
#--------------------------------------------------------------------------
|
||||
def raise_preemptive?
|
||||
party_ability(ABILITY_RAISE_PREEMPTIVE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 獲得金額二倍?
|
||||
#--------------------------------------------------------------------------
|
||||
def gold_double?
|
||||
party_ability(ABILITY_GOLD_DOUBLE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム入手率二倍?
|
||||
#--------------------------------------------------------------------------
|
||||
def drop_item_double?
|
||||
party_ability(ABILITY_DROP_ITEM_DOUBLE)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先制攻撃の確率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def rate_preemptive(troop_agi)
|
||||
(agi >= troop_agi ? 0.05 : 0.03) * (raise_preemptive? ? 4 : 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 不意打ちの確率計算
|
||||
#--------------------------------------------------------------------------
|
||||
def rate_surprise(troop_agi)
|
||||
cancel_surprise? ? 0 : (agi >= troop_agi ? 0.03 : 0.05)
|
||||
end
|
||||
end
|
||||
160
Scripts/Game_Picture.rb
Normal file
160
Scripts/Game_Picture.rb
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Picture
|
||||
#------------------------------------------------------------------------------
|
||||
# ピクチャを扱うクラスです。このクラスは Game_Pictures クラスの内部で、特定
|
||||
# の番号のピクチャが必要になったときだけ作成されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Picture
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :number # ピクチャ番号
|
||||
attr_reader :name # ファイル名
|
||||
attr_reader :origin # 原点
|
||||
attr_reader :x # X 座標
|
||||
attr_reader :y # Y 座標
|
||||
attr_reader :zoom_x # X 方向拡大率
|
||||
attr_reader :zoom_y # Y 方向拡大率
|
||||
attr_reader :opacity # 不透明度
|
||||
attr_reader :blend_type # ブレンド方法
|
||||
attr_reader :tone # 色調
|
||||
attr_reader :angle # 回転角度
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(number)
|
||||
@number = number
|
||||
init_basic
|
||||
init_target
|
||||
init_tone
|
||||
init_rotate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 基本変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_basic
|
||||
@name = ""
|
||||
@origin = @x = @y = 0
|
||||
@zoom_x = @zoom_y = 100.0
|
||||
@opacity = 255.0
|
||||
@blend_type = 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動目標の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_target
|
||||
@target_x = @x
|
||||
@target_y = @y
|
||||
@target_zoom_x = @zoom_x
|
||||
@target_zoom_y = @zoom_y
|
||||
@target_opacity = @opacity
|
||||
@duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_tone
|
||||
@tone = Tone.new
|
||||
@tone_target = Tone.new
|
||||
@tone_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 回転の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_rotate
|
||||
@angle = 0
|
||||
@rotate_speed = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
|
||||
@name = name
|
||||
@origin = origin
|
||||
@x = x.to_f
|
||||
@y = y.to_f
|
||||
@zoom_x = zoom_x.to_f
|
||||
@zoom_y = zoom_y.to_f
|
||||
@opacity = opacity.to_f
|
||||
@blend_type = blend_type
|
||||
init_target
|
||||
init_tone
|
||||
init_rotate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration)
|
||||
@origin = origin
|
||||
@target_x = x.to_f
|
||||
@target_y = y.to_f
|
||||
@target_zoom_x = zoom_x.to_f
|
||||
@target_zoom_y = zoom_y.to_f
|
||||
@target_opacity = opacity.to_f
|
||||
@blend_type = blend_type
|
||||
@duration = duration
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 回転速度の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def rotate(speed)
|
||||
@rotate_speed = speed
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調変更の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_tone_change(tone, duration)
|
||||
@tone_target = tone.clone
|
||||
@tone_duration = duration
|
||||
@tone = @tone_target.clone if @tone_duration == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの消去
|
||||
#--------------------------------------------------------------------------
|
||||
def erase
|
||||
@name = ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_move
|
||||
update_tone_change
|
||||
update_rotate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャ移動の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_move
|
||||
return if @duration == 0
|
||||
d = @duration
|
||||
@x = (@x * (d - 1) + @target_x) / d
|
||||
@y = (@y * (d - 1) + @target_y) / d
|
||||
@zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
|
||||
@zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
|
||||
@opacity = (@opacity * (d - 1) + @target_opacity) / d
|
||||
@duration -= 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調変更の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_tone_change
|
||||
return if @tone_duration == 0
|
||||
d = @tone_duration
|
||||
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
|
||||
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
|
||||
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
|
||||
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
|
||||
@tone_duration -= 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 回転の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_rotate
|
||||
return if @rotate_speed == 0
|
||||
@angle += @rotate_speed / 2.0
|
||||
@angle += 360 while @angle < 0
|
||||
@angle %= 360
|
||||
end
|
||||
end
|
||||
27
Scripts/Game_Pictures.rb
Normal file
27
Scripts/Game_Pictures.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Pictures
|
||||
#------------------------------------------------------------------------------
|
||||
# ピクチャの配列のラッパーです。このクラスは Game_Screen クラスの内部で使用
|
||||
# されます。マップ画面のピクチャとバトル画面のピクチャは別々に扱われます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Pictures
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@data = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](number)
|
||||
@data[number] ||= Game_Picture.new(number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イテレータ
|
||||
#--------------------------------------------------------------------------
|
||||
def each
|
||||
@data.compact.each {|picture| yield picture } if block_given?
|
||||
end
|
||||
end
|
||||
486
Scripts/Game_Player.rb
Normal file
486
Scripts/Game_Player.rb
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Player
|
||||
#------------------------------------------------------------------------------
|
||||
# プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
|
||||
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Player < Game_Character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :followers # フォロワー(隊列メンバー)
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super
|
||||
@vehicle_type = :walk # 現在乗っている乗り物の種類
|
||||
@vehicle_getting_on = false # 乗る動作の途中フラグ
|
||||
@vehicle_getting_off = false # 降りる動作の途中フラグ
|
||||
@followers = Game_Followers.new(self)
|
||||
@transparent = $data_system.opt_transparent
|
||||
clear_transfer_info
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動情報のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_transfer_info
|
||||
@transferring = false # 場所移動フラグ
|
||||
@new_map_id = 0 # 移動先 マップ ID
|
||||
@new_x = 0 # 移動先 X 座標
|
||||
@new_y = 0 # 移動先 Y 座標
|
||||
@new_direction = 0 # 移動後の向き
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
@character_name = actor ? actor.character_name : ""
|
||||
@character_index = actor ? actor.character_index : 0
|
||||
@followers.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 対応するアクターの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def actor
|
||||
$game_party.battle_members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def stopping?
|
||||
return false if @vehicle_getting_on || @vehicle_getting_off
|
||||
return super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動の予約
|
||||
# d : 移動後の向き(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def reserve_transfer(map_id, x, y, d = 2)
|
||||
@transferring = true
|
||||
@new_map_id = map_id
|
||||
@new_x = x
|
||||
@new_y = y
|
||||
@new_direction = d
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動の予約中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def transfer?
|
||||
@transferring
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_transfer
|
||||
if transfer?
|
||||
set_direction(@new_direction)
|
||||
if @new_map_id != $game_map.map_id
|
||||
$game_map.setup(@new_map_id)
|
||||
$game_map.autoplay
|
||||
end
|
||||
moveto(@new_x, @new_y)
|
||||
clear_transfer_info
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ通行可能判定
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def map_passable?(x, y, d)
|
||||
case @vehicle_type
|
||||
when :boat
|
||||
$game_map.boat_passable?(x, y)
|
||||
when :ship
|
||||
$game_map.ship_passable?(x, y)
|
||||
when :airship
|
||||
true
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在乗っている乗り物を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def vehicle
|
||||
$game_map.vehicle(@vehicle_type)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 小型船に乗っている状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def in_boat?
|
||||
@vehicle_type == :boat
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 大型船に乗っている状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def in_ship?
|
||||
@vehicle_type == :ship
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船に乗っている状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def in_airship?
|
||||
@vehicle_type == :airship
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常歩行状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def normal_walk?
|
||||
@vehicle_type == :walk && !@move_route_forcing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダッシュ状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def dash?
|
||||
return false if @move_route_forcing
|
||||
return false if $game_map.disable_dash?
|
||||
return false if vehicle
|
||||
return Input.press?(:A)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● デバッグすり抜け状態判定
|
||||
#--------------------------------------------------------------------------
|
||||
def debug_through?
|
||||
$TEST && Input.press?(:CTRL)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 衝突判定(フォロワーを含む)
|
||||
#--------------------------------------------------------------------------
|
||||
def collide?(x, y)
|
||||
!@through && (pos?(x, y) || followers.collide?(x, y))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面中央の X 座標
|
||||
#--------------------------------------------------------------------------
|
||||
def center_x
|
||||
(Graphics.width / 32 - 1) / 2.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面中央の Y 座標
|
||||
#--------------------------------------------------------------------------
|
||||
def center_y
|
||||
(Graphics.height / 32 - 1) / 2.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面中央に来るようにマップの表示位置を設定
|
||||
#--------------------------------------------------------------------------
|
||||
def center(x, y)
|
||||
$game_map.set_display_pos(x - center_x, y - center_y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定位置に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def moveto(x, y)
|
||||
super
|
||||
center(x, y)
|
||||
make_encounter_count
|
||||
vehicle.refresh if vehicle
|
||||
@followers.synchronize(x, y, direction)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩数増加
|
||||
#--------------------------------------------------------------------------
|
||||
def increase_steps
|
||||
super
|
||||
$game_party.increase_steps if normal_walk?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント カウント作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_encounter_count
|
||||
n = $game_map.encounter_step
|
||||
@encounter_count = rand(n) + rand(n) + 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウントする敵グループの ID を作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_encounter_troop_id
|
||||
encounter_list = []
|
||||
weight_sum = 0
|
||||
$game_map.encounter_list.each do |encounter|
|
||||
next unless encounter_ok?(encounter)
|
||||
encounter_list.push(encounter)
|
||||
weight_sum += encounter.weight
|
||||
end
|
||||
if weight_sum > 0
|
||||
value = rand(weight_sum)
|
||||
encounter_list.each do |encounter|
|
||||
value -= encounter.weight
|
||||
return encounter.troop_id if value < 0
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント項目の採用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_ok?(encounter)
|
||||
return true if encounter.region_set.empty?
|
||||
return true if encounter.region_set.include?(region_id)
|
||||
return false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント処理の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter
|
||||
return false if $game_map.interpreter.running?
|
||||
return false if $game_system.encounter_disabled
|
||||
return false if @encounter_count > 0
|
||||
make_encounter_count
|
||||
troop_id = make_encounter_troop_id
|
||||
return false unless $data_troops[troop_id]
|
||||
BattleManager.setup(troop_id)
|
||||
BattleManager.on_encounter
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップイベントの起動
|
||||
# triggers : トリガーの配列
|
||||
# normal : プライオリティ[通常キャラと同じ]かそれ以外か
|
||||
#--------------------------------------------------------------------------
|
||||
def start_map_event(x, y, triggers, normal)
|
||||
$game_map.events_xy(x, y).each do |event|
|
||||
if event.trigger_in?(triggers) && event.normal_priority? == normal
|
||||
event.start
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 同位置のイベント起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_here(triggers)
|
||||
start_map_event(@x, @y, triggers, false)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 正面のイベント起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_there(triggers)
|
||||
x2 = $game_map.round_x_with_direction(@x, @direction)
|
||||
y2 = $game_map.round_y_with_direction(@y, @direction)
|
||||
start_map_event(x2, y2, triggers, true)
|
||||
return if $game_map.any_event_starting?
|
||||
return unless $game_map.counter?(x2, y2)
|
||||
x3 = $game_map.round_x_with_direction(x2, @direction)
|
||||
y3 = $game_map.round_y_with_direction(y2, @direction)
|
||||
start_map_event(x3, y3, triggers, true)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 接触イベントの起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_event_trigger_touch(x, y)
|
||||
start_map_event(x, y, [1,2], true)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 方向ボタン入力による移動処理
|
||||
#--------------------------------------------------------------------------
|
||||
def move_by_input
|
||||
return if !movable? || $game_map.interpreter.running?
|
||||
move_straight(Input.dir4) if Input.dir4 > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def movable?
|
||||
return false if moving?
|
||||
return false if @move_route_forcing || @followers.gathering?
|
||||
return false if @vehicle_getting_on || @vehicle_getting_off
|
||||
return false if $game_message.busy? || $game_message.visible
|
||||
return false if vehicle && !vehicle.movable?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
last_real_x = @real_x
|
||||
last_real_y = @real_y
|
||||
last_moving = moving?
|
||||
move_by_input
|
||||
super
|
||||
update_scroll(last_real_x, last_real_y)
|
||||
update_vehicle
|
||||
update_nonmoving(last_moving) unless moving?
|
||||
@followers.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロール処理
|
||||
#--------------------------------------------------------------------------
|
||||
def update_scroll(last_real_x, last_real_y)
|
||||
ax1 = $game_map.adjust_x(last_real_x)
|
||||
ay1 = $game_map.adjust_y(last_real_y)
|
||||
ax2 = $game_map.adjust_x(@real_x)
|
||||
ay2 = $game_map.adjust_y(@real_y)
|
||||
$game_map.scroll_down (ay2 - ay1) if ay2 > ay1 && ay2 > center_y
|
||||
$game_map.scroll_left (ax1 - ax2) if ax2 < ax1 && ax2 < center_x
|
||||
$game_map.scroll_right(ax2 - ax1) if ax2 > ax1 && ax2 > center_x
|
||||
$game_map.scroll_up (ay1 - ay2) if ay2 < ay1 && ay2 < center_y
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def update_vehicle
|
||||
return if @followers.gathering?
|
||||
return unless vehicle
|
||||
if @vehicle_getting_on
|
||||
update_vehicle_get_on
|
||||
elsif @vehicle_getting_off
|
||||
update_vehicle_get_off
|
||||
else
|
||||
vehicle.sync_with_player
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物に乗る動作の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_vehicle_get_on
|
||||
if !@followers.gathering? && !moving?
|
||||
@direction = vehicle.direction
|
||||
@move_speed = vehicle.speed
|
||||
@vehicle_getting_on = false
|
||||
@transparent = true
|
||||
@through = true if in_airship?
|
||||
vehicle.get_on
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物から降りる動作の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_vehicle_get_off
|
||||
if !@followers.gathering? && vehicle.altitude == 0
|
||||
@vehicle_getting_off = false
|
||||
@vehicle_type = :walk
|
||||
@transparent = false
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動中でない場合の処理
|
||||
# last_moving : 直前に移動中だったか
|
||||
#--------------------------------------------------------------------------
|
||||
def update_nonmoving(last_moving)
|
||||
return if $game_map.interpreter.running?
|
||||
if last_moving
|
||||
$game_party.on_player_walk
|
||||
return if check_touch_event
|
||||
end
|
||||
if movable? && Input.trigger?(:C)
|
||||
return if get_on_off_vehicle
|
||||
return if check_action_event
|
||||
end
|
||||
update_encounter if last_moving
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウントの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_encounter
|
||||
return if $TEST && Input.press?(:CTRL)
|
||||
return if $game_party.encounter_none?
|
||||
return if in_airship?
|
||||
return if @move_route_forcing
|
||||
@encounter_count -= encounter_progress_value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウント進行値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def encounter_progress_value
|
||||
value = $game_map.bush?(@x, @y) ? 2 : 1
|
||||
value *= 0.5 if $game_party.encounter_half?
|
||||
value *= 0.5 if in_ship?
|
||||
value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 接触(重なり)によるイベント起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_touch_event
|
||||
return false if in_airship?
|
||||
check_event_trigger_here([1,2])
|
||||
$game_map.setup_starting_event
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ボタンによるイベント起動判定
|
||||
#--------------------------------------------------------------------------
|
||||
def check_action_event
|
||||
return false if in_airship?
|
||||
check_event_trigger_here([0])
|
||||
return true if $game_map.setup_starting_event
|
||||
check_event_trigger_there([0,1,2])
|
||||
$game_map.setup_starting_event
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物の乗降
|
||||
#--------------------------------------------------------------------------
|
||||
def get_on_off_vehicle
|
||||
if vehicle
|
||||
get_off_vehicle
|
||||
else
|
||||
get_on_vehicle
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物に乗る
|
||||
# 現在乗り物に乗っていないことが前提。
|
||||
#--------------------------------------------------------------------------
|
||||
def get_on_vehicle
|
||||
front_x = $game_map.round_x_with_direction(@x, @direction)
|
||||
front_y = $game_map.round_y_with_direction(@y, @direction)
|
||||
@vehicle_type = :boat if $game_map.boat.pos?(front_x, front_y)
|
||||
@vehicle_type = :ship if $game_map.ship.pos?(front_x, front_y)
|
||||
@vehicle_type = :airship if $game_map.airship.pos?(@x, @y)
|
||||
if vehicle
|
||||
@vehicle_getting_on = true
|
||||
force_move_forward unless in_airship?
|
||||
@followers.gather
|
||||
end
|
||||
@vehicle_getting_on
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物から降りる
|
||||
# 現在乗り物に乗っていることが前提。
|
||||
#--------------------------------------------------------------------------
|
||||
def get_off_vehicle
|
||||
if vehicle.land_ok?(@x, @y, @direction)
|
||||
set_direction(2) if in_airship?
|
||||
@followers.synchronize(@x, @y, @direction)
|
||||
vehicle.get_off
|
||||
unless in_airship?
|
||||
force_move_forward
|
||||
@transparent = false
|
||||
end
|
||||
@vehicle_getting_off = true
|
||||
@move_speed = 4
|
||||
@through = false
|
||||
make_encounter_count
|
||||
@followers.gather
|
||||
end
|
||||
@vehicle_getting_off
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強制的に一歩前進
|
||||
#--------------------------------------------------------------------------
|
||||
def force_move_forward
|
||||
@through = true
|
||||
move_forward
|
||||
@through = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージ床判定
|
||||
#--------------------------------------------------------------------------
|
||||
def on_damage_floor?
|
||||
$game_map.damage_floor?(@x, @y) && !in_airship?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● まっすぐに移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move_straight(d, turn_ok = true)
|
||||
@followers.move if passable?(@x, @y, d)
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 斜めに移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move_diagonal(horz, vert)
|
||||
@followers.move if diagonal_passable?(@x, @y, horz, vert)
|
||||
super
|
||||
end
|
||||
end
|
||||
233
Scripts/Game_Screen.rb
Normal file
233
Scripts/Game_Screen.rb
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Screen
|
||||
#------------------------------------------------------------------------------
|
||||
# 色調変更やフラッシュなど、画面全体に関係する処理のデータを保持するクラスで
|
||||
# す。このクラスは Game_Map クラス、Game_Troop クラスの内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Screen
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :brightness # 明るさ
|
||||
attr_reader :tone # 色調
|
||||
attr_reader :flash_color # フラッシュ色
|
||||
attr_reader :pictures # ピクチャ
|
||||
attr_reader :shake # シェイク位置
|
||||
attr_reader :weather_type # 天候 タイプ
|
||||
attr_reader :weather_power # 天候 強さ (Float)
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@pictures = Game_Pictures.new
|
||||
clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
clear_fade
|
||||
clear_tone
|
||||
clear_flash
|
||||
clear_shake
|
||||
clear_weather
|
||||
clear_pictures
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードイン・アウトのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_fade
|
||||
@brightness = 255
|
||||
@fadeout_duration = 0
|
||||
@fadein_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_tone
|
||||
@tone = Tone.new
|
||||
@tone_target = Tone.new
|
||||
@tone_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フラッシュのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_flash
|
||||
@flash_color = Color.new
|
||||
@flash_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シェイクのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_shake
|
||||
@shake_power = 0
|
||||
@shake_speed = 0
|
||||
@shake_duration = 0
|
||||
@shake_direction = 1
|
||||
@shake = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_weather
|
||||
@weather_type = :none
|
||||
@weather_power = 0
|
||||
@weather_power_target = 0
|
||||
@weather_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_pictures
|
||||
@pictures.each {|picture| picture.erase }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードアウトの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_fadeout(duration)
|
||||
@fadeout_duration = duration
|
||||
@fadein_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードインの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_fadein(duration)
|
||||
@fadein_duration = duration
|
||||
@fadeout_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調変更の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_tone_change(tone, duration)
|
||||
@tone_target = tone.clone
|
||||
@tone_duration = duration
|
||||
@tone = @tone_target.clone if @tone_duration == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フラッシュの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_flash(color, duration)
|
||||
@flash_color = color.clone
|
||||
@flash_duration = duration
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シェイクの開始
|
||||
# power : 強さ
|
||||
# speed : 速さ
|
||||
#--------------------------------------------------------------------------
|
||||
def start_shake(power, speed, duration)
|
||||
@shake_power = power
|
||||
@shake_speed = speed
|
||||
@shake_duration = duration
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の変更
|
||||
# type : タイプ (:none, :rain, :storm, :snow)
|
||||
# power : 強さ
|
||||
# 雨が段階的に止むような表現を行うため、天候タイプがなし (:none) の場合
|
||||
# は例外的に @weather_power_target (強さの目標値) を 0 に設定する。
|
||||
#--------------------------------------------------------------------------
|
||||
def change_weather(type, power, duration)
|
||||
@weather_type = type if type != :none || duration == 0
|
||||
@weather_power_target = type == :none ? 0.0 : power.to_f
|
||||
@weather_duration = duration
|
||||
@weather_power = @weather_power_target if duration == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_fadeout
|
||||
update_fadein
|
||||
update_tone
|
||||
update_flash
|
||||
update_shake
|
||||
update_weather
|
||||
update_pictures
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードアウトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_fadeout
|
||||
if @fadeout_duration > 0
|
||||
d = @fadeout_duration
|
||||
@brightness = (@brightness * (d - 1)) / d
|
||||
@fadeout_duration -= 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードインの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_fadein
|
||||
if @fadein_duration > 0
|
||||
d = @fadein_duration
|
||||
@brightness = (@brightness * (d - 1) + 255) / d
|
||||
@fadein_duration -= 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_tone
|
||||
if @tone_duration > 0
|
||||
d = @tone_duration
|
||||
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
|
||||
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
|
||||
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
|
||||
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
|
||||
@tone_duration -= 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フラッシュの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_flash
|
||||
if @flash_duration > 0
|
||||
d = @flash_duration
|
||||
@flash_color.alpha = @flash_color.alpha * (d - 1) / d
|
||||
@flash_duration -= 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シェイクの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_shake
|
||||
if @shake_duration > 0 || @shake != 0
|
||||
delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
|
||||
if @shake_duration <= 1 && @shake * (@shake + delta) < 0
|
||||
@shake = 0
|
||||
else
|
||||
@shake += delta
|
||||
end
|
||||
@shake_direction = -1 if @shake > @shake_power * 2
|
||||
@shake_direction = 1 if @shake < - @shake_power * 2
|
||||
@shake_duration -= 1
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_weather
|
||||
if @weather_duration > 0
|
||||
d = @weather_duration
|
||||
@weather_power = (@weather_power * (d - 1) + @weather_power_target) / d
|
||||
@weather_duration -= 1
|
||||
if @weather_duration == 0 && @weather_power_target == 0
|
||||
@weather_type = :none
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_pictures
|
||||
@pictures.each {|picture| picture.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フラッシュの開始(毒・ダメージ床用)
|
||||
#--------------------------------------------------------------------------
|
||||
def start_flash_for_damage
|
||||
start_flash(Color.new(255,0,0,128), 8)
|
||||
end
|
||||
end
|
||||
35
Scripts/Game_SelfSwitches.rb
Normal file
35
Scripts/Game_SelfSwitches.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#==============================================================================
|
||||
# ■ Game_SelfSwitches
|
||||
#------------------------------------------------------------------------------
|
||||
# セルフスイッチを扱うクラスです。組み込みクラス Hash のラッパーです。このク
|
||||
# ラスのインスタンスは $game_self_switches で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_SelfSwitches
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@data = {}
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セルフスイッチの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](key)
|
||||
@data[key] == true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セルフスイッチの設定
|
||||
# value : ON (true) / OFF (false)
|
||||
#--------------------------------------------------------------------------
|
||||
def []=(key, value)
|
||||
@data[key] = value
|
||||
on_change
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セルフスイッチの設定時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_change
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
end
|
||||
35
Scripts/Game_Switches.rb
Normal file
35
Scripts/Game_Switches.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Switches
|
||||
#------------------------------------------------------------------------------
|
||||
# スイッチを扱うクラスです。組み込みクラス Array のラッパーです。このクラス
|
||||
# のインスタンスは $game_switches で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Switches
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@data = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スイッチの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](switch_id)
|
||||
@data[switch_id] || false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スイッチの設定
|
||||
# value : ON (true) / OFF (false)
|
||||
#--------------------------------------------------------------------------
|
||||
def []=(switch_id, value)
|
||||
@data[switch_id] = value
|
||||
on_change
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スイッチの設定時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_change
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
end
|
||||
122
Scripts/Game_System.rb
Normal file
122
Scripts/Game_System.rb
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
#==============================================================================
|
||||
# ■ Game_System
|
||||
#------------------------------------------------------------------------------
|
||||
# システム周りのデータを扱うクラスです。セーブやメニューの禁止状態などを保存
|
||||
# します。このクラスのインスタンスは $game_system で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_System
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :save_disabled # セーブ禁止
|
||||
attr_accessor :menu_disabled # メニュー禁止
|
||||
attr_accessor :encounter_disabled # エンカウント禁止
|
||||
attr_accessor :formation_disabled # 並び替え禁止
|
||||
attr_accessor :battle_count # 戦闘回数
|
||||
attr_reader :save_count # セーブ回数
|
||||
attr_reader :version_id # ゲームのバージョン ID
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@save_disabled = false
|
||||
@menu_disabled = false
|
||||
@encounter_disabled = false
|
||||
@formation_disabled = false
|
||||
@battle_count = 0
|
||||
@save_count = 0
|
||||
@version_id = 0
|
||||
@window_tone = nil
|
||||
@battle_bgm = nil
|
||||
@battle_end_me = nil
|
||||
@saved_bgm = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 日本語モード判定
|
||||
#--------------------------------------------------------------------------
|
||||
def japanese?
|
||||
$data_system.japanese
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウカラーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_tone
|
||||
@window_tone || $data_system.window_tone
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウカラーの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def window_tone=(window_tone)
|
||||
@window_tone = window_tone
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘 BGM の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_bgm
|
||||
@battle_bgm || $data_system.battle_bgm
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘 BGM の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_bgm=(battle_bgm)
|
||||
@battle_bgm = battle_bgm
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了 ME の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_end_me
|
||||
@battle_end_me || $data_system.battle_end_me
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了 ME の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_end_me=(battle_end_me)
|
||||
@battle_end_me = battle_end_me
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブ前の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_before_save
|
||||
@save_count += 1
|
||||
@version_id = $data_system.version_id
|
||||
@frames_on_save = Graphics.frame_count
|
||||
@bgm_on_save = RPG::BGM.last
|
||||
@bgs_on_save = RPG::BGS.last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロード後の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_after_load
|
||||
Graphics.frame_count = @frames_on_save
|
||||
@bgm_on_save.play
|
||||
@bgs_on_save.play
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイ時間を秒数で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def playtime
|
||||
Graphics.frame_count / Graphics.frame_rate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイ時間を文字列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def playtime_s
|
||||
hour = playtime / 60 / 60
|
||||
min = playtime / 60 % 60
|
||||
sec = playtime % 60
|
||||
sprintf("%02d:%02d:%02d", hour, min, sec)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● BGM の保存
|
||||
#--------------------------------------------------------------------------
|
||||
def save_bgm
|
||||
@saved_bgm = RPG::BGM.last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● BGM の再開
|
||||
#--------------------------------------------------------------------------
|
||||
def replay_bgm
|
||||
@saved_bgm.replay if @saved_bgm
|
||||
end
|
||||
end
|
||||
45
Scripts/Game_Temp.rb
Normal file
45
Scripts/Game_Temp.rb
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Temp
|
||||
#------------------------------------------------------------------------------
|
||||
# セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
|
||||
# スタンスは $game_temp で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Temp
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :common_event_id # コモンイベント ID
|
||||
attr_accessor :fade_type # 場所移動時のフェードタイプ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@common_event_id = 0
|
||||
@fade_type = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コモンイベントの呼び出しを予約
|
||||
#--------------------------------------------------------------------------
|
||||
def reserve_common_event(common_event_id)
|
||||
@common_event_id = common_event_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コモンイベントの呼び出し予約をクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_common_event
|
||||
@common_event_id = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コモンイベント呼び出しの予約判定
|
||||
#--------------------------------------------------------------------------
|
||||
def common_event_reserved?
|
||||
@common_event_id > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 予約されているコモンイベントを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def reserved_common_event
|
||||
$data_common_events[@common_event_id]
|
||||
end
|
||||
end
|
||||
56
Scripts/Game_Timer.rb
Normal file
56
Scripts/Game_Timer.rb
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Timer
|
||||
#------------------------------------------------------------------------------
|
||||
# タイマーを扱うクラスです。このクラスのインスタンスは $game_timer で参照さ
|
||||
# れます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Timer
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@count = 0
|
||||
@working = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
if @working && @count > 0
|
||||
@count -= 1
|
||||
on_expire if @count == 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 始動
|
||||
#--------------------------------------------------------------------------
|
||||
def start(count)
|
||||
@count = count
|
||||
@working = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 停止
|
||||
#--------------------------------------------------------------------------
|
||||
def stop
|
||||
@working = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 作動中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def working?
|
||||
@working
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 秒の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def sec
|
||||
@count / Graphics.frame_rate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマーが 0 になったときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_expire
|
||||
BattleManager.abort
|
||||
end
|
||||
end
|
||||
205
Scripts/Game_Troop.rb
Normal file
205
Scripts/Game_Troop.rb
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Troop
|
||||
#------------------------------------------------------------------------------
|
||||
# 敵グループおよび戦闘に関するデータを扱うクラスです。バトルイベントの処理も
|
||||
# 行います。このクラスのインスタンスは $game_troop で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Troop < Game_Unit
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ名の後ろにつける文字の表
|
||||
#--------------------------------------------------------------------------
|
||||
LETTER_TABLE_HALF = [' A',' B',' C',' D',' E',' F',' G',' H',' I',' J',
|
||||
' K',' L',' M',' N',' O',' P',' Q',' R',' S',' T',
|
||||
' U',' V',' W',' X',' Y',' Z']
|
||||
LETTER_TABLE_FULL = ['A','B','C','D','E','F','G','H','I','J',
|
||||
'K','L','M','N','O','P','Q','R','S','T',
|
||||
'U','V','W','X','Y','Z']
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :screen # バトル画面の状態
|
||||
attr_reader :interpreter # バトルイベント用インタプリタ
|
||||
attr_reader :event_flags # バトルイベント実行済みフラグ
|
||||
attr_reader :turn_count # ターン数
|
||||
attr_reader :name_counts # 敵キャラ名の出現数記録ハッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super
|
||||
@screen = Game_Screen.new
|
||||
@interpreter = Game_Interpreter.new
|
||||
@event_flags = {}
|
||||
clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def members
|
||||
@enemies
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
@screen.clear
|
||||
@interpreter.clear
|
||||
@event_flags.clear
|
||||
@enemies = []
|
||||
@turn_count = 0
|
||||
@names_count = {}
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵グループオブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def troop
|
||||
$data_troops[@troop_id]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup(troop_id)
|
||||
clear
|
||||
@troop_id = troop_id
|
||||
@enemies = []
|
||||
troop.members.each do |member|
|
||||
next unless $data_enemies[member.enemy_id]
|
||||
enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
|
||||
enemy.hide if member.hidden
|
||||
enemy.screen_x = member.x
|
||||
enemy.screen_y = member.y
|
||||
@enemies.push(enemy)
|
||||
end
|
||||
init_screen_tone
|
||||
make_unique_names
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面の色調を初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_screen_tone
|
||||
@screen.start_tone_change($game_map.screen.tone, 0) if $game_map
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 同名の敵キャラに ABC などの文字を付加
|
||||
#--------------------------------------------------------------------------
|
||||
def make_unique_names
|
||||
members.each do |enemy|
|
||||
next unless enemy.alive?
|
||||
next unless enemy.letter.empty?
|
||||
n = @names_count[enemy.original_name] || 0
|
||||
enemy.letter = letter_table[n % letter_table.size]
|
||||
@names_count[enemy.original_name] = n + 1
|
||||
end
|
||||
members.each do |enemy|
|
||||
n = @names_count[enemy.original_name] || 0
|
||||
enemy.plural = true if n >= 2
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ名の後ろにつける文字の表を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def letter_table
|
||||
$game_system.japanese? ? LETTER_TABLE_FULL : LETTER_TABLE_HALF
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
@screen.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ名の配列取得
|
||||
# 戦闘開始時の表示用。重複は除去する。
|
||||
#--------------------------------------------------------------------------
|
||||
def enemy_names
|
||||
names = []
|
||||
members.each do |enemy|
|
||||
next unless enemy.alive?
|
||||
next if names.include?(enemy.original_name)
|
||||
names.push(enemy.original_name)
|
||||
end
|
||||
names
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトルイベント(ページ)の条件合致判定
|
||||
#--------------------------------------------------------------------------
|
||||
def conditions_met?(page)
|
||||
c = page.condition
|
||||
if !c.turn_ending && !c.turn_valid && !c.enemy_valid &&
|
||||
!c.actor_valid && !c.switch_valid
|
||||
return false # 条件未設定…実行しない
|
||||
end
|
||||
if @event_flags[page]
|
||||
return false # 実行済み
|
||||
end
|
||||
if c.turn_ending # ターン終了時
|
||||
return false unless BattleManager.turn_end?
|
||||
end
|
||||
if c.turn_valid # ターン数
|
||||
n = @turn_count
|
||||
a = c.turn_a
|
||||
b = c.turn_b
|
||||
return false if (b == 0 && n != a)
|
||||
return false if (b > 0 && (n < 1 || n < a || n % b != a % b))
|
||||
end
|
||||
if c.enemy_valid # 敵キャラ
|
||||
enemy = $game_troop.members[c.enemy_index]
|
||||
return false if enemy == nil
|
||||
return false if enemy.hp_rate * 100 > c.enemy_hp
|
||||
end
|
||||
if c.actor_valid # アクター
|
||||
actor = $game_actors[c.actor_id]
|
||||
return false if actor == nil
|
||||
return false if actor.hp_rate * 100 > c.actor_hp
|
||||
end
|
||||
if c.switch_valid # スイッチ
|
||||
return false if !$game_switches[c.switch_id]
|
||||
end
|
||||
return true # 条件合致
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトルイベントのセットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_battle_event
|
||||
return if @interpreter.running?
|
||||
return if @interpreter.setup_reserved_common_event
|
||||
troop.pages.each do |page|
|
||||
next unless conditions_met?(page)
|
||||
@interpreter.setup(page.list)
|
||||
@event_flags[page] = true if page.span <= 1
|
||||
return
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターンの増加
|
||||
#--------------------------------------------------------------------------
|
||||
def increase_turn
|
||||
troop.pages.each {|page| @event_flags[page] = false if page.span == 1 }
|
||||
@turn_count += 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 経験値の合計計算
|
||||
#--------------------------------------------------------------------------
|
||||
def exp_total
|
||||
dead_members.inject(0) {|r, enemy| r += enemy.exp }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● お金の合計計算
|
||||
#--------------------------------------------------------------------------
|
||||
def gold_total
|
||||
dead_members.inject(0) {|r, enemy| r += enemy.gold } * gold_rate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● お金の倍率を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def gold_rate
|
||||
$game_party.gold_double? ? 2 : 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ドロップアイテムの配列作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_drop_items
|
||||
dead_members.inject([]) {|r, enemy| r += enemy.make_drop_items }
|
||||
end
|
||||
end
|
||||
131
Scripts/Game_Unit.rb
Normal file
131
Scripts/Game_Unit.rb
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Unit
|
||||
#------------------------------------------------------------------------------
|
||||
# ユニットを扱うクラスです。このクラスは Game_Party クラスと Game_Troop クラ
|
||||
# スのスーパークラスとして使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Unit
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :in_battle # 戦闘中フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@in_battle = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def members
|
||||
return []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 生存しているメンバーの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def alive_members
|
||||
members.select {|member| member.alive? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘不能のメンバーの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def dead_members
|
||||
members.select {|member| member.dead? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動可能なメンバーの配列取得
|
||||
#--------------------------------------------------------------------------
|
||||
def movable_members
|
||||
members.select {|member| member.movable? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全員の戦闘行動クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_actions
|
||||
members.each {|member| member.clear_actions }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敏捷性の平均値を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def agi
|
||||
return 1 if members.size == 0
|
||||
members.inject(0) {|r, member| r += member.agi } / members.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 狙われ率の合計を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def tgr_sum
|
||||
alive_members.inject(0) {|r, member| r + member.tgr }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターゲットのランダムな決定
|
||||
#--------------------------------------------------------------------------
|
||||
def random_target
|
||||
tgr_rand = rand * tgr_sum
|
||||
alive_members.each do |member|
|
||||
tgr_rand -= member.tgr
|
||||
return member if tgr_rand < 0
|
||||
end
|
||||
alive_members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターゲットのランダムな決定(戦闘不能)
|
||||
#--------------------------------------------------------------------------
|
||||
def random_dead_target
|
||||
dead_members.empty? ? nil : dead_members[rand(dead_members.size)]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターゲットのスムーズな決定
|
||||
#--------------------------------------------------------------------------
|
||||
def smooth_target(index)
|
||||
member = members[index]
|
||||
(member && member.alive?) ? member : alive_members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターゲットのスムーズな決定(戦闘不能)
|
||||
#--------------------------------------------------------------------------
|
||||
def smooth_dead_target(index)
|
||||
member = members[index]
|
||||
(member && member.dead?) ? member : dead_members[0]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動結果のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_results
|
||||
members.select {|member| member.result.clear }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_battle_start
|
||||
members.each {|member| member.on_battle_start }
|
||||
@in_battle = true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_battle_end
|
||||
@in_battle = false
|
||||
members.each {|member| member.on_battle_end }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_actions
|
||||
members.each {|member| member.make_actions }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全滅判定
|
||||
#--------------------------------------------------------------------------
|
||||
def all_dead?
|
||||
alive_members.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 身代わりバトラーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def substitute_battler
|
||||
members.find {|member| member.substitute? }
|
||||
end
|
||||
end
|
||||
34
Scripts/Game_Variables.rb
Normal file
34
Scripts/Game_Variables.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Variables
|
||||
#------------------------------------------------------------------------------
|
||||
# 変数を扱うクラスです。組み込みクラス Array のラッパーです。このクラスのイ
|
||||
# ンスタンスは $game_variables で参照されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Variables
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@data = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 変数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def [](variable_id)
|
||||
@data[variable_id] || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 変数の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def []=(variable_id, value)
|
||||
@data[variable_id] = value
|
||||
on_change
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 変数の設定時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_change
|
||||
$game_map.need_refresh = true
|
||||
end
|
||||
end
|
||||
193
Scripts/Game_Vehicle.rb
Normal file
193
Scripts/Game_Vehicle.rb
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
#==============================================================================
|
||||
# ■ Game_Vehicle
|
||||
#------------------------------------------------------------------------------
|
||||
# 乗り物を扱うクラスです。このクラスは Game_Map クラスの内部で使用されます。
|
||||
# 現在のマップに乗り物がないときは、マップ座標 (-1,-1) に設定されます。
|
||||
#==============================================================================
|
||||
|
||||
class Game_Vehicle < Game_Character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :altitude # 高度(飛行船用)
|
||||
attr_reader :driving # 運転中フラグ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# type : 乗り物タイプ(:boat, :ship, :airship)
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(type)
|
||||
super()
|
||||
@type = type
|
||||
@altitude = 0
|
||||
@driving = false
|
||||
@direction = 4
|
||||
@walk_anime = false
|
||||
@step_anime = false
|
||||
@walking_bgm = nil
|
||||
init_move_speed
|
||||
load_system_settings
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動速度の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_move_speed
|
||||
@move_speed = 4 if @type == :boat
|
||||
@move_speed = 5 if @type == :ship
|
||||
@move_speed = 6 if @type == :airship
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● システム設定の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def system_vehicle
|
||||
return $data_system.boat if @type == :boat
|
||||
return $data_system.ship if @type == :ship
|
||||
return $data_system.airship if @type == :airship
|
||||
return nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● システム設定のロード
|
||||
#--------------------------------------------------------------------------
|
||||
def load_system_settings
|
||||
@map_id = system_vehicle.start_map_id
|
||||
@x = system_vehicle.start_x
|
||||
@y = system_vehicle.start_y
|
||||
@character_name = system_vehicle.character_name
|
||||
@character_index = system_vehicle.character_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
if @driving
|
||||
@map_id = $game_map.map_id
|
||||
sync_with_player
|
||||
elsif @map_id == $game_map.map_id
|
||||
moveto(@x, @y)
|
||||
end
|
||||
if @type == :airship
|
||||
@priority_type = @driving ? 2 : 0
|
||||
else
|
||||
@priority_type = 1
|
||||
end
|
||||
@walk_anime = @step_anime = @driving
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の変更
|
||||
#--------------------------------------------------------------------------
|
||||
def set_location(map_id, x, y)
|
||||
@map_id = map_id
|
||||
@x = x
|
||||
@y = y
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 座標一致判定
|
||||
#--------------------------------------------------------------------------
|
||||
def pos?(x, y)
|
||||
@map_id == $game_map.map_id && super(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 透明判定
|
||||
#--------------------------------------------------------------------------
|
||||
def transparent
|
||||
@map_id != $game_map.map_id || super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物に乗る
|
||||
#--------------------------------------------------------------------------
|
||||
def get_on
|
||||
@driving = true
|
||||
@walk_anime = true
|
||||
@step_anime = true
|
||||
@walking_bgm = RPG::BGM.last
|
||||
system_vehicle.bgm.play
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗り物から降りる
|
||||
#--------------------------------------------------------------------------
|
||||
def get_off
|
||||
@driving = false
|
||||
@walk_anime = false
|
||||
@step_anime = false
|
||||
@direction = 4
|
||||
@walking_bgm.play
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーとの同期
|
||||
#--------------------------------------------------------------------------
|
||||
def sync_with_player
|
||||
@x = $game_player.x
|
||||
@y = $game_player.y
|
||||
@real_x = $game_player.real_x
|
||||
@real_y = $game_player.real_y
|
||||
@direction = $game_player.direction
|
||||
update_bush_depth
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def speed
|
||||
@move_speed
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面 Y 座標の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_y
|
||||
super - altitude
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 移動可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def movable?
|
||||
!moving? && !(@type == :airship && @altitude < max_altitude)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_airship_altitude if @type == :airship
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の高度を更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_airship_altitude
|
||||
if @driving
|
||||
@altitude += 1 if @altitude < max_altitude && takeoff_ok?
|
||||
elsif @altitude > 0
|
||||
@altitude -= 1
|
||||
@priority_type = 0 if @altitude == 0
|
||||
end
|
||||
@step_anime = (@altitude == max_altitude)
|
||||
@priority_type = 2 if @altitude > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船が飛ぶ高さを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_altitude
|
||||
return 32
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 離陸可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def takeoff_ok?
|
||||
$game_player.followers.gather?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 接岸/着陸可能判定
|
||||
# d : 方向(2,4,6,8)
|
||||
#--------------------------------------------------------------------------
|
||||
def land_ok?(x, y, d)
|
||||
if @type == :airship
|
||||
return false unless $game_map.airship_land_ok?(x, y)
|
||||
return false unless $game_map.events_xy(x, y).empty?
|
||||
else
|
||||
x2 = $game_map.round_x_with_direction(x, d)
|
||||
y2 = $game_map.round_y_with_direction(y, d)
|
||||
return false unless $game_map.valid?(x2, y2)
|
||||
return false unless $game_map.passable?(x2, y2, reverse_dir(d))
|
||||
return false if collide_with_characters?(x2, y2)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
1567
Scripts/KGC_.rb
Normal file
1567
Scripts/KGC_.rb
Normal file
File diff suppressed because it is too large
Load diff
93
Scripts/M_.rb
Normal file
93
Scripts/M_.rb
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#==============================================================================
|
||||
# ■ RGSS3 メッセージスキップ機能 Ver1.01 by 星潟
|
||||
#------------------------------------------------------------------------------
|
||||
# メッセージウィンドウに表示された文章を一気に読み飛ばします。
|
||||
# テストモード限定化機能と、特定のスイッチがONの時だけ
|
||||
# メッセージスキップを有効にする機能も併せて持っています。
|
||||
#------------------------------------------------------------------------------
|
||||
# Ver1.01 入力待ち無視(\^)が無効になる不具合を修正しました。
|
||||
#==============================================================================
|
||||
module M_SKIP
|
||||
|
||||
#メッセージスキップの効果をテストモードに限定するか?
|
||||
#trueでテストモード限定、falseで常時
|
||||
|
||||
T_LIMT = false
|
||||
|
||||
#メッセージスキップ有効化スイッチIDの設定。
|
||||
#0にするとスイッチによる判定は消滅。
|
||||
#1以上にすると、そのスイッチがONの時のみメッセージスキップ有効。
|
||||
|
||||
SWITID = 0
|
||||
|
||||
#メッセージスキップに使用するキーの設定。
|
||||
#文字送りキーとしても機能します。
|
||||
#nilにするとメッセージスキップ機能全てを無効化。
|
||||
|
||||
KEY = :A
|
||||
|
||||
end
|
||||
class Window_Message < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
alias update_mb update
|
||||
def update
|
||||
if skip_execute
|
||||
@pause_skip = true
|
||||
@show_fast = true
|
||||
end
|
||||
update_mb
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキップ判定
|
||||
#--------------------------------------------------------------------------
|
||||
def skip_execute
|
||||
if M_SKIP::T_LIMT
|
||||
unless $TEST or $BTEST
|
||||
return false
|
||||
end
|
||||
end
|
||||
if M_SKIP::SWITID != 0
|
||||
return false unless $game_switches[M_SKIP::SWITID]
|
||||
end
|
||||
return false unless Input.press?(M_SKIP::KEY)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_input
|
||||
if $game_message.choice?
|
||||
input_choice
|
||||
elsif $game_message.num_input?
|
||||
input_number
|
||||
elsif $game_message.item_choice?
|
||||
input_item
|
||||
else
|
||||
input_pause unless @pause_skip or skip_execute
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力待ち処理
|
||||
#--------------------------------------------------------------------------
|
||||
def input_pause
|
||||
self.pause = true
|
||||
wait(10)
|
||||
if M_SKIP::KEY == nil
|
||||
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
|
||||
else
|
||||
if M_SKIP::T_LIMT == true
|
||||
if $TEST or $BTEST
|
||||
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || Input.press?(M_SKIP::KEY)
|
||||
else
|
||||
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
|
||||
end
|
||||
else
|
||||
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || Input.press?(M_SKIP::KEY)
|
||||
end
|
||||
end
|
||||
Input.update
|
||||
self.pause = false
|
||||
end
|
||||
end
|
||||
7
Scripts/Main.rb
Normal file
7
Scripts/Main.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#==============================================================================
|
||||
# ■ Main
|
||||
#------------------------------------------------------------------------------
|
||||
# モジュールとクラスの定義が終わった後に実行される処理です。
|
||||
#==============================================================================
|
||||
|
||||
rgss_main { SceneManager.run }
|
||||
93
Scripts/SceneManager.rb
Normal file
93
Scripts/SceneManager.rb
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#==============================================================================
|
||||
# ■ SceneManager
|
||||
#------------------------------------------------------------------------------
|
||||
# シーン遷移を管理するモジュールです。たとえばメインメニューからアイテム画面
|
||||
# を呼び出し、また戻るというような階層構造を扱うことができます。
|
||||
#==============================================================================
|
||||
|
||||
module SceneManager
|
||||
#--------------------------------------------------------------------------
|
||||
# ● モジュールのインスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
@scene = nil # 現在のシーンオブジェクト
|
||||
@stack = [] # 階層遷移用のスタック
|
||||
@background_bitmap = nil # 背景用ビットマップ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 実行
|
||||
#--------------------------------------------------------------------------
|
||||
def self.run
|
||||
DataManager.init
|
||||
Audio.setup_midi if use_midi?
|
||||
@scene = first_scene_class.new
|
||||
@scene.main while @scene
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最初のシーンクラスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.first_scene_class
|
||||
$BTEST ? Scene_Battle : Scene_Title
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MIDI を使用するか
|
||||
#--------------------------------------------------------------------------
|
||||
def self.use_midi?
|
||||
$data_system.opt_use_midi
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のシーンを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.scene
|
||||
@scene
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のシーンクラス判定
|
||||
#--------------------------------------------------------------------------
|
||||
def self.scene_is?(scene_class)
|
||||
@scene.instance_of?(scene_class)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 直接遷移
|
||||
#--------------------------------------------------------------------------
|
||||
def self.goto(scene_class)
|
||||
@scene = scene_class.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 呼び出し
|
||||
#--------------------------------------------------------------------------
|
||||
def self.call(scene_class)
|
||||
@stack.push(@scene)
|
||||
@scene = scene_class.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 呼び出し元へ戻る
|
||||
#--------------------------------------------------------------------------
|
||||
def self.return
|
||||
@scene = @stack.pop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 呼び出しスタックのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def self.clear
|
||||
@stack.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲーム終了
|
||||
#--------------------------------------------------------------------------
|
||||
def self.exit
|
||||
@scene = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景として使うためのスナップショット作成
|
||||
#--------------------------------------------------------------------------
|
||||
def self.snapshot_for_background
|
||||
@background_bitmap.dispose if @background_bitmap
|
||||
@background_bitmap = Graphics.snap_to_bitmap
|
||||
@background_bitmap.blur
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景用ビットマップを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def self.background_bitmap
|
||||
@background_bitmap
|
||||
end
|
||||
end
|
||||
132
Scripts/Scene_Base.rb
Normal file
132
Scripts/Scene_Base.rb
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Base
|
||||
#------------------------------------------------------------------------------
|
||||
# ゲーム中の全てのシーンのスーパークラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メイン
|
||||
#--------------------------------------------------------------------------
|
||||
def main
|
||||
start
|
||||
post_start
|
||||
update until scene_changing?
|
||||
pre_terminate
|
||||
terminate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
create_main_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始後処理
|
||||
#--------------------------------------------------------------------------
|
||||
def post_start
|
||||
perform_transition
|
||||
Input.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シーン変更中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def scene_changing?
|
||||
SceneManager.scene != self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_basic
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新(基本)
|
||||
#--------------------------------------------------------------------------
|
||||
def update_basic
|
||||
Graphics.update
|
||||
Input.update
|
||||
update_all_windows
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_terminate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
Graphics.freeze
|
||||
dispose_all_windows
|
||||
dispose_main_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_transition
|
||||
Graphics.transition(transition_speed)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def transition_speed
|
||||
return 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_main_viewport
|
||||
@viewport = Viewport.new
|
||||
@viewport.z = 200
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_main_viewport
|
||||
@viewport.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_all_windows
|
||||
instance_variables.each do |varname|
|
||||
ivar = instance_variable_get(varname)
|
||||
ivar.update if ivar.is_a?(Window)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_all_windows
|
||||
instance_variables.each do |varname|
|
||||
ivar = instance_variable_get(varname)
|
||||
ivar.dispose if ivar.is_a?(Window)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 呼び出し元のシーンへ戻る
|
||||
#--------------------------------------------------------------------------
|
||||
def return_scene
|
||||
SceneManager.return
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 各種サウンドとグラフィックの一括フェードアウト
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout_all(time = 1000)
|
||||
RPG::BGM.fade(time)
|
||||
RPG::BGS.fade(time)
|
||||
RPG::ME.fade(time)
|
||||
Graphics.fadeout(time * Graphics.frame_rate / 1000)
|
||||
RPG::BGM.stop
|
||||
RPG::BGS.stop
|
||||
RPG::ME.stop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲームオーバー判定
|
||||
# パーティが全滅状態ならゲームオーバー画面へ遷移する。
|
||||
#--------------------------------------------------------------------------
|
||||
def check_gameover
|
||||
SceneManager.goto(Scene_Gameover) if $game_party.all_dead?
|
||||
end
|
||||
end
|
||||
691
Scripts/Scene_Battle.rb
Normal file
691
Scripts/Scene_Battle.rb
Normal file
|
|
@ -0,0 +1,691 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Battle
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Battle < Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_spriteset
|
||||
create_all_windows
|
||||
BattleManager.method_wait_for_message = method(:wait_for_message)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始後処理
|
||||
#--------------------------------------------------------------------------
|
||||
def post_start
|
||||
super
|
||||
battle_start
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_terminate
|
||||
super
|
||||
Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map)
|
||||
Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
dispose_spriteset
|
||||
@info_viewport.dispose
|
||||
RPG::ME.stop
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
if BattleManager.in_turn?
|
||||
process_event
|
||||
process_action
|
||||
end
|
||||
BattleManager.judge_win_loss
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新(基本)
|
||||
#--------------------------------------------------------------------------
|
||||
def update_basic
|
||||
super
|
||||
$game_timer.update
|
||||
$game_troop.update
|
||||
@spriteset.update
|
||||
update_info_viewport
|
||||
update_message_open
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新(ウェイト用)
|
||||
#--------------------------------------------------------------------------
|
||||
def update_for_wait
|
||||
update_basic
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait(duration)
|
||||
duration.times {|i| update_for_wait if i < duration / 2 || !show_fast? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 早送り判定
|
||||
#--------------------------------------------------------------------------
|
||||
def show_fast?
|
||||
Input.press?(:A) || Input.press?(:C)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト(早送り無効)
|
||||
#--------------------------------------------------------------------------
|
||||
def abs_wait(duration)
|
||||
duration.times {|i| update_for_wait }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 短時間ウェイト(早送り無効)
|
||||
#--------------------------------------------------------------------------
|
||||
def abs_wait_short
|
||||
abs_wait(10)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージ表示が終わるまでウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_message
|
||||
@message_window.update
|
||||
update_for_wait while $game_message.visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーション表示が終わるまでウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_animation
|
||||
update_for_wait
|
||||
update_for_wait while @spriteset.animation?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクト実行が終わるまでウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_effect
|
||||
update_for_wait
|
||||
update_for_wait while @spriteset.effect?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 情報表示ビューポートの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_info_viewport
|
||||
move_info_viewport(0) if @party_command_window.active
|
||||
move_info_viewport(128) if @actor_command_window.active
|
||||
move_info_viewport(64) if BattleManager.in_turn?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 情報表示ビューポートの移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move_info_viewport(ox)
|
||||
current_ox = @info_viewport.ox
|
||||
@info_viewport.ox = [ox, current_ox + 16].min if current_ox < ox
|
||||
@info_viewport.ox = [ox, current_ox - 16].max if current_ox > ox
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージウィンドウを開く処理の更新
|
||||
# ステータスウィンドウなどが閉じ終わるまでオープン度を 0 にする。
|
||||
#--------------------------------------------------------------------------
|
||||
def update_message_open
|
||||
if $game_message.busy? && !@status_window.close?
|
||||
@message_window.openness = 0
|
||||
@status_window.close
|
||||
@party_command_window.close
|
||||
@actor_command_window.close
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトセットの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_spriteset
|
||||
@spriteset = Spriteset_Battle.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトセットの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_spriteset
|
||||
@spriteset.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_all_windows
|
||||
create_message_window
|
||||
create_scroll_text_window
|
||||
create_log_window
|
||||
create_status_window
|
||||
create_info_viewport
|
||||
create_party_command_window
|
||||
create_actor_command_window
|
||||
create_help_window
|
||||
create_skill_window
|
||||
create_item_window
|
||||
create_actor_window
|
||||
create_enemy_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_message_window
|
||||
@message_window = Window_Message.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロール文章ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_scroll_text_window
|
||||
@scroll_text_window = Window_ScrollText.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ログウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_log_window
|
||||
@log_window = Window_BattleLog.new
|
||||
@log_window.method_wait = method(:wait)
|
||||
@log_window.method_wait_for_effect = method(:wait_for_effect)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_status_window
|
||||
@status_window = Window_BattleStatus.new
|
||||
@status_window.x = 128
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 情報表示ビューポートの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_info_viewport
|
||||
@info_viewport = Viewport.new
|
||||
@info_viewport.rect.y = Graphics.height - @status_window.height
|
||||
@info_viewport.rect.height = @status_window.height
|
||||
@info_viewport.z = 100
|
||||
@info_viewport.ox = 64
|
||||
@status_window.viewport = @info_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティコマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_party_command_window
|
||||
@party_command_window = Window_PartyCommand.new
|
||||
@party_command_window.viewport = @info_viewport
|
||||
@party_command_window.set_handler(:fight, method(:command_fight))
|
||||
@party_command_window.set_handler(:escape, method(:command_escape))
|
||||
@party_command_window.unselect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターコマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actor_command_window
|
||||
@actor_command_window = Window_ActorCommand.new
|
||||
@actor_command_window.viewport = @info_viewport
|
||||
@actor_command_window.set_handler(:attack, method(:command_attack))
|
||||
@actor_command_window.set_handler(:skill, method(:command_skill))
|
||||
@actor_command_window.set_handler(:guard, method(:command_guard))
|
||||
@actor_command_window.set_handler(:item, method(:command_item))
|
||||
@actor_command_window.set_handler(:cancel, method(:prior_command))
|
||||
@actor_command_window.x = Graphics.width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_help_window
|
||||
@help_window = Window_Help.new
|
||||
@help_window.visible = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_skill_window
|
||||
@skill_window = Window_BattleSkill.new(@help_window, @info_viewport)
|
||||
@skill_window.set_handler(:ok, method(:on_skill_ok))
|
||||
@skill_window.set_handler(:cancel, method(:on_skill_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_item_window
|
||||
@item_window = Window_BattleItem.new(@help_window, @info_viewport)
|
||||
@item_window.set_handler(:ok, method(:on_item_ok))
|
||||
@item_window.set_handler(:cancel, method(:on_item_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actor_window
|
||||
@actor_window = Window_BattleActor.new(@info_viewport)
|
||||
@actor_window.set_handler(:ok, method(:on_actor_ok))
|
||||
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_enemy_window
|
||||
@enemy_window = Window_BattleEnemy.new(@info_viewport)
|
||||
@enemy_window.set_handler(:ok, method(:on_enemy_ok))
|
||||
@enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの情報を更新
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh_status
|
||||
@status_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def next_command
|
||||
if BattleManager.next_command
|
||||
start_actor_command_selection
|
||||
else
|
||||
turn_start
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前のコマンド入力へ
|
||||
#--------------------------------------------------------------------------
|
||||
def prior_command
|
||||
if BattleManager.prior_command
|
||||
start_actor_command_selection
|
||||
else
|
||||
start_party_command_selection
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティコマンド選択の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_party_command_selection
|
||||
unless scene_changing?
|
||||
refresh_status
|
||||
@status_window.unselect
|
||||
@status_window.open
|
||||
if BattleManager.input_start
|
||||
@actor_command_window.close
|
||||
@party_command_window.setup
|
||||
else
|
||||
@party_command_window.deactivate
|
||||
turn_start
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[戦う]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_fight
|
||||
next_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[逃げる]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_escape
|
||||
turn_start unless BattleManager.process_escape
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターコマンド選択の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_actor_command_selection
|
||||
@status_window.select(BattleManager.actor.index)
|
||||
@party_command_window.close
|
||||
@actor_command_window.setup(BattleManager.actor)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[攻撃]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_attack
|
||||
BattleManager.actor.input.set_attack
|
||||
select_enemy_selection
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[スキル]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_skill
|
||||
@skill_window.actor = BattleManager.actor
|
||||
@skill_window.stype_id = @actor_command_window.current_ext
|
||||
@skill_window.refresh
|
||||
@skill_window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[防御]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_guard
|
||||
BattleManager.actor.input.set_guard
|
||||
next_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[アイテム]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_item
|
||||
@item_window.refresh
|
||||
@item_window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター選択の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def select_actor_selection
|
||||
@actor_window.refresh
|
||||
@actor_window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_ok
|
||||
BattleManager.actor.input.target_index = @actor_window.index
|
||||
@actor_window.hide
|
||||
@skill_window.hide
|
||||
@item_window.hide
|
||||
next_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_cancel
|
||||
@actor_window.hide
|
||||
case @actor_command_window.current_symbol
|
||||
when :skill
|
||||
@skill_window.activate
|
||||
when :item
|
||||
@item_window.activate
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ選択の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def select_enemy_selection
|
||||
@enemy_window.refresh
|
||||
@enemy_window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_enemy_ok
|
||||
BattleManager.actor.input.target_index = @enemy_window.enemy.index
|
||||
@enemy_window.hide
|
||||
@skill_window.hide
|
||||
@item_window.hide
|
||||
next_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラ[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_enemy_cancel
|
||||
@enemy_window.hide
|
||||
case @actor_command_window.current_symbol
|
||||
when :attack
|
||||
@actor_command_window.activate
|
||||
when :skill
|
||||
@skill_window.activate
|
||||
when :item
|
||||
@item_window.activate
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_skill_ok
|
||||
@skill = @skill_window.item
|
||||
BattleManager.actor.input.set_skill(@skill.id)
|
||||
BattleManager.actor.last_skill.object = @skill
|
||||
if !@skill.need_selection?
|
||||
@skill_window.hide
|
||||
next_command
|
||||
elsif @skill.for_opponent?
|
||||
select_enemy_selection
|
||||
else
|
||||
select_actor_selection
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_skill_cancel
|
||||
@skill_window.hide
|
||||
@actor_command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_ok
|
||||
@item = @item_window.item
|
||||
BattleManager.actor.input.set_item(@item.id)
|
||||
if !@item.need_selection?
|
||||
@item_window.hide
|
||||
next_command
|
||||
elsif @item.for_opponent?
|
||||
select_enemy_selection
|
||||
else
|
||||
select_actor_selection
|
||||
end
|
||||
$game_party.last_item.object = @item
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_cancel
|
||||
@item_window.hide
|
||||
@actor_command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘開始
|
||||
#--------------------------------------------------------------------------
|
||||
def battle_start
|
||||
BattleManager.battle_start
|
||||
process_event
|
||||
start_party_command_selection
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン開始
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_start
|
||||
@party_command_window.close
|
||||
@actor_command_window.close
|
||||
@status_window.unselect
|
||||
@subject = nil
|
||||
BattleManager.turn_start
|
||||
@log_window.wait
|
||||
@log_window.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ターン終了
|
||||
#--------------------------------------------------------------------------
|
||||
def turn_end
|
||||
all_battle_members.each do |battler|
|
||||
battler.on_turn_end
|
||||
refresh_status
|
||||
@log_window.display_auto_affected_status(battler)
|
||||
@log_window.wait_and_clear
|
||||
end
|
||||
BattleManager.turn_end
|
||||
process_event
|
||||
start_party_command_selection
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵味方合わせた全バトルメンバーの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def all_battle_members
|
||||
$game_party.members + $game_troop.members
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● イベントの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_event
|
||||
while !scene_changing?
|
||||
$game_troop.interpreter.update
|
||||
$game_troop.setup_battle_event
|
||||
wait_for_message
|
||||
wait_for_effect if $game_troop.all_dead?
|
||||
process_forced_action
|
||||
BattleManager.judge_win_loss
|
||||
break unless $game_troop.interpreter.running?
|
||||
update_for_wait
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 強制された戦闘行動の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_forced_action
|
||||
if BattleManager.action_forced?
|
||||
last_subject = @subject
|
||||
@subject = BattleManager.action_forced_battler
|
||||
BattleManager.clear_action_force
|
||||
process_action
|
||||
@subject = last_subject
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_action
|
||||
return if scene_changing?
|
||||
if !@subject || !@subject.current_action
|
||||
@subject = BattleManager.next_subject
|
||||
end
|
||||
return turn_end unless @subject
|
||||
if @subject.current_action
|
||||
@subject.current_action.prepare
|
||||
if @subject.current_action.valid?
|
||||
@status_window.open
|
||||
execute_action
|
||||
end
|
||||
@subject.remove_current_action
|
||||
end
|
||||
process_action_end unless @subject.current_action
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動終了時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_action_end
|
||||
@subject.on_action_end
|
||||
refresh_status
|
||||
@log_window.display_auto_affected_status(@subject)
|
||||
@log_window.wait_and_clear
|
||||
@log_window.display_current_state(@subject)
|
||||
@log_window.wait_and_clear
|
||||
BattleManager.judge_win_loss
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘行動の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def execute_action
|
||||
@subject.sprite_effect_type = :whiten
|
||||
use_item
|
||||
@log_window.wait_and_clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの使用
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item
|
||||
item = @subject.current_action.item
|
||||
@log_window.display_use_item(@subject, item)
|
||||
@subject.use_item(item)
|
||||
refresh_status
|
||||
targets = @subject.current_action.make_targets.compact
|
||||
show_animation(targets, item.animation_id)
|
||||
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの発動
|
||||
#--------------------------------------------------------------------------
|
||||
def invoke_item(target, item)
|
||||
if rand < target.item_cnt(@subject, item)
|
||||
invoke_counter_attack(target, item)
|
||||
elsif rand < target.item_mrf(@subject, item)
|
||||
invoke_magic_reflection(target, item)
|
||||
else
|
||||
apply_item_effects(apply_substitute(target, item), item)
|
||||
end
|
||||
@subject.last_target_index = target.index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテムの効果を適用
|
||||
#--------------------------------------------------------------------------
|
||||
def apply_item_effects(target, item)
|
||||
target.item_apply(@subject, item)
|
||||
refresh_status
|
||||
@log_window.display_action_results(target, item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 反撃の発動
|
||||
#--------------------------------------------------------------------------
|
||||
def invoke_counter_attack(target, item)
|
||||
@log_window.display_counter(target, item)
|
||||
attack_skill = $data_skills[target.attack_skill_id]
|
||||
@subject.item_apply(target, attack_skill)
|
||||
refresh_status
|
||||
@log_window.display_action_results(@subject, attack_skill)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 魔法反射の発動
|
||||
#--------------------------------------------------------------------------
|
||||
def invoke_magic_reflection(target, item)
|
||||
@log_window.display_reflection(target, item)
|
||||
apply_item_effects(@subject, item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 身代わりの適用
|
||||
#--------------------------------------------------------------------------
|
||||
def apply_substitute(target, item)
|
||||
if check_substitute(target, item)
|
||||
substitute = target.friends_unit.substitute_battler
|
||||
if substitute && target != substitute
|
||||
@log_window.display_substitute(substitute, target)
|
||||
return substitute
|
||||
end
|
||||
end
|
||||
target
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 身代わり条件チェック
|
||||
#--------------------------------------------------------------------------
|
||||
def check_substitute(target, item)
|
||||
target.hp < target.mhp / 4 && (!item || !item.certain?)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの表示
|
||||
# targets : 対象者の配列
|
||||
# animation_id : アニメーション ID(-1: 通常攻撃と同じ)
|
||||
#--------------------------------------------------------------------------
|
||||
def show_animation(targets, animation_id)
|
||||
if animation_id < 0
|
||||
show_attack_animation(targets)
|
||||
else
|
||||
show_normal_animation(targets, animation_id)
|
||||
end
|
||||
@log_window.wait
|
||||
wait_for_animation
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃アニメーションの表示
|
||||
# targets : 対象者の配列
|
||||
# アクターの場合は二刀流を考慮(左手武器は反転して表示)。
|
||||
# 敵キャラの場合は [敵の通常攻撃] 効果音を演奏して一瞬待つ。
|
||||
#--------------------------------------------------------------------------
|
||||
def show_attack_animation(targets)
|
||||
if @subject.actor?
|
||||
show_normal_animation(targets, @subject.atk_animation_id1, false)
|
||||
show_normal_animation(targets, @subject.atk_animation_id2, true)
|
||||
else
|
||||
Sound.play_enemy_attack
|
||||
abs_wait_short
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常アニメーションの表示
|
||||
# targets : 対象者の配列
|
||||
# animation_id : アニメーション ID
|
||||
# mirror : 左右反転
|
||||
#--------------------------------------------------------------------------
|
||||
def show_normal_animation(targets, animation_id, mirror = false)
|
||||
animation = $data_animations[animation_id]
|
||||
if animation
|
||||
targets.each do |target|
|
||||
target.animation_id = animation_id
|
||||
target.animation_mirror = mirror
|
||||
abs_wait_short unless animation.to_screen?
|
||||
end
|
||||
abs_wait_short if animation.to_screen?
|
||||
end
|
||||
end
|
||||
end
|
||||
87
Scripts/Scene_Debug.rb
Normal file
87
Scripts/Scene_Debug.rb
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Debug
|
||||
#------------------------------------------------------------------------------
|
||||
# デバッグ画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Debug < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_left_window
|
||||
create_right_window
|
||||
create_debug_help_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
#$game_map.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 左ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_left_window
|
||||
@left_window = Window_DebugLeft.new(0, 0)
|
||||
@left_window.set_handler(:ok, method(:on_left_ok))
|
||||
@left_window.set_handler(:cancel, method(:return_scene))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_right_window
|
||||
wx = @left_window.width
|
||||
ww = Graphics.width - wx
|
||||
@right_window = Window_DebugRight.new(wx, 0, ww)
|
||||
@right_window.set_handler(:cancel, method(:on_right_cancel))
|
||||
@left_window.right_window = @right_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_debug_help_window
|
||||
wx = @right_window.x
|
||||
wy = @right_window.height
|
||||
ww = @right_window.width
|
||||
wh = Graphics.height - wy
|
||||
@debug_help_window = Window_Base.new(wx, wy, ww, wh)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 左[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_left_ok
|
||||
refresh_help_window
|
||||
@right_window.activate
|
||||
@right_window.select(0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_right_cancel
|
||||
@left_window.activate
|
||||
@right_window.unselect
|
||||
@debug_help_window.contents.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウのリフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh_help_window
|
||||
@debug_help_window.draw_text_ex(4, 0, help_text)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプ文字列の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def help_text
|
||||
if @left_window.mode == :switch
|
||||
"C (Enter) : ON / OFF"
|
||||
else
|
||||
"← (Left) : -1\n" +
|
||||
"→ (Right) : +1\n" +
|
||||
"L (Pageup) : -10\n" +
|
||||
"R (Pagedown) : +10"
|
||||
end
|
||||
end
|
||||
end
|
||||
61
Scripts/Scene_End.rb
Normal file
61
Scripts/Scene_End.rb
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_End
|
||||
#------------------------------------------------------------------------------
|
||||
# ゲーム終了画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_End < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_command_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_terminate
|
||||
super
|
||||
close_command_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_background
|
||||
super
|
||||
@background_sprite.tone.set(0, 0, 0, 128)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
@command_window = Window_GameEnd.new
|
||||
@command_window.set_handler(:to_title, method(:command_to_title))
|
||||
@command_window.set_handler(:shutdown, method(:command_shutdown))
|
||||
@command_window.set_handler(:cancel, method(:return_scene))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウを閉じる
|
||||
#--------------------------------------------------------------------------
|
||||
def close_command_window
|
||||
@command_window.close
|
||||
update until @command_window.close?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[タイトルへ]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_to_title
|
||||
close_command_window
|
||||
fadeout_all
|
||||
SceneManager.goto(Scene_Title)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[シャットダウン]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_shutdown
|
||||
close_command_window
|
||||
fadeout_all
|
||||
SceneManager.exit
|
||||
end
|
||||
end
|
||||
144
Scripts/Scene_Equip.rb
Normal file
144
Scripts/Scene_Equip.rb
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Equip
|
||||
#------------------------------------------------------------------------------
|
||||
# 装備画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Equip < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_help_window
|
||||
create_status_window
|
||||
create_command_window
|
||||
create_slot_window
|
||||
create_item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_status_window
|
||||
@status_window = Window_EquipStatus.new(0, @help_window.height)
|
||||
@status_window.viewport = @viewport
|
||||
@status_window.actor = @actor
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
wx = @status_window.width
|
||||
wy = @help_window.height
|
||||
ww = Graphics.width - @status_window.width
|
||||
@command_window = Window_EquipCommand.new(wx, wy, ww)
|
||||
@command_window.viewport = @viewport
|
||||
@command_window.help_window = @help_window
|
||||
@command_window.set_handler(:equip, method(:command_equip))
|
||||
@command_window.set_handler(:optimize, method(:command_optimize))
|
||||
@command_window.set_handler(:clear, method(:command_clear))
|
||||
@command_window.set_handler(:cancel, method(:return_scene))
|
||||
@command_window.set_handler(:pagedown, method(:next_actor))
|
||||
@command_window.set_handler(:pageup, method(:prev_actor))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スロットウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_slot_window
|
||||
wx = @status_window.width
|
||||
wy = @command_window.y + @command_window.height
|
||||
ww = Graphics.width - @status_window.width
|
||||
@slot_window = Window_EquipSlot.new(wx, wy, ww)
|
||||
@slot_window.viewport = @viewport
|
||||
@slot_window.help_window = @help_window
|
||||
@slot_window.status_window = @status_window
|
||||
@slot_window.actor = @actor
|
||||
@slot_window.set_handler(:ok, method(:on_slot_ok))
|
||||
@slot_window.set_handler(:cancel, method(:on_slot_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_item_window
|
||||
wx = 0
|
||||
wy = @slot_window.y + @slot_window.height
|
||||
ww = Graphics.width
|
||||
wh = Graphics.height - wy
|
||||
@item_window = Window_EquipItem.new(wx, wy, ww, wh)
|
||||
@item_window.viewport = @viewport
|
||||
@item_window.help_window = @help_window
|
||||
@item_window.status_window = @status_window
|
||||
@item_window.actor = @actor
|
||||
@item_window.set_handler(:ok, method(:on_item_ok))
|
||||
@item_window.set_handler(:cancel, method(:on_item_cancel))
|
||||
@slot_window.item_window = @item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[装備変更]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_equip
|
||||
@slot_window.activate
|
||||
@slot_window.select(0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[最強装備]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_optimize
|
||||
Sound.play_equip
|
||||
@actor.optimize_equipments
|
||||
@status_window.refresh
|
||||
@slot_window.refresh
|
||||
@command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[全て外す]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_clear
|
||||
Sound.play_equip
|
||||
@actor.clear_equipments
|
||||
@status_window.refresh
|
||||
@slot_window.refresh
|
||||
@command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スロット[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_slot_ok
|
||||
@item_window.activate
|
||||
@item_window.select(0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スロット[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_slot_cancel
|
||||
@slot_window.unselect
|
||||
@command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_ok
|
||||
Sound.play_equip
|
||||
@actor.change_equip(@slot_window.index, @item_window.item)
|
||||
@slot_window.activate
|
||||
@slot_window.refresh
|
||||
@item_window.unselect
|
||||
@item_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_cancel
|
||||
@slot_window.activate
|
||||
@item_window.unselect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_change
|
||||
@status_window.actor = @actor
|
||||
@slot_window.actor = @actor
|
||||
@item_window.actor = @actor
|
||||
@command_window.activate
|
||||
end
|
||||
end
|
||||
203
Scripts/Scene_File.rb
Normal file
203
Scripts/Scene_File.rb
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_File
|
||||
#------------------------------------------------------------------------------
|
||||
# セーブ画面とロード画面の共通処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_File < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_help_window
|
||||
create_savefile_viewport
|
||||
create_savefile_windows
|
||||
init_selection
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
@savefile_viewport.dispose
|
||||
@savefile_windows.each {|window| window.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
@savefile_windows.each {|window| window.update }
|
||||
update_savefile_selection
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_help_window
|
||||
@help_window = Window_Help.new(1)
|
||||
@help_window.set_text(help_window_text)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウのテキストを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def help_window_text
|
||||
return ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルビューポートの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_savefile_viewport
|
||||
@savefile_viewport = Viewport.new
|
||||
@savefile_viewport.rect.y = @help_window.height
|
||||
@savefile_viewport.rect.height -= @help_window.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_savefile_windows
|
||||
@savefile_windows = Array.new(item_max) do |i|
|
||||
Window_SaveFile.new(savefile_height, i)
|
||||
end
|
||||
@savefile_windows.each {|window| window.viewport = @savefile_viewport }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択状態の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_selection
|
||||
@index = first_savefile_index
|
||||
@savefile_windows[@index].selected = true
|
||||
self.top_index = @index - visible_max / 2
|
||||
ensure_cursor_visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
DataManager.savefile_max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面内に表示するセーブファイル数を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_max
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルウィンドウの高さを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def savefile_height
|
||||
@savefile_viewport.rect.height / visible_max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最初に選択状態にするファイルインデックスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def first_savefile_index
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のインデックスの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def index
|
||||
@index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭のインデックスの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def top_index
|
||||
@savefile_viewport.oy / savefile_height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭のインデックスの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def top_index=(index)
|
||||
index = 0 if index < 0
|
||||
index = item_max - visible_max if index > item_max - visible_max
|
||||
@savefile_viewport.oy = index * savefile_height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 末尾のインデックスの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def bottom_index
|
||||
top_index + visible_max - 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 末尾のインデックスの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def bottom_index=(index)
|
||||
self.top_index = index - (visible_max - 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイル選択の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_savefile_selection
|
||||
return on_savefile_ok if Input.trigger?(:C)
|
||||
return on_savefile_cancel if Input.trigger?(:B)
|
||||
update_cursor
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイル[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_savefile_ok
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイル[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_savefile_cancel
|
||||
Sound.play_cancel
|
||||
return_scene
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_cursor
|
||||
last_index = @index
|
||||
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
|
||||
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
|
||||
cursor_pagedown if Input.trigger?(:R)
|
||||
cursor_pageup if Input.trigger?(:L)
|
||||
if @index != last_index
|
||||
Sound.play_cursor
|
||||
@savefile_windows[last_index].selected = false
|
||||
@savefile_windows[@index].selected = true
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを下に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_down(wrap)
|
||||
@index = (@index + 1) % item_max if @index < item_max - 1 || wrap
|
||||
ensure_cursor_visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを上に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_up(wrap)
|
||||
@index = (@index - 1 + item_max) % item_max if @index > 0 || wrap
|
||||
ensure_cursor_visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを 1 ページ後ろに移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_pagedown
|
||||
if top_index + visible_max < item_max
|
||||
self.top_index += visible_max
|
||||
@index = [@index + visible_max, item_max - 1].min
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを 1 ページ前に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_pageup
|
||||
if top_index > 0
|
||||
self.top_index -= visible_max
|
||||
@index = [@index - visible_max, 0].max
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソル位置が画面内になるようにスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def ensure_cursor_visible
|
||||
self.top_index = index if index < top_index
|
||||
self.bottom_index = index if index > bottom_index
|
||||
end
|
||||
end
|
||||
85
Scripts/Scene_Gameover.rb
Normal file
85
Scripts/Scene_Gameover.rb
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Gameover
|
||||
#------------------------------------------------------------------------------
|
||||
# ゲームオーバー画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Gameover < Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
play_gameover_music
|
||||
fadeout_frozen_graphics
|
||||
create_background
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
dispose_background
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
goto_title if Input.trigger?(:C)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_transition
|
||||
Graphics.transition(fadein_speed)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲームオーバー画面の音楽演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def play_gameover_music
|
||||
RPG::BGM.stop
|
||||
RPG::BGS.stop
|
||||
$data_system.gameover_me.play
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 固定済みグラフィックのフェードアウト
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout_frozen_graphics
|
||||
Graphics.transition(fadeout_speed)
|
||||
Graphics.freeze
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_background
|
||||
@sprite = Sprite.new
|
||||
@sprite.bitmap = Cache.system("GameOver")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_background
|
||||
@sprite.bitmap.dispose
|
||||
@sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードアウト速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout_speed
|
||||
return 60
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードイン速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def fadein_speed
|
||||
return 120
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル画面へ遷移
|
||||
#--------------------------------------------------------------------------
|
||||
def goto_title
|
||||
fadeout_all
|
||||
SceneManager.goto(Scene_Title)
|
||||
end
|
||||
end
|
||||
75
Scripts/Scene_Item.rb
Normal file
75
Scripts/Scene_Item.rb
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Item
|
||||
#------------------------------------------------------------------------------
|
||||
# アイテム画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Item < Scene_ItemBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_help_window
|
||||
create_category_window
|
||||
create_item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_category_window
|
||||
@category_window = Window_ItemCategory.new
|
||||
@category_window.viewport = @viewport
|
||||
@category_window.help_window = @help_window
|
||||
@category_window.y = @help_window.height
|
||||
@category_window.set_handler(:ok, method(:on_category_ok))
|
||||
@category_window.set_handler(:cancel, method(:return_scene))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_item_window
|
||||
wy = @category_window.y + @category_window.height
|
||||
wh = Graphics.height - wy
|
||||
@item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
|
||||
@item_window.viewport = @viewport
|
||||
@item_window.help_window = @help_window
|
||||
@item_window.set_handler(:ok, method(:on_item_ok))
|
||||
@item_window.set_handler(:cancel, method(:on_item_cancel))
|
||||
@category_window.item_window = @item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリ[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_category_ok
|
||||
@item_window.activate
|
||||
@item_window.select_last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_ok
|
||||
$game_party.last_item.object = item
|
||||
determine_item
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_cancel
|
||||
@item_window.unselect
|
||||
@category_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム使用時の SE 演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def play_se_for_item
|
||||
Sound.play_use_item
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item
|
||||
super
|
||||
@item_window.redraw_current_item
|
||||
end
|
||||
end
|
||||
147
Scripts/Scene_ItemBase.rb
Normal file
147
Scripts/Scene_ItemBase.rb
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_ItemBase
|
||||
#------------------------------------------------------------------------------
|
||||
# アイテム画面とスキル画面の共通処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_ItemBase < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_actor_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actor_window
|
||||
@actor_window = Window_MenuActor.new
|
||||
@actor_window.set_handler(:ok, method(:on_actor_ok))
|
||||
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在選択されているアイテムの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item
|
||||
@item_window.item
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用者を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def user
|
||||
$game_party.movable_members.max_by {|member| member.pha }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルが左列にあるかの判定
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_left?
|
||||
@item_window.index % 2 == 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● サブウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show_sub_window(window)
|
||||
width_remain = Graphics.width - window.width
|
||||
window.x = cursor_left? ? width_remain : 0
|
||||
@viewport.rect.x = @viewport.ox = cursor_left? ? 0 : window.width
|
||||
@viewport.rect.width = width_remain
|
||||
window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● サブウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide_sub_window(window)
|
||||
@viewport.rect.x = @viewport.ox = 0
|
||||
@viewport.rect.width = Graphics.width
|
||||
window.hide.deactivate
|
||||
activate_item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_ok
|
||||
if item_usable?
|
||||
use_item
|
||||
else
|
||||
Sound.play_buzzer
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_cancel
|
||||
hide_sub_window(@actor_window)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの決定
|
||||
#--------------------------------------------------------------------------
|
||||
def determine_item
|
||||
if item.for_friend?
|
||||
show_sub_window(@actor_window)
|
||||
@actor_window.select_for_item(item)
|
||||
else
|
||||
use_item
|
||||
activate_item_window
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウのアクティブ化
|
||||
#--------------------------------------------------------------------------
|
||||
def activate_item_window
|
||||
@item_window.refresh
|
||||
@item_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用対象となるアクターを配列で取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_target_actors
|
||||
if !item.for_friend?
|
||||
[]
|
||||
elsif item.for_all?
|
||||
$game_party.members
|
||||
else
|
||||
[$game_party.members[@actor_window.index]]
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_usable?
|
||||
user.usable?(item) && item_effects_valid?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの効果が有効かを判定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_effects_valid?
|
||||
item_target_actors.any? do |target|
|
||||
target.item_test(user, item)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムをアクターに対して使用
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item_to_actors
|
||||
item_target_actors.each do |target|
|
||||
item.repeats.times { target.item_apply(user, item) }
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item
|
||||
play_se_for_item
|
||||
user.use_item(item)
|
||||
use_item_to_actors
|
||||
check_common_event
|
||||
check_gameover
|
||||
@actor_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コモンイベント予約判定
|
||||
# イベントの呼び出しが予約されているならマップ画面へ遷移する。
|
||||
#--------------------------------------------------------------------------
|
||||
def check_common_event
|
||||
SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
|
||||
end
|
||||
end
|
||||
40
Scripts/Scene_Load.rb
Normal file
40
Scripts/Scene_Load.rb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Load
|
||||
#------------------------------------------------------------------------------
|
||||
# ロード画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Load < Scene_File
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウのテキストを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def help_window_text
|
||||
Vocab::LoadMessage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最初に選択状態にするファイルインデックスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def first_savefile_index
|
||||
DataManager.latest_savefile_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの決定
|
||||
#--------------------------------------------------------------------------
|
||||
def on_savefile_ok
|
||||
super
|
||||
if DataManager.load_game(@index)
|
||||
on_load_success
|
||||
else
|
||||
Sound.play_buzzer
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ロード成功時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_load_success
|
||||
Sound.play_load
|
||||
fadeout_all
|
||||
$game_system.on_after_load
|
||||
SceneManager.goto(Scene_Map)
|
||||
end
|
||||
end
|
||||
275
Scripts/Scene_Map.rb
Normal file
275
Scripts/Scene_Map.rb
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Map
|
||||
#------------------------------------------------------------------------------
|
||||
# マップ画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Map < Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
SceneManager.clear
|
||||
$game_player.straighten
|
||||
$game_map.refresh
|
||||
$game_message.visible = false
|
||||
create_spriteset
|
||||
create_all_windows
|
||||
@menu_calling = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション実行
|
||||
# 戦闘後やロード直後など、画面が暗転しているときはフェードインを行う。
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_transition
|
||||
if Graphics.brightness == 0
|
||||
Graphics.transition(0)
|
||||
fadein(fadein_speed)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def transition_speed
|
||||
return 15
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_terminate
|
||||
super
|
||||
pre_battle_scene if SceneManager.scene_is?(Scene_Battle)
|
||||
pre_title_scene if SceneManager.scene_is?(Scene_Title)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
SceneManager.snapshot_for_background
|
||||
dispose_spriteset
|
||||
perform_battle_transition if SceneManager.scene_is?(Scene_Battle)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
$game_map.update(true)
|
||||
$game_player.update
|
||||
$game_timer.update
|
||||
@spriteset.update
|
||||
update_scene if scene_change_ok?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シーン遷移の可能判定
|
||||
#--------------------------------------------------------------------------
|
||||
def scene_change_ok?
|
||||
!$game_message.busy? && !$game_message.visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シーン遷移に関連する更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_scene
|
||||
check_gameover
|
||||
update_transfer_player unless scene_changing?
|
||||
update_encounter unless scene_changing?
|
||||
update_call_menu unless scene_changing?
|
||||
update_call_debug unless scene_changing?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新(フェード用)
|
||||
#--------------------------------------------------------------------------
|
||||
def update_for_fade
|
||||
update_basic
|
||||
$game_map.update(false)
|
||||
@spriteset.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 汎用フェード処理
|
||||
#--------------------------------------------------------------------------
|
||||
def fade_loop(duration)
|
||||
duration.times do |i|
|
||||
yield 255 * (i + 1) / duration
|
||||
update_for_fade
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面のフェードイン
|
||||
#--------------------------------------------------------------------------
|
||||
def fadein(duration)
|
||||
fade_loop(duration) {|v| Graphics.brightness = v }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面のフェードアウト
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout(duration)
|
||||
fade_loop(duration) {|v| Graphics.brightness = 255 - v }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面のフェードイン(白)
|
||||
#--------------------------------------------------------------------------
|
||||
def white_fadein(duration)
|
||||
fade_loop(duration) {|v| @viewport.color.set(255, 255, 255, 255 - v) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面のフェードアウト(白)
|
||||
#--------------------------------------------------------------------------
|
||||
def white_fadeout(duration)
|
||||
fade_loop(duration) {|v| @viewport.color.set(255, 255, 255, v) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトセットの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_spriteset
|
||||
@spriteset = Spriteset_Map.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトセットの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_spriteset
|
||||
@spriteset.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_all_windows
|
||||
create_message_window
|
||||
create_scroll_text_window
|
||||
create_location_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_message_window
|
||||
@message_window = Window_Message.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スクロール文章ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_scroll_text_window
|
||||
@scroll_text_window = Window_ScrollText.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ名ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_location_window
|
||||
@map_name_window = Window_MapName.new
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_transfer_player
|
||||
perform_transfer if $game_player.transfer?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エンカウントの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_encounter
|
||||
SceneManager.call(Scene_Battle) if $game_player.encounter
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャンセルボタンによるメニュー呼び出し判定
|
||||
#--------------------------------------------------------------------------
|
||||
def update_call_menu
|
||||
if $game_system.menu_disabled || $game_map.interpreter.running?
|
||||
@menu_calling = false
|
||||
else
|
||||
@menu_calling ||= Input.trigger?(:B)
|
||||
call_menu if @menu_calling && !$game_player.moving?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メニュー画面の呼び出し
|
||||
#--------------------------------------------------------------------------
|
||||
def call_menu
|
||||
Sound.play_ok
|
||||
SceneManager.call(Scene_Menu)
|
||||
Window_MenuCommand::init_command_position
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● F9 キーによるデバッグ呼び出し判定
|
||||
#--------------------------------------------------------------------------
|
||||
def update_call_debug
|
||||
SceneManager.call(Scene_Debug) if $TEST && Input.press?(:F9)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_transfer
|
||||
pre_transfer
|
||||
$game_player.perform_transfer
|
||||
post_transfer
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動前の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_transfer
|
||||
@map_name_window.close
|
||||
case $game_temp.fade_type
|
||||
when 0
|
||||
fadeout(fadeout_speed)
|
||||
when 1
|
||||
white_fadeout(fadeout_speed)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 場所移動後の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def post_transfer
|
||||
case $game_temp.fade_type
|
||||
when 0
|
||||
Graphics.wait(fadein_speed / 2)
|
||||
fadein(fadein_speed)
|
||||
when 1
|
||||
Graphics.wait(fadein_speed / 2)
|
||||
white_fadein(fadein_speed)
|
||||
end
|
||||
@map_name_window.open
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● バトル画面遷移の前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_battle_scene
|
||||
Graphics.update
|
||||
Graphics.freeze
|
||||
@spriteset.dispose_characters
|
||||
BattleManager.save_bgm_and_bgs
|
||||
BattleManager.play_battle_bgm
|
||||
Sound.play_battle_start
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル画面遷移の前処理
|
||||
#--------------------------------------------------------------------------
|
||||
def pre_title_scene
|
||||
fadeout(fadeout_speed_to_title)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘前トランジション実行
|
||||
#--------------------------------------------------------------------------
|
||||
def perform_battle_transition
|
||||
Graphics.transition(60, "Graphics/System/BattleStart", 100)
|
||||
Graphics.freeze
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードアウト速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout_speed
|
||||
return 30
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードイン速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def fadein_speed
|
||||
return 30
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル画面遷移用フェードアウト速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def fadeout_speed_to_title
|
||||
return 60
|
||||
end
|
||||
end
|
||||
127
Scripts/Scene_Menu.rb
Normal file
127
Scripts/Scene_Menu.rb
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Menu
|
||||
#------------------------------------------------------------------------------
|
||||
# メニュー画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Menu < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_command_window
|
||||
create_gold_window
|
||||
create_status_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
@command_window = Window_MenuCommand.new
|
||||
@command_window.set_handler(:item, method(:command_item))
|
||||
@command_window.set_handler(:skill, method(:command_personal))
|
||||
@command_window.set_handler(:equip, method(:command_personal))
|
||||
@command_window.set_handler(:status, method(:command_personal))
|
||||
@command_window.set_handler(:formation, method(:command_formation))
|
||||
@command_window.set_handler(:save, method(:command_save))
|
||||
@command_window.set_handler(:game_end, method(:command_game_end))
|
||||
@command_window.set_handler(:cancel, method(:return_scene))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゴールドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_gold_window
|
||||
@gold_window = Window_Gold.new
|
||||
@gold_window.x = 0
|
||||
@gold_window.y = Graphics.height - @gold_window.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_status_window
|
||||
@status_window = Window_MenuStatus.new(@command_window.width, 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[アイテム]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_item
|
||||
SceneManager.call(Scene_Item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[スキル][装備][ステータス]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_personal
|
||||
@status_window.select_last
|
||||
@status_window.activate
|
||||
@status_window.set_handler(:ok, method(:on_personal_ok))
|
||||
@status_window.set_handler(:cancel, method(:on_personal_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[並び替え]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_formation
|
||||
@status_window.select_last
|
||||
@status_window.activate
|
||||
@status_window.set_handler(:ok, method(:on_formation_ok))
|
||||
@status_window.set_handler(:cancel, method(:on_formation_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[セーブ]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_save
|
||||
SceneManager.call(Scene_Save)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[ゲーム終了]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_game_end
|
||||
SceneManager.call(Scene_End)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個人コマンド[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_personal_ok
|
||||
case @command_window.current_symbol
|
||||
when :skill
|
||||
SceneManager.call(Scene_Skill)
|
||||
when :equip
|
||||
SceneManager.call(Scene_Equip)
|
||||
when :status
|
||||
SceneManager.call(Scene_Status)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個人コマンド[終了]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_personal_cancel
|
||||
@status_window.unselect
|
||||
@command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 並び替え[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_formation_ok
|
||||
if @status_window.pending_index >= 0
|
||||
$game_party.swap_order(@status_window.index,
|
||||
@status_window.pending_index)
|
||||
@status_window.pending_index = -1
|
||||
@status_window.redraw_item(@status_window.index)
|
||||
else
|
||||
@status_window.pending_index = @status_window.index
|
||||
end
|
||||
@status_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 並び替え[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_formation_cancel
|
||||
if @status_window.pending_index >= 0
|
||||
@status_window.pending_index = -1
|
||||
@status_window.activate
|
||||
else
|
||||
@status_window.unselect
|
||||
@command_window.activate
|
||||
end
|
||||
end
|
||||
end
|
||||
63
Scripts/Scene_MenuBase.rb
Normal file
63
Scripts/Scene_MenuBase.rb
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_MenuBase
|
||||
#------------------------------------------------------------------------------
|
||||
# メニュー画面系の基本処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_MenuBase < Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_background
|
||||
@actor = $game_party.menu_actor
|
||||
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 create_help_window
|
||||
@help_window = Window_Help.new
|
||||
@help_window.viewport = @viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 次のアクターに切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def next_actor
|
||||
@actor = $game_party.menu_actor_next
|
||||
on_actor_change
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前のアクターに切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def prev_actor
|
||||
@actor = $game_party.menu_actor_prev
|
||||
on_actor_change
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_change
|
||||
end
|
||||
end
|
||||
32
Scripts/Scene_Name.rb
Normal file
32
Scripts/Scene_Name.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Name
|
||||
#------------------------------------------------------------------------------
|
||||
# 名前入力画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Name < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 準備
|
||||
#--------------------------------------------------------------------------
|
||||
def prepare(actor_id, max_char)
|
||||
@actor_id = actor_id
|
||||
@max_char = max_char
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
@actor = $game_actors[@actor_id]
|
||||
@edit_window = Window_NameEdit.new(@actor, @max_char)
|
||||
@input_window = Window_NameInput.new(@edit_window)
|
||||
@input_window.set_handler(:ok, method(:on_input_ok))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_input_ok
|
||||
@actor.name = @edit_window.name
|
||||
return_scene
|
||||
end
|
||||
end
|
||||
38
Scripts/Scene_Save.rb
Normal file
38
Scripts/Scene_Save.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Save
|
||||
#------------------------------------------------------------------------------
|
||||
# セーブ画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Save < Scene_File
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプウィンドウのテキストを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def help_window_text
|
||||
Vocab::SaveMessage
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最初に選択状態にするファイルインデックスを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def first_savefile_index
|
||||
DataManager.last_savefile_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブファイルの決定
|
||||
#--------------------------------------------------------------------------
|
||||
def on_savefile_ok
|
||||
super
|
||||
if DataManager.save_game(@index)
|
||||
on_save_success
|
||||
else
|
||||
Sound.play_buzzer
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブ成功時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_save_success
|
||||
Sound.play_save
|
||||
return_scene
|
||||
end
|
||||
end
|
||||
299
Scripts/Scene_Shop.rb
Normal file
299
Scripts/Scene_Shop.rb
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Shop
|
||||
#------------------------------------------------------------------------------
|
||||
# ショップ画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Shop < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 準備
|
||||
#--------------------------------------------------------------------------
|
||||
def prepare(goods, purchase_only)
|
||||
@goods = goods
|
||||
@purchase_only = purchase_only
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_help_window
|
||||
create_gold_window
|
||||
create_command_window
|
||||
create_dummy_window
|
||||
create_number_window
|
||||
create_status_window
|
||||
create_buy_window
|
||||
create_category_window
|
||||
create_sell_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゴールドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_gold_window
|
||||
@gold_window = Window_Gold.new
|
||||
@gold_window.viewport = @viewport
|
||||
@gold_window.x = Graphics.width - @gold_window.width
|
||||
@gold_window.y = @help_window.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
@command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
|
||||
@command_window.viewport = @viewport
|
||||
@command_window.y = @help_window.height
|
||||
@command_window.set_handler(:buy, method(:command_buy))
|
||||
@command_window.set_handler(:sell, method(:command_sell))
|
||||
@command_window.set_handler(:cancel, method(:return_scene))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダミーウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_dummy_window
|
||||
wy = @command_window.y + @command_window.height
|
||||
wh = Graphics.height - wy
|
||||
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
|
||||
@dummy_window.viewport = @viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個数入力ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_number_window
|
||||
wy = @dummy_window.y
|
||||
wh = @dummy_window.height
|
||||
@number_window = Window_ShopNumber.new(0, wy, wh)
|
||||
@number_window.viewport = @viewport
|
||||
@number_window.hide
|
||||
@number_window.set_handler(:ok, method(:on_number_ok))
|
||||
@number_window.set_handler(:cancel, method(:on_number_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_status_window
|
||||
wx = @number_window.width
|
||||
wy = @dummy_window.y
|
||||
ww = Graphics.width - wx
|
||||
wh = @dummy_window.height
|
||||
@status_window = Window_ShopStatus.new(wx, wy, ww, wh)
|
||||
@status_window.viewport = @viewport
|
||||
@status_window.hide
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 購入ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_buy_window
|
||||
wy = @dummy_window.y
|
||||
wh = @dummy_window.height
|
||||
@buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
|
||||
@buy_window.viewport = @viewport
|
||||
@buy_window.help_window = @help_window
|
||||
@buy_window.status_window = @status_window
|
||||
@buy_window.hide
|
||||
@buy_window.set_handler(:ok, method(:on_buy_ok))
|
||||
@buy_window.set_handler(:cancel, method(:on_buy_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_category_window
|
||||
@category_window = Window_ItemCategory.new
|
||||
@category_window.viewport = @viewport
|
||||
@category_window.help_window = @help_window
|
||||
@category_window.y = @dummy_window.y
|
||||
@category_window.hide.deactivate
|
||||
@category_window.set_handler(:ok, method(:on_category_ok))
|
||||
@category_window.set_handler(:cancel, method(:on_category_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売却ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_sell_window
|
||||
wy = @category_window.y + @category_window.height
|
||||
wh = Graphics.height - wy
|
||||
@sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
|
||||
@sell_window.viewport = @viewport
|
||||
@sell_window.help_window = @help_window
|
||||
@sell_window.hide
|
||||
@sell_window.set_handler(:ok, method(:on_sell_ok))
|
||||
@sell_window.set_handler(:cancel, method(:on_sell_cancel))
|
||||
@category_window.item_window = @sell_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 購入ウィンドウのアクティブ化
|
||||
#--------------------------------------------------------------------------
|
||||
def activate_buy_window
|
||||
@buy_window.money = money
|
||||
@buy_window.show.activate
|
||||
@status_window.show
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売却ウィンドウのアクティブ化
|
||||
#--------------------------------------------------------------------------
|
||||
def activate_sell_window
|
||||
@category_window.show
|
||||
@sell_window.refresh
|
||||
@sell_window.show.activate
|
||||
@status_window.hide
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[購入する]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_buy
|
||||
@dummy_window.hide
|
||||
activate_buy_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[売却する]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_sell
|
||||
@dummy_window.hide
|
||||
@category_window.show.activate
|
||||
@sell_window.show
|
||||
@sell_window.unselect
|
||||
@sell_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 購入[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_buy_ok
|
||||
@item = @buy_window.item
|
||||
@buy_window.hide
|
||||
@number_window.set(@item, max_buy, buying_price, currency_unit)
|
||||
@number_window.show.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 購入[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_buy_cancel
|
||||
@command_window.activate
|
||||
@dummy_window.show
|
||||
@buy_window.hide
|
||||
@status_window.hide
|
||||
@status_window.item = nil
|
||||
@help_window.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリ[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_category_ok
|
||||
activate_sell_window
|
||||
@sell_window.select(0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリ[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_category_cancel
|
||||
@command_window.activate
|
||||
@dummy_window.show
|
||||
@category_window.hide
|
||||
@sell_window.hide
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売却[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_sell_ok
|
||||
@item = @sell_window.item
|
||||
@status_window.item = @item
|
||||
@category_window.hide
|
||||
@sell_window.hide
|
||||
@number_window.set(@item, max_sell, selling_price, currency_unit)
|
||||
@number_window.show.activate
|
||||
@status_window.show
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売却[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_sell_cancel
|
||||
@sell_window.unselect
|
||||
@category_window.activate
|
||||
@status_window.item = nil
|
||||
@help_window.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個数入力[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_number_ok
|
||||
Sound.play_shop
|
||||
case @command_window.current_symbol
|
||||
when :buy
|
||||
do_buy(@number_window.number)
|
||||
when :sell
|
||||
do_sell(@number_window.number)
|
||||
end
|
||||
end_number_input
|
||||
@gold_window.refresh
|
||||
@status_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個数入力[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_number_cancel
|
||||
Sound.play_cancel
|
||||
end_number_input
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 購入の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def do_buy(number)
|
||||
$game_party.lose_gold(number * buying_price)
|
||||
$game_party.gain_item(@item, number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売却の実行
|
||||
#--------------------------------------------------------------------------
|
||||
def do_sell(number)
|
||||
$game_party.gain_gold(number * selling_price)
|
||||
$game_party.lose_item(@item, number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 個数入力の終了
|
||||
#--------------------------------------------------------------------------
|
||||
def end_number_input
|
||||
@number_window.hide
|
||||
case @command_window.current_symbol
|
||||
when :buy
|
||||
activate_buy_window
|
||||
when :sell
|
||||
activate_sell_window
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最大購入可能個数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_buy
|
||||
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
|
||||
buying_price == 0 ? max : [max, money / buying_price].min
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最大売却可能個数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_sell
|
||||
$game_party.item_number(@item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 所持金の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def money
|
||||
@gold_window.value
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通貨単位の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def currency_unit
|
||||
@gold_window.currency_unit
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 買値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def buying_price
|
||||
@buy_window.price(@item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 売値の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def selling_price
|
||||
@item.price / 2
|
||||
end
|
||||
end
|
||||
108
Scripts/Scene_Skill.rb
Normal file
108
Scripts/Scene_Skill.rb
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Skill
|
||||
#------------------------------------------------------------------------------
|
||||
# スキル画面の処理を行うクラスです。処理共通化の便宜上、スキルも「アイテム」
|
||||
# として扱っています。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Skill < Scene_ItemBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
create_help_window
|
||||
create_command_window
|
||||
create_status_window
|
||||
create_item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
wy = @help_window.height
|
||||
@command_window = Window_SkillCommand.new(0, wy)
|
||||
@command_window.viewport = @viewport
|
||||
@command_window.help_window = @help_window
|
||||
@command_window.actor = @actor
|
||||
@command_window.set_handler(:skill, method(:command_skill))
|
||||
@command_window.set_handler(:cancel, method(:return_scene))
|
||||
@command_window.set_handler(:pagedown, method(:next_actor))
|
||||
@command_window.set_handler(:pageup, method(:prev_actor))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_status_window
|
||||
y = @help_window.height
|
||||
@status_window = Window_SkillStatus.new(@command_window.width, y)
|
||||
@status_window.viewport = @viewport
|
||||
@status_window.actor = @actor
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_item_window
|
||||
wx = 0
|
||||
wy = @status_window.y + @status_window.height
|
||||
ww = Graphics.width
|
||||
wh = Graphics.height - wy
|
||||
@item_window = Window_SkillList.new(wx, wy, ww, wh)
|
||||
@item_window.actor = @actor
|
||||
@item_window.viewport = @viewport
|
||||
@item_window.help_window = @help_window
|
||||
@item_window.set_handler(:ok, method(:on_item_ok))
|
||||
@item_window.set_handler(:cancel, method(:on_item_cancel))
|
||||
@command_window.skill_window = @item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルの使用者を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def user
|
||||
@actor
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[スキル]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_skill
|
||||
@item_window.activate
|
||||
@item_window.select_last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[決定]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_ok
|
||||
@actor.last_skill.object = item
|
||||
determine_item
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム[キャンセル]
|
||||
#--------------------------------------------------------------------------
|
||||
def on_item_cancel
|
||||
@item_window.unselect
|
||||
@command_window.activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム使用時の SE 演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def play_se_for_item
|
||||
Sound.play_use_skill
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの使用
|
||||
#--------------------------------------------------------------------------
|
||||
def use_item
|
||||
super
|
||||
@status_window.refresh
|
||||
@item_window.refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_change
|
||||
@command_window.actor = @actor
|
||||
@status_window.actor = @actor
|
||||
@item_window.actor = @actor
|
||||
@command_window.activate
|
||||
end
|
||||
end
|
||||
25
Scripts/Scene_Status.rb
Normal file
25
Scripts/Scene_Status.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Status
|
||||
#------------------------------------------------------------------------------
|
||||
# ステータス画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Status < Scene_MenuBase
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
@status_window = Window_Status.new(@actor)
|
||||
@status_window.set_handler(:cancel, method(:return_scene))
|
||||
@status_window.set_handler(:pagedown, method(:next_actor))
|
||||
@status_window.set_handler(:pageup, method(:prev_actor))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの切り替え
|
||||
#--------------------------------------------------------------------------
|
||||
def on_actor_change
|
||||
@status_window.actor = @actor
|
||||
@status_window.activate
|
||||
end
|
||||
end
|
||||
137
Scripts/Scene_Title.rb
Normal file
137
Scripts/Scene_Title.rb
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
#==============================================================================
|
||||
# ■ Scene_Title
|
||||
#------------------------------------------------------------------------------
|
||||
# タイトル画面の処理を行うクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Title < Scene_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開始処理
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
super
|
||||
SceneManager.clear
|
||||
Graphics.freeze
|
||||
create_background
|
||||
create_foreground
|
||||
create_command_window
|
||||
play_title_music
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● トランジション速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def transition_speed
|
||||
return 20
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 終了処理
|
||||
#--------------------------------------------------------------------------
|
||||
def terminate
|
||||
super
|
||||
SceneManager.snapshot_for_background
|
||||
dispose_background
|
||||
dispose_foreground
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_background
|
||||
@sprite1 = Sprite.new
|
||||
@sprite1.bitmap = Cache.title1($data_system.title1_name)
|
||||
@sprite2 = Sprite.new
|
||||
@sprite2.bitmap = Cache.title2($data_system.title2_name)
|
||||
center_sprite(@sprite1)
|
||||
center_sprite(@sprite2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前景の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_foreground
|
||||
@foreground_sprite = Sprite.new
|
||||
@foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
||||
@foreground_sprite.z = 100
|
||||
draw_game_title if $data_system.opt_draw_title
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲームタイトルの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_game_title
|
||||
@foreground_sprite.bitmap.font.size = 48
|
||||
rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)
|
||||
@foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_background
|
||||
@sprite1.bitmap.dispose
|
||||
@sprite1.dispose
|
||||
@sprite2.bitmap.dispose
|
||||
@sprite2.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前景の解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_foreground
|
||||
@foreground_sprite.bitmap.dispose
|
||||
@foreground_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトを画面中央に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def center_sprite(sprite)
|
||||
sprite.ox = sprite.bitmap.width / 2
|
||||
sprite.oy = sprite.bitmap.height / 2
|
||||
sprite.x = Graphics.width / 2
|
||||
sprite.y = Graphics.height / 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_command_window
|
||||
@command_window = Window_TitleCommand.new
|
||||
@command_window.set_handler(:new_game, method(:command_new_game))
|
||||
@command_window.set_handler(:continue, method(:command_continue))
|
||||
@command_window.set_handler(:shutdown, method(:command_shutdown))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドウィンドウを閉じる
|
||||
#--------------------------------------------------------------------------
|
||||
def close_command_window
|
||||
@command_window.close
|
||||
update until @command_window.close?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[ニューゲーム]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_new_game
|
||||
DataManager.setup_new_game
|
||||
close_command_window
|
||||
fadeout_all
|
||||
$game_map.autoplay
|
||||
SceneManager.goto(Scene_Map)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[コンティニュー]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_continue
|
||||
close_command_window
|
||||
SceneManager.call(Scene_Load)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド[シャットダウン]
|
||||
#--------------------------------------------------------------------------
|
||||
def command_shutdown
|
||||
close_command_window
|
||||
fadeout_all
|
||||
SceneManager.exit
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイトル画面の音楽演奏
|
||||
#--------------------------------------------------------------------------
|
||||
def play_title_music
|
||||
$data_system.title_bgm.play
|
||||
RPG::BGS.stop
|
||||
RPG::ME.stop
|
||||
end
|
||||
end
|
||||
135
Scripts/Sound.rb
Normal file
135
Scripts/Sound.rb
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#==============================================================================
|
||||
# ■ Sound
|
||||
#------------------------------------------------------------------------------
|
||||
# 効果音を演奏するモジュールです。グローバル変数 $data_system からデータベー
|
||||
# スで設定された SE の内容を取得し、演奏します。
|
||||
#==============================================================================
|
||||
|
||||
module Sound
|
||||
|
||||
# システム効果音
|
||||
def self.play_system_sound(n)
|
||||
$data_system.sounds[n].play
|
||||
end
|
||||
|
||||
# カーソル移動
|
||||
def self.play_cursor
|
||||
play_system_sound(0)
|
||||
end
|
||||
|
||||
# 決定
|
||||
def self.play_ok
|
||||
play_system_sound(1)
|
||||
end
|
||||
|
||||
# キャンセル
|
||||
def self.play_cancel
|
||||
play_system_sound(2)
|
||||
end
|
||||
|
||||
# ブザー
|
||||
def self.play_buzzer
|
||||
play_system_sound(3)
|
||||
end
|
||||
|
||||
# 装備
|
||||
def self.play_equip
|
||||
play_system_sound(4)
|
||||
end
|
||||
|
||||
# セーブ
|
||||
def self.play_save
|
||||
play_system_sound(5)
|
||||
end
|
||||
|
||||
# ロード
|
||||
def self.play_load
|
||||
play_system_sound(6)
|
||||
end
|
||||
|
||||
# 戦闘開始
|
||||
def self.play_battle_start
|
||||
play_system_sound(7)
|
||||
end
|
||||
|
||||
# 逃走
|
||||
def self.play_escape
|
||||
play_system_sound(8)
|
||||
end
|
||||
|
||||
# 敵の通常攻撃
|
||||
def self.play_enemy_attack
|
||||
play_system_sound(9)
|
||||
end
|
||||
|
||||
# 敵ダメージ
|
||||
def self.play_enemy_damage
|
||||
play_system_sound(10)
|
||||
end
|
||||
|
||||
# 敵消滅
|
||||
def self.play_enemy_collapse
|
||||
play_system_sound(11)
|
||||
end
|
||||
|
||||
# ボス消滅 1
|
||||
def self.play_boss_collapse1
|
||||
play_system_sound(12)
|
||||
end
|
||||
|
||||
# ボス消滅 2
|
||||
def self.play_boss_collapse2
|
||||
play_system_sound(13)
|
||||
end
|
||||
|
||||
# 味方ダメージ
|
||||
def self.play_actor_damage
|
||||
play_system_sound(14)
|
||||
end
|
||||
|
||||
# 味方戦闘不能
|
||||
def self.play_actor_collapse
|
||||
play_system_sound(15)
|
||||
end
|
||||
|
||||
# 回復
|
||||
def self.play_recovery
|
||||
play_system_sound(16)
|
||||
end
|
||||
|
||||
# ミス
|
||||
def self.play_miss
|
||||
play_system_sound(17)
|
||||
end
|
||||
|
||||
# 攻撃回避
|
||||
def self.play_evasion
|
||||
play_system_sound(18)
|
||||
end
|
||||
|
||||
# 魔法回避
|
||||
def self.play_magic_evasion
|
||||
play_system_sound(19)
|
||||
end
|
||||
|
||||
# 魔法反射
|
||||
def self.play_reflection
|
||||
play_system_sound(20)
|
||||
end
|
||||
|
||||
# ショップ
|
||||
def self.play_shop
|
||||
play_system_sound(21)
|
||||
end
|
||||
|
||||
# アイテム使用
|
||||
def self.play_use_item
|
||||
play_system_sound(22)
|
||||
end
|
||||
|
||||
# スキル使用
|
||||
def self.play_use_skill
|
||||
play_system_sound(23)
|
||||
end
|
||||
|
||||
end
|
||||
232
Scripts/Sprite_Base.rb
Normal file
232
Scripts/Sprite_Base.rb
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
#==============================================================================
|
||||
# ■ Sprite_Base
|
||||
#------------------------------------------------------------------------------
|
||||
# アニメーションの表示処理を追加したスプライトのクラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Base < Sprite
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クラス変数
|
||||
#--------------------------------------------------------------------------
|
||||
@@ani_checker = []
|
||||
@@ani_spr_checker = []
|
||||
@@_reference_count = {}
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport = nil)
|
||||
super(viewport)
|
||||
@use_sprite = true # スプライト使用フラグ
|
||||
@ani_duration = 0 # アニメーションの残り時間
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
super
|
||||
dispose_animation
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_animation
|
||||
@@ani_checker.clear
|
||||
@@ani_spr_checker.clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーション表示中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def animation?
|
||||
@animation != nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_animation(animation, mirror = false)
|
||||
dispose_animation
|
||||
@animation = animation
|
||||
if @animation
|
||||
@ani_mirror = mirror
|
||||
set_animation_rate
|
||||
@ani_duration = @animation.frame_max * @ani_rate + 1
|
||||
load_animation_bitmap
|
||||
make_animation_sprites
|
||||
set_animation_origin
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの速度を設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_animation_rate
|
||||
@ani_rate = 4 # デフォルトでは固定値
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーション グラフィックの読み込み
|
||||
#--------------------------------------------------------------------------
|
||||
def load_animation_bitmap
|
||||
animation1_name = @animation.animation1_name
|
||||
animation1_hue = @animation.animation1_hue
|
||||
animation2_name = @animation.animation2_name
|
||||
animation2_hue = @animation.animation2_hue
|
||||
@ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
|
||||
@ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
|
||||
if @@_reference_count.include?(@ani_bitmap1)
|
||||
@@_reference_count[@ani_bitmap1] += 1
|
||||
else
|
||||
@@_reference_count[@ani_bitmap1] = 1
|
||||
end
|
||||
if @@_reference_count.include?(@ani_bitmap2)
|
||||
@@_reference_count[@ani_bitmap2] += 1
|
||||
else
|
||||
@@_reference_count[@ani_bitmap2] = 1
|
||||
end
|
||||
Graphics.frame_reset
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションスプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_animation_sprites
|
||||
@ani_sprites = []
|
||||
if @use_sprite && !@@ani_spr_checker.include?(@animation)
|
||||
16.times do
|
||||
sprite = ::Sprite.new(viewport)
|
||||
sprite.visible = false
|
||||
@ani_sprites.push(sprite)
|
||||
end
|
||||
if @animation.position == 3
|
||||
@@ani_spr_checker.push(@animation)
|
||||
end
|
||||
end
|
||||
@ani_duplicated = @@ani_checker.include?(@animation)
|
||||
if !@ani_duplicated && @animation.position == 3
|
||||
@@ani_checker.push(@animation)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの原点設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_animation_origin
|
||||
if @animation.position == 3
|
||||
if viewport == nil
|
||||
@ani_ox = Graphics.width / 2
|
||||
@ani_oy = Graphics.height / 2
|
||||
else
|
||||
@ani_ox = viewport.rect.width / 2
|
||||
@ani_oy = viewport.rect.height / 2
|
||||
end
|
||||
else
|
||||
@ani_ox = x - ox + width / 2
|
||||
@ani_oy = y - oy + height / 2
|
||||
if @animation.position == 0
|
||||
@ani_oy -= height / 2
|
||||
elsif @animation.position == 2
|
||||
@ani_oy += height / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_animation
|
||||
if @ani_bitmap1
|
||||
@@_reference_count[@ani_bitmap1] -= 1
|
||||
if @@_reference_count[@ani_bitmap1] == 0
|
||||
@ani_bitmap1.dispose
|
||||
end
|
||||
end
|
||||
if @ani_bitmap2
|
||||
@@_reference_count[@ani_bitmap2] -= 1
|
||||
if @@_reference_count[@ani_bitmap2] == 0
|
||||
@ani_bitmap2.dispose
|
||||
end
|
||||
end
|
||||
if @ani_sprites
|
||||
@ani_sprites.each {|sprite| sprite.dispose }
|
||||
@ani_sprites = nil
|
||||
@animation = nil
|
||||
end
|
||||
@ani_bitmap1 = nil
|
||||
@ani_bitmap2 = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_animation
|
||||
return unless animation?
|
||||
@ani_duration -= 1
|
||||
if @ani_duration % @ani_rate == 0
|
||||
if @ani_duration > 0
|
||||
frame_index = @animation.frame_max
|
||||
frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate
|
||||
animation_set_sprites(@animation.frames[frame_index])
|
||||
@animation.timings.each do |timing|
|
||||
animation_process_timing(timing) if timing.frame == frame_index
|
||||
end
|
||||
else
|
||||
end_animation
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの終了
|
||||
#--------------------------------------------------------------------------
|
||||
def end_animation
|
||||
dispose_animation
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションスプライトの設定
|
||||
# frame : フレームデータ(RPG::Animation::Frame)
|
||||
#--------------------------------------------------------------------------
|
||||
def animation_set_sprites(frame)
|
||||
cell_data = frame.cell_data
|
||||
@ani_sprites.each_with_index do |sprite, i|
|
||||
next unless sprite
|
||||
pattern = cell_data[i, 0]
|
||||
if !pattern || pattern < 0
|
||||
sprite.visible = false
|
||||
next
|
||||
end
|
||||
sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
|
||||
sprite.visible = true
|
||||
sprite.src_rect.set(pattern % 5 * 192,
|
||||
pattern % 100 / 5 * 192, 192, 192)
|
||||
if @ani_mirror
|
||||
sprite.x = @ani_ox - cell_data[i, 1]
|
||||
sprite.y = @ani_oy + cell_data[i, 2]
|
||||
sprite.angle = (360 - cell_data[i, 4])
|
||||
sprite.mirror = (cell_data[i, 5] == 0)
|
||||
else
|
||||
sprite.x = @ani_ox + cell_data[i, 1]
|
||||
sprite.y = @ani_oy + cell_data[i, 2]
|
||||
sprite.angle = cell_data[i, 4]
|
||||
sprite.mirror = (cell_data[i, 5] == 1)
|
||||
end
|
||||
sprite.z = self.z + 300 + i
|
||||
sprite.ox = 96
|
||||
sprite.oy = 96
|
||||
sprite.zoom_x = cell_data[i, 3] / 100.0
|
||||
sprite.zoom_y = cell_data[i, 3] / 100.0
|
||||
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
|
||||
sprite.blend_type = cell_data[i, 7]
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● SE とフラッシュのタイミング処理
|
||||
# timing : タイミングデータ(RPG::Animation::Timing)
|
||||
#--------------------------------------------------------------------------
|
||||
def animation_process_timing(timing)
|
||||
timing.se.play unless @ani_duplicated
|
||||
case timing.flash_scope
|
||||
when 1
|
||||
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
|
||||
when 2
|
||||
if viewport && !@ani_duplicated
|
||||
viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)
|
||||
end
|
||||
when 3
|
||||
self.flash(nil, timing.flash_duration * @ani_rate)
|
||||
end
|
||||
end
|
||||
end
|
||||
231
Scripts/Sprite_Battler.rb
Normal file
231
Scripts/Sprite_Battler.rb
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
#==============================================================================
|
||||
# ■ Sprite_Battler
|
||||
#------------------------------------------------------------------------------
|
||||
# バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
|
||||
# スプライトの状態を自動的に変化させます。
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Battler < Sprite_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :battler
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport, battler = nil)
|
||||
super(viewport)
|
||||
@battler = battler
|
||||
@battler_visible = false
|
||||
@effect_type = nil
|
||||
@effect_duration = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
bitmap.dispose if bitmap
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
if @battler
|
||||
@use_sprite = @battler.use_sprite?
|
||||
if @use_sprite
|
||||
update_bitmap
|
||||
update_origin
|
||||
update_position
|
||||
end
|
||||
setup_new_effect
|
||||
setup_new_animation
|
||||
update_effect
|
||||
else
|
||||
self.bitmap = nil
|
||||
@effect_type = nil
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元ビットマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_bitmap
|
||||
new_bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue)
|
||||
if bitmap != new_bitmap
|
||||
self.bitmap = new_bitmap
|
||||
init_visibility
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 可視状態の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_visibility
|
||||
@battler_visible = @battler.alive?
|
||||
self.opacity = 0 unless @battler_visible
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 原点の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_origin
|
||||
if bitmap
|
||||
self.ox = bitmap.width / 2
|
||||
self.oy = bitmap.height
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_position
|
||||
self.x = @battler.screen_x
|
||||
self.y = @battler.screen_y
|
||||
self.z = @battler.screen_z
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 新しいエフェクトの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_new_effect
|
||||
if !@battler_visible && @battler.alive?
|
||||
start_effect(:appear)
|
||||
elsif @battler_visible && @battler.hidden?
|
||||
start_effect(:disappear)
|
||||
end
|
||||
if @battler_visible && @battler.sprite_effect_type
|
||||
start_effect(@battler.sprite_effect_type)
|
||||
@battler.sprite_effect_type = nil
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクトの開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_effect(effect_type)
|
||||
@effect_type = effect_type
|
||||
case @effect_type
|
||||
when :appear
|
||||
@effect_duration = 16
|
||||
@battler_visible = true
|
||||
when :disappear
|
||||
@effect_duration = 32
|
||||
@battler_visible = false
|
||||
when :whiten
|
||||
@effect_duration = 16
|
||||
@battler_visible = true
|
||||
when :blink
|
||||
@effect_duration = 20
|
||||
@battler_visible = true
|
||||
when :collapse
|
||||
@effect_duration = 48
|
||||
@battler_visible = false
|
||||
when :boss_collapse
|
||||
@effect_duration = bitmap.height
|
||||
@battler_visible = false
|
||||
when :instant_collapse
|
||||
@effect_duration = 16
|
||||
@battler_visible = false
|
||||
end
|
||||
revert_to_normal
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常の設定に戻す
|
||||
#--------------------------------------------------------------------------
|
||||
def revert_to_normal
|
||||
self.blend_type = 0
|
||||
self.color.set(0, 0, 0, 0)
|
||||
self.opacity = 255
|
||||
self.ox = bitmap.width / 2 if bitmap
|
||||
self.src_rect.y = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 新しいアニメーションの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_new_animation
|
||||
if @battler.animation_id > 0
|
||||
animation = $data_animations[@battler.animation_id]
|
||||
mirror = @battler.animation_mirror
|
||||
start_animation(animation, mirror)
|
||||
@battler.animation_id = 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクト実行中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def effect?
|
||||
@effect_type != nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_effect
|
||||
if @effect_duration > 0
|
||||
@effect_duration -= 1
|
||||
case @effect_type
|
||||
when :whiten
|
||||
update_whiten
|
||||
when :blink
|
||||
update_blink
|
||||
when :appear
|
||||
update_appear
|
||||
when :disappear
|
||||
update_disappear
|
||||
when :collapse
|
||||
update_collapse
|
||||
when :boss_collapse
|
||||
update_boss_collapse
|
||||
when :instant_collapse
|
||||
update_instant_collapse
|
||||
end
|
||||
@effect_type = nil if @effect_duration == 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 白フラッシュエフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_whiten
|
||||
self.color.set(255, 255, 255, 0)
|
||||
self.color.alpha = 128 - (16 - @effect_duration) * 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 点滅エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_blink
|
||||
self.opacity = (@effect_duration % 10 < 5) ? 255 : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 出現エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_appear
|
||||
self.opacity = (16 - @effect_duration) * 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 消滅エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_disappear
|
||||
self.opacity = 256 - (32 - @effect_duration) * 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 崩壊エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_collapse
|
||||
self.blend_type = 1
|
||||
self.color.set(255, 128, 128, 128)
|
||||
self.opacity = 256 - (48 - @effect_duration) * 6
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ボス崩壊エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_boss_collapse
|
||||
alpha = @effect_duration * 120 / bitmap.height
|
||||
self.ox = bitmap.width / 2 + @effect_duration % 2 * 4 - 2
|
||||
self.blend_type = 1
|
||||
self.color.set(255, 255, 255, 255 - alpha)
|
||||
self.opacity = alpha
|
||||
self.src_rect.y -= 1
|
||||
Sound.play_boss_collapse2 if @effect_duration % 20 == 19
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 瞬間崩壊エフェクトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_instant_collapse
|
||||
self.opacity = 0
|
||||
end
|
||||
end
|
||||
212
Scripts/Sprite_Character.rb
Normal file
212
Scripts/Sprite_Character.rb
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
#==============================================================================
|
||||
# ■ Sprite_Character
|
||||
#------------------------------------------------------------------------------
|
||||
# キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを
|
||||
# 監視し、スプライトの状態を自動的に変化させます。
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Character < Sprite_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# character : Game_Character
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport, character = nil)
|
||||
super(viewport)
|
||||
@character = character
|
||||
@balloon_duration = 0
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
end_animation
|
||||
end_balloon
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_bitmap
|
||||
update_src_rect
|
||||
update_position
|
||||
update_other
|
||||
update_balloon
|
||||
setup_new_effect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定されたタイルが含まれるタイルセット画像の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tileset_bitmap(tile_id)
|
||||
Cache.tileset($game_map.tileset.tileset_names[5 + tile_id / 256])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元ビットマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_bitmap
|
||||
if graphic_changed?
|
||||
@tile_id = @character.tile_id
|
||||
@character_name = @character.character_name
|
||||
@character_index = @character.character_index
|
||||
if @tile_id > 0
|
||||
set_tile_bitmap
|
||||
else
|
||||
set_character_bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● グラフィックの変更判定
|
||||
#--------------------------------------------------------------------------
|
||||
def graphic_changed?
|
||||
@tile_id != @character.tile_id ||
|
||||
@character_name != @character.character_name ||
|
||||
@character_index != @character.character_index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルのビットマップを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_tile_bitmap
|
||||
sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
|
||||
sy = @tile_id % 256 / 8 % 16 * 32;
|
||||
self.bitmap = tileset_bitmap(@tile_id)
|
||||
self.src_rect.set(sx, sy, 32, 32)
|
||||
self.ox = 16
|
||||
self.oy = 32
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターのビットマップを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_character_bitmap
|
||||
self.bitmap = Cache.character(@character_name)
|
||||
sign = @character_name[/^[\!\$]./]
|
||||
if sign && sign.include?('$')
|
||||
@cw = bitmap.width / 3
|
||||
@ch = bitmap.height / 4
|
||||
else
|
||||
@cw = bitmap.width / 12
|
||||
@ch = bitmap.height / 8
|
||||
end
|
||||
self.ox = @cw / 2
|
||||
self.oy = @ch
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元矩形の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_src_rect
|
||||
if @tile_id == 0
|
||||
index = @character.character_index
|
||||
pattern = @character.pattern < 3 ? @character.pattern : 1
|
||||
sx = (index % 4 * 3 + pattern) * @cw
|
||||
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
|
||||
self.src_rect.set(sx, sy, @cw, @ch)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_position
|
||||
self.x = @character.screen_x
|
||||
self.y = @character.screen_y
|
||||
self.z = @character.screen_z
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● その他の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_other
|
||||
self.opacity = @character.opacity
|
||||
self.blend_type = @character.blend_type
|
||||
self.bush_depth = @character.bush_depth
|
||||
self.visible = !@character.transparent
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 新しいエフェクトの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_new_effect
|
||||
if !animation? && @character.animation_id > 0
|
||||
animation = $data_animations[@character.animation_id]
|
||||
start_animation(animation)
|
||||
end
|
||||
if !@balloon_sprite && @character.balloon_id > 0
|
||||
@balloon_id = @character.balloon_id
|
||||
start_balloon
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの終了
|
||||
#--------------------------------------------------------------------------
|
||||
def end_animation
|
||||
super
|
||||
@character.animation_id = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコン表示の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start_balloon
|
||||
dispose_balloon
|
||||
@balloon_duration = 8 * balloon_speed + balloon_wait
|
||||
@balloon_sprite = ::Sprite.new(viewport)
|
||||
@balloon_sprite.bitmap = Cache.system("Balloon")
|
||||
@balloon_sprite.ox = 16
|
||||
@balloon_sprite.oy = 32
|
||||
update_balloon
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコンの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_balloon
|
||||
if @balloon_sprite
|
||||
@balloon_sprite.dispose
|
||||
@balloon_sprite = nil
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコンの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_balloon
|
||||
if @balloon_duration > 0
|
||||
@balloon_duration -= 1
|
||||
if @balloon_duration > 0
|
||||
@balloon_sprite.x = x
|
||||
@balloon_sprite.y = y - height
|
||||
@balloon_sprite.z = z + 200
|
||||
sx = balloon_frame_index * 32
|
||||
sy = (@balloon_id - 1) * 32
|
||||
@balloon_sprite.src_rect.set(sx, sy, 32, 32)
|
||||
else
|
||||
end_balloon
|
||||
end
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコンの終了
|
||||
#--------------------------------------------------------------------------
|
||||
def end_balloon
|
||||
dispose_balloon
|
||||
@character.balloon_id = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコンの表示速度
|
||||
#--------------------------------------------------------------------------
|
||||
def balloon_speed
|
||||
return 8
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシ最終フレームのウェイト時間
|
||||
#--------------------------------------------------------------------------
|
||||
def balloon_wait
|
||||
return 12
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フキダシアイコンのフレーム番号
|
||||
#--------------------------------------------------------------------------
|
||||
def balloon_frame_index
|
||||
return 7 - [(@balloon_duration - balloon_wait) / balloon_speed, 0].max
|
||||
end
|
||||
end
|
||||
78
Scripts/Sprite_Picture.rb
Normal file
78
Scripts/Sprite_Picture.rb
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#==============================================================================
|
||||
# ■ Sprite_Picture
|
||||
#------------------------------------------------------------------------------
|
||||
# ピクチャ表示用のスプライトです。Game_Picture クラスのインスタンスを監視し、
|
||||
# スプライトの状態を自動的に変化させます。
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Picture < Sprite
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# picture : Game_Picture
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport, picture)
|
||||
super(viewport)
|
||||
@picture = picture
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
bitmap.dispose if bitmap
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_bitmap
|
||||
update_origin
|
||||
update_position
|
||||
update_zoom
|
||||
update_other
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元ビットマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_bitmap
|
||||
self.bitmap = Cache.picture(@picture.name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 原点の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_origin
|
||||
if @picture.origin == 0
|
||||
self.ox = 0
|
||||
self.oy = 0
|
||||
else
|
||||
self.ox = bitmap.width / 2
|
||||
self.oy = bitmap.height / 2
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_position
|
||||
self.x = @picture.x
|
||||
self.y = @picture.y
|
||||
self.z = @picture.number
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 拡大率の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_zoom
|
||||
self.zoom_x = @picture.zoom_x / 100.0
|
||||
self.zoom_y = @picture.zoom_y / 100.0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● その他の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_other
|
||||
self.opacity = @picture.opacity
|
||||
self.blend_type = @picture.blend_type
|
||||
self.angle = @picture.angle
|
||||
self.tone.set(@picture.tone)
|
||||
end
|
||||
end
|
||||
77
Scripts/Sprite_Timer.rb
Normal file
77
Scripts/Sprite_Timer.rb
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#==============================================================================
|
||||
# ■ Sprite_Timer
|
||||
#------------------------------------------------------------------------------
|
||||
# タイマー表示用のスプライトです。$game_timer を監視し、スプライトの状態を
|
||||
# 自動的に変化させます。
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Timer < Sprite
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport)
|
||||
super(viewport)
|
||||
create_bitmap
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
self.bitmap.dispose
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビットマップの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_bitmap
|
||||
self.bitmap = Bitmap.new(96, 48)
|
||||
self.bitmap.font.size = 32
|
||||
self.bitmap.font.color.set(255, 255, 255)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_bitmap
|
||||
update_position
|
||||
update_visibility
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元ビットマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_bitmap
|
||||
if $game_timer.sec != @total_sec
|
||||
@total_sec = $game_timer.sec
|
||||
redraw
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 再描画
|
||||
#--------------------------------------------------------------------------
|
||||
def redraw
|
||||
self.bitmap.clear
|
||||
self.bitmap.draw_text(self.bitmap.rect, timer_text, 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 描画用テキストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def timer_text
|
||||
sprintf("%02d:%02d", @total_sec / 60, @total_sec % 60)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_position
|
||||
self.x = Graphics.width - self.bitmap.width
|
||||
self.y = 0
|
||||
self.z = 200
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 可視状態の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_visibility
|
||||
self.visible = $game_timer.working?
|
||||
end
|
||||
end
|
||||
388
Scripts/Spriteset_Battle.rb
Normal file
388
Scripts/Spriteset_Battle.rb
Normal file
|
|
@ -0,0 +1,388 @@
|
|||
#==============================================================================
|
||||
# ■ Spriteset_Battle
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
|
||||
# スの内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Spriteset_Battle
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
create_viewports
|
||||
create_battleback1
|
||||
create_battleback2
|
||||
create_enemies
|
||||
create_actors
|
||||
create_pictures
|
||||
create_timer
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_viewports
|
||||
@viewport1 = Viewport.new
|
||||
@viewport2 = Viewport.new
|
||||
@viewport3 = Viewport.new
|
||||
@viewport2.z = 50
|
||||
@viewport3.z = 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)スプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_battleback1
|
||||
@back1_sprite = Sprite.new(@viewport1)
|
||||
@back1_sprite.bitmap = battleback1_bitmap
|
||||
@back1_sprite.z = 0
|
||||
center_sprite(@back1_sprite)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)スプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_battleback2
|
||||
@back2_sprite = Sprite.new(@viewport1)
|
||||
@back2_sprite.bitmap = battleback2_bitmap
|
||||
@back2_sprite.z = 1
|
||||
center_sprite(@back2_sprite)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)ビットマップの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battleback1_bitmap
|
||||
if battleback1_name
|
||||
Cache.battleback1(battleback1_name)
|
||||
else
|
||||
create_blurry_background_bitmap
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)ビットマップの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battleback2_bitmap
|
||||
if battleback2_name
|
||||
Cache.battleback2(battleback2_name)
|
||||
else
|
||||
Bitmap.new(1, 1)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップ画面を加工した戦闘背景用ビットマップの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_blurry_background_bitmap
|
||||
source = SceneManager.background_bitmap
|
||||
bitmap = Bitmap.new(640, 480)
|
||||
bitmap.stretch_blt(bitmap.rect, source, source.rect)
|
||||
bitmap.radial_blur(120, 16)
|
||||
bitmap
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battleback1_name
|
||||
if $BTEST
|
||||
$data_system.battleback1_name
|
||||
elsif $game_map.battleback1_name
|
||||
$game_map.battleback1_name
|
||||
elsif $game_map.overworld?
|
||||
overworld_battleback1_name
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battleback2_name
|
||||
if $BTEST
|
||||
$data_system.battleback2_name
|
||||
elsif $game_map.battleback2_name
|
||||
$game_map.battleback2_name
|
||||
elsif $game_map.overworld?
|
||||
overworld_battleback2_name
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フィールド 戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def overworld_battleback1_name
|
||||
$game_player.vehicle ? ship_battleback1_name : normal_battleback1_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フィールド 戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def overworld_battleback2_name
|
||||
$game_player.vehicle ? ship_battleback2_name : normal_battleback2_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常時 戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def normal_battleback1_name
|
||||
terrain_battleback1_name(autotile_type(1)) ||
|
||||
terrain_battleback1_name(autotile_type(0)) ||
|
||||
default_battleback1_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常時 戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def normal_battleback2_name
|
||||
terrain_battleback2_name(autotile_type(1)) ||
|
||||
terrain_battleback2_name(autotile_type(0)) ||
|
||||
default_battleback2_name
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 地形に対応する戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def terrain_battleback1_name(type)
|
||||
case type
|
||||
when 24,25 # 荒れ地
|
||||
"Wasteland"
|
||||
when 26,27 # 土肌
|
||||
"DirtField"
|
||||
when 32,33 # 砂漠
|
||||
"Desert"
|
||||
when 34 # 岩地
|
||||
"Lava1"
|
||||
when 35 # 岩地(溶岩)
|
||||
"Lava2"
|
||||
when 40,41 # 雪原
|
||||
"Snowfield"
|
||||
when 42 # 雲
|
||||
"Clouds"
|
||||
when 4,5 # 毒の沼
|
||||
"PoisonSwamp"
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 地形に対応する戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def terrain_battleback2_name(type)
|
||||
case type
|
||||
when 20,21 # 森
|
||||
"Forest1"
|
||||
when 22,30,38 # 低い山
|
||||
"Cliff"
|
||||
when 24,25,26,27 # 荒れ地、土肌
|
||||
"Wasteland"
|
||||
when 32,33 # 砂漠
|
||||
"Desert"
|
||||
when 34,35 # 岩地
|
||||
"Lava"
|
||||
when 40,41 # 雪原
|
||||
"Snowfield"
|
||||
when 42 # 雲
|
||||
"Clouds"
|
||||
when 4,5 # 毒の沼
|
||||
"PoisonSwamp"
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● デフォルト 戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def default_battleback1_name
|
||||
"Grassland"
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● デフォルト 戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def default_battleback2_name
|
||||
"Grassland"
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗船時 戦闘背景(床)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def ship_battleback1_name
|
||||
"Ship"
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 乗船時 戦闘背景(壁)ファイル名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def ship_battleback2_name
|
||||
"Ship"
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● プレイヤーの足元にあるオートタイルの種類を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def autotile_type(z)
|
||||
$game_map.autotile_type($game_player.x, $game_player.y, z)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトを画面中央に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def center_sprite(sprite)
|
||||
sprite.ox = sprite.bitmap.width / 2
|
||||
sprite.oy = sprite.bitmap.height / 2
|
||||
sprite.x = Graphics.width / 2
|
||||
sprite.y = Graphics.height / 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラスプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_enemies
|
||||
@enemy_sprites = $game_troop.members.reverse.collect do |enemy|
|
||||
Sprite_Battler.new(@viewport1, enemy)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクタースプライトの作成
|
||||
# デフォルトではアクター側の画像は表示しないが、便宜上、敵と味方を同じ
|
||||
# ように扱うためにダミーのスプライトを作成する。
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actors
|
||||
@actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの作成
|
||||
# 初期状態では空の配列だけ作っておき、必要になった時点で追加する。
|
||||
#--------------------------------------------------------------------------
|
||||
def create_pictures
|
||||
@picture_sprites = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_timer
|
||||
@timer_sprite = Sprite_Timer.new(@viewport2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
dispose_battleback1
|
||||
dispose_battleback2
|
||||
dispose_enemies
|
||||
dispose_actors
|
||||
dispose_pictures
|
||||
dispose_timer
|
||||
dispose_viewports
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)スプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_battleback1
|
||||
@back1_sprite.bitmap.dispose
|
||||
@back1_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)スプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_battleback2
|
||||
@back2_sprite.bitmap.dispose
|
||||
@back2_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラスプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_enemies
|
||||
@enemy_sprites.each {|sprite| sprite.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクタースプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_actors
|
||||
@actor_sprites.each {|sprite| sprite.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_pictures
|
||||
@picture_sprites.compact.each {|sprite| sprite.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_timer
|
||||
@timer_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_viewports
|
||||
@viewport1.dispose
|
||||
@viewport2.dispose
|
||||
@viewport3.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_battleback1
|
||||
update_battleback2
|
||||
update_enemies
|
||||
update_actors
|
||||
update_pictures
|
||||
update_timer
|
||||
update_viewports
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(床)スプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_battleback1
|
||||
@back1_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 戦闘背景(壁)スプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_battleback2
|
||||
@back2_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラスプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_enemies
|
||||
@enemy_sprites.each {|sprite| sprite.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクタースプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_actors
|
||||
@actor_sprites.each_with_index do |sprite, i|
|
||||
sprite.battler = $game_party.members[i]
|
||||
sprite.update
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_pictures
|
||||
$game_troop.screen.pictures.each do |pic|
|
||||
@picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic)
|
||||
@picture_sprites[pic.number].update
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_timer
|
||||
@timer_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_viewports
|
||||
@viewport1.tone.set($game_troop.screen.tone)
|
||||
@viewport1.ox = $game_troop.screen.shake
|
||||
@viewport2.color.set($game_troop.screen.flash_color)
|
||||
@viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
|
||||
@viewport1.update
|
||||
@viewport2.update
|
||||
@viewport3.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラとアクターのスプライトを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def battler_sprites
|
||||
@enemy_sprites + @actor_sprites
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーション表示中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def animation?
|
||||
battler_sprites.any? {|sprite| sprite.animation? }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクト実行中判定
|
||||
#--------------------------------------------------------------------------
|
||||
def effect?
|
||||
battler_sprites.any? {|sprite| sprite.effect? }
|
||||
end
|
||||
end
|
||||
273
Scripts/Spriteset_Map.rb
Normal file
273
Scripts/Spriteset_Map.rb
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
#==============================================================================
|
||||
# ■ Spriteset_Map
|
||||
#------------------------------------------------------------------------------
|
||||
# マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
|
||||
# Scene_Map クラスの内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Spriteset_Map
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
create_viewports
|
||||
create_tilemap
|
||||
create_parallax
|
||||
create_characters
|
||||
create_shadow
|
||||
create_weather
|
||||
create_pictures
|
||||
create_timer
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_viewports
|
||||
@viewport1 = Viewport.new
|
||||
@viewport2 = Viewport.new
|
||||
@viewport3 = Viewport.new
|
||||
@viewport2.z = 50
|
||||
@viewport3.z = 100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルマップの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_tilemap
|
||||
@tilemap = Tilemap.new(@viewport1)
|
||||
@tilemap.map_data = $game_map.data
|
||||
load_tileset
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルセットのロード
|
||||
#--------------------------------------------------------------------------
|
||||
def load_tileset
|
||||
@tileset = $game_map.tileset
|
||||
@tileset.tileset_names.each_with_index do |name, i|
|
||||
@tilemap.bitmaps[i] = Cache.tileset(name)
|
||||
end
|
||||
@tilemap.flags = @tileset.flags
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_parallax
|
||||
@parallax = Plane.new(@viewport1)
|
||||
@parallax.z = -100
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクタースプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_characters
|
||||
@character_sprites = []
|
||||
$game_map.events.values.each do |event|
|
||||
@character_sprites.push(Sprite_Character.new(@viewport1, event))
|
||||
end
|
||||
$game_map.vehicles.each do |vehicle|
|
||||
@character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
|
||||
end
|
||||
$game_player.followers.reverse_each do |follower|
|
||||
@character_sprites.push(Sprite_Character.new(@viewport1, follower))
|
||||
end
|
||||
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
|
||||
@map_id = $game_map.map_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の影スプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_shadow
|
||||
@shadow_sprite = Sprite.new(@viewport1)
|
||||
@shadow_sprite.bitmap = Cache.system("Shadow")
|
||||
@shadow_sprite.ox = @shadow_sprite.bitmap.width / 2
|
||||
@shadow_sprite.oy = @shadow_sprite.bitmap.height
|
||||
@shadow_sprite.z = 180
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_weather
|
||||
@weather = Spriteset_Weather.new(@viewport2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_pictures
|
||||
@picture_sprites = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_timer
|
||||
@timer_sprite = Sprite_Timer.new(@viewport2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
dispose_tilemap
|
||||
dispose_parallax
|
||||
dispose_characters
|
||||
dispose_shadow
|
||||
dispose_weather
|
||||
dispose_pictures
|
||||
dispose_timer
|
||||
dispose_viewports
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルマップの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_tilemap
|
||||
@tilemap.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景の解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_parallax
|
||||
@parallax.bitmap.dispose if @parallax.bitmap
|
||||
@parallax.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクタースプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_characters
|
||||
@character_sprites.each {|sprite| sprite.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の影スプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_shadow
|
||||
@shadow_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_weather
|
||||
@weather.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_pictures
|
||||
@picture_sprites.compact.each {|sprite| sprite.dispose }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_timer
|
||||
@timer_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_viewports
|
||||
@viewport1.dispose
|
||||
@viewport2.dispose
|
||||
@viewport3.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクターのリフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh_characters
|
||||
dispose_characters
|
||||
create_characters
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_tileset
|
||||
update_tilemap
|
||||
update_parallax
|
||||
update_characters
|
||||
update_shadow
|
||||
update_weather
|
||||
update_pictures
|
||||
update_timer
|
||||
update_viewports
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルセットの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_tileset
|
||||
if @tileset != $game_map.tileset
|
||||
load_tileset
|
||||
refresh_characters
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイルマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_tilemap
|
||||
@tilemap.map_data = $game_map.data
|
||||
@tilemap.ox = $game_map.display_x * 32
|
||||
@tilemap.oy = $game_map.display_y * 32
|
||||
@tilemap.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 遠景の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_parallax
|
||||
if @parallax_name != $game_map.parallax_name
|
||||
@parallax_name = $game_map.parallax_name
|
||||
@parallax.bitmap.dispose if @parallax.bitmap
|
||||
@parallax.bitmap = Cache.parallax(@parallax_name)
|
||||
Graphics.frame_reset
|
||||
end
|
||||
@parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
|
||||
@parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャラクタースプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_characters
|
||||
refresh_characters if @map_id != $game_map.map_id
|
||||
@character_sprites.each {|sprite| sprite.update }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 飛行船の影スプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_shadow
|
||||
airship = $game_map.airship
|
||||
@shadow_sprite.x = airship.screen_x
|
||||
@shadow_sprite.y = airship.screen_y + airship.altitude
|
||||
@shadow_sprite.opacity = airship.altitude * 8
|
||||
@shadow_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_weather
|
||||
@weather.type = $game_map.screen.weather_type
|
||||
@weather.power = $game_map.screen.weather_power
|
||||
@weather.ox = $game_map.display_x * 32
|
||||
@weather.oy = $game_map.display_y * 32
|
||||
@weather.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャスプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_pictures
|
||||
$game_map.screen.pictures.each do |pic|
|
||||
@picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic)
|
||||
@picture_sprites[pic.number].update
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● タイマースプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_timer
|
||||
@timer_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ビューポートの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_viewports
|
||||
@viewport1.tone.set($game_map.screen.tone)
|
||||
@viewport1.ox = $game_map.screen.shake
|
||||
@viewport2.color.set($game_map.screen.flash_color)
|
||||
@viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness)
|
||||
@viewport1.update
|
||||
@viewport2.update
|
||||
@viewport3.update
|
||||
end
|
||||
end
|
||||
184
Scripts/Spriteset_Weather.rb
Normal file
184
Scripts/Spriteset_Weather.rb
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
#==============================================================================
|
||||
# ■ Spriteset_Weather
|
||||
#------------------------------------------------------------------------------
|
||||
# 天候エフェクト(雨、嵐、雪)のクラスです。このクラスは Spriteset_Map クラ
|
||||
# スの内部で使用されます。
|
||||
#==============================================================================
|
||||
|
||||
class Spriteset_Weather
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :type # 天候タイプ
|
||||
attr_accessor :ox # 原点 X 座標
|
||||
attr_accessor :oy # 原点 Y 座標
|
||||
attr_reader :power # 強さ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport = nil)
|
||||
@viewport = viewport
|
||||
init_members
|
||||
create_rain_bitmap
|
||||
create_storm_bitmap
|
||||
create_snow_bitmap
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メンバ変数の初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def init_members
|
||||
@type = :none
|
||||
@ox = 0
|
||||
@oy = 0
|
||||
@power = 0
|
||||
@sprites = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
@sprites.each {|sprite| sprite.dispose }
|
||||
@rain_bitmap.dispose
|
||||
@storm_bitmap.dispose
|
||||
@snow_bitmap.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 粒子の色 1
|
||||
#--------------------------------------------------------------------------
|
||||
def particle_color1
|
||||
Color.new(255, 255, 255, 192)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 粒子の色 2
|
||||
#--------------------------------------------------------------------------
|
||||
def particle_color2
|
||||
Color.new(255, 255, 255, 96)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候[雨]のビットマップを作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_rain_bitmap
|
||||
@rain_bitmap = Bitmap.new(7, 42)
|
||||
7.times {|i| @rain_bitmap.fill_rect(6-i, i*6, 1, 6, particle_color1) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候[嵐]のビットマップを作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_storm_bitmap
|
||||
@storm_bitmap = Bitmap.new(34, 64)
|
||||
32.times do |i|
|
||||
@storm_bitmap.fill_rect(33-i, i*2, 1, 2, particle_color2)
|
||||
@storm_bitmap.fill_rect(32-i, i*2, 1, 2, particle_color1)
|
||||
@storm_bitmap.fill_rect(31-i, i*2, 1, 2, particle_color2)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候[雪]のビットマップを作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_snow_bitmap
|
||||
@snow_bitmap = Bitmap.new(6, 6)
|
||||
@snow_bitmap.fill_rect(0, 1, 6, 4, particle_color2)
|
||||
@snow_bitmap.fill_rect(1, 0, 4, 6, particle_color2)
|
||||
@snow_bitmap.fill_rect(1, 2, 4, 2, particle_color1)
|
||||
@snow_bitmap.fill_rect(2, 1, 2, 4, particle_color1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 天候の強さを設定
|
||||
#--------------------------------------------------------------------------
|
||||
def power=(power)
|
||||
@power = power
|
||||
(sprite_max - @sprites.size).times { add_sprite }
|
||||
(@sprites.size - sprite_max).times { remove_sprite }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの最大数を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def sprite_max
|
||||
(@power * 10).to_i
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_sprite
|
||||
sprite = Sprite.new(@viewport)
|
||||
sprite.opacity = 0
|
||||
@sprites.push(sprite)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの削除
|
||||
#--------------------------------------------------------------------------
|
||||
def remove_sprite
|
||||
sprite = @sprites.pop
|
||||
sprite.dispose if sprite
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
update_screen
|
||||
@sprites.each {|sprite| update_sprite(sprite) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 画面の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_screen
|
||||
@viewport.tone.set(-dimness, -dimness, -dimness)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 暗さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def dimness
|
||||
(@power * 6).to_i
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_sprite(sprite)
|
||||
sprite.ox = @ox
|
||||
sprite.oy = @oy
|
||||
case @type
|
||||
when :rain
|
||||
update_sprite_rain(sprite)
|
||||
when :storm
|
||||
update_sprite_storm(sprite)
|
||||
when :snow
|
||||
update_sprite_snow(sprite)
|
||||
end
|
||||
create_new_particle(sprite) if sprite.opacity < 64
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの更新[雨]
|
||||
#--------------------------------------------------------------------------
|
||||
def update_sprite_rain(sprite)
|
||||
sprite.bitmap = @rain_bitmap
|
||||
sprite.x -= 1
|
||||
sprite.y += 6
|
||||
sprite.opacity -= 12
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの更新[嵐]
|
||||
#--------------------------------------------------------------------------
|
||||
def update_sprite_storm(sprite)
|
||||
sprite.bitmap = @storm_bitmap
|
||||
sprite.x -= 3
|
||||
sprite.y += 6
|
||||
sprite.opacity -= 12
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スプライトの更新[雪]
|
||||
#--------------------------------------------------------------------------
|
||||
def update_sprite_snow(sprite)
|
||||
sprite.bitmap = @snow_bitmap
|
||||
sprite.x -= 1
|
||||
sprite.y += 3
|
||||
sprite.opacity -= 12
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 新しい粒子の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_new_particle(sprite)
|
||||
sprite.x = rand(Graphics.width + 100) - 100 + @ox
|
||||
sprite.y = rand(Graphics.height + 200) - 200 + @oy
|
||||
sprite.opacity = 160 + rand(96)
|
||||
end
|
||||
end
|
||||
157
Scripts/VXAce_SP1.rb
Normal file
157
Scripts/VXAce_SP1.rb
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
#==============================================================================
|
||||
# ■ VXAce_SP1
|
||||
#------------------------------------------------------------------------------
|
||||
# プリセットスクリプトの不具合を修正します。ユーザー定義のスクリプト素材は、
|
||||
# 原則としてこのセクションより下に配置してください。
|
||||
#==============================================================================
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# 【修正内容】
|
||||
#------------------------------------------------------------------------------
|
||||
# ●イベントコマンド[ステートの変更]にて、同じステートの付加と解除を同時に実
|
||||
# 行した際、二回目以降の付加が失敗する不具合を修正しました。
|
||||
# ●イベントコマンド[アニメーションの表示]にて、表示中のアニメーションがマッ
|
||||
# プのスクロールに同期しない不具合を修正しました。
|
||||
# ●自動戦闘の行動が正常に選択されない不具合を修正しました。
|
||||
# ●装備できなくなった装備品が外れたことにより、さらに別の装備品が装備できなく
|
||||
# なったとき、その装備品が増殖してしまう不具合を修正しました。
|
||||
# ●イベントコマンド[ピクチャの消去]を実行した後に余分な負荷がかかる不具合を
|
||||
# 修正しました。
|
||||
# ●移動ルートのオプション[移動できない場合は飛ばす]にチェックを入れた状態で
|
||||
# トリガー[プレイヤーから接触]のイベントに接触すると、イベントが実行中であ
|
||||
# っても起動予約がされてしまう不具合を修正しました。
|
||||
# ●魔法反射されたスキルに対してステート有効度が反映されない不具合を修正しまし
|
||||
# た。
|
||||
# ●フォントのデフォルト設定にて太字または斜体を有効にしていても、ステータス画
|
||||
# 面を切り替えたとき等に無効な状態に戻ってしまう不具合を修正しました。
|
||||
#------------------------------------------------------------------------------
|
||||
class Game_Battler
|
||||
attr_accessor :magic_reflection
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵対関係の判定
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_opposite? opposite?
|
||||
def opposite?(battler)
|
||||
vxace_sp1_opposite?(battler) || battler.magic_reflection
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Game_Actor
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備できない装備品を外す
|
||||
# item_gain : 外した装備品をパーティに戻す
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_release_unequippable_items release_unequippable_items
|
||||
def release_unequippable_items(item_gain = true)
|
||||
loop do
|
||||
last_equips = equips.dup
|
||||
vxace_sp1_release_unequippable_items(item_gain)
|
||||
return if equips == last_equips
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動戦闘時の戦闘行動を作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_auto_battle_actions
|
||||
@actions.size.times do |i|
|
||||
@actions[i] = make_action_list.max_by {|action| action.value }
|
||||
end
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Game_Player
|
||||
#--------------------------------------------------------------------------
|
||||
# ● マップイベントの起動
|
||||
# triggers : トリガーの配列
|
||||
# normal : プライオリティ[通常キャラと同じ]かそれ以外か
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_start_map_event start_map_event
|
||||
def start_map_event(x, y, triggers, normal)
|
||||
return if $game_map.interpreter.running?
|
||||
vxace_sp1_start_map_event(x, y, triggers, normal)
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Game_Picture
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ピクチャの消去
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_erase erase
|
||||
def erase
|
||||
vxace_sp1_erase
|
||||
@origin = 0
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Game_Interpreter
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートの変更
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_command_313 command_313
|
||||
def command_313
|
||||
vxace_sp1_command_313
|
||||
$game_party.clear_results
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Sprite_Character
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_update_position update_position
|
||||
def update_position
|
||||
move_animation(@character.screen_x - x, @character.screen_y - y)
|
||||
vxace_sp1_update_position
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アニメーションの移動
|
||||
#--------------------------------------------------------------------------
|
||||
def move_animation(dx, dy)
|
||||
if @animation && @animation.position != 3
|
||||
@ani_ox += dx
|
||||
@ani_oy += dy
|
||||
@ani_sprites.each do |sprite|
|
||||
sprite.x += dx
|
||||
sprite.y += dy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Sprite_Picture
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 転送元ビットマップの更新
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_update_bitmap update_bitmap
|
||||
def update_bitmap
|
||||
if @picture.name.empty?
|
||||
self.bitmap = nil
|
||||
else
|
||||
vxace_sp1_update_bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フォント設定のリセット
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_reset_font_settings reset_font_settings
|
||||
def reset_font_settings
|
||||
vxace_sp1_reset_font_settings
|
||||
contents.font.bold = Font.default_bold
|
||||
contents.font.italic = Font.default_italic
|
||||
end
|
||||
end
|
||||
#------------------------------------------------------------------------------
|
||||
class Scene_Battle
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 魔法反射の発動
|
||||
#--------------------------------------------------------------------------
|
||||
alias vxace_sp1_invoke_magic_reflection invoke_magic_reflection
|
||||
def invoke_magic_reflection(target, item)
|
||||
@subject.magic_reflection = true
|
||||
vxace_sp1_invoke_magic_reflection(target, item)
|
||||
@subject.magic_reflection = false
|
||||
end
|
||||
end
|
||||
145
Scripts/Vocab.rb
Normal file
145
Scripts/Vocab.rb
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
#==============================================================================
|
||||
# ■ Vocab
|
||||
#------------------------------------------------------------------------------
|
||||
# 用語とメッセージを定義するモジュールです。定数でメッセージなどを直接定義す
|
||||
# るほか、グローバル変数 $data_system から用語データを取得します。
|
||||
#==============================================================================
|
||||
|
||||
module Vocab
|
||||
|
||||
# ショップ画面
|
||||
ShopBuy = "購入する"
|
||||
ShopSell = "売却する"
|
||||
ShopCancel = "やめる"
|
||||
Possession = "持っている数"
|
||||
|
||||
# ステータス画面
|
||||
ExpTotal = "現在の経験値"
|
||||
ExpNext = "次の%sまで"
|
||||
|
||||
# セーブ/ロード画面
|
||||
SaveMessage = "どのファイルにセーブしますか?"
|
||||
LoadMessage = "どのファイルをロードしますか?"
|
||||
File = "ファイル"
|
||||
|
||||
# 複数メンバーの場合の表示
|
||||
PartyName = "%sたち"
|
||||
|
||||
# 戦闘基本メッセージ
|
||||
Emerge = "%sが出現!"
|
||||
Preemptive = "%sは先手を取った!"
|
||||
Surprise = "%sは不意をつかれた!"
|
||||
EscapeStart = "%sは逃げ出した!"
|
||||
EscapeFailure = "しかし逃げることはできなかった!"
|
||||
|
||||
# 戦闘終了メッセージ
|
||||
Victory = "%sの勝利!"
|
||||
Defeat = "%sは戦いに敗れた。"
|
||||
ObtainExp = "%s の経験値を獲得!"
|
||||
ObtainGold = "エネルギーを %s\\G 手に入れた!"
|
||||
ObtainItem = "%sを手に入れた!"
|
||||
LevelUp = "%sは%s %s に上がった!"
|
||||
ObtainSkill = "%sを覚えた!"
|
||||
|
||||
# アイテム使用
|
||||
UseItem = "%sは%sを使った!"
|
||||
|
||||
# クリティカルヒット
|
||||
CriticalToEnemy = "クリティカルヒット!!"
|
||||
CriticalToActor = "クリティカルヒット!!"
|
||||
|
||||
# アクター対象の行動結果
|
||||
ActorDamage = "%sは %s のダメージを受けた!"
|
||||
ActorRecovery = "%sの%sが %s 回復した!"
|
||||
ActorGain = "%sの%sが %s 増えた!"
|
||||
ActorLoss = "%sの%sが %s 減った!"
|
||||
ActorDrain = "%sは%sを %s 奪われた!"
|
||||
ActorNoDamage = "%sはダメージを受けていない!"
|
||||
ActorNoHit = "ミス! %sはダメージを受けていない!"
|
||||
|
||||
# 敵キャラ対象の行動結果
|
||||
EnemyDamage = "%sに %s のダメージを与えた!"
|
||||
EnemyRecovery = "%sの%sが %s 回復した!"
|
||||
EnemyGain = "%sの%sが %s 増えた!"
|
||||
EnemyLoss = "%sの%sが %s 減った!"
|
||||
EnemyDrain = "%sの%sを %s 奪った!"
|
||||
EnemyNoDamage = "%sにダメージを与えられない!"
|
||||
EnemyNoHit = "ミス! %sにダメージを与えられない!"
|
||||
|
||||
# 回避/反射
|
||||
Evasion = "%sは攻撃をかわした!"
|
||||
MagicEvasion = "%sは魔法を打ち消した!"
|
||||
MagicReflection = "%sは魔法を跳ね返した!"
|
||||
CounterAttack = "%sの反撃!"
|
||||
Substitute = "%sが%sをかばった!"
|
||||
|
||||
# 能力強化/弱体
|
||||
BuffAdd = "%sの%sが上がった!"
|
||||
DebuffAdd = "%sの%sが下がった!"
|
||||
BuffRemove = "%sの%sが元に戻った!"
|
||||
|
||||
# スキル、アイテムの効果がなかった
|
||||
ActionFailure = "%sには効かなかった!"
|
||||
|
||||
# エラーメッセージ
|
||||
PlayerPosError = "プレイヤーの初期位置が設定されていません。"
|
||||
EventOverflow = "コモンイベントの呼び出しが上限を超えました。"
|
||||
|
||||
# 基本ステータス
|
||||
def self.basic(basic_id)
|
||||
$data_system.terms.basic[basic_id]
|
||||
end
|
||||
|
||||
# 能力値
|
||||
def self.param(param_id)
|
||||
$data_system.terms.params[param_id]
|
||||
end
|
||||
|
||||
# 装備タイプ
|
||||
def self.etype(etype_id)
|
||||
$data_system.terms.etypes[etype_id]
|
||||
end
|
||||
|
||||
# コマンド
|
||||
def self.command(command_id)
|
||||
$data_system.terms.commands[command_id]
|
||||
end
|
||||
|
||||
# 通貨単位
|
||||
def self.currency_unit
|
||||
$data_system.currency_unit
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
def self.level; basic(0); end # レベル
|
||||
def self.level_a; basic(1); end # レベル (短)
|
||||
def self.hp; basic(2); end # HP
|
||||
def self.hp_a; basic(3); end # HP (短)
|
||||
def self.mp; basic(4); end # MP
|
||||
def self.mp_a; basic(5); end # MP (短)
|
||||
def self.tp; basic(6); end # TP
|
||||
def self.tp_a; basic(7); end # TP (短)
|
||||
def self.fight; command(0); end # 戦う
|
||||
def self.escape; command(1); end # 逃げる
|
||||
def self.attack; command(2); end # 攻撃
|
||||
def self.guard; command(3); end # 防御
|
||||
def self.item; command(4); end # アイテム
|
||||
def self.skill; command(5); end # スキル
|
||||
def self.equip; command(6); end # 装備
|
||||
def self.status; command(7); end # ステータス
|
||||
def self.formation; command(8); end # 並び替え
|
||||
def self.save; command(9); end # セーブ
|
||||
def self.game_end; command(10); end # ゲーム終了
|
||||
def self.weapon; command(12); end # 武器
|
||||
def self.armor; command(13); end # 防具
|
||||
def self.key_item; command(14); end # 大事なもの
|
||||
def self.equip2; command(15); end # 装備変更
|
||||
def self.optimize; command(16); end # 最強装備
|
||||
def self.clear; command(17); end # 全て外す
|
||||
def self.new_game; command(18); end # ニューゲーム
|
||||
def self.continue; command(19); end # コンティニュー
|
||||
def self.shutdown; command(20); end # シャットダウン
|
||||
def self.to_title; command(21); end # タイトルへ
|
||||
def self.cancel; command(22); end # やめる
|
||||
#--------------------------------------------------------------------------
|
||||
end
|
||||
78
Scripts/Window_ActorCommand.rb
Normal file
78
Scripts/Window_ActorCommand.rb
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#==============================================================================
|
||||
# ■ Window_ActorCommand
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、アクターの行動を選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_ActorCommand < Window_Command
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0)
|
||||
self.openness = 0
|
||||
deactivate
|
||||
@actor = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 128
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
return unless @actor
|
||||
add_attack_command
|
||||
add_skill_commands
|
||||
add_guard_command
|
||||
add_item_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 攻撃コマンドをリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_attack_command
|
||||
add_command(Vocab::attack, :attack, @actor.attack_usable?)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキルコマンドをリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_skill_commands
|
||||
@actor.added_skill_types.sort.each do |stype_id|
|
||||
name = $data_system.skill_types[stype_id]
|
||||
add_command(name, :skill, true, stype_id)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 防御コマンドをリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_guard_command
|
||||
add_command(Vocab::guard, :guard, @actor.guard_usable?)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムコマンドをリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_item_command
|
||||
add_command(Vocab::item, :item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セットアップ
|
||||
#--------------------------------------------------------------------------
|
||||
def setup(actor)
|
||||
@actor = actor
|
||||
clear_command_list
|
||||
make_command_list
|
||||
refresh
|
||||
select(0)
|
||||
activate
|
||||
open
|
||||
end
|
||||
end
|
||||
569
Scripts/Window_Base.rb
Normal file
569
Scripts/Window_Base.rb
Normal file
|
|
@ -0,0 +1,569 @@
|
|||
#==============================================================================
|
||||
# ■ Window_Base
|
||||
#------------------------------------------------------------------------------
|
||||
# ゲーム中の全てのウィンドウのスーパークラスです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_Base < Window
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y, width, height)
|
||||
super
|
||||
self.windowskin = Cache.system("Window")
|
||||
update_padding
|
||||
update_tone
|
||||
create_contents
|
||||
@opening = @closing = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
contents.dispose unless disposed?
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行の高さを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def line_height
|
||||
return 24
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 標準パディングサイズの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def standard_padding
|
||||
return 12
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パディングの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_padding
|
||||
self.padding = standard_padding
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の幅を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def contents_width
|
||||
width - standard_padding * 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の高さを計算
|
||||
#--------------------------------------------------------------------------
|
||||
def contents_height
|
||||
height - standard_padding * 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定行数に適合するウィンドウの高さを計算
|
||||
#--------------------------------------------------------------------------
|
||||
def fitting_height(line_number)
|
||||
line_number * line_height + standard_padding * 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 色調の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_tone
|
||||
self.tone.set($game_system.window_tone)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_contents
|
||||
contents.dispose
|
||||
if contents_width > 0 && contents_height > 0
|
||||
self.contents = Bitmap.new(contents_width, contents_height)
|
||||
else
|
||||
self.contents = Bitmap.new(1, 1)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_tone
|
||||
update_open if @opening
|
||||
update_close if @closing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 開く処理の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_open
|
||||
self.openness += 48
|
||||
@opening = false if open?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 閉じる処理の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_close
|
||||
self.openness -= 48
|
||||
@closing = false if close?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを開く
|
||||
#--------------------------------------------------------------------------
|
||||
def open
|
||||
@opening = true unless open?
|
||||
@closing = false
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを閉じる
|
||||
#--------------------------------------------------------------------------
|
||||
def close
|
||||
@closing = true unless close?
|
||||
@opening = false
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show
|
||||
self.visible = true
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
self.visible = false
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウのアクティブ化
|
||||
#--------------------------------------------------------------------------
|
||||
def activate
|
||||
self.active = true
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非アクティブ化
|
||||
#--------------------------------------------------------------------------
|
||||
def deactivate
|
||||
self.active = false
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文字色取得
|
||||
# n : 文字色番号(0..31)
|
||||
#--------------------------------------------------------------------------
|
||||
def text_color(n)
|
||||
windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 各種文字色の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def normal_color; text_color(0); end; # 通常
|
||||
def system_color; text_color(23); end; # システム
|
||||
def crisis_color; text_color(17); end; # ピンチ
|
||||
def knockout_color; text_color(18); end; # 戦闘不能
|
||||
def gauge_back_color; text_color(19); end; # ゲージ背景
|
||||
def hp_gauge_color1; text_color(28); end; # HP ゲージ 1
|
||||
def hp_gauge_color2; text_color(29); end; # HP ゲージ 2
|
||||
def mp_gauge_color1; text_color(26); end; # MP ゲージ 1
|
||||
def mp_gauge_color2; text_color(27); end; # MP ゲージ 2
|
||||
def mp_cost_color; text_color(27); end; # 消費 TP
|
||||
def power_up_color; text_color(24); end; # 装備 パワーアップ
|
||||
def power_down_color; text_color(25); end; # 装備 パワーダウン
|
||||
def tp_gauge_color1; text_color(28); end; # TP ゲージ 1
|
||||
def tp_gauge_color2; text_color(29); end; # TP ゲージ 2
|
||||
def tp_cost_color; text_color(14); end; # 消費 TP
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 保留項目の背景色を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def pending_color
|
||||
windowskin.get_pixel(80, 80)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 半透明描画用のアルファ値を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def translucent_alpha
|
||||
return 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキスト描画色の変更
|
||||
# enabled : 有効フラグ。false のとき半透明で描画
|
||||
#--------------------------------------------------------------------------
|
||||
def change_color(color, enabled = true)
|
||||
contents.font.color.set(color)
|
||||
contents.font.color.alpha = translucent_alpha unless enabled
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキストの描画
|
||||
# args : Bitmap#draw_text と同じ
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_text(*args)
|
||||
contents.draw_text(*args)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキストサイズの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def text_size(str)
|
||||
contents.text_size(str)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字つきテキストの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_text_ex(x, y, text)
|
||||
reset_font_settings
|
||||
text = convert_escape_characters(text)
|
||||
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
|
||||
process_character(text.slice!(0, 1), text, pos) until text.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フォント設定のリセット
|
||||
#--------------------------------------------------------------------------
|
||||
def reset_font_settings
|
||||
change_color(normal_color)
|
||||
contents.font.size = Font.default_size
|
||||
contents.font.bold = false
|
||||
contents.font.italic = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字の事前変換
|
||||
# 実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
|
||||
# 文字「\」はエスケープ文字(\e)に変換。
|
||||
#--------------------------------------------------------------------------
|
||||
def convert_escape_characters(text)
|
||||
result = text.to_s.clone
|
||||
result.gsub!(/\\/) { "\e" }
|
||||
result.gsub!(/\e\e/) { "\\" }
|
||||
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
|
||||
result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
|
||||
result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
|
||||
result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
|
||||
result.gsub!(/\eG/i) { Vocab::currency_unit }
|
||||
result
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクター n 番の名前を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def actor_name(n)
|
||||
actor = n >= 1 ? $game_actors[n] : nil
|
||||
actor ? actor.name : ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● パーティメンバー n 番の名前を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def party_member_name(n)
|
||||
actor = n >= 1 ? $game_party.members[n - 1] : nil
|
||||
actor ? actor.name : ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文字の処理
|
||||
# c : 文字
|
||||
# text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
|
||||
# pos : 描画位置 {:x, :y, :new_x, :height}
|
||||
#--------------------------------------------------------------------------
|
||||
def process_character(c, text, pos)
|
||||
case c
|
||||
when "\n" # 改行
|
||||
process_new_line(text, pos)
|
||||
when "\f" # 改ページ
|
||||
process_new_page(text, pos)
|
||||
when "\e" # 制御文字
|
||||
process_escape_character(obtain_escape_code(text), text, pos)
|
||||
else # 普通の文字
|
||||
process_normal_character(c, pos)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_normal_character(c, pos)
|
||||
text_width = text_size(c).width
|
||||
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
|
||||
pos[:x] += text_width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改行文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_new_line(text, pos)
|
||||
pos[:x] = pos[:new_x]
|
||||
pos[:y] += pos[:height]
|
||||
pos[:height] = calc_line_height(text)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改ページ文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_new_page(text, pos)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字の本体を破壊的に取得
|
||||
#--------------------------------------------------------------------------
|
||||
def obtain_escape_code(text)
|
||||
text.slice!(/^[\$\.\|\^!><\{\}\\]|^[A-Z]+/i)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字の引数を破壊的に取得
|
||||
#--------------------------------------------------------------------------
|
||||
def obtain_escape_param(text)
|
||||
text.slice!(/^\[\d+\]/)[/\d+/].to_i rescue 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字の処理
|
||||
# code : 制御文字の本体部分(「\C[1]」なら「C」)
|
||||
#--------------------------------------------------------------------------
|
||||
def process_escape_character(code, text, pos)
|
||||
case code.upcase
|
||||
when 'C'
|
||||
change_color(text_color(obtain_escape_param(text)))
|
||||
when 'I'
|
||||
process_draw_icon(obtain_escape_param(text), pos)
|
||||
when '{'
|
||||
make_font_bigger
|
||||
when '}'
|
||||
make_font_smaller
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字によるアイコン描画の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_draw_icon(icon_index, pos)
|
||||
draw_icon(icon_index, pos[:x], pos[:y])
|
||||
pos[:x] += 24
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フォントを大きくする
|
||||
#--------------------------------------------------------------------------
|
||||
def make_font_bigger
|
||||
contents.font.size += 8 if contents.font.size <= 64
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フォントを小さくする
|
||||
#--------------------------------------------------------------------------
|
||||
def make_font_smaller
|
||||
contents.font.size -= 8 if contents.font.size >= 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行の高さを計算
|
||||
# restore_font_size : 計算後にフォントサイズを元に戻す
|
||||
#--------------------------------------------------------------------------
|
||||
def calc_line_height(text, restore_font_size = true)
|
||||
result = [line_height, contents.font.size].max
|
||||
last_font_size = contents.font.size
|
||||
text.slice(/^.*$/).scan(/\e[\{\}]/).each do |esc|
|
||||
make_font_bigger if esc == "\e{"
|
||||
make_font_smaller if esc == "\e}"
|
||||
result = [result, contents.font.size].max
|
||||
end
|
||||
contents.font.size = last_font_size if restore_font_size
|
||||
result
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージの描画
|
||||
# rate : 割合(1.0 で満タン)
|
||||
# color1 : グラデーション 左端
|
||||
# color2 : グラデーション 右端
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_gauge(x, y, width, rate, color1, color2)
|
||||
fill_w = (width * rate).to_i
|
||||
gauge_y = y + line_height - 8
|
||||
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
|
||||
contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイコンの描画
|
||||
# enabled : 有効フラグ。false のとき半透明で描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_icon(icon_index, x, y, enabled = true)
|
||||
bitmap = Cache.system("Iconset")
|
||||
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
|
||||
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 顔グラフィックの描画
|
||||
# enabled : 有効フラグ。false のとき半透明で描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_face(face_name, face_index, x, y, enabled = true)
|
||||
bitmap = Cache.face(face_name)
|
||||
rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
|
||||
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
|
||||
bitmap.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 歩行グラフィックの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_character(character_name, character_index, x, y)
|
||||
return unless character_name
|
||||
bitmap = Cache.character(character_name)
|
||||
sign = character_name[/^[\!\$]./]
|
||||
if sign && sign.include?('$')
|
||||
cw = bitmap.width / 3
|
||||
ch = bitmap.height / 4
|
||||
else
|
||||
cw = bitmap.width / 12
|
||||
ch = bitmap.height / 8
|
||||
end
|
||||
n = character_index
|
||||
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
|
||||
contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の文字色を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def hp_color(actor)
|
||||
return knockout_color if actor.hp == 0
|
||||
return crisis_color if actor.hp < actor.mhp / 4
|
||||
return normal_color
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP の文字色を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def mp_color(actor)
|
||||
return crisis_color if actor.mp < actor.mmp / 4
|
||||
return normal_color
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の文字色を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def tp_color(actor)
|
||||
return normal_color
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの歩行グラフィック描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_graphic(actor, x, y)
|
||||
draw_character(actor.character_name, actor.character_index, x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの顔グラフィック描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_face(actor, x, y, enabled = true)
|
||||
draw_face(actor.face_name, actor.face_index, x, y, enabled)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 名前の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_name(actor, x, y, width = 112)
|
||||
change_color(hp_color(actor))
|
||||
draw_text(x, y, width, line_height, actor.name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 職業の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_class(actor, x, y, width = 112)
|
||||
change_color(normal_color)
|
||||
draw_text(x, y, width, line_height, actor.class.name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 二つ名の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_nickname(actor, x, y, width = 180)
|
||||
change_color(normal_color)
|
||||
draw_text(x, y, width, line_height, actor.nickname)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● レベルの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_level(actor, x, y)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 32, line_height, Vocab::level_a)
|
||||
change_color(normal_color)
|
||||
draw_text(x + 32, y, 24, line_height, actor.level, 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステートおよび強化/弱体のアイコンを描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_icons(actor, x, y, width = 96)
|
||||
icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
|
||||
icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在値/最大値を分数形式で描画
|
||||
# current : 現在値
|
||||
# max : 最大値
|
||||
# color1 : 現在値の色
|
||||
# color2 : 最大値の色
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
|
||||
change_color(color1)
|
||||
xr = x + width
|
||||
if width < 96
|
||||
draw_text(xr - 40, y, 42, line_height, current, 2)
|
||||
else
|
||||
draw_text(xr - 92, y, 42, line_height, current, 2)
|
||||
change_color(color2)
|
||||
draw_text(xr - 52, y, 12, line_height, "/", 2)
|
||||
draw_text(xr - 42, y, 42, line_height, max, 2)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_hp(actor, x, y, width = 124)
|
||||
draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 30, line_height, Vocab::hp_a)
|
||||
draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
|
||||
hp_color(actor), normal_color)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_mp(actor, x, y, width = 124)
|
||||
draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 30, line_height, Vocab::mp_a)
|
||||
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
|
||||
mp_color(actor), normal_color)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_tp(actor, x, y, width = 124)
|
||||
draw_gauge(x, y, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 30, line_height, Vocab::tp_a)
|
||||
change_color(tp_color(actor))
|
||||
draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● シンプルなステータスの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_simple_status(actor, x, y)
|
||||
draw_actor_name(actor, x, y)
|
||||
draw_actor_level(actor, x, y + line_height * 1)
|
||||
draw_actor_icons(actor, x, y + line_height * 2)
|
||||
draw_actor_class(actor, x + 120, y)
|
||||
draw_actor_hp(actor, x + 120, y + line_height * 1)
|
||||
draw_actor_mp(actor, x + 120, y + line_height * 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力値の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_actor_param(actor, x, y, param_id)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 120, line_height, Vocab::param(param_id))
|
||||
change_color(normal_color)
|
||||
draw_text(x + 120, y, 36, line_height, actor.param(param_id), 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム名の描画
|
||||
# enabled : 有効フラグ。false のとき半透明で描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item_name(item, x, y, enabled = true, width = 172)
|
||||
return unless item
|
||||
draw_icon(item.icon_index, x, y, enabled)
|
||||
change_color(normal_color, enabled)
|
||||
draw_text(x + 24, y, width, line_height, item.name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通貨単位つき数値(所持金など)の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_currency_value(value, unit, x, y, width)
|
||||
cx = text_size(unit).width
|
||||
change_color(normal_color)
|
||||
draw_text(x, y, width - cx - 2, line_height, value, 2)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, width, line_height, unit, 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力値変化の描画色取得
|
||||
#--------------------------------------------------------------------------
|
||||
def param_change_color(change)
|
||||
return power_up_color if change > 0
|
||||
return power_down_color if change < 0
|
||||
return normal_color
|
||||
end
|
||||
end
|
||||
38
Scripts/Window_BattleActor.rb
Normal file
38
Scripts/Window_BattleActor.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleActor
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、行動対象のアクターを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleActor < Window_BattleStatus
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# info_viewport : 情報表示用ビューポート
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(info_viewport)
|
||||
super()
|
||||
self.y = info_viewport.rect.y
|
||||
self.visible = false
|
||||
self.openness = 255
|
||||
@info_viewport = info_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show
|
||||
if @info_viewport
|
||||
width_remain = Graphics.width - width
|
||||
self.x = width_remain
|
||||
@info_viewport.rect.width = width_remain
|
||||
select(0)
|
||||
end
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
@info_viewport.rect.width = Graphics.width if @info_viewport
|
||||
super
|
||||
end
|
||||
end
|
||||
69
Scripts/Window_BattleEnemy.rb
Normal file
69
Scripts/Window_BattleEnemy.rb
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleEnemy
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、行動対象の敵キャラを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleEnemy < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# info_viewport : 情報表示用ビューポート
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(info_viewport)
|
||||
super(0, info_viewport.rect.y, window_width, fitting_height(4))
|
||||
refresh
|
||||
self.visible = false
|
||||
@info_viewport = info_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width - 128
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 桁数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def col_max
|
||||
return 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
$game_troop.alive_members.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 敵キャラオブジェクト取得
|
||||
#--------------------------------------------------------------------------
|
||||
def enemy
|
||||
$game_troop.alive_members[@index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
change_color(normal_color)
|
||||
name = $game_troop.alive_members[index].name
|
||||
draw_text(item_rect_for_text(index), name)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show
|
||||
if @info_viewport
|
||||
width_remain = Graphics.width - width
|
||||
self.x = width_remain
|
||||
@info_viewport.rect.width = width_remain
|
||||
select(0)
|
||||
end
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
@info_viewport.rect.width = Graphics.width if @info_viewport
|
||||
super
|
||||
end
|
||||
end
|
||||
40
Scripts/Window_BattleItem.rb
Normal file
40
Scripts/Window_BattleItem.rb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleItem
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、使用するアイテムを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleItem < Window_ItemList
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# info_viewport : 情報表示用ビューポート
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(help_window, info_viewport)
|
||||
y = help_window.height
|
||||
super(0, y, Graphics.width, info_viewport.rect.y - y)
|
||||
self.visible = false
|
||||
@help_window = help_window
|
||||
@info_viewport = info_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムをリストに含めるかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def include?(item)
|
||||
$game_party.usable?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show
|
||||
select_last
|
||||
@help_window.show
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
@help_window.hide
|
||||
super
|
||||
end
|
||||
end
|
||||
425
Scripts/Window_BattleLog.rb
Normal file
425
Scripts/Window_BattleLog.rb
Normal file
|
|
@ -0,0 +1,425 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleLog
|
||||
#------------------------------------------------------------------------------
|
||||
# 戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
|
||||
# ウとして扱います。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleLog < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0, window_width, window_height)
|
||||
self.z = 200
|
||||
self.opacity = 0
|
||||
@lines = []
|
||||
@num_wait = 0
|
||||
create_back_bitmap
|
||||
create_back_sprite
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
super
|
||||
dispose_back_bitmap
|
||||
dispose_back_sprite
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(max_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最大行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_line_number
|
||||
return 6
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景ビットマップの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_back_bitmap
|
||||
@back_bitmap = Bitmap.new(width, height)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景スプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_back_sprite
|
||||
@back_sprite = Sprite.new
|
||||
@back_sprite.bitmap = @back_bitmap
|
||||
@back_sprite.y = y
|
||||
@back_sprite.z = z - 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景ビットマップの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_back_bitmap
|
||||
@back_bitmap.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景スプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_back_sprite
|
||||
@back_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
@num_wait = 0
|
||||
@lines.clear
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● データ行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def line_number
|
||||
@lines.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一行戻る
|
||||
#--------------------------------------------------------------------------
|
||||
def back_one
|
||||
@lines.pop
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定した行に戻る
|
||||
#--------------------------------------------------------------------------
|
||||
def back_to(line_number)
|
||||
@lines.pop while @lines.size > line_number
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文章の追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_text(text)
|
||||
@lines.push(text)
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文章の置き換え
|
||||
# 最下行を別の文章に置き換える。
|
||||
#--------------------------------------------------------------------------
|
||||
def replace_text(text)
|
||||
@lines.pop
|
||||
@lines.push(text)
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 最下行の文章の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def last_text
|
||||
@lines[-1]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
draw_background
|
||||
contents.clear
|
||||
@lines.size.times {|i| draw_line(i) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_background
|
||||
@back_bitmap.clear
|
||||
@back_bitmap.fill_rect(back_rect, back_color)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の矩形を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_rect
|
||||
Rect.new(0, padding, width, line_number * line_height)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景色の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_color
|
||||
Color.new(0, 0, 0, back_opacity)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の不透明度を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_opacity
|
||||
return 64
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_line(line_number)
|
||||
rect = item_rect_for_text(line_number)
|
||||
contents.clear_rect(rect)
|
||||
draw_text_ex(rect.x, rect.y, @lines[line_number])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト用メソッドの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def method_wait=(method)
|
||||
@method_wait = method
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクト実行のウェイト用メソッドの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def method_wait_for_effect=(method)
|
||||
@method_wait_for_effect = method
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait
|
||||
@num_wait += 1
|
||||
@method_wait.call(message_speed) if @method_wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● エフェクト実行が終わるまでウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_effect
|
||||
@method_wait_for_effect.call if @method_wait_for_effect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● メッセージ速度の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def message_speed
|
||||
return 20
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイトとクリア
|
||||
# メッセージが読める最低限のウェイトを入れた後クリアする。
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_and_clear
|
||||
wait while @num_wait < 2 if line_number > 0
|
||||
clear
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在のステートの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_current_state(subject)
|
||||
unless subject.most_important_state_text.empty?
|
||||
add_text(subject.name + subject.most_important_state_text)
|
||||
wait
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スキル/アイテム使用の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_use_item(subject, item)
|
||||
if item.is_a?(RPG::Skill)
|
||||
add_text(subject.name + item.message1)
|
||||
unless item.message2.empty?
|
||||
wait
|
||||
add_text(item.message2)
|
||||
end
|
||||
else
|
||||
add_text(sprintf(Vocab::UseItem, subject.name, item.name))
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 反撃の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_counter(target, item)
|
||||
Sound.play_evasion
|
||||
add_text(sprintf(Vocab::CounterAttack, target.name))
|
||||
wait
|
||||
back_one
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 反射の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_reflection(target, item)
|
||||
Sound.play_reflection
|
||||
add_text(sprintf(Vocab::MagicReflection, target.name))
|
||||
wait
|
||||
back_one
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 身代わりの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_substitute(substitute, target)
|
||||
add_text(sprintf(Vocab::Substitute, substitute.name, target.name))
|
||||
wait
|
||||
back_one
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 行動結果の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_action_results(target, item)
|
||||
if target.result.used
|
||||
last_line_number = line_number
|
||||
display_critical(target, item)
|
||||
display_damage(target, item)
|
||||
display_affected_status(target, item)
|
||||
display_failure(target, item)
|
||||
wait if line_number > last_line_number
|
||||
back_to(last_line_number)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 失敗の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_failure(target, item)
|
||||
if target.result.hit? && !target.result.success
|
||||
add_text(sprintf(Vocab::ActionFailure, target.name))
|
||||
wait
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリティカルヒットの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_critical(target, item)
|
||||
if target.result.critical
|
||||
text = target.actor? ? Vocab::CriticalToActor : Vocab::CriticalToEnemy
|
||||
add_text(text)
|
||||
wait
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ダメージの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_damage(target, item)
|
||||
if target.result.missed
|
||||
display_miss(target, item)
|
||||
elsif target.result.evaded
|
||||
display_evasion(target, item)
|
||||
else
|
||||
display_hp_damage(target, item)
|
||||
display_mp_damage(target, item)
|
||||
display_tp_damage(target, item)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ミスの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_miss(target, item)
|
||||
if !item || item.physical?
|
||||
fmt = target.actor? ? Vocab::ActorNoHit : Vocab::EnemyNoHit
|
||||
Sound.play_miss
|
||||
else
|
||||
fmt = Vocab::ActionFailure
|
||||
end
|
||||
add_text(sprintf(fmt, target.name))
|
||||
wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 回避の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_evasion(target, item)
|
||||
if !item || item.physical?
|
||||
fmt = Vocab::Evasion
|
||||
Sound.play_evasion
|
||||
else
|
||||
fmt = Vocab::MagicEvasion
|
||||
Sound.play_magic_evasion
|
||||
end
|
||||
add_text(sprintf(fmt, target.name))
|
||||
wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● HP ダメージ表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_hp_damage(target, item)
|
||||
return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
|
||||
if target.result.hp_damage > 0 && target.result.hp_drain == 0
|
||||
target.perform_damage_effect
|
||||
end
|
||||
Sound.play_recovery if target.result.hp_damage < 0
|
||||
add_text(target.result.hp_damage_text)
|
||||
wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● MP ダメージ表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_mp_damage(target, item)
|
||||
return if target.dead? || target.result.mp_damage == 0
|
||||
Sound.play_recovery if target.result.mp_damage < 0
|
||||
add_text(target.result.mp_damage_text)
|
||||
wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● TP ダメージ表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_tp_damage(target, item)
|
||||
return if target.dead? || target.result.tp_damage == 0
|
||||
Sound.play_recovery if target.result.tp_damage < 0
|
||||
add_text(target.result.tp_damage_text)
|
||||
wait
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 影響を受けたステータスの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_affected_status(target, item)
|
||||
if target.result.status_affected?
|
||||
add_text("") if line_number < max_line_number
|
||||
display_changed_states(target)
|
||||
display_changed_buffs(target)
|
||||
back_one if last_text.empty?
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 自動で影響を受けたステータスの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_auto_affected_status(target)
|
||||
if target.result.status_affected?
|
||||
display_affected_status(target, nil)
|
||||
wait if line_number > 0
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート付加/解除の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_changed_states(target)
|
||||
display_added_states(target)
|
||||
display_removed_states(target)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート付加の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_added_states(target)
|
||||
target.result.added_state_objects.each do |state|
|
||||
state_msg = target.actor? ? state.message1 : state.message2
|
||||
target.perform_collapse_effect if state.id == target.death_state_id
|
||||
next if state_msg.empty?
|
||||
replace_text(target.name + state_msg)
|
||||
wait
|
||||
wait_for_effect
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステート解除の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_removed_states(target)
|
||||
target.result.removed_state_objects.each do |state|
|
||||
next if state.message4.empty?
|
||||
replace_text(target.name + state.message4)
|
||||
wait
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化/弱体の表示
|
||||
#--------------------------------------------------------------------------
|
||||
def display_changed_buffs(target)
|
||||
display_buffs(target, target.result.added_buffs, Vocab::BuffAdd)
|
||||
display_buffs(target, target.result.added_debuffs, Vocab::DebuffAdd)
|
||||
display_buffs(target, target.result.removed_buffs, Vocab::BuffRemove)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力強化/弱体の表示(個別)
|
||||
#--------------------------------------------------------------------------
|
||||
def display_buffs(target, buffs, fmt)
|
||||
buffs.each do |param_id|
|
||||
replace_text(sprintf(fmt, target.name, Vocab::param(param_id)))
|
||||
wait
|
||||
end
|
||||
end
|
||||
end
|
||||
34
Scripts/Window_BattleSkill.rb
Normal file
34
Scripts/Window_BattleSkill.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleSkill
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、使用するスキルを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleSkill < Window_SkillList
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
# info_viewport : 情報表示用ビューポート
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(help_window, info_viewport)
|
||||
y = help_window.height
|
||||
super(0, y, Graphics.width, info_viewport.rect.y - y)
|
||||
self.visible = false
|
||||
@help_window = help_window
|
||||
@info_viewport = info_viewport
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの表示
|
||||
#--------------------------------------------------------------------------
|
||||
def show
|
||||
select_last
|
||||
@help_window.show
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウの非表示
|
||||
#--------------------------------------------------------------------------
|
||||
def hide
|
||||
@help_window.hide
|
||||
super
|
||||
end
|
||||
end
|
||||
110
Scripts/Window_BattleStatus.rb
Normal file
110
Scripts/Window_BattleStatus.rb
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#==============================================================================
|
||||
# ■ Window_BattleStatus
|
||||
#------------------------------------------------------------------------------
|
||||
# バトル画面で、パーティメンバーのステータスを表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_BattleStatus < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0, window_width, window_height)
|
||||
refresh
|
||||
self.openness = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width - 128
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(visible_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
$game_party.battle_members.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_all_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
actor = $game_party.battle_members[index]
|
||||
draw_basic_area(basic_area_rect(index), actor)
|
||||
draw_gauge_area(gauge_area_rect(index), actor)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 基本エリアの矩形を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def basic_area_rect(index)
|
||||
rect = item_rect_for_text(index)
|
||||
rect.width -= gauge_area_width + 10
|
||||
rect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージエリアの矩形を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def gauge_area_rect(index)
|
||||
rect = item_rect_for_text(index)
|
||||
rect.x += rect.width - gauge_area_width
|
||||
rect.width = gauge_area_width
|
||||
rect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージエリアの幅を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def gauge_area_width
|
||||
return 220
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 基本エリアの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_basic_area(rect, actor)
|
||||
draw_actor_name(actor, rect.x + 0, rect.y, 100)
|
||||
draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージエリアの描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_gauge_area(rect, actor)
|
||||
if $data_system.opt_display_tp
|
||||
draw_gauge_area_with_tp(rect, actor)
|
||||
else
|
||||
draw_gauge_area_without_tp(rect, actor)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージエリアの描画(TP あり)
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_gauge_area_with_tp(rect, actor)
|
||||
draw_actor_hp(actor, rect.x + 0, rect.y, 72)
|
||||
draw_actor_mp(actor, rect.x + 82, rect.y, 64)
|
||||
draw_actor_tp(actor, rect.x + 156, rect.y, 64)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲージエリアの描画(TP なし)
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_gauge_area_without_tp(rect, actor)
|
||||
draw_actor_hp(actor, rect.x + 0, rect.y, 134)
|
||||
draw_actor_mp(actor, rect.x + 144, rect.y, 76)
|
||||
end
|
||||
end
|
||||
88
Scripts/Window_ChoiceList.rb
Normal file
88
Scripts/Window_ChoiceList.rb
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#==============================================================================
|
||||
# ■ Window_ChoiceList
|
||||
#------------------------------------------------------------------------------
|
||||
# イベントコマンド[選択肢の表示]に使用するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_ChoiceList < Window_Command
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(message_window)
|
||||
@message_window = message_window
|
||||
super(0, 0)
|
||||
self.openness = 0
|
||||
deactivate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力処理の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
update_placement
|
||||
refresh
|
||||
select(0)
|
||||
open
|
||||
activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_placement
|
||||
self.width = [max_choice_width + 12, 96].max + padding * 2
|
||||
self.width = [width, Graphics.width].min
|
||||
self.height = fitting_height($game_message.choices.size)
|
||||
self.x = Graphics.width - width
|
||||
if @message_window.y >= Graphics.height / 2
|
||||
self.y = @message_window.y - height
|
||||
else
|
||||
self.y = @message_window.y + @message_window.height
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択肢の最大幅を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def max_choice_width
|
||||
$game_message.choices.collect {|s| text_size(s).width }.max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の高さを計算
|
||||
#--------------------------------------------------------------------------
|
||||
def contents_height
|
||||
item_max * item_height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
$game_message.choices.each do |choice|
|
||||
add_command(choice, :choice)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
rect = item_rect_for_text(index)
|
||||
draw_text_ex(rect.x, rect.y, command_name(index))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャンセル処理の有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def cancel_enabled?
|
||||
$game_message.choice_cancel_type > 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ハンドラの呼び出し
|
||||
#--------------------------------------------------------------------------
|
||||
def call_ok_handler
|
||||
$game_message.choice_proc.call(index)
|
||||
close
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャンセルハンドラの呼び出し
|
||||
#--------------------------------------------------------------------------
|
||||
def call_cancel_handler
|
||||
$game_message.choice_proc.call($game_message.choice_cancel_type - 1)
|
||||
close
|
||||
end
|
||||
end
|
||||
152
Scripts/Window_Command.rb
Normal file
152
Scripts/Window_Command.rb
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
#==============================================================================
|
||||
# ■ Window_Command
|
||||
#------------------------------------------------------------------------------
|
||||
# 一般的なコマンド選択を行うウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_Command < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y)
|
||||
clear_command_list
|
||||
make_command_list
|
||||
super(x, y, window_width, window_height)
|
||||
refresh
|
||||
select(0)
|
||||
activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(visible_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
item_max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
@list.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_command_list
|
||||
@list = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドの追加
|
||||
# name : コマンド名
|
||||
# symbol : 対応するシンボル
|
||||
# enabled : 有効状態フラグ
|
||||
# ext : 任意の拡張データ
|
||||
#--------------------------------------------------------------------------
|
||||
def add_command(name, symbol, enabled = true, ext = nil)
|
||||
@list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド名の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def command_name(index)
|
||||
@list[index][:name]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドの有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def command_enabled?(index)
|
||||
@list[index][:enabled]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目のコマンドデータを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_data
|
||||
index >= 0 ? @list[index] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目の有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_item_enabled?
|
||||
current_data ? current_data[:enabled] : false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目のシンボルを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_symbol
|
||||
current_data ? current_data[:symbol] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目の拡張データを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_ext
|
||||
current_data ? current_data[:ext] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定されたシンボルを持つコマンドにカーソルを移動
|
||||
#--------------------------------------------------------------------------
|
||||
def select_symbol(symbol)
|
||||
@list.each_index {|i| select(i) if @list[i][:symbol] == symbol }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 指定された拡張データを持つコマンドにカーソルを移動
|
||||
#--------------------------------------------------------------------------
|
||||
def select_ext(ext)
|
||||
@list.each_index {|i| select(i) if @list[i][:ext] == ext }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
change_color(normal_color, command_enabled?(index))
|
||||
draw_text(item_rect_for_text(index), command_name(index), alignment)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アライメントの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def alignment
|
||||
return 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定処理の有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def ok_enabled?
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ハンドラの呼び出し
|
||||
#--------------------------------------------------------------------------
|
||||
def call_ok_handler
|
||||
if handle?(current_symbol)
|
||||
call_handler(current_symbol)
|
||||
elsif handle?(:ok)
|
||||
super
|
||||
else
|
||||
activate
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
clear_command_list
|
||||
make_command_list
|
||||
create_contents
|
||||
super
|
||||
end
|
||||
end
|
||||
104
Scripts/Window_DebugLeft.rb
Normal file
104
Scripts/Window_DebugLeft.rb
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
#==============================================================================
|
||||
# ■ Window_DebugLeft
|
||||
#------------------------------------------------------------------------------
|
||||
# デバッグ画面で、スイッチや変数のブロックを指定するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_DebugLeft < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クラス変数
|
||||
#--------------------------------------------------------------------------
|
||||
@@last_top_row = 0 # 先頭の行 保存用
|
||||
@@last_index = 0 # カーソル位置 保存用
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :right_window # 右ウィンドウ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y)
|
||||
super(x, y, window_width, window_height)
|
||||
refresh
|
||||
self.top_row = @@last_top_row
|
||||
select(@@last_index)
|
||||
activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 164
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
Graphics.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
@item_max || 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
return unless @right_window
|
||||
@right_window.mode = mode
|
||||
@right_window.top_id = top_id
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● モードの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def mode
|
||||
index < @switch_max ? :switch : :variable
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭に表示する ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def top_id
|
||||
(index - (index < @switch_max ? 0 : @switch_max)) * 10 + 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
@switch_max = ($data_system.switches.size - 1 + 9) / 10
|
||||
@variable_max = ($data_system.variables.size - 1 + 9) / 10
|
||||
@item_max = @switch_max + @variable_max
|
||||
create_contents
|
||||
draw_all_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
if index < @switch_max
|
||||
n = index * 10
|
||||
text = sprintf("S [%04d-%04d]", n+1, n+10)
|
||||
else
|
||||
n = (index - @switch_max) * 10
|
||||
text = sprintf("V [%04d-%04d]", n+1, n+10)
|
||||
end
|
||||
draw_text(item_rect_for_text(index), text)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャンセルボタンが押されたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_cancel
|
||||
super
|
||||
@@last_top_row = top_row
|
||||
@@last_index = index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右ウィンドウの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def right_window=(right_window)
|
||||
@right_window = right_window
|
||||
update
|
||||
end
|
||||
end
|
||||
119
Scripts/Window_DebugRight.rb
Normal file
119
Scripts/Window_DebugRight.rb
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#==============================================================================
|
||||
# ■ Window_DebugRight
|
||||
#------------------------------------------------------------------------------
|
||||
# デバッグ画面で、スイッチや変数を個別に表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_DebugRight < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :mode # モード(:switch / :variable)
|
||||
attr_reader :top_id # 先頭に表示する ID
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#-------------------------------------------------------------------------
|
||||
def initialize(x, y, width)
|
||||
super(x, y, width, fitting_height(10))
|
||||
@mode = :switch
|
||||
@top_id = 1
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
return 10
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_all_items
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
data_id = @top_id + index
|
||||
id_text = sprintf("%04d:", data_id)
|
||||
id_width = text_size(id_text).width
|
||||
if @mode == :switch
|
||||
name = $data_system.switches[data_id]
|
||||
status = $game_switches[data_id] ? "[ON]" : "[OFF]"
|
||||
else
|
||||
name = $data_system.variables[data_id]
|
||||
status = $game_variables[data_id]
|
||||
end
|
||||
name = "" unless name
|
||||
rect = item_rect_for_text(index)
|
||||
change_color(normal_color)
|
||||
draw_text(rect, id_text)
|
||||
rect.x += id_width
|
||||
rect.width -= id_width + 60
|
||||
draw_text(rect, name)
|
||||
rect.width += 60
|
||||
draw_text(rect, status, 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● モードの設定
|
||||
# mode : 新しいモード
|
||||
#--------------------------------------------------------------------------
|
||||
def mode=(mode)
|
||||
if @mode != mode
|
||||
@mode = mode
|
||||
refresh
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭に表示する ID の設定
|
||||
# id : 新しい ID
|
||||
#--------------------------------------------------------------------------
|
||||
def top_id=(id)
|
||||
if @top_id != id
|
||||
@top_id = id
|
||||
refresh
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択中 ID の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_id
|
||||
top_id + index
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_switch_mode if active && mode == :switch
|
||||
update_variable_mode if active && mode == :variable
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● スイッチモード時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_switch_mode
|
||||
if Input.trigger?(:C)
|
||||
Sound.play_ok
|
||||
$game_switches[current_id] = !$game_switches[current_id]
|
||||
redraw_current_item
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 変数モード時の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_variable_mode
|
||||
return unless $game_variables[current_id].is_a?(Numeric)
|
||||
value = $game_variables[current_id]
|
||||
value += 1 if Input.repeat?(:RIGHT)
|
||||
value -= 1 if Input.repeat?(:LEFT)
|
||||
value += 10 if Input.repeat?(:R)
|
||||
value -= 10 if Input.repeat?(:L)
|
||||
if $game_variables[current_id] != value
|
||||
$game_variables[current_id] = value
|
||||
Sound.play_cursor
|
||||
redraw_current_item
|
||||
end
|
||||
end
|
||||
end
|
||||
35
Scripts/Window_EquipCommand.rb
Normal file
35
Scripts/Window_EquipCommand.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#==============================================================================
|
||||
# ■ Window_EquipCommand
|
||||
#------------------------------------------------------------------------------
|
||||
# スキル画面で、コマンド(装備変更、最強装備など)を選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_EquipCommand < Window_HorzCommand
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y, width)
|
||||
@window_width = width
|
||||
super(x, y)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
@window_width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 桁数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def col_max
|
||||
return 3
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
add_command(Vocab::equip2, :equip)
|
||||
add_command(Vocab::optimize, :optimize)
|
||||
add_command(Vocab::clear, :clear)
|
||||
end
|
||||
end
|
||||
77
Scripts/Window_EquipItem.rb
Normal file
77
Scripts/Window_EquipItem.rb
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#==============================================================================
|
||||
# ■ Window_EquipItem
|
||||
#------------------------------------------------------------------------------
|
||||
# 装備画面で、装備変更の候補となるアイテムの一覧を表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_EquipItem < Window_ItemList
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :status_window # ステータスウィンドウ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y, width, height)
|
||||
super
|
||||
@actor = nil
|
||||
@slot_id = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def actor=(actor)
|
||||
return if @actor == actor
|
||||
@actor = actor
|
||||
refresh
|
||||
self.oy = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備スロット ID の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def slot_id=(slot_id)
|
||||
return if @slot_id == slot_id
|
||||
@slot_id = slot_id
|
||||
refresh
|
||||
self.oy = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムをリストに含めるかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def include?(item)
|
||||
return true if item == nil
|
||||
return false unless item.is_a?(RPG::EquipItem)
|
||||
return false if @slot_id < 0
|
||||
return false if item.etype_id != @actor.equip_slots[@slot_id]
|
||||
return @actor.equippable?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムを許可状態で表示するかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def enable?(item)
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前回の選択位置を復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def select_last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def status_window=(status_window)
|
||||
@status_window = status_window
|
||||
call_update_help
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプテキスト更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_help
|
||||
super
|
||||
if @actor && @status_window
|
||||
temp_actor = Marshal.load(Marshal.dump(@actor))
|
||||
temp_actor.force_change_equip(@slot_id, item)
|
||||
@status_window.set_temp_actor(temp_actor)
|
||||
end
|
||||
end
|
||||
end
|
||||
110
Scripts/Window_EquipSlot.rb
Normal file
110
Scripts/Window_EquipSlot.rb
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#==============================================================================
|
||||
# ■ Window_EquipSlot
|
||||
#------------------------------------------------------------------------------
|
||||
# 装備画面で、アクターが現在装備しているアイテムを表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_EquipSlot < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :status_window # ステータスウィンドウ
|
||||
attr_reader :item_window # アイテムウィンドウ
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y, width)
|
||||
super(x, y, width, window_height)
|
||||
@actor = nil
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(visible_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 5
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def actor=(actor)
|
||||
return if @actor == actor
|
||||
@actor = actor
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
@item_window.slot_id = index if @item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
@actor ? @actor.equip_slots.size : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item
|
||||
@actor ? @actor.equips[index] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
return unless @actor
|
||||
rect = item_rect_for_text(index)
|
||||
change_color(system_color, enable?(index))
|
||||
draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
|
||||
draw_item_name(@actor.equips[index], rect.x + 92, rect.y, enable?(index))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備スロットの名前を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def slot_name(index)
|
||||
@actor ? Vocab::etype(@actor.equip_slots[index]) : ""
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備スロットを許可状態で表示するかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def enable?(index)
|
||||
@actor ? @actor.equip_change_ok?(index) : false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目の有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_item_enabled?
|
||||
enable?(index)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ステータスウィンドウの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def status_window=(status_window)
|
||||
@status_window = status_window
|
||||
call_update_help
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_window=(item_window)
|
||||
@item_window = item_window
|
||||
update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプテキスト更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_help
|
||||
super
|
||||
@help_window.set_item(item) if @help_window
|
||||
@status_window.set_temp_actor(nil) if @status_window
|
||||
end
|
||||
end
|
||||
97
Scripts/Window_EquipStatus.rb
Normal file
97
Scripts/Window_EquipStatus.rb
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
#==============================================================================
|
||||
# ■ Window_EquipStatus
|
||||
#------------------------------------------------------------------------------
|
||||
# 装備画面で、アクターの能力値変化を表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_EquipStatus < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y)
|
||||
super(x, y, window_width, window_height)
|
||||
@actor = nil
|
||||
@temp_actor = nil
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 208
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(visible_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 7
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アクターの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def actor=(actor)
|
||||
return if @actor == actor
|
||||
@actor = actor
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_actor_name(@actor, 4, 0) if @actor
|
||||
6.times {|i| draw_item(0, line_height * (1 + i), 2 + i) }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備変更後の一時アクター設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_temp_actor(temp_actor)
|
||||
return if @temp_actor == temp_actor
|
||||
@temp_actor = temp_actor
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(x, y, param_id)
|
||||
draw_param_name(x + 4, y, param_id)
|
||||
draw_current_param(x + 90, y, param_id) if @actor
|
||||
draw_right_arrow(x + 126, y)
|
||||
draw_new_param(x + 150, y, param_id) if @temp_actor
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 能力値の名前を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_param_name(x, y, param_id)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 80, line_height, Vocab::param(param_id))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 現在の能力値を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_current_param(x, y, param_id)
|
||||
change_color(normal_color)
|
||||
draw_text(x, y, 32, line_height, @actor.param(param_id), 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 右向き矢印を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_right_arrow(x, y)
|
||||
change_color(system_color)
|
||||
draw_text(x, y, 22, line_height, "→", 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 装備変更後の能力値を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_new_param(x, y, param_id)
|
||||
new_value = @temp_actor.param(param_id)
|
||||
change_color(param_change_color(new_value - @actor.param(param_id)))
|
||||
draw_text(x, y, 32, line_height, new_value, 2)
|
||||
end
|
||||
end
|
||||
38
Scripts/Window_GameEnd.rb
Normal file
38
Scripts/Window_GameEnd.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#==============================================================================
|
||||
# ■ Window_GameEnd
|
||||
#------------------------------------------------------------------------------
|
||||
# ゲーム終了画面で、タイトルへ/シャットダウンを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_GameEnd < Window_Command
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0)
|
||||
update_placement
|
||||
self.openness = 0
|
||||
open
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_placement
|
||||
self.x = (Graphics.width - width) / 2
|
||||
self.y = (Graphics.height - height) / 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
add_command(Vocab::to_title, :to_title)
|
||||
add_command(Vocab::shutdown, :shutdown)
|
||||
add_command(Vocab::cancel, :cancel)
|
||||
end
|
||||
end
|
||||
47
Scripts/Window_Gold.rb
Normal file
47
Scripts/Window_Gold.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#==============================================================================
|
||||
# ■ Window_Gold
|
||||
#------------------------------------------------------------------------------
|
||||
# 所持金を表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_Gold < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0, window_width, fitting_height(1))
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 所持金の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def value
|
||||
$game_party.gold
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通貨単位の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def currency_unit
|
||||
Vocab::currency_unit
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを開く
|
||||
#--------------------------------------------------------------------------
|
||||
def open
|
||||
refresh
|
||||
super
|
||||
end
|
||||
end
|
||||
43
Scripts/Window_Help.rb
Normal file
43
Scripts/Window_Help.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#==============================================================================
|
||||
# ■ Window_Help
|
||||
#------------------------------------------------------------------------------
|
||||
# スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_Help < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(line_number = 2)
|
||||
super(0, 0, Graphics.width, fitting_height(line_number))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● テキスト設定
|
||||
#--------------------------------------------------------------------------
|
||||
def set_text(text)
|
||||
if text != @text
|
||||
@text = text
|
||||
refresh
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● クリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear
|
||||
set_text("")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテム設定
|
||||
# item : スキル、アイテム等
|
||||
#--------------------------------------------------------------------------
|
||||
def set_item(item)
|
||||
set_text(item ? item.description : "")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_text_ex(4, 0, @text)
|
||||
end
|
||||
end
|
||||
106
Scripts/Window_HorzCommand.rb
Normal file
106
Scripts/Window_HorzCommand.rb
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#==============================================================================
|
||||
# ■ Window_HorzCommand
|
||||
#------------------------------------------------------------------------------
|
||||
# 横選択形式のコマンドウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_HorzCommand < Window_Command
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 桁数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def col_max
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 横に項目が並ぶときの空白の幅を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def spacing
|
||||
return 8
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の幅を計算
|
||||
#--------------------------------------------------------------------------
|
||||
def contents_width
|
||||
(item_width + spacing) * item_max - spacing
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ内容の高さを計算
|
||||
#--------------------------------------------------------------------------
|
||||
def contents_height
|
||||
item_height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭の桁の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def top_col
|
||||
ox / (item_width + spacing)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 先頭の桁の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def top_col=(col)
|
||||
col = 0 if col < 0
|
||||
col = col_max - 1 if col > col_max - 1
|
||||
self.ox = col * (item_width + spacing)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 末尾の桁の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def bottom_col
|
||||
top_col + col_max - 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 末尾の桁の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def bottom_col=(col)
|
||||
self.top_col = col - (col_max - 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソル位置が画面内になるようにスクロール
|
||||
#--------------------------------------------------------------------------
|
||||
def ensure_cursor_visible
|
||||
self.top_col = index if index < top_col
|
||||
self.bottom_col = index if index > bottom_col
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目を描画する矩形の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_rect(index)
|
||||
rect = super
|
||||
rect.x = index * (item_width + spacing)
|
||||
rect.y = 0
|
||||
rect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アライメントの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def alignment
|
||||
return 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを下に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_down(wrap = false)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを上に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_up(wrap = false)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを 1 ページ後ろに移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_pagedown
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カーソルを 1 ページ前に移動
|
||||
#--------------------------------------------------------------------------
|
||||
def cursor_pageup
|
||||
end
|
||||
end
|
||||
54
Scripts/Window_ItemCategory.rb
Normal file
54
Scripts/Window_ItemCategory.rb
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#==============================================================================
|
||||
# ■ Window_ItemCategory
|
||||
#------------------------------------------------------------------------------
|
||||
# アイテム画面またはショップ画面で、通常アイテムや装備品の分類を選択するウィ
|
||||
# ンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_ItemCategory < Window_HorzCommand
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :item_window
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 桁数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def col_max
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
@item_window.category = current_symbol if @item_window
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
add_command(Vocab::item, :item)
|
||||
add_command(Vocab::weapon, :weapon)
|
||||
add_command(Vocab::armor, :armor)
|
||||
add_command(Vocab::key_item, :key_item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムウィンドウの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def item_window=(item_window)
|
||||
@item_window = item_window
|
||||
update
|
||||
end
|
||||
end
|
||||
117
Scripts/Window_ItemList.rb
Normal file
117
Scripts/Window_ItemList.rb
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#==============================================================================
|
||||
# ■ Window_ItemList
|
||||
#------------------------------------------------------------------------------
|
||||
# アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_ItemList < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y, width, height)
|
||||
super
|
||||
@category = :none
|
||||
@data = []
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● カテゴリの設定
|
||||
#--------------------------------------------------------------------------
|
||||
def category=(category)
|
||||
return if @category == category
|
||||
@category = category
|
||||
refresh
|
||||
self.oy = 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 桁数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def col_max
|
||||
return 2
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
@data ? @data.size : 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item
|
||||
@data && index >= 0 ? @data[index] : nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択項目の有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def current_item_enabled?
|
||||
enable?(@data[index])
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムをリストに含めるかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def include?(item)
|
||||
case @category
|
||||
when :item
|
||||
item.is_a?(RPG::Item) && !item.key_item?
|
||||
when :weapon
|
||||
item.is_a?(RPG::Weapon)
|
||||
when :armor
|
||||
item.is_a?(RPG::Armor)
|
||||
when :key_item
|
||||
item.is_a?(RPG::Item) && item.key_item?
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムを許可状態で表示するかどうか
|
||||
#--------------------------------------------------------------------------
|
||||
def enable?(item)
|
||||
$game_party.usable?(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_item_list
|
||||
@data = $game_party.all_items.select {|item| include?(item) }
|
||||
@data.push(nil) if include?(nil)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前回の選択位置を復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def select_last
|
||||
select(@data.index($game_party.last_item.object) || 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
item = @data[index]
|
||||
if item
|
||||
rect = item_rect(index)
|
||||
rect.width -= 4
|
||||
draw_item_name(item, rect.x, rect.y, enable?(item))
|
||||
draw_item_number(rect, item)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの個数を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item_number(rect, item)
|
||||
draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ヘルプテキスト更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_help
|
||||
@help_window.set_item(item)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
make_item_list
|
||||
create_contents
|
||||
draw_all_items
|
||||
end
|
||||
end
|
||||
55
Scripts/Window_KeyItem.rb
Normal file
55
Scripts/Window_KeyItem.rb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#==============================================================================
|
||||
# ■ Window_KeyItem
|
||||
#------------------------------------------------------------------------------
|
||||
# イベントコマンド[アイテム選択の処理]に使用するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_KeyItem < Window_ItemList
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(message_window)
|
||||
@message_window = message_window
|
||||
super(0, 0, Graphics.width, fitting_height(4))
|
||||
self.openness = 0
|
||||
deactivate
|
||||
set_handler(:ok, method(:on_ok))
|
||||
set_handler(:cancel, method(:on_cancel))
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力処理の開始
|
||||
#--------------------------------------------------------------------------
|
||||
def start
|
||||
self.category = :key_item
|
||||
update_placement
|
||||
refresh
|
||||
select(0)
|
||||
open
|
||||
activate
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_placement
|
||||
if @message_window.y >= Graphics.height / 2
|
||||
self.y = 0
|
||||
else
|
||||
self.y = Graphics.height - height
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_ok
|
||||
result = item ? item.id : 0
|
||||
$game_variables[$game_message.item_choice_variable_id] = result
|
||||
close
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● キャンセル時の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def on_cancel
|
||||
$game_variables[$game_message.item_choice_variable_id] = 0
|
||||
close
|
||||
end
|
||||
end
|
||||
96
Scripts/Window_MapName.rb
Normal file
96
Scripts/Window_MapName.rb
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#==============================================================================
|
||||
# ■ Window_MapName
|
||||
#------------------------------------------------------------------------------
|
||||
# マップ名を表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_MapName < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0, window_width, fitting_height(1))
|
||||
self.opacity = 0
|
||||
self.contents_opacity = 0
|
||||
@show_count = 0
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 240
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
if @show_count > 0 && $game_map.name_display
|
||||
update_fadein
|
||||
@show_count -= 1
|
||||
else
|
||||
update_fadeout
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードインの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_fadein
|
||||
self.contents_opacity += 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フェードアウトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_fadeout
|
||||
self.contents_opacity -= 16
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを開く
|
||||
#--------------------------------------------------------------------------
|
||||
def open
|
||||
refresh
|
||||
@show_count = 150
|
||||
self.contents_opacity = 0
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを閉じる
|
||||
#--------------------------------------------------------------------------
|
||||
def close
|
||||
@show_count = 0
|
||||
self
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
unless $game_map.display_name.empty?
|
||||
draw_background(contents.rect)
|
||||
draw_text(contents.rect, $game_map.display_name, 1)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_background(rect)
|
||||
temp_rect = rect.clone
|
||||
temp_rect.width /= 2
|
||||
contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
|
||||
temp_rect.x = temp_rect.width
|
||||
contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景色 1 の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_color1
|
||||
Color.new(0, 0, 0, 192)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景色 2 の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_color2
|
||||
Color.new(0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
42
Scripts/Window_MenuActor.rb
Normal file
42
Scripts/Window_MenuActor.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#==============================================================================
|
||||
# ■ Window_MenuActor
|
||||
#------------------------------------------------------------------------------
|
||||
# アイテムやスキルの使用対象となるアクターを選択するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_MenuActor < Window_MenuStatus
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0)
|
||||
self.visible = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ボタンが押されたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_ok
|
||||
$game_party.target_actor = $game_party.members[index] unless @cursor_all
|
||||
call_ok_handler
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前回の選択位置を復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def select_last
|
||||
select($game_party.target_actor.index || 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムのためのカーソル位置設定
|
||||
#--------------------------------------------------------------------------
|
||||
def select_for_item(item)
|
||||
@cursor_fix = item.for_user?
|
||||
@cursor_all = item.for_all?
|
||||
if @cursor_fix
|
||||
select($game_party.menu_actor.index)
|
||||
elsif @cursor_all
|
||||
select(0)
|
||||
else
|
||||
select_last
|
||||
end
|
||||
end
|
||||
end
|
||||
106
Scripts/Window_MenuCommand.rb
Normal file
106
Scripts/Window_MenuCommand.rb
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#==============================================================================
|
||||
# ■ Window_MenuCommand
|
||||
#------------------------------------------------------------------------------
|
||||
# メニュー画面で表示するコマンドウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_MenuCommand < Window_Command
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンド選択位置の初期化(クラスメソッド)
|
||||
#--------------------------------------------------------------------------
|
||||
def self.init_command_position
|
||||
@@last_command_symbol = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0)
|
||||
select_last
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
return 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
item_max
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● コマンドリストの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def make_command_list
|
||||
add_main_commands
|
||||
add_formation_command
|
||||
add_original_commands
|
||||
add_save_command
|
||||
add_game_end_command
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 主要コマンドをリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_main_commands
|
||||
add_command(Vocab::item, :item, main_commands_enabled)
|
||||
add_command(Vocab::skill, :skill, main_commands_enabled)
|
||||
add_command(Vocab::equip, :equip, main_commands_enabled)
|
||||
add_command(Vocab::status, :status, main_commands_enabled)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 並び替えをコマンドリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_formation_command
|
||||
add_command(Vocab::formation, :formation, formation_enabled)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 独自コマンドの追加用
|
||||
#--------------------------------------------------------------------------
|
||||
def add_original_commands
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブをコマンドリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_save_command
|
||||
add_command(Vocab::save, :save, save_enabled)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ゲーム終了をコマンドリストに追加
|
||||
#--------------------------------------------------------------------------
|
||||
def add_game_end_command
|
||||
add_command(Vocab::game_end, :game_end)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 主要コマンドの有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def main_commands_enabled
|
||||
$game_party.exists
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 並び替えの有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def formation_enabled
|
||||
$game_party.members.size >= 2 && !$game_system.formation_disabled
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● セーブの有効状態を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def save_enabled
|
||||
!$game_system.save_disabled
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ボタンが押されたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_ok
|
||||
@@last_command_symbol = current_symbol
|
||||
super
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前回の選択位置を復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def select_last
|
||||
select_symbol(@@last_command_symbol)
|
||||
end
|
||||
end
|
||||
85
Scripts/Window_MenuStatus.rb
Normal file
85
Scripts/Window_MenuStatus.rb
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#==============================================================================
|
||||
# ■ Window_MenuStatus
|
||||
#------------------------------------------------------------------------------
|
||||
# メニュー画面でパーティメンバーのステータスを表示するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_MenuStatus < Window_Selectable
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :pending_index # 保留位置(並び替え用)
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(x, y)
|
||||
super(x, y, window_width, window_height)
|
||||
@pending_index = -1
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width - 160
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
Graphics.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_max
|
||||
$game_party.members.size
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の高さを取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_height
|
||||
(height - standard_padding * 2) / 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item(index)
|
||||
actor = $game_party.members[index]
|
||||
enabled = $game_party.battle_members.include?(actor)
|
||||
rect = item_rect(index)
|
||||
draw_item_background(index)
|
||||
draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
|
||||
draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目の背景を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_item_background(index)
|
||||
if index == @pending_index
|
||||
contents.fill_rect(item_rect(index), pending_color)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 決定ボタンが押されたときの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_ok
|
||||
super
|
||||
$game_party.menu_actor = $game_party.members[index]
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 前回の選択位置を復帰
|
||||
#--------------------------------------------------------------------------
|
||||
def select_last
|
||||
select($game_party.menu_actor.index || 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 保留位置(並び替え用)の設定
|
||||
#--------------------------------------------------------------------------
|
||||
def pending_index=(index)
|
||||
last_pending_index = @pending_index
|
||||
@pending_index = index
|
||||
redraw_item(@pending_index)
|
||||
redraw_item(last_pending_index)
|
||||
end
|
||||
end
|
||||
396
Scripts/Window_Message.rb
Normal file
396
Scripts/Window_Message.rb
Normal file
|
|
@ -0,0 +1,396 @@
|
|||
#==============================================================================
|
||||
# ■ Window_Message
|
||||
#------------------------------------------------------------------------------
|
||||
# 文章表示に使うメッセージウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_Message < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
super(0, 0, window_width, window_height)
|
||||
self.z = 200
|
||||
self.openness = 0
|
||||
create_all_windows
|
||||
create_back_bitmap
|
||||
create_back_sprite
|
||||
clear_instance_variables
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ幅の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_width
|
||||
Graphics.width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ高さの取得
|
||||
#--------------------------------------------------------------------------
|
||||
def window_height
|
||||
fitting_height(visible_line_number)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● インスタンス変数のクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_instance_variables
|
||||
@fiber = nil # ファイバー
|
||||
@background = 0 # 背景タイプ
|
||||
@position = 2 # 表示位置
|
||||
clear_flags
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フラグのクリア
|
||||
#--------------------------------------------------------------------------
|
||||
def clear_flags
|
||||
@show_fast = false # 早送りフラグ
|
||||
@line_show_fast = false # 行単位早送りフラグ
|
||||
@pause_skip = false # 入力待ち省略フラグ
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 表示行数の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def visible_line_number
|
||||
return 4
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose
|
||||
super
|
||||
dispose_all_windows
|
||||
dispose_back_bitmap
|
||||
dispose_back_sprite
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● フレーム更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update
|
||||
super
|
||||
update_all_windows
|
||||
update_back_sprite
|
||||
update_fiber
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ファイバーの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_fiber
|
||||
if @fiber
|
||||
@fiber.resume
|
||||
elsif $game_message.busy? && !$game_message.scroll_mode
|
||||
@fiber = Fiber.new { fiber_main }
|
||||
@fiber.resume
|
||||
else
|
||||
$game_message.visible = false
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_all_windows
|
||||
@gold_window = Window_Gold.new
|
||||
@gold_window.x = Graphics.width - @gold_window.width
|
||||
@gold_window.y = 0
|
||||
@gold_window.openness = 0
|
||||
@choice_window = Window_ChoiceList.new(self)
|
||||
@number_window = Window_NumberInput.new(self)
|
||||
@item_window = Window_KeyItem.new(self)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景ビットマップの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_back_bitmap
|
||||
@back_bitmap = Bitmap.new(width, height)
|
||||
rect1 = Rect.new(0, 0, width, 12)
|
||||
rect2 = Rect.new(0, 12, width, height - 24)
|
||||
rect3 = Rect.new(0, height - 12, width, 12)
|
||||
@back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
|
||||
@back_bitmap.fill_rect(rect2, back_color1)
|
||||
@back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景色 1 の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_color1
|
||||
Color.new(0, 0, 0, 160)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景色 2 の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def back_color2
|
||||
Color.new(0, 0, 0, 0)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景スプライトの作成
|
||||
#--------------------------------------------------------------------------
|
||||
def create_back_sprite
|
||||
@back_sprite = Sprite.new
|
||||
@back_sprite.bitmap = @back_bitmap
|
||||
@back_sprite.visible = false
|
||||
@back_sprite.z = z - 1
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_all_windows
|
||||
@gold_window.dispose
|
||||
@choice_window.dispose
|
||||
@number_window.dispose
|
||||
@item_window.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景ビットマップの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_back_bitmap
|
||||
@back_bitmap.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景スプライトの解放
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_back_sprite
|
||||
@back_sprite.dispose
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_all_windows
|
||||
@gold_window.update
|
||||
@choice_window.update
|
||||
@number_window.update
|
||||
@item_window.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景スプライトの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_back_sprite
|
||||
@back_sprite.visible = (@background == 1)
|
||||
@back_sprite.y = y
|
||||
@back_sprite.opacity = openness
|
||||
@back_sprite.update
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ファイバーのメイン処理
|
||||
#--------------------------------------------------------------------------
|
||||
def fiber_main
|
||||
$game_message.visible = true
|
||||
update_background
|
||||
update_placement
|
||||
loop do
|
||||
process_all_text if $game_message.has_text?
|
||||
process_input
|
||||
$game_message.clear
|
||||
@gold_window.close
|
||||
Fiber.yield
|
||||
break unless text_continue?
|
||||
end
|
||||
close_and_wait
|
||||
$game_message.visible = false
|
||||
@fiber = nil
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ背景の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_background
|
||||
@background = $game_message.background
|
||||
self.opacity = @background == 0 ? 255 : 0
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウ位置の更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_placement
|
||||
@position = $game_message.position
|
||||
self.y = @position * (Graphics.height - height) / 2
|
||||
@gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全テキストの処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_all_text
|
||||
open_and_wait
|
||||
text = convert_escape_characters($game_message.all_text)
|
||||
pos = {}
|
||||
new_page(text, pos)
|
||||
process_character(text.slice!(0, 1), text, pos) until text.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_input
|
||||
if $game_message.choice?
|
||||
input_choice
|
||||
elsif $game_message.num_input?
|
||||
input_number
|
||||
elsif $game_message.item_choice?
|
||||
input_item
|
||||
else
|
||||
input_pause unless @pause_skip
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを開き、完全に開くまで待つ
|
||||
#--------------------------------------------------------------------------
|
||||
def open_and_wait
|
||||
open
|
||||
Fiber.yield until open?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウィンドウを閉じ、完全に閉じるまで待つ
|
||||
#--------------------------------------------------------------------------
|
||||
def close_and_wait
|
||||
close
|
||||
Fiber.yield until all_close?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 全ウィンドウが完全に閉じているか判定
|
||||
#--------------------------------------------------------------------------
|
||||
def all_close?
|
||||
close? && @choice_window.close? &&
|
||||
@number_window.close? && @item_window.close?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文章を続けて表示するか判定
|
||||
#--------------------------------------------------------------------------
|
||||
def text_continue?
|
||||
$game_message.has_text? && !settings_changed?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 背景と位置の変更判定
|
||||
#--------------------------------------------------------------------------
|
||||
def settings_changed?
|
||||
@background != $game_message.background ||
|
||||
@position != $game_message.position
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● ウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait(duration)
|
||||
duration.times { Fiber.yield }
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 早送りフラグの更新
|
||||
#--------------------------------------------------------------------------
|
||||
def update_show_fast
|
||||
@show_fast = true if Input.trigger?(:C)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一文字出力後のウェイト
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_one_character
|
||||
update_show_fast
|
||||
Fiber.yield unless @show_fast || @line_show_fast
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改ページ処理
|
||||
#--------------------------------------------------------------------------
|
||||
def new_page(text, pos)
|
||||
contents.clear
|
||||
draw_face($game_message.face_name, $game_message.face_index, 0, 0)
|
||||
reset_font_settings
|
||||
pos[:x] = new_line_x
|
||||
pos[:y] = 0
|
||||
pos[:new_x] = new_line_x
|
||||
pos[:height] = calc_line_height(text)
|
||||
clear_flags
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改行位置の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def new_line_x
|
||||
$game_message.face_name.empty? ? 0 : 112
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 通常文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_normal_character(c, pos)
|
||||
super
|
||||
wait_for_one_character
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改行文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_new_line(text, pos)
|
||||
@line_show_fast = false
|
||||
super
|
||||
if need_new_page?(text, pos)
|
||||
input_pause
|
||||
new_page(text, pos)
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改ページが必要か判定
|
||||
#--------------------------------------------------------------------------
|
||||
def need_new_page?(text, pos)
|
||||
pos[:y] + pos[:height] > contents.height && !text.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 改ページ文字の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_new_page(text, pos)
|
||||
text.slice!(/^\n/)
|
||||
input_pause
|
||||
new_page(text, pos)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字によるアイコン描画の処理
|
||||
#--------------------------------------------------------------------------
|
||||
def process_draw_icon(icon_index, pos)
|
||||
super
|
||||
wait_for_one_character
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 制御文字の処理
|
||||
# code : 制御文字の本体部分(「\C[1]」なら「C」)
|
||||
# text : 描画処理中の文字列バッファ(必要なら破壊的に変更)
|
||||
# pos : 描画位置 {:x, :y, :new_x, :height}
|
||||
#--------------------------------------------------------------------------
|
||||
def process_escape_character(code, text, pos)
|
||||
case code.upcase
|
||||
when '$'
|
||||
@gold_window.open
|
||||
when '.'
|
||||
wait(15)
|
||||
when '|'
|
||||
wait(60)
|
||||
when '!'
|
||||
input_pause
|
||||
when '>'
|
||||
@line_show_fast = true
|
||||
when '<'
|
||||
@line_show_fast = false
|
||||
when '^'
|
||||
@pause_skip = true
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 入力待ち処理
|
||||
#--------------------------------------------------------------------------
|
||||
def input_pause
|
||||
self.pause = true
|
||||
wait(10)
|
||||
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
|
||||
Input.update
|
||||
self.pause = false
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 選択肢の入力処理
|
||||
#--------------------------------------------------------------------------
|
||||
def input_choice
|
||||
@choice_window.start
|
||||
Fiber.yield while @choice_window.active
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 数値の入力処理
|
||||
#--------------------------------------------------------------------------
|
||||
def input_number
|
||||
@number_window.start
|
||||
Fiber.yield while @number_window.active
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● アイテムの選択処理
|
||||
#--------------------------------------------------------------------------
|
||||
def input_item
|
||||
@item_window.start
|
||||
Fiber.yield while @item_window.active
|
||||
end
|
||||
end
|
||||
129
Scripts/Window_NameEdit.rb
Normal file
129
Scripts/Window_NameEdit.rb
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
#==============================================================================
|
||||
# ■ Window_NameEdit
|
||||
#------------------------------------------------------------------------------
|
||||
# 名前入力画面で、名前を編集するウィンドウです。
|
||||
#==============================================================================
|
||||
|
||||
class Window_NameEdit < Window_Base
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 公開インスタンス変数
|
||||
#--------------------------------------------------------------------------
|
||||
attr_reader :name # 名前
|
||||
attr_reader :index # カーソル位置
|
||||
attr_reader :max_char # 最大文字数
|
||||
#--------------------------------------------------------------------------
|
||||
# ● オブジェクト初期化
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(actor, max_char)
|
||||
x = (Graphics.width - 360) / 2
|
||||
y = (Graphics.height - (fitting_height(4) + fitting_height(9) + 8)) / 2
|
||||
super(x, y, 360, fitting_height(4))
|
||||
@actor = actor
|
||||
@max_char = max_char
|
||||
@default_name = @name = actor.name[0, @max_char]
|
||||
@index = @name.size
|
||||
deactivate
|
||||
refresh
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● デフォルトの名前に戻す
|
||||
#--------------------------------------------------------------------------
|
||||
def restore_default
|
||||
@name = @default_name
|
||||
@index = @name.size
|
||||
refresh
|
||||
return !@name.empty?
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文字の追加
|
||||
# ch : 追加する文字
|
||||
#--------------------------------------------------------------------------
|
||||
def add(ch)
|
||||
return false if @index >= @max_char
|
||||
@name += ch
|
||||
@index += 1
|
||||
refresh
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 一文字戻す
|
||||
#--------------------------------------------------------------------------
|
||||
def back
|
||||
return false if @index == 0
|
||||
@index -= 1
|
||||
@name = @name[0, @index]
|
||||
refresh
|
||||
return true
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 顔グラフィックの幅を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def face_width
|
||||
return 96
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文字の幅を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def char_width
|
||||
text_size($game_system.japanese? ? "あ" : "A").width
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 名前を描画する左端の座標を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def left
|
||||
name_center = (contents_width + face_width) / 2
|
||||
name_width = (@max_char + 1) * char_width
|
||||
return [name_center - name_width / 2, contents_width - name_width].min
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 項目を描画する矩形の取得
|
||||
#--------------------------------------------------------------------------
|
||||
def item_rect(index)
|
||||
Rect.new(left + index * char_width, 36, char_width, line_height)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 下線の矩形を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def underline_rect(index)
|
||||
rect = item_rect(index)
|
||||
rect.x += 1
|
||||
rect.y += rect.height - 4
|
||||
rect.width -= 2
|
||||
rect.height = 2
|
||||
rect
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 下線の色を取得
|
||||
#--------------------------------------------------------------------------
|
||||
def underline_color
|
||||
color = normal_color
|
||||
color.alpha = 48
|
||||
color
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 下線を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_underline(index)
|
||||
contents.fill_rect(underline_rect(index), underline_color)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● 文字を描画
|
||||
#--------------------------------------------------------------------------
|
||||
def draw_char(index)
|
||||
rect = item_rect(index)
|
||||
rect.x -= 1
|
||||
rect.width += 4
|
||||
change_color(normal_color)
|
||||
draw_text(rect, @name[index] || "")
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# ● リフレッシュ
|
||||
#--------------------------------------------------------------------------
|
||||
def refresh
|
||||
contents.clear
|
||||
draw_actor_face(@actor, 0, 0)
|
||||
@max_char.times {|i| draw_underline(i) }
|
||||
@name.size.times {|i| draw_char(i) }
|
||||
cursor_rect.set(item_rect(@index))
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue