Advertisement
MrTrivel

MrTS_Item_Info

Jun 5th, 2014
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.83 KB | None | 0 0
  1. # )-------------------------------------------(
  2. # )--     Author:     Mr Trivel             --(
  3. # )--     Name:       Item Info             --(
  4. # )--     Created:    2014-06-05            --(
  5. # )--     Version:    1.01                  --(
  6. # )-------------------------------------------(
  7. # )--     Requires:   None                  --(
  8. # )-------------------------------------------(
  9. # )--             Description               --(
  10. # )-- This script expands Item List in the  --(
  11. # )-- Item Menu, giving it a bigger         --(
  12. # )-- description window that shows more    --(
  13. # )-- data, like attack type, value,        --(
  14. # )-- immunity, buffs, debuffs, etc...      --(
  15. # )-------------------------------------------(
  16. # )--             Instructions              --(
  17. # )--Plug & Play or Plug -> Customize & Play--(
  18. # )---------------------------------------------------(
  19. # )--             LICENSE INFO                      --(
  20. # )-- http://mrtrivelvx.wordpress.com/terms-of-use/ --(
  21. # )---------------------------------------------------(
  22. # )-- Version history:                      --(
  23. # )-- v1.01 - Added indicators who can equip--(
  24. # )-- the armor/weapon.                     --(
  25. # )-------------------------------------------(
  26.  
  27. module MrTS
  28.   module MrTS_Item_Info
  29.    
  30.     # )-------------------------------------(
  31.     # )-- Hashes (leave this)             --(
  32.     # )-------------------------------------(
  33.     Icon_list = {}
  34.     Text_list = {}
  35.     Element_list = {}
  36.    
  37.     # )-------------------------------------(
  38.     # )--     Customize stat names here   --(
  39.     # )-------------------------------------(
  40.     # )--     Parameters                  --(
  41.     # )-------------------------------------(
  42.     STATS = [ "MHP: ",
  43.               "MMP: ",
  44.               "ATK: ",
  45.               "DEF: ",
  46.               "MAT: ",
  47.               "MDF: ",
  48.               "AGI: ",
  49.               "LUK: " ]
  50.              
  51.     # )-------------------------------------(
  52.     # )--      Ex-Parameters              --(
  53.     # )-------------------------------------(    
  54.     XSTATS = [ "HIT: ",
  55.                "EVA: ",
  56.                "CRI: ",
  57.                "CEV: ",
  58.                "MEV: ",
  59.                "MRF: ",
  60.                "CNT: ",
  61.                "HRG: ",
  62.                "MRG: ",
  63.                "TRG: " ]
  64.    
  65.     # )-------------------------------------(
  66.     # )-- Number of colums for items      --(
  67.     # )-------------------------------------(
  68.     COLUMNS = 3
  69.    
  70.     # )-------------------------------------(
  71.     # )--Icon list - Change to your liking--(
  72.     # )-------------------------------------(
  73.     Icon_list[11] = 112 # Health Recovery
  74.     Icon_list[12] = 121 # Mana Recovery
  75.     Icon_list[13] = 117 # TP Recovery
  76.    
  77.     Icon_list[41] = 12 # Special action: Escape
  78.    
  79.     # )-------------------------------------(
  80.     # )--        Buffs                    --(
  81.     # )-------------------------------------(
  82.     Icon_list["310"] = 32 # MHP Up
  83.     Icon_list["311"] = 33 # MMP Up
  84.     Icon_list["312"] = 34 # ATK Up
  85.     Icon_list["313"] = 35 # DEF Up
  86.     Icon_list["314"] = 36 # MAT Up
  87.     Icon_list["315"] = 37 # MDF Up
  88.     Icon_list["316"] = 38 # AGI Up
  89.     Icon_list["317"] = 39 # LUK Up
  90.    
  91.     # )-------------------------------------(
  92.     # )--        Debuffs                  --(
  93.     # )-------------------------------------(
  94.     Icon_list["320"] = 48 # MHP Down
  95.     Icon_list["321"] = 49 # MMP Down
  96.     Icon_list["322"] = 50 # ATK Down
  97.     Icon_list["323"] = 51 # DEF Down
  98.     Icon_list["324"] = 52 # MAT Down
  99.     Icon_list["325"] = 53 # MDF Down
  100.     Icon_list["326"] = 54 # AGI Down
  101.     Icon_list["327"] = 55 # LUK Down
  102.    
  103.    
  104.     # )-------------------------------------(
  105.     # )--        Text strings             --(
  106.     # )-------------------------------------(
  107.     Text_list[0] = "to apply"
  108.     Text_list[1] = "removal"
  109.     Text_list[2] = " turns"
  110.     Text_list[3] = "Cleanse"
  111.     Text_list[4] = "Escape"
  112.     Text_list[5] = "grow by"
  113.     Text_list[6] = "Learn skill"
  114.     Text_list[7] = "rate"
  115.     Text_list[8] = "Immunity"
  116.    
  117.     # )----------------------------------------------------(
  118.     # )--        Element list                            --(
  119.     # )--  Make sure it has all icons for your elements! --(
  120.     # )----------------------------------------------------(
  121.     Element_list[1] = 143
  122.     Element_list[2] = 120
  123.     Element_list[3] = 96
  124.     Element_list[4] = 97
  125.     Element_list[5] = 98
  126.     Element_list[6] = 99
  127.     Element_list[7] = 100
  128.     Element_list[8] = 101
  129.     Element_list[9] = 102
  130.     Element_list[10] = 103
  131.   end
  132. end
  133.  
  134.  
  135. # )------------------------------------------(
  136. # )--  Class: MrTS_Window_Description      --(
  137. # )------------------------------------------(
  138.  
  139. class MrTS_Window_Description < Window_Base
  140.   include MrTS
  141.  
  142.   # )-------------------------------------(
  143.   # )--  Method: initialize             --(
  144.   # )-------------------------------------(
  145.   def initialize (x, y, width, height)
  146.     super(x, y, width, height)
  147.     @name_offset = 32;
  148.     @currency_unit = Vocab::currency_unit
  149.   end
  150.  
  151.   # )-------------------------------------(
  152.   # )--  Method: set_item(item)         --(
  153.   # )-------------------------------------(
  154.   def set_item (newitem)
  155.     @item = newitem
  156.     if @item
  157.       draw_info
  158.     end
  159.   end
  160.  
  161.   # )-------------------------------------(
  162.   # )-- Method: get_item, returns @item --(
  163.   # )-------------------------------------(  
  164.   def get_item
  165.     return @item
  166.   end
  167.  
  168.   # )-------------------------------------(
  169.   # )--  Method: draw_info              --(
  170.   # )-------------------------------------(
  171.   def draw_info()
  172.     contents.clear
  173.     # Line 1
  174.       # Item name
  175.       draw_item_name(@item, @name_offset, 0)
  176.       change_color(normal_color)
  177.      
  178.       # Value
  179.       txt_value = "Value"
  180.       if (@item.is_a?(RPG::Item) && !@item.key_item?) || @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  181.         draw_text_ex(@name_offset + 176 + 40, 0, "Value -")
  182.         draw_currency_value(@item.price, @currency_unit,
  183.                             @name_offset + 156 + 20 + text_size(txt_value).width,
  184.                             0, 160)
  185.       end
  186.                          
  187.     # Line 2&3
  188.       #Description
  189.       draw_text_ex(0, line_height, @item.description)
  190.      
  191.     # Line 4-Last
  192.     if @item.is_a?(RPG::Item)  
  193.       effect_num = 0
  194.      
  195.       @item.effects.each do |eff|
  196.         # Draw X
  197.         dx = (contents.width/MrTS::MrTS_Item_Info::COLUMNS) * (effect_num%MrTS::MrTS_Item_Info::COLUMNS)
  198.        
  199.         # Draw Y
  200.         dy = line_height*(3 + effect_num/MrTS::MrTS_Item_Info::COLUMNS)
  201.        
  202.         # Values of effects
  203.         value1 = eff.value1
  204.         value2 = eff.value2
  205.        
  206.         # Draw effect icon
  207.         if MrTS_Item_Info::Icon_list[eff.code]
  208.           draw_icon(MrTS_Item_Info::Icon_list[eff.code], dx, dy)
  209.         elsif eff.code == 21 || eff.code == 22
  210.           draw_icon($data_states[eff.data_id].icon_index, dx, dy)
  211.         elsif eff.code == 31 || eff.code == 32
  212.           draw_icon(MrTS_Item_Info::Icon_list[eff.code.to_s + eff.data_id.to_s], dx, dy)
  213.         elsif eff.code == 33 || eff.code == 34
  214.           draw_icon(MrTS_Item_Info::Icon_list[(eff.code-2).to_s + eff.data_id.to_s], dx, dy)
  215.         elsif eff.code == 42
  216.           draw_icon(MrTS_Item_Info::Icon_list[(eff.code-11).to_s + eff.data_id.to_s], dx, dy)
  217.         elsif eff.code == 43
  218.           draw_icon($data_skills[eff.data_id].icon_index, dx, dy)
  219.         elsif eff.code == 44 # common event skip it
  220.           effect_num -= 1
  221.         else # Draw default
  222.           draw_icon(1, dx, dy)
  223.         end
  224.        
  225.         if eff.code == 11 || eff.code == 12 || eff.code == 21 || eff.code == 22
  226.           value1 *= 100
  227.         end
  228.        
  229.         value1_sign = value1 >= 0 ? "+" : ""
  230.         value2_sign = value2 >= 0 ? "+" : ""
  231.         value1_text = ""
  232.         value2_text = ""
  233.        
  234.         if eff.code == 11 || eff.code == 12
  235.           value1_text = value1 != 0 ? value1_sign + value1.to_i.to_s + "%" : ""
  236.           value2_text = value2 != 0 ? value2_sign + value2.to_i.to_s : ""
  237.         elsif eff.code == 21 || eff.code == 22
  238.           value1_text = value1.to_i.to_s + "%"
  239.           value2_text = eff.code == 21 ? MrTS::MrTS_Item_Info::Text_list[0] : MrTS::MrTS_Item_Info::Text_list[1]
  240.         elsif eff.code == 31 || eff.code == 32
  241.           value1_text = "for " + value1.to_i.to_s + MrTS::MrTS_Item_Info::Text_list[2]
  242.         elsif eff.code == 33 || eff.code == 34
  243.           value1_text = MrTS::MrTS_Item_Info::Text_list[3]
  244.         elsif eff.code == 41
  245.           value1_text = MrTS::MrTS_Item_Info::Text_list[4]
  246.         elsif eff.code == 42
  247.           value1_text = MrTS::MrTS_Item_Info::Text_list[5]
  248.           value2_text = value1.to_i.to_s
  249.         elsif eff.code == 43
  250.           value1_text = MrTS::MrTS_Item_Info::Text_list[6]
  251.         end        
  252.        
  253.         draw_text_ex(dx+32, dy, value1_text + " " + value2_text)
  254.        
  255.         effect_num += 1
  256.       end
  257.     elsif @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  258.      
  259.       row = 0
  260.      
  261.       #Check if party can equip
  262.       $game_party.members.each do |memb|
  263.         dx = 0 + row*32
  264.         dy = line_height*8
  265.         if memb.equippable?(@item)
  266.           draw_character(memb.character_name, memb.character_index, dx+16, dy+32)
  267.         else
  268.           row -= 1
  269.         end
  270.        
  271.         row += 1
  272.        
  273.       end
  274.      
  275.      
  276.       row = 0
  277.       @item.params.each do |param|
  278.         dx = row%2 * contents.width/4
  279.         dy = line_height*4 + row/2*line_height
  280.         change_color(param > 0 ? text_color(3) : param == 0 ? normal_color : text_color(18))
  281.         draw_text(dx, dy, contents.width/4, line_height, MrTS::MrTS_Item_Info::STATS[row] + param.to_s)
  282.         change_color(normal_color)
  283.         row += 1
  284.       end
  285.      
  286.       row = 0
  287.       elem = 0
  288.  
  289.       @item.features.each do |feat|
  290.         dx = row%2 * contents.width/4 + contents.width/4*2
  291.         dy = line_height*4 + row/2*line_height
  292.        
  293.         value1 = feat.value
  294.        
  295.         if feat.code == 11
  296.           draw_icon(MrTS_Item_Info::Element_list[feat.data_id], dx, dy)
  297.           value1 *= 100
  298.           change_color(value1 > 100 ? text_color(18) : value1 == 100 ? normal_color : text_color(3))
  299.           draw_text(dx+32, dy, contents.width/4, line_height, value1.to_i.to_s + "% rate")
  300.           change_color(normal_color)
  301.         elsif feat.code == 12
  302.           draw_icon(MrTS_Item_Info::Icon_list["32"+feat.data_id.to_s], dx, dy)
  303.           value1 *= 100
  304.           change_color(value1 > 100 ? text_color(18) : value1 == 100 ? normal_color : text_color(3))
  305.           draw_text(dx+32, dy, contents.width/4, line_height, value1.to_i.to_s + "% rate")
  306.           change_color(normal_color)
  307.         elsif feat.code == 13
  308.           draw_icon($data_states[feat.data_id].icon_index, dx, dy)
  309.           value1 *= 100
  310.           change_color(value1 > 100 ? text_color(18) : value1 == 100 ? normal_color : text_color(3))
  311.           draw_text(dx+32, dy, contents.width/4, line_height, value1.to_i.to_s + "%  " + MrTS::MrTS_Item_Info::Text_list[7])
  312.           change_color(normal_color)
  313.         elsif feat.code == 14
  314.           draw_icon($data_states[feat.data_id].icon_index, dx, dy)
  315.           draw_text(dx+32, dy, contents.width/4, line_height, MrTS::MrTS_Item_Info::Text_list[8])
  316.         elsif feat.code == 21
  317.           value1 *= 100
  318.           if value1 > 100 || value1 < 100
  319.             draw_icon(value1 > 100 ? MrTS::MrTS_Item_Info::Icon_list["31" + feat.data_id.to_s] : MrTS::MrTS_Item_Info::Icon_list["32" + feat.data_id.to_s], dx, dy)
  320.             change_color(value1 > 100 ? text_color(3) : text_color(18))
  321.             value1 -= 100
  322.             draw_text(dx+32, dy, contents.width/4, line_height, (value1 > 0 ? "+" : "") + value1.to_i.to_s + "%")
  323.             change_color(normal_color)
  324.           else
  325.             row -= 1
  326.           end
  327.         elsif feat.code == 22
  328.           value1 *= 100
  329.           if value1 < 0 || value1 > 0
  330.             change_color(value1 > 0 ? text_color(3) : text_color(18))
  331.             draw_text(dx+32, dy, contents.width/4, line_height, MrTS::MrTS_Item_Info::XSTATS[feat.data_id] + " " + (value1 > 0 ? "+" : "") + value1.to_i.to_s + "%")
  332.           else
  333.             row -= 1
  334.           end
  335.         elsif feat.code == 31
  336.           icon_i = MrTS_Item_Info::Element_list[feat.data_id] ? MrTS_Item_Info::Element_list[feat.data_id] : 1
  337.           draw_icon(icon_i, 0 + elem*32, line_height*3)
  338.           elem += 1
  339.           row -= 1
  340.         elsif feat.code == 32
  341.           draw_icon($data_states[feat.data_id].icon_index, dx, dy)
  342.           value1 *= 100
  343.           draw_text(dx+30, dy, contents.width/4, line_height, "OnHit:" + value1.to_i.to_s + "%")
  344.         end
  345.        
  346.         row += 1
  347.        
  348.       end #feats
  349.     end #elsif
  350.   end #def
  351.  
  352. end #class
  353.  
  354. # )-------------------------------------(
  355. # )--  Class: Scene_Item              --(
  356. # )-------------------------------------(
  357. class Scene_Item < Scene_ItemBase
  358.  
  359.   # )-------------------------------------(
  360.   # )--  Alias to: start                --(
  361.   # )-------------------------------------(
  362.   alias mrts_si_create_start start
  363.   def start
  364.     super
  365.     create_category_window
  366.     create_item_window
  367.     create_description_window
  368.     set_description_window
  369.   end
  370.  
  371.   # )------------------------------------------(
  372.   # )--  New method: set_description_window  --(
  373.   # )------------------------------------------(
  374.   def set_description_window
  375.     @item_window.set_desc_window(@desc_window)
  376.   end
  377.  
  378.   # )---------------------------------------------(
  379.   # )--  New method: create_description_window  --(
  380.   # )---------------------------------------------(
  381.   def create_description_window
  382.     wy = @category_window.y + @category_window.height
  383.     wh = Graphics.height - wy - @item_window.height
  384.     @desc_window = MrTS_Window_Description.new(0, wy, Graphics.width, wh)
  385.     @desc_window.viewport = @viewport
  386.   end
  387.  
  388.   # )-------------------------------------(
  389.   # )--  Alias to: create_item_window   --(
  390.   # )-------------------------------------(
  391.   alias mrts_si_create_item_window create_item_window
  392.   def create_item_window
  393.     wh = 24*4 + 12*2
  394.     wy = Graphics.height - wh
  395.     @item_window = MrTS_Item_List.new(0, wy, Graphics.width, wh)
  396.     @item_window.viewport = @viewport
  397.     @item_window.set_handler(:ok,     method(:on_item_ok))
  398.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  399.     @category_window.item_window = @item_window
  400.   end
  401.  
  402.   # )----------------------------------------(
  403.   # )--  Alias to: create_category_window  --(
  404.   # )----------------------------------------(
  405.   alias mrts_si_create_create_category_window create_category_window
  406.   def create_category_window
  407.     @category_window = Window_ItemCategory.new
  408.     @category_window.viewport = @viewport
  409.     @category_window.help_window = @help_window
  410.     @category_window.y = 0
  411.     @category_window.set_handler(:ok,     method(:on_category_ok))
  412.     @category_window.set_handler(:cancel, method(:return_scene))
  413.   end
  414.  
  415. end
  416.  
  417. # )-------------------------------------(
  418. # )--  Class: MrTS_Item_List          --(
  419. # )-------------------------------------(
  420. class MrTS_Item_List < Window_ItemList
  421.  
  422.   # )-------------------------------------(
  423.   # )--  Method: set_desc_window        --(
  424.   # )-------------------------------------(
  425.   def set_desc_window(new_desc)
  426.     @desc_window = new_desc
  427.   end
  428.  
  429.   # )-------------------------------------(
  430.   # )--  Method: call_update_help       --(
  431.   # )-------------------------------------(
  432.   def call_update_help
  433.     update_help if active && @desc_window
  434.   end
  435.  
  436.   # )-------------------------------------(
  437.   # )-- Method: update_help             --(
  438.   # )-------------------------------------(
  439.   def update_help
  440.     @desc_window.set_item(item)
  441.   end
  442.  
  443.  
  444. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement