RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Custom skill damage calculation formula

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 85
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

CUSTOMIZATION BEGINS AT LINE 102!

Script


Spoiler for:
Code: [Select]
=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^

"The pinata is full of shaving cream!"
My scripts:

My skins:


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It looks pretty interesting. Nice work.

***
Rep:
Level 86
I hate everyone except the ones I don't hate...
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
I wonder how many of my-reps are there for a reason, and not just because some jackass wanted to show off in front of some other jackasses...?
Probably a lot of them - and those people sure as hell don't deserve my pity, let alone my disgust.
That's right, let's see some more -Rep'ing! BOOYEAH!!

**
Rep: +0/-0Level 85
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.

**
Rep: +0/-0Level 84
very nice
thanks  :D

**
Rep: +0/-0Level 73
RMRK Junior
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?


thank you..