Script 1:
##==============================================================================
# Recharge Skills
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: December 11, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 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
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * 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)
$game_troop.turn_ending = true
$game_party.slip_damage_effect
$game_troop.slip_damage_effect
$game_party.do_auto_recovery
$game_troop.preemptive = false
$game_troop.surprise = false
process_battle_event
$game_troop.turn_ending = false
start_turn (*args) # Run Original Method
end
def start_turn (*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
start_party_command_selection
end
end
class Scene_Battle < Scene_Base
def turn_end(*args)
$game_troop.turn_ending = true
$game_party.slip_damage_effect
for i in 0...$game_party.members.size
for state in $game_party.members[i].states
if state.slip_damage
unless $game_party.members[i].dead?
if $game_party.members[i].hp_damage > 0
$game_troop.screen.start_shake(5, 5, 10)
Sound.play_actor_damage
else
Sound.play_recovery
end
@message_window.replace_instant_text($game_party.members[i].slip_damage_message)
wait(COZZIEKUNS::SHOW_SLIP_DAMAGE::WAIT)
break
end
end
end
end
$game_troop.slip_damage_effect
for i in 0...$game_troop.members.size
for state in $game_troop.members[i].states
if state.slip_damage
unless $game_troop.members[i].dead?
if $game_troop.members[i].hp_damage > 0
$game_troop.members[i].blink = true
Sound.play_enemy_damage
else
Sound.play_recovery
end
@message_window.replace_instant_text($game_troop.members[i].slip_damage_message)
wait(COZZIEKUNS::SHOW_SLIP_DAMAGE::WAIT)
$game_troop.members[i].slip_damage_message = nil
break
end
end
end
end
$game_party.do_auto_recovery
$game_troop.preemptive = false
$game_troop.surprise = false
process_battle_event
$game_troop.turn_ending = false
start_turn(*args)
end
end
Script 2:
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
#- Mithran's Critical Skills v 1.4
#- Last update April 16, 2009
#-
#- This script will allow skills to inflict critical damage
#-
#- Usage: Insert the following tags in the note section of skills to modify
#- Critical rate and ability to critical. By default, all skills will
#- with the box "Physical Attack" checked be able to critical.
#-
#- <CANCRIT> Specify to allow this skill to be able to crit
#- <CANNOTCRIT> Specify to disallow this skill to be able to crit
#- These options superceed all of the following. If neither is specified, the
#- default in the cusomization section is used.
#-
#- <Setcrit #> Sets a number chance for the specified skill to crit
#- If the number is not specificed, the chance for this skill to crit will be
#- zero. Examples:
#- <setcrit 50> - 50% chance for the skill to crit
#- <setcrit> - 0% chance for the skill to crit
#-
#- <Pluscrit #> or <Minuscrit #>
#- Sets a number chance to be added to the battler's normal crit
#- chance before determining the skill's chance to crit.
#- Examples:
#- (Actor crit value default is 4)
#- <pluscrit 4> - 8% chance for the skill to crit
#- <minuscrit 2> - 2% chance for the skill to crit
#-
#- <Autocrit> - This skill, if able to crit, will have 100% chance to deal
#- a critical hit. Autocrit will ignore prevent critical option on armors.
#- If you want a skill to automatically critical but not ignore critical
#- protection, simply <setcrit 100>
#-
#- <display critical type #>
#- Sets the vocab to be displayed when the attack is critical
#- 0 - Use Ambiguous
#- 1 - Use Physical
#- 2 - Use Magical
#- 5 - Custom 1
#- 6 - Custom 2
#- 7 - Custom 3
#- Defaults are automatically determined by my phsical/magical ambiguity
#- script, if installed
#- If an invalid index is set, defaults to the text used by Physical attacks
#-
#- <show zero dmg crit>
#- <hide zero dmg crit>
#- Sets whether to allow the critical to register if the attack deals zero
#- damage (combined of mp and hp damage). If you hide a critical, it will
#- not register for other scripts, such as Advacned State Probability
#- This option overrides the default set in the module.
#-
#- KGC Rate Damage support - Skills tagged to use rate damage will never
#- critical, no matter what other settings are set here.
#-
#- Skill Functions support - Skills tagged as exact damage damage will never
#- critical, no matter what other settings are set here.
#-
#- Install: Insert above Main. If you use my Skill Functions script
#- place it below that.
#<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
#==============================================================================#
# * Customization * #
#==============================================================================#
$imported = {} if $imported == nil
$imported["MithranCriticalSkills"] = true
module Vocab
CritToEnemyBase = "Critical Strike!!"
# If a physical attack critical
CritToActorBase = "A painful blow!!"
# If a physical attack critical
CritToEnemyAmbig = "An excellent hit!!"
# If an ambiguous critical (most skills are ambigous, so recommend leaving this)
CritToActorAmbig = "A painful blow!!"
# If If an ambiguous critical (most skills are ambigous, so recommend leaving this)
CritToEnemyMagic = "Critical Hit!!"
# If magical critical
CritToActorMagic = "An excrutiating blast!!"
# If magical critical
# Custom critical text spots
# three are available. Use the <display critical type n> tag to choose one
CritToEnemyCustom1 = "Booom!!"
# n = 5
CritToActorCustom1 = "Booom!!"
# n = 5
CritToEnemyCustom2 = "Whaaam!!"
# n = 6
CritToActorCustom2 = "Whaaam!!"
# n = 6
CritToEnemyCustom3 = "Smaaash!!"
# n = 7
CritToActorCustom3 = "Smaaash!!"
# n = 7
CritToEnemyZero = "A calcualted maneuver!"
# If zero damage is dealt and critical is still on (superceeds other options)
CritToActorZero = "A phantasmal strike!"
# If zero damage is dealt and critical is still on (superceeds other options)
CritToEnemyHeal = "An excellent heal!"
# If a heal is critical (superceeds other options)
CritToActorHeal = "An exceptional heal!"
# If a heal is critical (superceeds other options)
end
module Mithran
module CriticalSkills
SKILLS_CAN_CRIT = true
# If true, skill can crit by default.
# If false, only skills specified with the <CANCRIT> tag will be able to
# deal critical damage
NONPHYSICAL_CAN_CRIT = true
# If false, disallows skills that do not have the box "Physical Attack"
# checked in the database to deal critical damage by default.
# If true, these skills are allowed to crit.
# This setting is overridden by adding the <CANCRIT> tag.
MAGIC_CAN_CRIT = true
# Uses phyiscal/magical ambiguity fix if installed.
# When false, disallows skills defined as magic to deal critical damage
# by default. (By default, these are skills with spi_f > 0)
# If true, these skills are allowed to crit.
# This setting is overridden by adding the <CANCRIT> tag.
ALLOW_ZERO_DMG_CRIT = false
# If this value is false, critical will be turned off automatically when
# an attack scores zero total damage.
# This is mainly for display, but also if you use another script that increases
# other parameters due on a critical (such as Advanced State Probability)
# Recommend leaving this on false and turning the option on indiviudally for
# heavy state inflicting attacks, if you use probability
ALLOW_HEALS = true
# If this option is false, heals will never crit. This overrides even the CANCRIT tag.
# If it is true, heals (base damage in the database must be 0 or lower)
# will be able to critical
# 'Absorbed attacks' due to element reversal, however, will never critical
#==============================================================================#
# * End Customization * #
#==============================================================================#
# AutoCrit String Tag
AUTOCRIT = /<(?:AUTOCRIT|auto_critical)>/i
# Chance of this specific to critical - String Tag
SKILL_CRIT_CHANCE = /<(?:SETCRIT|skill_crit_chance)(\s+\d+)?>/i
# Added chance of this skill to critical - String Tag
PLUS_CRIT_CHANCE = /<(?:PLUSCRIT|add_crit_chance)(\s+\d+)?>/i
MINUS_CRIT_CHANCE = /<(?:MINUSCRIT|subtract_crit_chance)(\s+\d+)?>/i
CAN_CRIT = /<(?:CANCRIT|allow_critical)>/i
CANNOT_CRIT = /<(?:CANNOTCRIT|disallow_critical)>/i
DISPLAY_CRIT = /<display[\s_]?(?:critical|cri|crit)[\s_]?type[\s_]?(\d+)>/i
SHOW_ZERO_DMG = /<(hide|show)[\s_]?(?:zero|0)[\s_]?(?:dmg|damage)[\s_]?(?:critical|cri|crit)>/i
end
end
class StrProc < Proc
unless $@
alias to_ss to_s
def to_s
return self.call
end
end
def +(str)
return self.call + str
end
def -(str)
return self.call + str
end
end
module Vocab
CriticalToEnemy = StrProc.new {
case $crilasthit
when 0
CritToEnemyAmbig
when 1
CritToEnemyBase
when 2
CritToEnemyMagic
when 5
CritToEnemyCustom1
when 6
CritToEnemyCustom2
when 7
CritToEnemyCustom3
when 10
CritToEnemyZero
when 20
CritToEnemyHeal
else
CritToEnemyBase
end
}
CriticalToActor = StrProc.new {
case $crilasthit
when 0
CritToActorAmbig
when 1
CritToActorBase
when 2
CritToActorMagic
when 5
CritToActorCustom1
when 6
CritToActorCustom2
when 7
CritToActorCustom3
when 10
CritToActorZero
when 20
CritToActorHeal
else
CritToActorBase
end
}
end
class RPG::UsableItem
#============================================================================
# Allows the skill critical parameters to be seen outside the instance
#============================================================================
attr_accessor :autocrit # autocrit - ignores prevent critical
attr_accessor :skill_crit_chance # skill critical chance
attr_accessor :plus_crit_chance # plus critical chance
attr_accessor :crit_override # use skill critical modifier
attr_accessor :display_crit_mode # which critical message to display
attr_accessor :show_zero_damage # crit is turned off if zero damage
# By default, no useable skill or item will be allowed to crit
# Redefined by subclass RPG::Skill to allow some skills to crit
def critical_allowed
return false
end
unless method_defined?(:magical?)
def magical?
return spi_f > 0
end
end
unless method_defined?(:ambiguous?)
def ambiguous?
return !(physical_attack || magical?)
end
end
def display_crit_mode
create_critical_skill_cache if @display_crit_mode == nil
return @display_crit_mode
end
def create_critical_skill_cache
@autocrit = false
@skill_crit_chance = nil
@crit_override = false
@plus_crit_chance = 0
if ambiguous?
@display_crit_mode = 0
elsif physical_attack
@display_crit_mode = 1
elsif magical?
@display_crit_mode = 2
else
@display_crit_mode = 1
end
@allow_crit = false
@show_zero_damage = Mithran::CriticalSkills::ALLOW_ZERO_DMG_CRIT
end
def critical_allowed
create_critical_skill_cache if @allow_crit == nil
return @allow_crit
end
end
class RPG::Skill < RPG::UsableItem
#============================================================================
# This method does the actual creating of the skill critical
# attributes through parsing the note file and checking for the specific tags
#============================================================================
def create_critical_skill_cache
@autocrit = false
@skill_crit_chance = nil
@crit_override = false
@plus_crit_chance = 0
@allow_crit = Mithran::CriticalSkills::SKILLS_CAN_CRIT
# if the attack is not physical and skills are allowed to crit by default
if ambiguous?
@display_crit_mode = 0
elsif physical_attack
@display_crit_mode = 1
elsif magical?
@display_crit_mode = 2
else
@display_crit_mode = 1
end
@show_zero_damage = Mithran::CriticalSkills::ALLOW_ZERO_DMG_CRIT
if physical_attack == false && @allow_crit == true
# skill will be allowed to crit if nonphysical can crit
@allow_crit = Mithran::CriticalSkills::NONPHYSICAL_CAN_CRIT
end
# if the attack contains spirt_f value and is allowed to crit by default
if magical? && @allow_crit == true
# skill will be allowed to crit if magical skills can crit
@allow_crit = Mithran::CriticalSkills::MAGIC_CAN_CRIT
end
self.note.split(/[\r\n]+/).each { |line|
case line
when Mithran::CriticalSkills::AUTOCRIT
# if AutoCrit string tag is found
@autocrit = true
when Mithran::CriticalSkills::SKILL_CRIT_CHANCE
# if skill crit chance tag is found, set the skill crit chance
@skill_crit_chance = $1.to_i
when Mithran::CriticalSkills::PLUS_CRIT_CHANCE
# if plus crit chance tag is found, set the plus crit of this skill
@plus_crit_chance += $1.to_i
when Mithran::CriticalSkills::MINUS_CRIT_CHANCE
# if plus crit chance tag is found, set the plus crit of this skill
@plus_crit_chance -= $1.to_i
when Mithran::CriticalSkills::CAN_CRIT
# allow this skill to critical, overriding the default
@allow_crit = true
when Mithran::CriticalSkills::CANNOT_CRIT
# disallow this skill to critical, overriding the default
@allow_crit = false
when Mithran::CriticalSkills::DISPLAY_CRIT
n = $1.to_i
if n >= 0 && n <= 7
@display_crit_mode = n
end
when Mithran::CriticalSkills::SHOW_ZERO_DMG
@show_zero_damage = ($1.downcase == "show")
end
}
if $imported["RateDamage"] #KGC Rate Damage Support
@allow_crit = false if rate_damage_max? || rate_damage?
# rate damage skills will never critical
end
if defined?(Mithran::SkillFunctions)
@allow_crit = false if @exact_damage
end
# if a skill critical chance is specified, override normal crit chance
@crit_override = true unless @skill_crit_chance == nil
end
end
class Game_Battler
alias make_obj_damage_value_skillcrit_mithran make_obj_damage_value
def make_obj_damage_value(user, obj)
make_obj_damage_value_skillcrit_mithran(user, obj)
make_obj_critical_damage_value(user, obj) if obj.critical_allowed
end
def make_obj_critical_damage_value(user, obj)
if $imported["DamageLimit"]
return if @pre_critical && !@critical
end
@critical = determine_obj_critical(user, obj) unless @pre_critical != nil
@critical = true if @pre_critical
if @hp_damage < 0 && obj.base_damage >= 0
@critical = false
elsif @hp_damage <= 0 && @mp_damage < 0 && obj.base_damage >= 0
@critical = false
elsif @hp_damage <= 0 && obj.base_damage <= 0
@critical = false if !Mithran::CriticalSkills::ALLOW_HEALS
elsif @hp_damage <= 0 && @mp_damage < 0 && obj.base_damage <= 0
@critical = false if !Mithran::CriticalSkills::ALLOW_HEALS
end
@mp_damage *= 3 if @critical
@hp_damage *= 3 if @critical
if @hp_damage == 0 && @mp_damage == 0
@critical = false if !obj.show_zero_damage
end
end
def obj_critical_probability(user, obj)
critchance = user.cri # set base critical chance
critchance += obj.plus_crit_chance # critical chance increased by skill
critchance = obj.skill_crit_chance if obj.crit_override
# critical chance is set to the skill specific value if specified
return critchance
end
def determine_obj_critical(user, obj)
result = (rand(100) < obj_critical_probability(user, obj)) # roll to determine critical hit
result = false if prevent_critical # criticals prevented?
result = true if obj.autocrit # autocrits if skill is autocrit
return result
end
end
class Scene_Battle
alias display_critical_skillcrit display_critical
def display_critical(target, obj = nil)
$crilasthit = 1
if obj != nil
$crilasthit = obj.display_crit_mode
end
if target.hp_damage == 0 && target.mp_damage == 0
$crilasthit = 10
elsif (target.hp_damage <= 0 || target.mp_damage <= 0) && !obj.nil? && obj.base_damage <= 0
$crilasthit = 20
end
display_critical_skillcrit(target, obj)
end
end
Script 2 won't work properly unless placed AFTER script 1. but that sometimes causes problems with script 1, the error I was getting was pointing to around line 268 of script 1. can anyone see any problems or troubleshoot this?
What did the error message say and under what conditions did the error occur?
honestly man, I can't tell what the conditions are, just every once in a while after a battle it happens.
I'll give it a look and see if I can make it do it again so I can get you the error info.
it seems to happen when I use an ability with a recharge timer on it. and the error is:
undefined method 'recharge_time' for nil:NilClass
Well, for the moment, try replacing line 265 in my script:
return if skill.recharge_time == 0
with:
return if !skill || skill.recharge_time == 0
That's not a very logical fix and it might cause problems down the road, but I think I will need to see a demo with the error recreated in order to do more. Sorry. I'm having trouble seeing where these two scripts would conflict. Are you sure the Critical Skills script won't work unless it's below Recharge Skills, or is it possible that when you moved it below Recharge Skills, you also moved it below some other custom scripts? If that is the case, it would be possible that one of the other scripts is the problematic one.
Try moving only those two scripts into a demo project, use the recharge timer skill in battle and see if the same error occurs. If it does, share it with me, as I have been unable to recreate the error on my own.
Alright, thanks man, I'll try it out and get you results ASAP.
seems to be working for now bro, thanks a bunch.