Project1

标题: 求个好看的仓库脚本 [打印本页]

作者: lion006    时间: 2010-8-24 22:08
标题: 求个好看的仓库脚本
如题,最好能加上图片的脚本。
作者: 迅雷進    时间: 2010-8-24 23:13
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ chaochao的人物仓库ver1.02正式版
  6. # 修改了Game_Party
  7. # 功能:
  8. # 用来存放角色的仓库……
  9. # 召唤画面用$scene = Chaochao_Scene_Party.new
  10. # 其它使用说明在代码里已经备注。
  11. #------------------------------------------------------------------------------
  12. # 作者:chaochao
  13. # http://zhuchao.go1.icpcn.com
  14. #==============================================================================
  15. class Chaochao_Window_PartyLeft < Window_Selectable
  16.   def initialize
  17.     super(0, 0, 320, 224)
  18.     self.contents = Bitmap.new(width - 32, height - 32)
  19.     self.index = 0
  20.     refresh
  21.   end
  22.   def actor
  23.     return @actors[self.index]
  24.   end
  25.   def refresh
  26.     if self.contents != nil
  27.       self.contents.dispose
  28.       self.contents = nil
  29.     end
  30.     @actors = []
  31.     for i in 0...$game_party.actors.size
  32.       @actors.push($game_party.actors[i])
  33.     end
  34.    
  35.     @item_max = 4
  36.     if @item_max > 0
  37.       self.contents = Bitmap.new(width - 32, (row_max+1) * 32)
  38.       for i in 0...@item_max
  39.         draw_item(i)
  40.       end
  41.     end
  42.   end
  43.   def draw_item(index)
  44.     if @actors[index] != nil
  45.       actor = @actors[index]
  46.       text = @actors[index].name
  47.       lv = @actors[index].level.to_s + " "
  48.       if $game_party.chaochao.include?(actor.id) or $game_party.actors.size <= 1
  49.         self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色
  50.       else
  51.         self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色
  52.       end
  53.       self.contents.draw_text(4, index * 32 + 32, 288, 32, text)
  54.       self.contents.font.color = normal_color
  55.       self.contents.font.size = 16
  56.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  "Level:   ", 2)
  57.       colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
  58.       colory = [255.0000 / 60 * @actors[index].level,255].min
  59.       self.contents.font.color = Color.new(colorx, colory, 0)
  60.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  lv, 2)
  61.       self.contents.font.color = normal_color
  62.       self.contents.font.size = 22
  63.     else
  64.       self.contents.draw_text(4, index * 32 + 32, 288, 32,  "(空的。)")
  65.     end
  66.   end
  67.   def update_cursor_rect
  68.     if @index < 0
  69.       self.cursor_rect.empty
  70.       return
  71.     end
  72.     row = @index / @column_max
  73.     if row < self.top_row
  74.       self.top_row = row
  75.     end
  76.     if row > self.top_row + (self.page_row_max - 1)
  77.       self.top_row = row - (self.page_row_max - 1)
  78.     end
  79.     cursor_width = self.width / @column_max - 32
  80.     x = @index % @column_max * (cursor_width + 32)
  81.     y = @index / @column_max * 32 - self.oy + 32
  82.     self.cursor_rect.set(x, y, cursor_width, 32)
  83.   end
  84.   def item_max
  85.     return @item_max
  86.   end
  87.   def actor?(index)
  88.     return @actors[index] == nil ? false : true
  89.   end
  90.   def set_index(x)
  91.     @index = x
  92.   end
  93. end

  94. #------------------------------------------------------------------------------

  95. class Chaochao_Window_PartyRight < Window_Selectable
  96.   def initialize
  97.     super(320, 0, 320, 224)
  98.     self.contents = Bitmap.new(width - 32, height - 32)
  99.     self.index = -1
  100.     refresh
  101.   end
  102.   def actor
  103.     return @actors[self.index]
  104.   end
  105.   def refresh
  106.     if self.contents != nil
  107.       self.contents.dispose
  108.       self.contents = nil
  109.     end
  110.     @actors = []
  111.     for i in 0...$game_party.actors2.size
  112.       @actors.push($game_party.actors2[i])
  113.     end
  114.    
  115.     @item_max = $game_party.actors2.size
  116.     if @item_max > 0
  117.       self.contents = Bitmap.new(width - 32, row_max * 32)
  118.       for i in 0...@item_max
  119.         draw_item(i)
  120.       end
  121.     elsif @item_max == 0
  122.       
  123.     end
  124.   end
  125.   def draw_item(index)
  126.     actor = @actors[index]
  127.     text = @actors[index].name
  128.     lv = @actors[index].level.to_s + " "
  129.     if $game_party.chaochao2.include?(actor.id) or $game_party.actors.size >= 4
  130.         self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色
  131.       else
  132.         self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色
  133.       end
  134.     self.contents.draw_text(4, index * 32, 288, 32, text)
  135.     self.contents.font.color = normal_color
  136.     self.contents.font.size = 16
  137.     self.contents.draw_text(4, index * 32 + 4, 288, 32,  "Level:   ", 2)
  138.     colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
  139.     colory = [255.0000 / 60 * @actors[index].level,255].min
  140.     self.contents.font.color = Color.new(colorx, colory, 0)
  141.     self.contents.draw_text(4, index * 32 + 4, 288, 32,  lv, 2)
  142.     self.contents.font.color = normal_color
  143.     self.contents.font.size = 22
  144.   end
  145.   def update_cursor_rect
  146.     if @index < 0
  147.       self.cursor_rect.empty
  148.       return
  149.     end
  150.     row = @index / @column_max
  151.     if row < self.top_row
  152.       self.top_row = row
  153.     end
  154.     if row > self.top_row + (self.page_row_max - 1)
  155.       self.top_row = row - (self.page_row_max - 1)
  156.     end
  157.     cursor_width = self.width / @column_max - 32
  158.     x = @index % @column_max * (cursor_width + 32)
  159.     y = @index / @column_max * 32 - self.oy
  160.     self.cursor_rect.set(x, y, cursor_width, 32)
  161.   end
  162.   def item_max
  163.     return @item_max
  164.   end
  165.   def actor?(index)
  166.     return @actors[index] == nil ? false : true
  167.   end
  168.   def set_index(x)
  169.     @index = x
  170.   end
  171. end

  172. #------------------------------------------------------------------------------

  173. class Chaochao_Window_PartyData < Window_Base
  174.   
  175.   def initialize
  176.     super(0, 224, 640, 256)
  177.     self.contents = Bitmap.new(width - 32, height - 32)
  178.     @actor = nil
  179.   end
  180.   
  181.   def set_actor(actor)
  182.     self.contents.clear
  183.     draw_actor_name(actor, 4, 0)
  184.     draw_actor_hp(actor, 284, 0)
  185.     draw_actor_sp(actor, 460, 0)
  186.     @actor = actor
  187.     draw_actor_graphic(@actor, 40, 112)
  188.     draw_actor_name(@actor, 4, 0)
  189.     draw_actor_class(@actor, 4 + 144, 0)
  190.     draw_actor_level(@actor, 96, 32)
  191.     draw_actor_state(@actor, 96, 64)
  192.     draw_actor_hp(@actor, 96, 112, 172)
  193.     draw_actor_sp(@actor, 96, 144, 172)
  194.     draw_actor_parameter(@actor, 96, 192, 0)
  195.     draw_actor_parameter(@actor, 96, 224, 1)
  196.     draw_actor_parameter(@actor, 96, 256, 2)
  197.     draw_actor_parameter(@actor, 96, 304, 3)
  198.     draw_actor_parameter(@actor, 96, 336, 4)
  199.     draw_actor_parameter(@actor, 96, 368, 5)
  200.     draw_actor_parameter(@actor, 96, 400, 6)
  201.     self.visible = true
  202.   end
  203.   def clear
  204.     self.contents.clear
  205.   end
  206. end

  207. #------------------------------------------------------------------------------

  208. class Game_Party
  209.   attr_reader   :actors2
  210.   attr_reader   :chaochao#不能从队伍向备用角色移动的角色ID
  211.   attr_reader   :chaochao2#不能从备用角色向队伍移动的角色ID
  212.   def initialize
  213.     @actors = []
  214.     @gold = 0
  215.     @steps = 0
  216.     @items = {}
  217.     @weapons = {}
  218.     @armors = {}
  219.     @actors2 = []
  220.     @chaochao = []
  221.     @chaochao2 = []
  222.   end
  223.   def add_actor(actor_id,type=1)#type为1是向队伍中添加,为2则相反。
  224.     case type
  225.     when 1
  226.       if $game_actors[actor_id] != nil
  227.         actor = $game_actors[actor_id]
  228.         #如果队伍没有满和队伍中没有此角色
  229.         if @actors.size < 4 and not @actors.include?(actor) and not @actors2.include?(actor)
  230.           @actors.push(actor)
  231.           $game_player.refresh
  232.         end
  233.       end
  234.     when 2
  235.       if $game_actors[actor_id] != nil
  236.         actor = $game_actors[actor_id]
  237.         #如果角色不在队伍中和不在备用角色队伍中的情况下
  238.         #向备用角色中添加角色
  239.         if not @actors.include?(actor) and not @actors2.include?(actor)
  240.           @actors2.push(actor)
  241.           $game_player.refresh
  242.         end
  243.       end
  244.     end
  245.   end
  246.   
  247.   def huanren(index,type=1)#type为1是从备用角色向队伍中移动,为2则相反。
  248.     actor = $game_actors[index]
  249.     case type
  250.     when 1
  251.       if @actors.size < 4 and @actors2.include?(actor) and not @chaochao2.include?(index) and not @actors.include?(actor)
  252.         @actors.push(actor)
  253.         @actors2.delete(actor)
  254.         $game_system.se_play($data_system.decision_se)
  255.         $game_player.refresh
  256.       end
  257.     when 2
  258.       if @actors.include?(actor) and not @chaochao.include?(index) and not @actors2.include?(actor)
  259.         @actors2.push(actor)
  260.         @actors.delete(actor)
  261.         $game_system.se_play($data_system.decision_se)
  262.         $game_player.refresh
  263.       end
  264.     end
  265.   end
  266.   
  267.   #type1,1是操作队伍中的角色能否向备用队伍移动,2则相反。
  268.   #type2,1是添加不能移动的,2是删除不能移动的。
  269.   def yidong(actor_id,type1,type2=1)
  270.     case type2
  271.     when 1
  272.       case type1
  273.       when 1
  274.         @chaochao.push(actor_id)
  275.       when 2
  276.         @chaochao2.push(actor_id)
  277.       end
  278.     when 2
  279.       case type1
  280.       when 1
  281.         @chaochao.delete(actor_id)
  282.       when 2
  283.         @chaochao2.delete(actor_id)
  284.       end
  285.     end
  286.   end
  287.   
  288.   #type,1从队伍中离开,2从备用角色中离开,3从队伍和备用角色中离开。
  289.   def remove_actor(actor_id,type=1)
  290.     actor = $game_actors[actor_id]
  291.     case type
  292.     when 1
  293.       @actors.delete(actor)
  294.       $game_player.refresh
  295.     when 2
  296.       @actors2.delete(actor)
  297.       $game_player.refresh
  298.     when 3
  299.       @actors.delete(actor)
  300.       @actors2.delete(actor)
  301.       $game_player.refresh
  302.     end
  303.   end
  304.   
  305.   def refresh
  306.     new_actors = []
  307.     new_actors2 = []
  308.     for i in [email protected]
  309.       if $data_actors[@actors[i].id] != nil
  310.         new_actors.push($game_actors[@actors[i].id])
  311.       end
  312.     end
  313.     @actors = new_actors
  314.     for i in [email protected]
  315.       if $data_actors[@actors2[i].id] != nil
  316.         new_actors2.push($game_actors[@actors2[i].id])
  317.       end
  318.     end
  319.     @actors2 = new_actors2
  320.   end
  321. end

  322. #------------------------------------------------------------------------------

  323. class Chaochao_Scene_Party
  324.   def main
  325.     @left_temp_command = 0
  326.     @right_temp_command = 0
  327.     @temp = 0
  328.     @left_window = Chaochao_Window_PartyLeft.new
  329.     @left_window.active = true
  330.     @right_window = Chaochao_Window_PartyRight.new
  331.     @right_window.active = false
  332.     @data_window = Chaochao_Window_PartyData.new
  333.     update_data
  334.     Graphics.transition
  335.     loop do
  336.       Graphics.update
  337.       Input.update
  338.       update
  339.       if $scene != self
  340.         break
  341.       end
  342.     end
  343.     Graphics.freeze
  344.     @left_window.dispose
  345.     @right_window.dispose
  346.     @data_window.dispose
  347.   end
  348.   
  349.   def update
  350.     @left_window.update
  351.     @right_window.update
  352.     @data_window.update
  353.     update_command
  354.     update_data
  355.   end
  356.   
  357.   def update_command
  358.     if Input.trigger?(Input::B)
  359.       $game_system.se_play($data_system.cancel_se)
  360.       #画面切换
  361.       $scene = Scene_Map.new
  362.       return
  363.     end
  364.     if @left_window.active
  365.       update_left
  366.       return
  367.     end
  368.     if @right_window.active
  369.       update_right
  370.       return
  371.     end
  372.   end
  373.   
  374.   def update_left
  375.     if Input.trigger?(Input::RIGHT)
  376.       if @right_window.item_max > 0
  377.         @left_temp_command = @left_window.index
  378.         @left_window.set_index(-1)
  379.         $game_system.se_play($data_system.cursor_se)
  380.         @left_window.active = false
  381.         @right_window.active = true
  382.         @left_window.refresh
  383.         @right_window.refresh
  384.         @right_window.set_index(@right_temp_command)
  385.         return
  386.       else
  387.         $game_system.se_play($data_system.buzzer_se)
  388.         return
  389.       end
  390.     end
  391.     if Input.trigger?(Input::C)
  392.       if @left_window.active and @left_window.actor?(@left_window.index) and $game_party.actors.size > 1 and not $game_party.chaochao.include?($game_party.actors[@left_window.index].id)
  393.         $game_party.huanren($game_party.actors[@left_window.index].id,2)#type为1是从备用角色向队伍中移动,为2则相反。
  394.         @left_window.refresh
  395.         @right_window.refresh
  396.       else
  397.         $game_system.se_play($data_system.buzzer_se)
  398.       end
  399.     end
  400.     return
  401.   end
  402.   
  403.   def update_right
  404.     if Input.trigger?(Input::LEFT)
  405.       if @left_window.item_max > 0
  406.         @right_temp_command = @right_window.index
  407.         @right_window.set_index(-1)
  408.         $game_system.se_play($data_system.cursor_se)
  409.         @left_window.active = true
  410.         @right_window.active = false
  411.         @left_window.refresh
  412.         @right_window.refresh
  413.         @left_window.set_index(@left_temp_command)
  414.         return
  415.       else
  416.         $game_system.se_play($data_system.buzzer_se)
  417.         return
  418.       end
  419.     end
  420.     if Input.trigger?(Input::C)
  421.       if $game_party.actors.size >= 4
  422.         $game_system.se_play($data_system.buzzer_se)
  423.         return
  424.       end
  425.       if @right_window.active and @right_window.actor?(@right_window.index) and not $game_party.chaochao2.include?($game_party.actors2[@right_window.index].id)
  426.         $game_party.huanren($game_party.actors2[@right_window.index].id,1)#type为1是从备用角色向队伍中移动,为2则相反。
  427.         if $game_party.actors2.size == 0
  428.           @right_temp_command = @right_window.index
  429.           @right_window.set_index(-1)
  430.           $game_system.se_play($data_system.cursor_se)
  431.           @left_window.active = true
  432.           @right_window.active = false
  433.           @left_window.refresh
  434.           @right_window.refresh
  435.           @left_window.set_index(@left_temp_command)
  436.         end
  437.         if @right_window.index > 0
  438.           @right_window.set_index(@right_window.index-1)
  439.         end
  440.         @left_window.refresh
  441.         @right_window.refresh
  442.       else
  443.         $game_system.se_play($data_system.buzzer_se)
  444.       end
  445.     end
  446.     return
  447.   end
  448.   
  449.   def update_data
  450.     if @left_window.active
  451.       if $game_party.actors[@left_window.index] != nil
  452.         @data_window.set_actor($game_party.actors[@left_window.index])
  453.       else
  454.         @data_window.clear
  455.       end
  456.       return
  457.     end
  458.     if @right_window.active
  459.       if $game_party.actors2[@right_window.index] != nil
  460.         @data_window.set_actor($game_party.actors2[@right_window.index])
  461.       else
  462.         @data_window.clear
  463.       end
  464.       return
  465.     end
  466.   end
  467. end

  468. #==============================================================================
  469. # ■ Interpreter (分割定义 4)
  470. #------------------------------------------------------------------------------
  471. #  执行事件命令的解释器。本类在 Game_System 类
  472. # 和 Game_Event 类的内部使用。
  473. #==============================================================================
  474. class Interpreter
  475.   #--------------------------------------------------------------------------
  476.   # ● 角色的替换
  477.   #--------------------------------------------------------------------------
  478.   def command_129
  479.     # 获取角色
  480.     actor = $game_actors[@parameters[0]]
  481.     # 角色有效的情况下
  482.     if actor != nil
  483.       # 操作分支
  484.       if @parameters[1] == 0
  485.         if @parameters[2] == 1
  486.           $game_actors[@parameters[0]].setup(@parameters[0])
  487.         end
  488.         if $game_party.actors.size == 4
  489.           $game_party.add_actor(@parameters[0],2)
  490.         else
  491.           $game_party.add_actor(@parameters[0])
  492.         end
  493.       else
  494.         $game_party.remove_actor(@parameters[0],3)
  495.       end
  496.     end
  497.     # 继续
  498.     return true
  499.   end
  500. end


  501. #==============================================================================
  502. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  503. #==============================================================================
复制代码

作者: lion006    时间: 2010-8-25 06:57
这个脚本会发生错误




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