Project1

标题: 这个物品详细说明脚本如何让他在战斗中也能显示? [打印本页]

作者: sxjkjly8010    时间: 2021-7-22 02:28
标题: 这个物品详细说明脚本如何让他在战斗中也能显示?
RUBY 代码复制
  1. #===============================================================================
  2. #物品界面、技能界面按SHIFT打开介绍窗口
  3. #2019/1/14   By:真·可乐
  4. #===============================================================================
  5.  
  6. module ZCL_Detail_Set
  7.   #窗口的皮肤名称
  8.   WINDOWSKILL = "Window"
  9.   #窗口的宽度
  10.   WWIDTH = Graphics.width / 2.3
  11.   #窗口的高度
  12.   WHEIGHT = Graphics.height / 1.5
  13.   #窗口物品名称栏的背景色,最后一项是不透明度,填成0的话就没颜色了
  14.   ITEMNAMEBACKCOLOR = [0,255,0,100]
  15.   #禁用设定 , 1 为禁用 物品界面细明窗口 ,2 为禁用 技能界面细明窗口 , 3 为全部禁用
  16.   DISABLE = 0
  17. end
  18.  
  19.  
  20. module RPG
  21.   class BaseItem
  22.     def detail
  23.       /\[de\](.*)\[ta\]/ =~ self.note
  24.       return ($1.is_a?(String) ? $1 : "")
  25.     end
  26.   end
  27. end
  28.  
  29. class Window_Detail < Window_Base
  30.   attr_accessor           :item
  31.   include ZCL_Detail_Set
  32.   def initialize(y)
  33.     super(x = 0,y,WWIDTH,WHEIGHT)
  34.     self.windowskin = Cache.system(WINDOWSKILL)
  35.     @item = nil
  36.   end
  37.  
  38.   def refresh
  39.     self.contents.clear
  40.     return self.hide if @item.nil?
  41.     co = ITEMNAMEBACKCOLOR
  42.     contents.fill_rect(0,0,self.width,32,Color.new(co[0],co[1],co[2],co[3]))
  43.     text = @item.detail.gsub("\\n"){"\n"}
  44.     draw_item_name(@item,0,2,true);draw_text_ex(0,36,text)
  45.   end
  46.  
  47.   def item=(titem)
  48.     @item = titem
  49.     self.refresh
  50.   end
  51. end
  52.  
  53. class Scene_ItemBase
  54.   attr_reader   :detail_window
  55.   alias startzcl2019114 start
  56.   def start
  57.     startzcl2019114;create_detail_window
  58.   end
  59.  
  60.   def create_detail_window
  61.     @detail_window = Window_Detail.new(0)
  62.  
  63.     @detail_window.hide
  64.   end
  65.    alias updatezcl2019114 update
  66.   def update
  67.     updatezcl2019114
  68.     update_detail
  69.   end
  70.  
  71.   def update_detail
  72.   return @detail_window.hide unless @item_window.active
  73.     if Input.trigger?(Input::A)
  74.       return if self.is_a?(Scene_Item) && ZCL_Detail_Set::DISABLE == 1
  75.       return if self.is_a?(Scene_Skill) && ZCL_Detail_Set::DISABLE == 2
  76.       return unless ZCL_Detail_Set::DISABLE.between?(0,2)
  77.       refresh_detail_window;end
  78.     @detail_window.hide if Input.trigger?(:UP) || Input.trigger?(:DOWN) ||
  79.        Input.trigger?(:LEFT) || Input.trigger?(:RIGHT)
  80.    end
  81.  
  82.    def refresh_detail_window
  83.     if @item_window.item.nil?
  84.       @detail_window.hide
  85.       return Sound.play_buzzer
  86.     end
  87.      @detail_window.y = @item_window.y
  88.      @detail_window.z = @item_window.z + 100
  89.      @detail_window.height =  [Graphics.height - @detail_window.y , ZCL_Detail_Set::WHEIGHT ].min
  90.      @detail_window.create_contents
  91.       wx = Graphics.width/2 + (@item_window.index % 2 == 0 ? 0 : -@detail_window.width)
  92.       @detail_window.item = @item_window.item
  93.       @detail_window.x = wx
  94.       Sound.play_ok
  95.       @detail_window.visible = !@detail_window.visible
  96.     end
  97.  
  98.     alias use_itemzcl2019114 use_item
  99.     def use_item
  100.       use_itemzcl2019114
  101.       refresh_detail_window
  102.     end
  103. end


这个物品详细说明可以很好的解决不够写说明的问题,但是突然发现在战斗中,这个说明窗口不起作用,应该如何进行更改?
作者: alexncf125    时间: 2021-7-22 05:25
本帖最后由 alexncf125 于 2021-7-22 05:29 编辑

去Scene_Battle复制一遍这脚本的54-102行, 不就行了么




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1