Project1

标题: 请问这个队员改变脚本如何使用 [打印本页]

作者: 反斗奇彬    时间: 2010-10-20 17:25
标题: 请问这个队员改变脚本如何使用
  1. #==============================================================================
  2. # ** 队员改变系统
  3. #------------------------------------------------------------------------------
  4. #  编写:Dargor©
  5. #  时间:2008.08.03
  6. #  汉化:DeathKing
  7. #  时间:2009.06.17
  8. #  更新:DeathKing
  9. #  时间:2009.06.17
  10. #  版本:1.1
  11. #------------------------------------------------------------------------------
  12. #  更新历史:
  13. #   - 1.0 (2008.08.03), 发布初始版本
  14. #   - 1.1 (2009.06.17), DeathKing更新版本,修正了与国内RMVX脚本
  15. #                       不兼容问题。(找不到Game_Party的max_members方法)
  16. #------------------------------------------------------------------------------
  17. #  备注:
  18. #  一些无关紧要的就不翻译了!
  19. #==============================================================================

  20. # 词汇定义
  21. Vocab::PartyAccept       = '确认'         # 确认排序
  22. Vocab::PartyArrange      = '调整'         # 调整顺序
  23. Vocab::PartyReset        = '重置'         # 重新设定
  24. Vocab::PartyAcceptTxt    = '确认排列'     # 用于下方的详细说明
  25. Vocab::PartyArrangeTxt   = '调整顺序'     # 同上
  26. Vocab::PartyResetTxt     = '重置队列'     # 同上


  27. #==============================================================================
  28. # ** Window_Base
  29. #------------------------------------------------------------------------------
  30. #  所有窗口的超级类。
  31. #==============================================================================

  32. class Window_Base < Window
  33.   #--------------------------------------------------------------------------
  34.   # * Remake Window Contents
  35.   #--------------------------------------------------------------------------
  36.   def remake_contents(width, height)
  37.     self.width = width
  38.     self.height = height
  39.     create_contents
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # * Draw Actor Walking Graphic
  43.   #     actor : actor
  44.   #     x     : draw spot x-coordinate
  45.   #     y     : draw spot y-coordinate
  46.   #--------------------------------------------------------------------------
  47.   def draw_actor_graphic(actor, x, y, opacity = 255)
  48.     draw_character(actor.character_name, actor.character_index, x, y, opacity)
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Draw Character Graphic
  52.   #     character_name  : Character graphic filename
  53.   #     character_index : Character graphic index
  54.   #     x     : draw spot x-coordinate
  55.   #     y     : draw spot y-coordinate
  56.   #--------------------------------------------------------------------------
  57.   def draw_character(character_name, character_index, x, y, opacity = 255)
  58.     return if character_name == nil
  59.     bitmap = Cache.character(character_name)
  60.     sign = character_name[/^[\!\$]./]
  61.     if sign != nil and sign.include?('$')
  62.       cw = bitmap.width / 3
  63.       ch = bitmap.height / 4
  64.     else
  65.       cw = bitmap.width / 12
  66.       ch = bitmap.height / 8
  67.     end
  68.     n = character_index
  69.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  70.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
  71.   end
  72. end

  73. #==============================================================================
  74. # ** Game_Party
  75. #------------------------------------------------------------------------------
  76. #  This class handles the party. It includes information on amount of gold
  77. # and items. The instance of this class is referenced by $game_party.
  78. #==============================================================================

  79. class Game_Party < Game_Unit
  80.   #--------------------------------------------------------------------------
  81.   # * Public Instance Variables
  82.   #--------------------------------------------------------------------------
  83.   attr_accessor :actors
  84.   attr_accessor :reserve_actors
  85.   #--------------------------------------------------------------------------
  86.   # * Alias Listing
  87.   #--------------------------------------------------------------------------
  88.   alias dargor_party_changer_party_initialize initialize
  89.   alias dargor_party_add_actor add_actor
  90.   alias dargor_party_remove_actor remove_actor
  91.   #--------------------------------------------------------------------------
  92.   # * Object Initialization
  93.   #--------------------------------------------------------------------------
  94.   def initialize
  95.     dargor_party_changer_party_initialize
  96.     @reserve_actors = []
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # * Get Reserve Members
  100.   #--------------------------------------------------------------------------
  101.   def reserve_members
  102.     result = []
  103.     for i in @reserve_actors
  104.       result.push($game_actors)
  105.     end
  106.     return result
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Get All Members
  110.   #--------------------------------------------------------------------------
  111.   def all_members
  112.     all_actors = (@actors + @reserve_actors).sort
  113.     array = []
  114.     for i in all_actors
  115.       array << $game_actors
  116.     end
  117.     return array.uniq
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Add an Actor
  121.   #     actor_id : actor ID
  122.   #--------------------------------------------------------------------------
  123.   def add_actor(actor_id)
  124.     dargor_party_add_actor(actor_id)
  125.     add_reserve_actor(actor_id)
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # * Remove Actor
  129.   #     actor_id : actor ID
  130.   #--------------------------------------------------------------------------
  131.   def remove_actor(actor_id)
  132.     dargor_party_remove_actor(actor_id)
  133.     remove_reserve_actor(actor_id)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Add an Actor from the Reserve
  137.   #     actor_id : actor ID
  138.   #--------------------------------------------------------------------------
  139.   def add_reserve_actor(actor_id, force=false)
  140.     if force
  141.       @reserve_actors.push(actor_id)
  142.       $game_player.refresh
  143.       return
  144.     end
  145.     if @actors.size == MAX_MEMBERS and not @reserve_actors.include?(actor_id)
  146.       @reserve_actors.push(actor_id)
  147.       $game_player.refresh
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Remove Actor from the Reserve
  152.   #     actor_id : actor ID
  153.   #--------------------------------------------------------------------------
  154.   def remove_reserve_actor(actor_id)
  155.     @reserve_actors.delete(actor_id)
  156.     $game_player.refresh
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 获取最大同伴数
  160.   #--------------------------------------------------------------------------
  161.   def max_members
  162.     return MAX_MEMBERS
  163.   end
  164. end

  165. #==============================================================================
  166. # ** Window_Party
  167. #------------------------------------------------------------------------------
  168. #  This window displays party member status on the party changer screen.
  169. #==============================================================================

  170. class Window_PartyMembers < Window_Selectable
  171.   #--------------------------------------------------------------------------
  172.   # * Public Instance Variables
  173.   #--------------------------------------------------------------------------
  174.   attr_accessor :members
  175.   #--------------------------------------------------------------------------
  176.   # * Object Initialization
  177.   #     x : window X coordinate
  178.   #     y : window Y coordinate
  179.   #--------------------------------------------------------------------------
  180.   def initialize
  181.     super(0, 0, 272, 416)
  182.     @members = []
  183.     @selection_rect = false
  184.     @selection_y = 0
  185.     refresh
  186.     self.active = false
  187.     self.index = -1
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # * Refresh
  191.   #--------------------------------------------------------------------------
  192.   def refresh
  193.     self.contents.clear
  194.     @item_max = @members.size
  195.     if @selection_rect
  196.       color = Color.new(0,0,0,160)
  197.       self.contents.fill_rect(2, @selection_y, contents.width-4, 92, color)
  198.     end
  199.     i = 0
  200.     for actor in @members
  201.       x = 104
  202.       y = i * 96 + WLH / 2 + 10
  203.       draw_actor_face(actor, 2, i * 96 + 2, 92)
  204.       draw_actor_name(actor, x, y - WLH)
  205.       draw_actor_level(actor, x, y)
  206.       draw_actor_hp(actor, x, y + WLH * 1)
  207.       draw_actor_mp(actor, x, y + WLH * 2)
  208.       i += 1
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # * Add Member
  213.   #--------------------------------------------------------------------------
  214.   def add_member(id)
  215.     return if @members.include?($game_party.all_members[id])
  216.     @members.push($game_party.all_members[id])
  217.     w = self.width
  218.     h = self.height = 416 + (96 * (@members.size-4))
  219.     remake_contents(w, h)
  220.     self.height = 416
  221.     refresh
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # * Remove Member
  225.   #--------------------------------------------------------------------------
  226.   def remove_member(id)
  227.     @members.delete($game_party.all_members[id])
  228.     w = self.width
  229.     h = self.height = 416 + (96 * (@members.size-4))
  230.     remake_contents(w, h)
  231.     self.height = 416
  232.     refresh
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # * Clear Members
  236.   #--------------------------------------------------------------------------
  237.   def clear_members
  238.     @members = []
  239.     w = self.width
  240.     h = self.height = 416 + (96 * (@members.size-4))
  241.     remake_contents(w, h)
  242.     self.height = 416
  243.     refresh
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # * Set Selection Rect
  247.   #--------------------------------------------------------------------------
  248.   def set_selection_rect(index)
  249.     @selection_rect = true
  250.     @selection_y = index * 96 - WLH / 2 + 14
  251.     refresh
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # * Clear Selection Rect
  255.   #--------------------------------------------------------------------------
  256.   def clear_selection_rect
  257.     @selection_rect = false
  258.     refresh
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * Update cursor
  262.   #--------------------------------------------------------------------------
  263.   def update_cursor
  264.     if @index < 0
  265.       self.cursor_rect.empty
  266.       return
  267.     end
  268.     # Get top row
  269.     row = @index  / @column_max
  270.     if row < self.top_row
  271.       self.top_row = row
  272.     end
  273.     # Reset Top Row if at bottom of list
  274.     if row > self.top_row + (self.page_row_max - 1)
  275.       self.top_row = row - (self.page_row_max - 1)
  276.     end
  277.     y = @index / @column_max * 96 - self.oy
  278.     # Draw the cursor
  279.     self.cursor_rect.set(0, y, contents.width, 96)
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # * Get Top Row
  283.   #--------------------------------------------------------------------------  
  284.   def top_row
  285.     return self.oy / 96
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # * Set Top Row
  289.   #     row : row shown on top
  290.   #--------------------------------------------------------------------------  
  291.   def top_row=(row)
  292.     if row < 0
  293.       row = 0
  294.     end
  295.     if row > row_max - 1
  296.       row = row_max - 1
  297.     end
  298.     self.oy = row * 96
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # * Get Number of Rows Displayable on 1 Page
  302.   #--------------------------------------------------------------------------  
  303.   def page_row_max
  304.     return 4
  305.   end
  306. end

  307. #==============================================================================
  308. # ** Window_ReserveMembers
  309. #------------------------------------------------------------------------------
  310. #  This window displays reserve members on the party changer screen.
  311. #==============================================================================

  312. class Window_ReserveMembers < Window_Selectable
  313.   #--------------------------------------------------------------------------
  314.   # * Public Instance Variables
  315.   #--------------------------------------------------------------------------
  316.   attr_accessor :members
  317.   #--------------------------------------------------------------------------
  318.   # * Object Initialization
  319.   #     x : window X coordinate
  320.   #     y : window Y coordinate
  321.   #--------------------------------------------------------------------------
  322.   def initialize
  323.     @members = $game_party.all_members.dup
  324.     height =  58 * (@members.size.to_f / 4).ceil
  325.     super(272, 128, 272, height)
  326.     @item_max = @members.size
  327.     @column_max = 4
  328.     @row_max = (@members.size.to_f / 4).ceil
  329.     refresh
  330.     self.height = 128
  331.     self.index = 0
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # * Refresh
  335.   #--------------------------------------------------------------------------
  336.   def refresh
  337.     self.contents.clear
  338.     i = 0
  339.     for actor in @members
  340.       opacity = 255
  341.       if actor.nil?
  342.         actor = $game_party.all_members
  343.         opacity = 160
  344.       end
  345.       x = 24 + i % 4 * 60
  346.       y = 40 + i / 4 * 48
  347.       draw_actor_graphic(actor,x,y,opacity)
  348.       i += 1
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # * Set Member
  353.   #--------------------------------------------------------------------------
  354.   def set_member(index, member_id)
  355.     @members[index] = member_id
  356.     refresh
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # * Reset Members
  360.   #--------------------------------------------------------------------------
  361.   def reset_members
  362.     @members = $game_party.all_members.dup
  363.     refresh
  364.   end
  365.   #--------------------------------------------------------------------------
  366.   # * Update cursor
  367.   #--------------------------------------------------------------------------
  368.   def update_cursor
  369.     x = @index % 4 * 60
  370.     y = @index / 4 * 48
  371.     y -= self.oy
  372.     if @index < 0               # No cursor
  373.       self.cursor_rect.empty
  374.     elsif @index < @item_max    # Normal
  375.       self.cursor_rect.set(x, y, 48, 48)
  376.     end
  377.     # Get top row
  378.     row = @index  / @column_max
  379.     if row < self.top_row
  380.       self.top_row = row
  381.     end
  382.     # Reset Top Row if at bottom of list
  383.     if row > self.top_row + (self.page_row_max - 1)
  384.       self.top_row = row - (self.page_row_max - 1)
  385.     end
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * Get Top Row
  389.   #--------------------------------------------------------------------------  
  390.   def top_row
  391.     return self.oy / 48
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * Set Top Row
  395.   #     row : row shown on top
  396.   #--------------------------------------------------------------------------  
  397.   def top_row=(row)
  398.     if row < 0
  399.       row = 0
  400.     end
  401.     if row > row_max - 1
  402.       row = row_max - 1
  403.     end
  404.     self.oy = row * 48
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # * Get Number of Rows Displayable on 1 Page
  408.   #--------------------------------------------------------------------------  
  409.   def page_row_max
  410.     return 2
  411.   end
  412. end

  413. #==============================================================================
  414. # ** Window_MemberStatus
  415. #------------------------------------------------------------------------------
  416. #  This window displays a member's status on the party changer screen.
  417. #==============================================================================

  418. class Window_MemberStatus < Window_Base
  419.   #--------------------------------------------------------------------------
  420.   # * Object Initialization
  421.   #     x : window X coordinate
  422.   #     y : window Y coordinate
  423.   #--------------------------------------------------------------------------
  424.   def initialize
  425.     super(272, 0, 272, 128)
  426.     @member = nil
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # * Refresh
  430.   #--------------------------------------------------------------------------
  431.   def refresh
  432.     self.contents.clear
  433.     return if @member.nil?
  434.     actor = @member
  435.     x = 104
  436.     draw_actor_face(actor, 2, 2, 92)
  437.     draw_actor_name(actor, x, 0)
  438.     draw_actor_level(actor, x, WLH)
  439.     draw_actor_hp(actor, x, WLH * 2)
  440.     draw_actor_mp(actor, x, WLH * 3)
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # * Set Member
  444.   #--------------------------------------------------------------------------
  445.   def set_member(member)
  446.     @member = $game_actors[member]
  447.     refresh
  448.   end
  449. end

  450. #==============================================================================
  451. # ** Scene_PartyChanger
  452. #------------------------------------------------------------------------------
  453. #  This class performs the Party Changer screen processing.
  454. #==============================================================================

  455. class Scene_PartyChanger < Scene_Base
  456.   #--------------------------------------------------------------------------
  457.   # * Start processing
  458.   #--------------------------------------------------------------------------
  459.   def start
  460.     super
  461.     create_menu_background
  462.     create_command_window
  463.     create_help_window
  464.     @party_window = Window_PartyMembers.new
  465.     @reserve_window = Window_ReserveMembers.new
  466.     @status_window = Window_MemberStatus.new
  467.     @status_window.set_member(@reserve_window.index)
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # * Termination Processing
  471.   #--------------------------------------------------------------------------
  472.   def terminate
  473.     super
  474.     dispose_menu_background
  475.     @party_window.dispose
  476.     @reserve_window.dispose
  477.     @command_window.dispose
  478.     @status_window.dispose
  479.     @help_window.dispose
  480.   end
  481.   #--------------------------------------------------------------------------
  482.   # * Create Help Window
  483.   #--------------------------------------------------------------------------
  484.   def create_help_window
  485.     @help_window = Window_Help.new
  486.     @help_window.x = 272
  487.     @help_window.y = 416 - 56
  488.     @help_window.width = 272
  489.     @help_window.create_contents
  490.     @help_window.set_text('从你的同伴')
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # * Create Command Window
  494.   #--------------------------------------------------------------------------
  495.   def create_command_window
  496.     s1 = Vocab::PartyAccept
  497.     s2 = Vocab::PartyArrange
  498.     s3 = Vocab::PartyReset
  499.     @command_window = Window_Command.new(160, [s1, s2, s3])
  500.     @command_window.index = 0
  501.     @command_window.x = 272
  502.     @command_window.y = 256
  503.     @command_window.width = 272
  504.     @command_window.active = false
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # * Frame Update
  508.   #--------------------------------------------------------------------------
  509.   def update
  510.     @old_index = @reserve_window.index
  511.     super
  512.     update_menu_background
  513.     update_help
  514.     @command_window.update
  515.     @party_window.update
  516.     @reserve_window.update
  517.     @status_window.update
  518.     @help_window.update
  519.     if can_display_status?
  520.       @status_window.set_member(@reserve_window.index+1)
  521.     end
  522.     if @command_window.active
  523.       update_command_selection
  524.       return
  525.     end
  526.     if @party_window.active
  527.       update_party_selection
  528.       return
  529.     end
  530.     if @reserve_window.active
  531.       update_reserve_selection
  532.       return
  533.     end
  534.   end
  535.   #--------------------------------------------------------------------------
  536.   # * Can Display Status?
  537.   #--------------------------------------------------------------------------
  538.   def can_display_status?
  539.     return @reserve_window.index != @old_index
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # * Frame Update : Help Window
  543.   #--------------------------------------------------------------------------
  544.   def update_help
  545.     if @party_window.active
  546.       @help_window.set_text('调整队列')
  547.     end
  548.     if @reserve_window.active
  549.       @help_window.set_text('从你的同伴')
  550.     end
  551.     if @command_window.active
  552.       case @command_window.index
  553.       when 0
  554.         @help_window.set_text(Vocab::PartyAcceptTxt)
  555.       when 1
  556.         @help_window.set_text(Vocab::PartyArrangeTxt )
  557.       when 2
  558.         @help_window.set_text(Vocab::PartyResetTxt)
  559.       end
  560.     end
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # * Frame Update : Party Window
  564.   #--------------------------------------------------------------------------
  565.   def update_party_selection
  566.     # 跳转至命令窗口
  567.     if Input.trigger?(Input::B)
  568.       @party_window.active = false
  569.       @party_window.index = -1
  570.       @command_window.active = true
  571.       @party_window.clear_selection_rect
  572.       @member1 = nil
  573.       @member2 = nil
  574.       return
  575.     end
  576.     # 调整队列
  577.     if Input.trigger?(Input::C)
  578.       # 创建第一同伴变量
  579.       if @member1.nil?
  580.         @member1 = @party_window.members[@party_window.index]
  581.         @member1_index = @party_window.index
  582.         @party_window.set_selection_rect(@member1_index)
  583.         return
  584.       end
  585.       # 创建第二同伴变量
  586.       if @member2.nil?
  587.         @member2 = @party_window.members[@party_window.index]
  588.         @member2_index = @party_window.index
  589.         # 如果不是同一人就交换他们的位置
  590.         if @member1 != @member2
  591.           @party_window.members[@member1_index] = @member2
  592.           @party_window.members[@member2_index] = @member1
  593.         end
  594.         @party_window.clear_selection_rect
  595.         @member1 = nil
  596.         @member2 = nil
  597.       end
  598.     end
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # * Frame Update : Reserve Window
  602.   #--------------------------------------------------------------------------
  603.   def update_reserve_selection
  604.     # 如果同伴少于一人则调回选择角色的窗口。
  605.     if Input.trigger?(Input::B) and @party_window.members.size > 0
  606.       @reserve_window.active = false
  607.       @command_window.active = true
  608.       return
  609.     end
  610.     # 将角色加入同伴
  611.     if Input.trigger?(Input::C)
  612.       @party_window.add_member(@reserve_window.index)
  613.       @reserve_window.set_member(@reserve_window.index, nil)
  614.     end
  615.     # 如果同伴已满就跳转至另一窗口
  616.     if @party_window.members.size == $game_party.max_members
  617.       @command_window.active = true
  618.       @reserve_window.active = false
  619.       return
  620.     end
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # * Frame Update : Command Window
  624.   #--------------------------------------------------------------------------
  625.   def update_command_selection
  626.     if Input.trigger?(Input::C)
  627.       case @command_window.index
  628.       # 重置队列
  629.       when 0
  630.         $game_party.actors.clear
  631.         for member in @party_window.members + @reserve_window.members
  632.           if @party_window.members.include?(member)
  633.             $game_party.add_actor(member.id)
  634.           end
  635.           $game_party.add_reserve_actor(member.id, true)
  636.         end
  637.         $game_player.refresh
  638.         $scene = Scene_Map.new
  639.       # 调整队列
  640.       when 1
  641.         @party_window.index = 0
  642.         @party_window.active = true
  643.         @command_window.active = false
  644.       # 重置队列
  645.       when 2
  646.         @party_window.clear_members
  647.         @party_window.clear_selection_rect
  648.         @reserve_window.reset_members
  649.         @reserve_window.active
  650.         @reserve_window.active = true
  651.         @command_window.active = false
  652.       end
  653.     end
  654.   end
  655. end
复制代码
我问的是在游戏中如何把它调出来,用什么命令啊,拜托各位大哥大姐告诉我一下
作者: 巧克力猫咪    时间: 2010-10-20 17:32
本帖最后由 巧克力猫咪 于 2010-10-20 17:34 编辑

回复 反斗奇彬 的帖子


    插入脚本$scene = Scene_PartyChanger.new,不过这个的话有点BUG
# 1.系统呼出命令: $scene = Scene_Party.new

# 2.队员锁定命令: $game_party.members[0].actor.required = true  
# (其中数字0表示1号队员在队伍中锁定而无法进入仓库,1即为2号队员,以此类推)

# 3.队员加入仓库命令: $data_actors[5].found = true  
# (其中数字5表示5号队员直接进入仓库等待招募而不加入队伍,当队伍满员时使用此命令)

# 4.队员踢除仓库命令: $data_actors[5].found = false  
# (其中数字5表示将呆在仓库里的5号队员清除,该命令用于离开的队员)

# 5.队员加入仓库但无法被招募:$data_actors[8].found = true
#                              $data_actors[8].unavailable = true  
# (其中数字8表示8号队员# 直接进入仓库但无法被招募,该命令用于俘虏类)

# 6.仓库里无法招募的队员启动命令: $data_actors.each do |a|
#                                    a.unavailable = false if a
#                                   end                           
# (该命令作为第5项命令的补充,使所有仓库里无法被招募的队员重启为可招募状态)

# 7.全体队员进入仓库: $data_actors.each do |a|
#                         a.found = true if a
#                        nd                    
# (该命令使所有队员进入仓库等待招募,在队伍 中的队员不受影响)   

#  队员管理脚本(v1.1c)



module RPG

  class Actor

    def setup

      @found = false

      @unavailable = false

      @required = false

    end

    attr_accessor :found

    attr_accessor :unavailable

    attr_accessor :required

  end

end



class Game_Actors

  attr_reader :data

  alias prex_party_g_actors_initialize initialize

  def initialize

    prex_party_g_actors_initialize

    $data_actors.each do |actor|

      actor.setup if actor

      @data[actor.id] = Game_Actor.new(actor.id) if actor

    end

  end

end



class Scene_File < Scene_Base

  alias prex_party_s_file_write_save_data write_save_data

  alias prex_party_s_file_read_save_data read_save_data

  def write_save_data(file)

    prex_party_s_file_write_save_data(file)

    Marshal.dump($data_actors, file)

  end

  def read_save_data(file)

    prex_party_s_file_read_save_data(file)

    $data_actors = Marshal.load(file)

  end

end



class Scene_Title < Scene_Base

  alias prex_party_s_title_command_new_game command_new_game

  def command_new_game

    prex_party_s_title_command_new_game

    $game_party.members.each {|s| s.actor.found = true if s}

  end

end



class Window_Base < Window

  def draw_item_name(item, x, y, enabled = true, width = 172)

    if item != nil

      draw_icon(item.icon_index, x, y, enabled)

      self.contents.font.color = normal_color

      self.contents.font.color.alpha = enabled ? 255 : 128

      self.contents.draw_text(x + 24, y, width, WLH, item.name)

    end

  end

end



class Scene_Party < Scene_Base

  def start

    super

    create_menu_background

    create_windows

  end

  def create_windows

    @member_window = Window_CurrentMember.new

    @party_window = Window_CurrentParty.new

    @party_window.active = true

    @selectable_window = Window_SelectMember.new

  end

  def update_windows

    @member_window.update

    @party_window.update

    @selectable_window.update

    if @party_window.active

      @member_window.set_member(@party_window.member)

    elsif @selectable_window.active

      @member_window.set_member(@selectable_window.member)

    end

  end

  def terminate

    super

    @member_window.dispose

    @party_window.dispose

    @selectable_window.dispose

  end

  def update

    super

    update_windows

    update_input

  end

  def update_input

    if Input.trigger?(Input::A)

      if @member_window.mode == 1

        @member_window.set_mode(0)

      elsif @member_window.mode == 0

        @member_window.set_mode(1)

      end

    end

    if @party_window.active

      if Input.trigger?(Input::B)

        Sound.play_cancel

        $scene = Scene_Map.new

      elsif Input.trigger?(Input::C)

        member = @party_window.member

        if member != nil

          if member.actor.unavailable or member.actor.required

            Sound.play_buzzer

            return

          end

        end

        Sound.play_decision

        @party_window.active = false

        @selectable_window.active = true

        @selectable_window.index = 0

      end

    elsif @selectable_window.active

      if Input.trigger?(Input::B)

        Sound.play_cancel

        @selectable_window.index = -1

        @selectable_window.active = false

        @party_window.active = true

      elsif Input.trigger?(Input::C)

        member = @selectable_window.member

        if member != nil

          if member.actor.unavailable

            Sound.play_buzzer

            return

          end

        end

        Sound.play_decision

        $game_party.remove_actor(@party_window.member.id) if @party_window.member != nil

        $game_party.add_actor(@selectable_window.member.id) if @selectable_window.member != nil

        @selectable_window.refresh

        @party_window.refresh

        @selectable_window.index = -1

        @selectable_window.active = false

        @party_window.active = true

      end

    end

  end

end



class Window_CurrentMember < Window_Base

  attr_reader :mode

  def initialize(member = nil, mode = 0)

    super(304, 80, 192, 256)

    create_contents

    @member = member

    @mode = 0

    refresh

  end

  def member

    return @member

  end

  def set_member(member)

    old_member = @member

    @member = member

    refresh if old_member != @member

  end

  def set_mode(mode)

    @mode = mode if [0, 1].include?(mode)

    refresh

  end

  def refresh

    self.contents.clear

    return unless @member

    x, y = 0, 0

  

    self.draw_actor_name(@member, x + 100, y)

    self.draw_actor_class(@member, x + 100, y + WLH)

    self.draw_actor_level(@member, x + 103, y + WLH*2)

    case @mode

    when 0

      self.draw_actor_face(@member, x, y, 96) #****

      self.draw_actor_hp(@member, x, y + WLH*3, 160)

      self.draw_actor_mp(@member, x, y + WLH*4, 160)

      self.draw_actor_parameter(@member, x, y + WLH*5, 0)

      self.draw_actor_parameter(@member, x, y + WLH*6, 1)

      self.draw_actor_parameter(@member, x, y + WLH*7, 2)

      self.draw_actor_parameter(@member, x, y + WLH*8, 3)

    when 1

      self.draw_actor_face(@member, x, y, 96) #****

      for i in [email protected]

        item = @member.equips

        self.draw_item_name(item, x, y + WLH*(3+i), true, self.contents.width - 24)

      end

    end

  end

end



class Window_CurrentParty < Window_Selectable

  def initialize

    super(48, 80, 256, 64)

    @item_max = 4

    @column_max = @item_max

    create_contents

    self.index = 0

    refresh

  end

  def member

    return $game_party.members[self.index]

  end

  def refresh

    for i in 0...@item_max

      rect = item_rect(i)

      self.contents.clear_rect(rect)

    end

    for i in 0...$game_party.members.size

      rect = item_rect(i)

      bitmap = Cache.character($game_party.members.character_name)

      sign = $game_party.members.character_name[/^[\!\$]./]

      if sign != nil and sign.include?('$')

        cw = bitmap.width / 3

        ch = bitmap.height / 4

      else

        cw = bitmap.width / 12

        ch = bitmap.height / 8

      end

      n = $game_party.members.character_index

      src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)

      if $game_party.members.actor.unavailable

        self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)

      else

        self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)

      end

      if $game_party.members.actor.required

        lock_bitmap = Cache.system("Locked")

        self.contents.blt(rect.x + rect.width - lock_bitmap.width,

                          rect.y + rect.height - lock_bitmap.height,

                          lock_bitmap, lock_bitmap.rect)

      end

    end

  end

  def item_rect(index)

    rect = Rect.new(0, 0, 0, 0)

    rect.width = (contents.width + @spacing) / @column_max - @spacing

    rect.height = 32

    rect.x = index % @column_max * (rect.width + @spacing)

    rect.y = index / @column_max * 32

    return rect

  end

end



class Window_SelectMember < Window_Selectable

  def initialize

    super(48, 144, 256, 192)

    calculate_actors

    @item_max = @actors.size + 1

    @column_max = 4

    self.index = -1

    self.active = false

    refresh

  end

  def calculate_actors

    @actors = []

    for a in $game_actors.data

      @actors << a if a != nil and a.actor.found and !$game_party.members.include?(a)

    end

  end

  def member

    return @actors[self.index]

  end

  def refresh

    self.contents.clear

    calculate_actors

    @item_max = @actors.size + 1

    for i in [email protected]

      rect = item_rect(i)

      bitmap = Cache.character(@actors.character_name)

      sign = @actors.character_name[/^[\!\$]./]

      if sign != nil and sign.include?('$')

        cw = bitmap.width / 3

        ch = bitmap.height / 4

      else

        cw = bitmap.width / 12

        ch = bitmap.height / 8

      end

      n = @actors.character_index

      src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)

      if @actors.actor.unavailable

        self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)

      else

        self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)

      end

      if @actors.actor.required

        lock_bitmap = Cache.system("Locked")

        self.contents.blt(rect.x + rect.width - lock_bitmap.width,

                          rect.y + rect.height - lock_bitmap.height,

                          lock_bitmap, lock_bitmap.rect)

      end

    end

  end

  def item_rect(index)

    rect = Rect.new(0, 0, 0, 0)

    rect.width = (contents.width + @spacing) / @column_max - @spacing

    rect.height = 32

    rect.x = index % @column_max * (rect.width + @spacing)

    rect.y = index / @column_max * 32

    return rect

  end

end
我个人建议,这个比较好,至少我喜欢用这个
作者: 反斗奇彬    时间: 2010-10-20 17:42
回复 巧克力猫咪 的帖子


    貌似命令不行,我也知道ls推荐的那个脚本,现在问题是我使用了装备扩展脚本会与人物仓库脚本冲突,其中ls推荐的那个脚本更是冲突地厉害,实在没办法才换的,不过找了几个都不行,ls能推荐一个不?
作者: 巧克力猫咪    时间: 2010-10-20 18:12
本帖最后由 巧克力猫咪 于 2010-10-20 18:16 编辑

Project1.rar (251.41 KB, 下载次数: 42) 就这2个脚本的话貌似行的啊,是不是还加了别的脚本 KGC.rar (259.29 KB, 下载次数: 37) 这个是KGC的队伍脚本,也没冲突
作者: 反斗奇彬    时间: 2010-10-20 18:19
本帖最后由 反斗奇彬 于 2010-10-20 18:21 编辑

回复 巧克力猫咪 的帖子
我起初也是这样想的,不过我测试过新建一个工程,只添加这两个脚本,发现还是不行,它提示Game_Actor的443出错,顺便说一句吧,你提供的工程我下载试了一下,发现而是错误退出,我晕

   

未命名.jpg (12.44 KB, 下载次数: 25)

未命名.jpg

作者: 巧克力猫咪    时间: 2010-10-20 18:23
我倒,真的假的,我是新建个工程,然后把这2个放上去,发现没错才发的啊,还有错误不是我的问题吧,你出现的是哪的错误啊,晕死了
作者: 反斗奇彬    时间: 2010-10-20 18:37
回复 巧克力猫咪 的帖子

不好意思,可能是我操作上有问题吧,这次测试你给的工程可以了,不过我新建工程,把你的脚本复制过去后,发现又报错了,可能是我的软件有问题
   
作者: DeathKing    时间: 2010-10-22 12:34
回复 反斗奇彬 的帖子

如果我没记错的话。。。同这个一起发布的还有范例。。。
   




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1