Advertisement
Kakakadafi

[Overwrite] Skill Equip Notify

Oct 20th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.44 KB | None | 0 0
  1. #==============================================================================
  2. # ************************ Commissioned by Kudaaj330 *************************
  3. #==============================================================================
  4. # Kadafi - Equip Skill Notification
  5. # Version : 1.0
  6. # Contact : http://forums.rpgmakerweb.com/index.php?/user/33654-kadafi/
  7. #==============================================================================
  8. ($imported ||= {})[:Kadafi_EquipSkillNotif] = true
  9. #==============================================================================
  10. # CHANGE LOGS:
  11. # -----------------------------------------------------------------------------
  12. # 2016.11.17 - Finished script
  13. #==============================================================================
  14. =begin
  15.  
  16.   Introduction :
  17.   This script create a equip skill notification.
  18.  
  19.   How to Use :
  20.   Edit the configuration below.
  21.  
  22.   Terms of Use :
  23.   1. Credit me as Kadafi (Optional)
  24.  
  25. =end
  26. #==============================================================================
  27. # Configuration
  28. #==============================================================================
  29. module Kadafi
  30.   #--------------------------------------------------------------------------
  31.   # * Notification Window Width in Scene_Skill
  32.   #--------------------------------------------------------------------------
  33.   EquipSkillNotifWindow_Width = 256
  34.   #--------------------------------------------------------------------------
  35.   # * Notification Window Vocab
  36.   #--------------------------------------------------------------------------
  37.   EquipSkillNotif_Vocab = " is equipped."
  38.   #--------------------------------------------------------------------------
  39.   # * Notification Window Show Count
  40.   #--------------------------------------------------------------------------
  41.   EquipSkillNotif_ShowCount = 30 # Frames / 60s
  42. end
  43. #==============================================================================
  44. # Don't edit below this line unless you know what to do.
  45. #==============================================================================
  46.  
  47. #==============================================================================
  48. # ** Window_EquipSkillNotification
  49. #==============================================================================
  50.  
  51. class Window_EquipSkillNotification < Window_Base
  52.   #--------------------------------------------------------------------------
  53.   # * Object Initialization
  54.   #--------------------------------------------------------------------------
  55.   def initialize
  56.     super(0, 0, window_width, fitting_height(1))
  57.     update_placement
  58.     @skill_name = ""
  59.     @fade = false
  60.     @show_count = 0
  61.     refresh
  62.     hide
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Update Window Position
  66.   #--------------------------------------------------------------------------
  67.   def update_placement
  68.     self.x = (Graphics.width - width) / 2
  69.     self.y = Graphics.height - height
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Get Window Width
  73.   #--------------------------------------------------------------------------
  74.   def window_width
  75.     return Kadafi::EquipSkillNotifWindow_Width
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # * Refresh
  79.   #--------------------------------------------------------------------------
  80.   def refresh
  81.     contents.clear
  82.     text = @skill_name + Kadafi::EquipSkillNotif_Vocab
  83.     draw_text(0 - line_height / 2, 0, width, line_height, text, 1)
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Frame Update
  87.   #--------------------------------------------------------------------------
  88.   def update
  89.     super
  90.     if open? && @show_count > 0
  91.       @show_count -= 1
  92.       @fade = true if @show_count == 0
  93.     end
  94.     if @fade
  95.       self.opacity -= 1
  96.       self.contents_opacity -= 1
  97.       @fade = false if self.opacity == 0
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Show Notification
  102.   #--------------------------------------------------------------------------
  103.   def show_notification(skill)
  104.     self.opacity = 255
  105.     self.contents_opacity = 255
  106.     @skill_name = skill.name
  107.     @show_count = Kadafi::EquipSkillNotif_ShowCount
  108.     refresh
  109.     show
  110.   end
  111. end
  112.  
  113. #==============================================================================
  114. # ** Window Skill List
  115. #==============================================================================
  116.  
  117. class Window_SkillList < Window_Selectable
  118.   #--------------------------------------------------------------------------
  119.   # * Can Equip Skill Action
  120.   #--------------------------------------------------------------------------
  121.   def can_equip_skill_action?
  122.     return false if $game_party.in_battle
  123.     skill = @data[index]
  124.    
  125.     if skill != nil and skill.note =~ /<Duration = (\d+)>/
  126. #~       p @stype_id
  127. #~       p Kadafi::Magic_SkillTypesID
  128. #~       p Kadafi::WeaponSkill_SkillTypesID
  129.       if @stype_id == Kadafi::Magic_SkillTypesID
  130.         @actor.skill_id = skill.id
  131.       elsif @stype_id == Kadafi::WeaponSkill_SkillTypesID
  132.         @actor.skill2_id = skill.id
  133.       end
  134.       Sound.play_equip
  135.       SceneManager.scene.show_notification(skill)
  136.       return true        
  137.     end
  138.    
  139.     return false
  140.   end
  141. end
  142.  
  143. #==============================================================================
  144. # ** Scene_Skill
  145. #==============================================================================
  146.  
  147. class Scene_Skill < Scene_ItemBase
  148.   #--------------------------------------------------------------------------
  149.   # * Start Processing
  150.   #--------------------------------------------------------------------------
  151.   alias old_start start
  152.   def start
  153.     old_start
  154.     create_notification_window
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # * Create Notification Window
  158.   #--------------------------------------------------------------------------
  159.   def create_notification_window
  160.     @notification_window = Window_EquipSkillNotification.new
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # * Show Equip Skill Notification
  164.   #--------------------------------------------------------------------------
  165.   def show_notification(skill)
  166.     @notification_window.show_notification(skill)
  167.   end
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement