Post by Elkat on Sept 16, 2017 1:23:49 GMT
I'm writing this thread to deal with the current Mindcontrol bug as well as hopefully find a way to display both lines of text for items and skills during battle. I tried to post all the scripts at once, but apparently that exceed the character limit for a post so I will post one at a time.
Turns out that I hit the character limit for this post. I will post the rest in another post.
#==============================================================================
# ■ Game_BattlerBase
#------------------------------------------------------------------------------
# バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ
# のクラスは Game_Battler クラスのスーパークラスとして使用されます。
#==============================================================================
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 特徴を保持する全オブジェクトの配列取得
#--------------------------------------------------------------------------
alias tmsrpg_game_battlerbase_feature_objects feature_objects
def feature_objects
result = tmsrpg_game_battlerbase_feature_objects
if SceneManager.scene_is?(Scene_SrpgMap) && tile_state_object
result += [tile_state_object]
end
result
end
#--------------------------------------------------------------------------
# ○ 地形効果ステートオブジェクトを返す
#--------------------------------------------------------------------------
def tile_state_object
return nil unless @tile_state_id
$data_states[@tile_state_id]
end
#--------------------------------------------------------------------------
# ○ 移動力を返す
#--------------------------------------------------------------------------
def mov
feature_objects.inject(0) {|result, object| result + object.mov }
end
#--------------------------------------------------------------------------
# ○ 連携力を返す
#--------------------------------------------------------------------------
def chain
feature_objects.inject(0) {|result, object| result + object.chain }
end
#--------------------------------------------------------------------------
# ○ 索敵力を返す
#--------------------------------------------------------------------------
def search
feature_objects.inject(0) {|result, object| result + object.search }
end
#--------------------------------------------------------------------------
# ○ 浮遊状態かどうかを返す
#--------------------------------------------------------------------------
def float?
feature_objects.any? {|object| object.float? }
end
#--------------------------------------------------------------------------
# ○ 水上移動状態かどうかを返す
#--------------------------------------------------------------------------
def ship?
feature_objects.any? {|object| object.ship? }
end
#--------------------------------------------------------------------------
# ○ ノックバックガード率を返す
#--------------------------------------------------------------------------
def knock_back_guard
feature_objects.inject(0) {|result, object| result + object.knock_back_guard }
end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
# スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● スキル/アイテムの回避率計算
#--------------------------------------------------------------------------
alias tmsrpg_game_battler_item_eva item_eva
def item_eva(user, item)
result = tmsrpg_game_battler_item_eva(user, item)
if SceneManager.scene_is?(Scene_SrpgMap)
result *= TMSRPG::DIR_EVA_RATE if @dir_penalty
end
result
end
#--------------------------------------------------------------------------
# ● 防御修正の適用
#--------------------------------------------------------------------------
alias tmsrpg_game_battler_apply_guard apply_guard
def apply_guard(damage)
if SceneManager.scene_is?(Scene_SrpgMap) && damage > 0
damage *= TMSRPG::DIR_PENALTY_RATE if @dir_penalty
damage *= $game_srpgmap.chain_damage_rate
end
tmsrpg_game_battler_apply_guard(damage)
damage / (damage > 0 && guard? ? 2 * grd : 1)
end
#--------------------------------------------------------------------------
# ○ 向きによるダメージペナルティ状態のセット
#--------------------------------------------------------------------------
def set_dir_penalty(penalty)
@dir_penalty = penalty
end
#--------------------------------------------------------------------------
# ○ 地形効果ステートのセット
#--------------------------------------------------------------------------
def set_tile_state(state_id)
state_id = 0 if float? || state_resist?(state_id)
@tile_state_id = state_id
end
#--------------------------------------------------------------------------
# ○ ダメージ結果予測値を返す
#--------------------------------------------------------------------------
def test_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_guard(value)
item.effects.each do |effect|
case effect.code
when 11
value -= mhp * effect.value1 + effect.value2 if item.damage.to_hp?
when 12
value -= mmp * effect.value1 + effect.value2 if item.damage.to_mp?
end
end
-value.to_i
end
#--------------------------------------------------------------------------
# ○ 命中率結果予測値を返す
#--------------------------------------------------------------------------
def test_hit_rate(user, item)
rate = item_hit(user, item) * 100
rate *= (1 - item_eva(user, item))
rate
end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
# 敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の
# 内部で使用されます。
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 行動条件合致判定[ターン数]
#--------------------------------------------------------------------------
alias tmsrpg_game_enemy_conditions_met_turns? conditions_met_turns?
def conditions_met_turns?(param1, param2)
if SceneManager.scene_is?(Scene_SrpgMap)
n = $game_srpgmap.turn_count
if param2 == 0
n == param1
else
n > 0 && n >= param1 && n % param2 == param1 % param2
end
else
tmsrpg_game_enemy_conditions_met_turns?(param1, param2)
end
end
#--------------------------------------------------------------------------
# ● 行動条件合致判定[パーティレベル]
#--------------------------------------------------------------------------
alias tmsrpg_game_enemy_conditions_met_party_level? conditions_met_party_level?
def conditions_met_party_level?(param1, param2)
if SceneManager.scene_is?(Scene_SrpgMap)
$game_srpgmap.highest_level >= param1
else
tmsrpg_game_enemy_conditions_met_party_level?(param1, param2)
end
end
#--------------------------------------------------------------------------
# ○ レベル取得
#--------------------------------------------------------------------------
def level
/<Level\s*(\d+)>/ =~ enemy.note ? $1.to_i : 1
end
#--------------------------------------------------------------------------
# ○ 職業オブジェクト取得
#--------------------------------------------------------------------------
def class
id = /<Class\s*(\d+)>/ =~ enemy.note ? $1.to_i : 1
$data_classes[id]
end
#--------------------------------------------------------------------------
# ○ 二つ名取得
#--------------------------------------------------------------------------
def nickname
/<Nickname\s*(\S+?)>/ =~ enemy.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ○ 説明取得
#--------------------------------------------------------------------------
def description
/<Description>(.+?)<\/Description>/m =~ enemy.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ○ 装備品オブジェクトの配列取得
#--------------------------------------------------------------------------
def equips
if /<Equipment\s*(\d+),(\d+),(\d+),(\d+),(\d+)>/ =~ enemy.note
if dual_wield?
[$1, $2].collect {|id| $data_weapons[id.to_i] } +
[$3, $4, $5].collect {|id| $data_armors[id.to_i] }
else
[$data_weapons[$1.to_i]] + [$2, $3, $4, $5].collect {|id| $data_armors[id.to_i] }
end
else
[]
end
end
#--------------------------------------------------------------------------
# ○ 通常攻撃 アニメーション ID の取得
#--------------------------------------------------------------------------
def atk_animation_id1
/<ATK\s*(\d+)>/ =~ enemy.note ? $1.to_i : 1
end
#--------------------------------------------------------------------------
# ○ 歩行グラフィックのファイル名を返す
#--------------------------------------------------------------------------
def character_name
/<Sprite\s*(\S+?)\s*\,\s*(\d+)>/ =~ enemy.note ? $1 : "Monster1"
end
#--------------------------------------------------------------------------
# ○ 歩行グラフィックのインデックスを返す
#--------------------------------------------------------------------------
def character_index
/<Sprite_Index\s*(\S+?)\s*\,\s*(\d+)>/ =~ enemy.note ? $2.to_i : 0
end
#--------------------------------------------------------------------------
# ○ 顔グラフィックのファイル名を返す
#--------------------------------------------------------------------------
def face_name
/<Face\s*(\S+?)\s*\,\s*(\d+)>/ =~ enemy.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ○ 顔グラフィックのインデックスを返す
#--------------------------------------------------------------------------
def face_index
/<Face_Index\s*(\S+?)\s*\,\s*(\d+)>/ =~ enemy.note ? $2.to_i : 0
end
#--------------------------------------------------------------------------
# ○ 浮遊演出を利用するかどうかを返す
#--------------------------------------------------------------------------
def use_float_effect?
@use_float_effect ||= /<Float>/ =~ enemy.note ? false : true
end
#--------------------------------------------------------------------------
# ○ HP非表示フラグを返す
#--------------------------------------------------------------------------
def hp_hide?
/<(?:HP|HP)Hidden>/i =~ enemy.note ? true : false
end
#--------------------------------------------------------------------------
# ○ MP非表示フラグを返す
#--------------------------------------------------------------------------
def mp_hide?
/<(?:MP|MP)Hidden>/i =~ enemy.note ? true : false
end
#--------------------------------------------------------------------------
# ○ ドロップアイテム非表示フラグを返す
#--------------------------------------------------------------------------
def drop_hide?
/<Hide Drop>/ =~ enemy.note ? true : false
end
#--------------------------------------------------------------------------
# ○ 撃破対象かどうかを返す
#--------------------------------------------------------------------------
def boss?
$game_srpgmap.events[@index].boss?
end
#--------------------------------------------------------------------------
# ○ 護衛対象かどうかを返す
#--------------------------------------------------------------------------
def princess?
$game_srpgmap.events[@index].princess?
end
#--------------------------------------------------------------------------
# ○ オブジェクトフラグを返す
#--------------------------------------------------------------------------
def object?
/<Object>/ =~ enemy.note ? true : false
end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● レベルアップメッセージの表示
# new_skills : 新しく習得したスキルの配列
#--------------------------------------------------------------------------
alias tmsrpg_game_actor_display_level_up display_level_up
def display_level_up(new_skills)
if SceneManager.scene_is?(Scene_SrpgMap)
$game_srpgmap.actor_events.each do |event|
if event.battler.id == id
event.setup_animation(self, TMSRPG::ANIME_LEVEL_UP)
$game_srpgmap.add_popup(event.real_x + 0.5, event.real_y,
"Level Up!", 27, :state)
end
end
else
tmsrpg_game_actor_display_level_up(new_skills)
end
end
#--------------------------------------------------------------------------
# ○ 浮遊演出を利用するかどうかを返す
#--------------------------------------------------------------------------
def use_float_effect?
@use_float_effect ||= /<No Float>/ =~ actor.note ? false : true
end
#--------------------------------------------------------------------------
# ○ HP非表示フラグを返す
#--------------------------------------------------------------------------
def hp_hide?
false
end
#--------------------------------------------------------------------------
# ○ MP非表示フラグを返す
#--------------------------------------------------------------------------
def mp_hide?
false
end
#--------------------------------------------------------------------------
# ○ 撃破対象かどうかを返す
#--------------------------------------------------------------------------
def boss?
false
end
#--------------------------------------------------------------------------
# ○ 護衛対象かどうかを返す
#--------------------------------------------------------------------------
def princess?
false
end
end
#==============================================================================
# ■ Game_SrpgMap
#------------------------------------------------------------------------------
# SRPG用のマップを扱うクラスです。スクロールや通行可能判定などの機能を
# 持っています。このクラスのインスタンスは $game_srpgmap で参照されます。
#==============================================================================
class Game_SrpgMap
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :screen # マップ画面の状態
attr_reader :interpreter # マップイベント用インタプリタ
attr_reader :events # イベント
attr_reader :popups # ポップアップ
attr_reader :display_x # 表示 X 座標
attr_reader :display_y # 表示 Y 座標
attr_reader :parallax_name # 遠景 ファイル名
attr_reader :battleback1_name # 戦闘背景(床)ファイル名
attr_reader :battleback2_name # 戦闘背景(壁)ファイル名
attr_reader :sally_count # 出撃カウント
attr_reader :actor_death_count # 戦闘不能アクター数
attr_reader :enemy_death_count # 戦闘不能エネミー数
attr_reader :npc_death_count # 戦闘不能NPC数
attr_reader :turn_count # 現在のターン数
attr_reader :flash_data # フラッシュデータ
attr_reader :movable_area_table # 移動可能範囲ハッシュ
attr_reader :actable_area_table # 行動可能範囲ハッシュ
attr_reader :effect_area_table # 効果範囲配列
attr_reader :auto_check_victory # 自動勝利チェックフラグ
attr_accessor :name_display # マップ名表示フラグ
attr_accessor :need_refresh # リフレッシュ要求フラグ
attr_accessor :chain_damage_rate # 連携ダメージ補正率
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
@screen = Game_Screen.new
@interpreter = Game_SrpgInterpreter.new
@map_id = 0
@events = {}
@actor_events = {}
@display_x = 0
@display_y = 0
@name_display = true
@turn_count = 0
end
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
def setup(map_id)
@map_id = map_id
@map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
@tileset_id = @map.tileset_id
@flash_data = Table.new(width, height)
@display_x = 0
@display_y = 0
setup_srpg_parameters
setup_events
setup_scroll
setup_parallax
setup_battleback
setup_popups
setup_map_passable_table
@need_refresh = false
$game_party.on_battle_start
end
#--------------------------------------------------------------------------
# ● SRPGパラメータのセットアップ
#--------------------------------------------------------------------------
def setup_srpg_parameters
@actor_turn_end = false
@sally_count = 0
@actor_death_count = 0
@enemy_death_count = 0
@npc_death_count = 0
@turn_count = 1
@chain_damage_rate = 1.0
$game_variables[TMSRPG::VN_TURN_SWITCH] = 1
$game_variables[TMSRPG::VN_GAMEOVER] = 0
@auto_check_victory = /<Automatic Victory Invalid>/ =~ @map.note ? false : true
end
#--------------------------------------------------------------------------
# ● イベントのセットアップ
#--------------------------------------------------------------------------
def setup_events
@events = {}
@actor_events = {}
@gate_event_id = nil
@map.events.each do |i, event|
if TMSRPG::AUTO_D_RESET # セルフスイッチDの自動初期化
key = [@map_id, event.id, "D"]
$game_self_switches[key] = false
end
@events[i] = Game_SrpgEvent.new(@map_id, event)
@gate_event_id = i if @events[i].gate?
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 setup_popups
@popups = []
32.times {|i| @popups.push(Game_SrpgPopup.new(i)) }
end
#--------------------------------------------------------------------------
# ● 表示位置の設定
#--------------------------------------------------------------------------
def set_display_pos(x, y)
x = [0, [x, width - screen_tile_x].min].max
y = [0, [y, height - screen_tile_y].min].max
@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 description
/<Description>(.+?)<\/Description>/m =~ @map.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ● 勝利条件の取得
#--------------------------------------------------------------------------
def victory_rule
/<Victory>(.+?)<\/Victory>/m =~ @map.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ● 敗北条件の取得
#--------------------------------------------------------------------------
def gameover_rule
/<Defeat>(.+?)<\/Defeat>/m =~ @map.note ? $1 : ""
end
#--------------------------------------------------------------------------
# ● 幅の取得
#--------------------------------------------------------------------------
def width
@map.width
end
#--------------------------------------------------------------------------
# ● 高さの取得
#--------------------------------------------------------------------------
def height
@map.height
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 actor_turn?
!@actor_turn_end
end
#--------------------------------------------------------------------------
# ● 早送り判定
#--------------------------------------------------------------------------
def show_fast?
$game_system.turn_auto_dash ? !Input.press?(:A) : Input.press?(:A)
end
#--------------------------------------------------------------------------
# ● バトルメンバーの最大数を取得
#--------------------------------------------------------------------------
def max_battle_members
/<Max Allies\s*(\d+)>/ =~ @map.note ? $1.to_i : 8
end
#--------------------------------------------------------------------------
# ● 残り出撃可能人数を返す
#--------------------------------------------------------------------------
def sally_rest
max_battle_members - @sally_count
end
#--------------------------------------------------------------------------
# ● 出撃が可能かどうかを返す
#--------------------------------------------------------------------------
def can_sally?
sally_rest > 0
end
#--------------------------------------------------------------------------
# ● 指定したアクターが出撃中かどうかを返す
#--------------------------------------------------------------------------
def actor_in_battle?(actor_id)
$game_srpgmap.actor_events.any? {|event| event.battler.id == actor_id }
end
#--------------------------------------------------------------------------
# ● 画面の横タイル数
#--------------------------------------------------------------------------
def screen_tile_x
Graphics.width / 32
end
#--------------------------------------------------------------------------
# ● 画面の縦タイル数
#--------------------------------------------------------------------------
def screen_tile_y
Graphics.height / 32
end
#--------------------------------------------------------------------------
# ● 表示座標を差し引いた X 座標の計算
#--------------------------------------------------------------------------
def adjust_x(x)
x - @display_x
end
#--------------------------------------------------------------------------
# ● 表示座標を差し引いた Y 座標の計算
#--------------------------------------------------------------------------
def adjust_y(y)
y - @display_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
#--------------------------------------------------------------------------
# ● 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
#--------------------------------------------------------------------------
# ● 指定したアクターのイベントを返す(出撃していなければ nil を返す)
#--------------------------------------------------------------------------
def actor_event(actor_id)
return nil unless @actor_events[actor_id]
@actor_events[actor_id].battler? ? @actor_events[actor_id] : nil
end
#--------------------------------------------------------------------------
# ● バトラーイベントの配列取得
#--------------------------------------------------------------------------
def battler_events
@events.values.select {|event| event.battler? }
end
#--------------------------------------------------------------------------
# ● エネミーイベントの配列取得
#--------------------------------------------------------------------------
def enemy_events
@events.values.select {|event| event.enemy? }
end
#--------------------------------------------------------------------------
# ● NPCイベントの配列取得
#--------------------------------------------------------------------------
def npc_events
@events.values.select {|event| event.npc? }
end
#--------------------------------------------------------------------------
# ● 撃破対象イベントの配列取得
#--------------------------------------------------------------------------
def boss_events
@events.values.select {|event| event.boss? }
end
#--------------------------------------------------------------------------
# ● 護衛対象イベントの配列取得
#--------------------------------------------------------------------------
def princess_events
@events.values.select {|event| event.princess? }
end
#--------------------------------------------------------------------------
# ● アクターイベントの配列取得
#--------------------------------------------------------------------------
def actor_events
@actor_events.values.select {|event| event.battler? }
end
#--------------------------------------------------------------------------
# ● アクターイベントも含めたすべてのバトラーイベントの配列取得
#--------------------------------------------------------------------------
def all_battler_events
actor_events + battler_events
end
#--------------------------------------------------------------------------
# ● ゲートイベントを返す
#--------------------------------------------------------------------------
def gate_event
return nil unless @gate_event_id
@events[@gate_event_id]
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するイベントの配列取得
#--------------------------------------------------------------------------
def events_xy(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
@events.values.select {|event| event.pos?(x, y) }
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するイベント(すり抜け以外)の配列取得
#--------------------------------------------------------------------------
def events_xy_nt(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
@events.values.select {|event| event.pos_nt?(x, y) }
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
#--------------------------------------------------------------------------
def tile_events_xy(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
@tile_events.select {|event| event.pos_nt?(x, y) }
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するバトラーイベントを取得
#--------------------------------------------------------------------------
def battler_event_xy(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
event = actor_event_xy(x, y)
return event if event
@events.values.find {|event| event.pos?(x, y) && event.battler? }
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するアクターイベントを取得
#--------------------------------------------------------------------------
def actor_event_xy(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
actor_events.find {|event| event.pos?(x, y) }
end
#--------------------------------------------------------------------------
# ● 指定座標に存在するイベントの ID 取得(一つのみ)
#--------------------------------------------------------------------------
def event_id_xy(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
list = events_xy(x, y)
list.empty? ? 0 : list[0].id
end
#--------------------------------------------------------------------------
# ● 指定座標にゲートイベントが存在するかどうかを返す
#--------------------------------------------------------------------------
def gate_xy?(x = nil, y = nil)
return false unless @gate_event_id
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
event = gate_event
event.x == x && event.y == y
end
#--------------------------------------------------------------------------
# ● 効果範囲内に存在するSRPGイベントの配列取得
#--------------------------------------------------------------------------
def events_in_effect_area(event)
result = []
item = event.battler.current_action.item
if item.for_friend?
targets = event.friend_events
targets += event.opponent_events if item.indiscriminate?
else
targets = event.opponent_events
targets += event.friend_events if item.indiscriminate?
end
targets.each do |target|
x = target.x - $game_srpgplayer.x
y = target.y - $game_srpgplayer.y
if @effect_area_table.include?([x, y])
n = 1 + (event.battler.current_action.attack? ? event.battler.atk_times_add.to_i : 0)
n.times { result.push(target) }
end
end
result
end
#--------------------------------------------------------------------------
# ● 行動可能範囲内の座標かどうかを返す
#--------------------------------------------------------------------------
def actable_area?(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
@actable_area_table[[x, y]] == 1
end
#--------------------------------------------------------------------------
# ● 下にスクロール
#--------------------------------------------------------------------------
def scroll_down(distance)
last_y = @display_y
@display_y = [@display_y + distance, height - screen_tile_y].min
@parallax_y += @display_y - last_y
end
#--------------------------------------------------------------------------
# ● 左にスクロール
#--------------------------------------------------------------------------
def scroll_left(distance)
last_x = @display_x
@display_x = [@display_x - distance, 0].max
@parallax_x += @display_x - last_x
end
#--------------------------------------------------------------------------
# ● 右にスクロール
#--------------------------------------------------------------------------
def scroll_right(distance)
last_x = @display_x
@display_x = [@display_x + distance, (width - screen_tile_x)].min
@parallax_x += @display_x - last_x
end
#--------------------------------------------------------------------------
# ● 上にスクロール
#--------------------------------------------------------------------------
def scroll_up(distance)
last_y = @display_y
@display_y = [@display_y - distance, 0].max
@parallax_y += @display_y - last_y
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 ship_passable?(x, y)
check_passage(x, y, 0x0400)
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_parallax
update_popups
@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 }
@actor_events.each_value {|event| event.update }
@common_events.each {|event| event.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 update_popups
@popups.each {|popup| popup.update }
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
#--------------------------------------------------------------------------
# ● 地形のみの通行可能情報テーブルをセットアップ
#--------------------------------------------------------------------------
def setup_map_passable_table
@movable_area_table = {} # 移動可能範囲ハッシュ
@actable_area_table = {} # 行動可能範囲ハッシュ
@effect_area_table = [] # 効果範囲配列
@map_passable_table_normal = Table.new(width, height, 4)
@map_passable_table_float = Table.new(width, height, 4)
@map_passable_table_ship = Table.new(width, height, 4)
width.times do |x|
height.times do |y|
[2,4,6,8].each do |d|
next if (y == 0 && d == 8) || (y == height - 1 && d == 2)
next if (x == 0 && d == 4) || (x == width - 1 && d == 6)
x2 = x_with_direction(x, d)
y2 = y_with_direction(y, d)
if passable?(x, y, d) && passable?(x2, y2, 10 - d)
@map_passable_table_normal[x, y, d / 2 - 1] = 1
@map_passable_table_ship[x, y, d / 2 - 1] = 1
elsif ship_passable?(x2, y2) || (ship_passable?(x, y) && passable?(x2, y2, 10 - d))
@map_passable_table_ship[x, y, d / 2 - 1] = 1
end
@map_passable_table_float[x, y, d / 2 - 1] = 1
end
end
end
end
#--------------------------------------------------------------------------
# ● イベントの移動可能範囲を表示する
#--------------------------------------------------------------------------
def put_movable_area(event)
@movable_area_table.clear
mov = event.battler.mov # イベントの移動力
setup_passable_table(event, mov) # 通行判定テーブルのセット
check_movable_area(event.x, event.y - 1, mov - 1, event.x, event.y, 3, "4")
check_movable_area(event.x + 1, event.y, mov - 1, event.x, event.y, 2, "3")
check_movable_area(event.x, event.y + 1, mov - 1, event.x, event.y, 0, "1")
check_movable_area(event.x - 1, event.y, mov - 1, event.x, event.y, 1, "2")
(@events.values + actor_events).each do |obj|
@movable_area_table.delete([obj.x, obj.y]) if obj.priority_type == 1
end
if (event.actor? && event.acted?) || !event.actor? # ゲートへの移動を制限
@movable_area_table.delete([@events[@gate_event_id].x, @events[@gate_event_id].y])
end
clear_flash_data
@movable_area_table.each_key {|key| @flash_data[key[0], key[1]] = 0x22f }
end
#--------------------------------------------------------------------------
# ● 移動可能範囲計算用の通行判定テーブルをセット
#--------------------------------------------------------------------------
def setup_passable_table(event, mov)
if event.battler.float?
@passable_table = @map_passable_table_float.clone
elsif event.battler.ship?
@passable_table = @map_passable_table_ship.clone
else
@passable_table = @map_passable_table_normal.clone
end
(@events.values + actor_events).each do |target|
next if event.friend?(target)
next if target.priority_type != 1
4.times {|i| @passable_table[target.x, target.y, i] = 0 }
end
end
#--------------------------------------------------------------------------
# ● ユニットの移動可能範囲を表示する(再帰処理部分)
#--------------------------------------------------------------------------
def check_movable_area(x, y, mov, px, py, pd, way)
return if @passable_table[px, py, pd] == 0 # 移動不可座標なら終了
return if @movable_area_table[[x, y]] &&
way.length > @movable_area_table[[x, y]].length
return if mov < 0 # 移動力オーバーなら終了
@movable_area_table[[x, y]] = way
check_movable_area(x, y - 1, mov - 1, x, y, 3, way + "4") unless pd == 0
check_movable_area(x + 1, y, mov - 1, x, y, 2, way + "3") unless pd == 1
check_movable_area(x, y + 1, mov - 1, x, y, 0, way + "1") unless pd == 3
check_movable_area(x - 1, y, mov - 1, x, y, 1, way + "2") unless pd == 2
end
#--------------------------------------------------------------------------
# ● 指定した座標までの移動ルート文字列を返す(移動不可なら nil )
# 座標が指定されなければカーソル位置を移動先とする
#--------------------------------------------------------------------------
def movable_area_route(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
@movable_area_table[[x, y]]
end
#--------------------------------------------------------------------------
# ● フラッシュデータをクリア
#--------------------------------------------------------------------------
def clear_flash_data
@flash_data.xsize.times do |x|
@flash_data.ysize.times do |y|
@flash_data[x, y] = 0x000
end
end
@effect_area_table.clear
end
#--------------------------------------------------------------------------
# ● 指定した座標のフラッシュデータを設定
#--------------------------------------------------------------------------
def put_flash_data(x, y, color)
@flash_data[x, y] = color if valid?(x, y)
end
#--------------------------------------------------------------------------
# ● イベントの行動可能範囲を表示する
#--------------------------------------------------------------------------
def put_actable_area(event)
item = event.battler.current_action.item
@actable_area_table = make_actable_area(event.x, event.y, item).clone
clear_flash_data
@actable_area_table.each_key {|key| @flash_data[key[0], key[1]] = 0xf22 }
end
#--------------------------------------------------------------------------
# ● 座標とスキルから行動可能範囲を作成する
#--------------------------------------------------------------------------
def make_actable_area(x, y, item)
result = {}
range = item.range
type = item.range_type
hole = item.range_hole
(x - range...x + range + 1).each do |x2|
(y - range...y + range + 1).each do |y2|
d = (x - x2).abs + (y - y2).abs
next if d < hole # 穴の範囲を除外
next if type == 0 && d > range # 距離オーバーの範囲を除外
next if type == 2 && x != x2 && y != y2
next if type == 3 && (x - x2).abs != (y - y2).abs
result[[x2, y2]] = 1
end
end
result
end
#--------------------------------------------------------------------------
# ● イベントの行動効果範囲を表示する
#--------------------------------------------------------------------------
def put_effect_area(event, target_pos = nil)
target_pos ||= [$game_srpgplayer.x, $game_srpgplayer.y]
@effect_area_table = make_effect_area(event, target_pos).clone
end
#--------------------------------------------------------------------------
# ● イベントの行動効果範囲を作成する
# target_pos : 行動中心座標 [x, y]
#--------------------------------------------------------------------------
def make_effect_area(event, target_pos = nil)
result = []
item = event.battler.current_action.item
effect_size = item.effect_size
type = item.effect_type
hole = item.effect_hole
(-effect_size..effect_size).each do |x|
(-effect_size..effect_size).each do |y|
d = x.abs + y.abs
next if d < hole # 効果穴の範囲を除外
next if type == 0 && d > effect_size
next if type == 2 && x != 0 && y != 0
next if type == 3 && x.abs != y.abs
if type == 4
target_pos ||= [$game_srpgplayer.x, $game_srpgplayer.y]
dir = event.direction_from_pos(*target_pos)
next if dir == 2 && y < 0
next if dir == 4 && x > 0
next if dir == 6 && x < 0
next if dir == 8 && y > 0
end
result.push([x, y])
end
end
result
end
#--------------------------------------------------------------------------
# ● イベントの行動効果範囲(絶対座標)を作成する
#--------------------------------------------------------------------------
def make_effect_area_abs(event, target_pos = nil)
result = []
item = event.battler.current_action.item
make_effect_area(event, target_pos).each do |pos|
result.push([pos[0] + target_pos[0], pos[1] + target_pos[1]])
end
result
end
#--------------------------------------------------------------------------
# ● アクターイベントの追加
#--------------------------------------------------------------------------
def add_actor_event(x, y, actor)
if @actor_events[actor.id]
@actor_events[actor.id].setup(x, y, actor)
else
@actor_events[actor.id] = Game_SrpgActorEvent.new(x, y, actor)
end
@sally_count += 1
end
#--------------------------------------------------------------------------
# ● アクターイベントをゲートへ戻す
#--------------------------------------------------------------------------
def back_to_gate(event)
@sally_count -= 1
event.back_to_gate
end
#--------------------------------------------------------------------------
# ● 戦闘不能アクターのカウント
#--------------------------------------------------------------------------
def increase_actor_death
@actor_death_count += 1
end
#--------------------------------------------------------------------------
# ● 戦闘不能エネミーのカウント
#--------------------------------------------------------------------------
def increase_enemy_death
@enemy_death_count += 1
end
#--------------------------------------------------------------------------
# ● 戦闘不能NPCのカウント
#--------------------------------------------------------------------------
def increase_npc_death
@npc_death_count += 1
end
#--------------------------------------------------------------------------
# ● ポップアップの追加
#--------------------------------------------------------------------------
def add_popup(x, y, text, color, type_symbol = :damage)
@popups.each do |popup|
if popup.erased?
popup.setup(x, y, text, color, type_symbol)
break
end
end
end
#--------------------------------------------------------------------------
# ● ターン終了処理
#--------------------------------------------------------------------------
def turn_end
if actor_turn?
battler_events.each {|event| event.on_turn_end }
else
@actor_events.values.each {|event| event.on_turn_end }
@turn_count += 1 # 敵ターン終了時にターンカウントを進める
end
@actor_turn_end = !@actor_turn_end
$game_variables[TMSRPG::VN_TURN_SWITCH] = actor_turn? ? 1 : 2 # ゲーム変数操作
end
#--------------------------------------------------------------------------
# ● ゲームオーバー判定
#--------------------------------------------------------------------------
def check_gameover
return if $game_variables[TMSRPG::VN_GAMEOVER] > 0
if auto_check_victory && !enemy_events.any? {|event| !event.rule_out? }
$game_variables[TMSRPG::VN_GAMEOVER] = 1
end
if actor_events.empty? && (!can_sally? || $game_party.all_dead?)
$game_variables[TMSRPG::VN_GAMEOVER] = 2
end
a = boss_events
if !a.empty? && !a.any? {|event| event.battler? }
$game_variables[TMSRPG::VN_GAMEOVER] = 1
end
a = princess_events
if !a.empty? && !a.any? {|event| event.battler? }
$game_variables[TMSRPG::VN_GAMEOVER] = 2
end
end
#--------------------------------------------------------------------------
# ● 出撃メンバーの最も高いレベルの取得
#--------------------------------------------------------------------------
def highest_level
actor_events.collect {|event| event.battler.level }.max
end
#--------------------------------------------------------------------------
# ● 出撃メンバーの自動復活
#--------------------------------------------------------------------------
def auto_revive
@actor_events.keys.each do |actor_id|
actor = $game_actors[actor_id]
case TMSRPG::AUTO_REVIVE
when 1
actor.hp = 1 if actor.dead?
when 2
actor.hp = actor.mhp
end
end
end
end
#==============================================================================
# ■ Game_SrpgCharacterBase
#------------------------------------------------------------------------------
# キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
# ラフィックなどの基本的な情報を保持します。
#==============================================================================
class Game_SrpgCharacterBase
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
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_srpgmap.x_with_direction(x, d)
y2 = $game_srpgmap.y_with_direction(y, d)
return false unless $game_srpgmap.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_srpgmap.x_with_direction(x, horz)
y2 = $game_srpgmap.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_srpgmap.passable?(x, y, d)
end
#--------------------------------------------------------------------------
# ● キャラクターとの衝突判定
#--------------------------------------------------------------------------
def collide_with_characters?(x, y)
collide_with_events?(x, y) || $game_srpgmap.actor_event_xy(x, y)
end
#--------------------------------------------------------------------------
# ● イベントとの衝突判定
#--------------------------------------------------------------------------
def collide_with_events?(x, y)
$game_srpgmap.events_xy_nt(x, y).any? do |event|
event.normal_priority? || self.is_a?(Game_SrpgEvent)
end
end
#--------------------------------------------------------------------------
# ● 指定位置に移動
#--------------------------------------------------------------------------
def moveto(x, y)
@x = x % $game_srpgmap.width
@y = y % $game_srpgmap.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_srpgmap.adjust_x(@real_x) * 32 + 16
end
#--------------------------------------------------------------------------
# ● 画面 Y 座標の取得
#--------------------------------------------------------------------------
def screen_y
$game_srpgmap.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
@real_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_srpgmap.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_srpgmap.bush?(@x, @y)
end
#--------------------------------------------------------------------------
# ● 地形タグの取得
#--------------------------------------------------------------------------
def terrain_tag
$game_srpgmap.terrain_tag(@x, @y)
end
#--------------------------------------------------------------------------
# ● リージョン ID の取得
#--------------------------------------------------------------------------
def region_id
$game_srpgmap.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
#--------------------------------------------------------------------------
# ● まっすぐに移動
# 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_srpgmap.x_with_direction(@x, d)
@y = $game_srpgmap.y_with_direction(@y, d)
@real_x = $game_srpgmap.x_with_direction(@x, reverse_dir(d))
@real_y = $game_srpgmap.y_with_direction(@y, reverse_dir(d))
increase_steps
elsif turn_ok
set_direction(d)
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_srpgmap.x_with_direction(@x, horz)
@y = $game_srpgmap.y_with_direction(@y, vert)
@real_x = $game_srpgmap.x_with_direction(@x, reverse_dir(horz))
@real_y = $game_srpgmap.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
#==============================================================================
# ■ Game_SrpgCharacter
#------------------------------------------------------------------------------
# 主に移動ルートなどの処理を追加したキャラクターのクラスです。Game_SrpgPlayer、
# Game_SrpgEvent のスーパークラスとして使用されます。
#==============================================================================
class Game_SrpgCharacter < Game_SrpgCharacterBase
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
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 # 移動ルート強制フラグ
attr_accessor :zoom_x # x方向の拡大率
attr_accessor :zoom_y # y方向の拡大率
#--------------------------------------------------------------------------
# ● 公開メンバ変数の初期化
#--------------------------------------------------------------------------
def init_public_members
super
@move_route_forcing = false
clear_ex_param
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 clear_ex_param
@zoom_x = 1.0
@zoom_y = 1.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)
@x - x
end
#--------------------------------------------------------------------------
# ● Y 方向の距離計算
#--------------------------------------------------------------------------
def distance_y_from(y)
@y - y
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
#==============================================================================
# ■ Game_SrpgPlayer
#------------------------------------------------------------------------------
# SRPGマップで動かすカーソルを扱うクラスです。
#==============================================================================
class Game_SrpgPlayer < Game_SrpgCharacter
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super
@character_name = "$SrpgArrow"
@character_index = 0
@move_speed = 5
@step_anime = true
@priority_type = 2
@auto_move_count = 0
@moved = false
end
#--------------------------------------------------------------------------
# ● バトラーイベントかどうかを返す
#--------------------------------------------------------------------------
def battler?
false
end
#--------------------------------------------------------------------------
# ● 場所移動情報のクリア
#--------------------------------------------------------------------------
def clear_transfer_info
@transferring = false # 場所移動フラグ
@new_map_id = 0 # 移動先 マップ ID
@new_x = 0 # 移動先 X 座標
@new_y = 0 # 移動先 Y 座標
@new_direction = 0 # 移動後の向き
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_srpgmap.map_id
$game_srpgmap.setup(@new_map_id)
$game_srpgmap.autoplay
end
moveto(@new_x, @new_y)
clear_transfer_info
end
end
#--------------------------------------------------------------------------
# ● 自動移動のセット
#--------------------------------------------------------------------------
def setup_auto_move(x, y)
@x, @y = x, y
@auto_move_count = 8
@auto_move_vx = (@x + 0.5 - @real_x) / 8
@auto_move_vy = (@y + 0.5 - @real_y) / 8
end
#--------------------------------------------------------------------------
# ● 自動移動のセット(対象イベント指定)
#--------------------------------------------------------------------------
def setup_auto_move_to_event(event)
setup_auto_move(event.x, event.y)
end
#--------------------------------------------------------------------------
# ● 自動移動のセット(ゲート座標)
#--------------------------------------------------------------------------
def setup_auto_move_to_gate
setup_auto_move_to_event($game_srpgmap.gate_event)
end
#--------------------------------------------------------------------------
# ● ダッシュ状態判定
#--------------------------------------------------------------------------
def dash?
$game_system.player_auto_dash ? !Input.press?(:A) : Input.press?(:A)
end
#--------------------------------------------------------------------------
# ● デバッグすり抜け状態判定
#--------------------------------------------------------------------------
def debug_through?
$TEST && Input.press?(:CTRL)
end
#--------------------------------------------------------------------------
# ● ロック(ウィンドウ処理中の停止処理)
#--------------------------------------------------------------------------
def lock
@locked = true
end
#--------------------------------------------------------------------------
# ● ロック解除
#--------------------------------------------------------------------------
def unlock
@locked = false
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_srpgmap.set_display_pos(x - center_x, y - center_y)
end
#--------------------------------------------------------------------------
# ● 指定位置に移動
#--------------------------------------------------------------------------
def moveto(x, y)
super
center(x, y)
end
#--------------------------------------------------------------------------
# ● 方向ボタン入力による移動処理
#--------------------------------------------------------------------------
def move_by_input
return if !movable? || $game_srpgmap.interpreter.running?
if Input.press?(:Y)
d = Input.dir4
if d > 0
event = $game_srpgmap.actor_event_xy(@x, @y)
event.set_direction(d) if event
end
else
if Input.press?(:LEFT)
@real_x -= distance_per_frame
@real_x = 0 if @real_x < 0
elsif Input.press?(:RIGHT)
@real_x += distance_per_frame
@real_x = $game_srpgmap.width - 0.01 if @real_x >= $game_srpgmap.width
end
if Input.press?(:UP)
@real_y -= distance_per_frame
@real_y = 0 if @real_y < 0
elsif Input.press?(:DOWN)
@real_y += distance_per_frame
@real_y = $game_srpgmap.height - 0.01 if @real_y >= $game_srpgmap.height
end
end
end
#--------------------------------------------------------------------------
# ● カーソルの座標変更があったかどうかを返す
#--------------------------------------------------------------------------
def moved?
@moved
end
#--------------------------------------------------------------------------
# ● 移動可能判定
#--------------------------------------------------------------------------
def movable?
return false unless $game_srpgmap.actor_turn?
return false if @locked
return false if @move_route_forcing
return false if $game_message.busy? || $game_message.visible
return true
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
last_x, last_y = @x, @y
if @auto_move_count > 0
update_auto_move
else
last_real_x, last_real_y = @real_x, @real_y
move_by_input
super
update_scroll(last_real_x, last_real_y)
end
@moved = (last_x != @x || last_y != @y)
end
#--------------------------------------------------------------------------
# ● 移動時の更新
#--------------------------------------------------------------------------
def update_move
@x = @real_x.to_i
@y = @real_y.to_i
end
#--------------------------------------------------------------------------
# ● 自動移動の処理
#--------------------------------------------------------------------------
def update_auto_move
last_real_x, last_real_y = @real_x, @real_y
@real_x += @auto_move_vx
@real_y += @auto_move_vy
@auto_move_count -= 1
if @auto_move_count == 0
@real_x = @x + 0.5
@real_y = @y + 0.5
end
update_scroll(last_real_x, last_real_y)
end
#--------------------------------------------------------------------------
# ● スクロール処理
#--------------------------------------------------------------------------
def update_scroll(last_real_x, last_real_y)
ax1 = $game_srpgmap.adjust_x(last_real_x)
ay1 = $game_srpgmap.adjust_y(last_real_y)
ax2 = $game_srpgmap.adjust_x(@real_x)
ay2 = $game_srpgmap.adjust_y(@real_y)
$game_srpgmap.scroll_down (ay2 - ay1) if ay2 > ay1 && ay2 > center_y
$game_srpgmap.scroll_left (ax1 - ax2) if ax2 < ax1 && ax2 < center_x
$game_srpgmap.scroll_right(ax2 - ax1) if ax2 > ax1 && ax2 > center_x
$game_srpgmap.scroll_up (ay1 - ay2) if ay2 < ay1 && ay2 < center_y
end
end
#==============================================================================
# ■ Game_SrpgEvent
#------------------------------------------------------------------------------
# イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
# イベント実行などの機能を持っており、Game_SrpgMap クラスの内部で使用されます。
#==============================================================================
class Game_SrpgEvent < Game_SrpgCharacter
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
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 # イベントページ
@moved = false # 移動実行済みフラグ
@acted = false # 行動実行済みフラグ
@last_pos = [] # 移動前の座標
end
#--------------------------------------------------------------------------
# ● 画面 Y 座標の取得
#--------------------------------------------------------------------------
def screen_y
result = super
if battler && battler.float? && battler.use_float_effect?
#~ result -= Math.sin(Math::PI * (Graphics.frame_count % 90) / 45) * 6 + 8
end
result
end
#--------------------------------------------------------------------------
# ● イベントがゲートかどうかを返す
#--------------------------------------------------------------------------
def gate?
/<GATE>/i =~ @event.name ? true : false
end
#--------------------------------------------------------------------------
# ● バトラーイベントかどうかを返す
#--------------------------------------------------------------------------
def battler?
@battler != nil
end
#--------------------------------------------------------------------------
# ● アクターイベントかどうかを返す
#--------------------------------------------------------------------------
def actor?
false
end
#--------------------------------------------------------------------------
# ● エネミーイベントかどうかを返す
#--------------------------------------------------------------------------
def enemy?
battler? && !npc?
end
#--------------------------------------------------------------------------
# ● NPCイベントかどうかを返す
#--------------------------------------------------------------------------
def npc?
@npc
end
#--------------------------------------------------------------------------
# ● 撃破対象イベントかどうかを返す
#--------------------------------------------------------------------------
def boss?
@boss
end
#--------------------------------------------------------------------------
# ● 非撃破対象イベントかどうかを返す
#--------------------------------------------------------------------------
def rule_out?
@rule_out
end
#--------------------------------------------------------------------------
# ● 護衛対象イベントかどうかを返す
#--------------------------------------------------------------------------
def princess?
@princess
end
#--------------------------------------------------------------------------
# ● オブジェクトイベントかどうかを返す
#--------------------------------------------------------------------------
def object?
battler? && battler.object?
end
#--------------------------------------------------------------------------
# ● バトラーを返す
#--------------------------------------------------------------------------
def battler
@battler
end
#--------------------------------------------------------------------------
# ● 味方かどうかを返す
#--------------------------------------------------------------------------
def friend?(target)
return true if self == target
return false if battler.confusion_level == 2
if npc?
(target.actor? || target.npc?) ^ (battler.confusion_level == 3)
else
target.enemy? ^ (battler.confusion_level == 3)
end
end
#--------------------------------------------------------------------------
# ● 敵対するイベント配列を返す
#--------------------------------------------------------------------------
def opponent_events
$game_srpgmap.all_battler_events.select {|event| !friend?(event) }
end
#--------------------------------------------------------------------------
# ● 仲間イベント配列を返す
#--------------------------------------------------------------------------
def friend_events
$game_srpgmap.all_battler_events.select {|event| friend?(event) }
end
#--------------------------------------------------------------------------
# ● 指定した座標との距離計算
#--------------------------------------------------------------------------
def distance_pos_from(x, y)
(@x - x).abs + (@y - y).abs
end
#--------------------------------------------------------------------------
# ● 指定したイベントとの距離計算
#--------------------------------------------------------------------------
def distance_event_from(event)
distance_pos_from(event.x, event.y)
end
#--------------------------------------------------------------------------
# ● 索敵範囲内にいる敵対イベント配列を返す
#--------------------------------------------------------------------------
def near_opponent_events
opponent_events.select do |event|
distance_event_from(event) <= battler.search
end
end
#--------------------------------------------------------------------------
# ● 索敵範囲内で一番近い敵対イベントを返す
#--------------------------------------------------------------------------
def nearest_opponent_event
targets = near_opponent_events
return nil if targets.empty?
targets.sort! {|a, b| distance_event_from(a) - distance_event_from(b) }
targets[0]
end
#--------------------------------------------------------------------------
# ● 索敵範囲内にいる仲間イベント配列を返す
#--------------------------------------------------------------------------
def near_friend_events
friend_events.select do |event|
distance_event_from(event) <= battler.search
end
end
#--------------------------------------------------------------------------
# ● 索敵範囲内で一番近い仲間イベントを返す
#--------------------------------------------------------------------------
def nearest_friend_event
targets = near_friend_events
return nil if targets.empty?
targets.sort! {|a, b| distance_event_from(a) - distance_event_from(b) }
targets[0]
end
#--------------------------------------------------------------------------
# ● 移動済みかどうかを返す
#--------------------------------------------------------------------------
def moved?
@moved
end
#--------------------------------------------------------------------------
# ● 行動済みかどうかを返す
#--------------------------------------------------------------------------
def acted?
@acted
end
#--------------------------------------------------------------------------
# ● 移動をキャンセルできるかどうかを返す
#--------------------------------------------------------------------------
def can_move_cancel?
return false unless battler.movable? # 行動不能ならキャンセルもできない
return false if acted? # 行動済みならキャンセルできない
return true if moved? && !$game_srpgmap.battler_event_xy(@last_pos[0], @last_pos[1])
$game_srpgmap.gate_xy?(@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 moveto(x, y)
super
update_tile_state
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_srpgmap.adjust_x(@real_x) - Graphics.width / 2 / 32
ay = $game_srpgmap.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
@battler = 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_SrpgInterpreter.new : nil
setup_ex_param
setup_srpg_battler
end
#--------------------------------------------------------------------------
# ● 表示拡張のセットアップ
#--------------------------------------------------------------------------
def setup_ex_param
clear_ex_param
if @list
if /<zm\s+(\d+(?:\.\d+)?)\s*\,\s*(\d+(?:\.\d+)?)>/i =~ @event.name
@zoom_x, @zoom_y = $1.to_f, $2.to_f
end
@list.each do |list|
if list.code == 108 || list.code == 408
text = list.parameters[0]
if /<zm\s+(\d+(?:\.\d+)?)\s*\,\s*(\d+(?:\.\d+)?)>/i =~ text
@zoom_x, @zoom_y = $1.to_f, $2.to_f
end
else
break
end
end
end
end
#--------------------------------------------------------------------------
# ● バトラーのセットアップ
#--------------------------------------------------------------------------
def setup_srpg_battler
key = [$game_srpgmap.map_id, @id, "D"]
if !$game_self_switches[key] && /<(?:ENEMY|Enemy)\s*(\d+)>/i =~ @event.name
@battler = Game_Enemy.new(@id, $1.to_i)
@npc = /<NPC>/i =~ @event.name ? true : false
@boss = /<Boss>/ =~ @event.name ? true : false
@rule_out = /<Target>/ =~ @event.name ? true : false
@princess = /<Protect>/i =~ @event.name ? true : false
set_graphic(battler.character_name, battler.character_index)
@step_anime = true
update_tile_state
else
@battler = nil
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
#--------------------------------------------------------------------------
# ● 向きによるダメージペナルティ状態の更新
#--------------------------------------------------------------------------
def update_dir_penalty(user, item)
battler.set_dir_penalty(@direction == user.direction)
end
#--------------------------------------------------------------------------
# ● 地形効果ステートの更新
#--------------------------------------------------------------------------
def update_tile_state
return unless battler?
region_id = $game_srpgmap.region_id(@x, @y)
state_id = TMSRPG::TILE_STATE[region_id]
state_id ||= 0
battler.set_tile_state(state_id)
end
#--------------------------------------------------------------------------
# ● 目的地をセット( nil で目的地設定を解除)
# pos : [x, y]
#--------------------------------------------------------------------------
def set_goal(pos)
@goal_pos = pos
end
#--------------------------------------------------------------------------
# ● 行動時の向きをシミュレートしてペナルティ状態を更新する
#--------------------------------------------------------------------------
def test_dir_penalty(user, x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
last_dir = user.direction
user.turn_toward_pos(x, y)
update_dir_penalty(user, user.battler.current_action.item)
user.set_direction(last_dir)
end
#--------------------------------------------------------------------------
# ● 移動前に行動時の向きをシミュレートしてペナルティ状態を更新する
#--------------------------------------------------------------------------
def test_dir_penalty_pre_move(target, pos_m, x, y)
last_x, last_y = @x, @y
@x, @y = *pos_m
target.test_dir_penalty(self, x, y)
@x, @y = last_x, last_y
end
#--------------------------------------------------------------------------
# ● 移動前の座標を記憶
#--------------------------------------------------------------------------
def set_last_pos(x, y, direction)
@last_pos = [x, y, direction]
end
#--------------------------------------------------------------------------
# ● 指定座標までの移動をセット
#--------------------------------------------------------------------------
def setup_move_route(route_text)
set_last_pos(@x, @y, @direction) # 移動前の座標を記憶
route = RPG::MoveRoute.new
route.repeat = false
route.wait = true
speed = $game_srpgmap.show_fast? ? 6 : 4 # 早送り状態なら速度を速める
route.list[0] = RPG::MoveCommand.new(ROUTE_CHANGE_SPEED, [speed])
route.list.push(RPG::MoveCommand.new(ROUTE_THROUGH_ON, []))
route_text.length.times do |i|
route.list.push(RPG::MoveCommand.new(route_text[i].to_i))
end
route.list.push(RPG::MoveCommand.new(ROUTE_THROUGH_OFF, []))
route.list.push(RPG::MoveCommand.new(ROUTE_CHANGE_SPEED, [4])) # 速度を戻す
route.list.push(RPG::MoveCommand.new(0))
force_move_route(route)
end
#--------------------------------------------------------------------------
# ● ノックバックをセット
#--------------------------------------------------------------------------
def setup_knock_back(user, item)
route = RPG::MoveRoute.new
route.repeat = false
route.skippable = true
route.wait = true
route.list[0] = RPG::MoveCommand.new(ROUTE_CHANGE_SPEED, [6])
route.list.push(RPG::MoveCommand.new(ROUTE_DIR_FIX_ON, []))
item.knock_back[0].times do |i|
route.list.push(RPG::MoveCommand.new(user.direction / 2))
end
route.list.push(RPG::MoveCommand.new(ROUTE_DIR_FIX_OFF, []))
route.list.push(RPG::MoveCommand.new(ROUTE_CHANGE_SPEED, [4])) # 速度を戻す
route.list.push(RPG::MoveCommand.new(0))
force_move_route(route)
end
#--------------------------------------------------------------------------
# ● ノックバックキャンセルをセット
#--------------------------------------------------------------------------
def setup_knock_back_cancel(user)
route = RPG::MoveRoute.new
route.repeat = false
route.wait = true
route.list[0] = RPG::MoveCommand.new(ROUTE_DIR_FIX_ON, [])
route.list.push(RPG::MoveCommand.new(ROUTE_THROUGH_ON, []))
case user.direction
when 2; route.list.push(RPG::MoveCommand.new(ROUTE_JUMP, [0, -1]))
when 4; route.list.push(RPG::MoveCommand.new(ROUTE_JUMP, [1, 0]))
when 6; route.list.push(RPG::MoveCommand.new(ROUTE_JUMP, [-1, 0]))
when 8; route.list.push(RPG::MoveCommand.new(ROUTE_JUMP, [0, 1]))
end
route.list.push(RPG::MoveCommand.new(ROUTE_THROUGH_OFF, []))
route.list.push(RPG::MoveCommand.new(ROUTE_DIR_FIX_OFF, []))
route.list.push(RPG::MoveCommand.new(0))
force_move_route(route)
end
#--------------------------------------------------------------------------
# ● 指定した座標の方向を返す
#--------------------------------------------------------------------------
def direction_from_pos(x = nil, y = nil)
x ||= $game_srpgplayer.x
y ||= $game_srpgplayer.y
sx = distance_x_from(x)
sy = distance_y_from(y)
if sx.abs > sy.abs
sx > 0 ? 4 : 6
elsif sy != 0
sy > 0 ? 8 : 2
else
0
end
end
#--------------------------------------------------------------------------
# ● 指定した座標の方を向く
#--------------------------------------------------------------------------
def turn_toward_pos(x = nil, y = nil)
d = direction_from_pos(x, y)
set_direction(d) if d > 0
end
#--------------------------------------------------------------------------
# ● 移動の実行
#--------------------------------------------------------------------------
def execute_move
@moved = true
@step_anime = false if @acted
update_tile_state
end
#--------------------------------------------------------------------------
# ● 移動のキャンセル
#--------------------------------------------------------------------------
def reset_move
moveto(@last_pos[0], @last_pos[1])
@direction = @last_pos[2]
@moved = false
end
#--------------------------------------------------------------------------
# ● ゲートへ戻すときの処理
#--------------------------------------------------------------------------
def back_to_gate
@priority_type = 0
erase
end
#--------------------------------------------------------------------------
# ● 行動の実行
#--------------------------------------------------------------------------
def execute_action
return unless battler?
@acted = true
@step_anime = false if @moved
battler.on_action_end
popup_removed_status(@real_x + 0.5, @real_y) # 解除された効果をポップアップ
end
#--------------------------------------------------------------------------
# ● ターンリセット
#--------------------------------------------------------------------------
def on_turn_end
return unless battler?
#~ execute_action unless acted? # 行動していなければここで行動終了処理
@moved = false
@acted = false
@step_anime = true
battler.on_turn_end
popup_damage(@real_x + 0.5, @real_y)
popup_added_status(@real_x + 0.5, @real_y) # 付加された効果をポップアップ
popup_removed_status(@real_x + 0.5, @real_y) # 解除された効果をポップアップ
die(nil) if battler.dead?
end
#--------------------------------------------------------------------------
# ● 被行動結果をポップアップ
#--------------------------------------------------------------------------
def popup_result(user, item)
x = @real_x + 0.5
y = @real_y
if battler.result.missed
popup_miss(x, y)
elsif battler.result.evaded
popup_evade(x, y)
else
popup_added_status(x, y) # 付加された効果をポップアップ
popup_removed_status(x, y) # 解除された効果をポップアップ
popup_critical(x, y) if battler.result.critical
popup_damage(x, y, item)
popup_drain(user.real_x + 0.5, user.real_y)
end
end
#--------------------------------------------------------------------------
# ● ミスのポップアップ
#--------------------------------------------------------------------------
def popup_miss(x, y)
$game_srpgmap.add_popup(x, y, "MISS", 10)
end
#--------------------------------------------------------------------------
# ● 回避のポップアップ
#--------------------------------------------------------------------------
def popup_evade(x, y)
$game_srpgmap.add_popup(x, y, "DODGE", 10)
end
#--------------------------------------------------------------------------
# ● 付加された効果をポップアップ
#--------------------------------------------------------------------------
def popup_added_status(x, y)
# 付与されたステート
battler.result.added_state_objects.each do |state|
$game_srpgmap.add_popup(x, y, state.name, 0, :state)
y -= 0.5
end
# 付与されたバフ
battler.result.added_buffs.each do |param_id|
$game_srpgmap.add_popup(x, y, Vocab::param(param_id) + "+", 4, :state)
y -= 0.5
end
# 付与されたデバフ
battler.result.added_debuffs.each do |param_id|
$game_srpgmap.add_popup(x, y, Vocab::param(param_id) + "-", 5, :state)
y -= 0.5
end
end
#--------------------------------------------------------------------------
# ● 解除された効果をポップアップ
#--------------------------------------------------------------------------
def popup_removed_status(x, y)
# 解除されたステート
battler.result.removed_state_objects.each do |state|
$game_srpgmap.add_popup(x, y, state.name, 8, :remove)
y += 0.5
end
# 解除されたバフ、デバフ
battler.result.removed_buffs.each do |param_id|
$game_srpgmap.add_popup(x, y, Vocab::param(param_id), 8, :remove)
y += 0.5
end
end
#--------------------------------------------------------------------------
# ● クリティカルのポップアップ
#--------------------------------------------------------------------------
def popup_critical(x, y)
$game_srpgmap.add_popup(x, y - 0.5, "CRITICAL", 6)
end
#--------------------------------------------------------------------------
# ● ダメージのポップアップ
#--------------------------------------------------------------------------
def popup_damage(x, y, item = nil)
if battler.result.hp_damage != 0 || (item && item.damage.type == 1)
color_id = battler.result.hp_damage >= 0 ? 0 : 3
$game_srpgmap.add_popup(x, y, battler.result.hp_damage.abs.to_s, color_id)
end
if battler.result.mp_damage != 0 || (item && item.damage.type == 2)
color_id = battler.result.mp_damage >= 0 ? 0 : 3
$game_srpgmap.add_popup(x, y, "MND " + battler.result.mp_damage.abs.to_s, color_id)
end
end
#--------------------------------------------------------------------------
# ● 吸収のポップアップ
#--------------------------------------------------------------------------
def popup_drain(x, y)
if battler.result.hp_drain != 0
color_id = battler.result.hp_drain >= 0 ? 3 : 0
$game_srpgmap.add_popup(x, y, battler.result.hp_drain.abs.to_s, color_id)
end
if battler.result.mp_drain != 0
color_id = battler.result.mp_drain >= 0 ? 3 : 0
$game_srpgmap.add_popup(x, y, "MND " + battler.result.mp_drain.abs.to_s, color_id)
end
end
#--------------------------------------------------------------------------
# ● アニメーションの表示
#--------------------------------------------------------------------------
def setup_animation(user, animation_id)
if animation_id < 0
animation_id = user.atk_animation_id1
end
@animation_id = animation_id
end
#--------------------------------------------------------------------------
# ● スキル/アイテムの反撃率計算
#--------------------------------------------------------------------------
def item_cnt(user, item)
return 0 unless battler
return 0 unless item.physical? # 命中タイプが物理ではない
battler.make_actions
return 0 if (battler.current_action == nil)
battler.current_action.set_attack
unless $game_srpgmap.make_actable_area(x, y, battler.current_action.item)[[user.x, user.y]] == 1
return 0
end
battler.cnt
end
#--------------------------------------------------------------------------
# ● スキル/アイテムのノックバック率計算
#--------------------------------------------------------------------------
def item_knock_back(user, item)
return 0 unless battler.result.success
return 0 unless item.knock_back
return 0 unless battler
return 0 if rand < battler.knock_back_guard
return item.knock_back[1] / 100.0
end
#--------------------------------------------------------------------------
# ● 戦闘不能になった時の処理
#--------------------------------------------------------------------------
def die(attacker)
gain_reward(attacker)
unless object?
if enemy?
$game_srpgmap.increase_enemy_death
else
$game_srpgmap.increase_npc_death
end
end
Sound.play_enemy_collapse
key = [$game_srpgmap.map_id, @id, "D"]
$game_self_switches[key] = true
@priority_type = 0
@battler = nil
$game_srpgmap.check_gameover # ゲームオーバー判定
end
#--------------------------------------------------------------------------
# ● 撃破時のリワード獲得
#--------------------------------------------------------------------------
def gain_reward(attacker = nil)
exp = battler.exp
$game_party.members.each do |actor|
if attacker && attacker.actor? && actor.id == attacker.battler.id
actor.gain_exp((exp * TMSRPG::EXP_ATTACKER_RATE).to_i)
elsif $game_srpgmap.actor_in_battle?(actor.id)
actor.gain_exp((exp * TMSRPG::EXP_BATTLER_RATE).to_i)
else
actor.gain_exp((exp * TMSRPG::EXP_PARTY_RATE).to_i)
end
end
$game_party.gain_gold(battler.gold)
x = @real_x + 0.5
y = @real_y
battler.make_drop_items.each do |item|
$game_party.gain_item(item, 1)
$game_srpgmap.add_popup(x, y, "+" + item.name, 17, :reward)
y -= 0.5
end
end
#--------------------------------------------------------------------------
# ● 行動内容から移動先を決定する
#--------------------------------------------------------------------------
def make_move_pos
if @goal_pos # 移動目標が設定されている場合
return nearest_pos_from_goal(*@goal_pos)
end
if battler.actions.empty? || !battler.current_action.item # 行動が設定されていない場合は逃げる
target = nearest_opponent_event
return target ? farest_pos_from_target(target) : nil
end
item = battler.current_action.item
if acted? || item.effects.any? {|effect| effect.code == 41 && effect.data_id == 0 }
target = nearest_opponent_event
return nil unless target
farest_pos_from_target(target)
else
targets = item.for_friend? ? near_friend_events : near_opponent_events
return nil if targets.empty?
result = nil
score = 0
$game_srpgmap.movable_area_table.keys.each do |pos_m|
$game_srpgmap.make_actable_area(pos_m[0], pos_m[1], item).keys.each do |pos_a|
new_score = 0
effect_area_table = $game_srpgmap.make_effect_area_abs(self, pos_a)
targets.each do |target|
next unless effect_area_table.include?([target.x, target.y])
test_dir_penalty_pre_move(target, pos_m, target.x, target.y)
n = target.battler.test_damage_value(battler, item).abs + 1
n *= 2 if target.battler.hp < target.battler.mhp / 4
n *= 2 if target.battler.item_has_any_valid_effects?(battler, item)
new_score += n
end
result, score = pos_m, new_score if new_score > score
end
end
return result if result
targets.sort! {|a, b| distance_event_from(a) - distance_event_from(b) }
nearest_pos_from_target(targets[0])
end
end
#--------------------------------------------------------------------------
# ● 移動可能範囲の中から移動目標に一番近づける座標を返す
#--------------------------------------------------------------------------
def nearest_pos_from_goal(x, y)
return nil if pos?(x, y) # すでに目的地にいるなら移動しない
d = 500
result = nil
$game_srpgmap.movable_area_table.keys.each do |pos|
new_d = (pos[0] - x).abs + (pos[1] - y).abs
d, result = new_d, pos if new_d < d
end
result
end
#--------------------------------------------------------------------------
# ● 移動可能範囲の中から対象に一番近づける座標を返す
#--------------------------------------------------------------------------
def nearest_pos_from_target(target)
d = 500
result = nil
$game_srpgmap.movable_area_table.keys.each do |pos|
new_d = target.distance_pos_from(*pos)
d, result = new_d, pos if new_d < d
end
result
end
#--------------------------------------------------------------------------
# ● 移動可能範囲の中から対象から一番遠ざかる座標を返す
#--------------------------------------------------------------------------
def farest_pos_from_target(target)
d = 0
result = nil
$game_srpgmap.movable_area_table.keys.each do |pos|
new_d = target.distance_pos_from(*pos)
d, result = new_d, pos if new_d > d
end
result
end
#--------------------------------------------------------------------------
# ● 行動を実行する座標を決定する
#--------------------------------------------------------------------------
def make_action_pos
item = battler.current_action.item
score = 0
result = nil
$game_srpgmap.actable_area_table.keys.each do |pos_a|
new_score = 0
$game_srpgmap.effect_area_table.each do |pos_e|
x = pos_a[0] + pos_e[0]
y = pos_a[1] + pos_e[1]
target = $game_srpgmap.battler_event_xy(x, y)
next unless target # 誰も見つからない
next unless item.for_friend? == friend?(target) # 行動対象ではない
target.test_dir_penalty(self, target.x, target.y)
n = target.battler.test_damage_value(battler, item).abs + 1
n *= 2 if target.battler.hp < target.battler.mhp / 4
n *= 2 if target.battler.item_has_any_valid_effects?(battler, item)
new_score += n
end
score, result = new_score, pos_a if new_score > score
end
result
end
#--------------------------------------------------------------------------
# ● 指定したイベントのHPを回復する
#--------------------------------------------------------------------------
def gain_hp(value, enable_death = false)
if battler?
battler.change_hp(value, enable_death)
die(nil) if battler.dead?
end
end
#--------------------------------------------------------------------------
# ● 指定したイベントのMPを回復する
#--------------------------------------------------------------------------
def gain_mp(value)
battler.mp += value if battler?
end
#--------------------------------------------------------------------------
# ● 指定したイベントにステートを付加する
#--------------------------------------------------------------------------
def add_state(state_id)
battler.add_state(state_id) if battler?
end
#--------------------------------------------------------------------------
# ● 指定したイベントのステートを解除する
#--------------------------------------------------------------------------
def remove_state(state_id)
battler.remove_state(state_id) if battler?
end
#--------------------------------------------------------------------------
# ● 指定したイベントを全回復させる
#--------------------------------------------------------------------------
def recover_all
battler.recover_all if battler?
end
end
#==============================================================================
# ■ Game_SrpgActorEvent
#------------------------------------------------------------------------------
# 味方ユニットとして扱うイベントクラスです。
#==============================================================================
class Game_SrpgActorEvent < Game_SrpgEvent
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# event : RPG::Event
#--------------------------------------------------------------------------
def initialize(x, y, actor)
setup(x, y, actor)
end
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
def setup(x, y, actor)
init_public_members
init_private_members
@battler = actor
@step_anime = true
moveto(x, y)
refresh
end
#--------------------------------------------------------------------------
# ● アクターイベントかどうかを返す
#--------------------------------------------------------------------------
def actor?
battler?
end
#--------------------------------------------------------------------------
# ● エネミーイベントかどうかを返す
#--------------------------------------------------------------------------
def enemy?
false
end
#--------------------------------------------------------------------------
# ● 味方かどうかを返す
#--------------------------------------------------------------------------
def friend?(target)
return true if self == target
return false if battler.confusion_level == 2
(target.actor? || target.npc?) ^ (battler.confusion_level == 3)
end
#--------------------------------------------------------------------------
# ● オブジェクトイベントかどうかを返す
#--------------------------------------------------------------------------
def object?
false
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if @erased
clear_page_settings
else
set_graphic(battler.character_name, battler.character_index)
end
end
#--------------------------------------------------------------------------
# ● 行動の実行
#--------------------------------------------------------------------------
def execute_action
return unless battler?
super
n = TMSRPG::EXP_ACTION + (battler.next_level_exp -
battler.current_level_exp) * TMSRPG::EXP_ACTION_RATE
battler.gain_exp(n.to_i)
end
#--------------------------------------------------------------------------
# ● ミスのポップアップ
#--------------------------------------------------------------------------
def popup_miss(x, y)
$game_srpgmap.add_popup(x, y, "MISS", 0)
end
#--------------------------------------------------------------------------
# ● 回避のポップアップ
#--------------------------------------------------------------------------
def popup_evade(x, y)
$game_srpgmap.add_popup(x, y, "DODGE", 0)
end
#--------------------------------------------------------------------------
# ● ダメージのポップアップ
#--------------------------------------------------------------------------
def popup_damage(x, y, item = nil)
if battler.result.hp_damage != 0 || (item && item.damage.type == 1)
color_id = battler.result.hp_damage >= 0 ? 10 : 3
$game_srpgmap.add_popup(x, y, battler.result.hp_damage.abs.to_s, color_id)
end
if battler.result.mp_damage != 0 || (item && item.damage.type == 2)
color_id = battler.result.mp_damage >= 0 ? 10 : 3
$game_srpgmap.add_popup(x, y, "MND " + battler.result.mp_damage.abs.to_s, color_id)
end
end
#--------------------------------------------------------------------------
# ● 吸収のポップアップ
#--------------------------------------------------------------------------
def popup_drain(x, y)
if battler.result.hp_drain != 0
color_id = battler.result.hp_drain >= 0 ? 3 : 10
$game_srpgmap.add_popup(x, y, battler.result.hp_drain.abs.to_s, color_id)
end
if battler.result.mp_drain != 0
color_id = battler.result.mp_drain >= 0 ? 3 : 10
$game_srpgmap.add_popup(x, y, "MND " + battler.result.mp_drain.abs.to_s, color_id)
end
end
#--------------------------------------------------------------------------
# ● 戦闘不能になった時の処理
#--------------------------------------------------------------------------
def die(attacker)
$game_srpgmap.increase_actor_death
Sound.play_actor_collapse
@priority_type = 0
erase
$game_srpgmap.check_gameover # ゲームオーバー判定
end
end
#==============================================================================
# ■ Game_SrpgPopup
#------------------------------------------------------------------------------
# ポップアップを扱うクラスです。
#==============================================================================
class Game_SrpgPopup
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :text # テキスト
attr_reader :color # カラーインデックス
attr_reader :opacity # 不透明度
attr_reader :font_name # フォント
attr_reader :font_size # フォントサイズ
attr_reader :font_bold # フォント強調フラグ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(id)
@id = id
end
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
def setup(x, y, text, color, type_symbol = :damage)
@real_x = x
@real_y = y
@text = text
@color = color
@type_symbol = type_symbol
setup_type
end
#--------------------------------------------------------------------------
# ● ポップアップの種類をセット
#--------------------------------------------------------------------------
def setup_type
case @type_symbol
when :damage
@vx = 0
@vy = -0.09
@gravity = 0.003
@count = 75
@opacity = 255
@font_name = TMSRPG::POPUP_DAMAGE_FONT_NAME
@font_size = TMSRPG::POPUP_DAMAGE_FONT_SIZE
@font_bold = TMSRPG::POPUP_DAMAGE_FONT_BOLD
when :state
@vx = 0
@vy = -0.02
@gravity = 0
@count = 75
@opacity = 255
@font_name = TMSRPG::POPUP_STATE_FONT_NAME
@font_size = TMSRPG::POPUP_STATE_FONT_SIZE
@font_bold = TMSRPG::POPUP_STATE_FONT_BOLD
when :remove
@vx = 0
@vy = 0.02
@gravity = 0
@count = 75
@opacity = 255
@font_name = TMSRPG::POPUP_STATE_FONT_NAME
@font_size = TMSRPG::POPUP_STATE_FONT_SIZE
@font_bold = TMSRPG::POPUP_STATE_FONT_BOLD
when :reward
@vx = 0
@vy = 0
@gravity = 0
@count = 75
@opacity = 255
@font_name = TMSRPG::POPUP_STATE_FONT_NAME
@font_size = TMSRPG::POPUP_STATE_FONT_SIZE
@font_bold = TMSRPG::POPUP_STATE_FONT_BOLD
end
end
#--------------------------------------------------------------------------
# ● 画面 X 座標の取得
#--------------------------------------------------------------------------
def screen_x
$game_srpgmap.adjust_x(@real_x) * 32
end
#--------------------------------------------------------------------------
# ● 画面 Y 座標の取得
#--------------------------------------------------------------------------
def screen_y
$game_srpgmap.adjust_y(@real_y) * 32
end
#--------------------------------------------------------------------------
# ● 画面 Z 座標の取得
#--------------------------------------------------------------------------
def screen_z
@id + 500
end
#--------------------------------------------------------------------------
# ● 削除されているかどうかを返す
#--------------------------------------------------------------------------
def erased?
@text == nil
end
#--------------------------------------------------------------------------
# ● 削除
#--------------------------------------------------------------------------
def erase
@text = nil
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
return if erased?
@count -= 1
@opacity = @count << 3
@real_x += @vx
@real_y += @vy
@vy = [@vy + @gravity, 4].min
erase if @count == 0
end
end
#==============================================================================
# ■ Game_SrpgInterpreter
#------------------------------------------------------------------------------
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_SrpgInterpreter
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :map_id # マップ ID
attr_reader :event_id # イベント ID(通常イベントのみ)
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# depth : ネストの深さ
#--------------------------------------------------------------------------
def initialize(depth = 0)
@depth = depth
check_overflow
clear
end
#--------------------------------------------------------------------------
# ● オーバーフローのチェック
# 通常の使用で深さが 100 以上になることはない。再帰的なイベント呼び出し
# による無限ループの可能性が高いので、100 で打ち切ってエラーにする。
#--------------------------------------------------------------------------
def check_overflow
if @depth >= 100
msgbox(Vocab::EventOverflow)
exit
end
end
#--------------------------------------------------------------------------
# ● クリア
#--------------------------------------------------------------------------
def clear
@map_id = 0
@event_id = 0
@list = nil # 実行内容
@index = 0 # インデックス
@branch = {} # 分岐データ
@fiber = nil # ファイバー
end
#--------------------------------------------------------------------------
# ● イベントのセットアップ
#--------------------------------------------------------------------------
def setup(list, event_id = 0)
clear
@map_id = $game_srpgmap.map_id
@event_id = event_id
@list = list
create_fiber
end
#--------------------------------------------------------------------------
# ● ファイバーの作成
#--------------------------------------------------------------------------
def create_fiber
@fiber = Fiber.new { run } if @list
end
#--------------------------------------------------------------------------
# ● オブジェクトのダンプ
# ファイバーは Marshal に対応していないため自前で定義する。
# イベントの実行位置は一つ進めて保存する。
#--------------------------------------------------------------------------
def marshal_dump
[@depth, @map_id, @event_id, @list, @index + 1, @branch]
end
#--------------------------------------------------------------------------
# ● オブジェクトのロード
# obj : marshal_dump でダンプされたオブジェクト(配列)
# 多重代入でデータを復帰し、必要ならファイバーを再作成する。
#--------------------------------------------------------------------------
def marshal_load(obj)
@depth, @map_id, @event_id, @list, @index, @branch = obj
create_fiber
end
#--------------------------------------------------------------------------
# ● イベント起動時のマップと同じか判定
#--------------------------------------------------------------------------
def same_map?
@map_id == $game_srpgmap.map_id
end
#--------------------------------------------------------------------------
# ● 呼び出し予約されたコモンイベントを検出/セットアップ
#--------------------------------------------------------------------------
def setup_reserved_common_event
if $game_temp.common_event_reserved?
setup($game_temp.reserved_common_event.list)
$game_temp.clear_common_event
true
else
false
end
end
#--------------------------------------------------------------------------
# ● 実行
#--------------------------------------------------------------------------
def run
wait_for_message
while @list[@index] do
execute_command
@index += 1
end
Fiber.yield
@fiber = nil
end
#--------------------------------------------------------------------------
# ● 実行中判定
#--------------------------------------------------------------------------
def running?
@fiber != nil
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
@fiber.resume if @fiber
end
#--------------------------------------------------------------------------
# ● アクター用イテレータ(ID)
# param : 1 以上なら ID、0 なら全体
#--------------------------------------------------------------------------
def iterate_actor_id(param)
if param == 0
$game_party.members.each {|actor| yield actor }
else
actor = $game_actors[param]
yield actor if actor
end
end
#--------------------------------------------------------------------------
# ● アクター用イテレータ(可変)
# param1 : 0 なら固定、1 なら変数で指定
# param2 : アクターまたは変数 ID
#--------------------------------------------------------------------------
def iterate_actor_var(param1, param2)
if param1 == 0
iterate_actor_id(param2) {|actor| yield actor }
else
iterate_actor_id($game_variables[param2]) {|actor| yield actor }
end
end
#--------------------------------------------------------------------------
# ● アクター用イテレータ(インデックス)
# param : 0 以上ならインデックス、-1 なら全体
#--------------------------------------------------------------------------
def iterate_actor_index(param)
if param < 0
$game_party.members.each {|actor| yield actor }
else
actor = $game_party.members[param]
yield actor if actor
end
end
#--------------------------------------------------------------------------
# ● 敵キャラ用イテレータ(インデックス)
# param : 0 以上ならインデックス、-1 なら全体
#--------------------------------------------------------------------------
def iterate_enemy_index(param)
if param < 0
$game_troop.members.each {|enemy| yield enemy }
else
enemy = $game_troop.members[param]
yield enemy if enemy
end
end
#--------------------------------------------------------------------------
# ● バトラー用イテレータ(敵グループ全体、パーティ全体を考慮)
# param1 : 0 なら敵キャラ、1 ならアクター
# param2 : 敵キャラならインデックス、アクターなら ID
#--------------------------------------------------------------------------
def iterate_battler(param1, param2)
if $game_party.in_battle
if param1 == 0
iterate_enemy_index(param2) {|enemy| yield enemy }
else
iterate_actor_id(param2) {|actor| yield actor }
end
end
end
#--------------------------------------------------------------------------
# ● 画面系コマンドの対象を取得
#--------------------------------------------------------------------------
def screen
$game_srpgmap.screen
end
#--------------------------------------------------------------------------
# ● イベントコマンドの実行
#--------------------------------------------------------------------------
def execute_command
command = @list[@index]
@params = command.parameters
@indent = command.indent
method_name = "command_#{command.code}"
send(method_name) if respond_to?(method_name)
end
#--------------------------------------------------------------------------
# ● コマンドスキップ
# 現在のインデントより深いコマンドを飛ばしてインデックスを進める。
#--------------------------------------------------------------------------
def command_skip
@index += 1 while @list[@index + 1].indent > @indent
end
#--------------------------------------------------------------------------
# ● 次のイベントコマンドのコードを取得
#--------------------------------------------------------------------------
def next_event_code
@list[@index + 1].code
end
#--------------------------------------------------------------------------
# ● キャラクターの取得
# param : -1 ならプレイヤー、0 ならこのイベント、それ以外はイベント ID
#--------------------------------------------------------------------------
def get_character(param)
if param < 0
$game_temp.srpg_last_user
else
events = same_map? ? $game_srpgmap.events : {}
events[param > 0 ? param : @event_id]
end
end
#--------------------------------------------------------------------------
# ● 操作する値の計算
# operation : 操作(0:増やす 1:減らす)
# operand_type : オペランドタイプ(0:定数 1:変数)
# operand : オペランド(数値または変数 ID)
#--------------------------------------------------------------------------
def operate_value(operation, operand_type, operand)
value = operand_type == 0 ? operand : $game_variables[operand]
operation == 0 ? value : -value
end
#--------------------------------------------------------------------------
# ● ウェイト
#--------------------------------------------------------------------------
def wait(duration)
duration.times { Fiber.yield }
end
#--------------------------------------------------------------------------
# ● メッセージ表示がビジー状態の間ウェイト
#--------------------------------------------------------------------------
def wait_for_message
Fiber.yield while $game_message.busy?
end
#--------------------------------------------------------------------------
# ● 文章の表示
#--------------------------------------------------------------------------
def command_101
wait_for_message
$game_message.face_name = @params[0]
$game_message.face_index = @params[1]
$game_message.background = @params[2]
$game_message.position = @params[3]
while next_event_code == 401 # 文章データ
@index += 1
$game_message.add(@list[@index].parameters[0])
end
case next_event_code
when 102 # 選択肢の表示
@index += 1
setup_choices(@list[@index].parameters)
when 103 # 数値入力の処理
@index += 1
setup_num_input(@list[@index].parameters)
when 104 # アイテム選択の処理
@index += 1
setup_item_choice(@list[@index].parameters)
end
wait_for_message
end
#--------------------------------------------------------------------------
# ● 選択肢の表示
#--------------------------------------------------------------------------
def command_102
wait_for_message
setup_choices(@params)
Fiber.yield while $game_message.choice?
end
#--------------------------------------------------------------------------
# ● 選択肢のセットアップ
#--------------------------------------------------------------------------
def setup_choices(params)
params[0].each {|s| $game_message.choices.push(s) }
$game_message.choice_cancel_type = params[1]
$game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
end
#--------------------------------------------------------------------------
# ● [**] の場合
#--------------------------------------------------------------------------
def command_402
command_skip if @branch[@indent] != @params[0]
end
#--------------------------------------------------------------------------
# ● キャンセルの場合
#--------------------------------------------------------------------------
def command_403
command_skip if @branch[@indent] != 4
end
#--------------------------------------------------------------------------
# ● 数値入力の処理
#--------------------------------------------------------------------------
def command_103
wait_for_message
setup_num_input(@params)
Fiber.yield while $game_message.num_input?
end
#--------------------------------------------------------------------------
# ● 数値入力のセットアップ
#--------------------------------------------------------------------------
def setup_num_input(params)
$game_message.num_input_variable_id = params[0]
$game_message.num_input_digits_max = params[1]
end
#--------------------------------------------------------------------------
# ● アイテム選択の処理
#--------------------------------------------------------------------------
def command_104
wait_for_message
setup_item_choice(@params)
Fiber.yield while $game_message.item_choice?
end
#--------------------------------------------------------------------------
# ● アイテム選択のセットアップ
#--------------------------------------------------------------------------
def setup_item_choice(params)
$game_message.item_choice_variable_id = params[0]
end
#--------------------------------------------------------------------------
# ● スクロール文章の表示
#--------------------------------------------------------------------------
def command_105
Fiber.yield while $game_message.visible
$game_message.scroll_mode = true
$game_message.scroll_speed = @params[0]
$game_message.scroll_no_fast = @params[1]
while next_event_code == 405
@index += 1
$game_message.add(@list[@index].parameters[0])
end
wait_for_message
end
#--------------------------------------------------------------------------
# ● 注釈
#--------------------------------------------------------------------------
def command_108
@comments = [@params[0]]
while next_event_code == 408
@index += 1
@comments.push(@list[@index].parameters[0])
end
end
#--------------------------------------------------------------------------
# ● 条件分岐
#--------------------------------------------------------------------------
def command_111
result = false
case @params[0]
when 0 # スイッチ
result = ($game_switches[@params[1]] == (@params[2] == 0))
when 1 # 変数
value1 = $game_variables[@params[1]]
if @params[2] == 0
value2 = @params[3]
else
value2 = $game_variables[@params[3]]
end
case @params[4]
when 0 # と同値
result = (value1 == value2)
when 1 # 以上
result = (value1 >= value2)
when 2 # 以下
result = (value1 <= value2)
when 3 # 超
result = (value1 > value2)
when 4 # 未満
result = (value1 < value2)
when 5 # 以外
result = (value1 != value2)
end
when 2 # セルフスイッチ
if @event_id > 0
key = [@map_id, @event_id, @params[1]]
result = ($game_self_switches[key] == (@params[2] == 0))
end
when 3 # タイマー
if $game_timer.working?
if @params[2] == 0
result = ($game_timer.sec >= @params[1])
else
result = ($game_timer.sec <= @params[1])
end
end
when 4 # アクター
actor = $game_actors[@params[1]]
if actor
case @params[2]
when 0 # パーティにいる
result = ($game_party.members.include?(actor))
when 1 # 名前
result = (actor.name == @params[3])
when 2 # 職業
result = (actor.class_id == @params[3])
when 3 # スキル
result = (actor.skill_learn?($data_skills[@params[3]]))
when 4 # 武器
result = (actor.weapons.include?($data_weapons[@params[3]]))
when 5 # 防具
result = (actor.armors.include?($data_armors[@params[3]]))
when 6 # ステート
result = (actor.state?(@params[3]))
end
end
when 5 # 敵キャラ
enemy = $game_troop.members[@params[1]]
if enemy
case @params[2]
when 0 # 出現している
result = (enemy.alive?)
when 1 # ステート
result = (enemy.state?(@params[3]))
end
end
when 6 # キャラクター
character = get_character(@params[1])
if character
result = (character.direction == @params[2])
end
when 7 # ゴールド
case @params[2]
when 0 # 以上
result = ($game_party.gold >= @params[1])
when 1 # 以下
result = ($game_party.gold <= @params[1])
when 2 # 未満
result = ($game_party.gold < @params[1])
end
when 8 # アイテム
result = $game_party.has_item?($data_items[@params[1]])
when 9 # 武器
result = $game_party.has_item?($data_weapons[@params[1]], @params[2])
when 10 # 防具
result = $game_party.has_item?($data_armors[@params[1]], @params[2])
when 11 # ボタン
result = Input.press?(@params[1])
when 12 # スクリプト
result = eval(@params[1])
when 13 # 乗り物
result = ($game_player.vehicle == $game_map.vehicles[@params[1]])
end
@branch[@indent] = result
command_skip if !@branch[@indent]
end
#--------------------------------------------------------------------------
# ● それ以外の場合
#--------------------------------------------------------------------------
def command_411
command_skip if @branch[@indent]
end
#--------------------------------------------------------------------------
# ● ループ
#--------------------------------------------------------------------------
def command_112
end
#--------------------------------------------------------------------------
# ● 以上繰り返し
#--------------------------------------------------------------------------
def command_413
begin
@index -= 1
end until @list[@index].indent == @indent
end
#--------------------------------------------------------------------------
# ● ループの中断
#--------------------------------------------------------------------------
def command_113
loop do
@index += 1
return if @index >= @list.size - 1
return if @list[@index].code == 413 && @list[@index].indent < @indent
end
end
#--------------------------------------------------------------------------
# ● イベント処理の中断
#--------------------------------------------------------------------------
def command_115
@index = @list.size
end
#--------------------------------------------------------------------------
# ● コモンイベント
#--------------------------------------------------------------------------
def command_117
common_event = $data_common_events[@params[0]]
if common_event
child = Game_Interpreter.new(@depth + 1)
child.setup(common_event.list, same_map? ? @event_id : 0)
child.run
end
end
#--------------------------------------------------------------------------
# ● ラベル
#--------------------------------------------------------------------------
def command_118
end
#--------------------------------------------------------------------------
# ● ラベルジャンプ
#--------------------------------------------------------------------------
def command_119
label_name = @params[0]
@list.size.times do |i|
if @list[i].code == 118 && @list[i].parameters[0] == label_name
@index = i
return
end
end
end
#--------------------------------------------------------------------------
# ● スイッチの操作
#--------------------------------------------------------------------------
def command_121
(@params[0]..@params[1]).each do |i|
$game_switches[i] = (@params[2] == 0)
end
end
#--------------------------------------------------------------------------
# ● 変数の操作
#--------------------------------------------------------------------------
def command_122
value = 0
case @params[3] # オペランド
when 0 # 定数
value = @params[4]
when 1 # 変数
value = $game_variables[@params[4]]
when 2 # 乱数
value = @params[4] + rand(@params[5] - @params[4] + 1)
when 3 # ゲームデータ
value = game_data_operand(@params[4], @params[5], @params[6])
when 4 # スクリプト
value = eval(@params[4])
end
(@params[0]..@params[1]).each do |i|
operate_variable(i, @params[2], value)
end
end
#--------------------------------------------------------------------------
# ● 変数オペランド用ゲームデータの取得
#--------------------------------------------------------------------------
def game_data_operand(type, param1, param2)
case type
when 0 # アイテム
return $game_party.item_number($data_items[param1])
when 1 # 武器
return $game_party.item_number($data_weapons[param1])
when 2 # 防具
return $game_party.item_number($data_armors[param1])
when 3 # アクター
actor = $game_actors[param1]
if actor
case param2
when 0 # レベル
return actor.level
when 1 # 経験値
return actor.exp
when 2 # HP
return actor.hp
when 3 # MP
return actor.mp
when 4..11 # 通常能力値
return actor.param(param2 - 4)
end
end
when 4 # 敵キャラ
enemy = $game_troop.members[param1]
if enemy
case param2
when 0 # HP
return enemy.hp
when 1 # MP
return enemy.mp
when 2..9 # 通常能力値
return enemy.param(param2 - 2)
end
end
when 5 # キャラクター
character = get_character(param1)
if character
case param2
when 0 # X 座標
return character.x
when 1 # Y 座標
return character.y
when 2 # 向き
return character.direction
when 3 # 画面 X 座標
return character.screen_x
when 4 # 画面 Y 座標
return character.screen_y
end
end
when 6 # パーティ
actor = $game_party.members[param1]
return actor ? actor.id : 0
when 7 # その他
case param1
when 0 # マップ ID
return $game_srpgmap.map_id
when 1 # パーティ人数
return $game_party.members.size
when 2 # ゴールド
return $game_party.gold
when 3 # 歩数
return $game_party.steps
when 4 # プレイ時間
return Graphics.frame_count / Graphics.frame_rate
when 5 # タイマー
return $game_timer.sec
when 6 # セーブ回数
return $game_system.save_count
when 7 # 戦闘回数
return $game_system.battle_count
end
end
return 0
end
#--------------------------------------------------------------------------
# ● 変数の操作を実行
#--------------------------------------------------------------------------
def operate_variable(variable_id, operation_type, value)
begin
case operation_type
when 0 # 代入
$game_variables[variable_id] = value
when 1 # 加算
$game_variables[variable_id] += value
when 2 # 減算
$game_variables[variable_id] -= value
when 3 # 乗算
$game_variables[variable_id] *= value
when 4 # 除算
$game_variables[variable_id] /= value
when 5 # 剰余
$game_variables[variable_id] %= value
end
rescue
$game_variables[variable_id] = 0
end
end
#--------------------------------------------------------------------------
# ● セルフスイッチの操作
#--------------------------------------------------------------------------
def command_123
if @event_id > 0
key = [@map_id, @event_id, @params[0]]
$game_self_switches[key] = (@params[1] == 0)
end
end
#--------------------------------------------------------------------------
# ● タイマーの操作
#--------------------------------------------------------------------------
def command_124
if @params[0] == 0 # 始動
$game_timer.start(@params[1] * Graphics.frame_rate)
else # 停止
$game_timer.stop
end
end
#--------------------------------------------------------------------------
# ● 所持金の増減
#--------------------------------------------------------------------------
def command_125
value = operate_value(@params[0], @params[1], @params[2])
$game_party.gain_gold(value)
end
#--------------------------------------------------------------------------
# ● アイテムの増減
#--------------------------------------------------------------------------
def command_126
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item($data_items[@params[0]], value)
end
#--------------------------------------------------------------------------
# ● 武器の増減
#--------------------------------------------------------------------------
def command_127
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item($data_weapons[@params[0]], value, @params[4])
end
#--------------------------------------------------------------------------
# ● 防具の増減
#--------------------------------------------------------------------------
def command_128
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item($data_armors[@params[0]], value, @params[4])
end
#--------------------------------------------------------------------------
# ● メンバーの入れ替え
#--------------------------------------------------------------------------
def command_129
actor = $game_actors[@params[0]]
if actor
if @params[1] == 0 # 加える
if @params[2] == 1 # 初期化
$game_actors[@params[0]].setup(@params[0])
end
$game_party.add_actor(@params[0])
else # 外す
$game_party.remove_actor(@params[0])
end
end
end
#--------------------------------------------------------------------------
# ● 戦闘 BGM の変更
#--------------------------------------------------------------------------
def command_132
$game_system.battle_bgm = @params[0]
end
#--------------------------------------------------------------------------
# ● 戦闘終了 ME の変更
#--------------------------------------------------------------------------
def command_133
$game_system.battle_end_me = @params[0]
end
#--------------------------------------------------------------------------
# ● セーブ禁止の変更
#--------------------------------------------------------------------------
def command_134
$game_system.save_disabled = (@params[0] == 0)
end
#--------------------------------------------------------------------------
# ● メニュー禁止の変更
#--------------------------------------------------------------------------
def command_135
$game_system.menu_disabled = (@params[0] == 0)
end
#--------------------------------------------------------------------------
# ● エンカウント禁止の変更
#--------------------------------------------------------------------------
def command_136
$game_system.encounter_disabled = (@params[0] == 0)
$game_player.make_encounter_count
end
#--------------------------------------------------------------------------
# ● 並び替え禁止の変更
#--------------------------------------------------------------------------
def command_137
$game_system.formation_disabled = (@params[0] == 0)
end
#--------------------------------------------------------------------------
# ● ウィンドウカラーの変更
#--------------------------------------------------------------------------
def command_138
$game_system.window_tone = @params[0]
end
#--------------------------------------------------------------------------
# ● 場所移動
#--------------------------------------------------------------------------
def command_201
return if $game_party.in_battle
Fiber.yield while $game_player.transfer? || $game_message.visible
if @params[0] == 0 # 直接指定
map_id = @params[1]
x = @params[2]
y = @params[3]
else # 変数で指定
map_id = $game_variables[@params[1]]
x = $game_variables[@params[2]]
y = $game_variables[@params[3]]
end
$game_player.reserve_transfer(map_id, x, y, @params[4])
$game_temp.fade_type = @params[5]
Fiber.yield while $game_player.transfer?
end
#--------------------------------------------------------------------------
# ● 乗り物の位置設定
#--------------------------------------------------------------------------
def command_202
if @params[1] == 0 # 直接指定
map_id = @params[2]
x = @params[3]
y = @params[4]
else # 変数で指定
map_id = $game_variables[@params[2]]
x = $game_variables[@params[3]]
y = $game_variables[@params[4]]
end
vehicle = $game_map.vehicles[@params[0]]
vehicle.set_location(map_id, x, y) if vehicle
end
#--------------------------------------------------------------------------
# ● イベントの位置設定
#--------------------------------------------------------------------------
def command_203
character = get_character(@params[0])
if character
if @params[1] == 0 # 直接指定
character.moveto(@params[2], @params[3])
elsif @params[1] == 1 # 変数で指定
new_x = $game_variables[@params[2]]
new_y = $game_variables[@params[3]]
character.moveto(new_x, new_y)
else # 他のイベントと交換
character2 = get_character(@params[2])
character.swap(character2) if character2
end
character.set_direction(@params[4]) if @params[4] > 0
end
end
#--------------------------------------------------------------------------
# ● マップのスクロール
#--------------------------------------------------------------------------
def command_204
return if $game_party.in_battle
Fiber.yield while $game_srpgmap.scrolling?
$game_srpgmap.start_scroll(@params[0], @params[1], @params[2])
end
#--------------------------------------------------------------------------
# ● 移動ルートの設定
#--------------------------------------------------------------------------
def command_205
$game_srpgmap.refresh if $game_srpgmap.need_refresh
character = get_character(@params[0])
if character
character.force_move_route(@params[1])
Fiber.yield while character.move_route_forcing if @params[1].wait
end
end
#--------------------------------------------------------------------------
# ● 乗り物の乗降
#--------------------------------------------------------------------------
def command_206
$game_player.get_on_off_vehicle
end
#--------------------------------------------------------------------------
# ● 透明状態の変更
#--------------------------------------------------------------------------
def command_211
$game_player.transparent = (@params[0] == 0)
end
#--------------------------------------------------------------------------
# ● アニメーションの表示
#--------------------------------------------------------------------------
def command_212
character = get_character(@params[0])
if character
character.animation_id = @params[1]
Fiber.yield while character.animation_id > 0 if @params[2]
end
end
#--------------------------------------------------------------------------
# ● フキダシアイコンの表示
#--------------------------------------------------------------------------
def command_213
character = get_character(@params[0])
if character
character.balloon_id = @params[1]
Fiber.yield while character.balloon_id > 0 if @params[2]
end
end
#--------------------------------------------------------------------------
# ● イベントの一時消去
#--------------------------------------------------------------------------
def command_214
$game_srpgmap.events[@event_id].erase if same_map? && @event_id > 0
end
#--------------------------------------------------------------------------
# ● 隊列歩行の変更
#--------------------------------------------------------------------------
def command_216
$game_player.followers.visible = (@params[0] == 0)
$game_player.refresh
end
#--------------------------------------------------------------------------
# ● 隊列メンバーの集合
#--------------------------------------------------------------------------
def command_217
return if $game_party.in_battle
$game_player.followers.gather
Fiber.yield until $game_player.followers.gather?
end
#--------------------------------------------------------------------------
# ● 画面のフェードアウト
#--------------------------------------------------------------------------
def command_221
Fiber.yield while $game_message.visible
screen.start_fadeout(30)
wait(30)
end
#--------------------------------------------------------------------------
# ● 画面のフェードイン
#--------------------------------------------------------------------------
def command_222
Fiber.yield while $game_message.visible
screen.start_fadein(30)
wait(30)
end
#--------------------------------------------------------------------------
# ● 画面の色調変更
#--------------------------------------------------------------------------
def command_223
screen.start_tone_change(@params[0], @params[1])
wait(@params[1]) if @params[2]
end
#--------------------------------------------------------------------------
# ● 画面のフラッシュ
#--------------------------------------------------------------------------
def command_224
screen.start_flash(@params[0], @params[1])
wait(@params[1]) if @params[2]
end
#--------------------------------------------------------------------------
# ● 画面のシェイク
#--------------------------------------------------------------------------
def command_225
screen.start_shake(@params[0], @params[1], @params[2])
wait(@params[1]) if @params[2]
end
#--------------------------------------------------------------------------
# ● ウェイト
#--------------------------------------------------------------------------
def command_230
wait(@params[0])
end
#--------------------------------------------------------------------------
# ● ピクチャの表示
#--------------------------------------------------------------------------
def command_231
if @params[3] == 0 # 直接指定
x = @params[4]
y = @params[5]
else # 変数で指定
x = $game_variables[@params[4]]
y = $game_variables[@params[5]]
end
screen.pictures[@params[0]].show(@params[1], @params[2],
x, y, @params[6], @params[7], @params[8], @params[9])
end
#--------------------------------------------------------------------------
# ● ピクチャの移動
#--------------------------------------------------------------------------
def command_232
if @params[3] == 0 # 直接指定
x = @params[4]
y = @params[5]
else # 変数で指定
x = $game_variables[@params[4]]
y = $game_variables[@params[5]]
end
screen.pictures[@params[0]].move(@params[2], x, y, @params[6],
@params[7], @params[8], @params[9], @params[10])
wait(@params[10]) if @params[11]
end
#--------------------------------------------------------------------------
# ● ピクチャの回転
#--------------------------------------------------------------------------
def command_233
screen.pictures[@params[0]].rotate(@params[1])
end
#--------------------------------------------------------------------------
# ● ピクチャの色調変更
#--------------------------------------------------------------------------
def command_234
screen.pictures[@params[0]].start_tone_change(@params[1], @params[2])
wait(@params[2]) if @params[3]
end
#--------------------------------------------------------------------------
# ● ピクチャの消去
#--------------------------------------------------------------------------
def command_235
screen.pictures[@params[0]].erase
end
#--------------------------------------------------------------------------
# ● 天候の設定
#--------------------------------------------------------------------------
def command_236
return if $game_party.in_battle
screen.change_weather(@params[0], @params[1], @params[2])
wait(@params[2]) if @params[3]
end
#--------------------------------------------------------------------------
# ● BGM の演奏
#--------------------------------------------------------------------------
def command_241
@params[0].play
end
#--------------------------------------------------------------------------
# ● BGM のフェードアウト
#--------------------------------------------------------------------------
def command_242
RPG::BGM.fade(@params[0] * 1000)
end
#--------------------------------------------------------------------------
# ● BGM の保存
#--------------------------------------------------------------------------
def command_243
$game_system.save_bgm
end
#--------------------------------------------------------------------------
# ● BGM の再開
#--------------------------------------------------------------------------
def command_244
$game_system.replay_bgm
end
#--------------------------------------------------------------------------
# ● BGS の演奏
#--------------------------------------------------------------------------
def command_245
@params[0].play
end
#--------------------------------------------------------------------------
# ● BGS のフェードアウト
#--------------------------------------------------------------------------
def command_246
RPG::BGS.fade(@params[0] * 1000)
end
#--------------------------------------------------------------------------
# ● ME の演奏
#--------------------------------------------------------------------------
def command_249
@params[0].play
end
#--------------------------------------------------------------------------
# ● SE の演奏
#--------------------------------------------------------------------------
def command_250
@params[0].play
end
#--------------------------------------------------------------------------
# ● SE の停止
#--------------------------------------------------------------------------
def command_251
RPG::SE.stop
end
#--------------------------------------------------------------------------
# ● ムービーの再生
#--------------------------------------------------------------------------
def command_261
Fiber.yield while $game_message.visible
Fiber.yield
name = @params[0]
Graphics.play_movie('Movies/' + name) unless name.empty?
end
#--------------------------------------------------------------------------
# ● マップ名表示の変更
#--------------------------------------------------------------------------
def command_281
$game_srpgmap.name_display = (@params[0] == 0)
end
#--------------------------------------------------------------------------
# ● タイルセットの変更
#--------------------------------------------------------------------------
def command_282
$game_srpgmap.change_tileset(@params[0])
end
#--------------------------------------------------------------------------
# ● 戦闘背景の変更
#--------------------------------------------------------------------------
def command_283
$game_srpgmap.change_battleback(@params[0], @params[1])
end
#--------------------------------------------------------------------------
# ● 遠景の変更
#--------------------------------------------------------------------------
def command_284
$game_srpgmap.change_parallax(@params[0], @params[1], @params[2],
@params[3], @params[4])
end
#--------------------------------------------------------------------------
# ● 指定位置の情報取得
#--------------------------------------------------------------------------
def command_285
if @params[2] == 0 # 直接指定
x = @params[3]
y = @params[4]
else # 変数で指定
x = $game_variables[@params[3]]
y = $game_variables[@params[4]]
end
case @params[1]
when 0 # 地形タグ
value = $game_srpgmap.terrain_tag(x, y)
when 1 # イベント ID
value = $game_srpgmap.event_id_xy(x, y)
when 2..4 # タイル ID
value = $game_srpgmap.tile_id(x, y, @params[1] - 2)
else # リージョン ID
value = $game_srpgmap.region_id(x, y)
end
$game_variables[@params[0]] = value
end
#--------------------------------------------------------------------------
# ● バトルの処理
#--------------------------------------------------------------------------
def command_301
return if $game_party.in_battle
if @params[0] == 0 # 直接指定
troop_id = @params[1]
elsif @params[0] == 1 # 変数で指定
troop_id = $game_variables[@params[1]]
else # マップ指定の敵グループ
troop_id = $game_player.make_encounter_troop_id
end
if $data_troops[troop_id]
BattleManager.setup(troop_id, @params[2], @params[3])
BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n }
$game_player.make_encounter_count
SceneManager.call(Scene_Battle)
end
Fiber.yield
end
#--------------------------------------------------------------------------
# ● 勝った場合
#--------------------------------------------------------------------------
def command_601
command_skip if @branch[@indent] != 0
end
#--------------------------------------------------------------------------
# ● 逃げた場合
#--------------------------------------------------------------------------
def command_602
command_skip if @branch[@indent] != 1
end
#--------------------------------------------------------------------------
# ● 負けた場合
#--------------------------------------------------------------------------
def command_603
command_skip if @branch[@indent] != 2
end
#--------------------------------------------------------------------------
# ● ショップの処理
#--------------------------------------------------------------------------
def command_302
return if $game_party.in_battle
goods = [@params]
while next_event_code == 605
@index += 1
goods.push(@list[@index].parameters)
end
SceneManager.call(Scene_Shop)
SceneManager.scene.prepare(goods, @params[4])
Fiber.yield
end
#--------------------------------------------------------------------------
# ● 名前入力の処理
#--------------------------------------------------------------------------
def command_303
return if $game_party.in_battle
if $data_actors[@params[0]]
SceneManager.call(Scene_Name)
SceneManager.scene.prepare(@params[0], @params[1])
Fiber.yield
end
end
#--------------------------------------------------------------------------
# ● HP の増減
#--------------------------------------------------------------------------
def command_311
value = operate_value(@params[2], @params[3], @params[4])
iterate_actor_var(@params[0], @params[1]) do |actor|
next if actor.dead?
actor.change_hp(value, @params[5])
if actor.dead?
actor_event = $game_srpgmap.actor_event(actor.id)
actor_event.die(nil) if actor_event
end
end
#~ SceneManager.goto(Scene_Gameover) if $game_party.all_dead?
end
#--------------------------------------------------------------------------
# ● MP の増減
#--------------------------------------------------------------------------
def command_312
value = operate_value(@params[2], @params[3], @params[4])
iterate_actor_var(@params[0], @params[1]) do |actor|
actor.mp += value
end
end
#--------------------------------------------------------------------------
# ● ステートの変更
#--------------------------------------------------------------------------
def command_313
iterate_actor_var(@params[0], @params[1]) do |actor|
already_dead = actor.dead?
if @params[2] == 0
actor.add_state(@params[3])
else
actor.remove_state(@params[3])
end
actor.perform_collapse_effect if actor.dead? && !already_dead
end
end
#--------------------------------------------------------------------------
# ● 全回復
#--------------------------------------------------------------------------
def command_314
iterate_actor_var(@params[0], @params[1]) do |actor|
actor.recover_all
end
end
#--------------------------------------------------------------------------
# ● 経験値の増減
#--------------------------------------------------------------------------
def command_315
value = operate_value(@params[2], @params[3], @params[4])
iterate_actor_var(@params[0], @params[1]) do |actor|
actor.change_exp(actor.exp + value, @params[5])
end
end
#--------------------------------------------------------------------------
# ● レベルの増減
#--------------------------------------------------------------------------
def command_316
value = operate_value(@params[2], @params[3], @params[4])
iterate_actor_var(@params[0], @params[1]) do |actor|
actor.change_level(actor.level + value, @params[5])
end
end
#--------------------------------------------------------------------------
# ● 能力値の増減
#--------------------------------------------------------------------------
def command_317
value = operate_value(@params[3], @params[4], @params[5])
iterate_actor_var(@params[0], @params[1]) do |actor|
actor.add_param(@params[2], value)
end
end
#--------------------------------------------------------------------------
# ● スキルの増減
#--------------------------------------------------------------------------
def command_318
iterate_actor_var(@params[0], @params[1]) do |actor|
if @params[2] == 0
actor.learn_skill(@params[3])
else
actor.forget_skill(@params[3])
end
end
end
#--------------------------------------------------------------------------
# ● 装備の変更
#--------------------------------------------------------------------------
def command_319
actor = $game_actors[@params[0]]
actor.change_equip_by_id(@params[1], @params[2]) if actor
end
#--------------------------------------------------------------------------
# ● 名前の変更
#--------------------------------------------------------------------------
def command_320
actor = $game_actors[@params[0]]
actor.name = @params[1] if actor
end
#--------------------------------------------------------------------------
# ● 職業の変更
#--------------------------------------------------------------------------
def command_321
actor = $game_actors[@params[0]]
actor.change_class(@params[1]) if actor && $data_classes[@params[1]]
end
#--------------------------------------------------------------------------
# ● アクターのグラフィック変更
#--------------------------------------------------------------------------
def command_322
actor = $game_actors[@params[0]]
if actor
actor.set_graphic(@params[1], @params[2], @params[3], @params[4])
end
$game_player.refresh
end
#--------------------------------------------------------------------------
# ● 乗り物のグラフィック変更
#--------------------------------------------------------------------------
def command_323
vehicle = $game_map.vehicles[@params[0]]
vehicle.set_graphic(@params[1], @params[2]) if vehicle
end
#--------------------------------------------------------------------------
# ● 二つ名の変更
#--------------------------------------------------------------------------
def command_324
actor = $game_actors[@params[0]]
actor.nickname = @params[1] if actor
end
#--------------------------------------------------------------------------
# ● 敵キャラの HP 増減
#--------------------------------------------------------------------------
def command_331
value = operate_value(@params[1], @params[2], @params[3])
iterate_enemy_index(@params[0]) do |enemy|
return if enemy.dead?
enemy.change_hp(value, @params[4])
enemy.perform_collapse_effect if enemy.dead?
end
end
#--------------------------------------------------------------------------
# ● 敵キャラの MP 増減
#--------------------------------------------------------------------------
def command_332
value = operate_value(@params[1], @params[2], @params[3])
iterate_enemy_index(@params[0]) do |enemy|
enemy.mp += value
end
end
#--------------------------------------------------------------------------
# ● 敵キャラのステート変更
#--------------------------------------------------------------------------
def command_333
iterate_enemy_index(@params[0]) do |enemy|
already_dead = enemy.dead?
if @params[1] == 0
enemy.add_state(@params[2])
else
enemy.remove_state(@params[2])
end
enemy.perform_collapse_effect if enemy.dead? && !already_dead
end
end
#--------------------------------------------------------------------------
# ● 敵キャラの全回復
#--------------------------------------------------------------------------
def command_334
iterate_enemy_index(@params[0]) do |enemy|
enemy.recover_all
end
end
#--------------------------------------------------------------------------
# ● 敵キャラの出現
#--------------------------------------------------------------------------
def command_335
iterate_enemy_index(@params[0]) do |enemy|
enemy.appear
$game_troop.make_unique_names
end
end
#--------------------------------------------------------------------------
# ● 敵キャラの変身
#--------------------------------------------------------------------------
def command_336
iterate_enemy_index(@params[0]) do |enemy|
enemy.transform(@params[1])
$game_troop.make_unique_names
end
end
#--------------------------------------------------------------------------
# ● 戦闘アニメーションの表示
#--------------------------------------------------------------------------
def command_337
iterate_enemy_index(@params[0]) do |enemy|
enemy.animation_id = @params[1] if enemy.alive?
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動の強制
#--------------------------------------------------------------------------
def command_339
iterate_battler(@params[0], @params[1]) do |battler|
next if battler.death_state?
battler.force_action(@params[2], @params[3])
BattleManager.force_action(battler)
Fiber.yield while BattleManager.action_forced?
end
end
#--------------------------------------------------------------------------
# ● バトルの中断
#--------------------------------------------------------------------------
def command_340
BattleManager.abort
Fiber.yield
end
#--------------------------------------------------------------------------
# ● メニュー画面を開く
#--------------------------------------------------------------------------
def command_351
return if $game_party.in_battle
SceneManager.call(Scene_Menu)
Window_MenuCommand::init_command_position
Fiber.yield
end
#--------------------------------------------------------------------------
# ● セーブ画面を開く
#--------------------------------------------------------------------------
def command_352
return if $game_party.in_battle
SceneManager.call(Scene_Save)
Fiber.yield
end
#--------------------------------------------------------------------------
# ● ゲームオーバー
#--------------------------------------------------------------------------
def command_353
SceneManager.goto(Scene_Gameover)
Fiber.yield
end
#--------------------------------------------------------------------------
# ● タイトル画面に戻す
#--------------------------------------------------------------------------
def command_354
SceneManager.goto(Scene_Title)
Fiber.yield
end
#--------------------------------------------------------------------------
# ● スクリプト
#--------------------------------------------------------------------------
def command_355
script = @list[@index].parameters[0] + "\n"
while next_event_code == 655
@index += 1
script += @list[@index].parameters[0] + "\n"
end
eval(script)
end
#--------------------------------------------------------------------------
# ● 指定したアクターが出撃中かどうかを返す
#--------------------------------------------------------------------------
def battle?(actor_id)
$game_srpgmap.actor_in_battle?(actor_id)
end
#--------------------------------------------------------------------------
# ● 指定したアクターをイベント対象として選択する
#--------------------------------------------------------------------------
def select_actor(actor_id)
return false unless battle?(actor_id)
$game_temp.srpg_last_user = $game_srpgmap.actor_events.find {|event| event.battler.id == actor_id }
end
#--------------------------------------------------------------------------
# ● 指定したアクターを強制出撃させる
#--------------------------------------------------------------------------
def pop_actor(actor_id, x, y)
actor = $game_actors[actor_id]
return false unless $game_party.members.include?(actor) # パーティにいない
return false unless actor.alive? # アクターが戦闘不能
return false if battle?(actor_id) # すでに出撃中
return false unless $game_srpgmap.can_sally? # 出撃可能人数を超過
$game_srpgmap.add_actor_event(x, y, actor)
end
#--------------------------------------------------------------------------
# ● 指定したイベントのHPを取得する
#--------------------------------------------------------------------------
def hp?(event_id)
event = $game_srpgmap.events[event_id]
event && event.battler? ? event.battler.hp : 0
end
#--------------------------------------------------------------------------
# ● 指定したイベントのMPを取得する
#--------------------------------------------------------------------------
def mp?(event_id)
event = $game_srpgmap.events[event_id]
event && event.battler? ? event.battler.mp : 0
end
#--------------------------------------------------------------------------
# ● 指定したイベントのTPを取得する
#--------------------------------------------------------------------------
def tp?(event_id)
event = $game_srpgmap.events[event_id]
event && event.battler? ? event.battler.tp : 0
end
#--------------------------------------------------------------------------
# ● 指定したイベントに指定したステートが付与されているかを取得する
#--------------------------------------------------------------------------
def state?(event_id, state_id)
event = $game_srpgmap.events[event_id]
(event && event.battler?) ? event.battler.state?(state_id) : (state_id == 1)
end
#--------------------------------------------------------------------------
# ● 指定したイベントに目的地を設定する
#--------------------------------------------------------------------------
def set_goal(event_id, x, y)
event = $game_srpgmap.events[event_id]
event.set_goal([x, y]) if event
end
#--------------------------------------------------------------------------
# ● 指定したイベントの目的地を解除する
#--------------------------------------------------------------------------
def clear_goal(event_id)
event = $game_srpgmap.events[event_id]
event.set_goal(nil) if event
end
#--------------------------------------------------------------------------
# ● 指定した座標へカーソルを移動させる
#--------------------------------------------------------------------------
def focus_xy(x, y)
$game_srpgplayer.setup_auto_move(x, y)
end
#--------------------------------------------------------------------------
# ● 指定したイベントへカーソルを移動させる
#--------------------------------------------------------------------------
def focus_event(event_id)
event = $game_srpgmap.events[event_id]
$game_srpgplayer.setup_auto_move_to_event(event) if event
end
#--------------------------------------------------------------------------
# ● 指定したアクターイベントへカーソルを移動させる
#--------------------------------------------------------------------------
def focus_actor(actor_id)
actor_event = $game_srpgmap.actor_events.find {|event| event.battler.id == actor_id }
$game_srpgplayer.setup_auto_move_to_event(actor_event) if actor_event
end
#--------------------------------------------------------------------------
# ● 味方ターンへの切り替えフラグが立っているかどうかを返す
#--------------------------------------------------------------------------
def a_turn_start?
$game_variables[TMSRPG::VN_TURN_SWITCH] == 1
end
#--------------------------------------------------------------------------
# ● 敵ターンへの切り替えフラグが立っているかどうかを返す
#--------------------------------------------------------------------------
def e_turn_start?
$game_variables[TMSRPG::VN_TURN_SWITCH] == 2
end
#--------------------------------------------------------------------------
# ● 勝利フラグが立っているかどうかを返す
#--------------------------------------------------------------------------
def victory?
$game_variables[TMSRPG::VN_GAMEOVER] == 1
end
#--------------------------------------------------------------------------
# ● 敗北フラグが立っているかどうかを返す
#--------------------------------------------------------------------------
def gameover?
$game_variables[TMSRPG::VN_GAMEOVER] == 2
end
#--------------------------------------------------------------------------
# ● ターン開始処理の終了
#--------------------------------------------------------------------------
def turn_start_end
$game_variables[TMSRPG::VN_TURN_SWITCH] = 0
end
#--------------------------------------------------------------------------
# ● 現在のターン数を返す
#--------------------------------------------------------------------------
def turn_count
$game_srpgmap.turn_count
end
#--------------------------------------------------------------------------
# ● SRPGを終了する
#--------------------------------------------------------------------------
def srpg_end
$game_party.on_battle_end
$game_srpgmap.auto_revive
SceneManager.return
end
end
#==============================================================================
# ■ Sprite_SrpgCharacter
#------------------------------------------------------------------------------
# キャラクター表示用のスプライトです。Game_SrpgCharacter クラスのインスタンスを
# 監視し、スプライトの状態を自動的に変化させます。
#==============================================================================
class Sprite_SrpgCharacter < 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_ex_param
update_other
update_balloon
setup_new_effect
end
#--------------------------------------------------------------------------
# ● 指定されたタイルが含まれるタイルセット画像の取得
#--------------------------------------------------------------------------
def tileset_bitmap(tile_id)
Cache.tileset($game_srpgmap.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_ex_param
self.zoom_x = @character.zoom_x
self.zoom_y = @character.zoom_y
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
#==============================================================================
# ■ Sprite_Popup
#------------------------------------------------------------------------------
# ポップアップ表示用のスプライトです。Game_SrpgPopup クラスのインスタンスを
# 監視し、スプライトの状態を自動的に変化させます。
#==============================================================================
class Sprite_SrpgPopup < Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport, popup = nil)
@popup = popup
super(viewport)
bh = [TMSRPG::POPUP_DAMAGE_FONT_SIZE, TMSRPG::POPUP_STATE_FONT_SIZE].max
self.bitmap = Bitmap.new(200, bh)
self.ox = self.width / 2
self.oy = self.height / 2
self.z = @popup.screen_z
self.visible = false
@text = nil
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if @text != @popup.text
@text = @popup.text
if @text
refresh
else
self.visible = false
end
end
super
if self.visible
self.x = @popup.screen_x
self.y = @popup.screen_y
self.opacity = @popup.opacity
end
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.bitmap.clear
self.bitmap.font.name = @popup.font_name
self.bitmap.font.size = @popup.font_size
self.bitmap.font.bold = @popup.font_bold
self.bitmap.font.color = text_color(@popup.color)
self.bitmap.draw_text(self.bitmap.rect, @text, 1)
self.visible = true
end
#--------------------------------------------------------------------------
# ● 文字色取得
# n : 文字色番号(0..31)
#--------------------------------------------------------------------------
def text_color(n)
bitmap_window = Cache.system("Window")
bitmap_window.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
end
end
#==============================================================================
# ■ Spriteset_SrpgMap
#------------------------------------------------------------------------------
# SRPG用マップ画面のスプライトやタイルマップなどをまとめたクラスです。
# このクラスは Scene_SrpgMap クラスの内部で使用されます。
#==============================================================================
class Spriteset_SrpgMap
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
create_viewports
create_tilemap
create_parallax
create_characters
create_weather
create_pictures
create_timer
create_cursor
create_popups
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_srpgmap.data
@tilemap.flash_data = $game_srpgmap.flash_data
@effect_area_sprite = Sprite.new(@viewport1)
@effect_area_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@effect_area_sprite.ox = Graphics.width / 2
@effect_area_sprite.oy = Graphics.height / 2
load_tileset
end
#--------------------------------------------------------------------------
# ● タイルセットのロード
#--------------------------------------------------------------------------
def load_tileset
@tileset = $game_srpgmap.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 = []
@actor_event_sprites = []
$game_srpgmap.events.values.each do |event|
@character_sprites.push(Sprite_SrpgCharacter.new(@viewport1, event))
end
@character_sprites.push(Sprite_SrpgCharacter.new(@viewport1, $game_srpgplayer))
@map_id = $game_srpgmap.map_id
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 create_cursor
@cursor_sprite = Sprite.new(@viewport1)
@cursor_sprite.bitmap = Cache.system("SrpgCursor")
end
#--------------------------------------------------------------------------
# ● ポップアップスプライトの作成
#--------------------------------------------------------------------------
def create_popups
@popup_sprites = []
$game_srpgmap.popups.each do |popup|
@popup_sprites.push(Sprite_SrpgPopup.new(@viewport2, popup))
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
dispose_tilemap
dispose_parallax
dispose_characters
dispose_weather
dispose_pictures
dispose_timer
dispose_cursor
dispose_popups
dispose_viewports
end
#--------------------------------------------------------------------------
# ● タイルマップの解放
#--------------------------------------------------------------------------
def dispose_tilemap
@tilemap.dispose
@effect_area_sprite.bitmap.dispose
@effect_area_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 遠景の解放
#--------------------------------------------------------------------------
def dispose_parallax
@parallax.bitmap.dispose if @parallax.bitmap
@parallax.dispose
end
#--------------------------------------------------------------------------
# ● キャラクタースプライトの解放
#--------------------------------------------------------------------------
def dispose_characters
@character_sprites.each {|sprite| sprite.dispose }
@actor_event_sprites.compact.each {|sprite| 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_cursor
@cursor_sprite.dispose
end
#--------------------------------------------------------------------------
# ● ポップアップスプライトの解放
#--------------------------------------------------------------------------
def dispose_popups
@popup_sprites.each {|sprite| 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_weather
update_pictures
update_timer
update_cursor
update_popups
update_viewports
end
#--------------------------------------------------------------------------
# ● タイルセットの更新
#--------------------------------------------------------------------------
def update_tileset
if @tileset != $game_srpgmap.tileset
load_tileset
refresh_characters
end
end
#--------------------------------------------------------------------------
# ● タイルマップの更新
#--------------------------------------------------------------------------
def update_tilemap
@tilemap.map_data = $game_srpgmap.data
@tilemap.ox = $game_srpgmap.display_x * 32
@tilemap.oy = $game_srpgmap.display_y * 32
@tilemap.update
if $game_srpgmap.effect_area_table.empty?
if @effect_area_sprite.visible
@effect_area_sprite.visible = false
end
else
unless @effect_area_sprite.visible
refresh_effect_area
@effect_area_sprite.visible = true
end
@effect_area_sprite.x = @cursor_sprite.x
@effect_area_sprite.y = @cursor_sprite.y
@effect_area_sprite.update
end
end
#--------------------------------------------------------------------------
# ● 効果範囲スプライトのリフレッシュ
#--------------------------------------------------------------------------
def refresh_effect_area
@effect_area_sprite.bitmap.clear
color = Color.new(255, 255, 0, 128)
$game_srpgmap.effect_area_table.each do |pos|
@effect_area_sprite.bitmap.fill_rect(@effect_area_sprite.width / 2 + (pos[0] << 5),
@effect_area_sprite.height / 2 + (pos[1] << 5), 32, 32, color)
end
end
#--------------------------------------------------------------------------
# ● 遠景の更新
#--------------------------------------------------------------------------
def update_parallax
if @parallax_name != $game_srpgmap.parallax_name
@parallax_name = $game_srpgmap.parallax_name
@parallax.bitmap.dispose if @parallax.bitmap
@parallax.bitmap = Cache.parallax(@parallax_name)
Graphics.frame_reset
end
@parallax.ox = $game_srpgmap.parallax_ox(@parallax.bitmap)
@parallax.oy = $game_srpgmap.parallax_oy(@parallax.bitmap)
end
#--------------------------------------------------------------------------
# ● キャラクタースプライトの更新
#--------------------------------------------------------------------------
def update_characters
refresh_characters if @map_id != $game_srpgmap.map_id
$game_srpgmap.actor_events.each do |event|
unless @actor_event_sprites[event.battler.id]
@actor_event_sprites[event.battler.id] = Sprite_Character.new(@viewport1, event)
end
end
@character_sprites.each {|sprite| sprite.update }
@actor_event_sprites.compact.each {|sprite| sprite.update }
end
#--------------------------------------------------------------------------
# ● 天候の更新
#--------------------------------------------------------------------------
def update_weather
@weather.type = $game_srpgmap.screen.weather_type
@weather.power = $game_srpgmap.screen.weather_power
@weather.ox = $game_srpgmap.display_x * 32
@weather.oy = $game_srpgmap.display_y * 32
@weather.update
end
#--------------------------------------------------------------------------
# ● ピクチャスプライトの更新
#--------------------------------------------------------------------------
def update_pictures
$game_srpgmap.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_cursor
@cursor_sprite.x = $game_srpgmap.adjust_x($game_srpgplayer.x) * 32
@cursor_sprite.y = $game_srpgmap.adjust_y($game_srpgplayer.y) * 32
@cursor_sprite.update
end
#--------------------------------------------------------------------------
# ● ポップアップスプライトの更新
#--------------------------------------------------------------------------
def update_popups
@popup_sprites.each {|sprite| sprite.update }
end
#--------------------------------------------------------------------------
# ● ビューポートの更新
#--------------------------------------------------------------------------
def update_viewports
@viewport1.tone.set($game_srpgmap.screen.tone)
@viewport1.ox = $game_srpgmap.screen.shake
@viewport2.color.set($game_srpgmap.screen.flash_color)
@viewport3.color.set(0, 0, 0, 255 - $game_srpgmap.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
end
#--------------------------------------------------------------------------
# ● バトラーアニメーションが再生中かどうかを返す
#--------------------------------------------------------------------------
def battler_animation?
(@character_sprites + @actor_event_sprites.compact).any? {|sprite|
sprite.character.battler? && sprite.animation? }
end
#--------------------------------------------------------------------------
# ● フラッシュを一時的に隠す
#--------------------------------------------------------------------------
def hide_flash
@tilemap.flash_data = nil
@effect_area_sprite.bitmap.clear
end
#--------------------------------------------------------------------------
# ● 隠したフラッシュを元に戻す
#--------------------------------------------------------------------------
def show_flash(effect_redraw = false)
@tilemap.flash_data = $game_srpgmap.flash_data
refresh_effect_area if effect_redraw
end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 制御文字の事前変換
# 実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
# 文字「\」はエスケープ文字(\e)に変換。
#--------------------------------------------------------------------------
alias tmsrpg_window_base_convert_escape_characters convert_escape_characters
def convert_escape_characters(text)
result = tmsrpg_window_base_convert_escape_characters(text)
result.gsub!(/\eTURN/i) { $game_srpgmap.turn_count }
result
end
#--------------------------------------------------------------------------
# ● HP の描画
#--------------------------------------------------------------------------
alias tmsrpg_window_base_draw_actor_hp draw_actor_hp
def draw_actor_hp(actor, x, y, width = 124)
if actor.hp_hide? && !(TMSRPG::CRISIS_HP_SHOW && actor.hp < actor.mhp / 4)
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::hp_a)
change_color(hp_color(actor))
draw_text(x, y, width, line_height, "??", 2)
else
tmsrpg_window_base_draw_actor_hp(actor, x, y, width)
end
end
#--------------------------------------------------------------------------
# ● MP の描画
#--------------------------------------------------------------------------
alias tmsrpg_window_base_draw_actor_mp draw_actor_mp
def draw_actor_mp(actor, x, y, width = 124)
if actor.mp_hide?
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a)
change_color(mp_color(actor))
draw_text(x, y, width, line_height, "??", 2)
else
tmsrpg_window_base_draw_actor_mp(actor, x, y, width)
end
end
#--------------------------------------------------------------------------
# ○ SRPGフェイスアイコン の描画
#--------------------------------------------------------------------------
def draw_srpg_face_icon(battler, x, y)
draw_icon(TMSRPG::ICON_BOSS, x, y + 48) if battler.boss?
draw_icon(TMSRPG::ICON_PRINCESS, x, y + 48) if battler.princess?
if battler.float?
draw_icon(TMSRPG::ICON_FLOAT, x, y + 24)
elsif battler.ship?
draw_icon(TMSRPG::ICON_SHIP, x, y + 24)
end
end
end
# ■ Window_Base
#------------------------------------------------------------------------------
# ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 制御文字の事前変換
# 実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
# 文字「\」はエスケープ文字(\e)に変換。
#--------------------------------------------------------------------------
alias tmsrpg_window_base_convert_escape_characters convert_escape_characters
def convert_escape_characters(text)
result = tmsrpg_window_base_convert_escape_characters(text)
result.gsub!(/\eTURN/i) { $game_srpgmap.turn_count }
result
end
#--------------------------------------------------------------------------
# ● HP の描画
#--------------------------------------------------------------------------
alias tmsrpg_window_base_draw_actor_hp draw_actor_hp
def draw_actor_hp(actor, x, y, width = 124)
if actor.hp_hide? && !(TMSRPG::CRISIS_HP_SHOW && actor.hp < actor.mhp / 4)
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::hp_a)
change_color(hp_color(actor))
draw_text(x, y, width, line_height, "??", 2)
else
tmsrpg_window_base_draw_actor_hp(actor, x, y, width)
end
end
#--------------------------------------------------------------------------
# ● MP の描画
#--------------------------------------------------------------------------
alias tmsrpg_window_base_draw_actor_mp draw_actor_mp
def draw_actor_mp(actor, x, y, width = 124)
if actor.mp_hide?
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a)
change_color(mp_color(actor))
draw_text(x, y, width, line_height, "??", 2)
else
tmsrpg_window_base_draw_actor_mp(actor, x, y, width)
end
end
#--------------------------------------------------------------------------
# ○ SRPGフェイスアイコン の描画
#--------------------------------------------------------------------------
def draw_srpg_face_icon(battler, x, y)
draw_icon(TMSRPG::ICON_BOSS, x, y + 48) if battler.boss?
draw_icon(TMSRPG::ICON_PRINCESS, x, y + 48) if battler.princess?
if battler.float?
draw_icon(TMSRPG::ICON_FLOAT, x, y + 24)
elsif battler.ship?
draw_icon(TMSRPG::ICON_SHIP, x, y + 24)
end
end
end
#==============================================================================
# ■ Window_Status
#------------------------------------------------------------------------------
# ステータス画面で表示する、フル仕様のステータスウィンドウです。
#==============================================================================
class Window_Status < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tmsrpg_window_status_initialize initialize
def initialize(actor)
@mode = 0
tmsrpg_window_status_initialize(actor)
end
#--------------------------------------------------------------------------
# ● ウィンドウ内容の作成【再定義】
#--------------------------------------------------------------------------
def create_contents
contents.dispose
if contents_width > 0 && contents_height > 0
self.contents = Bitmap.new(contents_width + 2, contents_height)
self.ox = 1
else
self.contents = Bitmap.new(1, 1)
end
end
#--------------------------------------------------------------------------
# ○ モード切り替え
#--------------------------------------------------------------------------
def set_mode(new_mode)
@mode = (new_mode + 2) % 2
Sound.play_cursor
refresh
end
#--------------------------------------------------------------------------
# ● ブロック 3 の描画【再定義】
#--------------------------------------------------------------------------
def draw_block3(y)
if @mode == 0
draw_parameters(8, y)
draw_equipments(288, y)
else
draw_parameters_ex(8, y)
draw_element_rate(152, y)
draw_state_rate(344, y)
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(:RIGHT)
set_mode(@mode + 1)
elsif Input.trigger?(:LEFT)
set_mode(@mode - 1)
end
end
#--------------------------------------------------------------------------
# ● 能力値の描画【再定義】
#--------------------------------------------------------------------------
def draw_parameters(x, y)
6.times do |i|
change_color(system_color)
draw_text(x, y + line_height * i, 80, line_height, Vocab::param(i + 2))
change_color(normal_color)
draw_text(x + 80, y + line_height * i, 36, line_height, @actor.param(i + 2), 2)
end
change_color(system_color)
draw_text(x + 144, y + line_height * 0, 80, line_height, TMSRPG::VC_PARAM_MOV)
draw_text(x + 144, y + line_height * 1, 80, line_height, TMSRPG::VC_PARAM_HIT)
draw_text(x + 144, y + line_height * 2, 80, line_height, TMSRPG::VC_PARAM_EVA)
draw_text(x + 144, y + line_height * 3, 80, line_height, TMSRPG::VC_PARAM_CRI)
draw_text(x + 144, y + line_height * 4, 80, line_height, TMSRPG::VC_PARAM_CNT)
draw_text(x + 144, y + line_height * 5, 80, line_height, TMSRPG::VC_PARAM_CHN)
change_color(normal_color)
draw_text(x + 224, y + line_height * 0, 36, line_height, @actor.mov, 2)
draw_text(x + 224, y + line_height * 1, 36, line_height, (@actor.hit * 100).to_i, 2)
draw_text(x + 224, y + line_height * 2, 36, line_height, (@actor.eva * 100).to_i, 2)
draw_text(x + 224, y + line_height * 3, 36, line_height, (@actor.cri * 100).to_i, 2)
draw_text(x + 224, y + line_height * 4, 36, line_height, (@actor.cnt * 100).to_i, 2)
draw_text(x + 224, y + line_height * 5, 36, line_height, @actor.chain, 2)
end
#--------------------------------------------------------------------------
# ○ 能力値の描画(2ページ目)
#--------------------------------------------------------------------------
def draw_parameters_ex(x, y)
change_color(system_color)
draw_text(x, y + line_height * 0, 80, line_height, TMSRPG::VC_PARAM_CEV)
draw_text(x, y + line_height * 1, 80, line_height, TMSRPG::VC_PARAM_MEV)
draw_text(x, y + line_height * 2, 80, line_height, TMSRPG::VC_PARAM_MRF)
draw_text(x, y + line_height * 3, 80, line_height, TMSRPG::VC_PARAM_HRG)
draw_text(x, y + line_height * 4, 80, line_height, TMSRPG::VC_PARAM_MRG)
draw_text(x, y + line_height * 5, 80, line_height, TMSRPG::VC_PARAM_TRG)
change_color(normal_color)
draw_text(x + 80, y + line_height * 0, 36, line_height, (@actor.cev * 100).to_i, 2)
draw_text(x + 80, y + line_height * 1, 36, line_height, (@actor.mev * 100).to_i, 2)
draw_text(x + 80, y + line_height * 2, 36, line_height, (@actor.mrf * 100).to_i, 2)
draw_text(x + 80, y + line_height * 3, 36, line_height, (@actor.hrg * 100).to_i, 2)
draw_text(x + 80, y + line_height * 4, 36, line_height, (@actor.mrg * 100).to_i, 2)
draw_text(x + 80, y + line_height * 5, 36, line_height, (@actor.trg * 100).to_i, 2)
end
#--------------------------------------------------------------------------
# ○ 属性有効度の描画
#--------------------------------------------------------------------------
def draw_element_rate(x, y)
change_color(system_color)
draw_text(x, y, 128, line_height, "Elemental Weakness")
change_color(normal_color)
TMSRPG::SHOW_ELEMENTS.each_with_index do |element_id, i|
x2 = x + i / 5 * 96
y2 = y + (i % 5 + 1) * line_height
draw_icon(TMSRPG::ICON_ELEMENTS[element_id], x2, y2)
draw_text(x2 + 24, y2, 48, line_height, (@actor.element_rate(element_id) * 100).to_i, 2)
end
end
#--------------------------------------------------------------------------
# ○ ステート有効度の描画
#--------------------------------------------------------------------------
def draw_state_rate(x, y)
change_color(system_color)
draw_text(x, y, 128, line_height, "State Weakness")
change_color(normal_color)
TMSRPG::SHOW_STATES.each_with_index do |state_id, i|
x2 = x + i / 5 * 96
y2 = y + (i % 5 + 1) * line_height
state = $data_states[state_id]
draw_icon(state.icon_index, x2, y2)
draw_text(x2 + 24, y2, 48, line_height, (@actor.state_rate(state_id) * 100).to_i, 2)
end
end
end
# ■ Window_Status
#------------------------------------------------------------------------------
# ステータス画面で表示する、フル仕様のステータスウィンドウです。
#==============================================================================
class Window_Status < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias tmsrpg_window_status_initialize initialize
def initialize(actor)
@mode = 0
tmsrpg_window_status_initialize(actor)
end
#--------------------------------------------------------------------------
# ● ウィンドウ内容の作成【再定義】
#--------------------------------------------------------------------------
def create_contents
contents.dispose
if contents_width > 0 && contents_height > 0
self.contents = Bitmap.new(contents_width + 2, contents_height)
self.ox = 1
else
self.contents = Bitmap.new(1, 1)
end
end
#--------------------------------------------------------------------------
# ○ モード切り替え
#--------------------------------------------------------------------------
def set_mode(new_mode)
@mode = (new_mode + 2) % 2
Sound.play_cursor
refresh
end
#--------------------------------------------------------------------------
# ● ブロック 3 の描画【再定義】
#--------------------------------------------------------------------------
def draw_block3(y)
if @mode == 0
draw_parameters(8, y)
draw_equipments(288, y)
else
draw_parameters_ex(8, y)
draw_element_rate(152, y)
draw_state_rate(344, y)
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(:RIGHT)
set_mode(@mode + 1)
elsif Input.trigger?(:LEFT)
set_mode(@mode - 1)
end
end
#--------------------------------------------------------------------------
# ● 能力値の描画【再定義】
#--------------------------------------------------------------------------
def draw_parameters(x, y)
6.times do |i|
change_color(system_color)
draw_text(x, y + line_height * i, 80, line_height, Vocab::param(i + 2))
change_color(normal_color)
draw_text(x + 80, y + line_height * i, 36, line_height, @actor.param(i + 2), 2)
end
change_color(system_color)
draw_text(x + 144, y + line_height * 0, 80, line_height, TMSRPG::VC_PARAM_MOV)
draw_text(x + 144, y + line_height * 1, 80, line_height, TMSRPG::VC_PARAM_HIT)
draw_text(x + 144, y + line_height * 2, 80, line_height, TMSRPG::VC_PARAM_EVA)
draw_text(x + 144, y + line_height * 3, 80, line_height, TMSRPG::VC_PARAM_CRI)
draw_text(x + 144, y + line_height * 4, 80, line_height, TMSRPG::VC_PARAM_CNT)
draw_text(x + 144, y + line_height * 5, 80, line_height, TMSRPG::VC_PARAM_CHN)
change_color(normal_color)
draw_text(x + 224, y + line_height * 0, 36, line_height, @actor.mov, 2)
draw_text(x + 224, y + line_height * 1, 36, line_height, (@actor.hit * 100).to_i, 2)
draw_text(x + 224, y + line_height * 2, 36, line_height, (@actor.eva * 100).to_i, 2)
draw_text(x + 224, y + line_height * 3, 36, line_height, (@actor.cri * 100).to_i, 2)
draw_text(x + 224, y + line_height * 4, 36, line_height, (@actor.cnt * 100).to_i, 2)
draw_text(x + 224, y + line_height * 5, 36, line_height, @actor.chain, 2)
end
#--------------------------------------------------------------------------
# ○ 能力値の描画(2ページ目)
#--------------------------------------------------------------------------
def draw_parameters_ex(x, y)
change_color(system_color)
draw_text(x, y + line_height * 0, 80, line_height, TMSRPG::VC_PARAM_CEV)
draw_text(x, y + line_height * 1, 80, line_height, TMSRPG::VC_PARAM_MEV)
draw_text(x, y + line_height * 2, 80, line_height, TMSRPG::VC_PARAM_MRF)
draw_text(x, y + line_height * 3, 80, line_height, TMSRPG::VC_PARAM_HRG)
draw_text(x, y + line_height * 4, 80, line_height, TMSRPG::VC_PARAM_MRG)
draw_text(x, y + line_height * 5, 80, line_height, TMSRPG::VC_PARAM_TRG)
change_color(normal_color)
draw_text(x + 80, y + line_height * 0, 36, line_height, (@actor.cev * 100).to_i, 2)
draw_text(x + 80, y + line_height * 1, 36, line_height, (@actor.mev * 100).to_i, 2)
draw_text(x + 80, y + line_height * 2, 36, line_height, (@actor.mrf * 100).to_i, 2)
draw_text(x + 80, y + line_height * 3, 36, line_height, (@actor.hrg * 100).to_i, 2)
draw_text(x + 80, y + line_height * 4, 36, line_height, (@actor.mrg * 100).to_i, 2)
draw_text(x + 80, y + line_height * 5, 36, line_height, (@actor.trg * 100).to_i, 2)
end
#--------------------------------------------------------------------------
# ○ 属性有効度の描画
#--------------------------------------------------------------------------
def draw_element_rate(x, y)
change_color(system_color)
draw_text(x, y, 128, line_height, "Elemental Weakness")
change_color(normal_color)
TMSRPG::SHOW_ELEMENTS.each_with_index do |element_id, i|
x2 = x + i / 5 * 96
y2 = y + (i % 5 + 1) * line_height
draw_icon(TMSRPG::ICON_ELEMENTS[element_id], x2, y2)
draw_text(x2 + 24, y2, 48, line_height, (@actor.element_rate(element_id) * 100).to_i, 2)
end
end
#--------------------------------------------------------------------------
# ○ ステート有効度の描画
#--------------------------------------------------------------------------
def draw_state_rate(x, y)
change_color(system_color)
draw_text(x, y, 128, line_height, "State Weakness")
change_color(normal_color)
TMSRPG::SHOW_STATES.each_with_index do |state_id, i|
x2 = x + i / 5 * 96
y2 = y + (i % 5 + 1) * line_height
state = $data_states[state_id]
draw_icon(state.icon_index, x2, y2)
draw_text(x2 + 24, y2, 48, line_height, (@actor.state_rate(state_id) * 100).to_i, 2)
end
end
end
#==============================================================================
# ■ Window_SrpgHelp
#------------------------------------------------------------------------------
# スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
#==============================================================================
class Window_SrpgHelp < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(line_number = 2)
super(0, 0, Graphics.width, fitting_height(line_number))
end
#--------------------------------------------------------------------------
# ● テキスト設定
#--------------------------------------------------------------------------
def set_text(text, align = 0)
@align = align
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
if @align == 0
draw_text_ex(4, 0, @text)
else
draw_text(4, 0, contents.width - 8, line_height, @text, @align)
end
end
end
#==============================================================================
# ■ Window_SrpgMenuCommand
#------------------------------------------------------------------------------
# SRPGマップのメインメニューを表示するウィンドウです。
#==============================================================================
class Window_SrpgMenuCommand < Window_Command
#--------------------------------------------------------------------------
# ● コマンド選択位置の初期化(クラスメソッド)
#--------------------------------------------------------------------------
def self.init_command_position
@@last_command_symbol = nil
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
select_last
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 表示行数の取得
#--------------------------------------------------------------------------
def visible_line_number
item_max
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command(TMSRPG::VC_MENU_TURN_END, :turn_end, turn_end_enabled)
add_command(TMSRPG::VC_MENU_LIST, :list, list_enabled)
add_command(TMSRPG::VC_MENU_MAP, :map, map_enabled)
add_command(TMSRPG::VC_MENU_OPTION, :option, option_enabled)
end
#--------------------------------------------------------------------------
# ● ターン終了コマンドの有効状態を取得
#--------------------------------------------------------------------------
def turn_end_enabled
!$game_srpgmap.actor_events.empty?
end
#--------------------------------------------------------------------------
# ● キャラ一覧コマンドの有効状態を取得
#--------------------------------------------------------------------------
def list_enabled
!$game_srpgmap.all_battler_events.empty?
end
#--------------------------------------------------------------------------
# ● マップ情報コマンドの有効状態を取得
#--------------------------------------------------------------------------
def map_enabled
true
end
#--------------------------------------------------------------------------
# ● オプションコマンドの有効状態を取得
#--------------------------------------------------------------------------
def option_enabled
true
end
#--------------------------------------------------------------------------
# ● 決定ボタンが押されたときの処理
#--------------------------------------------------------------------------
def process_ok
@@last_command_symbol = current_symbol
super
end
#--------------------------------------------------------------------------
# ● 前回の選択位置を復帰
#--------------------------------------------------------------------------
def select_last
select_symbol(@@last_command_symbol)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
case current_symbol
when :turn_end
if turn_end_enabled
@help_window.set_text("End the turn.")
else
@help_window.set_text("No characters summoned.")
end
when :list
@help_window.set_text("A list of all characters.")
when :map
@help_window.set_text("Display the map's information.")
when :option
@help_window.set_text("Change game settings.")
end
end
end
#==============================================================================
# ■ Window_SrpgGateCommand
#------------------------------------------------------------------------------
# SRPGマップのゲートメニューを表示するウィンドウです。
#==============================================================================
class Window_SrpgGateCommand < Window_Command
#--------------------------------------------------------------------------
# ● コマンド選択位置の初期化(クラスメソッド)
#--------------------------------------------------------------------------
def self.init_command_position
@@last_command_symbol = nil
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
select_last
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 表示行数の取得
#--------------------------------------------------------------------------
def visible_line_number
item_max
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command(TMSRPG::VC_GATE_SALLY, :sally, sally_enabled)
end
#--------------------------------------------------------------------------
# ● 出撃コマンドの有効状態を取得
#--------------------------------------------------------------------------
def sally_enabled
$game_srpgmap.can_sally?
end
#--------------------------------------------------------------------------
# ● 決定ボタンが押されたときの処理
#--------------------------------------------------------------------------
def process_ok
@@last_command_symbol = current_symbol
super
end
#--------------------------------------------------------------------------
# ● 前回の選択位置を復帰
#--------------------------------------------------------------------------
def select_last
select_symbol(@@last_command_symbol)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
case current_symbol
when :sally
text = sprintf("Select a character to summon. (%d remaining)",
$game_srpgmap.sally_rest)
@help_window.set_text(text)
end
end
end
Turns out that I hit the character limit for this post. I will post the rest in another post.