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

Project1

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

[原创发布] 【二次创作】人物仓库-改——追加图像、属性

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
274 小时
注册时间
2014-2-22
帖子
335
跳转到指定楼层
1
发表于 2015-11-1 12:52:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
想必不少人在使用人物仓库的时候都有一个疑惑……特别是玩家,部分游戏的人名难以让人记住,在人物仓库又不显示造型、属性什么的,这要怎么分啊?
所以这个玩野就出现了&…
  1. #==============================================================================
  2. # ■ chaochao的人物仓库ver1.02正式版
  3. # 修改了Game_Party
  4. # 功能:
  5. # 用来存放角色的仓库……
  6. # 召唤画面用$scene = Chaochao_Scene_Party.new
  7. # 其它使用说明在代码里已经备注。
  8. #------------------------------------------------------------------------------
  9. # 作者:chaochao
  10. #由逗比的菊花侠以及蛋疼的绝望二次编写
  11. #说明:半身像的图片名称为此角色的行走图名称加上_b,列如,阿尔西斯_b
  12. #另外,半身像是放在Graphics/picture 这个文件夹里的
  13. # http://zhuchao.go1.icpcn.com
  14. #==============================================================================
  15. $半身像坐标x = 500#暂时先这样了,根据你的图片大小自由调整吧
  16. $半身像坐标y = 260
  17. $行走图坐标x = 40
  18. $行走图坐标y = 112
  19. class Window_Base
  20.    def 描绘半身像(actor, x, y)
  21.     bitmap = RPG::Cache.picture(actor.character_name+"_b")
  22.     cw = bitmap.width
  23.     ch = bitmap.height
  24.     src_rect = Rect.new(0, 0, cw, ch)
  25.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  26.   end
  27.   end
  28. class Chaochao_Window_PartyLeft < Window_Selectable
  29.   def initialize
  30.     super(0, 0, 320, 224)
  31.     self.contents = Bitmap.new(width - 32, height - 32)
  32.     self.index = 0
  33.     #@actor = actor
  34.     refresh
  35.   end
  36.   def actor
  37.     return @actors[self.index]
  38.   end
  39.   def refresh
  40.     if self.contents != nil
  41.       self.contents.dispose
  42.       self.contents = nil
  43.     end
  44.     @actors = []
  45.     for i in 0...$game_party.actors.size
  46.       @actors.push($game_party.actors[i])
  47.     end
  48.    
  49.     @item_max = 4
  50.     if @item_max > 0
  51.       self.contents = Bitmap.new(width - 32, (row_max+1) * 32)
  52.       for i in 0...@item_max
  53.         draw_item(i)
  54.       end
  55.     end
  56.   end
  57.   def draw_item(index)
  58.     if @actors[index] != nil
  59.       actor = @actors[index]
  60.      # p index
  61.       text = @actors[index].name
  62.       lv = @actors[index].level.to_s + " "
  63.       if $game_party.chaochao.include?(actor.id) or $game_party.actors.size <= 1
  64.         self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色
  65.       else
  66.         self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色
  67.       end
  68.       #--------
  69.       #--------
  70.       self.contents.draw_text(4, index * 32 + 32, 288, 32, text)
  71.       self.contents.font.color = normal_color
  72.       self.contents.font.size = 16
  73.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  "Level:   ", 2)
  74.       colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
  75.       colory = [255.0000 / 60 * @actors[index].level,255].min
  76.       self.contents.font.color = Color.new(colorx, colory, 0)
  77.       self.contents.draw_text(4, index * 32 + 36, 288, 32,  lv, 2)
  78.       self.contents.font.color = normal_color
  79.       self.contents.font.size = 22
  80.     else
  81.       self.contents.draw_text(4, index * 32 + 32, 288, 32,  "米有人物!")
  82.     end
  83.   end
  84.   def update_cursor_rect
  85.     if @index < 0
  86.       self.cursor_rect.empty
  87.       return
  88.     end
  89.     row = @index / @column_max
  90.     if row < self.top_row
  91.       self.top_row = row
  92.     end
  93.     if row > self.top_row + (self.page_row_max - 1)
  94.       self.top_row = row - (self.page_row_max - 1)
  95.     end
  96.     cursor_width = self.width / @column_max - 32
  97.     x = @index % @column_max * (cursor_width + 32)
  98.     y = @index / @column_max * 32 - self.oy + 32
  99.     self.cursor_rect.set(x, y, cursor_width, 32)
  100.   end
  101.   def item_max
  102.     return @item_max
  103.   end
  104.   def actor?(index)
  105.     return @actors[index] == nil ? false : true
  106.   end
  107.   def set_index(x)
  108.     @index = x
  109.   end
  110. end

  111. #------------------------------------------------------------------------------

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

  189. #------------------------------------------------------------------------------

  190. class Chaochao_Window_PartyData < Window_Base
  191.   
  192.   def initialize
  193.     super(0, 224, 640, 256)
  194.     self.contents = Bitmap.new(width - 32, height - 32)
  195.     @actor = nil
  196.   end
  197.   
  198.   def set_actor(actor)
  199.     self.contents.clear
  200.     draw_actor_name(actor, 4, 0)
  201.     #更新的地方
  202.     描绘半身像(actor, $半身像坐标x, $半身像坐标y)
  203.     draw_actor_graphic(actor, $行走图坐标x, $行走图坐标y)
  204.     draw_actor_state(actor, 140, 0)
  205.     draw_actor_hp(actor, 284, 0)
  206.     draw_actor_sp(actor, 460, 0)
  207.     @actor = actor
  208.     draw_actor_class(@actor, 20, 32)
  209.     b = 20
  210.     draw_actor_parameter(@actor, 70, 60, 0)
  211.     draw_actor_parameter(@actor, 70, 60+b, 1)
  212.     draw_actor_parameter(@actor, 70, 60+b+b, 2)
  213.     draw_actor_parameter(@actor, 70, 60+b+b+b, 3)
  214.     draw_actor_parameter(@actor, 70, 60+b+b+b+b, 4)
  215.     draw_actor_parameter(@actor, 70, 60+b+b+b+b+b, 5)
  216.     draw_actor_parameter(@actor, 70, 60+b+b+b+b+b+b, 6)
  217.     self.contents.font.color = system_color
  218.     self.contents.draw_text(280, 48, 80, 32, "EXP")
  219.     self.contents.draw_text(280, 80, 80, 32, "NEXT")
  220.     self.contents.font.color = normal_color
  221.     self.contents.draw_text(280+40, 48, 84, 32, @actor.exp_s, 2)
  222.     self.contents.draw_text(280+40, 80, 84, 32, @actor.next_rest_exp_s, 2)
  223.     self.visible = true
  224.   end
  225.   def clear
  226.     self.contents.clear
  227.   end
  228. end

  229. #------------------------------------------------------------------------------

  230. class Game_Party
  231.   attr_reader   :actors2
  232.   attr_reader   :chaochao#不能从队伍向备用角色移动的角色ID
  233.   attr_reader   :chaochao2#不能从备用角色向队伍移动的角色ID
  234.   def initialize
  235.     @actors = []
  236.     @gold = 0
  237.     @steps = 0
  238.     @items = {}
  239.     @weapons = {}
  240.     @armors = {}
  241.     @actors2 = []
  242.     @chaochao = []
  243.     @chaochao2 = []
  244.   end
  245.   def add_actor(actor_id,type=1)#type为1是向队伍中添加,为2则相反。
  246.     case type
  247.     when 1
  248.       if $game_actors[actor_id] != nil
  249.         actor = $game_actors[actor_id]
  250.         #如果队伍没有满和队伍中没有此角色
  251.         if @actors.size < 4 and not @actors.include?(actor) and not @actors2.include?(actor)
  252.           @actors.push(actor)
  253.           $game_player.refresh
  254.         end
  255.       end
  256.     when 2
  257.       if $game_actors[actor_id] != nil
  258.         actor = $game_actors[actor_id]
  259.         #如果角色不在队伍中和不在备用角色队伍中的情况下
  260.         #向备用角色中添加角色
  261.         if not @actors.include?(actor) and not @actors2.include?(actor)
  262.           @actors2.push(actor)
  263.           $game_player.refresh
  264.         end
  265.       end
  266.     end
  267.   end
  268.   
  269.   def huanren(index,type=1)#type为1是从备用角色向队伍中移动,为2则相反。
  270.     actor = $game_actors[index]
  271.     case type
  272.     when 1
  273.       if @actors.size < 4 and @actors2.include?(actor) and not @chaochao2.include?(index) and not @actors.include?(actor)
  274.         @actors.push(actor)
  275.         @actors2.delete(actor)
  276.         $game_system.se_play($data_system.decision_se)
  277.         $game_player.refresh
  278.       end
  279.     when 2
  280.       if @actors.include?(actor) and not @chaochao.include?(index) and not @actors2.include?(actor)
  281.         @actors2.push(actor)
  282.         @actors.delete(actor)
  283.         $game_system.se_play($data_system.decision_se)
  284.         $game_player.refresh
  285.       end
  286.     end
  287.   end
  288.   
  289.   #type1,1是操作队伍中的角色能否向备用队伍移动,2则相反。
  290.   #type2,1是添加不能移动的,2是删除不能移动的。
  291.   def yidong(actor_id,type1,type2=1)
  292.     case type2
  293.     when 1
  294.       case type1
  295.       when 1
  296.         @chaochao.push(actor_id)
  297.       when 2
  298.         @chaochao2.push(actor_id)
  299.       end
  300.     when 2
  301.       case type1
  302.       when 1
  303.         @chaochao.delete(actor_id)
  304.       when 2
  305.         @chaochao2.delete(actor_id)
  306.       end
  307.     end
  308.   end
  309.   
  310.   #type,1从队伍中离开,2从备用角色中离开,3从队伍和备用角色中离开。
  311.   def remove_actor(actor_id,type=1)
  312.     actor = $game_actors[actor_id]
  313.     case type
  314.     when 1
  315.       @actors.delete(actor)
  316.       $game_player.refresh
  317.     when 2
  318.       @actors2.delete(actor)
  319.       $game_player.refresh
  320.     when 3
  321.       @actors.delete(actor)
  322.       @actors2.delete(actor)
  323.       $game_player.refresh
  324.     end
  325.   end
  326. def XXX(param)
  327.    for i in [email protected]
  328.            if(param == i and param != 0)
  329.                    @actors2[i].hp = @actors2[i].maxhp
  330.        @actors2[i].sp = @actors2[i].maxsp
  331.        @actors2[i].states_clear
  332.                    break
  333.            end
  334.      if(param == 0)
  335.                     @actors2[i].hp = @actors2[i].maxhp
  336.        @actors2[i].sp = @actors2[i].maxsp
  337.        @actors2[i].states_clear
  338.            end
  339.   end
  340. end
  341.   def refresh
  342.     new_actors = []
  343.     new_actors2 = []
  344.     for i in [email protected]
  345.       if $data_actors[@actors[i].id] != nil
  346.         new_actors.push($game_actors[@actors[i].id])
  347.       end
  348.     end
  349.     @actors = new_actors
  350.     for i in [email protected]
  351.       if $data_actors[@actors2[i].id] != nil
  352.         new_actors2.push($game_actors[@actors2[i].id])
  353.       end
  354.     end
  355.     @actors2 = new_actors2
  356.   end
  357. end

  358. #------------------------------------------------------------------------------

  359. class Chaochao_Scene_Party
  360.   def main
  361.     @left_temp_command = 0
  362.     @right_temp_command = 0
  363.     @temp = 0
  364.     @left_window = Chaochao_Window_PartyLeft.new
  365.     @left_window.active = true
  366.     @right_window = Chaochao_Window_PartyRight.new
  367.     @right_window.active = false
  368.     @data_window = Chaochao_Window_PartyData.new
  369.     update_data
  370.     Graphics.transition
  371.     loop do
  372.       Graphics.update
  373.       Input.update
  374.       update
  375.       if $scene != self
  376.         break
  377.       end
  378.     end
  379.     Graphics.freeze
  380.     @left_window.dispose
  381.     @right_window.dispose
  382.     @data_window.dispose
  383.   end
  384.   
  385.   def update
  386.     @left_window.update
  387.     @right_window.update
  388.     @data_window.update
  389.     update_command
  390.     update_data
  391.   end
  392.   
  393.   def update_command
  394.     if Input.trigger?(Input::B)
  395.       $game_system.se_play($data_system.cancel_se)
  396.       #画面切换
  397.       $scene = Scene_Map.new
  398.       return
  399.     end
  400.     if @left_window.active
  401.       update_left
  402.       return
  403.     end
  404.     if @right_window.active
  405.       update_right
  406.       return
  407.     end
  408.   end
  409.   
  410.   def update_left
  411.     if Input.trigger?(Input::RIGHT)
  412.       if @right_window.item_max > 0
  413.         @left_temp_command = @left_window.index
  414.         @left_window.set_index(-1)
  415.         $game_system.se_play($data_system.cursor_se)
  416.         @left_window.active = false
  417.         @right_window.active = true
  418.         @left_window.refresh
  419.         @right_window.refresh
  420.         @right_window.set_index(@right_temp_command)
  421.         return
  422.       else
  423.         $game_system.se_play($data_system.buzzer_se)
  424.         return
  425.       end
  426.     end
  427.     if Input.trigger?(Input::C)
  428.       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)
  429.         $game_party.huanren($game_party.actors[@left_window.index].id,2)#type为1是从备用角色向队伍中移动,为2则相反。
  430.         @left_window.refresh
  431.         @right_window.refresh
  432.       else
  433.         $game_system.se_play($data_system.buzzer_se)
  434.       end
  435.     end
  436.     return
  437.   end
  438.   
  439.   def update_right
  440.     if Input.trigger?(Input::LEFT)
  441.       if @left_window.item_max > 0
  442.         @right_temp_command = @right_window.index
  443.         @right_window.set_index(-1)
  444.         $game_system.se_play($data_system.cursor_se)
  445.         @left_window.active = true
  446.         @right_window.active = false
  447.         @left_window.refresh
  448.         @right_window.refresh
  449.         @left_window.set_index(@left_temp_command)
  450.         return
  451.       else
  452.         $game_system.se_play($data_system.buzzer_se)
  453.         return
  454.       end
  455.     end
  456.     if Input.trigger?(Input::C)
  457.       if $game_party.actors.size >= 4
  458.         $game_system.se_play($data_system.buzzer_se)
  459.         return
  460.       end
  461.       if @right_window.active and @right_window.actor?(@right_window.index) and not $game_party.chaochao2.include?($game_party.actors2[@right_window.index].id)
  462.         $game_party.huanren($game_party.actors2[@right_window.index].id,1)#type为1是从备用角色向队伍中移动,为2则相反。
  463.         if $game_party.actors2.size == 0
  464.           @right_temp_command = @right_window.index
  465.           @right_window.set_index(-1)
  466.           $game_system.se_play($data_system.cursor_se)
  467.           @left_window.active = true
  468.           @right_window.active = false
  469.           @left_window.refresh
  470.           @right_window.refresh
  471.           @left_window.set_index(@left_temp_command)
  472.         end
  473.         if @right_window.index > 0
  474.           @right_window.set_index(@right_window.index-1)
  475.         end
  476.         @left_window.refresh
  477.         @right_window.refresh
  478.       else
  479.         $game_system.se_play($data_system.buzzer_se)
  480.       end
  481.     end
  482.     return
  483.   end
  484.   
  485.   def update_data
  486.     if @left_window.active
  487.       if $game_party.actors[@left_window.index] != nil
  488.         @data_window.set_actor($game_party.actors[@left_window.index])
  489.       else
  490.         @data_window.clear
  491.       end
  492.       return
  493.     end
  494.     if @right_window.active
  495.       if $game_party.actors2[@right_window.index] != nil
  496.         @data_window.set_actor($game_party.actors2[@right_window.index])
  497.       else
  498.         @data_window.clear
  499.       end
  500.       return
  501.     end
  502.   end
  503. end
  504.    
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
138 小时
注册时间
2015-6-9
帖子
30
2
发表于 2015-11-4 15:32:59 手机端发表。 | 只看该作者
大神,有图么?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
42 小时
注册时间
2012-11-27
帖子
1
3
发表于 2015-11-5 22:02:44 | 只看该作者
大神,可以给个范例么?我引用了下,提示 method “name”错误
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 01:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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