| 赞 | 40  | 
 
| VIP | 559 | 
 
| 好人卡 | 234 | 
 
| 积分 | 47 | 
 
| 经验 | 251834 | 
 
| 最后登录 | 2025-10-7 | 
 
| 在线时间 | 5233 小时 | 
 
 
 
 
 
Lv3.寻梦者 (版主) 八宝粥的基叔 
	- 梦石
 - 0 
 
        - 星屑
 - 4687 
 
        - 在线时间
 - 5233 小时
 
        - 注册时间
 - 2009-4-29
 
        - 帖子
 - 14320
 
 
  
 
 | 
	
先给范例链接:http://pan.baidu.com/share/link?shareid=88540&uk=875076719 
实现要求:特定消耗物品和魔法在与特定敌群的战斗中变为不可使用。   
使用方法:敌群注释(必须把注释写在敌群事件的第一页,写在其它页无效)。比如范例中的敌群1史莱姆*2注释如下: 
 
 
如果需要设定与某敌群的战斗禁止使用某些物品或魔法,那么: 
(1)注释的第一行必须写<禁止恢复>   
(2)注释的第二行DisableItem等号后面的中括号写上需要禁止使用的物品ID,比如禁止1至4号物品就写[1,2,3,4],不能写成[1..4]。   
(3)注释的第三行DisableSkill等号后面的中括号写上需要禁止使用的技能ID,比如禁止26至30号物品就写[26,27,28,29,30],不能写成[26..30]。   
(4)注释的第四行Reason等号后面的中括号写上需要禁止使用的物品或技能的帮助说明(说明无需加引号" ")。若这行写不完,第五行还可以接着写。   
按要求截图:   
与恢复技能禁止的敌群战斗 
 
 
与普通敌群战斗 
 
 
恢复物品禁止的截图类似,这里由于篇幅的原因省略。   
按要求上脚本: 
脚本注释得很详细,特别适合新手们学习 - #==============================================================================
 
 - # ■ Game_Troop
 
 - #------------------------------------------------------------------------------
 
 - #  管理敌群和战斗相关资料的类,也可执行如战斗事件管理之类的功能。
 
 - #   本类的实例请参考 $game_troop 。
 
 - #==============================================================================
 
  
- class Game_Troop < Game_Unit
 
 -   attr_reader   :troop_id               # 敌群ID
 
 - end  
 
  
- #==============================================================================
 
 - # ■ Game_BattlerBase
 
 - #------------------------------------------------------------------------------
 
 - #  管理战斗者的类。主要含有能力值计算的方法。Game_Battler 类的父类。
 
 - #==============================================================================
 
  
- class Game_BattlerBase
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 判定技能/使用物品是否可用  再定义
 
 -   #--------------------------------------------------------------------------
 
 -   def usable?(item)
 
 -     return false if special_troop_cannot_recover(item)[0]  # 添加
 
 -     return skill_conditions_met?(item) if item.is_a?(RPG::Skill)
 
 -     return item_conditions_met?(item)  if item.is_a?(RPG::Item)
 
 -     return false
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 敌群注释的读取  新定义
 
 -   #--------------------------------------------------------------------------
 
 -   def special_troop_cannot_recover(item)
 
 -     item_id = []                        # 数组初始化
 
 -     skill_id = []                       # 数组初始化
 
 -     message = []                        # 数组初始化
 
 -     if SceneManager.scene_is?(Scene_Battle)  # 战斗中
 
 -       troop_page = $data_troops[$game_troop.troop_id].pages[0] # 只判定第一事件页
 
 -       if troop_page.list[0].code == 108 and troop_page.list[0].parameters == ["<禁止恢复>"]
 
 -         if troop_page.list[1].parameters[0].split(/=/)[0] == "DisableItem"
 
 -           item_id = eval(troop_page.list[1].parameters[0].split(/=/)[1]) # 读取物品禁止列表
 
 -         end
 
 -         if troop_page.list[2].parameters[0].split(/=/)[0] == "DisableSkill"
 
 -           skill_id = eval(troop_page.list[2].parameters[0].split(/=/)[1])# 读取技能禁止列表
 
 -         end
 
 -         if troop_page.list[3].parameters[0].split(/=/)[0] == "Reason"
 
 -           message = troop_page.list[3].parameters[0].split(/=/)[1]+      # 读取禁止时的帮助文本
 
 -             troop_page.list[4].parameters[0]
 
 -         end
 
 -       end
 
 -       case item
 
 -       when RPG::Item
 
 -         return [true, item_id, message] if item_id.include?(item.id) # 物品情况下返回特定值
 
 -       when RPG::Skill
 
 -         return [true, skill_id, message] if skill_id.include?(item.id) # 技能情况下返回特定值
 
 -       end
 
 -     end
 
 -     return [false, [], ""] # 无注释情况下返回特定值
 
 -   end  
 
 - end  
 
  
- #==============================================================================
 
 - # ■ Window_BattleItem
 
 - #------------------------------------------------------------------------------
 
 - #  战斗画面中,选择“使用物品”的窗口。
 
 - #==============================================================================
 
  
- class Window_BattleItem < Window_ItemList
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 查询使用列表中是否含有此物品  再定义
 
 -   #--------------------------------------------------------------------------
 
 -   def include?(item)
 
 -     return true if item.is_a?(RPG::Item) # 显示所有物品列表
 
 -   end
 
 - end  
 
  
- #==============================================================================
 
 - # ■ Window_Help
 
 - #------------------------------------------------------------------------------
 
 - #  显示特技和物品等的说明、以及角色状态的窗口
 
 - #==============================================================================
 
  
- class Window_Help < Window_Base
 
 -   #--------------------------------------------------------------------------
 
 -   # ● 设置物品  再定义
 
 -   #     item : 技能、物品等
 
 -   #--------------------------------------------------------------------------
 
 -   def set_item(item)
 
 -     set_text(item ? item.description : "")
 
 -     text = Game_BattlerBase.new.special_troop_cannot_recover(item)[2]
 
 -     text.insert(21, "\n") if text != ""  # 在第21个字符插入换行
 
 -     set_text(item ? text : "") if text != ""
 
 -   end
 
 - end  
 
 -   
 
  复制代码 |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |