Advertisement
Falmc

Falcao Skills cooldown

Oct 10th, 2012
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.45 KB | None | 0 0
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#          * Falcao Skills Cool Down 1.0                  #
  4. #  #*****************#          This script allows you set waiting time to a   #
  5. #                               used skill, so you have to wait x time before  #
  6. #       RMVXACE                 use it again. Date: Octuber 8 2012             #
  7. #                                                                              #
  8. # Falcao RGSS site:  http://falcaorgss.wordpress.com                           #
  9. # Falcao Forum site: http://makerpalace.com                                    #
  10. #==============================================================================#
  11.  
  12. #-------------------------------------------------------------------------------
  13. # * Installation
  14. #
  15. # Paste this script above main and below any custom battle system
  16. #-------------------------------------------------------------------------------
  17. # * Features
  18. #
  19. #- Bring more balance to the game skills system, just imagine you create a
  20. #  really powerful skill that kills all enemies, it dont make sense if you can
  21. #  use that powerful skill over and over again, just put waiting time now.
  22. #- A simple time meter is displayed at the help window showing time left
  23. #-------------------------------------------------------------------------------
  24. # * Usage
  25. #
  26. # It is pretty simple just tag a skill as follows (skill note tags)
  27. #
  28. # <cooldown: x>          Instead x puts cooldown integer, time in seconds    
  29. #-------------------------------------------------------------------------------
  30. # * License
  31. #
  32. # Free to use in any project, but you still need to credit me as creator
  33. #-------------------------------------------------------------------------------
  34.  
  35. module FalCooldown
  36.   def self.apply_cooldown(skill)
  37.     i = skill.id - 1 ; data = $game_system
  38.     data.cooldown[i] = skill.cooldown * 60 if data.cooldown[i] == 0
  39.   end
  40. end
  41.  
  42. class Game_System
  43.   attr_accessor :cooldown
  44.   alias falcaocooldown_ini initialize
  45.   def initialize
  46.     @cooldown = []
  47.     $data_skills.size.times do ; @cooldown.push(0) ; end
  48.     falcaocooldown_ini
  49.   end
  50. end
  51.  
  52. class Window_SkillList < Window_Selectable
  53.   alias falcaocooldown_enable enable?
  54.   def enable?(item)
  55.     return false if !item.nil? and cool_data(item.id) > 0
  56.     falcaocooldown_enable(item)
  57.   end
  58.  
  59.   def update
  60.     @refresh_delay = 0 if @refresh_delay.nil?
  61.     refresh_cooldown(cool_data(item.id)) if !item.nil? and
  62.     cool_data(item.id) > 0
  63.     if @skill_index != self.index
  64.       @skill_index = self.index
  65.       refresh_cooldown(cool_data(item.id)) if !item.nil?
  66.     end
  67.     @refresh_delay -= 1 if @refresh_delay > 0
  68.     refresh if @refresh_delay == 1
  69.     for i in 0...$game_system.cooldown.size
  70.       @refresh_delay = 2 if $game_system.cooldown[i] == 1
  71.     end
  72.     super
  73.   end
  74.  
  75.   def refresh_cooldown(cooldown)
  76.     @help_window.contents.font.size = Font.default_size
  77.     @help_window.refresh
  78.     @help_window.contents.font.size = 20
  79.     cooldown > 0 ? operand = cooldown : operand = item.cooldown * 60
  80.     total_sec = operand / Graphics.frame_rate
  81.     cd = sprintf("%02d:%02d", total_sec / 60, total_sec % 60)
  82.     @help_window.contents.draw_text(-30, 22, @help_window.width, 32,
  83.     "Cooldown: #{cd}", 2)
  84.   end
  85.  
  86.   def cool_data(id)
  87.     value = $game_system.cooldown[id - 1] if $game_system.cooldown[id - 1] > 0
  88.     return value.nil? ? 0 : value
  89.   end
  90. end
  91.  
  92. class RPG::Skill
  93.   def cooldown
  94.     @note =~ /<cooldown: (.*)>/i ? cd = $1.to_i : cd = 0
  95.     return cd
  96.   end
  97. end
  98.  
  99. class << Input
  100.   unless self.method_defined?(:falcaocd_update)
  101.     alias_method :falcaocd_update,   :update
  102.   end
  103.   def update
  104.     update_cooldown_global
  105.     falcaocd_update
  106.   end
  107.   def update_cooldown_global
  108.     data = $game_system
  109.     unless data.nil?
  110.       for i in 0...data.cooldown.size
  111.         data.cooldown[i] -= 1 if data.cooldown[i] > 0
  112.       end
  113.     end
  114.   end
  115. end
  116.  
  117. class Scene_Battle < Scene_Base
  118.   alias falcao_cooldown_use_item use_item
  119.   def use_item
  120.     item = @subject.current_action.item
  121.     FalCooldown.apply_cooldown(item) if item.is_a?(RPG::Skill)
  122.     falcao_cooldown_use_item
  123.   end
  124. end
  125.  
  126. class Scene_ItemBase < Scene_MenuBase
  127.   alias falcaocd22_use_item use_item
  128.   def use_item
  129.     FalCooldown.apply_cooldown(item) if item.is_a?(RPG::Skill)
  130.     falcaocd22_use_item
  131.   end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement