Critical Vulnerability Script

Discussion in 'RGSS3 Script Requests' started by SaburoX, Jul 25, 2019.

  1. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    I have a state, Frozen. In addition to making the actor unable to act, I want to make it so that a critical hit multiplier is placed (as freezing something makes it brittle.) So essentially, a target that suffers from this state has a much higher likelihood of receiving critical damage from enemy attacks. I'm looking for a script that would let me add a notetag to this state to that .effect
    I've tried Yanfly LDP Critical, Victor's Critical Hit Effects, and AdiktuzMiko's Critical Ex, but none of them seem to be able to create the effect I'm looking for. Hoping there's something I haven't tried yet, or that someone can give me some guidance.

    Thanks in advance!
     
    #1
  2. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,249
    Likes Received:
    507
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    I wrote this from mobile, give it a try and see if it works for you. I am sorry if there are any typos but coding from mobile is a pain.
    Code:
    #==============================================================================
    # HEIRUKICHI EXTRA CRITICAL MULTIPLIERS
    #==============================================================================
    # Version 1.0.1
    # - Author: Heirukichi
    # - Last update 07-25-2019 [MM-DD-YYYY]
    #==============================================================================
    # TERMS OF USE
    #------------------------------------------------------------------------------
    # This script is licensed under the GNU General Public License 3.0. This means
    # that you can:
    # - use this script for both commercial and non commercial projects as long as
    #   * proper credit is given to me (Heirukichi);
    #   * a link to my website is provided;
    # - modify this script as much as you want as long as
    #   * you do not pretend you wrote the whole script;
    #   * you still give credit to me for the original work;
    #   * you provide a link to my website instead of re-posting my script when you
    #     post the modified version of the script.
    #
    # You can review the complete license here:
    # https://www.gnu.org/licenses/gpl-3.0.html
    #
    # If you are using this script for a commercial game, I would like to receive a
    # link of your game page. The link does not need to contain a free copy of your
    # game and it is only used to keep track of games where my scripts are being
    # used.
    # While this is not mandatory for non commercial games, I really appreciate if
    # you could send me a link regardless of your game being commercial or not.
    # You can contact me using the Contacts form on my website or by sending me a
    # private message on RPG Maker Web forum.
    #
    # IMPORTANT NOTICE:
    # If you want to distribute this code, feel free to do it, but provide a link
    # to my website instead of pasting my script somewhere else.
    #==============================================================================
    # DESCRIPTION
    #------------------------------------------------------------------------------
    # This script allows you to have different critical multipliers for each state.
    #==============================================================================
    # INSTRUCTIONS
    #------------------------------------------------------------------------------
    # Configuring this script is extremely easy.
    # Check the CONFIG module below to learn how to configure it properly.
    #==============================================================================
    # COMPATIBILITY
    #------------------------------------------------------------------------------
    # Minor compatibility issues are possible. More information below.
    #==============================================================================
    $imported = {} if $imported.nil?
    $imported["Heirukichi_ECD"] = true
    #==============================================================================
    # ** HRK_ECD Module
    #==============================================================================
    module HRK_ECD
      #============================================================================
      # ** CONFIG module
      #============================================================================
      module CONFIG
        #==========================================================================
        # List states with their relative multiplier. Those not in the list use the
        # default multiplier.
        # Separate lines using a comma at the end of each line.
        #==========================================================================
        MULTIPLIERS = { # Keep this
          7 => 0.5, # This deals +50% damage compared to normal critical hits
          9 => -0.25 # The guard state reduces damage taken by 25%
        } # Do not remove this
        #==========================================================================
        # List of states with relative critical chance. Those not in the list have
        # a default critical chance. This bonus is ADDITIVE.
        # Separate lines using a comma at the end of each line.
        #==========================================================================
        EXTRA_CHANCE = { # Keep this
          7 => 0.2, # Extra +20% critical chance
          9 => -0.5 # Reduces likelihood of taking critical hits by 50%
        } # Do not remove this
        #==========================================================================
        # Set this to be your default critical multiplier. Default is 3.
        # Changing this might create issues with other scripts that change the
        # default multiplier.
        #==========================================================================
        DEFAULT_CRIT_MULT = 3
      end # end of CONFIG module
      #============================================================================
      # - - - - - - - - - - - - - - - ! WARNING ! - - - - - - - - - - - - - - - - -
      # DO NOT MODIFY AFTER THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING.
      # ANY MODIFICATION AFTER THIS POINT MIGHT PREVENT THE SCRIPT FROM WORKING
      # PROPERLY AND MIGHT CAUSE YOUR GAME TO CRASH. DO IT AT YOUR OWN RISK.
      #============================================================================
      # * Critical Multiplier
      #----------------------------------------------------------------------------
      def self.crit_mul(battler)
        result = CONFIG::DEFAULT_CRIT_MULT / 3.0
        CONFIG::MULTIPLIERS.each_key do |id|
          result += CONFIG::MULTIPLIERS[id] if battler.state?(id)
        end
        result
      end # Critical Multiplier
      #----------------------------------------------------------------------------
      # * Critical Chance
      #----------------------------------------------------------------------------
      def self.crit_chance(battler)
        result = 0
        CONFIG::EXTRA_CHANCE.each_key do |id|
          result += CONFIG::EXTRA_CHANCE[id] if battler.state?(id)
        end
        result
      end # Critical Chance
    end # end of HRK_ECD module
    #------------------------------------------------------------------------------
    # ** Game_Battler class
    #------------------------------------------------------------------------------
    class Game_Battler < Game_BattlerBase
      #----------------------------------------------------------------------------
      # * Aliased method: Apply Critical
      #----------------------------------------------------------------------------
      alias hrk_ecd_apply_critical_old apply_critical
      def apply_critical(damage)
        (hrk_ecd_apply_critical_old(damage) * HRK_ECD.crit_mul(self)).to_i
      end # Apply Critical
      #----------------------------------------------------------------------------
      # * Aliased method: Calculate Critical Rate
      #----------------------------------------------------------------------------
      alias hrk_ecd_item_cri_old item_cri
      def item_cri(user, item)
        hrk_ecd_item_cri_old(user, item) + HRK_ECD.crit_chance(self)
      end # Calculate Critical Rate
    end # end of Game_Battler class
    
     
    Last edited: Jul 25, 2019
    #2
    SaburoX likes this.
  3. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    Thanks for giving this a shot!
    I tried it in my project and it gave me an error so I decided to try it in a fresh one and it's giving me essentially the same:
    Code:
    Game_Battler:508:in `item_apply': wrong number of arguments (2 for 0), ArgumentError
    Any advice on how to fix that?
     
    #3
  4. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,249
    Likes Received:
    507
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Thanks for testing it. I fixed that and you should no longer get that error. I directly modified the script in my previous post, you can copy the fixed version and use it.
     
    #4
  5. SaburoX

    SaburoX Veteran Veteran

    Messages:
    79
    Likes Received:
    7
    That works perfectly. It does exactly what I need. Thanks a ton!
     
    #5

Share This Page