module Sword
#=======================================
#★ 魔劍工舖 - 人物倉庫 1.04
# [url]http://blog.yam.com/a870053jjkj/[/url]
#=======================================
=begin
● 函數
呼叫方法:$scene = Sword_FigureDepot.new
移動同伴:$game_party.move_figure_depot(角色編號)
交換同伴:$game_party.move_figure_depot(角色編號一, 角色編號二)
倉庫變量:$game_party.figepot
禁止變量:$game_party.figepotX
----------------------------------------------------------------
○ 只在戰鬥畫面中有效的設置
戰鬥呼叫:$scene.figure_depot7
========================================
● 所需腳本
XP與VX資料轉換(1.01):[url]http://blog.yam.com/a870053jjkj/article/33973184[/url]
=end
#=======================================
#● 功能設定
Sword7_HELP = ['夥伴倉庫:至少要有一人出战', 1] # [幫助窗口文字, 靠邊],靠邊:0左;1中;2右
Sword7_FISI = 5 # 設定持有隊員的上限數量,有減少或增多上限才要修改
Sword7_DESI = 99 # 設定倉庫中最多能存放的人物數量
Sword7_Add = 2 # 設定上限時增加隊員的情況,0為照加;1為不加;2為移到倉庫
#=======================================
$Sword ? $Sword[7] = true : $Sword = {7=>true} # 腳本使用標誌
($Sword_VX = false ; RPG::Weather rescue $Sword_VX = true) if $Sword_VX == nil
end
#=======================================
#■ 同伴的類
class Game_Party
include Sword # 連接自定設置
attr_accessor :figepot # 倉庫空間
attr_accessor :figepotX # 禁止存放列表
#-------------------------------------------------------------
#● 初始化物件
alias sword7_initialize initialize
def initialize ; sword7_initialize ; @figepot, @figepotX = [], [] ;
end
#-------------------------------------------------------------
#● 加入同伴
alias sword7_add_actor add_actor
def add_actor(actor_id)
if @figepot.include?(actor_id) ; return # 防止出現分身
elsif XPVX.members.size + 1 > Sword7_FISI and Sword7_Add == 1 ; return
elsif XPVX.members.size + 1 > Sword7_FISI and Sword7_Add == 2 and
@figepot.size + 1 <= Sword7_DESI
@figepot += [actor_id] ; return
end
sword7_add_actor(actor_id)
end
#-------------------------------------------------------------
#● 角色離開
alias sword7_remove_actor remove_actor
def remove_actor(actor_id)
if @figepot.include?(actor_id) ; @figepot.delete(actor_id) # 倉庫的同伴離開
else ; sword7_remove_actor(actor_id) # 目前指定同伴離開
end
end
#-------------------------------------------------------------
#● 同伴與倉庫的移動處理(角色編號一, 角色編號二)
def move_figure_depot(actor_id, depot_id = nil)
ending = false # 結果
if depot_id # 交換的場合
if i1 = XPVX.members.index(
$game_actors[actor_id]) and i2 = @figepot.index(depot_id) #and not actor_id == 1
XPVX.members(i1, depot_id) ; @figepot[i2], ending = actor_id, true
elsif i1 = XPVX.members.index(
$game_actors[depot_id]) and i2 = @figepot.index(actor_id)
XPVX.members(i1, actor_id) ; @figepot[i2], ending = depot_id, true
end
else # 移動的場合
if XPVX.members.include?($game_actors[actor_id]) #and not actor_id == 1# 在隊伍中的話
remove_actor(actor_id) ; @figepot += [actor_id] ; ending = true
elsif @figepot.include?(actor_id) # 在倉庫中的話
@figepot -= [actor_id] ; add_actor(actor_id) ; ending = true
end
end
$game_player.refresh # 更新領隊
ending # 返回結果
end
end
#=======================================
#■ 人物倉庫窗口
class WSword_FigureDepot < Window_Base
include Sword # 連接自定設置
attr_accessor :figmax # 總人數
attr_accessor :line # 滾動行數
attr_accessor :index # 游標位置
#-------------------------------------------------------------
#● 初始化物件(倉庫標誌)
def initialize(mode) # mode:0為目前隊員(偽)、1為倉庫隊員(真)
@mode = mode == 0 ? false : true
# [窗口寬度/2, 說明窗口高度, HP與SP修正, 游標寬度, 名稱Y座標修正, 窗口高度]
[url=home.php?mod=space&uid=280620]@xpvx[/url] = [XPVX.width / 2, XPVX.wlh] + ($Sword_VX ? [36, Graphics.width / 1.7 - 32, 4] :
[0, 386, 0]) + [XPVX.height - XPVX.wlh]
super(mode * @xpvx[0], @xpvx[1], @xpvx[0], @xpvx[5])
@index = @mode ? -2 : 0 # 設定選項起始位置
[url=home.php?mod=space&uid=401263]@line[/url] = 0 # 記錄往下滾動了多少行
refresh
end
#-------------------------------------------------------------
#● 更新內容
def refresh
#○ 重新產生顯示用的位圖
if @mode # 倉庫顯示用位圖高度,除此以外則是目前隊伍窗口
a, b = $game_party.figepot.size, $game_party.figepot.size == Sword7_DESI ? 0 : 64
else ; a, b = XPVX.members.size, XPVX.members.size == Sword7_FISI ? 0 : 64
end
self.contents = Bitmap.new(width - 32, a * 64 + b)
self.windowskin = RPG::Cache.windowskin("palskin1")
self.opacity = 150
self.contents.font.color = normal_color
ii = 0 # 隊員存在數
a = @mode ? $game_party.figepot : XPVX.members
#○ 產生隊員清單
for i in a
next if i == nil
i = i.id unless @mode
if $Sword_VX
#draw_actor_face(actor, 18, 64 * ii + 48)
#draw_character($game_actors[i].character_name, $game_actors[i].character_index, 18, 64 * ii + 48)
else
# cache = $Sword_VX ? Cache.character($game_actors[i].character_name) :
# RPG::Cache.character($game_actors[i].character_name, $game_actors[i].character_hue)
# self.contents.blt(4, 64 * ii + (64 - cache.height / 4) / 2, cache,
# Rect.new(0, 0, cache.width / 4, cache.height / 4))
end
self.contents.font.size = 18 if $Sword_VX
draw_actor_name($game_actors[i], 36, 64 * ii + @xpvx[4]) # 名稱
#draw_actor_partyface($game_actors[i], 72, 64 * ii + 56)
draw_actor_level($game_actors[i], 36, 64 * ii + 32) # 等級
self.contents.font.size = 18
draw_actor_hp($game_actors[i], 152 - @xpvx[2], 64 * ii + 2) # HP
$Sword_VX ?
draw_actor_mp($game_actors[i], 152 - @xpvx[2], 64 * ii + 30) : # MP(VX)
draw_actor_sp($game_actors[i], 152 - @xpvx[2], 64 * ii + 30) # SP(XP)
self.contents.font.size = 22
ii += 1
end
update_cursor_rect
#○ 設定上限
@figmax = @mode ? [ii, Sword7_DESI - 1].min : [ii, Sword7_FISI - 1].min
@figmax = 0 if @figmax == -2
end
#-------------------------------------------------------------
#● 更新游標
def update_cursor_rect
XPVX.se_cursor
self.cursor_rect.set(0, 64 * (@index - @line), @xpvx[3], 64)
end
end
#=======================================
#■ 戰鬥畫面
class Scene_Battle
#-------------------------------------------------------------
#● 主處理
alias sword7_main main
def main
@figure_depot7 = Sword_FigureDepot.new(false) ; sword7_main ; @figure_depot7.dispose
end
#-------------------------------------------------------------
#● 更新
alias sword7_update update
def update
if @figure_depot7.visible # 更新人物倉庫
@figure_depot7.update
(@figure_depot7.status_update = false ; @status_window.refresh ; to_reset7) if
@figure_depot7.status_update # 需要更新狀態窗口的場合
return
end
sword7_update
end
#-------------------------------------------------------------
#● 顯示人物倉庫
def figure_depot7 ; @figure_depot7.visible = true ; end
#-------------------------------------------------------------
#● 重置行動順序
def to_reset7
return if @phase != 3 # 非在隊伍命令選擇的話就中斷
@actor_index = XPVX.members.size - 1 unless XPVX.members[@actor_index]
@actor_index -= 1
phase3_next_actor
end
end
#=======================================
#■ 人物倉庫畫面(與戰鬥畫面共用)
class Sword_FigureDepot
include Sword # 連接自定設置
attr_reader :visible # 整體畫面顯示標誌(nil狀態時為不使用)
attr_accessor :status_update # 戰鬥中的狀態窗口更新標誌
#-------------------------------------------------------------
#● 初始化物件(顯示標誌)
def initialize(visible = nil) ; @visible = visible ; main unless @visible.nil? ; end
#-------------------------------------------------------------
#● 主處理
def main
@xpvx = $Sword_VX ? 4 : 5 # 設定滾動條件
@help_window = Window_Help.new # 產生幫助窗口
@help_window.set_text(Sword7_HELP[0], Sword7_HELP[1])
@help_window.windowskin = RPG::Cache.windowskin("help")
@help_window.opacity = 200
@bg = Sprite.new
@bg.bitmap = RPG::Cache.picture("backround_bar")
@figure_wsword = WSword_FigureDepot.new(0) # 產生目前隊員窗口
@depot_wsword = WSword_FigureDepot.new(1) # 產生人物倉庫窗口
@depot_wsword.active = false
self.visible = @visible
return unless @visible.nil?
Graphics.transition(30, "Graphics/Transitions/Unbenannt-4")
loop{Graphics.update ; Input.update ; update ; break if $scene != self}
Graphics.freeze
dispose # 釋放
end
#-------------------------------------------------------------
#● 更新
def update
return if @visible == false # 整體畫面沒有顯示的場合
@figure_wsword.update ; @depot_wsword.update # 更新窗口
if @figure_wsword.active ; update_figure # 目前隊員窗口活動時
elsif @depot_wsword.active ; update_depot # 人物倉庫窗口活動時
end
end
#-------------------------------------------------------------
#● 更新目前隊員窗口
def update_figure
if Input.trigger?(Input::B) # 按下取消鍵的場合
return XPVX.se_buzzer if XPVX.members.empty? # 隊伍為空的情況
XPVX.se_cancel
if @visible ; self.visible = false ; @status_update = true
else ; $scene = Scene_Menu.new(6)
end
elsif Input.trigger?(Input::C) or Input.trigger?(Input::RIGHT)
return XPVX.se_buzzer if
$game_party.figepotX.include?(XPVX.members[@figure_wsword.index].id) if
XPVX.members[@figure_wsword.index] # 確認選擇的角色是否能移入倉庫中
# 開始選擇倉庫中的角色
XPVX.se_decision
@figure_wsword.active = false
@depot_wsword.active = true
@depot_wsword.index = 0
@depot_wsword.update_cursor_rect
elsif Input.trigger?(Input::UP) # 向上移動游標
@figure_wsword.index -= 1
if @figure_wsword.figmax >= @xpvx # 滾動
if @figure_wsword.index - @figure_wsword.line == -1
@figure_wsword.line -= 1 ; @figure_wsword.oy -= 64
end
if @figure_wsword.oy== -64 # 當選樣回到頂部時
@figure_wsword.line = @figure_wsword.figmax - @xpvx
@figure_wsword.oy = @figure_wsword.line * 64
@figure_wsword.index = @figure_wsword.figmax
end
elsif @figure_wsword.index == -1
@figure_wsword.index = @figure_wsword.figmax
end
@figure_wsword.update_cursor_rect
elsif Input.trigger?(Input::DOWN) # 向下移動游標
@figure_wsword.index == @figure_wsword.figmax ?
@figure_wsword.index = 0 : @figure_wsword.index += 1
if @figure_wsword.figmax >= @xpvx # 滾動
if @figure_wsword.index - @figure_wsword.line == @xpvx + 1 # 滾動開始
@figure_wsword.line += 1 ; @figure_wsword.oy += 64
end
if @figure_wsword.index == 0 # 當選樣回到頂部時
@figure_wsword.line = 0 ; @figure_wsword.oy = 0
end
end
@figure_wsword.update_cursor_rect
end
end
#-------------------------------------------------------------
#● 更新人物倉庫窗口
def update_depot
if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
XPVX.se_cancel ; end_depot
elsif Input.trigger?(Input::C) # 更換隊員
XPVX.se_decision
if XPVX.members[@figure_wsword.index] and
$game_party.figepot[@depot_wsword.index] # 交換
$game_party.move_figure_depot(XPVX.members[@figure_wsword.index].id,
$game_party.figepot[@depot_wsword.index])
elsif XPVX.members[@figure_wsword.index] # 移動(隊伍)
$game_party.move_figure_depot(XPVX.members[@figure_wsword.index].id)
elsif $game_party.figepot[@depot_wsword.index] # 移動(倉庫)
$game_party.move_figure_depot($game_party.figepot[@depot_wsword.index])
end
@figure_wsword.refresh ; @depot_wsword.refresh ; end_depot # 更新
elsif Input.trigger?(Input::UP)
@depot_wsword.index -= 1
if @depot_wsword.figmax >= @xpvx # 滾動
if @depot_wsword.index - @depot_wsword.line == -1
@depot_wsword.line -= 1 ; @depot_wsword.oy -= 64
end
if @depot_wsword.oy == -64 # 當選樣回到頂部時
@depot_wsword.line = @depot_wsword.figmax - @xpvx
@depot_wsword.oy = @depot_wsword.line * 64
@depot_wsword.index = @depot_wsword.figmax
end
elsif @depot_wsword.index == -1
@depot_wsword.index = @depot_wsword.figmax
end
@depot_wsword.update_cursor_rect
elsif Input.trigger?(Input::DOWN)
@depot_wsword.index == @depot_wsword.figmax ?
@depot_wsword.index = 0 : @depot_wsword.index += 1
if @depot_wsword.figmax >= @xpvx # 滾動
if @depot_wsword.index - @depot_wsword.line == @xpvx + 1 # 滾動開始
@depot_wsword.line += 1 ; @depot_wsword.oy += 64
end
if @depot_wsword.index == 0 # 當選樣回到頂部時
@depot_wsword.line = 0 ; @depot_wsword.oy = 0
end
end
@depot_wsword.update_cursor_rect
end
end
#-------------------------------------------------------------
#● 返回目前隊員選擇
def end_depot
@figure_wsword.active, @depot_wsword.active, @depot_wsword.index = true, false, -2
@depot_wsword.oy, @depot_wsword.line = 0, 0
@depot_wsword.update_cursor_rect
end
#-------------------------------------------------------------
#● 整體畫面顯示與活動=(顯示標誌)
def visible=(visible)
return if @visible.nil? # 如果是nil的情況就中斷
@help_window.z = @figure_wsword.z = @depot_wsword.z = 999
@visible = @help_window.visible = @figure_wsword.visible =
@depot_wsword.visible = visible
@figure_wsword.refresh ; @depot_wsword.refresh
end
#-------------------------------------------------------------
#● 釋放這個畫面的窗口
def dispose
@help_window.dispose ; @figure_wsword.dispose ; @depot_wsword.dispose
# $game_player.refresh # 更新領隊
@bg.dispose
end
end