Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ++ Real-time Cooldowns ++ v1.2 (7/31/12)
- #==============================================================================
- # Script by:
- # Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
- #--------------------------------------------------------------------------
- # This script allows you to define real-time cooldowns for skills,
- # limiting the frequency of skill usage based on the Playtime timer.
- #
- # Inspiration for creating this script comes from Breath of Fire 3's
- # "Bonebreak" (テラブレイク) and "Celerity" skills which were known for
- # their 3-hour long cooldown timers.
- #
- # This script only affects Actor's skills. This has no effect on Enemies.
- #--------------------------------------------------------------------------
- # ++ Changelog ++
- #--------------------------------------------------------------------------
- # v1.1 : Added proper $imported variable. (7/31/2012)
- # v1.1 : Efficiency update. (7/30/2012)
- # v1.0 : Initial release. (7/30/2012)
- #--------------------------------------------------------------------------
- # ++ Installation ++
- #--------------------------------------------------------------------------
- # Install this script in the Materials section in your project's
- # script editor.
- #==============================================================================
- # ++ Real-time Cooldown Notetags ++
- #==============================================================================
- # Note: Some tags are given shorter tags for typing convenience. You only
- # need to use one <tag> from a given group for a notebox.
- # Use common sense.
- #
- # The following Notetag is for Skills only:
- #
- # <realtime cooldown: hrs:min:sec>
- # <rtcooldown: hrs:min:sec>
- # This tag defines the amount of real-life time the skill needs to
- # cooldown after being used once. All hours, minutes, and seconds
- # values must be defined even if any one of them is zero. The cooldown
- # uses the Playtime clock to determine time elapsed.
- #
- # Here is an example of a <realtime cooldown> tag:
- #
- # <realtime cooldown: 02:30:00>
- #
- # A skill with this tag will have a 2 hour and 30 minute cooldown after
- # being used once. Leading zeroes are not necessary, but can be used.
- #
- #==============================================================================
- # ++ Real-time Cooldown Script Calls ++
- #==============================================================================
- # The following script calls are meant to be used in "Script..." event
- # commands found under Tab 3 when creating a new event.
- #
- # reset_realtime_cooldowns(actor_id)
- # Removes all current real-time cooldowns from the given Actor where
- # actor_id is an actor ID number from your database.
- #
- #--------------------------------------------------------------------------
- # ++ Compatibility ++
- #--------------------------------------------------------------------------
- # This script aliases the following default VXA methods:
- #
- # DataManager#load_database
- # Game_BattlerBase#initialize
- # Game_BattlerBase#skill_conditions_met?
- # Game_Battler#use_item
- #
- # There are no default method overwrites.
- #
- # Requests for compatibility with other scripts are welcome.
- #--------------------------------------------------------------------------
- # ++ Terms and Conditions ++
- #--------------------------------------------------------------------------
- # Please do not repost this script elsewhere without permission.
- # Free for non-commercial use. For commercial use, contact me first.
- #
- # Newest versions of this script can be found at
- # http://mrbubblewand.wordpress.com/
- #==============================================================================
- $imported ||= {}
- $imported["BubsRealtimeCooldown"] = true
- #==========================================================================
- # ++ This script contains no customization module ++
- #==========================================================================
- #==========================================================================
- # ++ DataManager
- #==========================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias : load_database
- #--------------------------------------------------------------------------
- class << self; alias load_database_bubs_rtcooldown load_database; end
- def self.load_database
- load_database_bubs_rtcooldown # alias
- load_notetags_bubs_rtcooldown
- end
- #--------------------------------------------------------------------------
- # new method : load_notetags_bubs_rtcooldown
- #--------------------------------------------------------------------------
- def self.load_notetags_bubs_rtcooldown
- for obj in $data_skills
- next if obj.nil?
- obj.load_notetags_bubs_rtcooldown
- end # for obj
- end # def
- end # module DataManager
- #==========================================================================
- # ++ Bubs::Regexp
- #==========================================================================
- module Bubs
- module Regexp
- REALTIME_COOLDOWN_TAG =
- /<(?:REAL[_\s\-]?TIME|rt)[_\s]?COOLDOWN:\s*(\d+):(\d+):(\d+)\s*>/i
- end # module Regexp
- end # module Bubs
- #==========================================================================
- # ++ RPG::BaseItem
- #==========================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :realtime_cooldown
- #--------------------------------------------------------------------------
- # common cache : load_notetags_bubs_rtcooldown
- #--------------------------------------------------------------------------
- def load_notetags_bubs_rtcooldown
- @realtime_cooldown = 0
- return unless note =~ Bubs::Regexp::REALTIME_COOLDOWN_TAG ? true : false
- hour = $1.to_i * 60 * 60
- min = $2.to_i * 60
- sec = $3.to_i
- @realtime_cooldown = hour + min + sec
- end
- end # class RPG::BaseItem
- #==============================================================================
- # ++ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # new method : reset_realtime_cooldowns
- #--------------------------------------------------------------------------
- def reset_realtime_cooldowns(actor_id)
- return unless $game_actors[actor_id]
- $game_actors[actor_id].realtime_cooldowns.clear
- end
- end # class Game_Interpreter
- #==============================================================================
- # ++ Game_BattlerBase
- #==============================================================================
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :realtime_cooldowns
- #--------------------------------------------------------------------------
- # alias : initialize
- #--------------------------------------------------------------------------
- alias initialize_bubs_rtcooldown initialize
- def initialize
- initialize_bubs_rtcooldown # alias
- @realtime_cooldowns = {}
- end
- #--------------------------------------------------------------------------
- # alias : skill_conditions_met?
- #--------------------------------------------------------------------------
- alias skill_conditions_met_bubs_rtcooldown skill_conditions_met?
- def skill_conditions_met?(skill)
- return false if realtime_cooldown?(skill)
- return skill_conditions_met_bubs_rtcooldown(skill) # alias
- end
- #--------------------------------------------------------------------------
- # new method : realtime_cooldown?
- #--------------------------------------------------------------------------
- def realtime_cooldown?(skill)
- return false unless skill.realtime_cooldown > 0
- return false unless actor?
- return false if @realtime_cooldowns[skill.id].nil?
- elapsed = $game_system.playtime - @realtime_cooldowns[skill.id]
- if elapsed > skill.realtime_cooldown
- @realtime_cooldowns.delete(skill.id)
- return false
- else
- return true
- end
- end
- end # class Game_BattlerBase
- #==============================================================================
- # ++ Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # alias : use_item
- #--------------------------------------------------------------------------
- alias use_item_bubs_rtcooldown use_item
- def use_item(item)
- set_realtime_cooldown(item)
- use_item_bubs_rtcooldown(item) # alias
- end
- #--------------------------------------------------------------------------
- # new method : set_realtime_cooldown
- #--------------------------------------------------------------------------
- def set_realtime_cooldown(item)
- return unless item.is_a?(RPG::Skill)
- return unless item.realtime_cooldown > 0
- return unless actor?
- @realtime_cooldowns[item.id] = $game_system.playtime
- end
- end # class Game_Battler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement