设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2231|回复: 1
打印 上一主题 下一主题

[已经解决] 人物仓库脚本使用就出错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
3 小时
注册时间
2012-5-4
帖子
284
跳转到指定楼层
1
发表于 2012-6-27 20:37:27 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
  1. module Sword
  2. #=======================================
  3. #★ 魔劍工舖 - 人物倉庫 1.04
  4. # http://blog.yam.com/a870053jjkj/
  5. #=======================================
  6. =begin
  7. ● 函數
  8. 呼叫方法:$scene = Sword_FigureDepot.new
  9. 移動同伴:$game_party.move_figure_depot(角色編號)
  10. 交換同伴:$game_party.move_figure_depot(角色編號一, 角色編號二)
  11. 倉庫變量:$game_party.figepot
  12. 禁止變量:$game_party.figepotX
  13. ----------------------------------------------------------------
  14. ○ 只在戰鬥畫面中有效的設置
  15. 戰鬥呼叫:$scene.figure_depot7
  16. ========================================
  17. ● 所需腳本
  18. XP與VX資料轉換(1.01):http://blog.yam.com/a870053jjkj/article/33973184
  19. =end
  20. #=======================================
  21. #● 功能設定
  22. Sword7_HELP = ['更換隊伍', 1] # [幫助窗口文字, 靠邊],靠邊:0左;1中;2右
  23. Sword7_FISI = 4 # 設定持有隊員的上限數量,有減少或增多上限才要修改
  24. Sword7_DESI = 99 # 設定倉庫中最多能存放的人物數量
  25. Sword7_Add = 2 # 設定上限時增加隊員的情況,0為照加;1為不加;2為移到倉庫
  26. #=======================================
  27.   $Sword ? $Sword[7] = true : $Sword = {7=>true} # 腳本使用標誌
  28.   ($Sword_VX = false ; RPG::Weather rescue $Sword_VX = true) if $Sword_VX == nil
  29. end
  30. #=======================================
  31. #■ 同伴的類
  32. class Game_Party
  33.   include Sword # 連接自定設置
  34.   attr_accessor :figepot    # 倉庫空間
  35.   attr_accessor :figepotX   # 禁止存放列表
  36.   #-------------------------------------------------------------
  37.   #● 初始化物件
  38.   alias sword7_initialize initialize
  39.   def initialize ; sword7_initialize ; @figepot, @figepotX = [], [] ; end
  40.   #-------------------------------------------------------------
  41.   #● 加入同伴
  42.   alias sword7_add_actor add_actor
  43.   def add_actor(actor_id)
  44.     if @figepot.include?(actor_id) ; return # 防止出現分身
  45.     elsif XPVX.members.size + 1 > Sword7_FISI and Sword7_Add == 1 ; return
  46.     elsif XPVX.members.size + 1 > Sword7_FISI and Sword7_Add == 2 and
  47.     @figepot.size + 1 <= Sword7_DESI
  48.       @figepot += [actor_id] ; return
  49.     end
  50.     sword7_add_actor(actor_id)
  51.   end
  52.   #-------------------------------------------------------------
  53.   #● 角色離開
  54.   alias sword7_remove_actor remove_actor
  55.   def remove_actor(actor_id)
  56.     if @figepot.include?(actor_id) ; @figepot.delete(actor_id) # 倉庫的同伴離開
  57.     else ; sword7_remove_actor(actor_id) # 目前指定同伴離開
  58.     end
  59.   end
  60.   #-------------------------------------------------------------
  61.   #● 同伴與倉庫的移動處理(角色編號一, 角色編號二)
  62.   def move_figure_depot(actor_id, depot_id = nil)
  63.     ending = false # 結果
  64.     if depot_id # 交換的場合
  65.       if i1 = XPVX.members.index(
  66.       $game_actors[actor_id]) and i2 = @figepot.index(depot_id)
  67.         XPVX.members(i1, depot_id) ; @figepot[i2], ending = actor_id, true
  68.       elsif i1 = XPVX.members.index(
  69.       $game_actors[depot_id]) and i2 = @figepot.index(actor_id)
  70.         XPVX.members(i1, actor_id) ; @figepot[i2], ending = depot_id, true
  71.       end
  72.     else # 移動的場合
  73.       if XPVX.members.include?($game_actors[actor_id]) # 在隊伍中的話
  74.         remove_actor(actor_id) ; @figepot += [actor_id] ; ending = true
  75.       elsif @figepot.include?(actor_id) # 在倉庫中的話
  76.         @figepot -= [actor_id] ; add_actor(actor_id) ; ending = true
  77.       end
  78.     end
  79.     $game_player.refresh # 更新領隊
  80.     ending # 返回結果
  81.   end
  82. end
  83. #=======================================
  84. #■ 人物倉庫窗口
  85. class WSword_FigureDepot < Window_Base
  86.   include Sword # 連接自定設置
  87.   attr_accessor :figmax # 總人數
  88.   attr_accessor :line   # 滾動行數
  89.   attr_accessor :index  # 游標位置
  90.   #-------------------------------------------------------------
  91.   #● 初始化物件(倉庫標誌)
  92.   def initialize(mode) # mode:0為目前隊員(偽)、1為倉庫隊員(真)
  93.     @mode = mode == 0 ? false : true
  94.     # [窗口寬度/2, 說明窗口高度, HP與SP修正, 游標寬度, 名稱Y座標修正, 窗口高度]
  95.     @xpvx = [XPVX.width / 2, XPVX.wlh] + ($Sword_VX ? [36, Graphics.width / 2 - 32, 4] :
  96.     [0, 288, 0]) + [XPVX.height - XPVX.wlh]
  97.     super(mode * @xpvx[0], @xpvx[1], @xpvx[0], @xpvx[5])
  98.     @index = @mode ? -2 : 0 # 設定選項起始位置
  99.     @line = 0 # 記錄往下滾動了多少行
  100.     refresh
  101.   end
  102.   #-------------------------------------------------------------
  103.   #● 更新內容
  104.   def refresh
  105.     #○ 重新產生顯示用的位圖
  106.     if @mode # 倉庫顯示用位圖高度,除此以外則是目前隊伍窗口
  107.       a, b = $game_party.figepot.size, $game_party.figepot.size == Sword7_DESI ? 0 : 64
  108.     else ; a, b = XPVX.members.size, XPVX.members.size == Sword7_FISI ? 0 : 64
  109.     end
  110.     self.contents = Bitmap.new(width - 32, a * 64 + b)
  111.     self.contents.font.color = normal_color
  112.     ii = 0 # 隊員存在數
  113.     a = @mode ? $game_party.figepot : XPVX.members
  114.     #○ 產生隊員清單
  115.     for i in a
  116.       next if i == nil
  117.       i = i.id unless @mode
  118.       if $Sword_VX
  119.         draw_character($game_actors[i].character_name,
  120.         $game_actors[i].character_index, 18, 64 * ii + 48)
  121.       else
  122.         cache = $Sword_VX ? Cache.character($game_actors[i].character_name) :
  123.         RPG::Cache.character($game_actors[i].character_name, $game_actors[i].character_hue)
  124.         self.contents.blt(4, 64 * ii +  (64 - cache.height / 4) / 2, cache,
  125.         Rect.new(0, 0, cache.width / 4, cache.height / 4))
  126.       end
  127.       self.contents.font.size = 18 if $Sword_VX
  128.       draw_actor_name($game_actors[i], 36, 64 * ii + @xpvx[4]) # 名稱
  129.       draw_actor_level($game_actors[i], 36, 64 * ii + 32) # 等級
  130.       self.contents.font.size = 18
  131.       draw_actor_hp($game_actors[i], 152 - @xpvx[2], 64 * ii + 2) # HP
  132.       $Sword_VX ?
  133.       draw_actor_mp($game_actors[i], 152 - @xpvx[2], 64 * ii + 30) : # MP(VX)
  134.       draw_actor_sp($game_actors[i], 152 - @xpvx[2], 64 * ii + 30) # SP(XP)
  135.       self.contents.font.size = 22
  136.       ii += 1
  137.     end
  138.     update_cursor_rect
  139.     #○ 設定上限
  140.     @figmax = @mode ? [ii, Sword7_DESI - 1].min : [ii, Sword7_FISI - 1].min
  141.     @figmax = 0 if @figmax == -2
  142.   end
  143.   #-------------------------------------------------------------
  144.   #● 更新游標
  145.   def update_cursor_rect
  146.     XPVX.se_cursor
  147.     self.cursor_rect.set(0, 64 * (@index - @line), @xpvx[3], 64)
  148.   end
  149. end
  150. #=======================================
  151. #■ 戰鬥畫面
  152. class Scene_Battle
  153.   #-------------------------------------------------------------
  154.   #● 主處理
  155.   alias sword7_main main
  156.   def main
  157.     @figure_depot7 = Sword_FigureDepot.new(false) ; sword7_main ; @figure_depot7.dispose
  158.   end
  159.   #-------------------------------------------------------------
  160.   #● 更新
  161.   alias sword7_update update
  162.   def update
  163.     if @figure_depot7.visible # 更新人物倉庫
  164.       @figure_depot7.update
  165.       (@figure_depot7.status_update = false ; @status_window.refresh ; to_reset7) if
  166.       @figure_depot7.status_update # 需要更新狀態窗口的場合
  167.       return
  168.     end
  169.     sword7_update
  170.   end
  171.   #-------------------------------------------------------------
  172.   #● 顯示人物倉庫
  173.   def figure_depot7 ; @figure_depot7.visible = true ; end
  174.   #-------------------------------------------------------------
  175.   #● 重置行動順序
  176.   def to_reset7
  177.     return if @phase != 3 # 非在隊伍命令選擇的話就中斷
  178.     @actor_index = XPVX.members.size - 1 unless XPVX.members[@actor_index]
  179.     @actor_index -= 1
  180.     phase3_next_actor
  181.   end
  182. end
  183. #=======================================
  184. #■ 人物倉庫畫面(與戰鬥畫面共用)
  185. class Sword_FigureDepot
  186.   include Sword # 連接自定設置
  187.   attr_reader    :visible # 整體畫面顯示標誌(nil狀態時為不使用)
  188.   attr_accessor :status_update # 戰鬥中的狀態窗口更新標誌
  189.   #-------------------------------------------------------------
  190.   #● 初始化物件(顯示標誌)
  191.   def initialize(visible = nil) ; @visible = visible ; main unless @visible.nil? ; end
  192.   #-------------------------------------------------------------
  193.   #● 主處理
  194.   def main
  195.     @xpvx = $Sword_VX ? 4 : 5 # 設定滾動條件
  196.     @help_window = Window_Help.new # 產生幫助窗口
  197.     @help_window.set_text(Sword7_HELP[0], Sword7_HELP[1])
  198.     @figure_wsword = WSword_FigureDepot.new(0) # 產生目前隊員窗口
  199.     @depot_wsword = WSword_FigureDepot.new(1) # 產生人物倉庫窗口
  200.     @depot_wsword.active = false
  201.     self.visible = @visible
  202.     return unless @visible.nil?
  203.     Graphics.transition
  204.     loop{Graphics.update ; Input.update ; update ; break if $scene != self}
  205.     Graphics.freeze
  206.     dispose # 釋放
  207.   end
  208.   #-------------------------------------------------------------
  209.   #● 更新
  210.   def update
  211.     return if @visible == false # 整體畫面沒有顯示的場合
  212.     @figure_wsword.update ; @depot_wsword.update # 更新窗口
  213.     if @figure_wsword.active ; update_figure # 目前隊員窗口活動時
  214.     elsif @depot_wsword.active ; update_depot # 人物倉庫窗口活動時
  215.     end
  216.   end
  217.   #-------------------------------------------------------------
  218.   #● 更新目前隊員窗口
  219.   def update_figure
  220.     if Input.trigger?(Input::B) # 按下取消鍵的場合
  221.       return XPVX.se_buzzer if XPVX.members.empty? # 隊伍為空的情況
  222.       XPVX.se_cancel
  223.       if @visible ; self.visible = false ; @status_update = true
  224.       else ; $scene = Scene_Map.new
  225.       end
  226.     elsif Input.trigger?(Input::C) or Input.trigger?(Input::RIGHT)
  227.       return XPVX.se_buzzer if
  228.       $game_party.figepotX.include?(XPVX.members[@figure_wsword.index].id) if
  229.       XPVX.members[@figure_wsword.index] # 確認選擇的角色是否能移入倉庫中
  230.       # 開始選擇倉庫中的角色
  231.       XPVX.se_decision
  232.       @figure_wsword.active = false
  233.       @depot_wsword.active = true
  234.       @depot_wsword.index = 0
  235.       @depot_wsword.update_cursor_rect
  236.     elsif Input.trigger?(Input::UP) # 向上移動游標
  237.       @figure_wsword.index -= 1
  238.       if @figure_wsword.figmax >= @xpvx # 滾動
  239.         if @figure_wsword.index - @figure_wsword.line == -1
  240.           @figure_wsword.line -= 1 ; @figure_wsword.oy -= 64
  241.         end
  242.         if @figure_wsword.oy== -64 # 當選樣回到頂部時
  243.           @figure_wsword.line = @figure_wsword.figmax - @xpvx
  244.           @figure_wsword.oy = @figure_wsword.line * 64
  245.           @figure_wsword.index = @figure_wsword.figmax
  246.         end
  247.       elsif @figure_wsword.index == -1
  248.         @figure_wsword.index = @figure_wsword.figmax
  249.       end
  250.       @figure_wsword.update_cursor_rect
  251.     elsif Input.trigger?(Input::DOWN) # 向下移動游標
  252.       @figure_wsword.index == @figure_wsword.figmax ?
  253.       @figure_wsword.index = 0 : @figure_wsword.index += 1
  254.       if @figure_wsword.figmax >= @xpvx # 滾動
  255.         if @figure_wsword.index - @figure_wsword.line == @xpvx + 1 # 滾動開始
  256.           @figure_wsword.line += 1 ; @figure_wsword.oy += 64
  257.         end
  258.         if @figure_wsword.index == 0 # 當選樣回到頂部時
  259.           @figure_wsword.line = 0 ; @figure_wsword.oy = 0
  260.         end
  261.       end
  262.       @figure_wsword.update_cursor_rect
  263.     end
  264.   end
  265.   #-------------------------------------------------------------
  266.   #● 更新人物倉庫窗口
  267.   def update_depot
  268.     if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
  269.       XPVX.se_cancel ; end_depot
  270.     elsif Input.trigger?(Input::C) # 更換隊員
  271.       XPVX.se_decision
  272.       if XPVX.members[@figure_wsword.index] and
  273.       $game_party.figepot[@depot_wsword.index] # 交換
  274.         $game_party.move_figure_depot(XPVX.members[@figure_wsword.index].id,
  275.         $game_party.figepot[@depot_wsword.index])
  276.       elsif XPVX.members[@figure_wsword.index] # 移動(隊伍)
  277.         $game_party.move_figure_depot(XPVX.members[@figure_wsword.index].id)
  278.       elsif $game_party.figepot[@depot_wsword.index] # 移動(倉庫)
  279.         $game_party.move_figure_depot($game_party.figepot[@depot_wsword.index])
  280.       end
  281.       @figure_wsword.refresh ; @depot_wsword.refresh ; end_depot # 更新
  282.     elsif Input.trigger?(Input::UP)
  283.       @depot_wsword.index -= 1
  284.       if @depot_wsword.figmax >= @xpvx # 滾動
  285.         if @depot_wsword.index - @depot_wsword.line == -1
  286.           @depot_wsword.line -= 1 ; @depot_wsword.oy -= 64
  287.         end
  288.         if @depot_wsword.oy == -64 # 當選樣回到頂部時
  289.           @depot_wsword.line = @depot_wsword.figmax - @xpvx
  290.           @depot_wsword.oy = @depot_wsword.line * 64
  291.           @depot_wsword.index = @depot_wsword.figmax
  292.         end
  293.       elsif @depot_wsword.index == -1
  294.         @depot_wsword.index = @depot_wsword.figmax
  295.       end
  296.       @depot_wsword.update_cursor_rect
  297.     elsif Input.trigger?(Input::DOWN)
  298.       @depot_wsword.index == @depot_wsword.figmax ?
  299.       @depot_wsword.index = 0 : @depot_wsword.index += 1
  300.       if @depot_wsword.figmax >= @xpvx # 滾動
  301.         if @depot_wsword.index - @depot_wsword.line == @xpvx + 1 # 滾動開始
  302.           @depot_wsword.line += 1 ; @depot_wsword.oy += 64
  303.         end
  304.         if @depot_wsword.index == 0 # 當選樣回到頂部時
  305.           @depot_wsword.line = 0 ; @depot_wsword.oy = 0
  306.         end
  307.       end
  308.       @depot_wsword.update_cursor_rect
  309.     end
  310.   end
  311.   #-------------------------------------------------------------
  312.   #● 返回目前隊員選擇
  313.   def end_depot
  314.     @figure_wsword.active, @depot_wsword.active, @depot_wsword.index = true, false, -2
  315.     @depot_wsword.oy, @depot_wsword.line = 0, 0
  316.     @depot_wsword.update_cursor_rect
  317.   end
  318.   #-------------------------------------------------------------
  319.   #● 整體畫面顯示與活動=(顯示標誌)
  320.   def visible=(visible)
  321.     return if @visible.nil? # 如果是nil的情況就中斷
  322.     @help_window.z = @figure_wsword.z = @depot_wsword.z = 999
  323.     @visible = @help_window.visible = @figure_wsword.visible =
  324.     @depot_wsword.visible = visible
  325.     @figure_wsword.refresh ; @depot_wsword.refresh
  326.   end
  327.   #-------------------------------------------------------------
  328.   #● 釋放這個畫面的窗口
  329.   def dispose
  330.     @help_window.dispose ; @figure_wsword.dispose ; @depot_wsword.dispose
  331.     $game_player.refresh # 更新領隊
  332.   end
  333. end
复制代码

Lv3.寻梦者

梦石
0
星屑
1314
在线时间
962 小时
注册时间
2012-4-30
帖子
1475

开拓者

2
发表于 2012-6-27 21:50:33 | 只看该作者
● 所需脚本
XP与VX资料转换(1.01):http://blog.yam.com/a870053jjkj/article/33973184  需要解释么?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-2 10:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表