Advertisement
Kakakadafi

Param Grow Notification 2

Oct 1st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.21 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. # ** SceneManager
  66. #==============================================================================
  67.  
  68. module SceneManager
  69.   #--------------------------------------------------------------------------
  70.   # * Module Instance Variables
  71.   #--------------------------------------------------------------------------
  72.   @bg_bitmap = nil                # background bitmap
  73.   #--------------------------------------------------------------------------
  74.   # * Create Snapshot to Use as Background
  75.   #--------------------------------------------------------------------------
  76.   def self.snapshot_for_bg
  77.     @bg_bitmap.dispose if @bg_bitmap
  78.     @bg_bitmap = Graphics.snap_to_bitmap
  79. #~     @bg_bitmap.blur
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Get Background Bitmap
  83.   #--------------------------------------------------------------------------
  84.   def self.bg_bitmap
  85.     @bg_bitmap
  86.   end
  87. end
  88.  
  89. #==============================================================================
  90. # ** Game_Map
  91. #==============================================================================
  92.  
  93. class Game_Map
  94.   attr_reader :recall_menu, :show_notif, :show_item_id
  95.   attr_accessor :recall_menu, :show_notif, :show_item_id
  96.   #--------------------------------------------------------------------------
  97.   # * Object Initialization
  98.   #--------------------------------------------------------------------------
  99.   alias old_initialize_1 initialize
  100.   def initialize
  101.     old_initialize_1
  102.     @recall_menu = false
  103.     @show_notif = false
  104.     @show_item_id = 0
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Show Item Use Notification
  108.   #--------------------------------------------------------------------------
  109.   def show_notification(item)
  110.     if Kadafi::ItemUseNotif_Items.include?(item.id)
  111.       if item.effects[0].code == 42
  112.         @show_notif = true
  113.         @show_item_id = item.id
  114.       end
  115.     end
  116.   end
  117. end
  118.  
  119. #==============================================================================
  120. # ** Window_EquipSkillNotification
  121. #==============================================================================
  122.  
  123. class Window_ItemUseNotification < Window_Base
  124.   #--------------------------------------------------------------------------
  125.   # * Object Initialization
  126.   #--------------------------------------------------------------------------
  127.   def initialize
  128.     super(0, 0, window_width, fitting_height(1))
  129.     update_placement
  130.     @parameter = ""
  131.     @value1 = 0
  132.     @fade = false
  133.     @show_count = 0
  134.     refresh
  135.     hide
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Update Window Position
  139.   #--------------------------------------------------------------------------
  140.   def update_placement
  141.     self.x = (Graphics.width - width) / 2
  142.     self.y = Graphics.height - height
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # * Get Window Width
  146.   #--------------------------------------------------------------------------
  147.   def window_width
  148.     return Kadafi::EquipSkillNotifWindow_Width
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Refresh
  152.   #--------------------------------------------------------------------------
  153.   def refresh
  154.     contents.clear
  155.     text = @parameter + " +" + @value1.to_s
  156.     draw_text(0 - line_height / 2, 0, width, line_height, text, 1)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Frame Update
  160.   #--------------------------------------------------------------------------
  161.   def update
  162.     super
  163.     if open? && @show_count > 0
  164.       @show_count -= 1
  165.       if @show_count == 0
  166.         @fade = true
  167.       end
  168.     end
  169.     if @fade
  170.       self.opacity -= 7.5
  171.       self.contents_opacity -= 7.5
  172.       if self.opacity == 0
  173.         @fade = false
  174.         if SceneManager.scene_is?(Scene_Item)
  175.           $game_map.show_notif = false
  176.           SceneManager.scene.show_all_window
  177.           SceneManager.scene.create_background
  178.         end
  179.       end
  180.     end
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Show Notification
  184.   #--------------------------------------------------------------------------
  185.   def show_notification(item)
  186.     self.opacity = 255
  187.     self.contents_opacity = 255
  188.     @parameter = Kadafi::Parameter_Vocab[item.effects[0].data_id]
  189.     @value1 = item.effects[0].value1.to_i
  190.     @show_count = Kadafi::ItemUseNotif_ShowCount
  191.     refresh
  192.     show
  193.   end
  194. end
  195.  
  196. #==============================================================================
  197. # ** Scene_Map
  198. #==============================================================================
  199.  
  200. class Scene_Map < Scene_Base
  201.   #--------------------------------------------------------------------------
  202.   # * Termination Processing
  203.   #--------------------------------------------------------------------------
  204.   alias old_terminate_1 terminate
  205.   def terminate
  206.     SceneManager.snapshot_for_bg
  207.     old_terminate_1
  208.   end
  209. end
  210.  
  211. #==============================================================================
  212. # ** Scene_Item
  213. #==============================================================================
  214.  
  215. class Scene_Item < Scene_ItemBase
  216.   #--------------------------------------------------------------------------
  217.   # * Start Processing
  218.   #--------------------------------------------------------------------------
  219.   alias old_start start
  220.   def start
  221.     old_start
  222.     create_notification_window
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # * Create Notification Window
  226.   #--------------------------------------------------------------------------
  227.   def create_notification_window
  228.     @notification_window = Window_ItemUseNotification.new
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Show Item Use Notification
  232.   #--------------------------------------------------------------------------
  233.   def show_notification(item)
  234.     @notification_window.show_notification(item)
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Show All Window
  238.   #--------------------------------------------------------------------------
  239.   def show_all_window
  240.     @help_window.show
  241.     @category_window.show
  242.     @item_window.show
  243.     @actor_window.show
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # * Use Item
  247.   #--------------------------------------------------------------------------
  248.   alias old_use_item_1 use_item
  249.   def use_item
  250.     old_use_item_1
  251.    
  252.     @help_window.hide
  253.     @category_window.hide
  254.     @item_window.hide
  255.     @actor_window.hide
  256.     create_bg
  257.    
  258.     $game_map.show_notification(item)
  259.     show_notification($data_items[$game_map.show_item_id])
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # * Create Background
  263.   #--------------------------------------------------------------------------
  264.   def create_bg
  265.     @background_sprite = Sprite.new
  266.     @background_sprite.bitmap = SceneManager.bg_bitmap
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # * Update Frame (Basic)
  270.   #--------------------------------------------------------------------------
  271.   def update_basic
  272.     Graphics.update
  273.     Input.update unless $game_map.show_notif
  274.     update_all_windows
  275.   end
  276. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement