Advertisement
Kakakadafi

Param Grow Notification 3

Oct 2nd, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.40 KB | None | 0 0
  1. #==============================================================================
  2. # Kadafi - Item Use Notification
  3. # Version : 2.1
  4. # Contact : http://forums.rpgmakerweb.com/index.php?/user/33654-kadafi/
  5. #==============================================================================
  6. ($imported ||= {})[:Kadafi_ItemUseNotif] = true
  7. #==============================================================================
  8. # CHANGE LOGS:
  9. # -----------------------------------------------------------------------------
  10. # 2016.09.30 - Finished script
  11. #==============================================================================
  12. =begin
  13.  
  14.   Introduction :
  15.   This script create an item use notification.
  16.  
  17.   How to Use :
  18.   Edit the configuration below.
  19.  
  20.   NOTE :
  21.   1. This script will only show the "Parameter Grow" effect on item use
  22.   2. You must set the "Parameter Grow" effect into no. 1 from the effect lists
  23.   3. All Stats Notification only for the item that has all parameter grow effect
  24.      and the number of growth (All Stats +[Growth]) is from the first effect
  25.  
  26.   Terms of Use :
  27.   1. Credit me as Kadafi (Optional)
  28.  
  29. =end
  30. #==============================================================================
  31. # Configuration
  32. #==============================================================================
  33. module Kadafi
  34.   #--------------------------------------------------------------------------
  35.   # * List of Allowed Item Use Notification (Item IDs)
  36.   #--------------------------------------------------------------------------
  37.   ItemUseNotif_Items = [9, 10, 11, 12, 13, 14]
  38.   #--------------------------------------------------------------------------
  39.   # * Notification Window Width in Scene_Map
  40.   #--------------------------------------------------------------------------
  41.   ItemUseNotifWindow_Width = 256
  42.   #--------------------------------------------------------------------------
  43.   # * Parameter Grow Vocab
  44.   #--------------------------------------------------------------------------
  45.   Parameter_Vocab = [
  46.     "Life", # Max HP
  47.     "Mana", # Max MP
  48.     "Strength", # Attack
  49.     "Defense", # Defense
  50.     "Magic", # Magic ATK
  51.     "Magic Defense", # Magic DEF
  52.     "Agility", # Agility
  53.     "Luck", # Luck
  54.   ]
  55.   #--------------------------------------------------------------------------
  56.   # * All Parameter Grow Vocab
  57.   #--------------------------------------------------------------------------
  58.   AllParameter_Vocab = "All Stats"
  59.   #--------------------------------------------------------------------------
  60.   # * Notification Window Show Count
  61.   #--------------------------------------------------------------------------
  62.   ItemUseNotif_ShowCount = 30 # Frames / 60s
  63. end
  64. #==============================================================================
  65. # Don't edit below this line unless you know what to do.
  66. #==============================================================================
  67.  
  68. #==============================================================================
  69. # ** Window_EquipSkillNotification
  70. #==============================================================================
  71.  
  72. class Window_ItemUseNotification < Window_Base
  73.   #--------------------------------------------------------------------------
  74.   # * Object Initialization
  75.   #--------------------------------------------------------------------------
  76.   def initialize
  77.     super(0, 0, window_width, fitting_height(1))
  78.     update_placement
  79.     @parameter = ""
  80.     @value1 = 0
  81.     @fade = false
  82.     @show_count = 0
  83.     refresh
  84.     hide
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Update Window Position
  88.   #--------------------------------------------------------------------------
  89.   def update_placement
  90.     self.x = (Graphics.width - width) / 2
  91.     self.y = Graphics.height - height
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Get Window Width
  95.   #--------------------------------------------------------------------------
  96.   def window_width
  97.     return Kadafi::EquipSkillNotifWindow_Width
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Refresh
  101.   #--------------------------------------------------------------------------
  102.   def refresh
  103.     contents.clear
  104.     text = @parameter + " +" + @value1.to_s
  105.     draw_text(0 - line_height / 2, 0, width, line_height, text, 1)
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Frame Update
  109.   #--------------------------------------------------------------------------
  110.   def update
  111.     super
  112.     if open? && @show_count > 0
  113.       @show_count -= 1
  114.       if @show_count == 0
  115.         @fade = true
  116.       end
  117.     end
  118.     if @fade
  119.       self.opacity -= 1
  120.       self.contents_opacity -= 1
  121.       if self.opacity == 0
  122.         @fade = false
  123.       end
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Show Notification
  128.   #--------------------------------------------------------------------------
  129.   def show_notification(item)
  130.     self.opacity = 255
  131.     self.contents_opacity = 255
  132.     eff = item.effects.select {|e| e.code == 42 }
  133.     par = []
  134.     eff.each do |efek|
  135.       par.push(efek.data_id)
  136.     end
  137.     par.sort!
  138.     @parameter = Kadafi::Parameter_Vocab[item.effects[0].data_id]
  139.     if par == [0, 1, 2, 3, 4, 5, 6, 7]
  140.       @parameter = Kadafi::AllParameter_Vocab
  141.     end
  142.     @value1 = item.effects[0].value1.to_i
  143.     @show_count = Kadafi::ItemUseNotif_ShowCount
  144.     refresh
  145.     show
  146.   end
  147. end
  148.  
  149. #==============================================================================
  150. # ** Scene_Item
  151. #==============================================================================
  152.  
  153. class Scene_Item < Scene_ItemBase
  154.   #--------------------------------------------------------------------------
  155.   # * Start Processing
  156.   #--------------------------------------------------------------------------
  157.   alias old_start start
  158.   def start
  159.     old_start
  160.     @hide_selector = false
  161.     create_notification_window
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Create Notification Window
  165.   #--------------------------------------------------------------------------
  166.   def create_notification_window
  167.     @notification_window = Window_ItemUseNotification.new
  168.     @notification_window.z = 999
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Show Item Use Notification
  172.   #--------------------------------------------------------------------------
  173.   def show_notification(item)
  174.     @notification_window.show_notification(item)
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * Use Item
  178.   #--------------------------------------------------------------------------
  179.   alias old_use_item_1 use_item
  180.   def use_item
  181.     old_use_item_1
  182.     @hide_selector = true
  183.     if Kadafi::ItemUseNotif_Items.include?(item.id)
  184.       if item.effects[0].code == 42
  185.         show_notification(item)
  186.       end
  187.     end
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # * Frame Update
  191.   #--------------------------------------------------------------------------
  192.   alias old_update_1 update
  193.   def update
  194.     old_update_1
  195.     if @hide_selector
  196.       hide_sub_window(@actor_window)
  197.       @item_window.refresh
  198.       @hide_selector = false
  199.     end
  200.   end
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement