Advertisement
Eusmusia

Yanfly Item Overhaul

Nov 16th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.50 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Melody - Item Overhaul
  4. # Last Date Updated: 2010.06.20
  5. # Level: Normal, Hard
  6. #
  7. # The item scene can become seriously lacking as it often keeps players in the
  8. # dark as to what items actually do. This script rewrites the item scene and
  9. # provides the player adequate information about how an item functions, be it
  10. # a healing item, battle item, weapon, or a piece of armour. And if needed,
  11. # custom data can be inserted, too.
  12. #
  13. #===============================================================================
  14. # Updates
  15. # -----------------------------------------------------------------------------
  16. # o 2010.06.20 - Finished Script.
  17. # o 2010.06.18 - Started Script.
  18. #===============================================================================
  19. # Instructions
  20. # -----------------------------------------------------------------------------
  21. # To install this script, open up your script editor and copy/paste this script
  22. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  23. #
  24. # -----------------------------------------------------------------------------
  25. # Item and Equip Tags - For Items, Weapons, and Armours.
  26. # -----------------------------------------------------------------------------
  27. # <key item>
  28. # This labels the item as a key item, making it appear in the key item category
  29. # inside of the item scene. Does nothing else.
  30. #
  31. # <custom data>
  32. # icon, string1, string2
  33. # </custom data>
  34. # This allows you to input in custom data to be displayed in the item list
  35. # data window. Replace "icon" with a number to depict which icon you want
  36. # shown in the data. Replace "string1" with the category you want shown in the
  37. # data. Replace "string2" with the text you want shown in the data.
  38. #===============================================================================
  39.  
  40. $imported = {} if $imported == nil
  41. $imported["ItemOverhaul"] = true
  42.  
  43. module YEM
  44. module ITEM
  45.  
  46. #===========================================================================
  47. # Section I. Basic Settings
  48. # --------------------------------------------------------------------------
  49. # The following below will adjust the basic settings and vocabulary that
  50. # alter the basic item scene the players see before them.
  51. #===========================================================================
  52.  
  53. # This adjusts the commands used within the item scene. The command window
  54. # is the window that lets you switch between various item scene options.
  55. #
  56. # :usable Opens up usable menu items.
  57. # :battle Views battle-only items.
  58. # :weapons Views weapons list.
  59. # :armours Views armours list.
  60. # :misc Views miscellaneous items.
  61. # :key_items Views key items.
  62. # :all_items Views all items.
  63. #
  64. COMMANDS =[
  65. :usable, # Opens up usable menu items.
  66. :battle, # Views battle-only items.
  67. :weapons, # Views weapons list.
  68. :armours, # Views armours list.
  69. :misc, # Views miscellaneous items.
  70. :key_items, # Views key items.
  71. :all_items, # Views all items.
  72. ] # Do not remove this.
  73.  
  74. # The following determines the vocabulary used for the remade item scene.
  75. # Adjust it accordingly to set the way text is displayed.
  76. VOCAB ={
  77. :usable => "Usable",
  78. :battle => "Battle",
  79. :weapons => "Weapons",
  80. :armours => "Armours",
  81. :misc => "Various",
  82. :key_items => "Key Items",
  83. :all_items => "All Items",
  84. } # Do not remove this.
  85.  
  86. #===========================================================================
  87. # Section II. Data Window Settings
  88. # --------------------------------------------------------------------------
  89. # These settings adjust what you see in the data window shown to the lower
  90. # right of the item scene. The window shows the selected item's properties.
  91. # The data represented differs depending on the item, its tags, and whether
  92. # or not it is an item, weapon, or armour.
  93. #===========================================================================
  94.  
  95. # These constants determine how the gold value appears in the data windows.
  96. DRAW_GOLD_ICON = 1970
  97. DRAW_GOLD_TEXT = "Value"
  98.  
  99. # This adjusts the settings shown for items. Adjust as you see fit. The
  100. # majority of these keys are vocab settings.
  101. ITEM_DATA ={
  102. :properties => "Properties",
  103. :gold_value => true,
  104. :fontsize => 16,
  105. :hp_heal_icon => 2512,
  106. :hp_heal_text => "HP Heal",
  107. :mp_heal_icon => 2799,
  108. :mp_heal_text => "MP Heal",
  109. :dmg_icon => 742,
  110. :base_dmg => "Base Damage",
  111. :heal_icon => 2512,
  112. :base_heal => "Base Healing",
  113. :multiplier => "%s Multiplier",
  114. :element => "Element",
  115. :add_state => "Applies",
  116. :rem_state => "Cancels",
  117. :growth => "%s Growth",
  118. :resist => "%s Resist",
  119. :bonus => "%s Bonus",
  120. } # Do not remove this.
  121.  
  122. # This adjusts the settings shown for equipment. Adjust as you see fit. For
  123. # :shown_stats, valid stats to be shown are as follows:
  124. # :hp, :mp, :atk, :def, :spi, :res, :dex, :agi
  125. EQUIP_DATA ={
  126. :properties => "Attributes",
  127. :gold_value => true,
  128. :fontsize => 16,
  129. :shown_stats => [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi],
  130. :ele_weapon => "Adds",
  131. :ele_armour => "Guards",
  132. :state_weapon => "Applies",
  133. :state_armour => "Resists",
  134. } # Do not remove this.
  135.  
  136. # This array contains all of the elements you want displayed and in which
  137. # order to display them in. You can display them as individual integers or
  138. # as number ranges.
  139. SHOWN_ELEMENTS = [1..5, 9..17]
  140.  
  141. # Since elements do not have icons innately, use the following hash below
  142. # adjust and apply icons to them.
  143. ELEMENT_ICONS ={
  144. 1 => 929,
  145. 2 => 742,
  146. 3 => 726,
  147. 4 => 872,
  148. 5 => 400,
  149. 9 => 2816, # Fire element.
  150. 10 => 2817, # Ice element.
  151. 11 => 2818, # Volt element.
  152. 12 => 2820, # Earth element.
  153. 13 => 2819, # Water element.
  154. 14 => 2821, # Air element.
  155. 15 => 2822, # Light element.
  156. 16 => 2823, # Dark element.
  157. 17 => 2856
  158.  
  159. } # Do not remove this.
  160.  
  161. end # ITEM
  162. end # YEM
  163.  
  164. #===============================================================================
  165. # Editting anything past this point may potentially result in causing computer
  166. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  167. # Therefore, edit at your own risk.
  168. #===============================================================================
  169.  
  170. module YEM
  171. module REGEXP
  172. module BASEITEM
  173.  
  174. KEY_ITEM = /<(?:KEY_ITEM|key item|key)>/i
  175.  
  176. CUSTOM_DATA1 = /<(?:CUSTOM_DATA|custom data)>/i
  177. CUSTOM_DATA2 = /<\/(?:CUSTOM_DATA|custom data)>/i
  178.  
  179. end # BASEITEM
  180. end # REGEXP
  181. module ITEM
  182. module_function
  183. #--------------------------------------------------------------------------
  184. # convert_integer_array
  185. #--------------------------------------------------------------------------
  186. def convert_integer_array(array)
  187. result = []
  188. array.each { |i|
  189. case i
  190. when Range; result |= i.to_a
  191. when Integer; result |= [i]
  192. end }
  193. return result
  194. end
  195.  
  196. #--------------------------------------------------------------------------
  197. # converted_contants
  198. #--------------------------------------------------------------------------
  199. SHOWN_ELEMENTS = convert_integer_array(SHOWN_ELEMENTS)
  200. end # ITEM
  201. end # YEM
  202.  
  203. #===============================================================================
  204. # module Icon
  205. #===============================================================================
  206.  
  207. module Icon
  208.  
  209. #--------------------------------------------------------------------------
  210. # self.gold_cost
  211. #--------------------------------------------------------------------------
  212. def self.gold_cost; return YEM::ITEM::DRAW_GOLD_ICON; end
  213.  
  214. #--------------------------------------------------------------------------
  215. # self.element
  216. #--------------------------------------------------------------------------
  217. def self.element(element_id)
  218. icon = YEM::ITEM::ELEMENT_ICONS[element_id]
  219. return (icon == nil) ? 0 : icon
  220. end
  221.  
  222. #--------------------------------------------------------------------------
  223. # self.hp_heal
  224. #--------------------------------------------------------------------------
  225. def self.hp_heal; return YEM::ITEM::ITEM_DATA[:hp_heal_icon]; end
  226.  
  227. #--------------------------------------------------------------------------
  228. # self.mp_heal
  229. #--------------------------------------------------------------------------
  230. def self.mp_heal; return YEM::ITEM::ITEM_DATA[:mp_heal_icon]; end
  231.  
  232. #--------------------------------------------------------------------------
  233. # self.base_damage
  234. #--------------------------------------------------------------------------
  235. def self.base_damage; return YEM::ITEM::ITEM_DATA[:dmg_icon]; end
  236.  
  237. #--------------------------------------------------------------------------
  238. # self.base_healing
  239. #--------------------------------------------------------------------------
  240. def self.base_healing; return YEM::ITEM::ITEM_DATA[:heal_icon]; end
  241.  
  242. #--------------------------------------------------------------------------
  243. # self.stat
  244. #--------------------------------------------------------------------------
  245. def self.stat(actor, item); return 0; end
  246.  
  247. end # Icon
  248.  
  249. #===============================================================================
  250. # RPG::BaseItem
  251. #===============================================================================
  252.  
  253. class RPG::BaseItem
  254.  
  255. #--------------------------------------------------------------------------
  256. # public instance variables
  257. #--------------------------------------------------------------------------
  258. attr_accessor :custom_data
  259. attr_accessor :key_item
  260.  
  261. #--------------------------------------------------------------------------
  262. # common cache: yem_cache_baseitem_io
  263. #--------------------------------------------------------------------------
  264. def yem_cache_baseitem_io
  265. return if @cached_baseitem_io; @cached_baseitem_io = true
  266. @key_item = false
  267. enable_custom_data = false
  268. @custom_data = [] unless self.is_a?(RPG::Skill)
  269. self.note.split(/[\r\n]+/).each { |line|
  270. case line
  271. #---
  272. when YEM::REGEXP::BASEITEM::KEY_ITEM
  273. @key_item = true
  274. #---
  275. when YEM::REGEXP::BASEITEM::CUSTOM_DATA1
  276. next if self.is_a?(RPG::Skill)
  277. enable_custom_data = true
  278. when YEM::REGEXP::BASEITEM::CUSTOM_DATA2
  279. next if self.is_a?(RPG::Skill)
  280. enable_custom_data = false
  281. when /(\d+),[ ](.*),[ ](.*)/i
  282. next unless enable_custom_data
  283. next if self.is_a?(RPG::Skill)
  284. array = [$1.to_i, $2.to_s, $3.to_s]
  285. @custom_data.push(array)
  286. end
  287. } # end self.note.split
  288. end # yem_cache_baseitem_io
  289.  
  290. end # RPG::BaseItem
  291.  
  292. #===============================================================================
  293. # Scene_Title
  294. #===============================================================================
  295.  
  296. class Scene_Title < Scene_Base
  297.  
  298. #--------------------------------------------------------------------------
  299. # alias method: load_bt_database
  300. #--------------------------------------------------------------------------
  301. alias load_bt_database_io load_bt_database unless $@
  302. def load_bt_database
  303. load_bt_database_io
  304. load_io_cache
  305. end
  306.  
  307. #--------------------------------------------------------------------------
  308. # alias method: load_database
  309. #--------------------------------------------------------------------------
  310. alias load_database_io load_database unless $@
  311. def load_database
  312. load_database_io
  313. load_io_cache
  314. end
  315.  
  316. #--------------------------------------------------------------------------
  317. # new method: load_io_cache
  318. #--------------------------------------------------------------------------
  319. def load_io_cache
  320. groups = [$data_items, $data_weapons, $data_armors]
  321. for group in groups
  322. for obj in group
  323. next if obj == nil
  324. obj.yem_cache_baseitem_io if obj.is_a?(RPG::BaseItem)
  325. end
  326. end
  327. end
  328.  
  329. end # Scene_Title
  330.  
  331. #===============================================================================
  332. # Window_ItemStatus
  333. #===============================================================================
  334.  
  335. class Window_ItemStatus < Window_Base
  336.  
  337. #--------------------------------------------------------------------------
  338. # initialize
  339. #--------------------------------------------------------------------------
  340. def initialize
  341. super(160, 0, Graphics.width - 160, 128)
  342. refresh
  343. end
  344.  
  345. #--------------------------------------------------------------------------
  346. # refresh
  347. #--------------------------------------------------------------------------
  348. def refresh
  349. self.contents.clear
  350. @item = @item_window == nil ? nil : @item_window.item
  351. draw_item
  352. draw_party_members
  353. end
  354.  
  355. #--------------------------------------------------------------------------
  356. # set_item_window
  357. #--------------------------------------------------------------------------
  358. def set_item_window(new_item_window)
  359. @item_window = new_item_window
  360. update
  361. end
  362.  
  363. #--------------------------------------------------------------------------
  364. # update
  365. #--------------------------------------------------------------------------
  366. def update
  367. super
  368. return if @item_window == nil
  369. refresh if @item != @item_window.item
  370. end
  371.  
  372. #--------------------------------------------------------------------------
  373. # draw_item
  374. #--------------------------------------------------------------------------
  375. def draw_item
  376. return if @item == nil
  377. draw_icon(@item.icon_index, 0, 0)
  378. self.contents.draw_text(24, 0, contents.width-28, WLH, @item.name, 0)
  379. end
  380.  
  381. #--------------------------------------------------------------------------
  382. # draw_party_members
  383. #--------------------------------------------------------------------------
  384. def draw_party_members
  385. $game_temp.in_battle = true
  386. size = $game_party.members.size
  387. dx = (contents.width - (size * 64))/2 + 32
  388. dy = contents.height * 3/4
  389. for member in $game_party.members
  390. next if member == nil
  391. draw_member(member, dx, dy)
  392. dx += 64
  393. end
  394. $game_temp.in_battle = false
  395. end
  396.  
  397. #--------------------------------------------------------------------------
  398. # draw_member
  399. #--------------------------------------------------------------------------
  400. def draw_member(actor, dx, dy)
  401. bitmap = Cache.character(actor.character_name)
  402. sign = actor.character_name[/^[\!\$]./]
  403. if sign != nil and sign.include?('$')
  404. cw = bitmap.width / 3
  405. ch = bitmap.height / 4
  406. else
  407. cw = bitmap.width / 12
  408. ch = bitmap.height / 8
  409. end
  410. n = actor.character_index
  411. src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  412. if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  413. opacity = actor.equippable?(@item) ? 255 : 128
  414. elsif @item.is_a?(RPG::Item)
  415. opacity = @item.for_friend? ? 255 : 128
  416. else
  417. opacity = 255
  418. end
  419. self.contents.blt(dx - cw / 2, dy - ch, bitmap, src_rect, opacity)
  420. end
  421.  
  422. end # Window_ItemStatus
  423.  
  424. #===============================================================================
  425. # Window_ItemList
  426. #===============================================================================
  427.  
  428. class Window_ItemList < Window_Selectable
  429.  
  430. #--------------------------------------------------------------------------
  431. # initialize
  432. #--------------------------------------------------------------------------
  433. def initialize(help_window)
  434. @help_window = help_window
  435. dy = @help_window.y + @help_window.height
  436. super(0, dy, Graphics.width - 240, Graphics.height - dy)
  437. refresh
  438. self.active = false
  439. self.index = 0
  440. end
  441.  
  442. #--------------------------------------------------------------------------
  443. # item
  444. #--------------------------------------------------------------------------
  445. def item; return @data[[self.index, 0].max]; end
  446.  
  447. #--------------------------------------------------------------------------
  448. # used_item_refresh
  449. #--------------------------------------------------------------------------
  450. def used_item_refresh(array)
  451. for item in array
  452. next if item == nil
  453. next unless @data.include?(item)
  454. refresh
  455. break
  456. end
  457. end
  458.  
  459. #--------------------------------------------------------------------------
  460. # refresh
  461. #--------------------------------------------------------------------------
  462. def refresh
  463. @data = []
  464. for item in $game_party.items
  465. next unless include?(item)
  466. @data.push(item)
  467. end
  468. @data.push(nil) if @data.size <= 0
  469. @item_max = @data.size
  470. self.index = [self.index, @item_max - 1].min
  471. create_contents
  472. for i in 0...@item_max; draw_item(i); end
  473. end
  474.  
  475. #--------------------------------------------------------------------------
  476. # include?
  477. #--------------------------------------------------------------------------
  478. def include?(item)
  479. return false if item == nil
  480. return false if item.name == ""
  481. return false unless item.is_a?(RPG::Item)
  482. return item.menu_ok?
  483. end
  484.  
  485. #--------------------------------------------------------------------------
  486. # draw_item
  487. #--------------------------------------------------------------------------
  488. def draw_item(index)
  489. rect = item_rect(index)
  490. self.contents.clear_rect(rect)
  491. item = @data[index]
  492. return if item == nil
  493. enabled = enable?(item)
  494. draw_obj_name(item, rect.clone, enabled)
  495. draw_obj_charges(item, rect.clone, enabled)
  496. draw_obj_total(item, rect.clone, enabled)
  497. end
  498.  
  499. #--------------------------------------------------------------------------
  500. # enable?
  501. #--------------------------------------------------------------------------
  502. def enable?(item)
  503. return false if item == nil
  504. return $game_party.has_item?(item)
  505. end
  506.  
  507. #--------------------------------------------------------------------------
  508. # new method: draw_obj_name
  509. #--------------------------------------------------------------------------
  510. def draw_obj_name(obj, rect, enabled)
  511. draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  512. self.contents.font.size = Font.default_size
  513. self.contents.font.color = normal_color
  514. self.contents.font.color.alpha = enabled ? 255 : 128
  515. rect.width -= 48
  516. self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  517. end
  518.  
  519. #--------------------------------------------------------------------------
  520. # new method: draw_obj_charges
  521. #--------------------------------------------------------------------------
  522. def draw_obj_charges(obj, rect, enabled)
  523. return unless $imported["BattleEngineMelody"]
  524. return unless obj.is_a?(RPG::Item)
  525. return unless obj.consumable
  526. return if obj.charges <= 1
  527. $game_party.item_charges = {} if $game_party.item_charges == nil
  528. $game_party.item_charges[obj.id] = obj.charges if
  529. $game_party.item_charges[obj.id] == nil
  530. charges = $game_party.item_charges[obj.id]
  531. dx = rect.x; dy = rect.y + WLH/3
  532. self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
  533. self.contents.font.color = normal_color
  534. self.contents.font.color.alpha = enabled ? 255 : 128
  535. self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
  536. self.contents.font.size = Font.default_size
  537. end
  538.  
  539. #--------------------------------------------------------------------------
  540. # new method: draw_obj_total
  541. #--------------------------------------------------------------------------
  542. def draw_obj_total(obj, rect, enabled)
  543. if $imported["BattleEngineMelody"]
  544. hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
  545. else
  546. hash ={ :size => Font.default_size, :colour => 0, :text => "×%2d" }
  547. end
  548. number = $game_party.item_number(obj)
  549. dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
  550. text = sprintf(hash[:text], number)
  551. self.contents.font.size = hash[:size]
  552. self.contents.font.color = text_color(hash[:colour])
  553. self.contents.font.color.alpha = enabled ? 255 : 128
  554. self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  555. end
  556.  
  557. #--------------------------------------------------------------------------
  558. # update_help
  559. #--------------------------------------------------------------------------
  560. def update_help
  561. @help_window.set_text(item == nil ? "" : item.description)
  562. end
  563.  
  564. end # Window_ItemList
  565.  
  566. #===============================================================================
  567. # Window_BattleItemList
  568. #===============================================================================
  569.  
  570. class Window_BattleItemList < Window_ItemList
  571.  
  572. #--------------------------------------------------------------------------
  573. # include?
  574. #--------------------------------------------------------------------------
  575. def include?(item)
  576. return false if item == nil
  577. return false if item.name == ""
  578. return false unless item.is_a?(RPG::Item)
  579. return false if item.menu_ok?
  580. return item.battle_ok?
  581. end
  582.  
  583. end # Window_BattleItemList
  584.  
  585. #===============================================================================
  586. # Window_WeaponItemList
  587. #===============================================================================
  588.  
  589. class Window_WeaponItemList < Window_ItemList
  590.  
  591. #--------------------------------------------------------------------------
  592. # include?
  593. #--------------------------------------------------------------------------
  594. def include?(item)
  595. return false if item == nil
  596. return false if item.name == ""
  597. return item.is_a?(RPG::Weapon)
  598. end
  599.  
  600. end # Window_WeaponItemList
  601.  
  602. #===============================================================================
  603. # Window_ArmourItemList
  604. #===============================================================================
  605.  
  606. class Window_ArmourItemList < Window_ItemList
  607.  
  608. #--------------------------------------------------------------------------
  609. # include?
  610. #--------------------------------------------------------------------------
  611. def include?(item)
  612. return false if item == nil
  613. return false if item.name == ""
  614. return item.is_a?(RPG::Armor)
  615. end
  616.  
  617. end # Window_ArmourItemList
  618.  
  619. #===============================================================================
  620. # Window_MiscItemList
  621. #===============================================================================
  622.  
  623. class Window_MiscItemList < Window_ItemList
  624.  
  625. #--------------------------------------------------------------------------
  626. # include?
  627. #--------------------------------------------------------------------------
  628. def include?(item)
  629. return false if item == nil
  630. return false if item.name == ""
  631. return false if item.is_a?(RPG::Weapon)
  632. return false if item.is_a?(RPG::Armor)
  633. return false if item.menu_ok?
  634. return false if item.battle_ok?
  635. return false if item.key_item
  636. return true
  637. end
  638.  
  639. end # Window_MiscItemList
  640.  
  641. #===============================================================================
  642. # Window_KeyItemList
  643. #===============================================================================
  644.  
  645. class Window_KeyItemList < Window_ItemList
  646.  
  647. #--------------------------------------------------------------------------
  648. # include?
  649. #--------------------------------------------------------------------------
  650. def include?(item)
  651. return false if item == nil
  652. return false if item.name == ""
  653. return item.key_item
  654. end
  655.  
  656. end # Window_KeyItemList
  657.  
  658. #===============================================================================
  659. # Window_AllItemList
  660. #===============================================================================
  661.  
  662. class Window_AllItemList < Window_ItemList
  663.  
  664. #--------------------------------------------------------------------------
  665. # include?
  666. #--------------------------------------------------------------------------
  667. def include?(item)
  668. return false if item == nil
  669. return false if item.name == ""
  670. return true
  671. end
  672.  
  673. end # Window_AllItemList
  674.  
  675. #===============================================================================
  676. # Window_ItemData
  677. #===============================================================================
  678.  
  679. class Window_ItemData < Window_Base
  680.  
  681. #--------------------------------------------------------------------------
  682. # initialize
  683. #--------------------------------------------------------------------------
  684. def initialize(help_window)
  685. dy = help_window.y + help_window.height
  686. super(Graphics.width - 240, dy, 240, Graphics.height - dy)
  687. create_clone
  688. end
  689.  
  690. #--------------------------------------------------------------------------
  691. # create_clone
  692. #--------------------------------------------------------------------------
  693. def create_clone
  694. @clone = Game_Actor.new(1)
  695. @clone.maxhp = @clone.base_maxhp
  696. @clone.maxmp = @clone.base_maxmp
  697. @clone.atk = @clone.base_atk
  698. @clone.def = @clone.base_def
  699. @clone.spi = @clone.base_spi
  700. @clone.res = @clone.base_res if $imported["RES Stat"]
  701. @clone.dex = @clone.base_dex if $imported["DEX Stat"]
  702. @clone.agi = @clone.base_agi
  703. end
  704.  
  705. #--------------------------------------------------------------------------
  706. # set_item_window
  707. #--------------------------------------------------------------------------
  708. def set_item_window(new_item_window)
  709. @item_window = new_item_window
  710. update
  711. end
  712.  
  713. #--------------------------------------------------------------------------
  714. # update
  715. #--------------------------------------------------------------------------
  716. def update
  717. super
  718. return if @item_window == nil
  719. refresh if @item != @item_window.item
  720. end
  721.  
  722. #--------------------------------------------------------------------------
  723. # refresh
  724. #--------------------------------------------------------------------------
  725. def refresh
  726. self.contents.clear
  727. @item = @item_window.item
  728. return if @item == nil
  729. dx = 0; dy = 0
  730. dy = draw_item_name(dy)
  731. if @item.is_a?(RPG::Item)
  732. @hash = YEM::ITEM::ITEM_DATA
  733. dy = draw_item_properties(dy)
  734. elsif @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  735. @hash = YEM::ITEM::EQUIP_DATA
  736. dy = draw_equip_properties(dy)
  737. end
  738. end
  739.  
  740. #--------------------------------------------------------------------------
  741. # draw_item_name
  742. #--------------------------------------------------------------------------
  743. def draw_item_name(dy)
  744. draw_icon(@item.icon_index, 0, dy)
  745. self.contents.font.size = Font.default_size
  746. self.contents.font.color = normal_color
  747. self.contents.draw_text(24, dy, contents.width-28, WLH, @item.name)
  748. dy += WLH
  749. return dy
  750. end
  751.  
  752. #--------------------------------------------------------------------------
  753. # draw_item_properties
  754. #--------------------------------------------------------------------------
  755. def draw_item_properties(dy)
  756. dy = draw_properties(dy)
  757. dy = draw_item_value(dy)
  758. dy = draw_healing_properties(dy)
  759. dy = draw_base_damage(dy)
  760. dy = draw_multipliers(dy)
  761. dy = draw_elements(dy)
  762. dy = draw_plus_states(dy)
  763. dy = draw_minus_states(dy)
  764. dy = draw_item_growth(dy)
  765. dy = draw_custom_data(dy)
  766. return dy
  767. end
  768.  
  769. #--------------------------------------------------------------------------
  770. # draw_equip_properties
  771. #--------------------------------------------------------------------------
  772. def draw_equip_properties(dy)
  773. dy = draw_properties(dy)
  774. dy = draw_item_value(dy)
  775. dy = draw_equip_stats(dy)
  776. dy = draw_elements(dy)
  777. dy = draw_states(dy)
  778. dy = draw_custom_data(dy)
  779. return dy
  780. end
  781.  
  782. #--------------------------------------------------------------------------
  783. # draw_properties
  784. #--------------------------------------------------------------------------
  785. def draw_properties(dy)
  786. text = @hash[:properties]
  787. self.contents.font.size = @hash[:fontsize]
  788. self.contents.font.color = system_color
  789. self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  790. dy += WLH
  791. return dy
  792. end
  793.  
  794. #--------------------------------------------------------------------------
  795. # draw_item_value
  796. #--------------------------------------------------------------------------
  797. def draw_item_value(dy)
  798. return dy unless @hash[:gold_value]
  799. return dy if @item.price == 0
  800. draw_icon(Icon.gold_cost, 0, dy)
  801. text = YEM::ITEM::DRAW_GOLD_TEXT
  802. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  803. text = sprintf("%d%s", @item.price, Vocab.gold)
  804. self.contents.font.color = normal_color
  805. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  806. dy += WLH
  807. return dy
  808. end
  809.  
  810. #--------------------------------------------------------------------------
  811. # draw_healing_properties
  812. #--------------------------------------------------------------------------
  813. def draw_healing_properties(dy)
  814. return dy if dy + WLH > contents.height
  815. #---
  816. if @item.hp_recovery_rate != 0 or @item.hp_recovery != 0
  817. draw_icon(Icon.hp_heal, 0, dy)
  818. self.contents.font.color = system_color
  819. text = @hash[:hp_heal_text]
  820. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  821. self.contents.font.color = normal_color
  822. if @item.hp_recovery_rate != 0 and @item.hp_recovery != 0
  823. text = sprintf("%+d%%", @item.hp_recovery_rate)
  824. self.contents.draw_text(24, dy, (contents.width-28)*2/3, WLH, text, 2)
  825. text = sprintf("%+d", @item.hp_recovery)
  826. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  827. elsif @item.hp_recovery_rate != 0
  828. text = sprintf("%+d%%", @item.hp_recovery_rate)
  829. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  830. elsif @item.hp_recovery != 0
  831. text = sprintf("%+d", @item.hp_recovery)
  832. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  833. end
  834. dy += WLH
  835. end
  836. #---
  837. return dy if dy + WLH > contents.height
  838. #---
  839. if @item.mp_recovery_rate != 0 or @item.mp_recovery != 0
  840. draw_icon(Icon.mp_heal, 0, dy)
  841. self.contents.font.color = system_color
  842. text = @hash[:mp_heal_text]
  843. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  844. self.contents.font.color = normal_color
  845. if @item.mp_recovery_rate != 0 and @item.mp_recovery != 0
  846. text = sprintf("%+d%%", @item.mp_recovery_rate)
  847. self.contents.draw_text(24, dy, (contents.width-28)*2/3, WLH, text, 2)
  848. text = sprintf("%+d", @item.mp_recovery)
  849. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  850. elsif @item.mp_recovery_rate != 0
  851. text = sprintf("%+d%%", @item.mp_recovery_rate)
  852. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  853. elsif @item.mp_recovery != 0
  854. text = sprintf("%+d", @item.mp_recovery)
  855. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  856. end
  857. dy += WLH
  858. end
  859. #---
  860. return dy
  861. end
  862.  
  863. #--------------------------------------------------------------------------
  864. # draw_base_damage
  865. #--------------------------------------------------------------------------
  866. def draw_base_damage(dy)
  867. return dy if dy + WLH > contents.height
  868. return dy if (-5..5) === @item.base_damage
  869. if @item.base_damage > 0
  870. draw_icon(Icon.base_damage, 0, dy)
  871. text = @hash[:base_dmg]
  872. else
  873. draw_icon(Icon.base_healing, 0, dy)
  874. text = @hash[:base_heal]
  875. end
  876. self.contents.font.color = system_color
  877. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  878. self.contents.font.color = normal_color
  879. text = (@item.base_damage).abs
  880. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2); dy += WLH
  881. return dy
  882. end
  883.  
  884. #--------------------------------------------------------------------------
  885. # draw_multipliers
  886. #--------------------------------------------------------------------------
  887. def draw_multipliers(dy)
  888. return dy if dy + WLH > contents.height
  889. return dy if @item.base_damage == 0
  890. icon = @item.base_damage > 0 ? Icon.base_damage : Icon.base_healing
  891. #---
  892. if @item.atk_f > 0
  893. draw_icon(icon, 0, dy)
  894. text = sprintf(@hash[:multiplier], Vocab.atk)
  895. self.contents.font.color = system_color
  896. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  897. text = sprintf("%s%%", @item.atk_f)
  898. self.contents.font.color = normal_color
  899. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  900. dy += WLH
  901. end
  902. #---
  903. return dy if dy + WLH > contents.height
  904. #---
  905. if $imported["BattleEngineMelody"] and @item.def_f > 0
  906. draw_icon(icon, 0, dy)
  907. text = sprintf(@hash[:multiplier], Vocab.def)
  908. self.contents.font.color = system_color
  909. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  910. text = sprintf("%s%%", @item.def_f)
  911. self.contents.font.color = normal_color
  912. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  913. dy += WLH
  914. end
  915. #---
  916. return dy if dy + WLH > contents.height
  917. #---
  918. if @item.spi_f > 0
  919. draw_icon(icon, 0, dy)
  920. text = sprintf(@hash[:multiplier], Vocab.spi)
  921. self.contents.font.color = system_color
  922. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  923. text = sprintf("%s%%", @item.spi_f)
  924. self.contents.font.color = normal_color
  925. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  926. dy += WLH
  927. end
  928. #---
  929. return dy if dy + WLH > contents.height
  930. #---
  931. if $imported["BattleEngineMelody"] and $imported["RES Stat"] and
  932. @item.res_f > 0
  933. draw_icon(icon, 0, dy)
  934. text = sprintf(@hash[:multiplier], Vocab.res)
  935. self.contents.font.color = system_color
  936. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  937. text = sprintf("%s%%", @item.res_f)
  938. self.contents.font.color = normal_color
  939. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  940. dy += WLH
  941. end
  942. #---
  943. return dy if dy + WLH > contents.height
  944. #---
  945. if $imported["BattleEngineMelody"] and $imported["DEX Stat"] and
  946. @item.dex_f > 0
  947. draw_icon(icon, 0, dy)
  948. text = sprintf(@hash[:multiplier], Vocab.dex)
  949. self.contents.font.color = system_color
  950. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  951. text = sprintf("%s%%", @item.dex_f)
  952. self.contents.font.color = normal_color
  953. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  954. dy += WLH
  955. end
  956. #---
  957. return dy if dy + WLH > contents.height
  958. #---
  959. if $imported["BattleEngineMelody"] and @item.agi_f > 0
  960. draw_icon(icon, 0, dy)
  961. text = sprintf(@hash[:multiplier], Vocab.agi)
  962. self.contents.font.color = system_color
  963. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  964. text = sprintf("%s%%", @item.agi_f)
  965. self.contents.font.color = normal_color
  966. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  967. dy += WLH
  968. end
  969. #---
  970. return dy
  971. end
  972.  
  973. #--------------------------------------------------------------------------
  974. # draw_elements
  975. #--------------------------------------------------------------------------
  976. def draw_elements(dy)
  977. return dy if @item.element_set == []
  978. for element_id in YEM::ITEM::SHOWN_ELEMENTS
  979. break if dy + WLH > contents.height
  980. next unless @item.element_set.include?(element_id)
  981. draw_icon(Icon.element(element_id), 0, dy)
  982. text = @hash[:element] if @item.is_a?(RPG::Item)
  983. text = @hash[:ele_weapon] if @item.is_a?(RPG::Weapon)
  984. text = @hash[:ele_armour] if @item.is_a?(RPG::Armor)
  985. self.contents.font.color = system_color
  986. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  987. text = $data_system.elements[element_id]
  988. self.contents.font.color = normal_color
  989. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  990. dy += WLH
  991. end
  992. return dy
  993. end
  994.  
  995. #--------------------------------------------------------------------------
  996. # total_drawn_states
  997. #--------------------------------------------------------------------------
  998. def total_drawn_states(array)
  999. result = 0
  1000. for state_id in array
  1001. next if $data_states[state_id] == nil
  1002. next if $data_states[state_id].icon_index == 0
  1003. result += 1
  1004. end
  1005. return [result, 8].min
  1006. end
  1007.  
  1008. #--------------------------------------------------------------------------
  1009. # draw_states
  1010. #--------------------------------------------------------------------------
  1011. def draw_states(dy)
  1012. return dy if @item.state_set == []
  1013. total = total_drawn_states(@item.state_set)
  1014. if total == 1
  1015. return dy if dy + WLH > contents.height
  1016. state = $data_states[@item.state_set[0]]
  1017. draw_icon(state.icon_index, 0, dy)
  1018. text = @hash[:state_weapon] if @item.is_a?(RPG::Weapon)
  1019. text = @hash[:state_armour] if @item.is_a?(RPG::Armor)
  1020. self.contents.font.color = system_color
  1021. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1022. text = state.name
  1023. self.contents.font.color = normal_color
  1024. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1025. else
  1026. return dy if dy + WLH*2 > contents.height
  1027. text = @hash[:state_weapon] if @item.is_a?(RPG::Weapon)
  1028. text = @hash[:state_armour] if @item.is_a?(RPG::Armor)
  1029. self.contents.font.color = system_color
  1030. self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1031. dy += WLH
  1032. dx = (contents.width - total*24)/2
  1033. for state_id in @item.state_set
  1034. break if dx + 24 > contents.width
  1035. state = $data_states[state_id]
  1036. next if state.icon_index == 0
  1037. draw_icon(state.icon_index, dx, dy)
  1038. dx += 24
  1039. end
  1040. end
  1041. dy += WLH
  1042. return dy
  1043. end
  1044.  
  1045. #--------------------------------------------------------------------------
  1046. # draw_plus_states
  1047. #--------------------------------------------------------------------------
  1048. def draw_plus_states(dy)
  1049. return dy if @item.plus_state_set == []
  1050. total = total_drawn_states(@item.plus_state_set)
  1051. if total == 1
  1052. return dy if dy + WLH > contents.height
  1053. state = $data_states[@item.plus_state_set[0]]
  1054. draw_icon(state.icon_index, 0, dy)
  1055. text = @hash[:add_state]
  1056. self.contents.font.color = system_color
  1057. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1058. text = state.name
  1059. self.contents.font.color = normal_color
  1060. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1061. else
  1062. return dy if dy + WLH*2 > contents.height
  1063. text = @hash[:add_state]
  1064. self.contents.font.color = system_color
  1065. self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1066. dy += WLH
  1067. dx = (contents.width - total*24)/2
  1068. for state_id in @item.plus_state_set
  1069. break if dx + 24 > contents.width
  1070. state = $data_states[state_id]
  1071. next if state.icon_index == 0
  1072. draw_icon(state.icon_index, dx, dy)
  1073. dx += 24
  1074. end
  1075. end
  1076. dy += WLH
  1077. return dy
  1078. end
  1079.  
  1080. #--------------------------------------------------------------------------
  1081. # draw_minus_states
  1082. #--------------------------------------------------------------------------
  1083. def draw_minus_states(dy)
  1084. return dy if @item.minus_state_set == []
  1085. total = total_drawn_states(@item.minus_state_set)
  1086. if total == 1
  1087. return dy if dy + WLH > contents.height
  1088. state = $data_states[@item.minus_state_set[0]]
  1089. draw_icon(state.icon_index, 0, dy)
  1090. text = @hash[:rem_state]
  1091. self.contents.font.color = system_color
  1092. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1093. text = state.name
  1094. self.contents.font.color = normal_color
  1095. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1096. else
  1097. return dy if dy + WLH*2 > contents.height
  1098. text = @hash[:rem_state]
  1099. self.contents.font.color = system_color
  1100. self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1101. dy += WLH
  1102. dx = (contents.width - total*24)/2
  1103. for state_id in @item.minus_state_set
  1104. break if dx + 24 > contents.width
  1105. state = $data_states[state_id]
  1106. next if state.icon_index == 0
  1107. draw_icon(state.icon_index, dx, dy)
  1108. dx += 24
  1109. end
  1110. end
  1111. dy += WLH
  1112. return dy
  1113. end
  1114.  
  1115. #--------------------------------------------------------------------------
  1116. # draw_item_growth
  1117. #--------------------------------------------------------------------------
  1118. def draw_item_growth(dy)
  1119. #---
  1120. if @item.parameter_type != 0
  1121. case @item.parameter_type
  1122. when 1; text = sprintf(@hash[:growth], Vocab.hp)
  1123. when 2; text = sprintf(@hash[:growth], Vocab.mp)
  1124. when 3; text = sprintf(@hash[:growth], Vocab.atk)
  1125. when 4; text = sprintf(@hash[:growth], Vocab.def)
  1126. when 5; text = sprintf(@hash[:growth], Vocab.spi)
  1127. when 6; text = sprintf(@hash[:growth], Vocab.agi)
  1128. end
  1129. draw_icon(@item.icon_index, 0, dy)
  1130. self.contents.font.color = system_color
  1131. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1132. text = sprintf("%+d", @item.parameter_points)
  1133. self.contents.font.color = normal_color
  1134. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1135. dy += WLH
  1136. end
  1137. #---
  1138. if $imported["StatusMenuMelody"]
  1139. for stat in [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1140. return dy if dy + WLH > contents.height
  1141. next if stat == :res and !$imported["RES Stat"]
  1142. next if stat == :dex and !$imported["DEX Stat"]
  1143. next if @item.stat_growth[stat] == 0 or @item.stat_growth[stat] == nil
  1144. text = sprintf(@hash[:growth], eval("Vocab." + stat.to_s))
  1145. draw_icon(@item.icon_index, 0, dy)
  1146. self.contents.font.color = system_color
  1147. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1148. text = sprintf("%+d", @item.stat_growth[stat])
  1149. self.contents.font.color = normal_color
  1150. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1151. dy += WLH
  1152. end
  1153. end
  1154. #---
  1155. if $imported["BattleEngineMelody"]
  1156. growth = []
  1157. for key in @item.element_growth
  1158. growth.push(key[0]) if YEM::ITEM::SHOWN_ELEMENTS.include?(key[0])
  1159. end
  1160. growth.sort!
  1161. for element_id in growth
  1162. return dy if dy + WLH > contents.height
  1163. icon = Icon.element(element_id)
  1164. next if icon == 0
  1165. draw_icon(icon, 0, dy)
  1166. text = sprintf(@hash[:resist], $data_system.elements[element_id])
  1167. self.contents.font.color = system_color
  1168. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1169. text = sprintf("%+d%%", -@item.element_growth[element_id])
  1170. self.contents.font.color = normal_color
  1171. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1172. dy += WLH
  1173. end
  1174. end
  1175. #---
  1176. if $imported["BattleEngineMelody"]
  1177. growth = []
  1178. for key in @item.state_growth
  1179. growth.push(key[0])
  1180. end
  1181. growth.sort!
  1182. for state_id in growth
  1183. return dy if dy + WLH > contents.height
  1184. state = $data_states[state_id]
  1185. next if state == nil
  1186. icon = state.icon_index
  1187. next if icon == 0
  1188. draw_icon(icon, 0, dy)
  1189. text = sprintf(@hash[:resist], state.name)
  1190. self.contents.font.color = system_color
  1191. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1192. text = sprintf("%+d%%", -@item.state_growth[state_id])
  1193. self.contents.font.color = normal_color
  1194. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1195. dy += WLH
  1196. end
  1197. end
  1198. #---
  1199. if $imported["EquipmentOverhaul"]
  1200. for stat in [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1201. return dy if dy + WLH > contents.height
  1202. next if stat == :res and !$imported["RES Stat"]
  1203. next if stat == :dex and !$imported["DEX Stat"]
  1204. next if @item.apt_growth[stat] == 0 or @item.apt_growth[stat] == nil
  1205. text = sprintf(@hash[:bonus], eval("Vocab." + stat.to_s))
  1206. draw_icon(@item.icon_index, 0, dy)
  1207. self.contents.font.color = system_color
  1208. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1209. text = sprintf("%+d%%", @item.apt_growth[stat])
  1210. self.contents.font.color = normal_color
  1211. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1212. dy += WLH
  1213. end
  1214. end
  1215. #---
  1216. return dy
  1217. end
  1218.  
  1219. #--------------------------------------------------------------------------
  1220. # draw_equip_stats
  1221. #--------------------------------------------------------------------------
  1222. def draw_equip_stats(dy)
  1223. dx = 0
  1224. array = [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1225. for stat in @hash[:shown_stats]
  1226. return if dy + WLH > contents.height
  1227. next if stat == :res and !$imported["RES Stat"]
  1228. next if stat == :dex and !$imported["DEX Stat"]
  1229. next if [:hp, :mp].include?(stat) and !$imported["EquipmentOverhaul"]
  1230. next unless array.include?(stat)
  1231. draw_icon(Icon.stat(@clone, stat), dx, dy)
  1232. text = eval("Vocab." + stat.to_s)
  1233. self.contents.font.color = system_color
  1234. self.contents.draw_text(dx+24, dy, contents.width/2-28, WLH, text, 0)
  1235. stat_text = stat.to_s
  1236. stat_text = "max" + stat_text if ["hp", "mp"].include?(stat_text)
  1237. item_value = eval("@item." + stat_text)
  1238. text = sprintf("%+d", item_value)
  1239. self.contents.font.color = normal_color
  1240. self.contents.font.color.alpha = item_value == 0 ? 128 : 255
  1241. self.contents.draw_text(dx+24, dy, contents.width/2-28, WLH, text, 2)
  1242. if dx == 0
  1243. dx = contents.width/2
  1244. else
  1245. dx = 0
  1246. dy += WLH
  1247. end
  1248. end
  1249. dy += WLH if dx != 0
  1250. return dy
  1251. end
  1252.  
  1253. #--------------------------------------------------------------------------
  1254. # draw_custom_data
  1255. #--------------------------------------------------------------------------
  1256. def draw_custom_data(dy)
  1257. return dy if @item.custom_data == []
  1258. for array in @item.custom_data
  1259. break if dy + WLH > contents.height
  1260. draw_icon(array[0], 0, dy)
  1261. text = array[1]
  1262. self.contents.font.color = system_color
  1263. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1264. text = array[2]
  1265. self.contents.font.color = normal_color
  1266. self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1267. dy += WLH
  1268. end
  1269. return dy
  1270. end
  1271.  
  1272. end # Window_ItemData
  1273.  
  1274. #===============================================================================
  1275. # Scene_Item
  1276. #===============================================================================
  1277.  
  1278. class Scene_Item < Scene_Base
  1279.  
  1280. #--------------------------------------------------------------------------
  1281. # overwrite method: start
  1282. #--------------------------------------------------------------------------
  1283. def start
  1284. super
  1285. create_menu_background
  1286. @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  1287. @help_window = Window_Help.new
  1288. @help_window.viewport = @viewport
  1289. @help_window.y = 128
  1290. @data_window = Window_ItemData.new(@help_window)
  1291. @data_window.viewport = @viewport
  1292. @windows = []
  1293. @target_window = Window_MenuStatus.new(0, 0)
  1294. @target_window.visible = false
  1295. @target_window.active = false
  1296. @status_window = Window_ItemStatus.new
  1297. @status_window.viewport = @viewport
  1298. create_command_window
  1299. update_windows
  1300. end
  1301.  
  1302. #--------------------------------------------------------------------------
  1303. # new method: create_command_window
  1304. #--------------------------------------------------------------------------
  1305. def create_command_window
  1306. commands = []; @data = []
  1307. for command in YEM::ITEM::COMMANDS
  1308. case command
  1309. when :usable
  1310. @usable_window = Window_ItemList.new(@help_window)
  1311. @windows.push(@usable_window)
  1312. when :battle
  1313. @battle_window = Window_BattleItemList.new(@help_window)
  1314. @windows.push(@battle_window)
  1315. when :weapons
  1316. @weapon_window = Window_WeaponItemList.new(@help_window)
  1317. @windows.push(@weapon_window)
  1318. when :armours
  1319. @armour_window = Window_ArmourItemList.new(@help_window)
  1320. @windows.push(@armour_window)
  1321. when :misc
  1322. @misc_window = Window_MiscItemList.new(@help_window)
  1323. @windows.push(@misc_window)
  1324. when :key_items
  1325. @key_item_window = Window_KeyItemList.new(@help_window)
  1326. @windows.push(@key_item_window)
  1327. when :all_items
  1328. @all_item_window = Window_AllItemList.new(@help_window)
  1329. @windows.push(@all_item_window)
  1330. else; next
  1331. end
  1332. @data.push(command)
  1333. if YEM::ITEM::VOCAB[command] != nil
  1334. commands.push(YEM::ITEM::VOCAB[command])
  1335. end
  1336. end
  1337. for window in @windows
  1338. next if window == nil?
  1339. window.active = false
  1340. window.viewport = @viewport
  1341. window.help_window = @help_window if window.is_a?(Window_Selectable)
  1342. end
  1343. @command_window = Window_Command_Centered.new(160, commands)
  1344. @command_window.viewport = @viewport
  1345. @command_window.height = 128
  1346. @command_window.active = true
  1347. end
  1348.  
  1349. #--------------------------------------------------------------------------
  1350. # new method: update_windows
  1351. #--------------------------------------------------------------------------
  1352. def update_windows
  1353. @last_command_index = @command_window.index
  1354. @help_window.y = Graphics.height*8
  1355. @data_window.y = Graphics.height*8
  1356. for window in @windows
  1357. next if window == nil
  1358. window.y = Graphics.height*8
  1359. end
  1360. #---
  1361. case @data[@command_window.index]
  1362. when :usable
  1363. show_item_windows(@usable_window)
  1364. when :battle
  1365. show_item_windows(@battle_window)
  1366. when :weapons
  1367. show_item_windows(@weapon_window)
  1368. when :armours
  1369. show_item_windows(@armour_window)
  1370. when :misc
  1371. show_item_windows(@misc_window)
  1372. when :key_items
  1373. show_item_windows(@key_item_window)
  1374. when :all_items
  1375. show_item_windows(@all_item_window)
  1376. end
  1377. end
  1378.  
  1379. #--------------------------------------------------------------------------
  1380. # overwrite method: terminate
  1381. #--------------------------------------------------------------------------
  1382. def terminate
  1383. super
  1384. dispose_menu_background
  1385. @help_window.dispose
  1386. @command_window.dispose
  1387. @status_window.dispose
  1388. for window in @windows
  1389. next if window == nil
  1390. next if window.disposed?
  1391. window.dispose
  1392. end
  1393. @viewport.dispose
  1394. end
  1395.  
  1396. #--------------------------------------------------------------------------
  1397. # overwrite method: update
  1398. #--------------------------------------------------------------------------
  1399. def update
  1400. super
  1401. update_menu_background
  1402. if @command_window.active
  1403. update_command_selection
  1404. elsif @target_window.active
  1405. update_target_selection
  1406. elsif @item_window != nil and @item_window.active
  1407. update_item_selection
  1408. end
  1409. end
  1410.  
  1411. #--------------------------------------------------------------------------
  1412. # new method: update_command_selection
  1413. #--------------------------------------------------------------------------
  1414. def update_command_selection
  1415. @command_window.update
  1416. update_windows if @last_command_index != @command_window.index
  1417. if Input.trigger?(Input::B)
  1418. Sound.play_cancel
  1419. return_scene
  1420. elsif Input.trigger?(Input::C)
  1421. Sound.play_decision
  1422. @command_window.active = false
  1423. case @data[@command_window.index]
  1424. when :usable, :battle, :weapons, :armours, :misc, :key_items, :all_items
  1425. @item_window.active = true
  1426. end
  1427. end
  1428. end
  1429.  
  1430. #--------------------------------------------------------------------------
  1431. # new method: show_usable_windows
  1432. #--------------------------------------------------------------------------
  1433. def show_item_windows(window)
  1434. @help_window.y = 128
  1435. @data_window.set_item_window(window)
  1436. @status_window.set_item_window(window)
  1437. @data_window.y = @help_window.y + @help_window.height
  1438. window.y = @data_window.y
  1439. window.update_help
  1440. @item_window = window
  1441. end
  1442.  
  1443. #--------------------------------------------------------------------------
  1444. # overwrite method: update_item_selection
  1445. #--------------------------------------------------------------------------
  1446. def update_item_selection
  1447. @status_window.update
  1448. @item_window.update
  1449. @data_window.update
  1450. if Input.trigger?(Input::B)
  1451. Sound.play_cancel
  1452. @item_window.active = false
  1453. @command_window.active = true
  1454. return unless @item_used
  1455. for window in @windows
  1456. next unless window.is_a?(Window_ItemList)
  1457. window.used_item_refresh(@item_used)
  1458. end
  1459. @item_used = []
  1460. elsif Input.trigger?(Input::C)
  1461. @item = @item_window.item
  1462. if enable_item?
  1463. Sound.play_decision
  1464. determine_item
  1465. end
  1466. end
  1467. end
  1468.  
  1469. #--------------------------------------------------------------------------
  1470. # new method: enable_item?
  1471. #--------------------------------------------------------------------------
  1472. def enable_item?
  1473. return false unless @item.is_a?(RPG::Item)
  1474. return false unless @item.menu_ok?
  1475. return false unless @item_window.enable?(@item)
  1476. return true
  1477. end
  1478.  
  1479. #--------------------------------------------------------------------------
  1480. # alias method: update_target_selection
  1481. #--------------------------------------------------------------------------
  1482. alias update_target_selection_io update_target_selection unless $@
  1483. def update_target_selection
  1484. @target_window.update
  1485. update_target_selection_io
  1486. end
  1487.  
  1488. #--------------------------------------------------------------------------
  1489. # alias method: show_target_window
  1490. #--------------------------------------------------------------------------
  1491. alias show_target_window_io show_target_window unless $@
  1492. def show_target_window(right)
  1493. show_target_window_io(true)
  1494. end
  1495.  
  1496. #--------------------------------------------------------------------------
  1497. # alias method: use_item_nontarget
  1498. #--------------------------------------------------------------------------
  1499. alias use_item_nontarget_io use_item_nontarget unless $@
  1500. def use_item_nontarget
  1501. @item_used = [] if @item_used == nil
  1502. @item_used.push(@item) unless @item_used.include?(@item)
  1503. use_item_nontarget_io
  1504. @status_window.refresh
  1505. end
  1506.  
  1507. end # Scene_Base
  1508.  
  1509. #===============================================================================
  1510. #
  1511. # END OF FILE
  1512. #
  1513. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement