Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #--------------------------------------------------------------------------
- # Multi Hit Skills (RMVX)
- #
- # Author : Logan Forrests
- # With : Mr G W
- # Date Created : 20 August 2011
- # Date Finished : 20 August 2011
- # Last Updated : 03 November 2011
- # Latest Version : 1.1
- #
- #--------------------------------------------------------------------------
- # Version History
- #--------------------------------------------------------------------------
- #
- # v1.1 - 11.03.2011
- # Introduces new paramters:
- # - allowing a missed or evaded hit to stop further damage calculation
- # - Critical hit factored into individual hits
- # Code updated to fit coding standards
- # v1.0 - 08.20.2011
- # Original release of the script
- #
- #--------------------------------------------------------------------------
- # Description
- #--------------------------------------------------------------------------
- # Allows skills to be assigned a specific number of hits.
- #
- # For example, Quad Slash is intended to be a 4-hit physical skill. By
- # specifying this in the Database, the skill would be calculated as if it
- # was dealing 4 individual hits. Each individual hit of a multiple hit skill
- # is calculated seperately with the damage dealt by each hit being cumulitive
- # to provide the total damage dealt. This also means that the accuracy of
- # the skill and the evasion of the target is considered on each hit and not the
- # skill as a whole. Thus, of the 4 hits of Quad Slash, only 2 may hit and
- # contribute towards damage.
- #
- # The messages associated with attacks missing and being evaded will only be
- # shown when all hits of an attack miss or are evaded.
- #
- # Because the properties are kept within an items BaseItem class, it can also
- # be used for Items as well as Skills.
- #
- #--------------------------------------------------------------------------
- # Directions On How To Implement
- #--------------------------------------------------------------------------
- # Assigning the Number of Hits
- # ----------------------------
- # To specify the number of hits a skill has simply use the following the tag
- # within the Note field in the Database of the appropriate skills:
- #
- # <mhs_hits: #> - where # is the number of hits
- #
- # It is advised that skills that are made multiple hit are given a lower than
- # 100 hit ratio. Setting a skill to have a hit ratio of 100 will mean all hits
- # will land unless evaded which may result in a largely unbalanced skill.
- # This is, however, not required and skills may be set a 100 hit ratio if desired.
- #
- # Implementing Critical Hits
- # --------------------------
- # It is possible to assign a critical hit ratio, allowing a skill to sometimes
- # deal a critical blow on any one (or more) or its hits:
- #
- # <mhs_crit: c% d%>
- # - where c is the critical hit chance as a percentage
- # - where d is the critical damage bonus
- #
- # The '%' signs are optional and not required to function properly. It is allowed
- # simply for aesthetic and readability.
- # The value of c should be an integer value between 0 and 100;
- # 0 being no critical hit chance, 100 being always critical.
- # The value of d should be an integer value above 100.
- # Note: A d value of 150 means 150% or 1.5x damage dealt. This is to follow the same
- # calculation style as the default scripts. Thus, setting a value less than
- # 100 will reduce the damage dealt.
- #
- # Ending Damage Calculation Upon a Missed or Evaded Attack
- # --------------------------------------------------------
- # To make a skill stop damage calculation processing when the attack misses
- # or is evaded, the following tag can be used:
- #
- # <mhs_end_on_miss>
- #
- # No additional value is required.
- # This particular additional allows one to create skills that are 'interrupted'
- # should an attack miss somewhere during execution. Using this produces
- # a more realistic* effect but can lead to a much smaller average in damage.
- #
- # *Realistic in the sense that the attacker is caught off-guard when an attack
- # does not connect or is evaded by the target and can no longer continue the
- # barrage of attacks he is delivering. Mostly used for close combat type skills.
- #--------------------------------------------------------------------------
- # Script Installation & Compatibility
- #--------------------------------------------------------------------------
- #
- # Simply place the script in the Materials section of the Script Editor,
- # somewhere above Main.
- # If using this to extend GW Extra Skill Features, this script must be placed
- # below that script.
- #
- # This script is based from GW Extra Skill Features and thus is compatible
- # with it. It is also suggested that the GW Extra Skill Features is used
- # with this script, also it is not necessary.
- #
- # This script overwrites the following the methods:
- # skill_effect
- # - Removes the accuracy and evasion checks from this method.
- # make_obj_damage_value
- # - Includes critical hit damage calculation
- # - The default value can be set within this script in the LF::MHS
- # module; custom values can be assigned on a per skill basis.
- #
- # This script aliases the following methods:
- # make_obj_damage_value
- # - Implements a while loop to allow calculating of cumulative damage
- # for multiple hit skills
- # - Includes accuracy and evasion checks for each hit
- # but only sets the @missed and @evaded flags if all hits of a skill
- # miss or are evaded.
- #--------------------------------------------------------------------------
- # Support & Credit
- #--------------------------------------------------------------------------
- # The script has been written and tested with no other scripts in place. As
- # such, if you encounted any issues with regards to other scripts,
- # first try to resolve the problem by moving this script around. If you are
- # still unable to resolve the problem, feel free to contact me on rmrk.net
- # under the name LoganForrests (no spaces involved) with the name of the
- # script(s) you find no longer work when this script is included and the
- # nature of the problem(s) so that I can begin to work on the problem(s)
- # being caused.
- #
- # Credit must be given if used.
- #
- # Credit must also be given to Mr G W as this script is based and designed from
- # their Extra Skill Features script. When used as an extension to the Extra
- # Skill Features script, this script follows the same copyright restrictions.
- #--------------------------------------------------------------------------
- #==========================================================================
- #============= CUSTOMISE THE SCRIPT HERE ===============
- #==========================================================================
- module LF
- module MHS
- #Allows critical hit bonuses from weapon/actor trait to be included
- # in the critical hit rate check. Will currently only apply to skills
- # which have their Physical Attack flag checked true.
- INCLUDE_USER_BONUSES = true
- #Set the damage multiplier for a critical hit
- # This is the default multiplier; it will be overwritten if a crit hit
- # damage multiplier is also assigned in the Note field of the Skill.
- # A crit multiplier of 3 means that a critical hit will deal 300% damage
- # This value should not be set less than 1 (100% damage) as this will
- # reduce the final damage.
- CRIT_MULTIPLIER = 3
- end
- end
- #==========================================================================
- #============= NO MORE CUSTOMISING THE SCRIPT ===============
- #==========================================================================
- #============= DO NOT EDIT THE CONTENTS BELOW ===============
- #==========================================================================
- class RPG::BaseItem
- #assume 1 hit if not specified
- def skillhits
- self.note[/<mhs_hits: ([-0-9]+)>/]
- return 1 if $1 == nil
- return $1.to_i
- end
- #determine if calculation of damage should end on a miss/evade
- def miss_means_end
- return true if self.note[/<mhs_end_on_miss>/]
- return false
- end
- #chance of critical hit - value is based on percentage
- # First Value : critical hit chance/ratio
- # Second Value : critical hit damage bonus (if provided)
- def mhs_cri
- self.note[/<mhs_crit: ([-0-9]+)(?:[%]*)[ ]*([-0-9]*)(?:[%]*)>/]
- return [$1.to_i, $2.to_i]
- end
- end
- class Game_Battler
- #---------------------------------------------------------------
- # overwrite: skill_effect
- # Removed some checks - see Note at line 123
- #---------------------------------------------------------------
- def skill_effect(user, skill)
- clear_action_results
- unless skill_effective?(user, skill)
- @skipped = true
- return
- end
- #NOTE:
- #removed hit and evasion check from here to make_obj_damage_value
- #in order to perform this check for each hit in a multi hit skill
- #Effect stays the same even if single hit.
- make_obj_damage_value(user, skill) # calculate damage
- make_obj_absorb_effect(user, skill) # calculate absorption effect
- execute_damage(user) # damage reflection
- if skill.physical_attack && @hp_damage == 0 # physical and no damage?
- return
- end
- apply_state_changes(skill) # state change
- end
- #--------------------------------------------------------------------------
- # overwrite: make_obj_damage_value
- # Adds critical hit to obj damage calculation
- #
- #* 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
- #added by LoganForrests
- #to_i used due to possible floating point calculations
- damage = (damage * critical_damage(user, obj)).to_i
- #end added code
- damage = apply_variance(damage, obj.variance) # variance
- damage = apply_guard(damage) # guard adjustment
- if obj.damage_to_mp
- @mp_damage = damage # damage MP
- else
- @hp_damage = damage # damage HP
- end
- end
- def critical_damage(user, obj)
- crit_chance = obj.mhs_cri[0]
- if LF::MHS::INCLUDE_USER_BONUSES && obj.physical_attack
- crit_chance += user.cri
- end
- crit_multi = obj.mhs_cri[1]
- @critical = (rand(100) < crit_chance) # critical hit?
- @critical = false if prevent_critical # criticals prevented?
- if @critical #is a critical hit
- if crit_multi >= 100 #safety net for silly values like 50% damage
- return (crit_multi/100.0).to_i if @critical
- else #otherwise, use 'default' multiplier
- return LF::MHS::CRIT_MULTIPLIER if @critical
- end
- end
- return 1 #1 will ensure normal damage calculation if not critical
- end
- #---------------------------------------------------------------
- # alias method: make_obj_damage_value
- # calculates damage on a per hit basis
- #---------------------------------------------------------------
- alias :lfmhs_modv_gb_cd3e :make_obj_damage_value
- def make_obj_damage_value(user, obj, *args)
- #get number of hits of skill
- hits = obj.skillhits
- #repeat original method for 'hits' number of times,
- #storing the total damage to HP and MP
- #Set default variables
- count = 0 #hit cycle count
- totalhpdamage = 0 #total damage to HP
- totalmpdamage = 0 #total damage to MP (where required)
- miss_count = 0 #for correct message displaying - only if all hits miss
- evade_count = 0 #for correct message displaying - only if all hits evaded
- while (count < hits) #count starts at 0; cycle is: count until hits - 1
- #Check accuracy and evasion
- if rand(100) >= calc_hit(user, obj)
- if obj.miss_means_end
- #stop damage processing by ending while loop
- break
- end
- miss_count += 1 #missed a hit
- count += 1 #next hit
- next
- end
- if rand(100) < calc_eva(user, obj)
- if obj.miss_means_end
- #stop damage processing by ending while loop
- break
- end
- evade_count += 1 #evaded a hit
- count += 1 #next hit
- next
- end
- #check if all hits have been missed or evaded
- if miss_count == hits
- @missed = true
- return #don't process damage; show miss message
- end
- if evade_count == hits
- @evaded = true
- return #don't process damage; show evade message
- end
- #run original to get damage for this current hit
- lfmhs_modv_gb_cd3e(user, obj, *args)
- totalhpdamage += @hp_damage
- totalmpdamage += @mp_damage
- #increase counter
- count += 1
- end
- @hp_damage = totalhpdamage
- @mp_damage = totalmpdamage
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement