查看: 4129|回复: 13

[已经解决] 这个人物仓库怎么设置一个角色不能放入仓库

[复制链接]
梦石
0
星屑
55
在线时间
135 小时
注册时间
2013-8-7
回帖
70
发表于 2013-10-5 16:14:21 | 显示全部楼层 |阅读模式

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

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

×
[pre lang="ruby" line="1"]#==============================================================================
# ■ chaochao的人物仓库ver1.02正式版
# 修改了Game_Party
# 功能:
# 用来存放角色的仓库……
# 召唤画面用$scene = Chaochao_Scene_Party.new
# 其它使用说明在代码里已经备注。
#------------------------------------------------------------------------------
# 作者:chaochao
# http://zhuchao.go1.icpcn.com
#==============================================================================
class Chaochao_Window_PartyLeft < Window_Selectable
  def initialize
    super(0, 0, 320, 224)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = 0
    refresh
  end
  def actor
    return @actors[self.index]
  end
  def 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
    end
  end
  def draw_item(index)
    if @actors[index] != nil
      actor = @actors[index]
      text = @actors[index].name
      lv = @actors[index].level.to_s + " "
      if $game_party.chaochao.include?(actor.id) or $game_party.actors.size <= 1
        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 + 32, 288, 32, text)
      self.contents.font.color = normal_color
      self.contents.font.size = 16
      self.contents.draw_text(4, index * 32 + 36, 288, 32,  "Level:   ", 2)
      colorx = [255.0000 - 255.0000/60 * @actors[index].level,0].max
      colory = [255.0000 / 60 * @actors[index].level,255].min
      self.contents.font.color = Color.new(colorx, colory, 0)
      self.contents.draw_text(4, index * 32 + 36, 288, 32,  lv, 2)
      self.contents.font.color = normal_color
      self.contents.font.size = 22
    else
      self.contents.draw_text(4, index * 32 + 32, 288, 32,  "没有人物!")
    end
  end
  def 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 + 32
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
  def item_max
    return @item_max
  end
  def actor?(index)
    return @actors[index] == nil ? false : true
  end
  def set_index(x)
    @index = x
  end
end

#------------------------------------------------------------------------------

class Chaochao_Window_PartyRight < Window_Selectable
  def initialize
    super(320, 0, 320, 224)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = -1
    refresh
  end
  def actor
    return @actors[self.index]
  end
  def 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
      
    end
  end
  def draw_item(index)
    actor = @actors[index]
    text = @actors[index].name
    lv = @actors[index].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 = [255.0000 - 255.0000/60 * @actors[index].level,0].max
    colory = [255.0000 / 60 * @actors[index].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 = 22
  end
  def 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)
  end
  def item_max
    return @item_max
  end
  def actor?(index)
    return @actors[index] == nil ? false : true
  end
  def set_index(x)
    @index = x
  end
end

#------------------------------------------------------------------------------

class Chaochao_Window_PartyData < Window_Base
  
  def initialize
    super(0, 224, 640, 256)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = nil
  end
  
  def set_actor(actor)
    self.contents.clear
    draw_actor_name(actor, 4, 0)
    draw_actor_state(actor, 140, 0)
    draw_actor_hp(actor, 284, 0)
    draw_actor_sp(actor, 460, 0)
    @actor = actor
    self.visible = true
  end
  def clear
    self.contents.clear
  end
end

#------------------------------------------------------------------------------

class Game_Party
  attr_reader   :actors2
  attr_reader   :chaochao#不能从队伍向备用角色移动的角色ID
  attr_reader   :chaochao2#不能从备用角色向队伍移动的角色ID
  def initialize
    @actors = []
    @gold = 0
    @steps = 0
    @items = {}
    @weapons = {}
    @armors = {}
    @actors2 = []
    @chaochao = []
    @chaochao2 = []
  end
  def add_actor(actor_id,type=1)#type为1是向队伍中添加,为2则相反。
    case type
    when 1
      if $game_actors[actor_id] != nil
        actor = $game_actors[actor_id]
        #如果队伍没有满和队伍中没有此角色
        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[actor_id] != nil
        actor = $game_actors[actor_id]
        #如果角色不在队伍中和不在备用角色队伍中的情况下
        #向备用角色中添加角色
        if not @actors.include?(actor) and not @actors2.include?(actor)
          @actors2.push(actor)
          $game_player.refresh
        end
      end
    end
  end
  
  def huanren(index,type=1)#type为1是从备用角色向队伍中移动,为2则相反。
    actor = $game_actors[index]
    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
    end
  end
  
  #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
    end
  end
  
  #type,1从队伍中离开,2从备用角色中离开,3从队伍和备用角色中离开。
  def remove_actor(actor_id,type=1)
    actor = $game_actors[actor_id]
    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
    end
  end
  
  def refresh
    new_actors = []
    new_actors2 = []
    for i in 0...@actors.size
      if $data_actors[@actors.id] != nil
        new_actors.push($game_actors[@actors.id])
      end
    end
    @actors = new_actors
    for i in 0...@actors2.size
      if $data_actors[@actors2.id] != nil
        new_actors2.push($game_actors[@actors2.id])
      end
    end
    @actors2 = new_actors2
  end
end

#------------------------------------------------------------------------------

class Chaochao_Scene_Party
  def 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.dispose
  end
  
  def update
    @left_window.update
    @right_window.update
    @data_window.update
    update_command
    update_data
  end
  
  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
    end
  end
  
  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
    return
  end
  
  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
    return
  end
  
  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
    end
  end
end[/pre]
这个人物仓库怎么设置一个角色不能放入仓库,就是主角不可以放入人物仓库,别的人物可以

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2013-10-5 16:49:33 | 显示全部楼层
27行
  1. @actors = []
  2. for i in 0...$game_party.actors.size
  3. if $game_party.actors.id != 1 # 1号角色不可放入仓库
  4. @actors.push($game_party.actors[i])
  5. end
  6. end
复制代码
回复

使用道具 举报

梦石
0
星屑
55
在线时间
135 小时
注册时间
2013-8-7
回帖
70
 楼主| 发表于 2013-10-5 17:41:20 | 显示全部楼层
饿,那个,脚本我自己不会改,你能发个改好的吗

点评

做游戏不能偷懒…  发表于 2013-10-6 17:01
好吧,那谢谢你了  发表于 2013-10-5 22:06
懒也不能懒到这样,我也是脚本盲(因为鹰语不好),但至少我会用有道词典翻译对着看点,不会就求问请教,然后自己改,总不能让别人帮你改?...  发表于 2013-10-5 22:05
一个字:懒  发表于 2013-10-5 19:48
那LZ为甚么不去学学呢?简单的添加删除脚本一个小时差不多就能够学会了。  发表于 2013-10-5 18:29
回复

使用道具 举报

梦石
0
星屑
49
在线时间
295 小时
注册时间
2013-7-25
回帖
682
发表于 2013-10-6 16:39:44 | 显示全部楼层
我也是个脚本盲,以前话说也遇到这种问题——神奇宝贝仓库,竟然可以把小智放到仓库里!!!!!
所以最后就加了一下:
条件分歧:小智在不在背包里,如果在的话就结束,如果不在的话,标签跳转……
可勾搭
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2::52" alt="点击这里给我发消息" title="点击这里给我发消息"/></a>
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2013-10-6 16:51:24 | 显示全部楼层
本帖最后由 chd114 于 2013-10-6 17:05 编辑
  1. if $game_party.actors.id != 1 # 1号角色不可放入仓库
  2. @actors.push($game_party.actors[i])
  3. end
复制代码
把这段去掉后可以把1号角色放进仓库···但是如果你的角色全部放进去的话在运行游戏就可能出错···
把这段脚本改成
  1. if $game_party.actors.size= 1 and $game_party.actors.id != 1  # 队伍中只有1个队员时不能放入,禁止1号角色放入
  2. @actors.push($game_party.actors[i])
  3. end
复制代码
就可以了

点评

出错了,我感觉应该在200-201行修改?大雾  发表于 2013-10-9 00:04

评分

参与人数 1星屑 +3 收起 理由
guoyq1988 + 3 塞糖

查看全部评分

[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
343
在线时间
72 小时
注册时间
2013-10-4
回帖
33
发表于 2013-10-6 17:10:51 | 显示全部楼层
路过....
我是脚本盲

评分

参与人数 1星屑 -20 收起 理由
myownroc -20 无意义灌水

查看全部评分

回复

使用道具 举报

梦石
0
星屑
55
在线时间
135 小时
注册时间
2013-8-7
回帖
70
 楼主| 发表于 2013-10-6 20:48:06 | 显示全部楼层
唉,算了,总是出错
回复

使用道具 举报

梦石
0
星屑
50
在线时间
439 小时
注册时间
2013-3-2
回帖
657
发表于 2013-10-9 00:24:20 | 显示全部楼层
本帖最后由 guoyq1988 于 2013-10-9 00:27 编辑
RPG文笔 发表于 2013-10-6 20:48
唉,算了,总是出错


我自己改了下
楼主照我的说的改就好了,很简单
原来的脚本什么都不用改,楼上几位说的改法都错了(不是指责你们,你们也是在帮助他人,只是你们没注意看脚本,在脚本注释那里有改法,只要加个数字就可以了)

在脚本210行   @chaochao = []   的方框里写上你不想离队的人物ID即可

如一号人物不离队      @chaochao = [1]

我亲测了
图片红色名字的人物即为不可离队。。。
截图38.png

点评

粗心了···  发表于 2013-10-12 15:51

评分

参与人数 1星屑 +75 收起 理由
myownroc + 75 认可答案

查看全部评分


曾经的美好已不在   吾只能独自回忆
【RMXP共享】50个脚本整合的系统
回复

使用道具 举报

梦石
0
星屑
55
在线时间
135 小时
注册时间
2013-8-7
回帖
70
 楼主| 发表于 2013-10-12 18:01:06 | 显示全部楼层
哟西,谢谢你们

点评

礼貌是一定要懂滴  发表于 2013-10-12 21:00

评分

参与人数 1星屑 +2 收起 理由
guoyq1988 + 2 懂礼貌的新人

查看全部评分

回复

使用道具 举报

梦石
0
星屑
50
在线时间
14 小时
注册时间
2013-10-15
回帖
24
发表于 2014-1-17 21:09:57 | 显示全部楼层
guoyq1988 发表于 2013-10-9 00:24
我自己改了下
楼主照我的说的改就好了,很简单
原来的脚本什么都不用改,楼上几位说的改法都错了(不是指 ...

楼主能发下人物仓库的脚本吗?谢谢

点评

已发,话说我不是楼主。。。  发表于 2014-1-18 12:20

评分

参与人数 1星屑 -10 收起 理由
myownroc -10 挖坟

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部