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

Project1

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

[已经过期] 物品列表 如何设置不可出售物品

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
139 小时
注册时间
2013-1-30
帖子
65
跳转到指定楼层
1
发表于 2014-1-25 14:41:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 575539640 于 2014-1-25 15:02 编辑

这个脚本里物品在背包中可以随意卖出,但我的一些任务物品不想被玩家卖出,应该如何设置?

物品的那个脚本就是这个里面带的
VA 装备开发系统 1.34 (3.30 更新:解决解锁时出现的BUG)
http://rpg.blue/thread-296539-1-1.html



RUBY 代码复制
  1. module Equipplus
  2.   CODE ={
  3.     11 => "属性抗性",
  4.     12 => "弱化抗性",
  5.     13 => "状态抗性",
  6.     14 => "状态免疫",
  7.     21 => "基本能力",
  8.     22 => "附加能力",
  9.     23 => "独有能力",
  10.     31 => "攻击附带属性",
  11.     32 => "攻击附带状态",
  12.     33 => "修正攻击速度",
  13.     34 => "添加攻击次数",
  14.     41 => "添加技能类型",
  15.     42 => "禁用技能类型",
  16.     43 => "添加技能",
  17.     44 => "禁用技能",
  18.     51 => "可装备武器类型",
  19.     52 => "可装备护甲类型",
  20.     53 => "固定装备",
  21.     54 => "禁用装备",
  22.     55 => "装备风格",
  23.     61 => "添加行动次数",
  24.     62 => "特殊标志",
  25.     63 => "消失效果",
  26.     64 => "队伍能力"}
  27.   #特殊标志
  28.   FLAG ={
  29.                 0 => "自动战斗",
  30.                 1 => "擅长防御",
  31.                 2 => "保护弱者",
  32.                 3 => "特技专注"}
  33.   #普通能力
  34.         PARAM ={
  35.                 0 => "血量上限",
  36.                 1 => "魔力上限",
  37.                 2 => "物理破坏力",
  38.                 3 => "物理防御力",
  39.                 4 => "魔法破坏力",
  40.                 5 => "魔法防御力",
  41.                 6 => "灵巧值",
  42.                 7 => "幸运值"}
  43.   #添加能力
  44.         XPARAM ={
  45.                 0 => "攻击率:",
  46.                 1 => "闪避率:",
  47.                 2 => "暴击率:",
  48.                 3 => "保护率:",
  49.                 4 => "魔力抵消率:",
  50.                 5 => "魔力克制率:",
  51.                 6 => "物理反击率:",
  52.                 7 => "伤口愈合率:",
  53.                 8 => "魔力产生率:",
  54.                 9 => "怒气攻心率:"}
  55.   #特殊能力
  56.         SPARAM ={
  57.                 0 => "受到攻击率",
  58.                 1 => "防御效果率",
  59.                 2 => "恢复效果率",
  60.                 3 => "药理知识",
  61.                 4 => "魔法熟练度",
  62.                 5 => "怒气释放率",
  63.                 6 => "物理攻击伤害加成",
  64.                 7 => "魔法攻击伤害加成",
  65.                 8 => "洞察能力",
  66.                 9 => "领悟能力"}
  67.         @队伍能力 ={
  68.                 0 => "霸气外露",
  69.                 1 => "随机遇敌无效",
  70.                 2 => "很高的警惕性",
  71.                 3 => "善于隐藏自己",
  72.                 4 => "财神附体",
  73.                 5 => "幸运女神"}
  74.   def self.equiphelpready
  75.     @状态 = {}
  76.     @武器类型 = {}
  77.     @防具类型 = {}
  78.     @属性 = {}
  79.     $data_states.each{|x| @状态[x.id] = x.name if x != nil}
  80.     elements = $data_system.elements
  81.     weapon_types = $data_system.weapon_types
  82.     armor_types = $data_system.armor_types
  83.     elements.each_with_index{|x,y| @属性[y] = x if x != ""}
  84.     weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
  85.     armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  86.   end
  87.   def self.getequiphelp(equip)
  88.     help = ""
  89.     param = []
  90.     equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}
  91.     param = param.select{|x| x[1] != 0}
  92.     param.each{|x| help += x[0] + ":" + x[1].to_int.to_s + "\n"}
  93.     features = equip.features
  94.     features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}
  95.     features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}
  96.     features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  97.     features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}
  98.     features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}
  99.     features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}
  100.     features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}
  101.     features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  102.     features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  103.     features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  104.     features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  105.     features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  106.     features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  107.     features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}
  108.     features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}
  109.     features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}
  110.     features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}
  111.     features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}
  112.     featuresparam = []
  113.     featuresparam.push features.select{|x| x.code == 21}
  114.     featuresparam.push features.select{|x| x.code == 22}
  115.     featuresparam.push features.select{|x| x.code == 23}
  116.     featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  117.     featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}
  118.     featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  119.     help
  120.   end
  121.   def self.getline(text,maxtext)
  122.     xtext = []
  123.     line = 0
  124.     text.each_line{|x| xtext.push x.sub(/\n/){}}
  125.     xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
  126.     line
  127.   end
  128. end
  129. #==============================================================================
  130. # ■ Window_Help
  131. #------------------------------------------------------------------------------
  132. #  显示特技和物品等的说明、以及角色状态的窗口
  133. #==============================================================================
  134.  
  135. class Window_Help2 < Window_Base
  136.   #--------------------------------------------------------------------------
  137.   # ● 初始化对象
  138.   #--------------------------------------------------------------------------
  139.   def initialize(line_number = 0)
  140.     super(0, 0, 210, 0)
  141.     self.z = 150
  142.     contents.font.size = 20
  143.     hide
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 设置内容
  147.   #--------------------------------------------------------------------------
  148.   def set_text(text)
  149.       @text = text
  150.       refresh
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 清除
  154.   #--------------------------------------------------------------------------
  155.   def clear
  156.     set_text("")
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 更新帮助位置
  160.   #--------------------------------------------------------------------------
  161.   def uppos(index,rect,window)
  162.     self.height = fitting_height2(Equipplus.getline(@xtext,13))
  163.     create_contents
  164.     contents.font.size = 20
  165.     rect.x -= window.ox
  166.     rect.y -= window.oy
  167.     ax = rect.x + rect.width + 10
  168.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  169.     ax += window.x
  170.     ax = 0 if ax < 0
  171.     ay = rect.y + rect.height
  172.     ay = rect.y - self.height if ay + self.height > window.height
  173.     ay += window.y
  174.     ay = 0 if ay < 0
  175.     self.x = ax
  176.     self.y = ay
  177.     set_text(@xtext)
  178.     show
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● 设置物品
  182.   #     item : 技能、物品等
  183.   #--------------------------------------------------------------------------
  184.   def set_item(item)
  185.     if item == nil
  186.       set_text("")
  187.       return
  188.     end
  189.     @xtext = ""
  190.     @xtext = "名称:" + item.name + "\n"
  191.     @xtext += "介绍:" + item.description + "\n"
  192.     @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  193.     @xtext += "持有:" + $game_party.item_number(item).to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  194.     @xtext += Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
  195.     @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 刷新
  199.   #--------------------------------------------------------------------------
  200.   def refresh
  201.     contents.clear
  202.     hide if @text == ""
  203.     draw_text_ex(4, 0, @text,width,40,false)
  204.   end
  205. end
  206. class Window_Base < Window
  207.   #--------------------------------------------------------------------------
  208.   # ● 计算窗口显示指定行数时的应用高度2*************************
  209.   #--------------------------------------------------------------------------
  210.   def fitting_height2(line_number)
  211.     line_number * contents.font.size + standard_padding * 2
  212.   end
  213. # draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  214.   #--------------------------------------------------------------------------
  215.   # ● 绘制带有控制符的文本内容
  216.   #   如果传递了width参数的话,会自动换行
  217.   #--------------------------------------------------------------------------
  218.   def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
  219.     reset_font_settings if normalfont == true
  220.     text = convert_escape_characters(text)
  221.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  222.     if width != nil
  223.       pos[:height] = contents.font.size
  224.       pos[:width] = width
  225.       pos[:textwidth] = textwidth
  226.     end
  227.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 文字的处理
  231.   #     c    : 文字
  232.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  233.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  234.   #--------------------------------------------------------------------------
  235.   def process_character(c, text, pos)
  236.     case c
  237.     when "\r"   # 回车
  238.       return
  239.     when "\n"   # 换行
  240.       process_new_line(text, pos)
  241.     when "\f"   # 翻页
  242.       process_new_page(text, pos)
  243.     when "\e"   # 控制符
  244.       process_escape_character(obtain_escape_code(text), text, pos)
  245.     else        # 普通文字
  246.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  247.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  248.         process_new_line(text, pos)
  249.       end
  250.       process_normal_character(c, pos)
  251.     end
  252.   end
  253. end
  254.  
  255. class Window_ItemList < Window_Selectable
  256.   #--------------------------------------------------------------------------
  257.   # ● 更新帮助内容
  258.   #--------------------------------------------------------------------------
  259.   def update_help
  260.     @help_window.set_item(item)
  261.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  262.   end
  263. end
  264.  
  265. class Window_SkillList < Window_Selectable
  266.   #--------------------------------------------------------------------------
  267.   # ● 更新帮助内容
  268.   #--------------------------------------------------------------------------
  269.   def update_help
  270.     @help_window.set_item(item)
  271.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  272.   end
  273. end
  274.  
  275. class Window_ShopBuy < Window_Selectable
  276.   #--------------------------------------------------------------------------
  277.   # ● 更新帮助内容
  278.   #--------------------------------------------------------------------------
  279.   def update_help
  280.     @help_window.set_item(item) if @help_window
  281.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  282.     @status_window.item = item if @status_window
  283.   end
  284. end
  285.  
  286. class Window_EquipSlot < Window_Selectable
  287.   #--------------------------------------------------------------------------
  288.   # ● 更新帮助内容
  289.   #--------------------------------------------------------------------------
  290.   def update_help
  291.     super
  292.     @help_window.set_item(item) if @help_window
  293.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  294.     @status_window.set_temp_actor(nil) if @status_window
  295.   end
  296. end
  297.  
  298. class Scene_Shop < Scene_MenuBase
  299.         alias on_sell_ok_old on_sell_ok
  300.         def on_sell_ok
  301.                 on_sell_ok_old
  302.                 @help_window.hide
  303.         end
  304.         alias on_buy_ok_old on_buy_ok
  305.         def on_buy_ok
  306.                 on_buy_ok_old
  307.                 @help_window.hide
  308.         end
  309.         alias on_number_ok_old on_number_ok
  310.         def on_number_ok
  311.                 on_number_ok_old
  312.     @help_window.refresh
  313.                 @help_window.show
  314.         end
  315.         alias on_number_cancel_old on_number_cancel
  316.         def on_number_cancel
  317.                 on_number_cancel_old
  318.     @help_window.refresh
  319.                 @help_window.show
  320.         end
  321. end
  322.  
  323. class Scene_Title < Scene_Base
  324.   alias start_old start
  325.   def start
  326.     start_old
  327.     Equipplus.equiphelpready
  328.   end
  329. end
  330.  
  331. class Scene_ItemBase < Scene_MenuBase
  332.         alias old_on_actor_cancel on_actor_cancel
  333.   def on_actor_cancel
  334.     old_on_actor_cancel
  335.         @help_window.refresh
  336.   end
  337.         alias old_on_actor_ok on_actor_ok
  338.   def on_actor_ok
  339.     old_on_actor_ok
  340.         @help_window.refresh
  341.   end
  342. end
  343.  
  344. class Window_Base < Window
  345.         alias old_process_new_line process_new_line
  346.         def process_new_line(text, pos)
  347.     old_process_new_line(text, pos)
  348.                 pos[:height] = contents.font.size if pos[:width] != nil
  349.         end
  350. end
  351.  
  352. class Scene_MenuBase < Scene_Base
  353.   def create_help_window
  354.     @help_window = Window_Help2.new
  355.     @help_window.viewport = @viewport
  356.   end
  357. end
  358. class Scene_Battle < Scene_Base
  359.   def create_help_window
  360.     @help_window = Window_Help2.new
  361.     @help_window.visible = false
  362.   end
  363. end
  364. #==============================================================================
  365. # ■ Scene_Item
  366. #------------------------------------------------------------------------------
  367. #  选项重新定义
  368. #==============================================================================
  369. class Window_ItemCommand < Window_Command
  370.   #--------------------------------------------------------------------------
  371.   # ● 添加指令
  372.   #     color     : 指令字体颜色
  373.   #     icon_index: 指令图标
  374.   #     name      : 指令名称
  375.   #     symbol    : 对应的符号
  376.   #     enabled   : 有效状态的标志
  377.   #     ext       : 任意的扩展数据
  378.   #--------------------------------------------------------------------------
  379.   def add_command(name, symbol, enabled = true, color = Color.new(255,255,255) ,icon_index = 0 ,ext = nil)
  380.     @list.push({:color=>color, :icon_index=>icon_index, :name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # ● 获取指令字体颜色
  384.   #--------------------------------------------------------------------------
  385.   def command_color(index)
  386.     @list[index][:color]
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 获取指令图标
  390.   #--------------------------------------------------------------------------
  391.   def command_icon_index(index)
  392.     @list[index][:icon_index]
  393.   end
  394.   def draw_text_in_rect(rect, str,icon_index,enabled = true, align = 0)
  395.     draw_icon(icon_index, rect.x, rect.y, enabled)
  396.     if icon_index > 0
  397.       draw_text(rect.x + 24, rect.y, rect.width - 28, line_height,str)
  398.     else
  399.       draw_text(rect.x, rect.y, rect.width - 8, line_height,str)
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 绘制项目
  404.   #--------------------------------------------------------------------------
  405.   def draw_item(index)
  406.     change_color(command_color(index), command_enabled?(index))
  407.     draw_text_in_rect(item_rect_for_text(index), command_name(index),command_icon_index(index))   
  408.   end
  409. end
  410. #==============================================================================
  411. # ■ Window_ItemCommand
  412. #------------------------------------------------------------------------------
  413. #  物品画面中,显示装备选项的窗口。
  414. #==============================================================================
  415. class Window_ItemCommand < Window_Command
  416.   #--------------------------------------------------------------------------
  417.   # ● 初始化对象
  418.   #--------------------------------------------------------------------------
  419.   def initialize(item)
  420.     @item = item
  421.     super(0,0)
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # ● 获取窗口的宽度
  425.   #--------------------------------------------------------------------------
  426.   def window_width
  427.     return 160
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 获取列数
  431.   #--------------------------------------------------------------------------
  432.   def visible_line_number
  433.     return 4
  434.   end
  435.   def enable?
  436.     $game_party.usable?(@item)
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   # ● 生成指令列表
  440.   #--------------------------------------------------------------------------
  441.   def make_command_list
  442.     add_command("使用物品",   :use_item   , enable?,Color.new(11,168,3)   ,121)
  443.     add_command("卖出物品",   :sell_item  , enable?,Color.new(252,236,15) ,361)
  444.     add_command("丢弃物品",   :giveup_item, enable?,Color.new(242,119,14) ,227)
  445.     add_command("取消",       :cancel     , true   ,Color.new(173,164,156))
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 更新帮助位置
  449.   #--------------------------------------------------------------------------
  450.   def uppos(index,rect,window)
  451.     create_contents
  452.     clear_command_list
  453.     make_command_list
  454.     rect.x -= window.ox
  455.     rect.y -= window.oy
  456.     ax = rect.x + rect.width + 10
  457.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  458.     ax += window.x
  459.     ax = 0 if ax < 0
  460.     ay = rect.y + rect.height
  461.     ay = rect.y - self.height if ay + self.height > window.height
  462.     ay += window.y
  463.     ay = 0 if ay < 0
  464.     self.x = ax
  465.     self.y = ay
  466.     refresh
  467.     show
  468.   end
  469.  
  470. end
  471. #==============================================================================
  472. # ■ Window_ItemCategory
  473. #------------------------------------------------------------------------------
  474. #  物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
  475. #==============================================================================
  476. class Window_New_ItemCategory < Window_Command
  477.   #--------------------------------------------------------------------------
  478.   # ● 定义实例变量
  479.   #--------------------------------------------------------------------------
  480.   attr_reader   :item_window
  481.   #--------------------------------------------------------------------------
  482.   # ● 初始化对象
  483.   #--------------------------------------------------------------------------
  484.   def initialize
  485.     super(0,72)
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● 获取窗口的宽度
  489.   #--------------------------------------------------------------------------
  490.   def window_width
  491.     return 168
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 获取窗口的高度
  495.   #--------------------------------------------------------------------------
  496.   def window_height
  497.     return Graphics.height - 72
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● 更新画面
  501.   #--------------------------------------------------------------------------
  502.   def update
  503.     super
  504.     @item_window.category = current_symbol if @item_window
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● 生成指令列表
  508.   #--------------------------------------------------------------------------
  509.   def make_command_list
  510.     add_command("全部道具",     :none)
  511.     add_command("全部物品",     :item)
  512.     add_command("全部武器",   :weapon)
  513.     add_command("全部防具",   :armor)
  514.     add_command("消耗品",       :use_item)
  515.     for i in 0 ... $kind_of_item.size
  516.     add_command($kind_of_item[i],("kind_"+i.to_s).to_sym)
  517.     end
  518.     add_command(Vocab::key_item, :key_item)
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 设置物品窗口
  522.   #--------------------------------------------------------------------------
  523.   def item_window=(item_window)
  524.     @item_window = item_window
  525.     update
  526.   end
  527. end
  528. #==============================================================================
  529. # ■ Window_ItemList
  530. #------------------------------------------------------------------------------
  531. #  物品画面中,显示持有物品的窗口。
  532. #==============================================================================
  533. class Window_ItemList2 < Window_ItemList
  534.   #--------------------------------------------------------------------------
  535.   # ● 初始化对象
  536.   #--------------------------------------------------------------------------
  537.   def initialize(x, y, width, height)
  538.     super
  539.     @category = :none
  540.     @data = []
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # ● 获取列数
  544.   #--------------------------------------------------------------------------
  545.   def col_max
  546.     return 12
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 项目间隔
  550.   #--------------------------------------------------------------------------
  551.   def spacing
  552.     return 4
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ● 获取选择项目的有效状态
  556.   #--------------------------------------------------------------------------
  557.   def current_item_enabled?
  558.     true
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # ● 查询列表中是否含有此物品
  562.   #--------------------------------------------------------------------------
  563.   def include?(item)
  564.     case @category
  565.     when :none
  566.       true if item
  567.     when :item
  568.       item.is_a?(RPG::Item) && !item.key_item?
  569.     when :use_item
  570.       item.is_a?(RPG::Item) && !item.key_item? && item.consumable
  571.     when :weapon
  572.       item.is_a?(RPG::Weapon)
  573.     when :armor
  574.       item.is_a?(RPG::Armor)
  575.     when :key_item
  576.       item.is_a?(RPG::Item) && item.key_item?
  577.     else
  578.       if item.is_a?(RPG::Item)
  579.         a = @category.to_s[5,2]
  580.         return true if item.class_id == a.to_i
  581.       else
  582.         false
  583.       end
  584.     end
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 生成物品列表
  588.   #--------------------------------------------------------------------------
  589.   def make_item_list
  590.     @data = $game_party.all_items.select {|item| include?(item) }
  591.     @data.push(nil) if include?(nil)
  592.   end
  593.   #--------------------------------------------------------------------------
  594.   # ● 绘制项目
  595.   #--------------------------------------------------------------------------
  596.   def draw_item(index)
  597.     item = @data[index]
  598.     if item
  599.       rect = item_rect(index)
  600.       rect.width -= 4
  601.       draw_icon(item.icon_index, rect.x, rect.y, enable?(item))
  602.     end
  603.   end
  604. end
  605. #==============================================================================
  606. # ■ Window_Control_Number
  607. #------------------------------------------------------------------------------
  608. #  物品选择数量画面
  609. #==============================================================================
  610. class Window_Control_Number < Window_ShopNumber
  611.   #--------------------------------------------------------------------------
  612.   # ● 定义实例变量
  613.   #--------------------------------------------------------------------------
  614.   attr_reader   :number                   # 数量
  615.   #--------------------------------------------------------------------------
  616.   # ● 初始化
  617.   #--------------------------------------------------------------------------
  618.   def initialize(x,y,w,h)
  619.     @window_w = w
  620.     super(x,y,h)
  621.   end
  622.   #--------------------------------------------------------------------------
  623.   # ● 获取窗口的宽度
  624.   #--------------------------------------------------------------------------
  625.   def window_width
  626.     return @window_w
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● 计算窗口内容的宽度
  630.   #--------------------------------------------------------------------------
  631.   def contents_width
  632.     width - standard_padding * 2
  633.   end
  634.   #--------------------------------------------------------------------------
  635.   # ● 刷新
  636.   #--------------------------------------------------------------------------
  637.   def refresh
  638.     contents.clear
  639.     draw_item_name(@item, 4, 0)
  640.     draw_number
  641.     draw_total_price
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ● 绘制数量
  645.   #--------------------------------------------------------------------------
  646.   def draw_number
  647.     change_color(normal_color) # x = cursor_x - 28
  648.     draw_text(4, fitting_height(1)-12, 22, line_height, "×")
  649.     draw_text(32, fitting_height(1)-12, cursor_width - 4, line_height, @number, 2)
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # ● 绘制总价
  653.   #--------------------------------------------------------------------------
  654.   def draw_total_price
  655.     width = contents_width - 60
  656.     draw_currency_value(@price * @number, @currency_unit, 4, price_y + 8, width)
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● 更新光标
  660.   #--------------------------------------------------------------------------
  661.   def update_cursor
  662.     cursor_rect.set(32, fitting_height(1)-12, cursor_width - 4, line_height)
  663.   end
  664. end
  665. #==============================================================================
  666. # ■ Scene_Item
  667. #------------------------------------------------------------------------------
  668. #  物品画面
  669. #==============================================================================
  670. class Scene_Item < Scene_ItemBase
  671.   #--------------------------------------------------------------------------
  672.   # ● 开始处理
  673.   #--------------------------------------------------------------------------
  674.   def start
  675.     super
  676.     @control_kind = :none
  677.     create_help_window
  678.     create_category_window
  679.     create_item_window
  680.     create_item_logo
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # ● 生成Logo
  684.   #--------------------------------------------------------------------------
  685.   def create_item_logo
  686.     @logo_window = Window_Base.new(0,0,@category_window.width,Graphics.height - @category_window.height)
  687.     @logo_window.draw_icon(264,4,0)
  688.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  689.     @logo_window.make_font_smaller
  690.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  691.     @logo_window.make_font_bigger
  692.     @logo_window.viewport = @viewport
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ● 刷新Logo
  696.   #--------------------------------------------------------------------------
  697.   def refresh_item_logo
  698.     @logo_window.contents.clear
  699.     @logo_window.draw_icon(264,4,0)
  700.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  701.     @logo_window.make_font_smaller
  702.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  703.     @logo_window.make_font_bigger
  704.     @logo_window.viewport = @viewport
  705.   end
  706.   #--------------------------------------------------------------------------
  707.   # ● 生成控制数量
  708.   #--------------------------------------------------------------------------
  709.   def create_item_control_amount
  710.     x = 145
  711.     y = 140
  712.     w = Graphics.width - x * 2
  713.     h = Graphics.height - y * 2
  714.     @control_amount = Window_Control_Number.new(x,y,w,h)
  715.     @control_amount.viewport = @viewport
  716.     @control_amount.set_handler(:ok,   method(:on_item_control))
  717.     @control_amount.set_handler(:cancel,   method(:back_to_choose_item))
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 生成物品控制窗口
  721.   #--------------------------------------------------------------------------
  722.   def create_item_control
  723.     @item_control = Window_ItemCommand.new(item)
  724.     @item_control.viewport = @viewport
  725.     @item_control.set_handler(:use_item,   method(:on_item_use))
  726.     @item_control.set_handler(:sell_item,  method(:sell_item))
  727.     @item_control.set_handler(:giveup_item,method(:giveup_item))
  728.     @item_control.set_handler(:cancel,     method(:back_to_choose_item))
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ● 生成物品分类窗口
  732.   #--------------------------------------------------------------------------
  733.   def create_category_window
  734.     @category_window = Window_New_ItemCategory.new
  735.     @category_window.viewport = @viewport
  736.     @category_window.help_window = @help_window
  737.     @category_window.set_handler(:ok,     method(:on_category_ok))
  738.     @category_window.set_handler(:cancel, method(:return_scene))
  739.     @category_window.activate
  740.   end
  741.   #--------------------------------------------------------------------------
  742.   # ● 生成物品窗口
  743.   #--------------------------------------------------------------------------
  744.   def create_item_window
  745.     @item_window = Window_ItemList2.new(@category_window.width, 0, Graphics.width - @category_window.width, Graphics.height)
  746.     @item_window.help_window = @help_window
  747.     @item_window.viewport = @viewport
  748.     @item_window.set_handler(:ok,     method(:on_item_ok))
  749.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  750.     @category_window.item_window = @item_window
  751.     @item_window.refresh
  752.   end
  753.   #--------------------------------------------------------------------------
  754.   # ● 分类“确定”
  755.   #--------------------------------------------------------------------------
  756.   def on_category_ok
  757.     @item_window.activate
  758.     @item_window.select_last
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # ● 物品“确定”
  762.   #--------------------------------------------------------------------------
  763.   def on_item_ok
  764.     @help_window.hide
  765.     create_item_control
  766.     @item_control.uppos(@item_window.index,@item_window.item_rect(@item_window.index),@item_window)
  767.     @item_control.activate
  768.   end
  769.   #--------------------------------------------------------------------------
  770.   # ● 返回选择物品
  771.   #--------------------------------------------------------------------------
  772.   def back_to_choose_item
  773.     @control_amount.hide if @control_amount
  774.     @item_control.hide
  775.     @item_window.activate
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # ● 物品“取消”
  779.   #--------------------------------------------------------------------------
  780.   def on_item_cancel
  781.     @item_window.unselect
  782.     @category_window.activate
  783.   end
  784.   #--------------------------------------------------------------------------
  785.   # ● 播放使用物品声效
  786.   #--------------------------------------------------------------------------
  787.   def play_se_for_item
  788.     Sound.play_use_item
  789.   end
  790.   #--------------------------------------------------------------------------
  791.   # ● 卖出物品(选择数量)
  792.   #--------------------------------------------------------------------------
  793.   def sell_item
  794.     create_item_control_amount
  795.     @control_amount.set(item, max_sell, selling_price, currency_unit)
  796.     @control_amount.activate
  797.     @control_kind = :sell
  798.   end
  799.   #--------------------------------------------------------------------------
  800.   # ● 丢弃物品(选择数量)
  801.   #--------------------------------------------------------------------------
  802.   def giveup_item
  803.     create_item_control_amount
  804.     @control_amount.set(item, max_sell, 0, currency_unit)
  805.     @control_amount.activate
  806.     @control_kind = :giveup
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # ● 结束选择数量
  810.   #--------------------------------------------------------------------------
  811.   def on_item_control
  812.     case @control_kind
  813.     when :sell
  814.       do_sell(@control_amount.number)
  815.     when :giveup
  816.       do_giveup(@control_amount.number)
  817.     end
  818.     refresh_item_logo
  819.     @item_window.refresh
  820.     back_to_choose_item
  821.   end
  822.   #--------------------------------------------------------------------------
  823.   # ● 执行卖出
  824.   #--------------------------------------------------------------------------
  825.   def do_sell(number)
  826.     $game_party.gain_gold(number * selling_price)
  827.     $game_party.lose_item(item, number)
  828.   end
  829.   #--------------------------------------------------------------------------
  830.   # ● 执行丢弃
  831.   #--------------------------------------------------------------------------
  832.   def do_giveup(number)
  833.     $game_party.lose_item(item, number)
  834.   end
  835.   #--------------------------------------------------------------------------
  836.   # ● 获取货币单位
  837.   #--------------------------------------------------------------------------
  838.   def currency_unit
  839.     Vocab::currency_unit
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # ● 获取可以卖出的最大值
  843.   #--------------------------------------------------------------------------
  844.   def max_sell
  845.     $game_party.item_number(item)
  846.   end
  847.   #--------------------------------------------------------------------------
  848.   # ● 获取卖出价格
  849.   #--------------------------------------------------------------------------
  850.   def selling_price
  851.        item.price / 2
  852.   end
  853.   #--------------------------------------------------------------------------
  854.   # ● 使用物品(选择角色)
  855.   #--------------------------------------------------------------------------
  856.   def on_item_use
  857.     @item_control.hide
  858.     $game_party.last_item.object = item
  859.     determine_item
  860.   end
  861.   #--------------------------------------------------------------------------
  862.   # ● 使用物品
  863.   #--------------------------------------------------------------------------
  864.   def use_item
  865.     super
  866.     @item_window.redraw_current_item
  867.     refresh_item_logo
  868.   end
  869. end
愁死我了。。。。

Lv1.梦旅人

梦石
0
星屑
50
在线时间
87 小时
注册时间
2014-1-14
帖子
74
2
发表于 2014-1-25 14:50:36 | 只看该作者
价格设置为0,试试能不能卖?

点评

设置为零了,但是还是卖了  发表于 2014-1-25 15:00
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
243
在线时间
341 小时
注册时间
2010-9-5
帖子
70
3
发表于 2014-1-25 14:51:57 | 只看该作者
这个脚本和你说的好像没关系啊
这个脚本是物品详细显示 不是卖不卖东西的脚本
点击即可领养:
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
4
发表于 2014-1-25 15:25:39 | 只看该作者
事实上你完全可以删掉在背包里卖物品这一功能。PS:我记得我上回帮你修正过一个这个脚本的bug。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
5
发表于 2014-1-25 15:27:30 | 只看该作者
还有一种办法,你试试,把任务物品设成贵重物品,应该卖不了。

点评

还是卖了~  发表于 2014-1-25 16:30
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
6
发表于 2014-1-25 16:34:37 | 只看该作者
你非要这个背包卖物品这个功能吗?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
7
发表于 2014-1-25 17:03:42 | 只看该作者
可以删掉一些脚本这样这个功能就没了。

点评

不要的话,应该删哪啊?  发表于 2014-1-25 22:36
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
8
发表于 2014-1-26 07:14:09 | 只看该作者
  1. module Equipplus
  2.   CODE ={
  3.     11 => "属性抗性",
  4.     12 => "弱化抗性",
  5.     13 => "状态抗性",
  6.     14 => "状态免疫",
  7.     21 => "基本能力",
  8.     22 => "附加能力",
  9.     23 => "独有能力",
  10.     31 => "攻击附带属性",
  11.     32 => "攻击附带状态",
  12.     33 => "修正攻击速度",
  13.     34 => "添加攻击次数",
  14.     41 => "添加技能类型",
  15.     42 => "禁用技能类型",
  16.     43 => "添加技能",
  17.     44 => "禁用技能",
  18.     51 => "可装备武器类型",
  19.     52 => "可装备护甲类型",
  20.     53 => "固定装备",
  21.     54 => "禁用装备",
  22.     55 => "装备风格",
  23.     61 => "添加行动次数",
  24.     62 => "特殊标志",
  25.     63 => "消失效果",
  26.     64 => "队伍能力"}
  27.   #特殊标志
  28.   FLAG ={
  29.                 0 => "自动战斗",
  30.                 1 => "擅长防御",
  31.                 2 => "保护弱者",
  32.                 3 => "特技专注"}
  33.   #普通能力
  34.         PARAM ={
  35.                 0 => "血量上限",
  36.                 1 => "魔力上限",
  37.                 2 => "物理破坏力",
  38.                 3 => "物理防御力",
  39.                 4 => "魔法破坏力",
  40.                 5 => "魔法防御力",
  41.                 6 => "灵巧值",
  42.                 7 => "幸运值"}
  43.   #添加能力
  44.         XPARAM ={
  45.                 0 => "攻击率:",
  46.                 1 => "闪避率:",
  47.                 2 => "暴击率:",
  48.                 3 => "保护率:",
  49.                 4 => "魔力抵消率:",
  50.                 5 => "魔力克制率:",
  51.                 6 => "物理反击率:",
  52.                 7 => "伤口愈合率:",
  53.                 8 => "魔力产生率:",
  54.                 9 => "怒气攻心率:"}
  55.   #特殊能力
  56.         SPARAM ={
  57.                 0 => "受到攻击率",
  58.                 1 => "防御效果率",
  59.                 2 => "恢复效果率",
  60.                 3 => "药理知识",
  61.                 4 => "魔法熟练度",
  62.                 5 => "怒气释放率",
  63.                 6 => "物理攻击伤害加成",
  64.                 7 => "魔法攻击伤害加成",
  65.                 8 => "洞察能力",
  66.                 9 => "领悟能力"}
  67.         @队伍能力 ={
  68.                 0 => "霸气外露",
  69.                 1 => "随机遇敌无效",
  70.                 2 => "很高的警惕性",
  71.                 3 => "善于隐藏自己",
  72.                 4 => "财神附体",
  73.                 5 => "幸运女神"}
  74.   def self.equiphelpready
  75.     @状态 = {}
  76.     @武器类型 = {}
  77.     @防具类型 = {}
  78.     @属性 = {}
  79.     $data_states.each{|x| @状态[x.id] = x.name if x != nil}
  80.     elements = $data_system.elements
  81.     weapon_types = $data_system.weapon_types
  82.     armor_types = $data_system.armor_types
  83.     elements.each_with_index{|x,y| @属性[y] = x if x != ""}
  84.     weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
  85.     armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  86.   end
  87.   def self.getequiphelp(equip)
  88.     help = ""
  89.     param = []
  90.     equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}
  91.     param = param.select{|x| x[1] != 0}
  92.     param.each{|x| help += x[0] + ":" + x[1].to_int.to_s + "\n"}
  93.     features = equip.features
  94.     features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}
  95.     features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}
  96.     features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  97.     features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}
  98.     features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}
  99.     features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}
  100.     features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}
  101.     features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  102.     features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  103.     features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  104.     features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  105.     features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  106.     features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  107.     features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}
  108.     features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}
  109.     features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}
  110.     features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}
  111.     features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}
  112.     featuresparam = []
  113.     featuresparam.push features.select{|x| x.code == 21}
  114.     featuresparam.push features.select{|x| x.code == 22}
  115.     featuresparam.push features.select{|x| x.code == 23}
  116.     featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  117.     featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}
  118.     featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  119.     help
  120.   end
  121.   def self.getline(text,maxtext)
  122.     xtext = []
  123.     line = 0
  124.     text.each_line{|x| xtext.push x.sub(/\n/){}}
  125.     xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
  126.     line
  127.   end
  128. end
  129. #==============================================================================
  130. # ■ Window_Help
  131. #------------------------------------------------------------------------------
  132. #  显示特技和物品等的说明、以及角色状态的窗口
  133. #==============================================================================

  134. class Window_Help2 < Window_Base
  135.   #--------------------------------------------------------------------------
  136.   # ● 初始化对象
  137.   #--------------------------------------------------------------------------
  138.   def initialize(line_number = 0)
  139.     super(0, 0, 210, 0)
  140.     self.z = 150
  141.     contents.font.size = 20
  142.     hide
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 设置内容
  146.   #--------------------------------------------------------------------------
  147.   def set_text(text)
  148.       @text = text
  149.       refresh
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 清除
  153.   #--------------------------------------------------------------------------
  154.   def clear
  155.     set_text("")
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 更新帮助位置
  159.   #--------------------------------------------------------------------------
  160.   def uppos(index,rect,window)
  161.     self.height = fitting_height2(Equipplus.getline(@xtext,13))
  162.     create_contents
  163.     contents.font.size = 20
  164.     rect.x -= window.ox
  165.     rect.y -= window.oy
  166.     ax = rect.x + rect.width + 10
  167.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  168.     ax += window.x
  169.     ax = 0 if ax < 0
  170.     ay = rect.y + rect.height
  171.     ay = rect.y - self.height if ay + self.height > window.height
  172.     ay += window.y
  173.     ay = 0 if ay < 0
  174.     self.x = ax
  175.     self.y = ay
  176.     set_text(@xtext)
  177.     show
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 设置物品
  181.   #     item : 技能、物品等
  182.   #--------------------------------------------------------------------------
  183.   def set_item(item)
  184.     if item == nil
  185.       set_text("")
  186.       return
  187.     end
  188.     @xtext = ""
  189.     @xtext = "名称:" + item.name + "\n"
  190.     @xtext += "介绍:" + item.description + "\n"
  191.     @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  192.     @xtext += "持有:" + $game_party.item_number(item).to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  193.     @xtext += Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
  194.     @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 刷新
  198.   #--------------------------------------------------------------------------
  199.   def refresh
  200.     contents.clear
  201.     hide if @text == ""
  202.     draw_text_ex(4, 0, @text,width,40,false)
  203.   end
  204. end
  205. class Window_Base < Window
  206.   #--------------------------------------------------------------------------
  207.   # ● 计算窗口显示指定行数时的应用高度2*************************
  208.   #--------------------------------------------------------------------------
  209.   def fitting_height2(line_number)
  210.     line_number * contents.font.size + standard_padding * 2
  211.   end
  212. # draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  213.   #--------------------------------------------------------------------------
  214.   # ● 绘制带有控制符的文本内容
  215.   #   如果传递了width参数的话,会自动换行
  216.   #--------------------------------------------------------------------------
  217.   def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
  218.     reset_font_settings if normalfont == true
  219.     text = convert_escape_characters(text)
  220.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  221.     if width != nil
  222.       pos[:height] = contents.font.size
  223.       pos[:width] = width
  224.       pos[:textwidth] = textwidth
  225.     end
  226.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● 文字的处理
  230.   #     c    : 文字
  231.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  232.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  233.   #--------------------------------------------------------------------------
  234.   def process_character(c, text, pos)
  235.     case c
  236.     when "\r"   # 回车
  237.       return
  238.     when "\n"   # 换行
  239.       process_new_line(text, pos)
  240.     when "\f"   # 翻页
  241.       process_new_page(text, pos)
  242.     when "\e"   # 控制符
  243.       process_escape_character(obtain_escape_code(text), text, pos)
  244.     else        # 普通文字
  245.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  246.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  247.         process_new_line(text, pos)
  248.       end
  249.       process_normal_character(c, pos)
  250.     end
  251.   end
  252. end

  253. class Window_ItemList < Window_Selectable
  254.   #--------------------------------------------------------------------------
  255.   # ● 更新帮助内容
  256.   #--------------------------------------------------------------------------
  257.   def update_help
  258.     @help_window.set_item(item)
  259.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  260.   end
  261. end

  262. class Window_SkillList < Window_Selectable
  263.   #--------------------------------------------------------------------------
  264.   # ● 更新帮助内容
  265.   #--------------------------------------------------------------------------
  266.   def update_help
  267.     @help_window.set_item(item)
  268.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  269.   end
  270. end

  271. class Window_ShopBuy < Window_Selectable
  272.   #--------------------------------------------------------------------------
  273.   # ● 更新帮助内容
  274.   #--------------------------------------------------------------------------
  275.   def update_help
  276.     @help_window.set_item(item) if @help_window
  277.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  278.     @status_window.item = item if @status_window
  279.   end
  280. end

  281. class Window_EquipSlot < Window_Selectable
  282.   #--------------------------------------------------------------------------
  283.   # ● 更新帮助内容
  284.   #--------------------------------------------------------------------------
  285.   def update_help
  286.     super
  287.     @help_window.set_item(item) if @help_window
  288.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  289.     @status_window.set_temp_actor(nil) if @status_window
  290.   end
  291. end

  292. class Scene_Shop < Scene_MenuBase
  293.         alias on_sell_ok_old on_sell_ok
  294.         def on_sell_ok
  295.                 on_sell_ok_old
  296.                 @help_window.hide
  297.         end
  298.         alias on_buy_ok_old on_buy_ok
  299.         def on_buy_ok
  300.                 on_buy_ok_old
  301.                 @help_window.hide
  302.         end
  303.         alias on_number_ok_old on_number_ok
  304.         def on_number_ok
  305.                 on_number_ok_old
  306.     @help_window.refresh
  307.                 @help_window.show
  308.         end
  309.         alias on_number_cancel_old on_number_cancel
  310.         def on_number_cancel
  311.                 on_number_cancel_old
  312.     @help_window.refresh
  313.                 @help_window.show
  314.         end
  315. end

  316. class Scene_Title < Scene_Base
  317.   alias start_old start
  318.   def start
  319.     start_old
  320.     Equipplus.equiphelpready
  321.   end
  322. end

  323. class Scene_ItemBase < Scene_MenuBase
  324.         alias old_on_actor_cancel on_actor_cancel
  325.   def on_actor_cancel
  326.     old_on_actor_cancel
  327.         @help_window.refresh
  328.   end
  329.         alias old_on_actor_ok on_actor_ok
  330.   def on_actor_ok
  331.     old_on_actor_ok
  332.         @help_window.refresh
  333.   end
  334. end

  335. class Window_Base < Window
  336.         alias old_process_new_line process_new_line
  337.         def process_new_line(text, pos)
  338.     old_process_new_line(text, pos)
  339.                 pos[:height] = contents.font.size if pos[:width] != nil
  340.         end
  341. end

  342. class Scene_MenuBase < Scene_Base
  343.   def create_help_window
  344.     @help_window = Window_Help2.new
  345.     @help_window.viewport = @viewport
  346.   end
  347. end
  348. class Scene_Battle < Scene_Base
  349.   def create_help_window
  350.     @help_window = Window_Help2.new
  351.     @help_window.visible = false
  352.   end
  353. end
  354. #==============================================================================
  355. # ■ Scene_Item
  356. #------------------------------------------------------------------------------
  357. #  选项重新定义
  358. #==============================================================================
  359. class Window_ItemCommand < Window_Command
  360.   #--------------------------------------------------------------------------
  361.   # ● 添加指令
  362.   #     color     : 指令字体颜色
  363.   #     icon_index: 指令图标
  364.   #     name      : 指令名称
  365.   #     symbol    : 对应的符号
  366.   #     enabled   : 有效状态的标志
  367.   #     ext       : 任意的扩展数据
  368.   #--------------------------------------------------------------------------
  369.   def add_command(name, symbol, enabled = true, color = Color.new(255,255,255) ,icon_index = 0 ,ext = nil)
  370.     @list.push({:color=>color, :icon_index=>icon_index, :name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ● 获取指令字体颜色
  374.   #--------------------------------------------------------------------------
  375.   def command_color(index)
  376.     @list[index][:color]
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 获取指令图标
  380.   #--------------------------------------------------------------------------
  381.   def command_icon_index(index)
  382.     @list[index][:icon_index]
  383.   end
  384.   def draw_text_in_rect(rect, str,icon_index,enabled = true, align = 0)
  385.     draw_icon(icon_index, rect.x, rect.y, enabled)
  386.     if icon_index > 0
  387.       draw_text(rect.x + 24, rect.y, rect.width - 28, line_height,str)
  388.     else
  389.       draw_text(rect.x, rect.y, rect.width - 8, line_height,str)
  390.     end
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ● 绘制项目
  394.   #--------------------------------------------------------------------------
  395.   def draw_item(index)
  396.     change_color(command_color(index), command_enabled?(index))
  397.     draw_text_in_rect(item_rect_for_text(index), command_name(index),command_icon_index(index))   
  398.   end
  399. end
  400. #==============================================================================
  401. # ■ Scene_Item
  402. #------------------------------------------------------------------------------
  403. #  物品画面
  404. #==============================================================================
  405. class Scene_Item < Scene_ItemBase
  406.   #--------------------------------------------------------------------------
  407.   # ● 开始处理
  408.   #--------------------------------------------------------------------------
  409.   def start
  410.     super
  411.     @control_kind = :none
  412.     create_help_window
  413.     create_category_window
  414.     create_item_window
  415.     create_item_logo
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 生成Logo
  419.   #--------------------------------------------------------------------------
  420.   def create_item_logo
  421.     @logo_window = Window_Base.new(0,0,@category_window.width,Graphics.height - @category_window.height)
  422.     @logo_window.draw_icon(264,4,0)
  423.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  424.     @logo_window.make_font_smaller
  425.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  426.     @logo_window.make_font_bigger
  427.     @logo_window.viewport = @viewport
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 刷新Logo
  431.   #--------------------------------------------------------------------------
  432.   def refresh_item_logo
  433.     @logo_window.contents.clear
  434.     @logo_window.draw_icon(264,4,0)
  435.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  436.     @logo_window.make_font_smaller
  437.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  438.     @logo_window.make_font_bigger
  439.     @logo_window.viewport = @viewport
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ● 生成控制数量
  443.   #--------------------------------------------------------------------------
  444.   def create_item_control_amount
  445.     x = 145
  446.     y = 140
  447.     w = Graphics.width - x * 2
  448.     h = Graphics.height - y * 2
  449.     @control_amount = Window_Control_Number.new(x,y,w,h)
  450.     @control_amount.viewport = @viewport
  451.     @control_amount.set_handler(:ok,   method(:on_item_control))
  452.     @control_amount.set_handler(:cancel,   method(:back_to_choose_item))
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● 生成物品控制窗口
  456.   #--------------------------------------------------------------------------
  457.   def create_item_control
  458.     @item_control = Window_ItemCommand.new(item)
  459.     @item_control.viewport = @viewport
  460.     @item_control.set_handler(:use_item,   method(:on_item_use))
  461.     @item_control.set_handler(:sell_item,  method(:sell_item))
  462.     @item_control.set_handler(:giveup_item,method(:giveup_item))
  463.     @item_control.set_handler(:cancel,     method(:back_to_choose_item))
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 生成物品分类窗口
  467.   #--------------------------------------------------------------------------
  468.   def create_category_window
  469.     @category_window = Window_New_ItemCategory.new
  470.     @category_window.viewport = @viewport
  471.     @category_window.help_window = @help_window
  472.     @category_window.set_handler(:ok,     method(:on_category_ok))
  473.     @category_window.set_handler(:cancel, method(:return_scene))
  474.     @category_window.activate
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # ● 生成物品窗口
  478.   #--------------------------------------------------------------------------
  479.   def create_item_window
  480.     @item_window = Window_ItemList2.new(@category_window.width, 0, Graphics.width - @category_window.width, Graphics.height)
  481.     @item_window.help_window = @help_window
  482.     @item_window.viewport = @viewport
  483.     @item_window.set_handler(:ok,     method(:on_item_ok))
  484.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  485.     @category_window.item_window = @item_window
  486.     @item_window.refresh
  487.   end
  488.   #--------------------------------------------------------------------------
  489.   # ● 分类“确定”
  490.   #--------------------------------------------------------------------------
  491.   def on_category_ok
  492.     @item_window.activate
  493.     @item_window.select_last
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ● 物品“确定”
  497.   #--------------------------------------------------------------------------
  498.   def on_item_ok
  499.     @help_window.hide
  500.     create_item_control
  501.     @item_control.uppos(@item_window.index,@item_window.item_rect(@item_window.index),@item_window)
  502.     @item_control.activate
  503.   end
  504.   #--------------------------------------------------------------------------
  505.   # ● 返回选择物品
  506.   #--------------------------------------------------------------------------
  507.   def back_to_choose_item
  508.     @control_amount.hide if @control_amount
  509.     @item_control.hide
  510.     @item_window.activate
  511.   end
  512.   #--------------------------------------------------------------------------
  513.   # ● 物品“取消”
  514.   #--------------------------------------------------------------------------
  515.   def on_item_cancel
  516.     @item_window.unselect
  517.     @category_window.activate
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● 播放使用物品声效
  521.   #--------------------------------------------------------------------------
  522.   def play_se_for_item
  523.     Sound.play_use_item
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ● 结束选择数量
  527.   #--------------------------------------------------------------------------
  528.   def on_item_control
  529.     case @control_kind
  530.     when :sell
  531.       do_sell(@control_amount.number)
  532.     when :giveup
  533.       do_giveup(@control_amount.number)
  534.     end
  535.     refresh_item_logo
  536.     @item_window.refresh
  537.     back_to_choose_item
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 使用物品(选择角色)
  541.   #--------------------------------------------------------------------------
  542.   def on_item_use
  543.     @item_control.hide
  544.     $game_party.last_item.object = item
  545.     determine_item
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # ● 使用物品
  549.   #--------------------------------------------------------------------------
  550.   def use_item
  551.     super
  552.     @item_window.redraw_current_item
  553.     refresh_item_logo
  554.   end
  555. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
9
发表于 2014-1-26 07:14:47 | 只看该作者
你试一试有没有bug。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
121 小时
注册时间
2013-9-19
帖子
163
10
发表于 2014-1-26 10:49:34 | 只看该作者
  1. module Equipplus
  2.   CODE ={
  3.     11 => "属性抗性",
  4.     12 => "弱化抗性",
  5.     13 => "状态抗性",
  6.     14 => "状态免疫",
  7.     21 => "基本能力",
  8.     22 => "附加能力",
  9.     23 => "独有能力",
  10.     31 => "攻击附带属性",
  11.     32 => "攻击附带状态",
  12.     33 => "修正攻击速度",
  13.     34 => "添加攻击次数",
  14.     41 => "添加技能类型",
  15.     42 => "禁用技能类型",
  16.     43 => "添加技能",
  17.     44 => "禁用技能",
  18.     51 => "可装备武器类型",
  19.     52 => "可装备护甲类型",
  20.     53 => "固定装备",
  21.     54 => "禁用装备",
  22.     55 => "装备风格",
  23.     61 => "添加行动次数",
  24.     62 => "特殊标志",
  25.     63 => "消失效果",
  26.     64 => "队伍能力"}
  27.   #特殊标志
  28.   FLAG ={
  29.                 0 => "自动战斗",
  30.                 1 => "擅长防御",
  31.                 2 => "保护弱者",
  32.                 3 => "特技专注"}
  33.   #普通能力
  34.         PARAM ={
  35.                 0 => "血量上限",
  36.                 1 => "魔力上限",
  37.                 2 => "物理破坏力",
  38.                 3 => "物理防御力",
  39.                 4 => "魔法破坏力",
  40.                 5 => "魔法防御力",
  41.                 6 => "灵巧值",
  42.                 7 => "幸运值"}
  43.   #添加能力
  44.         XPARAM ={
  45.                 0 => "攻击率:",
  46.                 1 => "闪避率:",
  47.                 2 => "暴击率:",
  48.                 3 => "保护率:",
  49.                 4 => "魔力抵消率:",
  50.                 5 => "魔力克制率:",
  51.                 6 => "物理反击率:",
  52.                 7 => "伤口愈合率:",
  53.                 8 => "魔力产生率:",
  54.                 9 => "怒气攻心率:"}
  55.   #特殊能力
  56.         SPARAM ={
  57.                 0 => "受到攻击率",
  58.                 1 => "防御效果率",
  59.                 2 => "恢复效果率",
  60.                 3 => "药理知识",
  61.                 4 => "魔法熟练度",
  62.                 5 => "怒气释放率",
  63.                 6 => "物理攻击伤害加成",
  64.                 7 => "魔法攻击伤害加成",
  65.                 8 => "洞察能力",
  66.                 9 => "领悟能力"}
  67.         @队伍能力 ={
  68.                 0 => "霸气外露",
  69.                 1 => "随机遇敌无效",
  70.                 2 => "很高的警惕性",
  71.                 3 => "善于隐藏自己",
  72.                 4 => "财神附体",
  73.                 5 => "幸运女神"}
  74.   def self.equiphelpready
  75.     @状态 = {}
  76.     @武器类型 = {}
  77.     @防具类型 = {}
  78.     @属性 = {}
  79.     $data_states.each{|x| @状态[x.id] = x.name if x != nil}
  80.     elements = $data_system.elements
  81.     weapon_types = $data_system.weapon_types
  82.     armor_types = $data_system.armor_types
  83.     elements.each_with_index{|x,y| @属性[y] = x if x != ""}
  84.     weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
  85.     armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  86.   end
  87.   def self.getequiphelp(equip)
  88.     help = ""
  89.     param = []
  90.     equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}
  91.     param = param.select{|x| x[1] != 0}
  92.     param.each{|x| help += x[0] + ":" + x[1].to_int.to_s + "\n"}
  93.     features = equip.features
  94.     features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}
  95.     features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}
  96.     features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  97.     features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}
  98.     features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}
  99.     features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}
  100.     features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}
  101.     features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  102.     features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
  103.     features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  104.     features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
  105.     features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  106.     features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
  107.     features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}
  108.     features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}
  109.     features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}
  110.     features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}
  111.     features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}
  112.     featuresparam = []
  113.     featuresparam.push features.select{|x| x.code == 21}
  114.     featuresparam.push features.select{|x| x.code == 22}
  115.     featuresparam.push features.select{|x| x.code == 23}
  116.     featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  117.     featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}
  118.     featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}
  119.     help
  120.   end
  121.   def self.getline(text,maxtext)
  122.     xtext = []
  123.     line = 0
  124.     text.each_line{|x| xtext.push x.sub(/\n/){}}
  125.     xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
  126.     line
  127.   end
  128. end
  129. #==============================================================================
  130. # ■ Window_Help
  131. #------------------------------------------------------------------------------
  132. #  显示特技和物品等的说明、以及角色状态的窗口
  133. #==============================================================================

  134. class Window_Help2 < Window_Base
  135.   #--------------------------------------------------------------------------
  136.   # ● 初始化对象
  137.   #--------------------------------------------------------------------------
  138.   def initialize(line_number = 0)
  139.     super(0, 0, 210, 0)
  140.     self.z = 150
  141.     contents.font.size = 20
  142.     hide
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 设置内容
  146.   #--------------------------------------------------------------------------
  147.   def set_text(text)
  148.       @text = text
  149.       refresh
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 清除
  153.   #--------------------------------------------------------------------------
  154.   def clear
  155.     set_text("")
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 更新帮助位置
  159.   #--------------------------------------------------------------------------
  160.   def uppos(index,rect,window)
  161.     self.height = fitting_height2(Equipplus.getline(@xtext,13))
  162.     create_contents
  163.     contents.font.size = 20
  164.     rect.x -= window.ox
  165.     rect.y -= window.oy
  166.     ax = rect.x + rect.width + 10
  167.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  168.     ax += window.x
  169.     ax = 0 if ax < 0
  170.     ay = rect.y + rect.height
  171.     ay = rect.y - self.height if ay + self.height > window.height
  172.     ay += window.y
  173.     ay = 0 if ay < 0
  174.     self.x = ax
  175.     self.y = ay
  176.     set_text(@xtext)
  177.     show
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 设置物品
  181.   #     item : 技能、物品等
  182.   #--------------------------------------------------------------------------
  183.   def set_item(item)
  184.     if item == nil
  185.       set_text("")
  186.       return
  187.     end
  188.     @xtext = ""
  189.     @xtext = "名称:" + item.name + "\n"
  190.     @xtext += "介绍:" + item.description + "\n"
  191.     @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  192.     @xtext += "持有:" + $game_party.item_number(item).to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  193.     @xtext += Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
  194.     @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 刷新
  198.   #--------------------------------------------------------------------------
  199.   def refresh
  200.     contents.clear
  201.     hide if @text == ""
  202.     draw_text_ex(4, 0, @text,width,40,false)
  203.   end
  204. end
  205. class Window_Base < Window
  206.   #--------------------------------------------------------------------------
  207.   # ● 计算窗口显示指定行数时的应用高度2*************************
  208.   #--------------------------------------------------------------------------
  209.   def fitting_height2(line_number)
  210.     line_number * contents.font.size + standard_padding * 2
  211.   end
  212. # draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  213.   #--------------------------------------------------------------------------
  214.   # ● 绘制带有控制符的文本内容
  215.   #   如果传递了width参数的话,会自动换行
  216.   #--------------------------------------------------------------------------
  217.   def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
  218.     reset_font_settings if normalfont == true
  219.     text = convert_escape_characters(text)
  220.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  221.     if width != nil
  222.       pos[:height] = contents.font.size
  223.       pos[:width] = width
  224.       pos[:textwidth] = textwidth
  225.     end
  226.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● 文字的处理
  230.   #     c    : 文字
  231.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  232.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  233.   #--------------------------------------------------------------------------
  234.   def process_character(c, text, pos)
  235.     case c
  236.     when "\r"   # 回车
  237.       return
  238.     when "\n"   # 换行
  239.       process_new_line(text, pos)
  240.     when "\f"   # 翻页
  241.       process_new_page(text, pos)
  242.     when "\e"   # 控制符
  243.       process_escape_character(obtain_escape_code(text), text, pos)
  244.     else        # 普通文字
  245.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  246.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  247.         process_new_line(text, pos)
  248.       end
  249.       process_normal_character(c, pos)
  250.     end
  251.   end
  252. end

  253. class Window_ItemList < Window_Selectable
  254.   #--------------------------------------------------------------------------
  255.   # ● 更新帮助内容
  256.   #--------------------------------------------------------------------------
  257.   def update_help
  258.     @help_window.set_item(item)
  259.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  260.   end
  261. end

  262. class Window_SkillList < Window_Selectable
  263.   #--------------------------------------------------------------------------
  264.   # ● 更新帮助内容
  265.   #--------------------------------------------------------------------------
  266.   def update_help
  267.     @help_window.set_item(item)
  268.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  269.   end
  270. end

  271. class Window_ShopBuy < Window_Selectable
  272.   #--------------------------------------------------------------------------
  273.   # ● 更新帮助内容
  274.   #--------------------------------------------------------------------------
  275.   def update_help
  276.     @help_window.set_item(item) if @help_window
  277.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  278.     @status_window.item = item if @status_window
  279.   end
  280. end

  281. class Window_EquipSlot < Window_Selectable
  282.   #--------------------------------------------------------------------------
  283.   # ● 更新帮助内容
  284.   #--------------------------------------------------------------------------
  285.   def update_help
  286.     super
  287.     @help_window.set_item(item) if @help_window
  288.     @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
  289.     @status_window.set_temp_actor(nil) if @status_window
  290.   end
  291. end

  292. class Scene_Shop < Scene_MenuBase
  293.         alias on_sell_ok_old on_sell_ok
  294.         def on_sell_ok
  295.                 on_sell_ok_old
  296.                 @help_window.hide
  297.         end
  298.         alias on_buy_ok_old on_buy_ok
  299.         def on_buy_ok
  300.                 on_buy_ok_old
  301.                 @help_window.hide
  302.         end
  303.         alias on_number_ok_old on_number_ok
  304.         def on_number_ok
  305.                 on_number_ok_old
  306.     @help_window.refresh
  307.                 @help_window.show
  308.         end
  309.         alias on_number_cancel_old on_number_cancel
  310.         def on_number_cancel
  311.                 on_number_cancel_old
  312.     @help_window.refresh
  313.                 @help_window.show
  314.         end
  315. end

  316. class Scene_Title < Scene_Base
  317.   alias start_old start
  318.   def start
  319.     start_old
  320.     Equipplus.equiphelpready
  321.   end
  322. end

  323. class Scene_ItemBase < Scene_MenuBase
  324.         alias old_on_actor_cancel on_actor_cancel
  325.   def on_actor_cancel
  326.     old_on_actor_cancel
  327.         @help_window.refresh
  328.   end
  329.         alias old_on_actor_ok on_actor_ok
  330.   def on_actor_ok
  331.     old_on_actor_ok
  332.         @help_window.refresh
  333.   end
  334. end

  335. class Window_Base < Window
  336.         alias old_process_new_line process_new_line
  337.         def process_new_line(text, pos)
  338.     old_process_new_line(text, pos)
  339.                 pos[:height] = contents.font.size if pos[:width] != nil
  340.         end
  341. end

  342. class Scene_MenuBase < Scene_Base
  343.   def create_help_window
  344.     @help_window = Window_Help2.new
  345.     @help_window.viewport = @viewport
  346.   end
  347. end
  348. class Scene_Battle < Scene_Base
  349.   def create_help_window
  350.     @help_window = Window_Help2.new
  351.     @help_window.visible = false
  352.   end
  353. end
  354. #==============================================================================
  355. # ■ Scene_Item
  356. #------------------------------------------------------------------------------
  357. #  选项重新定义
  358. #==============================================================================
  359. class Window_ItemCommand < Window_Command
  360.   #--------------------------------------------------------------------------
  361.   # ● 添加指令
  362.   #     color     : 指令字体颜色
  363.   #     icon_index: 指令图标
  364.   #     name      : 指令名称
  365.   #     symbol    : 对应的符号
  366.   #     enabled   : 有效状态的标志
  367.   #     ext       : 任意的扩展数据
  368.   #--------------------------------------------------------------------------
  369.   def add_command(name, symbol, enabled = true, color = Color.new(255,255,255) ,icon_index = 0 ,ext = nil)
  370.     @list.push({:color=>color, :icon_index=>icon_index, :name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ● 获取指令字体颜色
  374.   #--------------------------------------------------------------------------
  375.   def command_color(index)
  376.     @list[index][:color]
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 获取指令图标
  380.   #--------------------------------------------------------------------------
  381.   def command_icon_index(index)
  382.     @list[index][:icon_index]
  383.   end
  384.   def draw_text_in_rect(rect, str,icon_index,enabled = true, align = 0)
  385.     draw_icon(icon_index, rect.x, rect.y, enabled)
  386.     if icon_index > 0
  387.       draw_text(rect.x + 24, rect.y, rect.width - 28, line_height,str)
  388.     else
  389.       draw_text(rect.x, rect.y, rect.width - 8, line_height,str)
  390.     end
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ● 绘制项目
  394.   #--------------------------------------------------------------------------
  395.   def draw_item(index)
  396.     change_color(command_color(index), command_enabled?(index))
  397.     draw_text_in_rect(item_rect_for_text(index), command_name(index),command_icon_index(index))   
  398.   end
  399. end
  400. #==============================================================================
  401. # ■ Scene_Item
  402. #------------------------------------------------------------------------------
  403. #  物品画面
  404. #==============================================================================
  405. class Scene_Item < Scene_ItemBase
  406.   #--------------------------------------------------------------------------
  407.   # ● 开始处理
  408.   #--------------------------------------------------------------------------
  409.   def start
  410.     super
  411.     @control_kind = :none
  412.     create_help_window
  413.     create_category_window
  414.     create_item_window
  415.     create_item_logo
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 生成Logo
  419.   #--------------------------------------------------------------------------
  420.   def create_item_logo
  421.     @logo_window = Window_Base.new(0,0,@category_window.width,Graphics.height - @category_window.height)
  422.     @logo_window.draw_icon(264,4,0)
  423.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  424.     @logo_window.make_font_smaller
  425.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  426.     @logo_window.make_font_bigger
  427.     @logo_window.viewport = @viewport
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 刷新Logo
  431.   #--------------------------------------------------------------------------
  432.   def refresh_item_logo
  433.     @logo_window.contents.clear
  434.     @logo_window.draw_icon(264,4,0)
  435.     @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
  436.     @logo_window.make_font_smaller
  437.     @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
  438.     @logo_window.make_font_bigger
  439.     @logo_window.viewport = @viewport
  440.   end
  441.   #--------------------------------------------------------------------------
  442.   # ● 生成控制数量
  443.   #--------------------------------------------------------------------------
  444.   def create_item_control_amount
  445.     x = 145
  446.     y = 140
  447.     w = Graphics.width - x * 2
  448.     h = Graphics.height - y * 2
  449.     @control_amount = Window_Control_Number.new(x,y,w,h)
  450.     @control_amount.viewport = @viewport
  451.     @control_amount.set_handler(:ok,   method(:on_item_control))
  452.     @control_amount.set_handler(:cancel,   method(:back_to_choose_item))
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● 生成物品控制窗口
  456.   #--------------------------------------------------------------------------
  457.   def create_item_control
  458.     @item_control = Window_ItemCommand.new(item)
  459.     @item_control.viewport = @viewport
  460.     @item_control.set_handler(:use_item,   method(:on_item_use))
  461.     @item_control.set_handler(:cancel,     method(:back_to_choose_item))
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 生成物品分类窗口
  465.   #--------------------------------------------------------------------------
  466.   def create_category_window
  467.     @category_window = Window_New_ItemCategory.new
  468.     @category_window.viewport = @viewport
  469.     @category_window.help_window = @help_window
  470.     @category_window.set_handler(:ok,     method(:on_category_ok))
  471.     @category_window.set_handler(:cancel, method(:return_scene))
  472.     @category_window.activate
  473.   end
  474.   #--------------------------------------------------------------------------
  475.   # ● 生成物品窗口
  476.   #--------------------------------------------------------------------------
  477.   def create_item_window
  478.     @item_window = Window_ItemList2.new(@category_window.width, 0, Graphics.width - @category_window.width, Graphics.height)
  479.     @item_window.help_window = @help_window
  480.     @item_window.viewport = @viewport
  481.     @item_window.set_handler(:ok,     method(:on_item_ok))
  482.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  483.     @category_window.item_window = @item_window
  484.     @item_window.refresh
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● 分类“确定”
  488.   #--------------------------------------------------------------------------
  489.   def on_category_ok
  490.     @item_window.activate
  491.     @item_window.select_last
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # ● 物品“确定”
  495.   #--------------------------------------------------------------------------
  496.   def on_item_ok
  497.     @help_window.hide
  498.     create_item_control
  499.     @item_control.uppos(@item_window.index,@item_window.item_rect(@item_window.index),@item_window)
  500.     @item_control.activate
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● 返回选择物品
  504.   #--------------------------------------------------------------------------
  505.   def back_to_choose_item
  506.     @control_amount.hide if @control_amount
  507.     @item_control.hide
  508.     @item_window.activate
  509.   end
  510.   #--------------------------------------------------------------------------
  511.   # ● 物品“取消”
  512.   #--------------------------------------------------------------------------
  513.   def on_item_cancel
  514.     @item_window.unselect
  515.     @category_window.activate
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● 播放使用物品声效
  519.   #--------------------------------------------------------------------------
  520.   def play_se_for_item
  521.     Sound.play_use_item
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # ● 结束选择数量
  525.   #--------------------------------------------------------------------------
  526.   def on_item_control
  527.     case @control_kind
  528.     when :sell
  529.       do_sell(@control_amount.number)
  530.     when :giveup
  531.       do_giveup(@control_amount.number)
  532.     end
  533.     refresh_item_logo
  534.     @item_window.refresh
  535.     back_to_choose_item
  536.   end
  537.   #--------------------------------------------------------------------------
  538.   # ● 使用物品(选择角色)
  539.   #--------------------------------------------------------------------------
  540.   def on_item_use
  541.     @item_control.hide
  542.     $game_party.last_item.object = item
  543.     determine_item
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # ● 使用物品
  547.   #--------------------------------------------------------------------------
  548.   def use_item
  549.     super
  550.     @item_window.redraw_current_item
  551.     refresh_item_logo
  552.   end
  553. end
复制代码
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-5 20:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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