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

Project1

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

[已经解决] 在战斗中显示物品的问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
跳转到指定楼层
1
发表于 2010-9-30 21:35:29 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 步兵中尉 于 2010-10-3 23:47 编辑

      记得以前站上有过这样的帖子,但现在找不到了,特地问一下站上的大侠。
  就是在战斗中如何不显示不能使用的物品(例如事件物品、装备等)?
  备注:武器可以不屏蔽,使用了战斗中换武器的脚本
主要是以下的两个脚本冲突:http://rpg.blue/web/htm/news46.htm
                                       http://rpg.blue/portal.php?mod=view&aid=40422
可能难点就在如何限制第一个脚本如何不去掉战斗中显示武器吧!

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
39920
在线时间
7498 小时
注册时间
2009-7-6
帖子
13489

开拓者贵宾

2
发表于 2010-10-1 09:04:30 | 只看该作者
在那个脚本里的关键语句:
occasion = $data_items.occasion
if occasion == 0 or occasion == 1 #物品可以 ...
天圣的马甲 发表于 2008-10-11 15:02


http://rpg.blue/forum.php?mod=vi ... D%E4%BD%BF%E7%94%A8
这么厉害的人了还不会用搜索
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv1.梦旅人

鬼才

梦石
0
星屑
54
在线时间
40 小时
注册时间
2010-2-1
帖子
273
3
发表于 2010-10-1 09:10:04 | 只看该作者
用事件啊

1.jpg (15.12 KB, 下载次数: 6)

1.jpg
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
4
 楼主| 发表于 2010-10-1 11:38:21 | 只看该作者
本帖最后由 步兵中尉 于 2010-10-1 11:46 编辑

kukurui00 同志的方法只是限制物品的使用问题,不是解决显示问题
fux2 同志介绍的看了,用了下面的那个;但是把武器也屏蔽了,战斗中换武器不能
http://rpg.blue/web/htm/news46.htm

能否将上面的内容改变一下,不显示的范围添加武器
步兵中尉
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
5
 楼主| 发表于 2010-10-2 23:38:28 | 只看该作者
没法解决吗?
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
39920
在线时间
7498 小时
注册时间
2009-7-6
帖子
13489

开拓者贵宾

6
发表于 2010-10-3 09:13:07 | 只看该作者
本帖最后由 fux2 于 2010-10-3 11:08 编辑

回复 步兵中尉 的帖子


    自行把weapon和armor有关语句去掉。我认为这个你应该知道的,要自己想出来的方法才印象深刻,还是多思考吧。
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
7
 楼主| 发表于 2010-10-3 21:35:23 | 只看该作者
本帖最后由 步兵中尉 于 2010-10-3 22:57 编辑

楼上说的方法试验过的,没效果,所以才发帖上来询问。这次将那个脚本一起发上来!
而且删除你说的那些事管战斗之外的情况,也就是说平时看不到;附录武器的脚本
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   def refresh
  8.     if self.contents != nil
  9.       self.contents.dispose
  10.       self.contents = nil
  11.     end
  12.     @data = []
  13.     # 添加宝物
  14.     for i in 1...$data_items.size
  15.       if $game_party.item_number(i) > 0
  16.         @data.push($data_items[i])
  17.       end
  18.     end
  19.     # 添加武器
  20.     for i in 1...$data_weapons.size
  21.       if $game_party.weapon_number(i) > 0
  22.         @data.push($data_weapons[i])
  23.       end
  24.     end
  25.     # 在战斗中以外添加防具
  26.     unless $game_temp.in_battle
  27.       for i in 1...$data_armors.size
  28.         if $game_party.armor_number(i) > 0
  29.           @data.push($data_armors[i])
  30.         end
  31.       end
  32.     end
  33.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  34.     @item_max = @data.size
  35.     if @item_max > 0
  36.       self.contents = Bitmap.new(width - 32, row_max * 32)
  37.       for i in 0...@item_max
  38.         draw_item(i)
  39.       end
  40.     end
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 描绘项目
  44.   #     index : 项目编号
  45.   #--------------------------------------------------------------------------
  46.   def draw_item(index)
  47.     item = @data[index]
  48.     case item
  49.     when RPG::Item
  50.       number = $game_party.item_number(item.id)
  51.     when RPG::Weapon
  52.       number = $game_party.weapon_number(item.id)
  53.     when RPG::Armor
  54.       number = $game_party.armor_number(item.id)
  55.     end
  56.     if item.is_a?(RPG::Item) and
  57.        $game_party.item_can_use?(item.id)
  58.       self.contents.font.color = normal_color
  59.     else
  60.       if $game_temp.in_battle and item.is_a?(RPG::Weapon)
  61.         self.contents.font.color = normal_color
  62.       else
  63.         self.contents.font.color = disabled_color
  64.       end
  65.     end
  66.     x = 4 + index % 2 * (288 + 32)
  67.     y = index / 2 * 32
  68.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  69.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  70.     bitmap = RPG::Cache.icon(item.icon_name)
  71.     opacity = self.contents.font.color == normal_color ? 255 : 128
  72.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  73.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  74.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  75.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  76.   end
  77. end

  78. #==============================================================================
  79. # ■ Scene_Battle
  80. #------------------------------------------------------------------------------
  81. #  处理战斗画面的类。
  82. #==============================================================================

  83. class Scene_Battle
  84.   #--------------------------------------------------------------------------
  85.   # ● 转向前一个角色的命令输入
  86.   #--------------------------------------------------------------------------
  87.   def phase3_prior_actor
  88.     # 循环
  89.     begin
  90.       # 角色的明灭效果 OFF
  91.       if @active_battler != nil
  92.         @active_battler.blink = false
  93.       end
  94.       # 最初的角色的情况下
  95.       if @actor_index == 0
  96.         # 开始同伴指令回合
  97.         start_phase2
  98.         return
  99.       end
  100.       # 返回角色索引
  101.       @actor_index -= 1
  102.       @active_battler = $game_party.actors[@actor_index]
  103.       $game_party.gain_weapon(@active_battler.current_action.item_id[1], 1) if @active_battler.current_action.item_id[0] == false
  104.       @active_battler.blink = true
  105.     # 如果角色是在无法接受指令的状态就再试
  106.     end until @active_battler.inputable?
  107.     # 设置角色的命令窗口
  108.     phase3_setup_command_window
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 刷新画面 (角色命令回合 : 选择物品)
  112.   #--------------------------------------------------------------------------
  113.   def update_phase3_item_select
  114.     # 设置物品窗口为可视状态
  115.     @item_window.visible = true
  116.     # 刷新物品窗口
  117.     @item_window.update
  118.     # 按下 B 键的情况下
  119.     if Input.trigger?(Input::B)
  120.       # 演奏取消 SE
  121.       $game_system.se_play($data_system.cancel_se)
  122.       # 选择物品结束
  123.       end_item_select
  124.       return
  125.     end
  126.     # 按下 C 键的情况下
  127.     if Input.trigger?(Input::C)
  128.       # 获取物品窗口现在选择的物品资料
  129.       @item = @item_window.item
  130.       # 无法使用的情况下
  131.       if @item.is_a?(RPG::Item)
  132.         unless $game_party.item_can_use?(@item.id)
  133.           # 演奏冻结 SE
  134.           $game_system.se_play($data_system.buzzer_se)
  135.           return
  136.         end
  137.       elsif [email protected]_a?(RPG::Weapon)
  138.         # 演奏冻结 SE
  139.         $game_system.se_play($data_system.buzzer_se)
  140.         return
  141.       end
  142.       # 演奏确定 SE
  143.       $game_system.se_play($data_system.decision_se)
  144.       # 设置行动
  145.       @active_battler.current_action.item_id = [@item.is_a?(RPG::Item), @item.id]
  146.       # 设置物品窗口为不可见状态
  147.       @item_window.visible = false
  148.       # 效果范围是敌单体的情况下
  149.       if @item.is_a?(RPG::Weapon) or @item.scope == 1
  150.         $game_party.lose_weapon(@item.id, 1) if @item.is_a?(RPG::Weapon)
  151.         # 开始选择敌人
  152.         start_enemy_select
  153.       # 效果范围是我方单体的情况下
  154.       elsif @item.scope == 3 or @item.scope == 5
  155.         # 开始选择角色
  156.         start_actor_select
  157.       # 效果范围不是单体的情况下
  158.       else
  159.         # 物品选择结束
  160.         end_item_select
  161.         # 转到下一位角色的指令输入
  162.         phase3_next_actor
  163.       end
  164.       return
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  169.   #--------------------------------------------------------------------------
  170.   def update_phase3_enemy_select
  171.     # 刷新敌人箭头
  172.     @enemy_arrow.update
  173.     # 按下 B 键的情况下
  174.     if Input.trigger?(Input::B)
  175.       $game_party.gain_weapon(@item_window.item.id, 1) if @item_window != nil and @item_window.item.is_a(RPG::Weapon)
  176.       # 演奏取消 SE
  177.       $game_system.se_play($data_system.cancel_se)
  178.       # 选择敌人结束
  179.       end_enemy_select
  180.       return
  181.     end
  182.     # 按下 C 键的情况下
  183.     if Input.trigger?(Input::C)
  184.       # 演奏确定 SE
  185.       $game_system.se_play($data_system.decision_se)
  186.       # 设置行动
  187.       @active_battler.current_action.target_index = @enemy_arrow.index
  188.       # 选择敌人结束
  189.       end_enemy_select
  190.       # 显示特技窗口中的情况下
  191.       if @skill_window != nil
  192.         # 结束特技选择
  193.         end_skill_select
  194.       end
  195.       # 显示物品窗口的情况下
  196.       if @item_window != nil
  197.         # 结束物品选择
  198.         end_item_select
  199.       end
  200.       # 转到下一位角色的指令输入
  201.       phase3_next_actor
  202.     end
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 生成物品行动结果
  206.   #--------------------------------------------------------------------------
  207.   def make_item_action_result
  208.     # 获取物品
  209.     data = @active_battler.current_action.item_id[0] ? $data_items : $data_weapons
  210.     @item = data[@active_battler.current_action.item_id[1]]
  211.     # 因为物品耗尽而无法使用的情况下
  212.     if @active_battler.current_action.item_id[0]
  213.       unless $game_party.item_can_use?(@item.id)
  214.         # 移至步骤 1
  215.         @phase4_step = 1
  216.         return
  217.       end
  218.       # 消耗品的情况下
  219.       if @item.consumable
  220.         # 使用的物品减 1
  221.         $game_party.lose_item(@item.id, 1)
  222.       end
  223.       # 设置公共事件 ID
  224.       @common_event_id = @item.common_event_id
  225.       # 在帮助窗口显示物品名
  226.       @help_window.set_text(@item.name, 1)
  227.       # 设置动画 ID
  228.       @animation1_id = @item.animation1_id
  229.       @animation2_id = @item.animation2_id
  230.       # 确定对像
  231.       index = @active_battler.current_action.target_index
  232.       target = $game_party.smooth_target_actor(index)
  233.       # 设置对像侧战斗者
  234.       set_target_battlers(@item.scope)
  235.     else
  236.       # 在帮助窗口显示物品名
  237.       @help_window.set_text(@item.name, 1)
  238.       # 设置动画 ID
  239.       @animation1_id = @item.animation1_id
  240.       @animation2_id = @item.animation2_id
  241.       # 确定对像
  242.       index = @active_battler.current_action.target_index
  243.       target = $game_party.smooth_target_actor(index)
  244.       # 设置对像侧战斗者
  245.       set_target_battlers(1)
  246.     end
  247.     # 应用物品效果
  248.     for target in @target_battlers
  249.       target.item_effect(@item)
  250.     end
  251.   end
  252. end

  253. #==============================================================================
  254. # ■ Game_Battler
  255. #------------------------------------------------------------------------------
  256. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  257. # 超级类来使用。
  258. #==============================================================================

  259. class Game_Battler
  260.   ADDITION = 2  # 武器投掷时伤害与武器自身伤害的倍率
  261.   #--------------------------------------------------------------------------
  262.   # ● 应用物品效果
  263.   #     item : 物品
  264.   #--------------------------------------------------------------------------
  265.   def item_effect(item)
  266.     # 清除会心一击标志
  267.     self.critical = false
  268.     # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  269.     # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  270.     unless item.is_a?(RPG::Weapon)
  271.       if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  272.          ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  273.         # 过程结束
  274.         return false
  275.       end
  276.       # 清除有效标志
  277.       effective = false
  278.       # 公共事件 ID 是有效的情况下,设置为有效标志
  279.       effective |= item.common_event_id > 0
  280.       # 命中判定
  281.       hit_result = (rand(100) < item.hit)
  282.       # 不确定的特技的情况下设置为有效标志
  283.       effective |= item.hit < 100
  284.       # 命中的情况
  285.       if hit_result == true
  286.         # 计算回复量
  287.         recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  288.         recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  289.         if recover_hp < 0
  290.           recover_hp += self.pdef * item.pdef_f / 20
  291.           recover_hp += self.mdef * item.mdef_f / 20
  292.           recover_hp = [recover_hp, 0].min
  293.         end
  294.         # 属性修正
  295.         recover_hp *= elements_correct(item.element_set)
  296.         recover_hp /= 100
  297.         recover_sp *= elements_correct(item.element_set)
  298.         recover_sp /= 100
  299.         # 分散
  300.         if item.variance > 0 and recover_hp.abs > 0
  301.           amp = [recover_hp.abs * item.variance / 100, 1].max
  302.           recover_hp += rand(amp+1) + rand(amp+1) - amp
  303.         end
  304.         if item.variance > 0 and recover_sp.abs > 0
  305.           amp = [recover_sp.abs * item.variance / 100, 1].max
  306.           recover_sp += rand(amp+1) + rand(amp+1) - amp
  307.         end
  308.         # 回复量符号为负的情况下
  309.         if recover_hp < 0
  310.           # 防御修正
  311.           if self.guarding?
  312.             recover_hp /= 2
  313.           end
  314.         end
  315.         # HP 回复量符号的反转、设置伤害值
  316.         self.damage = -recover_hp
  317.         # HP 以及 SP 的回复
  318.         last_hp = self.hp
  319.         last_sp = self.sp
  320.         self.hp += recover_hp
  321.         self.sp += recover_sp
  322.         effective |= self.hp != last_hp
  323.         effective |= self.sp != last_sp
  324.         # 状态变化
  325.         @state_changed = false
  326.         effective |= states_plus(item.plus_state_set)
  327.         effective |= states_minus(item.minus_state_set)
  328.         # 能力上升值有效的情况下
  329.         if item.parameter_type > 0 and item.parameter_points != 0
  330.           # 能力值的分支
  331.           case item.parameter_type
  332.           when 1  # MaxHP
  333.             @maxhp_plus += item.parameter_points
  334.           when 2  # MaxSP
  335.             @maxsp_plus += item.parameter_points
  336.           when 3  # 力量
  337.             @str_plus += item.parameter_points
  338.           when 4  # 灵巧
  339.             @dex_plus += item.parameter_points
  340.           when 5  # 速度
  341.             @agi_plus += item.parameter_points
  342.           when 6  # 魔力
  343.             @int_plus += item.parameter_points
  344.           end
  345.           # 设置有效标志
  346.           effective = true
  347.         end
  348.         # HP 回复率与回复量为 0 的情况下
  349.         if item.recover_hp_rate == 0 and item.recover_hp == 0
  350.           # 设置伤害为空的字符串
  351.           self.damage = ""
  352.           # SP 回复率与回复量为 0、能力上升值无效的情况下
  353.           if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  354.              (item.parameter_type == 0 or item.parameter_points == 0)
  355.             # 状态没有变化的情况下
  356.             unless @state_changed
  357.               # 伤害设置为 "Miss"
  358.               self.damage = "Miss"
  359.             end
  360.           end
  361.         end
  362.       # Miss 的情况下
  363.       else
  364.         # 伤害设置为 "Miss"
  365.         self.damage = "Miss"
  366.       end
  367.     else
  368.       # 计算基本伤害
  369.       self.damage = item.atk * ADDITION
  370.       # 属性修正
  371.       self.damage *= elements_correct(item.element_set)
  372.       self.damage /= 100
  373.       # 伤害符号正确的情况下
  374.       if self.damage > 0
  375.         # 会心一击修正
  376.         if rand(100) < 4 * item.dex_plus / self.agi
  377.           self.damage *= 2
  378.           self.critical = true
  379.         end
  380.         # 防御修正
  381.         if self.guarding?
  382.           self.damage /= 2
  383.         end
  384.       end
  385.       # 分散
  386.       if self.damage.abs > 0
  387.         amp = [self.damage.abs * 15 / 100, 1].max
  388.         self.damage += rand(amp+1) + rand(amp+1) - amp
  389.       end
  390.       # 状态冲击解除
  391.       remove_states_shock
  392.       # HP 的伤害计算
  393.       self.hp -= self.damage
  394.       # 状态变化
  395.       @state_changed = false
  396.       states_plus(item.plus_state_set)
  397.       states_minus(item.minus_state_set)
  398.     end
  399.     # 不在战斗中的情况下
  400.     unless $game_temp.in_battle
  401.       # 伤害设置为 nil
  402.       self.damage = nil
  403.     end
  404.     # 过程结束
  405.     return effective
  406.   end
  407. end

  408. #==============================================================================
  409. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  410. #==============================================================================
复制代码
步兵中尉
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
39920
在线时间
7498 小时
注册时间
2009-7-6
帖子
13489

开拓者贵宾

8
发表于 2010-10-3 21:56:28 | 只看该作者
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   def refresh
  8.     if self.contents != nil
  9.       self.contents.dispose
  10.       self.contents = nil
  11.     end
  12.     @data = []
  13.     # 添加宝物
  14.     for i in 1...$data_items.size
  15.       if $game_party.item_number(i) > 0
  16.         @data.push($data_items[i])
  17.       end
  18.     end
  19.     # 添加武器
  20.     for i in 1...$data_weapons.size
  21.       if $game_party.weapon_number(i) > 0
  22.         @data.push($data_weapons[i])
  23.       end
  24.     end
  25.     # 在战斗中以外添加防具
  26.     unless $game_temp.in_battle
  27.       for i in 1...$data_armors.size
  28.         if $game_party.armor_number(i) > 0
  29.           @data.push($data_armors[i])
  30.         end
  31.       end
  32.     end
  33.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  34.     @item_max = @data.size
  35.     if @item_max > 0
  36.       self.contents = Bitmap.new(width - 32, row_max * 32)
  37.       for i in 0...@item_max
  38.         draw_item(i)
  39.       end
  40.     end
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 描绘项目
  44.   #     index : 项目编号
  45.   #--------------------------------------------------------------------------
  46.   def draw_item(index)
  47.     item = @data[index]
  48.     case item
  49.     when RPG::Item
  50.       number = $game_party.item_number(item.id)
  51.     when RPG::Weapon
  52.       number = $game_party.weapon_number(item.id)
  53.     when RPG::Armor
  54.       number = $game_party.armor_number(item.id)
  55.     end
  56.     if item.is_a?(RPG::Item) and
  57.        $game_party.item_can_use?(item.id)
  58.       self.contents.font.color = normal_color
  59.     else
  60.         self.contents.font.color = disabled_color
  61.     end
  62.     x = 4 + index % 2 * (288 + 32)
  63.     y = index / 2 * 32
  64.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  65.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  66.     bitmap = RPG::Cache.icon(item.icon_name)
  67.     opacity = self.contents.font.color == normal_color ? 255 : 128
  68.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  69.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  70.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  71.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  72.   end
  73. end

  74. #==============================================================================
  75. # ■ Scene_Battle
  76. #------------------------------------------------------------------------------
  77. #  处理战斗画面的类。
  78. #==============================================================================

  79. class Scene_Battle
  80.   #--------------------------------------------------------------------------
  81.   # ● 转向前一个角色的命令输入
  82.   #--------------------------------------------------------------------------
  83.   def phase3_prior_actor
  84.     # 循环
  85.     begin
  86.       # 角色的明灭效果 OFF
  87.       if @active_battler != nil
  88.         @active_battler.blink = false
  89.       end
  90.       # 最初的角色的情况下
  91.       if @actor_index == 0
  92.         # 开始同伴指令回合
  93.         start_phase2
  94.         return
  95.       end
  96.       # 返回角色索引
  97.       @actor_index -= 1
  98.       @active_battler = $game_party.actors[@actor_index]
  99.       $game_party.gain_weapon(@active_battler.current_action.item_id[1], 1) if @active_battler.current_action.item_id[0] == false
  100.       @active_battler.blink = true
  101.     # 如果角色是在无法接受指令的状态就再试
  102.     end until @active_battler.inputable?
  103.     # 设置角色的命令窗口
  104.     phase3_setup_command_window
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 刷新画面 (角色命令回合 : 选择物品)
  108.   #--------------------------------------------------------------------------
  109.   def update_phase3_item_select
  110.     # 设置物品窗口为可视状态
  111.     @item_window.visible = true
  112.     # 刷新物品窗口
  113.     @item_window.update
  114.     # 按下 B 键的情况下
  115.     if Input.trigger?(Input::B)
  116.       # 演奏取消 SE
  117.       $game_system.se_play($data_system.cancel_se)
  118.       # 选择物品结束
  119.       end_item_select
  120.       return
  121.     end
  122.     # 按下 C 键的情况下
  123.     if Input.trigger?(Input::C)
  124.       # 获取物品窗口现在选择的物品资料
  125.       @item = @item_window.item
  126.       # 无法使用的情况下
  127.       if @item.is_a?(RPG::Item)
  128.         unless $game_party.item_can_use?(@item.id)
  129.           # 演奏冻结 SE
  130.           $game_system.se_play($data_system.buzzer_se)
  131.           return
  132.         end
  133.       elsif [email protected]_a?(RPG::Weapon)
  134.         # 演奏冻结 SE
  135.         $game_system.se_play($data_system.buzzer_se)
  136.         return
  137.       end
  138.       # 演奏确定 SE
  139.       $game_system.se_play($data_system.decision_se)
  140.       # 设置行动
  141.       @active_battler.current_action.item_id = [@item.is_a?(RPG::Item), @item.id]
  142.       # 设置物品窗口为不可见状态
  143.       @item_window.visible = false
  144.       # 效果范围是敌单体的情况下
  145.       if @item.is_a?(RPG::Weapon) or @item.scope == 1
  146.         $game_party.lose_weapon(@item.id, 1) if @item.is_a?(RPG::Weapon)
  147.         # 开始选择敌人
  148.         start_enemy_select
  149.       # 效果范围是我方单体的情况下
  150.       elsif @item.scope == 3 or @item.scope == 5
  151.         # 开始选择角色
  152.         start_actor_select
  153.       # 效果范围不是单体的情况下
  154.       else
  155.         # 物品选择结束
  156.         end_item_select
  157.         # 转到下一位角色的指令输入
  158.         phase3_next_actor
  159.       end
  160.       return
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  165.   #--------------------------------------------------------------------------
  166.   def update_phase3_enemy_select
  167.     # 刷新敌人箭头
  168.     @enemy_arrow.update
  169.     # 按下 B 键的情况下
  170.     if Input.trigger?(Input::B)
  171.       $game_party.gain_weapon(@item_window.item.id, 1) if @item_window != nil and @item_window.item.is_a(RPG::Weapon)
  172.       # 演奏取消 SE
  173.       $game_system.se_play($data_system.cancel_se)
  174.       # 选择敌人结束
  175.       end_enemy_select
  176.       return
  177.     end
  178.     # 按下 C 键的情况下
  179.     if Input.trigger?(Input::C)
  180.       # 演奏确定 SE
  181.       $game_system.se_play($data_system.decision_se)
  182.       # 设置行动
  183.       @active_battler.current_action.target_index = @enemy_arrow.index
  184.       # 选择敌人结束
  185.       end_enemy_select
  186.       # 显示特技窗口中的情况下
  187.       if @skill_window != nil
  188.         # 结束特技选择
  189.         end_skill_select
  190.       end
  191.       # 显示物品窗口的情况下
  192.       if @item_window != nil
  193.         # 结束物品选择
  194.         end_item_select
  195.       end
  196.       # 转到下一位角色的指令输入
  197.       phase3_next_actor
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 生成物品行动结果
  202.   #--------------------------------------------------------------------------
  203.   def make_item_action_result
  204.     # 获取物品
  205.     data = @active_battler.current_action.item_id[0] ? $data_items : $data_weapons
  206.     @item = data[@active_battler.current_action.item_id[1]]
  207.     # 因为物品耗尽而无法使用的情况下
  208.     if @active_battler.current_action.item_id[0]
  209.       unless $game_party.item_can_use?(@item.id)
  210.         # 移至步骤 1
  211.         @phase4_step = 1
  212.         return
  213.       end
  214.       # 消耗品的情况下
  215.       if @item.consumable
  216.         # 使用的物品减 1
  217.         $game_party.lose_item(@item.id, 1)
  218.       end
  219.       # 设置公共事件 ID
  220.       @common_event_id = @item.common_event_id
  221.       # 在帮助窗口显示物品名
  222.       @help_window.set_text(@item.name, 1)
  223.       # 设置动画 ID
  224.       @animation1_id = @item.animation1_id
  225.       @animation2_id = @item.animation2_id
  226.       # 确定对像
  227.       index = @active_battler.current_action.target_index
  228.       target = $game_party.smooth_target_actor(index)
  229.       # 设置对像侧战斗者
  230.       set_target_battlers(@item.scope)
  231.     else
  232.       # 在帮助窗口显示物品名
  233.       @help_window.set_text(@item.name, 1)
  234.       # 设置动画 ID
  235.       @animation1_id = @item.animation1_id
  236.       @animation2_id = @item.animation2_id
  237.       # 确定对像
  238.       index = @active_battler.current_action.target_index
  239.       target = $game_party.smooth_target_actor(index)
  240.       # 设置对像侧战斗者
  241.       set_target_battlers(1)
  242.     end
  243.     # 应用物品效果
  244.     for target in @target_battlers
  245.       target.item_effect(@item)
  246.     end
  247.   end
  248. end

  249. #==============================================================================
  250. # ■ Game_Battler
  251. #------------------------------------------------------------------------------
  252. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  253. # 超级类来使用。
  254. #==============================================================================

  255. class Game_Battler
  256.   ADDITION = 2  # 武器投掷时伤害与武器自身伤害的倍率
  257.   #--------------------------------------------------------------------------
  258.   # ● 应用物品效果
  259.   #     item : 物品
  260.   #--------------------------------------------------------------------------
  261.   def item_effect(item)
  262.     # 清除会心一击标志
  263.     self.critical = false
  264.     # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  265.     # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  266.     unless item.is_a?(RPG::Weapon)
  267.       if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  268.          ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  269.         # 过程结束
  270.         return false
  271.       end
  272.       # 清除有效标志
  273.       effective = false
  274.       # 公共事件 ID 是有效的情况下,设置为有效标志
  275.       effective |= item.common_event_id > 0
  276.       # 命中判定
  277.       hit_result = (rand(100) < item.hit)
  278.       # 不确定的特技的情况下设置为有效标志
  279.       effective |= item.hit < 100
  280.       # 命中的情况
  281.       if hit_result == true
  282.         # 计算回复量
  283.         recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  284.         recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  285.         if recover_hp < 0
  286.           recover_hp += self.pdef * item.pdef_f / 20
  287.           recover_hp += self.mdef * item.mdef_f / 20
  288.           recover_hp = [recover_hp, 0].min
  289.         end
  290.         # 属性修正
  291.         recover_hp *= elements_correct(item.element_set)
  292.         recover_hp /= 100
  293.         recover_sp *= elements_correct(item.element_set)
  294.         recover_sp /= 100
  295.         # 分散
  296.         if item.variance > 0 and recover_hp.abs > 0
  297.           amp = [recover_hp.abs * item.variance / 100, 1].max
  298.           recover_hp += rand(amp+1) + rand(amp+1) - amp
  299.         end
  300.         if item.variance > 0 and recover_sp.abs > 0
  301.           amp = [recover_sp.abs * item.variance / 100, 1].max
  302.           recover_sp += rand(amp+1) + rand(amp+1) - amp
  303.         end
  304.         # 回复量符号为负的情况下
  305.         if recover_hp < 0
  306.           # 防御修正
  307.           if self.guarding?
  308.             recover_hp /= 2
  309.           end
  310.         end
  311.         # HP 回复量符号的反转、设置伤害值
  312.         self.damage = -recover_hp
  313.         # HP 以及 SP 的回复
  314.         last_hp = self.hp
  315.         last_sp = self.sp
  316.         self.hp += recover_hp
  317.         self.sp += recover_sp
  318.         effective |= self.hp != last_hp
  319.         effective |= self.sp != last_sp
  320.         # 状态变化
  321.         @state_changed = false
  322.         effective |= states_plus(item.plus_state_set)
  323.         effective |= states_minus(item.minus_state_set)
  324.         # 能力上升值有效的情况下
  325.         if item.parameter_type > 0 and item.parameter_points != 0
  326.           # 能力值的分支
  327.           case item.parameter_type
  328.           when 1  # MaxHP
  329.             @maxhp_plus += item.parameter_points
  330.           when 2  # MaxSP
  331.             @maxsp_plus += item.parameter_points
  332.           when 3  # 力量
  333.             @str_plus += item.parameter_points
  334.           when 4  # 灵巧
  335.             @dex_plus += item.parameter_points
  336.           when 5  # 速度
  337.             @agi_plus += item.parameter_points
  338.           when 6  # 魔力
  339.             @int_plus += item.parameter_points
  340.           end
  341.           # 设置有效标志
  342.           effective = true
  343.         end
  344.         # HP 回复率与回复量为 0 的情况下
  345.         if item.recover_hp_rate == 0 and item.recover_hp == 0
  346.           # 设置伤害为空的字符串
  347.           self.damage = ""
  348.           # SP 回复率与回复量为 0、能力上升值无效的情况下
  349.           if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  350.              (item.parameter_type == 0 or item.parameter_points == 0)
  351.             # 状态没有变化的情况下
  352.             unless @state_changed
  353.               # 伤害设置为 "Miss"
  354.               self.damage = "Miss"
  355.             end
  356.           end
  357.         end
  358.       # Miss 的情况下
  359.       else
  360.         # 伤害设置为 "Miss"
  361.         self.damage = "Miss"
  362.       end
  363.     else
  364.       # 计算基本伤害
  365.       self.damage = item.atk * ADDITION
  366.       # 属性修正
  367.       self.damage *= elements_correct(item.element_set)
  368.       self.damage /= 100
  369.       # 伤害符号正确的情况下
  370.       if self.damage > 0
  371.         # 会心一击修正
  372.         if rand(100) < 4 * item.dex_plus / self.agi
  373.           self.damage *= 2
  374.           self.critical = true
  375.         end
  376.         # 防御修正
  377.         if self.guarding?
  378.           self.damage /= 2
  379.         end
  380.       end
  381.       # 分散
  382.       if self.damage.abs > 0
  383.         amp = [self.damage.abs * 15 / 100, 1].max
  384.         self.damage += rand(amp+1) + rand(amp+1) - amp
  385.       end
  386.       # 状态冲击解除
  387.       remove_states_shock
  388.       # HP 的伤害计算
  389.       self.hp -= self.damage
  390.       # 状态变化
  391.       @state_changed = false
  392.       states_plus(item.plus_state_set)
  393.       states_minus(item.minus_state_set)
  394.     end
  395.     # 不在战斗中的情况下
  396.     unless $game_temp.in_battle
  397.       # 伤害设置为 nil
  398.       self.damage = nil
  399.     end
  400.     # 过程结束
  401.     return effective
  402.   end
  403. end

  404. #==============================================================================
  405. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  406. #==============================================================================
复制代码
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
9
 楼主| 发表于 2010-10-3 22:07:32 | 只看该作者
我给的那个是武器投掷系统的脚本,限制显示物品还是http://rpg.blue/web/htm/news46.htm
就是这两个脚本显示的问题
您刚才写的那个脚本没能解决物品的限制
步兵中尉
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3795
在线时间
1578 小时
注册时间
2006-5-5
帖子
2742
10
 楼主| 发表于 2010-10-6 10:33:17 | 只看该作者
根据亿万星辰的方法解决了,还是公布出来大家共享!
用的是武器投掷脚本,http://rpg.blue/portal.php?mod=view&aid=40422
更改方法是替换下面:
  1. class Window_Item < Window_Selectable
  2.     def refresh
  3.     if self.contents != nil
  4.       self.contents.dispose
  5.       self.contents = nil
  6.     end
  7.     @data = []
  8.     # 在战斗中以外添加武器、防具
  9.     unless $game_temp.in_battle
  10.       # 添加报务
  11.       for i in 1...$data_items.size
  12.         if $game_party.item_number(i) > 0
  13.             @data.push($data_items[i])
  14.         end
  15.       end
  16.       for i in 1...$data_weapons.size
  17.         if $game_party.weapon_number(i) > 0
  18.           @data.push($data_weapons[i])
  19.         end
  20.       end
  21.       for i in 1...$data_armors.size
  22.         if $game_party.armor_number(i) > 0
  23.           @data.push($data_armors[i])
  24.         end
  25.       end
  26.     else
  27.       for i in 1...$data_items.size
  28.         if $game_party.item_number(i) > 0
  29.           occasion = $data_items[i].occasion
  30.           if occasion == 0 or occasion == 1
  31.              @data.push($data_items[i])
  32.           end
  33.         end
  34.       end
  35.     # 添加武器
  36.     for i in 1...$data_weapons.size
  37.       if $game_party.weapon_number(i) > 0
  38.         @data.push($data_weapons[i])
  39.       end
  40.     end
  41.     end
  42.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  43.     @item_max = @data.size
  44.     if @item_max > 0
  45.       self.contents = Bitmap.new(width - 32, row_max * 32)
  46.       for i in 0...@item_max
  47.         draw_item(i)
  48.       end
  49.     end
  50.   end
复制代码
步兵中尉
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-21 07:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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