Serpentofshadow
Member
SoS Skill and Item Criticals
Version: 1.1
Introduction
Allows for skills and items to critically hit. Can be based on an actor's normal attack critical or on a factor of their SPI. Many options to make the skill work how you want. Can even set for certain skills or items to have a higher crit chance.
Changes are listed at the beginning of the script.
Features
Screenshots
No screenshots. Shouldn't be needed, but will add if necessary.
Demo
Currently no demo.
Script
Instructions
Place in the Materials section just like any other script.
By default it is set so that the skill determines the critical chance. If a skill has an ATK-F of 1 or more then the normal critical chance is used. If the skill has a SPI-F of 1 or more then the actor's SPI comes into play. By default it is set so that every 10 points of SPI would give a "magic" skill a +1 Crit chance. If the skill uses both ATK-F and SPI-F then an average of both is used.
When using this method you can change the SPI modifier under the module "Serpent_Critical" (in the script). Change the number to whatever you want. The default is 10, which makes it 10 SPI for 1 Skill Crit chance. Note that this does NOT affect the actor's actual crit chance with normal attacks.
In order to change it so that only the actor's default crit chance is used, under the module "Serpent_Critical" (in the script), change "SAME_CRIT" to true.
FAQ
No questions have been asked yet.
Compatibility
MAY conflict with any script that modifies "def make_obj_damage_value(user, obj)" in Game_Battler.
If using any alternate battle system, such as the Sideview Battle System script, just place this script BELOW it.
Credits and Thanks
n/a
Author's Notes
I am taking suggestions for future versions of this script. I'm considering looking into adding an option so that this can be turned off for monsters. Also may add options to allow for stats other than SPI determining crit chance for skills.
Might add in support for weapons and/or armor giving a bonus crit chance to skills and/or items.
Terms and Conditions
Free for non-commercial use so long as I get credit. For commercial use, please e-mail me.
If you are using this script, please let me know. I would merely like to see the games that use it. :smile:
Version: 1.1
Introduction
Allows for skills and items to critically hit. Can be based on an actor's normal attack critical or on a factor of their SPI. Many options to make the skill work how you want. Can even set for certain skills or items to have a higher crit chance.
Changes are listed at the beginning of the script.
Features
- Base it on an actor's natural crit chance
- Alternately can base it on SPI if the spell is magical
- Works for both actors and enemies
- Can be set to work with items
- Can be set to work with healing skills
- Many options allowing for a lot of customization
Screenshots
No screenshots. Shouldn't be needed, but will add if necessary.
Demo
Currently no demo.
Script
Code:
#==============================================================================
# SoS Skill_Item Criticals
#------------------------------------------------------------------------------
# Description:
# Â Â Â Â Â Â Â Allows skills and items to critically hit
#------------------------------------------------------------------------------
# By: Serpentofshadow
# 2/11/09
# Version 1.1
#------------------------------------------------------------------------------
# VERSION HISTORY:
# Â 1.0 - Released
# Â 1.1 - Added exclusion options for skills and items
# Â Â Â - Fixed a bug with the calculations
# Â Â Â - Option for healing skills to crit
# Â Â Â - Added toggle for items
# Â Â Â - Customizable Crit Adjustment for skills & items
# Â Â Â - Options for healing items to crit
#------------------------------------------------------------------------------
# INSTRUCTIONS:
# Â Paste this above main
# Â Customize the Serpent_Critical module if needed (optional)
# Â Customize the "critical_adjustment" definitions if needed (optional)
# Â Place this below any scripts that modify Game_Battler
#==============================================================================
Â
#==============================================================================
# SETUP
# Â Modify the settings below to your liking
#==============================================================================
module Serpent_Critical
 #Skill critical chance is the same as normal attack critical chance
 # Setting to false will base it off a stat
 # When false, the skill's atk_f and spi_f will determine the crit chance
 # If a skill has both then it will take the average of the two chances
 #Default is false
 SAME_CRIT = false
Â
 #Determines how many points in the chosen stat will result in 1 crit chance
 #Default is 10
 STAT_MOD = 10
Â
 #Determines if negative damage values can crit
 #This affects healing skills
 #Default for this script is true
 #Default for RMVX is false
 NEGATIVE_CRIT = true
Â
 #Determines if Items can critically hit
 #Default is true
 ITEM_CRIT = true
Â
 #Determines if Healing Items can critically hit
 #Has no effect if ITEM_CRIT is FALSE
 #Default is true
 HEALITEM_CRIT = true
Â
 #Chance a healing item will crit
 #Has no effect if ITEM_CRIT or HEALITEM_CRIT are FALSE
 #Default for this script is 2
 #To make it the same as the default crit chance, set to 4
 ITEM_CHANCE = 2
Â
 #Multiplier for healing item criticals
 #Has no effect if ITEM_CRIT or HEALITEM_CRIT are FALSE
 #Default for this script is 2
 #To make it the same as the default crit multiplier, set to 3
 ITEM_MULT = 2
Â
 #Skills that cannot critically hit (enter in skill ID)
 #Leave [] empty for all skills to critically hit
 EXCLUDED_SKILLS = []
Â
 #Items that cannot critically hit (enter in item ID)
 #Leave [] empty for all items to critically hit
 #NOTE: Only items that deal damage or recover HP/MP will be affected
 # This also depends on the above settings
 EXCLUDED_ITEMS = []
Â
end
Â
#==============================================================================
# RPG::Skill
#------------------------------------------------------------------------------
#  Skill Critical Settings
#==============================================================================
class RPG::Skill < RPG::UsableItem
 #This is for setting specific critical rates for skills
 #Make a "when" statement for any skill that has a higher or lower chance
 # to critically hit
 #In the "when" statement, return the modifier you want for that skill
 #ex:
 # "when 1" (this means the skill with an ID of 1 is being modified)
 #  "return 2" (this means skill 1 has an additional +2 crit chance)
 def critical_adjust
  case @id
   when 1
    return 0
   when 2
    return 0
  end
  #Default Critical Adjustment is 0
  return 0
 end
end
Â
#==============================================================================
# RPG::Item
#------------------------------------------------------------------------------
#  Item Critical Settings
#==============================================================================
class RPG::Item < RPG::UsableItem
 #This is for setting specific critical rates for items
 #Make a "when" statement for any item that has a higher or lower chance
 # to critically hit
 #In the "when" statement, return the modifier you want for that item
 #ex:
 # "when 1" (this means the item with an ID of 1 is being modified)
 #  "return 2" (this means item 1 has an additional +2 crit chance)
 def critical_adjust
  case @id
   when 1
    return 0
   when 2
    return 0
  end
  #Default Critical Adjustment is 0
  return 0
 end
end
Â
#==============================================================================
# END OF SETUP
#==============================================================================
Â
Â
#==============================================================================
# Game_Battler
#==============================================================================
class Game_Battler
 #--------------------------------------------------------------------------
 # * Calculation of Damage Caused by Skills or Items
 #   user : User of skill or item
 #   obj  : Skill or item (for normal attacks, this is nil)
 #   The results are substituted for @hp_damage or @mp_damage.
 #--------------------------------------------------------------------------
 def make_obj_damage_value(user, obj)
  damage = obj.base_damage             # get base damage
  if damage > 0                  # a positive number?
   damage += user.atk * 4 * obj.atk_f / 100    # Attack F of the user
   damage += user.spi * 2 * obj.spi_f / 100    # Spirit F of the user
   unless obj.ignore_defense           # Except for ignore defense
    damage -= self.def * 2 * obj.atk_f / 100   # Attack F of the target
    damage -= self.spi * 1 * obj.spi_f / 100   # Spirit F of the target
   end
   damage = 0 if damage < 0            # If negative, make 0
  elsif damage < 0                 # a negative number?
   damage -= user.atk * 4 * obj.atk_f / 100    # Attack F of the user
   damage -= user.spi * 2 * obj.spi_f / 100    # Spirit F of the user
  end
  damage *= elements_max_rate(obj.element_set)   # elemental adjustment
  damage /= 100
 Â
  #SoS Addition
  #Check if the skill is not capable of a critical
  if obj.is_a?(RPG::Skill) && Serpent_Critical::EXCLUDED_SKILLS.include?(obj.id)
   #do nothing
  elsif Serpent_Critical::ITEM_CRIT == false
   #do nothing
  elsif Serpent_Critical::ITEM_CRIT == true && obj.is_a?(RPG::Item) && Serpent_Critical::EXCLUDED_ITEMS.include?(obj.id)
   #do nothing
  else
   #Calculate the critical
   if Serpent_Critical::SAME_CRIT == true
    if damage > 0 || Serpent_Critical::NEGATIVE_CRIT == true
     if (obj.critical_adjust == 0)
      @critical = (rand(100) < user.cri)     # critical hit?
     else
      @critical = (rand(100) < (user.cri + obj.critical_adjust))    Â
     end
    Â
     @critical = false if prevent_critical     # criticals prevented?
     damage *= 3 if @critical            # critical adjustment
    end
   else
    if damage > 0 || Serpent_Critical::NEGATIVE_CRIT == true
     serptemp = 0
     if obj.atk_f > 0 && obj.spi_f > 0
      serptemp = (user.cri + (user.spi / Serpent_Critical::STAT_MOD)) / 2
     elsif obj.spi_f > 0
      serptemp = user.spi / Serpent_Critical::STAT_MOD
     else
      serptemp = user.cri
     end
     if serptemp < 1
      serptemp = 1
     end
Â
     if (obj.critical_adjust == 0)
      @critical = (rand(100) < serptemp)     # critical hit?
     else
      @critical = (rand(100) < (serptemp + obj.critical_adjust))    Â
     end
    Â
     @critical = false if prevent_critical     # criticals prevented?
     damage *= 3 if @critical            # critical adjustment
    end
   end
  Â
  #End of SoS Addition
 Â
  damage = apply_variance(damage, obj.variance)  # variance
  damage = apply_guard(damage)           # guard adjustment
 Â
  #SoS Addition
  #Healing Item Criticals
   if (Serpent_Critical::ITEM_CRIT == true && Serpent_Critical::HEALITEM_CRIT == true)
    if obj.is_a?(RPG::Item)
     if (obj.critical_adjust == 0)
      @critical = (rand(100) < Serpent_Critical::ITEM_CHANCE)     # critical hit?
     else
      @critical = (rand(100) < obj.critical_adjust)    Â
     end
    Â
     if @critical == true
      if (obj.hp_recovery > 0)
       damage = calc_hp_recovery(user, obj)
       damage *= Serpent_Critical::ITEM_MULT
       damage *= -1
      elsif (obj.mp_recovery > 0)
       damage = calc_mp_recovery(user, obj)
       damage *= Serpent_Critical::ITEM_MULT
       damage *= -1
      end
     end
    end
   end
  end
  #End of SoS Addition
 Â
  if obj.damage_to_mp Â
   @mp_damage = damage              # damage MP
  else
   @hp_damage = damage              # damage HP
  end
 end
end
#==============================================================================
# End of Script
#==============================================================================
Instructions
Place in the Materials section just like any other script.
By default it is set so that the skill determines the critical chance. If a skill has an ATK-F of 1 or more then the normal critical chance is used. If the skill has a SPI-F of 1 or more then the actor's SPI comes into play. By default it is set so that every 10 points of SPI would give a "magic" skill a +1 Crit chance. If the skill uses both ATK-F and SPI-F then an average of both is used.
When using this method you can change the SPI modifier under the module "Serpent_Critical" (in the script). Change the number to whatever you want. The default is 10, which makes it 10 SPI for 1 Skill Crit chance. Note that this does NOT affect the actor's actual crit chance with normal attacks.
In order to change it so that only the actor's default crit chance is used, under the module "Serpent_Critical" (in the script), change "SAME_CRIT" to true.
FAQ
No questions have been asked yet.
Compatibility
MAY conflict with any script that modifies "def make_obj_damage_value(user, obj)" in Game_Battler.
If using any alternate battle system, such as the Sideview Battle System script, just place this script BELOW it.
Credits and Thanks
n/a
Author's Notes
I am taking suggestions for future versions of this script. I'm considering looking into adding an option so that this can be turned off for monsters. Also may add options to allow for stats other than SPI determining crit chance for skills.
Might add in support for weapons and/or armor giving a bonus crit chance to skills and/or items.
Terms and Conditions
Free for non-commercial use so long as I get credit. For commercial use, please e-mail me.
If you are using this script, please let me know. I would merely like to see the games that use it. :smile: