Yanfly Skill Restriction - Minor FTB Edit

Status
Not open for further replies.

Lorenze

Veteran
Veteran
Joined
Mar 17, 2012
Messages
826
Reaction score
547
First Language
English
Primarily Uses
RMMV
EDIT: Nevermind, I was just being dumb. Carry on.

Hey guys.

I'm using a combination of Yanfly's battle engine with Free Turn Battle and his skill restrictions script, among others. This is all fine and dandy, except for one small thing concerning cooldowns and warmups.

In the default battle engine, 1 CD (Cooldown) = 1 turn. Basically, after using a skill, you'd have to wait one turn to be able to use it again. With Yanfly's FTB, however, the game makes each action count as a turn. So if I had 1 CD = 1 turn, I'd be able to use the skill immeadiately after using an action - even if I had remaining AP left. 

I'm trying to get rid of that. In a nutshell, I want a basic fix for the scripts that makes the remaining CD decrease after each turn, NOT action. If you need more info or this sounds confusing (trust me, I know it kinda is), just let me know.

Here's Yanfly's Free Turn Battle script:

#==============================================================================# # ▼ Yanfly Engine Ace - Battle System Add-On: Free Turn Battle v1.02# -- Last Updated: 2012.01.15# -- Level: Normal, Hard# -- Requires: Yanfly Engine Ace - Ace Battle Engine v1.15+# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-BattleSystem-FTB"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.01.15 - Bug fixed: Battle victory log doesn't play twice.# 2012.01.11 - Bug fixed: Dead actors are no longer inputable.# 2012.01.10 - Finished Script.# 2012.01.09 - Started Script.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# Free Turn Battle is a type of battle system made for Ace Battle Engine, where# actors perform their actions immediately (unless under the effects of berserk# or any other form of autobattle) as they're selected. After all of their# actions have been performed, the enemies will take their turn in battling the# actors. This becomes a system where actors and enemies will take turns# attacking one another as a whole.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # First, set the default battle system for your game to be :ftb by either going# to the Ace Battle Engine script and setting DEFAULT_BATTLE_SYSTEM as :ftb or# by using the following script call: # # $game_system:set_battle_system:)ftb)# # -----------------------------------------------------------------------------# Actor Notetags - These notetags go in the actors notebox in the database.# -----------------------------------------------------------------------------# <ftb actions: +x># <ftb actions: -x># This increases or decreases the maximum number of actions available to an# actor by x. While an actor's individual maximum can be any value, it does not# provide more than the party maximum applied in the module. An actor's total# maximum cannot go below 1.# # -----------------------------------------------------------------------------# Class Notetags - These notetags go in the classes notebox in the database.# -----------------------------------------------------------------------------# <ftb actions: +x># <ftb actions: -x># This increases or decreases the maximum number of actions available to an# actor by x. While an actor's individual maximum can be any value, it does not# provide more than the party maximum applied in the module. An actor's total# maximum cannot go below 1.# # -----------------------------------------------------------------------------# Skill Notetags - These notetags go in the skills notebox in the database.# -----------------------------------------------------------------------------# <ftb cost: x># This causes the skill to have an FTB cost of x. The FTB Cost does not occur# for individual chain skills, individual input skills, specialized input# skills, or instant skills. However, an FTB Cost can be used to put a specific# requirement on those listed types of skills.# # -----------------------------------------------------------------------------# Item Notetags - These notetags go in the items notebox in the database.# -----------------------------------------------------------------------------# <ftb cost: x># This causes the item to have an FTB cost of x. The FTB Cost does not occur# for instant items. If items cost more actions than the party has available,# then the items will not appear in the usable item list during battle.# # -----------------------------------------------------------------------------# Weapon Notetags - These notetags go in the weapons notebox in the database.# -----------------------------------------------------------------------------# <ftb actions: +x># <ftb actions: -x># This increases or decreases the maximum number of actions available to an# actor by x. While an actor's individual maximum can be any value, it does not# provide more than the party maximum applied in the module. An actor's total# maximum cannot go below 1.# # -----------------------------------------------------------------------------# Armour Notetags - These notetags go in the armour notebox in the database.# -----------------------------------------------------------------------------# <ftb actions: +x># <ftb actions: -x># This increases or decreases the maximum number of actions available to an# actor by x. While an actor's individual maximum can be any value, it does not# provide more than the party maximum applied in the module. An actor's total# maximum cannot go below 1.# # -----------------------------------------------------------------------------# State Notetags - These notetags go in the state notebox in the database.# -----------------------------------------------------------------------------# <ftb actions: +x># <ftb actions: -x># This increases or decreases the maximum number of actions available to an# actor by x. While an actor's individual maximum can be any value, it does not# provide more than the party maximum applied in the module. An actor's total# maximum cannot go below 1.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# # This script requires Yanfly Engine Ace - Ace Battle Engine v1.15+ and the# script must be placed under Ace Battle Engine in the script listing.# #==============================================================================module YEA module FTB #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - General FTB Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # These settings adjust various general Free Turn Battle constants such as # the icons used for actions and no actions, whether or not party members # will have limited actions (or unlimited). #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ICON_ACTION = 99 # Icon displayed when there are actions left. ICON_EMPTY = 97 # Icon displayed to indicate a used action. # For every x% above the base AGI, actors will gain an extra action. Change # the value below to adjust the percentage needed. EXTRA_FTB_ACTION_BONUS = 0.20 # This is the maximum number of actions that the party can have despite the # maximum number of individual actor actions totalling to more than this. MAXIMUM_FTB_ACTIONS = 10 # If this setting is on, then each member can only perform a limited amount # of actions per turn as opposed to freely performing actions until the # party's action usage is depleted. LIMITED_ACTIONS_PER_MEMBER = false end # FTBend # YEA#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================module YEA module REGEXP module BASEITEM FTB_ACTIONS = /<(?:FTB_ACTIONS|ftb actions):[ ]([\+\-]\d+)>/i end # BASEITEM module USABLEITEM FTB_COST = /<(?:FTB_COST|ftb cost):[ ](\d+)>/i end # USABLEITEM end # REGEXPend # YEA#==============================================================================# ■ Icon#==============================================================================module Icon #-------------------------------------------------------------------------- # self.ftb_action #-------------------------------------------------------------------------- def self.ftb_action return YEA::FTB::ICON_ACTION end #-------------------------------------------------------------------------- # self.ftb_empty #-------------------------------------------------------------------------- def self.ftb_empty return YEA::FTB::ICON_EMPTY end end # Icon#==============================================================================# ■ DataManager#==============================================================================module DataManager #-------------------------------------------------------------------------- # alias method: load_database #-------------------------------------------------------------------------- class <<self; alias load_database_ftb load_database; end def self.load_database load_database_ftb load_notetags_ftb end #-------------------------------------------------------------------------- # new method: load_notetags_ftb #-------------------------------------------------------------------------- def self.load_notetags_ftb groups = [$data_skills, $data_items, $data_actors, $data_classes, $data_weapons, $data_armors, $data_states] for group in groups for obj in group next if obj.nil? obj.load_notetags_ftb end end end end # DataManager#==============================================================================# ■ RPG::BaseItem#==============================================================================class RPG::BaseItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :ftb_actions #-------------------------------------------------------------------------- # common cache: load_notetags_ftb #-------------------------------------------------------------------------- def load_notetags_ftb @ftb_actions = 0 #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::BASEITEM::FTB_ACTIONS @ftb_actions = $1.to_i end } # self.note.split #--- end end # RPG::BaseItem#==============================================================================# ■ RPG::UsableItem#==============================================================================class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :ftb_cost #-------------------------------------------------------------------------- # common cache: load_notetags_ftb #-------------------------------------------------------------------------- def load_notetags_ftb @ftb_cost = 1 #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::USABLEITEM::FTB_COST @ftb_cost = $1.to_i end } # self.note.split #--- end end # RPG::UsableItem#==============================================================================# ■ BattleManager#==============================================================================module BattleManager #-------------------------------------------------------------------------- # alias method: make_action_orders #-------------------------------------------------------------------------- class <<self; alias make_action_orders_ftb make_action_orders; end def self.make_action_orders make_action_orders_ftb make_ftb_action_orders if btype?:)ftb) end #-------------------------------------------------------------------------- # new method: make_ftb_action_orders #-------------------------------------------------------------------------- def self.make_ftb_action_orders @action_battlers = [] @action_battlers += $game_party.members unless @surprise @action_battlers += $game_troop.members unless @preemptive @action_battlers.each { |battler| battler.make_speed } @action_battlers.sort! {|a,b| a.screen_x <=> b.screen_x } end #-------------------------------------------------------------------------- # alias method: judge_win_loss #-------------------------------------------------------------------------- class <<self; alias judge_win_loss_ftb judge_win_loss; end def self.judge_win_loss if @phase && $game_troop.all_dead? && SceneManager.scene_is?(Scene_Battle) SceneManager.scene.hide_ftb_gauge end judge_win_loss_ftb end end # BattleManager#==============================================================================# ■ Game_BattlerBase#==============================================================================class Game_BattlerBase #-------------------------------------------------------------------------- # new method: init_ftb_actions #-------------------------------------------------------------------------- def init_ftb_actions @used_ftb_actions = 0 end #-------------------------------------------------------------------------- # new method: ftb_actions #-------------------------------------------------------------------------- def ftb_actions init_ftb_actions if @used_ftb_actions.nil? return @used_ftb_actions end #-------------------------------------------------------------------------- # new method: max_ftb_actions #-------------------------------------------------------------------------- def max_ftb_actions n = make_action_times n += agi_bonus_max_ftb_actions n += trait_bonus_max_ftb_actions return [n, 1].max end #-------------------------------------------------------------------------- # new method: agi_bonus_max_ftb_actions #-------------------------------------------------------------------------- def agi_bonus_max_ftb_actions bonus_agi = agi - param_base(6) value_agi = param_base(6) * YEA::FTB::EXTRA_FTB_ACTION_BONUS return (bonus_agi / value_agi).to_i end #-------------------------------------------------------------------------- # new method: trait_bonus_max_ftb_actions #-------------------------------------------------------------------------- def trait_bonus_max_ftb_actions n = 0 if actor? n += self.actor.ftb_actions n += self.class.ftb_actions for equip in equips next if equip.nil? n += equip.ftb_actions end end for state in states next if state.nil? n += state.ftb_actions end return n end #-------------------------------------------------------------------------- # new method: use_ftb_action #-------------------------------------------------------------------------- def use_ftb_action(value = 1) init_ftb_actions if @used_ftb_actions.nil? @used_ftb_actions += value end #-------------------------------------------------------------------------- # alias method: inputable? #-------------------------------------------------------------------------- alias game_battlerbase_inputable_ftb inputable? def inputable? result = game_battlerbase_inputable_ftb return false unless result return result unless SceneManager.scene_is?(Scene_Battle) return result unless BattleManager.btype?:)ftb) return result unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER return max_ftb_actions > ftb_actions end #-------------------------------------------------------------------------- # alias method: skill_conditions_met? #-------------------------------------------------------------------------- alias game_battlerbase_skill_conditions_met_ftb skill_conditions_met? def skill_conditions_met?(skill) return false unless ftb_item_conditions_met?(skill) return game_battlerbase_skill_conditions_met_ftb(skill) end #-------------------------------------------------------------------------- # alias method: item_conditions_met? #-------------------------------------------------------------------------- alias game_battlerbase_item_conditions_met_ftb item_conditions_met? def item_conditions_met?(item) return false unless ftb_item_conditions_met?(item) return game_battlerbase_item_conditions_met_ftb(item) end #-------------------------------------------------------------------------- # new method: ftb_item_conditions_met? #-------------------------------------------------------------------------- def ftb_item_conditions_met?(item) return true unless actor? return true unless SceneManager.scene_is?(Scene_Battle) return true unless BattleManager.btype?:)ftb) return true if BattleManager.in_turn? return $game_party.ftb_actions_remaining >= item.ftb_cost end end # Game_BattlerBase#==============================================================================# ■ Game_Battler#==============================================================================class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # alias method: on_battle_start #-------------------------------------------------------------------------- alias game_battler_on_battle_start_ftb on_battle_start def on_battle_start game_battler_on_battle_start_ftb init_ftb_actions end #-------------------------------------------------------------------------- # alias method: on_turn_end #-------------------------------------------------------------------------- alias game_battler_on_turn_end_ftb on_turn_end def on_turn_end game_battler_on_turn_end_ftb init_ftb_actions end #-------------------------------------------------------------------------- # alias method: make_action_times #-------------------------------------------------------------------------- alias game_battler_make_action_times_ftb make_action_times def make_action_times if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?:)ftb) return make_ftb_action_times else return game_battler_make_action_times_ftb end end #-------------------------------------------------------------------------- # new method: make_ftb_action_times #-------------------------------------------------------------------------- def make_ftb_action_times return action_plus_set.inject(1) {|r, p| p > 0.01 ? r + 1 : r } end end # Game_Battler#==============================================================================# ■ Game_Actor#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # alias method: next_command #-------------------------------------------------------------------------- alias game_actor_next_command_ftb next_command def next_command if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?:)ftb) return false end return game_actor_next_command_ftb end #-------------------------------------------------------------------------- # alias method: prior_command #-------------------------------------------------------------------------- alias game_actor_prior_command_ftb prior_command def prior_command if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?:)ftb) return false end return game_actor_prior_command_ftb end end # Game_Actor#==============================================================================# ■ Game_Party#==============================================================================class Game_Party < Game_Unit #-------------------------------------------------------------------------- # alias method: inputable? #-------------------------------------------------------------------------- alias game_party_inputable_ftb inputable? def inputable? return false unless meet_ftb_requirements? return game_party_inputable_ftb end #-------------------------------------------------------------------------- # new method: meet_ftb_requirements? #-------------------------------------------------------------------------- def meet_ftb_requirements? return true unless BattleManager.btype?:)ftb) return ftb_actions_remaining > 0 end #-------------------------------------------------------------------------- # new method: ftb_actions_remaining #-------------------------------------------------------------------------- def ftb_actions_remaining return ftb_actions_maximum - ftb_actions_used end #-------------------------------------------------------------------------- # new method: ftb_actions_maximum #-------------------------------------------------------------------------- def ftb_actions_maximum n = 0 for member in $game_party.members next unless member.game_battlerbase_inputable_ftb n += member.max_ftb_actions end return [n, YEA::FTB::MAXIMUM_FTB_ACTIONS].min end #-------------------------------------------------------------------------- # new method: ftb_actions_used #-------------------------------------------------------------------------- def ftb_actions_used n = 0 for member in $game_party.members next unless member.game_battlerbase_inputable_ftb n += member.ftb_actions end return n end end # Game_Party#==============================================================================# ■ Window_BattleStatus#==============================================================================class Window_BattleStatus < Window_Selectable #-------------------------------------------------------------------------- # alias method: action_icon #-------------------------------------------------------------------------- alias window_battlestatus_action_icon_ftb action_icon def action_icon(actor) if SceneManager.scene_is?(Scene_Battle) && BattleManager.btype?:)ftb) return Icon.ftb_action if act_ftb_valid?(actor) end return window_battlestatus_action_icon_ftb(actor) end #-------------------------------------------------------------------------- # new method: act_ftb_valid? #-------------------------------------------------------------------------- def act_ftb_valid?(actor) return false unless actor.current_action.nil? || actor.current_action.item.nil? return true unless YEA::FTB::LIMITED_ACTIONS_PER_MEMBER return actor.max_ftb_actions > actor.ftb_actions end end # Window_BattleStatus#==============================================================================# ■ Window_FTB_Gauge#==============================================================================class Window_FTB_Gauge < Window_Base #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(help_window) @help_window = help_window super(0, 0, Graphics.width, fitting_height(1)) self.opacity = 0 self.contents_opacity = 0 self.z = 200 end #-------------------------------------------------------------------------- # refresh #-------------------------------------------------------------------------- def refresh contents.clear draw_empty_icons draw_filled_icons end #-------------------------------------------------------------------------- # draw_empty_icons #-------------------------------------------------------------------------- def draw_empty_icons n = $game_party.ftb_actions_maximum dx = contents.width n.times do dx -= 24 draw_icon(Icon.ftb_empty, dx, 0) end end #-------------------------------------------------------------------------- # draw_filled_icons #-------------------------------------------------------------------------- def draw_filled_icons n = $game_party.ftb_actions_maximum - $game_party.ftb_actions_used dx = contents.width n.times do dx -= 24 draw_icon(Icon.ftb_action, dx, 0) end end #-------------------------------------------------------------------------- # update #-------------------------------------------------------------------------- def update super self.contents_opacity = 0 unless SceneManager.scene_is?(Scene_Battle) return unless SceneManager.scene_is?(Scene_Battle) return unless BattleManager.btype?:)ftb) change_contents_opacity change_y_position end #-------------------------------------------------------------------------- # change_contents_opacity #-------------------------------------------------------------------------- def change_contents_opacity rate = BattleManager.in_turn? ? -8 : 8 self.contents_opacity += rate end #-------------------------------------------------------------------------- # change_y_position #-------------------------------------------------------------------------- def change_y_position self.y = @help_window.visible ? @help_window.height : 0 end end # Window_FTB_Gauge#==============================================================================# ■ Scene_Battle#==============================================================================class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # alias method: create_all_windows #-------------------------------------------------------------------------- alias scene_battle_create_all_windows_ftb create_all_windows def create_all_windows scene_battle_create_all_windows_ftb create_ftb_gauge end #-------------------------------------------------------------------------- # new method: create_ftb_gauge #-------------------------------------------------------------------------- def create_ftb_gauge @ftb_gauge = Window_FTB_Gauge.new(@help_window) end #-------------------------------------------------------------------------- # alias method: start_party_command_selection #-------------------------------------------------------------------------- alias start_party_command_selection_ftb start_party_command_selection def start_party_command_selection start_party_command_selection_ftb refresh_ftb_gauge end #-------------------------------------------------------------------------- # alias method: start_actor_command_selection #-------------------------------------------------------------------------- alias start_actor_command_selection_ftb start_actor_command_selection def start_actor_command_selection start_actor_command_selection_ftb refresh_ftb_gauge end #-------------------------------------------------------------------------- # new method: refresh_ftb_gauge #-------------------------------------------------------------------------- def refresh_ftb_gauge @ftb_gauge.refresh end #-------------------------------------------------------------------------- # new method: hide_ftb_gauge #-------------------------------------------------------------------------- def hide_ftb_gauge @ftb_gauge.hide end #-------------------------------------------------------------------------- # alias method: next_command #-------------------------------------------------------------------------- alias scene_battle_next_command_ftb next_command def next_command if ftb_action? perform_ftb_action else scene_battle_next_command_ftb end end #-------------------------------------------------------------------------- # new method: ftb_action? #-------------------------------------------------------------------------- def ftb_action? return false unless BattleManager.btype?:)ftb) return false if BattleManager.actor.nil? return false if BattleManager.actor.current_action.nil? action = BattleManager.actor.current_action.item return !action.nil? end #-------------------------------------------------------------------------- # new method: perform_ftb_action #-------------------------------------------------------------------------- def perform_ftb_action hide_ftb_action_windows @subject = BattleManager.actor item = @subject.current_action.item execute_action process_event loop do @subject.remove_current_action break if $game_troop.all_dead? break unless @subject.current_action @subject.current_action.prepare execute_action if @subject.current_action.valid? end return if $game_troop.alive_members.size <= 0 process_action_end consume_ftb_action(item) @subject.make_actions @subject = nil show_ftb_action_windows end #-------------------------------------------------------------------------- # new method: consume_ftb_action #-------------------------------------------------------------------------- def consume_ftb_action(item) @subject.use_ftb_action(item.ftb_cost) unless item.nil? refresh_ftb_gauge end #-------------------------------------------------------------------------- # new method: hide_ftb_action_windows #-------------------------------------------------------------------------- def hide_ftb_action_windows @info_viewport.visible = true @status_aid_window.hide @status_window.show @actor_command_window.show end #-------------------------------------------------------------------------- # new method: show_ftb_action_windows #-------------------------------------------------------------------------- def show_ftb_action_windows @info_viewport.visible = true end_ftb_action end #-------------------------------------------------------------------------- # new method: end_ftb_action #-------------------------------------------------------------------------- def end_ftb_action if $game_party.inputable? select_next_member else status_redraw_target(BattleManager.actor) BattleManager.next_command turn_start end end #-------------------------------------------------------------------------- # new method: select_next_member #-------------------------------------------------------------------------- def select_next_member status_redraw_target(BattleManager.actor) last_index = $game_party.battle_members.size - 1 for member in $game_party.battle_members.reverse break if member.inputable? last_index -= 1 end next_command if next_ftb_member?(last_index) return if BattleManager.actor.nil? if BattleManager.actor.index >= last_index && !BattleManager.actor.inputable? prior_command else start_actor_command_selection status_redraw_target(BattleManager.actor) end end #-------------------------------------------------------------------------- # new method: next_ftb_member? #-------------------------------------------------------------------------- def next_ftb_member?(last_index) actor = BattleManager.actor return true if actor.nil? return false if actor.max_ftb_actions > actor.ftb_actions return false if BattleManager.actor.index >= last_index return BattleManager.actor.index != last_index end #-------------------------------------------------------------------------- # alias method: hide_extra_gauges #-------------------------------------------------------------------------- alias scene_battle_hide_extra_gauges_ftb hide_extra_gauges def hide_extra_gauges scene_battle_hide_extra_gauges_ftb @ftb_gauge.hide end #-------------------------------------------------------------------------- # alias method: show_extra_gauges #-------------------------------------------------------------------------- alias scene_battle_show_extra_gauges_ftb show_extra_gauges def show_extra_gauges scene_battle_show_extra_gauges_ftb @ftb_gauge.show end end # Scene_Battle#==============================================================================# # ▼ End of File# #==============================================================================
And here's his Skill Restrictions script:

#==============================================================================# # ▼ Yanfly Engine Ace - Skill Restrictions v1.02# -- Last Updated: 2012.01.23# -- Level: Normal, Hard, Lunatic# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YEA-SkillRestrictions"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.01.23 - Compatibility Update: Doppelganger# 2011.12.12 - Started Script and Finished.# - Added cooldown altering notetags for items.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# Sometimes good game balance depends on restriction mechanics. Of these# mechanics include skill cooldowns, warmups, and the amount of times a skill# can be used (limited uses). Included in this script are features also to# lock cooldowns, reduce cooldown rates, change cooldown values for skills,# skill types, and more. If this isn't enough restriction power, switches may# be used to restrict skills from being used as well as even code.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.# # -----------------------------------------------------------------------------# Actor Notetags - These notetags go in the actors notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# # -----------------------------------------------------------------------------# Class Notetags - These notetags go in the class notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# # -----------------------------------------------------------------------------# Skill Notetags - These notetags go in the skills notebox in the database.# -----------------------------------------------------------------------------# <cooldown: x># Causes the skill to have a cooldown of x once it's used in battle. Skills# with cooldowns cannot be used again until cooldown reaches 0 or until the# battle is over.# # <change cooldown: +x># <change cooldown: -x># This will cause the target's cooldowns for every skill to increase by x or# decrease by x. This selects skills indiscriminately.# # <skill cooldown x: +y># <skill cooldown x: -y># This will cause the target's specific skill x to receive a change in cooldown# by either an increase or decrease of y amount.# # <stype cooldown x: +y># <stype cooldown x: -y># This will cause all of the skills with skill type x to have its cooldowns# changed by y amount. +y increases cooldown turns while -y decreases turns.# # <limited uses: x># This will allow the skill to only be usable x times throughout the course of# battle. Once the skill is used x times, it is disabled until the battle is# over. This effect only takes place during battle.# # <warmup: x># Causes the skill to be sealed until the x turns pass in battle. There's no# way to speed up a warmup manually with the exception of warmup rates.# # <restrict if switch: x># This will restrict the skill if switch x is ON. If switch x is OFF, this# skill will no longer be restricted.# # <restrict any switch: x># <restrict any switch: x, x># This will restrict the skill if any of the x switches are ON. If all of them# are off, then the skill will not be restricted.# # <restrict all switch: x># <restrict all switch: x, x># This will restrict the skill if all of the x switches are ON. If any of them# are off, then the skill will not be restricted.# # <restrict eval># string# string# </restrict eval># For the more advanced users, replace string with code to determine whether# or not the skill is restricted. If multiple lines are used, they are all# considered part of the same line.# # -----------------------------------------------------------------------------# Item Notetags - These notetags go in the items notebox in the database.# -----------------------------------------------------------------------------# <change cooldown: +x># <change cooldown: -x># This will cause the target's cooldowns for every skill to increase by x or# decrease by x. This selects skills indiscriminately.# # <skill cooldown x: +y># <skill cooldown x: -y># This will cause the target's specific skill x to receive a change in cooldown# by either an increase or decrease of y amount.# # <stype cooldown x: +y># <stype cooldown x: -y># This will cause all of the skills with skill type x to have its cooldowns# changed by y amount. +y increases cooldown turns while -y decreases turns.# # -----------------------------------------------------------------------------# Weapon Notetags - These notetags go in the weapons notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# # -----------------------------------------------------------------------------# Armour Notetags - These notetags go in the armours notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# # -----------------------------------------------------------------------------# Enemy Notetags - These notetags go in the enemies notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# # -----------------------------------------------------------------------------# State Notetags - These notetags go in the states notebox in the database.# -----------------------------------------------------------------------------# <cooldown lock># A battler afflicted with cooldown lock will not have cooldowns count down# every turn until the cooldown lock is removed.# # <cooldown rate: x%># When cooldowns are applied from using skills in battle, the cooldown rate can# reduce or increase the finalized amount of turns a battler would need to wait# before being able to use that skill again.# # <warmup rate: x%># Lowers/Raises the amount of turns needed to pass in battle before the warmup# skills become available for usage.# #==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================module YEA module SKILL_RESTRICT #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Cooldown Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Skills with cooldowns cannot be used for some number of turns. Adjust the # settings here on how cooldowns appear in the menu. Cooldowns are only # applied in battle. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- COOLDOWN_COLOUR = 1 # Colour used from "Window" skin. COOLDOWN_SIZE = 20 # Font size used for cooldowns. COOLDOWN_SUFFIX = "%sCD" # Suffix used for cooldowns. COOLDOWN_ICON = 0 # Icon used for cooldowns. Set 0 to disable. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Warmup Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Skills with warmups are unaffected by cooldowns. They become available to # use after a certain number of turns have passed. Warmups are only applied # in battle. Cooldown Rates do not affect warmups but Warmup Rates do. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- WARMUP_COLOUR = 5 # Colour used from "Window" skin. WARMUP_SIZE = 20 # Font size used for warmups. WARMUP_SUFFIX = "%sWU" # Suffix used for warmups. WARMUP_ICON = 0 # Icon used for warmups. Set 0 to disable. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Limited Use Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Some skills have limited uses per battle. These limited uses are reset # at the start and end of each battle and do not apply when used outside of # battle. There are no effects that can affect limited uses. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- LIMITED_COLOUR = 8 # Colour used from "Window" skin. LIMITED_SIZE = 16 # Font size used for used up. LIMITED_TEXT = "Used" # Text used for used up. LIMITED_ICON = 0 # Icon used for used up. Set 0 to disable. end # SKILL_RESTRICTend # YEA#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================module YEA module REGEXP module BASEITEM COOLDOWN_RATE = /<(?:COOL_DOWN_RATE|cooldown rate):[ ](\d+)([%%])>/i COOLDOWN_LOCK = /<(?:COOL_DOWN_LOCK|cooldown lock)>/i WARMUP_RATE = /<(?:WARM_UP_RATE|warmup rate):[ ](\d+)([%%])>/i end # BASEITEM module SKILL COOLDOWN = /<(?:COOL_DOWN|cooldown):[ ](\d+)>/i WARMUP = /<(?:WARM_UP|warmup):[ ](\d+)>/i LIMITED_USES = /<(?:LIMITED_USES|limited uses):[ ](\d+)>/i CHANGE_COOLDOWN = /<(?:CHANGE_COOL_DOWN|change cooldown):[ ]([\+\-]\d+)>/i STYPE_COOLDOWN = /<(?:STYPE_COOL_DOWN|stype cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i SKILL_COOLDOWN = /<(?:SKILL_COOL_DOWN|skill cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i RESTRICT_IF_SWITCH = /<(?:RESTRICT_IF_SWITCH|restrict if switch):[ ](\d+)>/i RESTRICT_ANY_SWITCH = /<(?:RESTRICT_ANY_SWITCH|restrict any switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i RESTRICT_ALL_SWITCH = /<(?:RESTRICT_ALL_SWITCH|restrict all switch):[ ]*(\d+(?:\s*,\s*\d+)*)>/i RESTRICT_EVAL_ON = /<(?:RESTRICT_EVAL|restrict eval)>/i RESTRICT_EVAL_OFF = /<\/(?:RESTRICT_EVAL|restrict eval)>/i end # SKILL module ITEM CHANGE_COOLDOWN = /<(?:CHANGE_COOL_DOWN|change cooldown):[ ]([\+\-]\d+)>/i STYPE_COOLDOWN = /<(?:STYPE_COOL_DOWN|stype cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i SKILL_COOLDOWN = /<(?:SKILL_COOL_DOWN|skill cooldown)[ ](\d+):[ ]([\+\-]\d+)>/i end # ITEM end # REGEXPend # YEA#==============================================================================# ■ Icon#==============================================================================module Icon #-------------------------------------------------------------------------- # self.cooldown #-------------------------------------------------------------------------- def self.cooldown; return YEA::SKILL_RESTRICT::COOLDOWN_ICON; end #-------------------------------------------------------------------------- # self.warmup #-------------------------------------------------------------------------- def self.warmup; return YEA::SKILL_RESTRICT::WARMUP_ICON; end #-------------------------------------------------------------------------- # self.limited #-------------------------------------------------------------------------- def self.limited; return YEA::SKILL_RESTRICT::LIMITED_ICON; end end # Icon#==============================================================================# ■ Numeric#==============================================================================class Numeric #-------------------------------------------------------------------------- # new method: group_digits #-------------------------------------------------------------------------- unless $imported["YEA-CoreEngine"] def group; return self.to_s; end end # $imported["YEA-CoreEngine"] end # Numeric#==============================================================================# ■ DataManager#==============================================================================module DataManager #-------------------------------------------------------------------------- # alias method: load_database #-------------------------------------------------------------------------- class <<self; alias load_database_srs load_database; end def self.load_database load_database_srs load_notetags_srs end #-------------------------------------------------------------------------- # new method: load_notetags_srs #-------------------------------------------------------------------------- def self.load_notetags_srs groups = [$data_actors, $data_classes, $data_skills, $data_weapons, $data_armors, $data_enemies, $data_states, $data_items] for group in groups for obj in group next if obj.nil? obj.load_notetags_srs end end end end # DataManager#==============================================================================# ■ RPG::BaseItem#==============================================================================class RPG::BaseItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :cooldown_rate attr_accessor :cooldown_lock attr_accessor :warmup_rate #-------------------------------------------------------------------------- # common cache: load_notetags_srs #-------------------------------------------------------------------------- def load_notetags_srs @cooldown_rate = 1.0 @warmup_rate = 1.0 #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::BASEITEM::COOLDOWN_RATE @cooldown_rate = $1.to_i * 0.01 when YEA::REGEXP::BASEITEM::COOLDOWN_LOCK @cooldown_lock = true when YEA::REGEXP::BASEITEM::WARMUP_RATE @warmup_rate = $1.to_i * 0.01 #--- end } # self.note.split #--- end end # RPG::BaseItem#==============================================================================# ■ RPG::Skill#==============================================================================class RPG::Skill < RPG::UsableItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :cooldown attr_accessor :warmup attr_accessor :limited_uses attr_accessor :change_cooldown attr_accessor :skill_cooldown attr_accessor :restrict_any_switch attr_accessor :restrict_all_switch attr_accessor :restrict_eval #-------------------------------------------------------------------------- # common cache: load_notetags_srs #-------------------------------------------------------------------------- def load_notetags_srs @cooldown = 0 @warmup = 0 @limited_uses = 0 @change_cooldown = {} @skill_cooldown = {} @restrict_any_switch = [] @restrict_all_switch = [] @restrict_eval = "" @restrict_eval_on = false #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::SKILL::COOLDOWN @cooldown = $1.to_i when YEA::REGEXP::SKILL::WARMUP @warmup = $1.to_i when YEA::REGEXP::SKILL::LIMITED_USES @limited_uses = $1.to_i #--- when YEA::REGEXP::SKILL::CHANGE_COOLDOWN @change_cooldown[0] = $1.to_i when YEA::REGEXP::SKILL::STYPE_COOLDOWN @change_cooldown[$1.to_i] = $2.to_i when YEA::REGEXP::SKILL::SKILL_COOLDOWN @skill_cooldown[$1.to_i] = $2.to_i #--- when YEA::REGEXP::SKILL::RESTRICT_IF_SWITCH @restrict_any_switch.push($1.to_i) when YEA::REGEXP::SKILL::RESTRICT_ANY_SWITCH $1.scan(/\d+/).each { |num| @restrict_any_switch.push(num.to_i) if num.to_i > 0 } when YEA::REGEXP::SKILL::RESTRICT_ALL_SWITCH $1.scan(/\d+/).each { |num| @restrict_all_switch.push(num.to_i) if num.to_i > 0 } #--- when YEA::REGEXP::SKILL::RESTRICT_EVAL_ON @restrict_eval_on = true when YEA::REGEXP::SKILL::RESTRICT_EVAL_OFF @restrict_eval_off = true else @restrict_eval += line.to_s if @restrict_eval_on #--- end } # self.note.split #--- end end # RPG::Skill#==============================================================================# ■ RPG::Item#==============================================================================class RPG::Item < RPG::UsableItem #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :change_cooldown attr_accessor :skill_cooldown #-------------------------------------------------------------------------- # common cache: load_notetags_srs #-------------------------------------------------------------------------- def load_notetags_srs @change_cooldown = {} @skill_cooldown = {} #--- self.note.split(/[\r\n]+/).each { |line| case line #--- when YEA::REGEXP::ITEM::CHANGE_COOLDOWN @change_cooldown[0] = $1.to_i when YEA::REGEXP::ITEM::STYPE_COOLDOWN @change_cooldown[$1.to_i] = $2.to_i when YEA::REGEXP::ITEM::SKILL_COOLDOWN @skill_cooldown[$1.to_i] = $2.to_i #--- end } # self.note.split #--- end end # RPG::Item#==============================================================================# ■ Game_BattlerBase#==============================================================================class Game_BattlerBase #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias game_battlerbase_initialize_srs initialize def initialize game_battlerbase_initialize_srs reset_cooldowns reset_times_used end #-------------------------------------------------------------------------- # new method: reset_cooldowns #-------------------------------------------------------------------------- def reset_cooldowns @cooldown = {} end #-------------------------------------------------------------------------- # new method: reset_times_used #-------------------------------------------------------------------------- def reset_times_used @times_used = {} end #-------------------------------------------------------------------------- # alias method: skill_conditions_met? #-------------------------------------------------------------------------- alias game_battlerbase_skill_conditions_met_srs skill_conditions_met? def skill_conditions_met?(skill) return false if skill_restriction?(skill) return game_battlerbase_skill_conditions_met_srs(skill) end #-------------------------------------------------------------------------- # alias method: pay_skill_cost #-------------------------------------------------------------------------- alias game_battlerbase_pay_skill_cost_srs pay_skill_cost def pay_skill_cost(skill) game_battlerbase_pay_skill_cost_srs(skill) pay_skill_cooldown(skill) end #-------------------------------------------------------------------------- # new method: skill_restriction? #-------------------------------------------------------------------------- def skill_restriction?(skill) if $game_party.in_battle return true if cooldown?(skill) > 0 return true if warmup?(skill) > $game_troop.turn_count return true if limit_restricted?(skill) end return true if switch_restricted?(skill) return true if restrict_eval?(skill) return false end #-------------------------------------------------------------------------- # new method: cooldown? #-------------------------------------------------------------------------- def cooldown?(skill) skill = skill.id if skill.is_a?(RPG::Skill) return @cooldown[skill].nil? ? 0 : @cooldown[skill] end #-------------------------------------------------------------------------- # new method: warmup?(skill) #-------------------------------------------------------------------------- def warmup?(skill) skill = skill.id if skill.is_a?(RPG::Skill) return [$data_skills[skill].warmup * wur, 0].max.to_i end #-------------------------------------------------------------------------- # new method: limit_restricted? #-------------------------------------------------------------------------- def limit_restricted?(skill) return false if skill.limited_uses <= 0 return times_used?(skill) >= skill.limited_uses end #-------------------------------------------------------------------------- # new method: times_used? #-------------------------------------------------------------------------- def times_used?(skill) skill = skill.id if skill.is_a?(RPG::Skill) return @times_used[skill].nil? ? 0 : @times_used[skill] end #-------------------------------------------------------------------------- # new method: update_times_used #-------------------------------------------------------------------------- def update_times_used(skill) skill = skill.id if skill.is_a?(RPG::Skill) reset_times_used if @times_used.nil? @times_used[skill] = 0 if @times_used[skill].nil? @times_used[skill] += 1 end #-------------------------------------------------------------------------- # new method: cdr #-------------------------------------------------------------------------- def cdr n = 1.0 if actor? n *= self.actor.cooldown_rate n *= self.class.cooldown_rate for equip in equips next if equip.nil? n *= equip.cooldown_rate end else n *= self.enemy.cooldown_rate if $imported["YEA-Doppelganger"] && !self.class.nil? n *= self.class.cooldown_rate end end for state in states next if state.nil? n *= state.cooldown_rate end return n end #-------------------------------------------------------------------------- # new method: pay_skill_cooldown #-------------------------------------------------------------------------- def pay_skill_cooldown(skill) return unless $game_party.in_battle skill = skill.id if skill.is_a?(RPG::Skill) set_cooldown(skill, $data_skills[skill].cooldown * cdr) end #-------------------------------------------------------------------------- # new method: set_cooldown #-------------------------------------------------------------------------- def set_cooldown(skill, amount = 0) return unless $game_party.in_battle skill = skill.id if skill.is_a?(RPG::Skill) @cooldown[skill] = [amount, 0].max.to_i end #-------------------------------------------------------------------------- # new method: cooldown_lock? #-------------------------------------------------------------------------- def cooldown_lock? if actor? return true if self.actor.cooldown_lock return true if self.class.cooldown_lock for equip in equips next if equip.nil? return true if equip.cooldown_lock end else return true if self.enemy.cooldown_lock end for state in states next if state.nil? return true if state.cooldown_lock end return false end #-------------------------------------------------------------------------- # new method: update_cooldowns #-------------------------------------------------------------------------- def update_cooldowns(amount = -1, stype_id = 0, skill_id = 0) return if cooldown_lock? reset_cooldowns if @cooldown.nil? for skill in skills skill = $data_skills[skill] if !skill.is_a?(RPG::Skill) next if stype_id != 0 && skill.stype_id != stype_id next if skill_id != 0 && skill.id != skill_id set_cooldown(skill, cooldown?(skill) + amount) end end #-------------------------------------------------------------------------- # new method: wur #-------------------------------------------------------------------------- def wur n = 1.0 if actor? n *= self.actor.warmup_rate n *= self.class.warmup_rate for equip in equips next if equip.nil? n *= equip.warmup_rate end else n *= self.enemy.warmup_rate if $imported["YEA-Doppelganger"] && !self.class.nil? n *= self.class.warmup_rate end end for state in states next if state.nil? n *= state.warmup_rate end return n end #-------------------------------------------------------------------------- # new method: switch_restricted? #-------------------------------------------------------------------------- def switch_restricted?(skill) return true if restrict_any_switch?(skill) return true if restrict_all_switch?(skill) return false end #-------------------------------------------------------------------------- # new method: restrict_any_switch? #-------------------------------------------------------------------------- def restrict_any_switch?(skill) for switch_id in skill.restrict_any_switch return true if $game_switches[switch_id] end return false end #-------------------------------------------------------------------------- # new method: restrict_all_switch? #-------------------------------------------------------------------------- def restrict_all_switch?(skill) return false if skill.restrict_all_switch == [] for switch_id in skill.restrict_all_switch return false unless $game_switches[switch_id] end return true end #-------------------------------------------------------------------------- # new method: restrict_eval? #-------------------------------------------------------------------------- def restrict_eval?(skill) return false if skill.restrict_eval == "" return eval(skill.restrict_eval) end end # Game_BattlerBase#==============================================================================# ■ Game_Battler#==============================================================================class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # alias method: on_battle_start #-------------------------------------------------------------------------- alias game_battler_on_battle_start_srs on_battle_start def on_battle_start game_battler_on_battle_start_srs reset_cooldowns reset_times_used end #-------------------------------------------------------------------------- # alias method: on_battle_end #-------------------------------------------------------------------------- alias game_battler_on_battle_end_srs on_battle_end def on_battle_end game_battler_on_battle_end_srs reset_cooldowns reset_times_used end #-------------------------------------------------------------------------- # alias method: item_apply #-------------------------------------------------------------------------- alias game_battler_item_apply_srs item_apply def item_apply(user, item) game_battler_item_apply_srs(user, item) updated_limited_uses(user, item) end #-------------------------------------------------------------------------- # new method: updated_limited_uses #-------------------------------------------------------------------------- def updated_limited_uses(user, item) return unless $game_party.in_battle return if item.nil? return unless item.is_a?(RPG::Skill) user.update_times_used(item) end #-------------------------------------------------------------------------- # alias method: item_user_effect #-------------------------------------------------------------------------- alias game_battler_item_user_effect_srs item_user_effect def item_user_effect(user, item) game_battler_item_user_effect_srs(user, item) apply_cooldown_changes(user, item) end #-------------------------------------------------------------------------- # new method: apply_cooldown_changes #-------------------------------------------------------------------------- def apply_cooldown_changes(user, item) return unless $game_party.in_battle return if item.nil? #--- if item.change_cooldown != {} for key in item.change_cooldown stype_id = key[0] update_cooldowns(item.change_cooldown[stype_id], stype_id) end @result.success = true end #--- if item.skill_cooldown != {} for key in item.skill_cooldown skill_id = key[0] update_cooldowns(item.skill_cooldown[skill_id], 0, skill_id) end @result.success = true end end end # Game_Battler#==============================================================================# ■ Game_Enemy#==============================================================================class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # new method: skills #-------------------------------------------------------------------------- def skills data = [] for action in enemy.actions next if data.include?(action.skill_id) data.push(action.skill_id) end return data end end # Game_Enemy#==============================================================================# ■ Game_Unit#==============================================================================class Game_Unit #-------------------------------------------------------------------------- # new method: update_restrictions #-------------------------------------------------------------------------- def update_restrictions for member in members; member.update_cooldowns; end end end # Game_Unit#==============================================================================# ■ Window_Base#==============================================================================class Window_Base < Window #-------------------------------------------------------------------------- # new methods: restrict_colours #-------------------------------------------------------------------------- def cooldown_colour; text_color(YEA::SKILL_RESTRICT::COOLDOWN_COLOUR); end; def warmup_colour; text_color(YEA::SKILL_RESTRICT::WARMUP_COLOUR); end; def limited_colour; text_color(YEA::SKILL_RESTRICT::LIMITED_COLOUR); end; end # Window_Base#==============================================================================# ■ Window_SkillList#==============================================================================class Window_SkillList < Window_Selectable #-------------------------------------------------------------------------- # alias method: draw_item #-------------------------------------------------------------------------- alias window_skilllist_draw_item_srs draw_item def draw_item(index) if skill_restriction?(index) draw_skill_restriction(index) else window_skilllist_draw_item_srs(index) end end #-------------------------------------------------------------------------- # new method: skill_restriction? #-------------------------------------------------------------------------- def skill_restriction?(index) skill = @data[index] return false if @actor.nil? return @actor.skill_restriction?(skill) end #-------------------------------------------------------------------------- # new method: draw_item #-------------------------------------------------------------------------- def draw_skill_restriction(index) skill = @data[index] rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y, enable?(skill)) if @actor.limit_restricted?(skill) draw_skill_limited(rect, skill) elsif @actor.cooldown?(skill) > 0 draw_skill_cooldown(rect, skill) elsif warmup_restriction?(skill) draw_skill_warmup(rect, skill) else draw_skill_cost(rect, skill) end end #-------------------------------------------------------------------------- # new method: draw_skill_limited #-------------------------------------------------------------------------- def draw_skill_limited(rect, skill) change_color(limited_colour, enable?(skill)) icon = Icon.limited if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill)) rect.width -= 24 end contents.font.size = YEA::SKILL_RESTRICT::LIMITED_SIZE text = YEA::SKILL_RESTRICT::LIMITED_TEXT draw_text(rect, text, 2) reset_font_settings end #-------------------------------------------------------------------------- # new method: draw_skill_cooldown #-------------------------------------------------------------------------- def draw_skill_cooldown(rect, skill) change_color(cooldown_colour, enable?(skill)) icon = Icon.cooldown if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill)) rect.width -= 24 end contents.font.size = YEA::SKILL_RESTRICT::COOLDOWN_SIZE value = @actor.cooldown?(skill) text = sprintf(YEA::SKILL_RESTRICT::COOLDOWN_SUFFIX, value.group) draw_text(rect, text, 2) reset_font_settings end #-------------------------------------------------------------------------- # new method: warmup_restriction? #-------------------------------------------------------------------------- def warmup_restriction?(skill) return false unless $game_party.in_battle return @actor.warmup?(skill) > $game_troop.turn_count end #-------------------------------------------------------------------------- # new method: draw_skill_warmup #-------------------------------------------------------------------------- def draw_skill_warmup(rect, skill) change_color(warmup_colour, enable?(skill)) icon = Icon.warmup if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill)) rect.width -= 24 end contents.font.size = YEA::SKILL_RESTRICT::WARMUP_SIZE value = @actor.warmup?(skill) - $game_troop.turn_count text = sprintf(YEA::SKILL_RESTRICT::WARMUP_SUFFIX, value.group) draw_text(rect, text, 2) reset_font_settings end end # Window_SkillList#==============================================================================# ■ Scene_Battle#==============================================================================class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # alias method: turn_start #-------------------------------------------------------------------------- alias scene_battle_turn_start_srs turn_start def turn_start $game_party.update_restrictions $game_troop.update_restrictions scene_battle_turn_start_srs end end # Scene_Battle#==============================================================================# # ▼ End of File# #==============================================================================
Thanks so much to anyone who's able to do this! 
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,763
Reaction score
14,007
First Language
English
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.


at OP's request
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

2021? I still wonder if people still doing MV than MZ more
Seeing a lot more active Ace topics recently, is it making a comeback? :o
0-7, left-to-right, top-to-bottom
As soon as I'm able to get out of bed I'm probably gonna go so hyper from being too cooped up, and burn myself out into another awful flare. lol
It makes me feel proud whenever an RM game does well. Even though I had nothing to do with it.

Forum statistics

Threads
107,627
Messages
1,031,013
Members
139,746
Latest member
Krunga
Top