Project1

标题: 自己把一个队员仓库脚本稍稍改了下~~ [打印本页]

作者: xokboy    时间: 2008-6-22 01:35
标题: 自己把一个队员仓库脚本稍稍改了下~~
可以发这种贴吧,如果违规了删就是了~~
以前在论坛里找到的一个脚本,地址我已经忘了,今天翻出来改了下,希望用得着这个功能的朋友可以试下,目前我测试不出什么问题,因为脚本是英文的我看不懂,大概就是这种效果:





这个脚本不起其他同类的脚本要简陋的多,队伍人数仍然限制为4人,而且也无法在战斗中更换队员,但这种简单脚本我想也会有朋友需要吧~~

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                    
(该命令使所有队员进入仓库等待招募,在队伍 中的队员不受影响)   

由于脚本的缺陷及技术不足,角色名和职业名尽量控制在3个字或3个字以下,不然会出现被遮住而无法显示的画面


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

  2. module RPG
  3.   class Actor
  4.     def setup
  5.       @found = false
  6.       @unavailable = false
  7.       @required = false
  8.     end
  9.     attr_accessor :found
  10.     attr_accessor :unavailable
  11.     attr_accessor :required
  12.   end
  13. end

  14. class Game_Actors
  15.   attr_reader :data
  16.   alias prex_party_g_actors_initialize initialize
  17.   def initialize
  18.     prex_party_g_actors_initialize
  19.     $data_actors.each do |actor|
  20.       actor.setup if actor
  21.       @data[actor.id] = Game_Actor.new(actor.id) if actor
  22.     end
  23.   end
  24. end

  25. class Scene_File < Scene_Base
  26.   alias prex_party_s_file_write_save_data write_save_data
  27.   alias prex_party_s_file_read_save_data read_save_data
  28.   def write_save_data(file)
  29.     prex_party_s_file_write_save_data(file)
  30.     Marshal.dump($data_actors, file)
  31.   end
  32.   def read_save_data(file)
  33.     prex_party_s_file_read_save_data(file)
  34.     $data_actors = Marshal.load(file)
  35.   end
  36. end

  37. class Scene_Title < Scene_Base
  38.   alias prex_party_s_title_command_new_game command_new_game
  39.   def command_new_game
  40.     prex_party_s_title_command_new_game
  41.     $game_party.members.each {|s| s.actor.found = true if s}
  42.   end
  43. end

  44. class Window_Base < Window
  45.   def draw_item_name(item, x, y, enabled = true, width = 172)
  46.     if item != nil
  47.       draw_icon(item.icon_index, x, y, enabled)
  48.       self.contents.font.color = normal_color
  49.       self.contents.font.color.alpha = enabled ? 255 : 128
  50.       self.contents.draw_text(x + 24, y, width, WLH, item.name)
  51.     end
  52.   end
  53. end

  54. class Scene_Party < Scene_Base
  55.   def start
  56.     super
  57.     create_menu_background
  58.     create_windows
  59.   end
  60.   def create_windows
  61.     @member_window = Window_CurrentMember.new
  62.     @party_window = Window_CurrentParty.new
  63.     @party_window.active = true
  64.     @selectable_window = Window_SelectMember.new
  65.   end
  66.   def update_windows
  67.     @member_window.update
  68.     @party_window.update
  69.     @selectable_window.update
  70.     if @party_window.active
  71.       @member_window.set_member(@party_window.member)
  72.     elsif @selectable_window.active
  73.       @member_window.set_member(@selectable_window.member)
  74.     end
  75.   end
  76.   def terminate
  77.     super
  78.     @member_window.dispose
  79.     @party_window.dispose
  80.     @selectable_window.dispose
  81.   end
  82.   def update
  83.     super
  84.     update_windows
  85.     update_input
  86.   end
  87.   def update_input
  88.     if Input.trigger?(Input::A)
  89.       if @member_window.mode == 1
  90.         @member_window.set_mode(0)
  91.       elsif @member_window.mode == 0
  92.         @member_window.set_mode(1)
  93.       end
  94.     end
  95.     if @party_window.active
  96.       if Input.trigger?(Input::B)
  97.         Sound.play_cancel
  98.         $scene = Scene_Map.new
  99.       elsif Input.trigger?(Input::C)
  100.         member = @party_window.member
  101.         if member != nil
  102.           if member.actor.unavailable or member.actor.required
  103.             Sound.play_buzzer
  104.             return
  105.           end
  106.         end
  107.         Sound.play_decision
  108.         @party_window.active = false
  109.         @selectable_window.active = true
  110.         @selectable_window.index = 0
  111.       end
  112.     elsif @selectable_window.active
  113.       if Input.trigger?(Input::B)
  114.         Sound.play_cancel
  115.         @selectable_window.index = -1
  116.         @selectable_window.active = false
  117.         @party_window.active = true
  118.       elsif Input.trigger?(Input::C)
  119.         member = @selectable_window.member
  120.         if member != nil
  121.           if member.actor.unavailable
  122.             Sound.play_buzzer
  123.             return
  124.           end
  125.         end
  126.         Sound.play_decision
  127.         $game_party.remove_actor(@party_window.member.id) if @party_window.member != nil
  128.         $game_party.add_actor(@selectable_window.member.id) if @selectable_window.member != nil
  129.         @selectable_window.refresh
  130.         @party_window.refresh
  131.         @selectable_window.index = -1
  132.         @selectable_window.active = false
  133.         @party_window.active = true
  134.       end
  135.     end
  136.   end
  137. end

  138. class Window_CurrentMember < Window_Base
  139.   attr_reader :mode
  140.   def initialize(member = nil, mode = 0)
  141.     super(304, 80, 192, 256)
  142.     create_contents
  143.     @member = member
  144.     @mode = 0
  145.     refresh
  146.   end
  147.   def member
  148.     return @member
  149.   end
  150.   def set_member(member)
  151.     old_member = @member
  152.     @member = member
  153.     refresh if old_member != @member
  154.   end
  155.   def set_mode(mode)
  156.     @mode = mode if [0, 1].include?(mode)
  157.     refresh
  158.   end
  159.   def refresh
  160.     self.contents.clear
  161.     return unless @member
  162.     x, y = 0, 0
  163.   
  164.     self.draw_actor_name(@member, x + 100, y)
  165.     self.draw_actor_class(@member, x + 100, y + WLH)
  166.     self.draw_actor_level(@member, x + 103, y + WLH*2)
  167.     case @mode
  168.     when 0
  169.       self.draw_actor_face(@member, x, y, 96) #****
  170.       self.draw_actor_hp(@member, x, y + WLH*3, 160)
  171.       self.draw_actor_mp(@member, x, y + WLH*4, 160)
  172.       self.draw_actor_parameter(@member, x, y + WLH*5, 0)
  173.       self.draw_actor_parameter(@member, x, y + WLH*6, 1)
  174.       self.draw_actor_parameter(@member, x, y + WLH*7, 2)
  175.       self.draw_actor_parameter(@member, x, y + WLH*8, 3)
  176.     when 1
  177.       self.draw_actor_face(@member, x, y, 96) #****
  178.       for i in [email protected]
  179.         item = @member.equips[i]
  180.         self.draw_item_name(item, x, y + WLH*(3+i), true, self.contents.width - 24)
  181.       end
  182.     end
  183.   end
  184. end

  185. class Window_CurrentParty < Window_Selectable
  186.   def initialize
  187.     super(48, 80, 256, 64)
  188.     @item_max = 4
  189.     @column_max = @item_max
  190.     create_contents
  191.     self.index = 0
  192.     refresh
  193.   end
  194.   def member
  195.     return $game_party.members[self.index]
  196.   end
  197.   def refresh
  198.     for i in 0...@item_max
  199.       rect = item_rect(i)
  200.       self.contents.clear_rect(rect)
  201.     end
  202.     for i in 0...$game_party.members.size
  203.       rect = item_rect(i)
  204.       bitmap = Cache.character($game_party.members[i].character_name)
  205.       sign = $game_party.members[i].character_name[/^[\!\$]./]
  206.       if sign != nil and sign.include?('$')
  207.         cw = bitmap.width / 3
  208.         ch = bitmap.height / 4
  209.       else
  210.         cw = bitmap.width / 12
  211.         ch = bitmap.height / 8
  212.       end
  213.       n = $game_party.members[i].character_index
  214.       src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  215.       if $game_party.members[i].actor.unavailable
  216.         self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
  217.       else
  218.         self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
  219.       end
  220.       if $game_party.members[i].actor.required
  221.         lock_bitmap = Cache.system("Locked")
  222.         self.contents.blt(rect.x + rect.width - lock_bitmap.width,
  223.                           rect.y + rect.height - lock_bitmap.height,
  224.                           lock_bitmap, lock_bitmap.rect)
  225.       end
  226.     end
  227.   end
  228.   def item_rect(index)
  229.     rect = Rect.new(0, 0, 0, 0)
  230.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  231.     rect.height = 32
  232.     rect.x = index % @column_max * (rect.width + @spacing)
  233.     rect.y = index / @column_max * 32
  234.     return rect
  235.   end
  236. end

  237. class Window_SelectMember < Window_Selectable
  238.   def initialize
  239.     super(48, 144, 256, 192)
  240.     calculate_actors
  241.     @item_max = @actors.size + 1
  242.     @column_max = 4
  243.     self.index = -1
  244.     self.active = false
  245.     refresh
  246.   end
  247.   def calculate_actors
  248.     @actors = []
  249.     for a in $game_actors.data
  250.       @actors << a if a != nil and a.actor.found and !$game_party.members.include?(a)
  251.     end
  252.   end
  253.   def member
  254.     return @actors[self.index]
  255.   end
  256.   def refresh
  257.     self.contents.clear
  258.     calculate_actors
  259.     @item_max = @actors.size + 1
  260.     for i in [email protected]
  261.       rect = item_rect(i)
  262.       bitmap = Cache.character(@actors[i].character_name)
  263.       sign = @actors[i].character_name[/^[\!\$]./]
  264.       if sign != nil and sign.include?('$')
  265.         cw = bitmap.width / 3
  266.         ch = bitmap.height / 4
  267.       else
  268.         cw = bitmap.width / 12
  269.         ch = bitmap.height / 8
  270.       end
  271.       n = @actors[i].character_index
  272.       src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  273.       if @actors[i].actor.unavailable
  274.         self.contents.blt(rect.x, rect.y, bitmap, src_rect, 128)
  275.       else
  276.         self.contents.blt(rect.x, rect.y, bitmap, src_rect, 255)
  277.       end
  278.       if @actors[i].actor.required
  279.         lock_bitmap = Cache.system("Locked")
  280.         self.contents.blt(rect.x + rect.width - lock_bitmap.width,
  281.                           rect.y + rect.height - lock_bitmap.height,
  282.                           lock_bitmap, lock_bitmap.rect)
  283.       end
  284.     end
  285.   end
  286.   def item_rect(index)
  287.     rect = Rect.new(0, 0, 0, 0)
  288.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  289.     rect.height = 32
  290.     rect.x = index % @column_max * (rect.width + @spacing)
  291.     rect.y = index / @column_max * 32
  292.     return rect
  293.   end
  294. end
复制代码

作者: zianyygy12    时间: 2008-9-9 10:33
顶一个·
刚好需要!




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