RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: Lettuce on May 14, 2008, 07:33:59 PM
Title: Custom skill damage calculation formula
Post by: Lettuce on May 14, 2008, 07:33:59 PM
Custom skill damage calculation formula Version:1.0ß Author:Lettuce and YOU! Date:May 14, 2008
***Not suitable for those who do not know basic scripting syntax***
Version History
None yet
Planned Future Versions
Version 1.1 will have custom formula for normal attack (though if you study this version, attack formula can easily be changed X_X)
Description
Let you fully customize how skill damages are calculated
Screenshots
Can't post a screenshot for something like this >.<;
Instructions
This is how you do it: 1. Set the base damage of the skill you want to use custom formula with to 9999 2. Set the variance value to something different than others, this will be used as a reference to the custom formula.
Sorry, typo, should say 9999 in the script comment x_x;;
Example
when 1 #Skill with 9999 base damage AND 1 as variance value will use this formula instead of default one damage = ( user.spi**2 ) #damage is user's spi squared (50 spi = 2500 damage) @ignore_def = true #this ignores target's defence @ignore_guard = true #this ignores guarding mode of target (normally guarding reduce damage by 50%)
**INFO** basic math operator + Add - Subtract * Multiply / Divide % Modulus; give you the left over value after division (5 % 2 gives you 1 because 5 can be divided by 2 twice with 1 as a remainder) ** Powering : 5**3 = 5 cubed = 5 x 5 x 5 = 125 Math.exp(x) Exponential : Math.exp(5) = e^5 = 148~ Math.sqrt(x)Square root : Math.sqrt(100) = root(100) = 10 rand(x) Returns random number between 0 and x .floor Round down number .ceil Round up number **Multiplication and division are processed before addition and subtraction! You can overide this by putting a bracket around addition or subtraction ;P 5*3+2 = 17 5*(3+2) = 15
Lets look at what sort of things you can use: **user is the one using the skill, self is the target. If the monster is using the skill, user.hp returns monster's hp and self.agi, return player's agi user.hp self.hp user.mp self.mp user.maxhp self.maxhp user.maxmp self.maxmp user.atk self.atk user.spi self.spi user.def self.def user.agi self.agi user.hit self.hit user.eva self.eva and more o.o
Something to be careful of: - You can use user.level and self.level BUT ONLY if you put "if user.level != nil" OR "if self.level != nil" because Monsters DOES NOT HAVE LEVEL! you'll get error if you don't put that line in there. Same goes for critical
IMPORTANT!! ** total damage MUST be stored in "damage" variable. ** These variables gives you extra control @varience - value used to derive variance, if you @no_variance is false @no_variance - set to true if you want fixed value @is_heal - allows damage to be less than 0. It can still be above 0 and hurt the target though @ignore_def - ignores target's defense @ignore_element - ignores element, no bonus or reduction @ignore_guard - ignore guarding mode, no damage reduction
=begin ???????????????????????????????????????????????????????????????????????????????? ? *** Custom Skill Damage Calculation *** ? ? By Lettuce. ? ? ? ?**Note** ? ? This idea was first brought to us by someone on creationasylum AGES ago ? ? So if you're that person, please contact me and I'll add your name ^_^ ? ???????????????????????????????????????????????????????????????????????????????? This script lets you create your own damage calculation formula for skills
The default formula takes the base damage and add 400% of user's ATK and subtract 200% of target's def. Then apply element, skill variance and guard status
But here you can make a completely custom formula. :D!
INSTRUCTION This is how you do it: 1. Set the base damage of the skill you want to use custom formula with to 9999 2. Set the variance value to something different than others, this will be used as a reference to the custom formula.
Example
when 1 #Skill with 9999 base damage AND 1 as variance value will use this formula instead of default one damage = ( user.spi**2 ) #damage is user's spi squared (50 spi = 2500 damage) @ignore_def = true #this ignores target's defence @ignore_guard = true #this ignores guarding mode of target (normally guarding reduce damage by 50%)
**INFO** basic math operator + Add - Subtract * Multiply / Divide % Modulus; give you the left over value after division (5 % 2 gives you 1 because 5 can be divided by 2 twice with 1 as a remainder) ** Powering : 5**3 = 5 cubed = 5 x 5 x 5 = 125 Math.exp(x) Exponential : Math.exp(5) = e^5 = 148~ Math.sqrt(x)Square root : Math.sqrt(100) = root(100) = 10 rand(x) Returns random number between 0 and x .floor Round down number .ceil Round up number **Multiplication and division are processed before addition and subtraction! You can overide this by putting a bracket around addition or subtraction ;P 5*3+2 = 17 5*(3+2) = 15
Lets look at what sort of things you can use: **user is the one using the skill, self is the target. If the monster is using the skill, user.hp returns monster's hp and self.agi, return player's agi user.hp self.hp user.mp self.mp user.maxhp self.maxhp user.maxmp self.maxmp user.atk self.atk user.spi self.spi user.def self.def user.agi self.agi user.hit self.hit user.eva self.eva and more o.o
Something to be careful of: - You can use user.level and self.level BUT ONLY if you put "if user.level != nil" OR "if self.level != nil" because Monsters DOES NOT HAVE LEVEL! you'll get error if you don't put that line in there. Same goes for critical
IMPORTANT!! ** total damage MUST be stored in "damage" variable. ** These variables gives you extra control @varience - value used to derive variance, if you @no_variance is false @no_variance - set to true if you want fixed value @is_heal - allows damage to be less than 0. It can still be above 0 and hurt the target though @ignore_def - ignores target's defense @ignore_element - ignores element, no bonus or reduction @ignore_guard - ignore guarding mode, no damage reduction
CUSTOMIZATION BEGINS AT LINE 102!
=end
class Game_Battler
#------------------------------------------------------------------------- # * Alias List #------------------------------------------------------------------------- alias Lettuce_make_obj_damage_value make_obj_damage_value
def make_obj_damage_value(user,obj) if obj.base_damage == 9999
@varience = user.hit @no_variance @is_heal = false @ignore_def = false @ignore_element = false @ignore_guard = false case obj.variance #------------------------------------------------------------------------- # ** Begin customization! # # #------------------------------------------------------------------------- when 1 #formula for skill with 9999 base damage and 1 variance multiple = 1 multiple = (user.level / 6).floor + 1 if user.level != nil #every 6 level, this skill get 100% increase multiple = 10 if multiple > 10 #no more increase after level 30 ;P damage = (0.7 * self.def * user.spi**2)/(self.def + user.spi) damage *= multiple damage = damage.floor #final damage, round down @ignore_def = true #ignore target's defence @no_variance = true #fixed damage
when 2 #formula for skill with 9999 base damage and 2 variance damage = (user.atk**2) damage = damage.floor #final damage, round down @ignore_def = true #ignore target's defence
when 3 #skill with 999 base damage and 3 variance will use this damage = $game_party.gold/100 #1% of your gold damage = damage.floor #round down to whole number $game_party.lose_gold(damage) #loose same amoung of gold as the damage #------------------------------------------------------------------------- # ** End customization! # # #-------------------------------------------------------------------------
end unless @ignore_def #this deals with damage decrease from target's def damage -= self.def * 2 * obj.atk_f end damage = 0 if damage < 0 unless @ignore_element damage *= elements_max_rate(obj.element_set) damage /= 100 end #Variance Formula if @no_variance == false variance_range = (100 - user.hit) * 2 #skill variance, can change ;D damage -= rand(variance_range) end
if @is_heal == false damage = 0 if damage < 0 end
if @ignore_guard == false damage = apply_guard(damage) end
if obj.damage_to_mp @mp_damage = damage else @hp_damage = damage end
else Lettuce_make_obj_damage_value end end end
Credit
Lettuce
Thanks
That person who brought this idea upon us in XP version, I can't remember the name and couldn't find a topic (it was ages ago). Do contact me if you know who that is, and I'll add the name to this list~
Support
Just post here or send me pm XD
Known Compatibility Issues
Used Alias, so should work with anything o,o
Demo
This shouldn't really need a demo ;[ but if you REALLY want it, I can post it up XD
Restrictions
Do whatever with it~ But would be nice if you inform me ^o^
Title: Re: Custom skill damage calculation formula
Post by: modern algebra on May 14, 2008, 07:47:26 PM
It looks pretty interesting. Nice work.
Title: Re: Custom skill damage calculation formula
Post by: Demonic Blade on May 16, 2008, 01:08:15 PM
I think it sounds interesting as well, but it seems really advanced. I guess the
Quote from: Lettuce the Veggie!
***Not suitable for those who do not know basic scripting syntax***
is true :P
Title: Re: Custom skill damage calculation formula
Post by: OfficerTJHooker on August 22, 2008, 06:16:51 AM
Excellent script, it's about time someone made a script like this. Oh and, I really doubt that you need much experience in scripting to effectively use this, because essentially all you have to do is enter in a few numbers and make sure you don't do any typos. With a little practice, I think using this script won't be difficult at all.
Title: Re: Custom skill damage calculation formula
Post by: Charbel on May 14, 2009, 07:25:22 PM
very nice thanks :D
Title: Re: Custom skill damage calculation formula
Post by: cilib0h on December 19, 2011, 09:40:28 PM
thanks 4 sharing the script... it really work... but in some event, it get stuck...
i get error in battle when i perform animation effect... how can i fix it? (https://rmrk.net/proxy.php?request=http%3A%2F%2Fi47.servimg.com%2Fu%2Ff47%2F13%2F17%2F06%2F37%2Ferror10.png&hash=8c604bb18070f1fc32ffddbf7870c6b5b5ca8a25)