The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on December 11, 2010, 06:39:53 PM

Title: Recharge Skills
Post by: modern algebra on December 11, 2010, 06:39:53 PM
Recharge Skills
Version: 1.0.1
Author: modern algebra
Date: 1 March 2013

Version History



Description


This allows you to make it so that skills can be set to need to recharge after use. In other words, you can make it so that once an actor uses Heal, he or she cannot use Heal again for x number of turns. This script will also allow you to make items, weapons, and states that can increase or reduce the amount of time it takes to recharge a skill, as well as create items and skills that can immediately recharge any skills that are charging.

Features


Instructions

Place this script in its own slot in the Script Editor, above Main and below other custom scripts.

See the header of the script for use instructions.

Script


Code: [Select]
#==============================================================================
#    Recharge Skills
#    Version: 1.0.1
#    Author: modern algebra (rmrk.net)
#    Date: 1 March 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This allows you to make it so that skills can be set to need to recharge
#   after use. In other words, you can make it so that once an actor uses Heal,
#   he or she cannot use Heal again for x number of turns. This script will
#   also allow you to make items, weapons, and states that can increase or
#   reduce the amount of time it takes to recharge a skill, as well as create
#   items and skills that can immediately recharge any skills that are charging
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script in its own slot in the Script Editor (F11), above Main
#   but below any other custom scripts you might have.
#
#    Configuration is fairly easy. To specify how long a skill needs to take to
#   recharge, all you need to do is place the following code in its notebox:
#      \charge[x]
#   where x is the number of turns you want it to be unavailable for after
#   using it. It must be a positive integer.
#
#    Example:
#      \recharge[2]   # Will wait two turns before you can use this skill again
#
#    To set either an item or skill so that, when used, it will refresh all
#   skills and get rid of any remaining charges so that all skills will be
#   available, all you need to do is put the following code in the notebox:
#      \refresh
#
#    To set a weapon, armor, state, or enemy to reduce or increase the default
#   charge times of a skill, all you need to do is use the following code:
#      \recharge[x]
#
#    You can also specify recharge modifiers by class or actor. See the
#   Configurable Region at line 57 for instructions on setting those up. All
#   recharge modifiers stack, so if your class normally adds 1 and an armor the
#   actor wears adds 2, then it will take 3 extra turns to recharge the skill.
#   Also, recharge mods will only add to skills that have a recharge time to
#   begin with.
#==============================================================================

#==============================================================================
# *** RPG
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    New Constants - CLASS_RECHARGE_MODS, ACTOR_RECHARGE_MODS
#    Modified classes - UsableItem, Skill, Weapon, Armor, State, Enemy
#==============================================================================

module RPG

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  CONFIGURABLE REGION
#``````````````````````````````````````````````````````````````````````````````
#    Here, you can set recharge modifiers for classes and actors, thus allowing
#   the recharge times to be different depending on which actor and what class.
#   They both work the same basic way:
#
#  CLASS_RECHARGE_MODS
#    Each line should look as follows (omitting the < and >):

#    <class ID> => <modifier>,
#
#       class ID : the ID of the class you want to modify. So, by default,
#         1 would be Paladin, 2 would be Warrior, 3 would be Priest, etc...
#       modifier : this can either be an integer or a positive decimal number.
#         If an integer, it will add it to the number of turns. If a decimal
#         number, it will multiply it by the number of turns.
#
#  If you don't do a line for a class, then it defaults to 0 modifier.
#  Remember to put a comma after EVERY one of these lines, except the last.
#
#  EXAMPLES:
#    2 => 1,
#      Whenever an actor with class 2 uses a skill, it will take one extra turn
#      to recharge than it would normally. So, if a skill should take 3 turns 
#      to recharge, it will take 4 turns for actors with this class.
#    7 => 0.5,
#      Whenever an actor with class 7 uses a skill, it will take only half as
#      long to recharge as it would normally. If a skill takes 6 turns
#      normally, it will take 3 turns to recharge for actors with this class.
#
#  ACTOR_RECHARGE_MODS
#    This works the same way, except with actor ID instead of class ID:
#
#    <actor ID> => <modifier>,
#       actor ID : the ID of the actor. So, by default, 1 would be Ralph,
#         2 would be Ulrika, etc...
#       modifier : same as at line 71.
#
#  If you don't do a line for a class, then it defaults to 0 modifier.
#  Remember to put a comma after EVERY one of these lines, except the last.
#
#  EXAMPLES:
#    4 => -2,
#      Whenever Actor 4 uses a skill, it takes 2 less turns to charge. So if
#      the skill normally takes 5 turns, it will take only 3 turns for actor 4.
#    7 => 2.5,
#      Whenever Actor 7 uses a skill it 250% longer to recharge. So if a skill
#      normally takes 2 turns, it will take 5 turns for actor 7.
#
#  You can also change an actor's recharge modifier in game with a script call:
#    $game_actors[<actor ID>] = <modifier>
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CLASS_RECHARGE_MODS = { # <- Do not touch.
  1 => 0,
  2 => 1.0,
} # <- Do not touch.
ACTOR_RECHARGE_MODS = { # <- Do not touch.
  1 => 0,
  2 => 1.0,
} # <- Do not touch.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END CONFIGURABLE REGION
#//////////////////////////////////////////////////////////////////////////////
CLASS_RECHARGE_MODS.default = 0
ACTOR_RECHARGE_MODS.default = 0
 
#==============================================================================
# ** UsableItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - refresh_charges?
#==============================================================================

class UsableItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh_charges?
    return (self.note[/\\REFRESH/i] != nil)
  end
end

#==============================================================================
# ** Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - charge_time
#==============================================================================

class Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Charge Time
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def recharge_time
    return self.note[/\\CHARGE\[(\d+)\]/i] != nil ? $1.to_i : 0
  end
end

#==============================================================================
# ** Weapon, Armor, State, Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - recharge_mod
#    aliased method - ma_reset_note_values (if have Note Editor)
#==============================================================================

["Weapon", "Armor", "State", "Enemy"].each { |class_name|

RS_REGEXP = "/\\\\RECHARGE\\[(-?\\d+)(%?)\\]/i"

CLDEF = <<__END__
class #{class_name}
  def recharge_mod
    if !@recharge_mod
      if self.note[#{RS_REGEXP}] != nil
        if $2.empty?
          @recharge_mod = $1.to_i
        else
          x = $1.to_f / 100.0
          @recharge_mod = x >= 0 ? x : -1*x
        end
      else
        @recharge_mod = 0
      end
    end
    return @recharge_mod
  end
  if self.method_defined? (:ma_reset_note_values)
    alias ma_rchrg_restnot_8ik3 ma_reset_note_values
    def ma_reset_note_values (*args)
      ma_rchrg_restnot_8ik3 (*args) # Run Original Method
      @recharge_mod = nil
    end
  end
end
__END__

eval (CLDEF)

}

end

#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - initialize; skill_can_use?; skill_test; skill_effect;
#      item_test; item_effect
#    new methods - set_skill_recharge; update_skill_recharge; recharge_mod
#==============================================================================

class Game_Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_skilchrg_initz_5tg2 initialize
  def initialize (*args)
    @sc_turns_count = {}
    @sc_turns_count.default = 0
    ma_skilchrg_initz_5tg2 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if Can Use Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgbr_chrgskil_canus_9dv4 skill_can_use?
  def skill_can_use? (skill, *args)
    return false if @sc_turns_count[skill.id] > 0
    return malgbr_chrgskil_canus_9dv4 (skill, *args) # Return Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Test
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mal_rchrgskl_tst_4wp9 skill_test
  def skill_test (user, skill, *args)
    return true if skill.refresh_charges? && !@sc_turns_count.empty?
    return mal_rchrgskl_tst_4wp9 (user, skill, *args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mgba_rchrgskil_efct_2ok7 skill_effect
  def skill_effect (user, skill, *args)
    @sc_turns_count.clear if skill.refresh_charges?
    mgba_rchrgskil_efct_2ok7 (user, skill, *args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item Test
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mogb_rchrg_itmtest_6yh2 item_test
  def item_test (user, item, *args)
    return true if item.refresh_charges? && !@sc_turns_count.empty?
    return mogb_rchrg_itmtest_6yh2 (user, item, *args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malga_rechrge_itmeffect_5th3 item_effect
  def item_effect (user, item, *args)
    @sc_turns_count.clear if item.refresh_charges?
    malga_rechrge_itmeffect_5th3 (user, item, *args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Charge
  #  skill : the skill used
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def set_skill_recharge (skill)
    return if skill.recharge_time == 0
    @sc_turns_count[skill.id] = skill.recharge_time
    direct, percent = recharge_mod
    @sc_turns_count[skill.id] += direct
    @sc_turns_count[skill.id] = (@sc_turns_count[skill.id] * percent).round
    @sc_turns_count[skill.id] += 1
    @sc_turns_count.delete (skill.id) if @sc_turns_count[skill.id] < 1
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear Charge
  #  skill : the skill used
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def clear_skill_recharge(skill_id = 0)
    if skill_id == 0
      @sc_turns_count.clear
    else
      @sc_turns_count.delete(skill_id)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Charges
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_skill_recharge
    for i in @sc_turns_count.keys
      @sc_turns_count[i] -= 1
      @sc_turns_count.delete (i) if @sc_turns_count[i] <= 0
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Recharge Mod
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def recharge_mod
    direct, percent = 0, 1.0
    states.each { |state|
      x = state.recharge_mod
      x.is_a? (Float) ? percent *= x : direct += x
    }
    return direct, percent
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - setup
#    redefined super method - recharge_mod
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :base_recharge
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Actor Setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgb_rechrg_initz_8ik2 setup
  def setup (*args)
    malgb_rechrg_initz_8ik2 (*args) # Run Original Method
    @base_recharge = RPG::ACTOR_RECHARGE_MODS[@actor_id]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Recharge Mod
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def recharge_mod
    direct, percent = super
    class_mod = RPG::CLASS_RECHARGE_MODS[class_id]
    class_mod.is_a? (Float) ? percent *= class_mod : direct += class_mod
    @base_recharge.is_a? (Float) ? percent *= @base_recharge : direct += @base_recharge
    equips.compact.each { |equip|
      x = equip.recharge_mod
      x.is_a? (Float) ? percent *= x : direct += x
    }
    return direct, percent
  end
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    redefined super method - recharge_mod
#==============================================================================

class Game_Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Recharge Mod
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def recharge_mod
    direct, percent = super
    x = enemy.recharge_mod
    x.is_a? (Float) ? percent *= x : direct += x
    return direct, percent
  end
end

#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - execute_action_skill; turn_end
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Battle Action: Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modrn_chrg_exactskil_5th3 execute_action_skill
  def execute_action_skill (*args)
    modrn_chrg_exactskil_5th3 (*args) # Run Original Method
    @active_battler.set_skill_recharge (@active_battler.action.skill)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * End Turn
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias morba_chrgskl_endturn_4tx1 turn_end
  def turn_end (*args)
    if args[0] && args[0].is_a? (Game_Battler) # Tankentai ATB Compatibility
      args[0].update_skill_recharge
    else
      ($game_troop.members + $game_party.members).each { |battler| battler.update_skill_recharge }
    end
    morba_chrgskl_endturn_4tx1 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * End Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias marc_batlend_4kb6 battle_end
  def battle_end(*args)
    $game_party.members.each { |actor| actor.clear_skill_recharge }
    marc_batlend_4kb6(*args) # Call Original Method
  end
end

Credit



Thanks


Support


Please post in this topic for any bug reports or suggestions. Do not PM me.

Known Compatibility Issues

If using this script with the Note Editor, then it should be placed below the General Compatibility Patch.
If using this script with Tankentai ATB, this script must be below it in the Script Editor.
This script is untested with YEM, but is probably incompatible with that battle system.
Title: Re: Recharge Skills
Post by: EvilM00s on December 11, 2010, 07:28:32 PM
You continue to amaze, sir.
Title: Re: Recharge Skills
Post by: heisenman on December 12, 2010, 01:59:17 AM
Very useful for preventing the spamming of certain skills.
Thanks for creating this (:


Quote
This script is untested with YEM, but is probably incompatible with that battle system.
Actually, it would be redundant to use these scripts in conjunction, Melody has the <cooldown: x> notetag.
Title: Re: Recharge Skills
Post by: modern algebra on December 12, 2010, 03:08:11 AM
Glad you both like it! And good to know that YEM already has this feature. No need to worry about making a compatibility patch anytime in the future :)

Cooldown would have been a better word to use than recharge for this script though. Ah well, live and learn.
Title: Re: Recharge Skills
Post by: Lecode on December 12, 2010, 01:53:58 PM
Awesome thank you! =)
Title: Re: Recharge Skills
Post by: hiromu656 on December 19, 2010, 09:53:47 AM
This sounds useful and makes me think of Icewind Dale. Would it be possible for the spells to recharge on Resting? Such as you go to an inn, or somewhere to sleep, then your skills will be usable once more. Along with that, is there a way for me to make it so that I can use the skill a certain number of times before I have to recharge? Such as a healing spell being allowed 3 times before a recharge but a paralyzing spell requiring a recharge after just one.

I like giving examples.
Title: Re: Recharge Skills
Post by: heisenman on December 20, 2010, 12:27:14 AM
Quote
Would it be possible for the spells to recharge on Resting?
"Recharge" gives the wrong idea on what this script actually does lol.
I haven't actually tried this myself, but I think that there's no need to manually recharge the skill outside battle since it just impedes to use certain skills too often.
I suppose at the start of each battle all previous recharges are reset.
Title: Re: Recharge Skills
Post by: modern algebra on December 20, 2010, 12:44:57 AM
Yeah, recharge is a misleading name, perhaps. Cooldown would have been a better name. heisenman is also right that it is not customizable with multiple use and then cooldown stuff. It is not a memorization system like in D&D either - if you really want one like that, I will make it for you, but you have to do the legwork; make a mockup, explain levels, tell me how you want that stuff represented graphically throughout the game menus, etc... It's a lot more work than a little script like this.
Title: Re: Recharge Skills
Post by: apoclaydon on January 01, 2011, 07:04:14 PM
could there be a display next to the item or in its description that states how long the cooldown has left also could a field cooldown be added (wen in map mode i mean)
Title: Re: Recharge Skills
Post by: roundeye on January 06, 2011, 06:03:03 PM
Hmm, I've been getting either a NoMethodError , and in some cases a StackLevel too deep error. The latter being when I start up a new game. I placed the script above the main and below the other custom scripts. I use a modified battle system that mimics the XP battler setup(Not YEM). Could that be the problem?

Title: Re: Recharge Skills
Post by: tSwitch on January 06, 2011, 06:25:19 PM
COOLDOWNS!
Title: Re: Recharge Skills
Post by: Grafikal on January 06, 2011, 06:30:36 PM
Troubleshoot by making a new, blank project. Import this script. Place other scripts you currently use, one at a time, above this script in that blank project. Test play after every single script. Test only 2 scripts at a time, this script and 1 other script. If you get no errors, remove the other script and try a different one in combination with this script until you get the error. When you do get the error, you will know what script that this script is incompatible with. Then ask MA if there's anyway he may be able to change or create a patch for you and that script.
Title: Re: Recharge Skills
Post by: roundeye on January 06, 2011, 08:05:19 PM
Thanks for the advice. Looks like it's working now. The script still won't work with saved files (from before I added it). There were two minor issues, both human error, I think. I may not have copied all of the script originally and I did not think to shut down and reopen the project. So bug-free afterall, I suppose.
Title: Re: Recharge Skills
Post by: Grafikal on January 06, 2011, 08:31:20 PM
Never used saved games after inserting a script. That's dumb. It has different data saved in the file than there was before without that script you added. Therefore you get errors.
Title: Re: Recharge Skills
Post by: Foghart on February 09, 2011, 12:28:10 AM
Its a interesting script, but I've got a question.
There is some script that the skill have to charge before it begin to cast?
Title: Re: Recharge Skills
Post by: Lecode on March 02, 2011, 09:04:18 AM
Hello modern algebra; I have a little request about this script x)
i want to show in windows skill:
The name of skill              Mp cost:...       Can be use in:... turn

I know how to show but i don't have the turn variable.
Can you help me?
Title: Re: Recharge Skills
Post by: modern algebra on March 03, 2011, 12:13:51 AM
It's the method in a Game Actor object:

#sc_turns_count[y]

where y is the ID of the skill. In other words:

Code: [Select]
$game_actors[4].sc_turns_count[31]

would give you the number of turns actor 4 needs to wait before he/she can again use skill 31.
Title: Re: Recharge Skills
Post by: Lecode on March 03, 2011, 03:55:16 PM
Thank you so much =)

EDIT:
I tried but it did not work.
  I had this code,It works but it's not what I wanted:
Code: [Select]
self.contents.draw_text(rect, "Charge:#{skill.recharge_time}", 2)

 Now i use your code,but i have error"Undefined method "sc_turns_count" for Game_Actor...":
 
Code: [Select]
self.contents.draw_text(rect, "Charge:#{@actor.sc_turns_count[skill.id]}", 2)

Why? :o
   
Title: Re: Recharge Skills
Post by: modern algebra on March 03, 2011, 05:39:38 PM
Oh right, sorry - I hadn't made the method accessible from outside the class. Just go up to Recharge skills script and find the line:

Code: [Select]
class Game_Battler

right underneath it, add the line:

Code: [Select]
  attr_reader :sc_turns_count
Title: Re: Recharge Skills
Post by: Lecode on March 03, 2011, 05:49:39 PM
Thank you =D !!
Title: Re: Recharge Skills
Post by: zerothedarklord on March 23, 2011, 11:41:33 PM
is it possible to modify, or for you to easily modify this to also allow cooldowns (recharge time) to items as well? for my game, healing is important, but spamming potions is just downright retarded, and I don't want that shit happening. Also, I have items that invoke super OP states that I don't want spammed, or active on more than 1 person at a time (EX: using guy's immortality state script, I made a potion that, on use, invokes the "Immortality" state, but that'd be kinda retarded if you could put it on everyone so nobody could die, so I would like to be able to add a cooldown to items as well)

If you have to modify it, can you (at least try to) make it so items can share cooldowns?
Title: Re: Recharge Skills
Post by: iTz_Cherry on April 22, 2011, 11:05:12 AM
Sorry for Necroposting,
Keep getting a Syntax error on line 323, a TypeError?
nil can't be coerced into Fixnum.
Help?

EDIT: fixed it, installed a new script and forgot to put this under it xP
Title: Re: Recharge Skills
Post by: oriceles on November 11, 2011, 04:10:54 AM
(I'm new so i don't know, post for support is considered to be necro?)

If i insert :sc_turns_count in YERD_Skill Display can it work?- Also if i use the \refresh note in a skill notebox can i create a skill that refresh other players cooldown but for  making this refresher skill to have 5 turn to refresh?
Title: Re: Recharge Skills
Post by: Wiimeiser on November 11, 2011, 11:37:56 AM
Don't know about ReDux, but if it's Melody you can use the custom data code it provides
Title: Re: Recharge Skills
Post by: oriceles on November 11, 2011, 02:58:41 PM
I'm not using melody, it's too complicated for me, I'm using a mix of all Yanfly engines, from ReDux the only thing that i have is the skill display script, and for battle system I'm using Battle engine zealous (which I tested and doesn't support the script, don't know why :( but i really really want to may it work)
Title: Re: Recharge Skills
Post by: DoctorTodd on November 26, 2011, 07:04:53 AM
Looks cool if only it was compatible with an abs, is there any way were it waits X numbers of seconds instead of turns.
Title: Re: Recharge Skills
Post by: QuesTMajoR on May 11, 2013, 01:25:13 AM
SOrry for NecroPosting! I GOT
line 231 : NameError Occured . undefined 'skill test' for 'Game_Battler'.

Please Help
Title: Re: Recharge Skills
Post by: Project CROSS on August 29, 2015, 03:14:30 PM
necropost;

I also got a problem., the skill has 8 turn cooldown. I dunno if its the number or something else.

(http://i458.photobucket.com/albums/qq302/soul_ravenous/error.jpg)
Title: Re: Recharge Skills
Post by: Project CROSS on September 28, 2015, 06:22:06 PM
Rereply; I just found a bug that when the skill attempts to confuse the caster itself, an error occurs.

Same thing happens when the caster died... like from reflect attack, HP cost, self sacrifice.. any means that takes off the control of the caster after casting a skill with cooldown.