Project1

标题: 技能消耗物品腳本 [打印本页]

作者: 99308013    时间: 2014-8-21 17:46
标题: 技能消耗物品腳本
我又來了><
想請問下,我從論壇下了技能消耗物品腳本,但是護甲圖標會蓋到技能名稱,弄了好久弄不好,特此請教!
以及,該怎麼讓圖標顯示得清楚一點?現在是有一點淡化的感覺


感激不盡!


RUBY 代码复制
  1. module IISNOW_ITEM_CONSUME_SKILL
  2.  
  3.   PATTERN = /.*ITEM:ID(\d+)NUM(\d+)(.*)/m  
  4.   # 非专业人士请勿修改,正则匹配式,修改后注意备注写法的改变,下同
  5.   PATTERN_E = /.*EQU:ID(\d+).*/m
  6.   PATTERN_A = /.*ARM:ID(\d+).*/m
  7.   STR_UN_CONSUM = "UN" # 物品不消耗标识
  8.  
  9.   TP_ICON = 189  # 你说你懂的
  10.   MP_ICON = 188
  11.  
  12.   STYLE = 1 # 界面风格(支持1,2,3,4效果自己体会,不推荐4)
  13.   STYLE_A = 1 # 提示风格(支持1,2,3,同上)
  14.   PLACE = 3 # 消耗物品的图标与数目间的间距
  15.   PLACE_E = 2 # 不同消耗物品间的间距
  16.   ORDER = [0,1,2]     # 从右往左的消耗显示顺序(0,TP;1,MP;2,物品)
  17.  
  18.   COLOR_ITEM = Color.new(255,255,255) # 物品消耗数目的字的颜色
  19.   COLOR_WE_L = Color.new(255,0,0) # 具体限定武器的框的颜色
  20.   COLOR_WE_A = Color.new(255,0,0) # 具体限定防具的框的颜色
  21.   COLOR_UN_I = Color.new(0,255,0) # 物品限定但不消耗的提示框的颜色
  22.  
  23.   TRAN_DE = 100 # 风格_A2下的透明度再次降低(最大为160)
  24. end
  25.  
  26. class Window_SkillList
  27.  
  28.   include IISNOW_ITEM_CONSUME_SKILL
  29.  
  30.   def col_max
  31.     case STYLE
  32.     when 1,3,4
  33.       return 2
  34.     when 2
  35.       return 1
  36.     end
  37.   end
  38.  
  39.   def item_height
  40.     case STYLE
  41.     when 3
  42.       line_height * 2
  43.     when 1,2,4
  44.       line_height + 1
  45.     end
  46.   end
  47.  
  48.   def draw_item(index)
  49.     skill = @data[index]
  50.     if skill
  51.       rect = item_rect(index)
  52.       rect.width -= 4
  53.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  54.       draw_skill_cost(rect, skill)
  55.     end
  56.   end
  57.  
  58.   alias :iisnow_draw_item_name :draw_item_name
  59.   def draw_item_name(item, x, y, enabled = true, width = 172)
  60.     iisnow_draw_item_name(item, x, y, enabled,width)
  61.     rect_temp = text_size(item.name)
  62.     if @actor.skill_eq_limt(item)
  63.       draw_kuang(x + 24 + PLACE  + rect_temp.width,y,24,24,COLOR_WE_L,enabled)
  64.       draw_icon(@actor.skill_eq_limt(item).icon_index,x + 24 + PLACE + rect_temp.width,y,enabled)
  65.       rect_temp.width += (24 + PLACE_E)
  66.     end
  67.     if @actor.skill_ar_limt(item)
  68.       draw_kuang(x + 24 + PLACE + rect_temp.width,y,24,24,COLOR_WE_A,enabled)
  69.       draw_icon(@actor.skill_ar_limt(item).icon_index,x + 24 + PLACE + rect_temp.width,y,enabled)
  70.     end
  71.   end
  72.  
  73.   def draw_skill_cost(rect, skill)
  74.     str = create_string(skill)
  75.     color = [tp_cost_color,mp_cost_color,COLOR_ITEM]
  76.     str.each_with_index do |str,i|
  77.       next unless str
  78.       change_color(color[ORDER[i]], enable?(skill))
  79.       kuang = false
  80.       case i
  81.       when ORDER.index(2)
  82.         icon_index = str[0].icon_index
  83.         kuang = true if str[2]
  84.         str = str[1]
  85.       when ORDER.index(1)
  86.         icon_index = MP_ICON
  87.       when ORDER.index(0)
  88.         icon_index = TP_ICON
  89.       end
  90.       contents.font.size = STYLE == 1 ? Font.default_size - 6 : Font.default_size
  91.       draw_style(icon_index,rect,str,skill,kuang)
  92.     end
  93.     contents.font.size = Font.default_size
  94.   end
  95.  
  96.   def draw_style(icon_index,rect,str,skill,kuang)
  97.     case STYLE
  98.     when 1
  99.       draw_kuang(rect.width - 24 + rect.x,rect.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
  100.       draw_icon(icon_index,rect.width - 24 + rect.x,rect.y,enable?(skill))
  101.       draw_text(Rect.new(rect.x + rect.width - 24,rect.y + 8,24,16),str,2) if str.to_i != 1
  102.       rect.width -= (30 + PLACE_E)
  103.     when 2,4
  104.       draw_text(rect,str,2) if str.to_i != 1
  105.       rect.width -= (text_size(str).width + PLACE) if str.to_i != 1
  106.       draw_kuang(rect.width - 24 + rect.x,rect.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
  107.       draw_icon(icon_index,rect.width - 24 + rect.x,rect.y,enable?(skill))
  108.       rect.width -= (24 + PLACE_E)
  109.     when 3
  110.       rect_temp = rect.clone
  111.       rect_temp.y += (rect_temp.height / 2)
  112.       rect_temp.height /= 2
  113.       draw_text(rect_temp,str,2) if str.to_i != 1
  114.       rect.width -= (text_size(str).width + PLACE) if str.to_i != 1
  115.       draw_kuang(rect.width - 24 + rect.x,rect_temp.y,24,24,COLOR_UN_I,enable?(skill)) if kuang
  116.       draw_icon(icon_index,rect.width - 24 + rect.x,rect_temp.y,enable?(skill))
  117.       rect.width -= (24 + PLACE_E)
  118.     end
  119.   end
  120.  
  121.   def draw_kuang(x,y,w,h,c,fl)
  122.     c.alpha = fl ? 255 : translucent_alpha - (STYLE_A == 2 ? TRAN_DE : 0)
  123.     case STYLE_A
  124.     when 1
  125.       contents.fill_rect(x,y,w,1,c)
  126.       contents.fill_rect(x,y + 1,1,h - 1,c)
  127.       contents.fill_rect(x + 1,y + h - 1,w - 1,1,c)
  128.       contents.fill_rect(x + w -1,y + 1,1,h - 2,c)
  129.     when 2
  130.       contents.fill_rect(x,y,w,h,c)
  131.     end
  132.   end
  133.  
  134.   def create_string(skill)
  135.     str1 = @actor.skill_tp_cost(skill)
  136.     str2 = @actor.skill_mp_cost(skill)
  137.     str3 = @actor.skill_it_cost(skill)
  138.     str1 = str1 > 0 ?  str1.to_s : nil
  139.     str2 = str2 > 0 ?  str2.to_s : nil
  140.     str3 = str3[1] > 0 ? [str3[0],str3[1].to_s,str3[2]] : nil
  141.     str = [str1,str2,str3]
  142.     iisnow = [str[ORDER[0]],str[ORDER[1]],str[ORDER[2]]]
  143.     iisnow
  144.   end
  145.  
  146. end
  147.  
  148. class Game_BattlerBase
  149.  
  150.   include IISNOW_ITEM_CONSUME_SKILL
  151.  
  152.   def skill_it_cost(skill)
  153.     skill.note.match(PATTERN)
  154.     item = $data_items[$1.to_i] if $1 != 0
  155.     num = $2.to_i
  156.     flag = $3.match(/^#{STR_UN_CONSUM}/) if $3
  157.     return [item,num,flag]
  158.   end
  159.  
  160.   def skill_eq_limt(skill)
  161.     skill.note.match(PATTERN_E)
  162.     eq = $data_weapons[$1.to_i] if $1 != 0
  163.     return eq
  164.   end
  165.  
  166.   def skill_ar_limt(skill)
  167.     skill.note.match(PATTERN_A)
  168.     eq = $data_armors[$1.to_i] if $1 != 0
  169.     return eq
  170.   end
  171.  
  172.   alias :iisnow_skill_cost_payable? :skill_cost_payable?
  173.   def skill_cost_payable?(skill)
  174.     result1 = iisnow_skill_cost_payable?(skill)
  175.     if skill_it_cost(skill)[0]
  176.       result2 = $game_party.item_number(skill_it_cost(skill)[0]) >= skill_it_cost(skill)[1]
  177.       return result1 && result2
  178.     end
  179.     return result1
  180.   end
  181.  
  182.   alias :iisnow_pay_skill_cost :pay_skill_cost
  183.   def pay_skill_cost(skill)
  184.     iisnow_pay_skill_cost(skill)
  185.     if skill_it_cost(skill)[0] && !skill_it_cost(skill)[2]
  186.       $game_party.gain_item(skill_it_cost(skill)[0],-skill_it_cost(skill)[1])
  187.     end
  188.   end
  189.  
  190. end
  191.  
  192. class Game_Actor
  193.  
  194.   alias :iisnow_skill_wtype_ok? :skill_wtype_ok?
  195.   def skill_wtype_ok?(skill)
  196.     result1 = iisnow_skill_wtype_ok?(skill)
  197.     result2 = skill_eq_limt(skill) ? weapons.include?(skill_eq_limt(skill)) : true
  198.     result3 = skill_ar_limt(skill) ? armors.include?(skill_ar_limt(skill)) : true
  199.     return result1 && result2 && result3
  200.   end
  201.  
  202. end

作者: 千夙    时间: 2014-8-21 17:52
  1. 14.PLACE = 3 # 消耗物品的图标与数目间的间距
复制代码
  1. 23.TRAN_DE = 100 # 风格_A2下的透明度再次降低(最大为160)
复制代码





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