rebf-gaiden/Scripts/_B.rb
2025-04-30 08:39:04 -05:00

491 lines
No EOL
20 KiB
Ruby
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

=begin
トリス スキルツリー仮 ver5
・ver5変更点スクリプトは変更なし
 ・スキル習得の条件スイッチ
  メモに <スイッチ=1> などと書くと、そのスイッチがオフの時は習得できない
=end
#==============================================================================
# ■ Scene_SkillPoint
#==============================================================================
class Scene_SkillPoint < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
@used_reset_flag = Array.new
@used_reset_flag.push(@actor.id)
create_help_window
create_pop_window
create_small_status_window
create_info_window
create_skill_point_window
@info_window.skill_point_window = @skill_point_window
@pop_up_window.skill_point_window = @skill_point_window
@skill_point_window.status_window = @small_status_window
@skill_point_window.help_window = @help_window
@skill_point_window.pop_up_window = @pop_up_window
@skill_point_window.decide_window = @decide_window
@skill_point_window.info_window = @info_window
@skill_point_window.x = Graphics.width - 200
@skill_point_window.y = 0
@help_window.y = Graphics.height - @help_window.height
@info_window.y = @help_window.y - @info_window.height
@small_status_window.y = @info_window.y - @small_status_window.height
@skill_info_window = Window_k_SkillInfomation_Window.new
@skill_info_window.y = @small_status_window.y
@skill_info_window.actor = @actor
@skill_info_window.skill_point_window = @skill_point_window
@info_window.skill_info_window = @skill_info_window
@small_status_window.skill_info_window = @skill_info_window
@skill_point_window.stype_id = 1
@last_skill_type_index = 0
@skill_point_window.select(0)
@skill_point_window.activate
@skill_point_window.refresh
end
#--------------------------------------------------------------------------
# ● スキルポイントウィンドウ[キャンセル]
#--------------------------------------------------------------------------
def skill_point_cancel
$game_temp.reserve_common_event(43) #紅茶走
reset_all_flag
return_scene
end
end
#==============================================================================
# ■ Window_k_SkillPoint_Small_Status
#==============================================================================
class Window_k_SkillPoint_Small_Status < Window_Selectable
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :skill_info_window
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
jobwidth = SkillTree::JOBEXP_WIDTH
super(Graphics.width - jobwidth, 0, jobwidth, fitting_height(1))
refresh
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_status
@skill_info_window.refresh(@skill_info_window.skill) if @skill_info_window
return unless @actor
draw_actor_skill_point(@actor, 0, 0)
end
end
#==============================================================================
# ■ Window_k_SkillInfomation_Window
#==============================================================================
class Window_k_SkillInfomation_Window < Window_k_Infomation_Window
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :actor
attr_accessor :skill_point_window
attr_reader :skill
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width - SkillTree::JOBEXP_WIDTH, fitting_height(1))
@skill = nil
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh(skill = nil)
contents.clear
return unless skill
@skill = skill
learned = @actor.skills.include?(skill)
flag = @skill_point_window.command_enabled_by_skill?(skill)
change_color(normal_color, flag)
draw_text(0, 0, contents_width, line_height, skill.name)
text = learned ? "MASTER" : "Not Learned"
draw_text(0, 0, contents_width, line_height, text, 2)
end
end
#==============================================================================
# ■ Window_k_SkillPoint_SkillList
#==============================================================================
class Window_k_SkillPoint_SkillList < Window_Command
#--------------------------------------------------------------------------
# ● スキルの有効状態を取得
#--------------------------------------------------------------------------
def command_enabled_by_skill?(item)
for skill in @data
return skill_enabled?(skill) if skill[1] == item
end
return false
end
end
#==============================================================================
# ■ Window_k_Infomation_Window
#==============================================================================
class Window_k_Infomation_Window < Window_Base
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :skill_info_window
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
alias :ex_info_refresh :refresh
def refresh
ex_info_refresh
skill = @skill_point_window.item if @skill_point_window
draw_text_exskill(250, 0, contents_width, line_height, skill.ex_help) if skill
@skill_info_window.refresh(skill) if @skill_info_window
end
end
class RPG::Skill
def ex_help
return @note =~ /<習得ヘルプ=\s*(\S.*)>/ ? $1 : ""
end
end
#
#==============================================================================
# ■ Window_k_SkillPoint_SkillList
#==============================================================================
class Window_k_SkillPoint_SkillList < Window_Command
include SkillTree
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
width = 200
height = Graphics.height - fitting_height(2) - fitting_height(1) * 2
@select_skill = 0
@width = width
@height = height
@draw_class = 0
super(x, y)
hide
@tree_changed = true
@tree_index = 1
tree_reset
create_sprites
update_sprites
end
#--------------------------------------------------------------------------
# ● リセット
#--------------------------------------------------------------------------
def tree_reset
@scroll_y = 0
@last_scroll_sprite_scroll_y = nil
node_select(1, true)
@test_cursor_x = 0
@test_cursor_y = 0
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_sprites
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
super
dispose_sprites
end
#--------------------------------------------------------------------------
# ● スプライト作成
#--------------------------------------------------------------------------
def create_sprites
@tree_sprite = Sprite_Base.new(self.viewport)
@cursor_sprite = Sprite_Base.new(self.viewport)
@cursor_sprite.bitmap = load_bitmap(CURSOR_FILENAME)
@scroll_sprite = Sprite_Base.new(self.viewport)
@scroll_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
end
#--------------------------------------------------------------------------
# ● スプライト更新
#--------------------------------------------------------------------------
def update_sprites
if @tree_changed
@tree_changed = false
@tree_sprite.bitmap = load_bitmap(tree_setting[0])
end
@tree_sprite.oy = @scroll_y
pos_data = node_data[I_POS]
@cursor_sprite.x = X[pos_data[0] - 1] + @test_cursor_x
@cursor_sprite.y = Y[pos_data[1] - 1] + @test_cursor_y - @scroll_y
if @last_scroll_sprite_scroll_y != @scroll_y
@last_scroll_sprite_scroll_y = @scroll_y
@scroll_sprite.bitmap.clear
s = SCROLL_BAR
r1 = Rect.new(s[0], s[1], s[2], s[3])
@scroll_sprite.bitmap.fill_rect(r1, s[4])
th = @tree_sprite.bitmap.height
sch = s[3] - s[6] * 2
rx = s[0] + s[5]
rw = s[2] - s[5] * 2
ry = s[1] + s[6] + sch * @scroll_y / th
rh = sch * height / th
ry = s[1] + s[3] - (rh + s[6]) if 100 * (@scroll_y + height) / th >= 99
r2 = Rect.new(rx, ry, rw, rh)
@scroll_sprite.bitmap.fill_rect(r2, s[7])
end
end
#--------------------------------------------------------------------------
# ● スプライト解放
#--------------------------------------------------------------------------
def dispose_sprites
@tree_sprite.dispose
@cursor_sprite.dispose
@scroll_sprite.dispose
end
#--------------------------------------------------------------------------
# ● スクロール更新
#--------------------------------------------------------------------------
def update_scroll_y(move = nil)
height
pos_data = node_data[I_POS]
cursor_y = Y[pos_data[1] - 1]
@scroll_y = cursor_y - height / 2
@scroll_y = [@scroll_y, @tree_sprite.bitmap.height - height].min
@scroll_y = [@scroll_y, 0].max
end
#--------------------------------------------------------------------------
# ● 補助 画像読み込み
#--------------------------------------------------------------------------
def load_bitmap(name)
Cache.load_bitmap("", name, 0)
end
#--------------------------------------------------------------------------
# ● 補助 ツリー取得
#--------------------------------------------------------------------------
def tree_data
TR[@tree_index]
end
#--------------------------------------------------------------------------
# ● 補助 ツリー設定取得
#--------------------------------------------------------------------------
def tree_setting
tree_data[0]
end
#--------------------------------------------------------------------------
# ● 補助 ノード取得
#--------------------------------------------------------------------------
def node_data
tree_data[@node_index]
end
#--------------------------------------------------------------------------
# ● カーソルの移動処理
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_node_index = @node_index
for symbol in [:DOWN, :UP, :RIGHT, :LEFT]
node_move(symbol, Input.trigger?(symbol)) if Input.repeat?(symbol)
end
Sound.play_cursor if @node_index != last_node_index
last_tree_index = @tree_index
tree_move(1) if Input.trigger?(:R)
tree_move(-1) if Input.trigger?(:L)
if @tree_index != last_tree_index
tree_reset
p sprintf("ツリー移動 %d→%d", last_tree_index, @tree_index)
Sound.play_cursor
@tree_changed = true
end
end
#--------------------------------------------------------------------------
# ● カーソルを移動
#--------------------------------------------------------------------------
def node_move(symbol, wrap)
return test_cursor_move(symbol) if ($TEST and Input.press?(:CTRL))
hash = {:UP => 0, :DOWN => 1, :LEFT => 2, :RIGHT => 3}
point = node_move_point(hash[symbol])
return if !wrap and point >= 900
point -= 900 if point >= 900
node_select(point)
end
#--------------------------------------------------------------------------
# ● テストカーソルを移動
#--------------------------------------------------------------------------
def test_cursor_move(symbol)
hash = {:UP => [0, -1], :DOWN => [0, 1], :LEFT => [-1, 0], :RIGHT => [1, 0]}
@test_cursor_x += hash[symbol][0]
@test_cursor_y += hash[symbol][1]
pos_data = node_data[I_POS]
p ["座標調整値", [@test_cursor_x, @test_cursor_y], "実際のカーソル座標",
[X[pos_data[0] - 1] + @test_cursor_x,
Y[pos_data[1] - 1] + @test_cursor_y]]
end
#--------------------------------------------------------------------------
# ● カーソルの移動先を取得
#--------------------------------------------------------------------------
def node_move_point(dir)
return node_data[I_MOVE][dir]
end
#--------------------------------------------------------------------------
# ● 項目の選択
#--------------------------------------------------------------------------
def node_select(index, flag = false)
last_y = Y[node_data[I_POS][1] - 1] if node_valid?(@node_index)
@node_index = index if flag or node_valid?(index)
now_y = Y[node_data[I_POS][1] - 1] if node_valid?(@node_index)
update_scroll_y(now_y - last_y) if last_y and now_y
node_command_select
end
#--------------------------------------------------------------------------
# ● 有効なノードか
#--------------------------------------------------------------------------
def node_valid?(index)
return false if index == nil
return false if index == 0
return false if tree_data == nil
return false if tree_data[index] == nil
return true
end
#--------------------------------------------------------------------------
# ● スキルの取得
#--------------------------------------------------------------------------
def item
return nil unless node_valid?(@node_index)
return $data_skills[node_skill_index(@node_index)]
end
#--------------------------------------------------------------------------
# ● ードのスキルID内から有効なスキルIDを取得
#--------------------------------------------------------------------------
def node_skill_index(node_index)
learned = -1
end_index = 0
skill_data = node_data[I_SKILL]
skill_data.each_with_index do |skill_index, i|
skill = $data_skills[skill_index]
learned = i if (@actor && @actor.skills.include?(skill))
end_index = i
end
result = learned + 1
result = end_index if learned == end_index
return skill_data[result]
end
#--------------------------------------------------------------------------
# ● スキルIDに対応したコマンドインデックスを取得
#--------------------------------------------------------------------------
def skill_command_index(skill_id)
@data.each_with_index do |skill, i|
return i if skill[1].id == skill_id
end
return 0
end
#--------------------------------------------------------------------------
# ● ノードインデックスに対応したコマンドインデックスを選択
#--------------------------------------------------------------------------
def node_command_select
self.index = skill_command_index(node_skill_index(@node_index))
return unless Input.press?(:Y)
p [@data[index][1].name, is_maxlv(@data[index]), @data[index][0],
have_need_point(@data[index]), cheack_base_skill(@data[index])]
return
#ツリーが存在しない時、マスター(習得)していれば許可
if @data[index][2] == 0
if is_maxlv(@data[index]) == 0
skill_point_back(@data[index]) if $game_switches[14] == true
end
#ツリーが存在する場合
else
#Lv1はマスターしていない場合以外処理しない
return if @data[index][0] == 1 && is_maxlv(@data[index]) == 1
#コマンドの有効をチェック
if command_enabled?(index)
skill_point_back(@data[index]) if $game_switches[14] == true
#コマンドが有効ではない場合
else
if is_maxlv(@data[index]) == 0
skill_point_back(@data[index]) if $game_switches[14] == true
end
if have_need_point(@data[index]) == 0
skill_point_back(@data[index]) if $game_switches[14] == true
end
if cheack_base_skill(@data[index]) == 0
skill_point_back(@data[index]) if $game_switches[14] == true
end
end
end
end
#--------------------------------------------------------------------------
# ● 項目の選択
#--------------------------------------------------------------------------
def select(index)
return
end
#--------------------------------------------------------------------------
# ● 項目の選択解除
#--------------------------------------------------------------------------
def unselect
return
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
super
if $game_switches[RESET_SWITCH] and @data[skill_command_index(RESET_SKILL)]
$game_switches[RESET_SWITCH] = false
skill_point_back(@data[skill_command_index(RESET_SKILL)])
end
node_command_select if @node_index
end
#--------------------------------------------------------------------------
# ● ツリー切り替え
#--------------------------------------------------------------------------
def tree_move(plus)
@tree_index += plus
@tree_index = 1 if @tree_index == TR.size
@tree_index = TR.size - 1 if @tree_index == 0
tree_move(plus) if tree_setting[1] and !$game_switches[tree_setting[1]]
end
#--------------------------------------------------------------------------
# ● スキルの有効状態を取得
#--------------------------------------------------------------------------
alias :switch_skill_enabled? :skill_enabled?
def skill_enabled?(skill)
return false unless skill[1].learn_switch_on?
return switch_skill_enabled?(skill)
end
end
#==============================================================================
# ■ RPG::Skill
#==============================================================================
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# ● 条件スイッチ
#--------------------------------------------------------------------------
def learn_switch_on?
return true unless @note =~ /<スイッチ=(\d+)>/
return $game_switches[$1.to_i]
end
end