Advertisement
Kakakadafi

Param Grow Notification

Sep 29th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.57 KB | None | 0 0
  1. #==============================================================================
  2. # ************************ Commissioned by Kudaaj330 *************************
  3. #==============================================================================
  4. # Kadafi - Item Use Notification
  5. # Version : 1.0
  6. # Contact : http://forums.rpgmakerweb.com/index.php?/user/33654-kadafi/
  7. #==============================================================================
  8. ($imported ||= {})[:Kadafi_ItemUseNotif] = true
  9. #==============================================================================
  10. # CHANGE LOGS:
  11. # -----------------------------------------------------------------------------
  12. # 2016.09.30 - Finished script
  13. #==============================================================================
  14. =begin
  15.  
  16.   Introduction :
  17.   This script create an item use notification.
  18.  
  19.   How to Use :
  20.   Edit the configuration below.
  21.  
  22.   NOTE :
  23.   1. This script will only show the "Parameter Grow" effect on item use
  24.   2. You must set the "Parameter Grow" effect into no. 1 from the effect lists
  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.   # * Notification Window Show Count
  57.   #--------------------------------------------------------------------------
  58.   ItemUseNotif_ShowCount = 30 # Frames / 60s
  59. end
  60. #==============================================================================
  61. # Don't edit below this line unless you know what to do.
  62. #==============================================================================
  63.  
  64. #==============================================================================
  65. # ** Game_Map
  66. #==============================================================================
  67.  
  68. class Game_Map
  69.   attr_reader :recall_menu, :show_notif, :show_item_id
  70.   attr_accessor :recall_menu, :show_notif, :show_item_id
  71.   #--------------------------------------------------------------------------
  72.   # * Object Initialization
  73.   #--------------------------------------------------------------------------
  74.   alias old_initialize_1 initialize
  75.   def initialize
  76.     old_initialize_1
  77.     @recall_menu = false
  78.     @show_notif = false
  79.     @show_item_id = 0
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Show Item Use Notification
  83.   #--------------------------------------------------------------------------
  84.   def show_notification(item)
  85.     if Kadafi::ItemUseNotif_Items.include?(item.id)
  86.       if item.effects[0].code == 42
  87.         @show_notif = true
  88.         @show_item_id = item.id
  89.       end
  90.     end
  91.   end
  92. end
  93.  
  94. #==============================================================================
  95. # ** Window_EquipSkillNotification
  96. #==============================================================================
  97.  
  98. class Window_ItemUseNotification < Window_Base
  99.   #--------------------------------------------------------------------------
  100.   # * Object Initialization
  101.   #--------------------------------------------------------------------------
  102.   def initialize
  103.     super(0, 0, window_width, fitting_height(1))
  104.     update_placement
  105.     @parameter = ""
  106.     @value1 = 0
  107.     @fade = false
  108.     @show_count = 0
  109.     refresh
  110.     hide
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Update Window Position
  114.   #--------------------------------------------------------------------------
  115.   def update_placement
  116.     self.x = (Graphics.width - width) / 2
  117.     self.y = Graphics.height - height
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Get Window Width
  121.   #--------------------------------------------------------------------------
  122.   def window_width
  123.     return Kadafi::EquipSkillNotifWindow_Width
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # * Refresh
  127.   #--------------------------------------------------------------------------
  128.   def refresh
  129.     contents.clear
  130.     text = @parameter + " +" + @value1.to_s
  131.     draw_text(0 - line_height / 2, 0, width, line_height, text, 1)
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Frame Update
  135.   #--------------------------------------------------------------------------
  136.   def update
  137.     super
  138.     if open? && @show_count > 0
  139.       @show_count -= 1
  140.       if @show_count == 0
  141.         @fade = true
  142. #~         SceneManager.call(Scene_Item)
  143.       end
  144.     end
  145.     if @fade
  146.       self.opacity -= 3
  147.       self.contents_opacity -= 3
  148.       if self.opacity == 0
  149.         @fade = false
  150.         $game_map.recall_menu = true
  151.         SceneManager.call(Scene_Item)
  152.       end
  153.     end
  154.   end
  155.   #--------------------------------------------------------------------------
  156.   # * Show Notification
  157.   #--------------------------------------------------------------------------
  158.   def show_notification(item)
  159.     self.opacity = 255
  160.     self.contents_opacity = 255
  161.     @parameter = Kadafi::Parameter_Vocab[item.effects[0].data_id]
  162.     @value1 = item.effects[0].value1.to_i
  163.     @show_count = Kadafi::ItemUseNotif_ShowCount
  164.     refresh
  165.     show
  166.   end
  167. end
  168.  
  169. #==============================================================================
  170. # ** Scene_Map
  171. #==============================================================================
  172.  
  173. class Scene_Map < Scene_Base
  174.   #--------------------------------------------------------------------------
  175.   # * Start Processing
  176.   #--------------------------------------------------------------------------
  177.   alias old_start start
  178.   def start
  179.     old_start
  180.     create_notification_window
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Create Notification Window
  184.   #--------------------------------------------------------------------------
  185.   def create_notification_window
  186.     @notification_window = Window_ItemUseNotification.new
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Show Item Use Notification
  190.   #--------------------------------------------------------------------------
  191.   def show_notification(item)
  192.     @notification_window.show_notification(item)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # * Frame Update
  196.   #--------------------------------------------------------------------------
  197.   alias old_update_1 update
  198.   def update
  199.     old_update_1
  200.     if $game_map.show_notif
  201.       show_notification($data_items[$game_map.show_item_id])
  202.       $game_map.show_notif = false
  203.     end
  204.   end
  205. end
  206.  
  207. #==============================================================================
  208. # ** Scene_Item
  209. #==============================================================================
  210.  
  211. class Scene_Item < Scene_ItemBase
  212.   #--------------------------------------------------------------------------
  213.   # * Use Item
  214.   #--------------------------------------------------------------------------
  215.   alias old_use_item_1 use_item
  216.   def use_item
  217.     old_use_item_1
  218.     $game_map.show_notification(item)
  219.     SceneManager.goto(Scene_Map)
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # * Return to Calling Scene
  223.   #--------------------------------------------------------------------------
  224.   alias old_return_scene_1 return_scene
  225.   def return_scene
  226.     if $game_map.recall_menu
  227.       $game_map.recall_menu = false
  228.       SceneManager.goto(Scene_Menu)
  229.     else
  230.       old_return_scene_1
  231.     end
  232.   end
  233. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement