じ☆ve冰风 发表于 2024-4-19 23:25:09

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

想必不少人在使用人物仓库的时候都有一个疑惑……特别是玩家,部分游戏的人名难以让人记住,在人物仓库又不显示造型、属性什么的,这要怎么分啊?
所以这个玩野就出现了&…#==============================================================================# ■ chaochao的人物仓库ver1.02正式版# 修改了Game_Party# 功能:# 用来存放角色的仓库……# 召唤画面用$scene = Chaochao_Scene_Party.new# 其它使用说明在代码里已经备注。#------------------------------------------------------------------------------# 作者:chaochao#由逗比的菊花侠以及蛋疼的绝望二次编写#说明:半身像的图片名称为此角色的行走图名称加上_b,列如,阿尔西斯_b #另外,半身像是放在Graphics/picture 这个文件夹里的# http://zhuchao.go1.icpcn.com#==============================================================================$半身像坐标x = 500#暂时先这样了,根据你的图片大小自由调整吧$半身像坐标y = 260$行走图坐标x = 40$行走图坐标y = 112class Window_Base   def 描绘半身像(actor, x, y)    bitmap = RPG::Cache.picture(actor.character_name+"_b")    cw = bitmap.width   ch = bitmap.height   src_rect = Rect.new(0, 0, cw, ch)    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)endendclass Chaochao_Window_PartyLeft < Window_Selectabledef initialize    super(0, 0, 320, 224)    self.contents = Bitmap.new(width - 32, height - 32)    self.index = 0    #@actor = actor    refreshenddef actor    return @actorsenddef refresh    if self.contents != nil      self.contents.dispose      self.contents = nil    end    @actors = []    for i in 0...$game_party.actors.size      @actors.push($game_party.actors)    end      @item_max = 4    if @item_max > 0      self.contents = Bitmap.new(width - 32, (row_max+1) * 32)      for i in 0...@item_max      draw_item(i)      end    endenddef draw_item(index)    if @actors != nil      actor = @actors   # p index      text = @actors.name      lv = @actors.level.to_s + " "      if $game_party.chaochao.include?(actor.id) or $game_party.actors.sizeself.top_row + (self.page_row_max - 1)      self.top_row = row - (self.page_row_max - 1)    end    cursor_width = self.width / @column_max - 32    x = @index % @column_max * (cursor_width + 32)    y = @index / @column_max * 32 - self.oy + 32    self.cursor_rect.set(x, y, cursor_width, 32)enddef item_max    return @item_maxenddef actor?(index)    return @actors == nil ? false : trueenddef set_index(x)    @index = xendend#------------------------------------------------------------------------------class Chaochao_Window_PartyRight < Window_Selectabledef initialize    super(320, 0, 320, 224)    self.contents = Bitmap.new(width - 32, height - 32)    self.index = -1    refreshenddef actor    return @actorsenddef refresh    if self.contents != nil      self.contents.dispose      self.contents = nil    end    @actors = []    for i in 0...$game_party.actors2.size      @actors.push($game_party.actors2)    end      @item_max = $game_party.actors2.size    if @item_max > 0      self.contents = Bitmap.new(width - 32, row_max * 32)      for i in 0...@item_max      draw_item(i)      end    elsif @item_max == 0          endenddef draw_item(index)    actor = @actors    text = @actors.name    lv = @actors.level.to_s + " "    if $game_party.chaochao2.include?(actor.id) or $game_party.actors.size >= 4      self.contents.font.color = Color.new(255, 0, 0) #不能被移动的颜色      else      self.contents.font.color = Color.new(0, 255, 0) #可以被移动的颜色      end    self.contents.draw_text(4, index * 32, 288, 32, text)    self.contents.font.color = normal_color    self.contents.font.size = 16    self.contents.draw_text(4, index * 32 + 4, 288, 32,"Level:   ", 2)    colorx = .level,0].max    colory = .level,255].min    self.contents.font.color = Color.new(colorx, colory, 0)    self.contents.draw_text(4, index * 32 + 4, 288, 32,lv, 2)    self.contents.font.color = normal_color    self.contents.font.size = 22enddef update_cursor_rect    if @index < 0      self.cursor_rect.empty      return    end    row = @index / @column_max    if row < self.top_row      self.top_row = row    end    if row > self.top_row + (self.page_row_max - 1)      self.top_row = row - (self.page_row_max - 1)    end    cursor_width = self.width / @column_max - 32    x = @index % @column_max * (cursor_width + 32)    y = @index / @column_max * 32 - self.oy    self.cursor_rect.set(x, y, cursor_width, 32)enddef item_max    return @item_maxenddef actor?(index)    return @actors == nil ? false : trueenddef set_index(x)    @index = xendend#------------------------------------------------------------------------------class Chaochao_Window_PartyData < Window_Base    def initialize    super(0, 224, 640, 256)    self.contents = Bitmap.new(width - 32, height - 32)    @actor = nilend    def set_actor(actor)    self.contents.clear    draw_actor_name(actor, 4, 0)    #更新的地方    描绘半身像(actor, $半身像坐标x, $半身像坐标y)    draw_actor_graphic(actor, $行走图坐标x, $行走图坐标y)    draw_actor_state(actor, 140, 0)    draw_actor_hp(actor, 284, 0)    draw_actor_sp(actor, 460, 0)    @actor = actor    draw_actor_class(@actor, 20, 32)    b = 20    draw_actor_parameter(@actor, 70, 60, 0)    draw_actor_parameter(@actor, 70, 60+b, 1)    draw_actor_parameter(@actor, 70, 60+b+b, 2)    draw_actor_parameter(@actor, 70, 60+b+b+b, 3)    draw_actor_parameter(@actor, 70, 60+b+b+b+b, 4)    draw_actor_parameter(@actor, 70, 60+b+b+b+b+b, 5)    draw_actor_parameter(@actor, 70, 60+b+b+b+b+b+b, 6)    self.contents.font.color = system_color    self.contents.draw_text(280, 48, 80, 32, "EXP")    self.contents.draw_text(280, 80, 80, 32, "NEXT")    self.contents.font.color = normal_color    self.contents.draw_text(280+40, 48, 84, 32, @actor.exp_s, 2)    self.contents.draw_text(280+40, 80, 84, 32, @actor.next_rest_exp_s, 2)    self.visible = trueenddef clear    self.contents.clearendend#------------------------------------------------------------------------------class Game_Partyattr_reader   :actors2attr_reader   :chaochao#不能从队伍向备用角色移动的角色IDattr_reader   :chaochao2#不能从备用角色向队伍移动的角色IDdef initialize    @actors = []    @gold = 0    @steps = 0    @items = {}    @weapons = {}    @armors = {}    @actors2 = []    @chaochao = []    @chaochao2 = []enddef add_actor(actor_id,type=1)#type为1是向队伍中添加,为2则相反。    case type    when 1      if $game_actors != nil      actor = $game_actors      #如果队伍没有满和队伍中没有此角色      if @actors.size < 4 and not @actors.include?(actor) and not @actors2.include?(actor)          @actors.push(actor)          $game_player.refresh      end      end    when 2      if $game_actors != nil      actor = $game_actors      #如果角色不在队伍中和不在备用角色队伍中的情况下      #向备用角色中添加角色      if not @actors.include?(actor) and not @actors2.include?(actor)          @actors2.push(actor)          $game_player.refresh      end      end    endend    def huanren(index,type=1)#type为1是从备用角色向队伍中移动,为2则相反。    actor = $game_actors    case type    when 1      if @actors.size < 4 and @actors2.include?(actor) and not @chaochao2.include?(index) and not @actors.include?(actor)      @actors.push(actor)      @actors2.delete(actor)      $game_system.se_play($data_system.decision_se)      $game_player.refresh      end    when 2      if @actors.include?(actor) and not @chaochao.include?(index) and not @actors2.include?(actor)      @actors2.push(actor)      @actors.delete(actor)      $game_system.se_play($data_system.decision_se)      $game_player.refresh      end    endend    #type1,1是操作队伍中的角色能否向备用队伍移动,2则相反。#type2,1是添加不能移动的,2是删除不能移动的。def yidong(actor_id,type1,type2=1)    case type2    when 1      case type1      when 1      @chaochao.push(actor_id)      when 2      @chaochao2.push(actor_id)      end    when 2      case type1      when 1      @chaochao.delete(actor_id)      when 2      @chaochao2.delete(actor_id)      end    endend    #type,1从队伍中离开,2从备用角色中离开,3从队伍和备用角色中离开。def remove_actor(actor_id,type=1)    actor = $game_actors    case type    when 1      @actors.delete(actor)      $game_player.refresh    when 2      @actors2.delete(actor)      $game_player.refresh    when 3      @actors.delete(actor)      @actors2.delete(actor)      $game_player.refresh    endend def XXX(param)   for i in          if(param == i and param != 0)                   @actors2.hp = @actors2.maxhp       @actors2.sp = @actors2.maxsp       @actors2.states_clear                   break         end   if(param == 0)                  @actors2.hp = @actors2.maxhp       @actors2.sp = @actors2.maxsp       @actors2.states_clear         endendenddef refresh    new_actors = []    new_actors2 = []    for i in       if $data_actors[@actors.id] != nil      new_actors.push($game_actors[@actors.id])      end    end    @actors = new_actors    for i in       if $data_actors[@actors2.id] != nil      new_actors2.push($game_actors[@actors2.id])      end    end    @actors2 = new_actors2endend#------------------------------------------------------------------------------class Chaochao_Scene_Partydef main    @left_temp_command = 0    @right_temp_command = 0    @temp = 0    @left_window = Chaochao_Window_PartyLeft.new    @left_window.active = true    @right_window = Chaochao_Window_PartyRight.new    @right_window.active = false    @data_window = Chaochao_Window_PartyData.new    update_data    Graphics.transition    loop do      Graphics.update      Input.update      update      if $scene != self      break      end    end    Graphics.freeze    @left_window.dispose    @right_window.dispose    @data_window.disposeend    def update    @left_window.update    @right_window.update    @data_window.update    update_command    update_dataend    def update_command    if Input.trigger?(Input::B)      $game_system.se_play($data_system.cancel_se)      #画面切换      $scene = Scene_Map.new      return    end    if @left_window.active      update_left      return    end    if @right_window.active      update_right      return    endend    def update_left    if Input.trigger?(Input::RIGHT)      if @right_window.item_max > 0      @left_temp_command = @left_window.index      @left_window.set_index(-1)      $game_system.se_play($data_system.cursor_se)      @left_window.active = false      @right_window.active = true      @left_window.refresh      @right_window.refresh      @right_window.set_index(@right_temp_command)      return      else      $game_system.se_play($data_system.buzzer_se)      return      end    end    if Input.trigger?(Input::C)      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)      $game_party.huanren($game_party.actors[@left_window.index].id,2)#type为1是从备用角色向队伍中移动,为2则相反。      @left_window.refresh      @right_window.refresh      else      $game_system.se_play($data_system.buzzer_se)      end    end    returnend    def update_right    if Input.trigger?(Input::LEFT)      if @left_window.item_max > 0      @right_temp_command = @right_window.index      @right_window.set_index(-1)      $game_system.se_play($data_system.cursor_se)      @left_window.active = true      @right_window.active = false      @left_window.refresh      @right_window.refresh      @left_window.set_index(@left_temp_command)      return      else      $game_system.se_play($data_system.buzzer_se)      return      end    end    if Input.trigger?(Input::C)      if $game_party.actors.size >= 4      $game_system.se_play($data_system.buzzer_se)      return      end      if @right_window.active and @right_window.actor?(@right_window.index) and not $game_party.chaochao2.include?($game_party.actors2[@right_window.index].id)      $game_party.huanren($game_party.actors2[@right_window.index].id,1)#type为1是从备用角色向队伍中移动,为2则相反。      if $game_party.actors2.size == 0          @right_temp_command = @right_window.index          @right_window.set_index(-1)          $game_system.se_play($data_system.cursor_se)          @left_window.active = true          @right_window.active = false          @left_window.refresh          @right_window.refresh          @left_window.set_index(@left_temp_command)      end      if @right_window.index > 0          @right_window.set_index(@right_window.index-1)      end      @left_window.refresh      @right_window.refresh      else      $game_system.se_play($data_system.buzzer_se)      end    end    returnend    def update_data    if @left_window.active      if $game_party.actors[@left_window.index] != nil      @data_window.set_actor($game_party.actors[@left_window.index])      else      @data_window.clear      end      return    end    if @right_window.active      if $game_party.actors2[@right_window.index] != nil      @data_window.set_actor($game_party.actors2[@right_window.index])      else      @data_window.clear      end      return    endendend   复制代码
             本帖来自P1论坛作者菊花侠小赵,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=384923若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: 【二次创作】人物仓库-改——追加图像、属性