查看: 2114|回复: 9

[已经解决] 请问如何在Scene_ItemBase里进行武器、防具判断?

[复制链接]
梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
回帖
659

开拓者

发表于 2017-8-18 12:12:51 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 jianyulei 于 2017-8-18 12:34 编辑

我想在确定物品(determine_item)里加入使用武器或防具后触发公共事件的效果,p过 item ,在里面能找到武器的开头 #<RPG::weapon ,请问我该如何读取这段话并判断它?
梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2017-8-18 12:15:09 | 显示全部楼层
if item.is_a?(RPG::Weapon)
if item.is_a?(RPG::Armor)

点评

你脚本怎么写的?  发表于 2017-8-18 12:40
不对,是weapon和Armor的报错  发表于 2017-8-18 12:30
用过了,一这样写就item NoMethhodError 报错  发表于 2017-8-18 12:29
回复

使用道具 举报

梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
回帖
659

开拓者

 楼主| 发表于 2017-8-18 12:45:46 | 显示全部楼层
本帖最后由 jianyulei 于 2017-8-18 12:50 编辑
soulsaga 发表于 2017-8-18 12:15
if item.is_a?(RPG::Weapon)
if item.is_a?(RPG::Armor)

  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Item
  4. #------------------------------------------------------------------------------
  5. #  物品画面
  6. #==============================================================================

  7. class Scene_Item < Scene_ItemBase
  8.   #--------------------------------------------------------------------------
  9.   # ● 开始处理
  10.   #--------------------------------------------------------------------------
  11.   alias scene_item_start_lx start
  12.   def start         #更新了
  13.     if $game_switches[1] == true
  14.        super
  15.        create_help_window
  16.        create_category1_window
  17.        create_item1_window
  18.     else   
  19.        scene_item_start_lx
  20.     end  
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 生成分类窗口
  24.   #--------------------------------------------------------------------------
  25.   def create_category1_window  #新的分类
  26.     @category_window = Window_ItemCategory.new
  27.     @category_window.viewport = @viewport
  28.     @category_window.help_window = @help_window
  29.     @category_window.y = @help_window.height
  30.     @category_window.set_handler(:ok,     method(:on_category1_ok))
  31.     @category_window.set_handler(:cancel, method(:return_scene))
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 生成物品窗口
  35.   #--------------------------------------------------------------------------
  36.   def create_item1_window   #新的物品
  37.     wy = @category_window.y + @category_window.height
  38.     wh = Graphics.height - wy
  39.     @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
  40.     @item_window.viewport = @viewport
  41.     @item_window.help_window = @help_window
  42.     @item_window.set_handler(:ok,     method(:on_item1_ok))
  43.     @item_window.set_handler(:cancel, method(:on_item1_cancel))
  44.     @category_window.item_window = @item_window
  45.   end

  46.   def on_category1_ok #新的分类“确定”
  47.     @item_window.activate
  48.     @item_window.select_last
  49.   end
  50.   def on_item1_ok #新的物品“确定”
  51.     $game_party.last_item.object = item
  52.     determine_item
  53.   end
  54.   def on_item1_cancel  #新的物品“取消”
  55.     @item_window.unselect
  56.     @category_window.activate
  57.   end  
  58.   
  59. end

  60. class Window_ItemList < Window_Selectable
  61.   alias enable_hc? enable?
  62.   def enable?(item)     #1号开关打开时所有装备都可以使用
  63.     if $game_switches[1] == true
  64.        return true
  65.     else
  66.        enable_hc?(item)
  67.     end
  68.   end  
  69. end

  70. class Scene_ItemBase < Scene_MenuBase
  71.    
  72.   alias determine_item_hc determine_item
  73.   def determine_item   #确定物品
  74.     if $game_switches[1] == true
  75.       if item.note =~ /<合成 (\d+)>/
  76.          $game_variables[3] += $1.to_i  
  77.       end
  78.            p item
  79.        if item.is_a?(RPG::item) #道具判定
  80.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(2);end
  81.       if item.is_a?(RPG::weapon)  #武器判定
  82.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(3);end
  83.       if item.is_a?(RPG::Armor) #防具判定  
  84.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(4);end
  85.     else
  86.        determine_item_hc
  87.     end  
  88.   end  
  89. end  
复制代码



只差判断了,这个脚本我是想做成装备使用特效、道具拆解、武器改造等多功能脚本来使用,因为是公共事件里写效果所以很灵活。

点评

原来要打开控制台..  发表于 2017-8-18 13:08
你可以用P么..我用的VA用P无效..何解..  发表于 2017-8-18 13:07
回复

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2017-8-18 13:16:49 | 显示全部楼层
jianyulei 发表于 2017-8-18 12:45
#encoding:utf-8
#==============================================================================
#  ...
  1. class Scene_ItemBase < Scene_MenuBase

  2.   alias determine_item_hc determine_item
  3.   def determine_item   #确定物品
  4.     if $game_switches[1] == true
  5.       if item.note =~ /<合成 (\d+)>/
  6.       end
  7.            #p item.is_a?(RPG::Weapon)
  8.        if item.is_a?(RPG::Item) #道具判定
  9.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(2);end
  10.       if item.is_a?(RPG::Weapon)  #武器判定
  11.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(3);end
  12.       if item.is_a?(RPG::Armor) #防具判定  
  13.         SceneManager.goto(Scene_Map);$game_temp.reserve_common_event(4);end
  14.     else
  15.        determine_item_hc
  16.     end  
  17.   end  
  18. end
复制代码


测试通过..复制默认脚本的item.is_a?(RPG::Weapon)那些就可以了..不知你写错了什么..

点评

我知道我写错了什么了……武器防具的第一个字母没有大写……  发表于 2017-8-18 13:19

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部