Josephkhland's DnD Style Damage Formula DFWAS

So actuall this is my first script. (DFWAS -> Damage for weapons and Spells). 

I have created 2 methods that can be used in the Damage Formula and change the Combat to a style similar to Dungeons and Dragons 3.5 edition (DnD) combat.

What I mean : 

Well in DnD 3.5 each PC and NPC has an attack bonus and an Armor class.

Attack bonus derives from this equation: class bonus + Strength or Dexterity modifier (depends on the weapon and feats)

Armor class derives from this equation : 10 + armor bonus + (shield bonus) + dexterity modifier +(miscelanious)

In this script I didn't create any new Stats so: 

The attack Bonus comes from : Attack Parameter + Agility bonus (since there is no strength I use agility for all weapons)

and

The Armor class comes from : Defence Parameter (Which includes Armors and shields) + Agility.

So the attacker rolls a 20 sided Dice and adds his attack bonus. If he surpasses his targets armor class means he has hitted his target. 
Then he deals damage equal to his Weapon Damage range (Each weapon may roll with different dices) and also adds his

strength or dexterity bonus (depends on weapon, I haven't included this in my script).

I have not created a complete weapon's list in the script so that users can create their own.

Also in the script, I have a second method for spells.
Some spells in DnD are like weapons, while others set a Difficulty that the defender must surpass with a dice check (DC).
 There are some others that auto-hit , I have included those for no reason in the script but anyway...

The spells that work like weapons , are not exaclty the same as weapons. 
For spells there is also a spellcasting ability bonus (In DnD it is either Intelligence , Wisdom or charisma check -depends on class). In my script I create this with this equation: (Magical Attack / 10 + magical Defence ) / 2

So for this type of spells : Attack Parameter + Spellcasting bonus + Agility must surpass Armor class in order to hit.

Spells tha set a DC , may set a Reflex/Agility DC , Fortitude/Max Health DC, Will DC (there are spots for other DCs as well) . The DC is set by this equation : 11 + spellcasting bonus. 

Here is the script

Spoiler
#-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # DnD Style dmg Formula - Damage for weapons and Spells. # DnD DFWAS v 1.0 #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- ########################################################################### ########################################################################### ### SCRIPT BY Josephkhland ################################################ ### ###################### ################################################ ## ###################### ############################################### # #################### ############################################## #-------------------------------------------------------------------------# ## USAGE ##---------------------------------------------------------------# ##----------------------------# WEAPONS #---------------------------------# ## - In the weapon configuration section below set your weapons.#---------# ## - In the skills you wish to use the following formula just write #-----# ## ## ## a.dnd_wpn(a, ## ## ## ##----------------------------# MAGIC #----------------------------------## ## ## ## a.dnd_magic(a,b,magic,effect,id) ## ## ## ## magic : use an int. Selects in what way to determine if you ## ## succeed or not. 1 for CERTAIN HITS, 2 for SPELLS with ## ## Attack Bonus and Spellcasting ability. ## ## 3 for setting Reflex DC, 4 for Fortitude DC, 5 for Will ## ## DC. You may create your own. ## ## effect : use an int. You may found magic effects at the end of ## ## script, in the method of dnd_magic. You can add your ## ## own effects if you want.By default set to 0 ## ## id : use an int. If you have chosen an effect that adds a ## ## state or anything else with an id just right the id of ## ## the item you want it. By default it is set to 1 ## ##-----------------------------------------------------------------------## ########################################################################### ########################################################################### ########################################################################### ## I hope you like my script. It is uncomplete yet, if you want you cans ## ## suggest some improvements. ## ## ## ## It is not exaclty DnD since I use the original stats ( I just reduced ## ## them to values close to thos of DnD). ## ## Reflex DCs are countered with agility ## ## Fortitude DCs are countered by Max HP / 10 ## ## Will DCs are countered by (Magic attack/10 + Magic Defence)/2 + 1 ## ########################################################################### ########################################################################### class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------# # Formula for Weapons and Monsters #-------------------------------------------------------------------------# def dnd_wpn(a, attackBonus = a.atk + a.agi rolledNumber = 1 + rand(20) is_it_a_hit = rolledNumber + attackBonus if a.actor? #If user is an ACTOR #Weapon enumeration ( ADD ANY MORE WEAPON WITH POSSIBLE DAMAGE HERE) if a.weapons.include?($data_weapons[2]) #Quarterstaff staff_double = rand(2) if staff_double == 0 @wpn_dmg = (1 + rand(6)) else msgbox_p("Staff Lands two strikes") @wpn_dmg = 2 + rand(6) + rand(6) end elsif a.weapons.include?($data_weapons[3]) @wpn_dmg = (1 + rand(6)) elsif a.weapons.include?($data_weapons[4]) @wpn_dmg = (1 + rand(8)) else @wpn_dmg = 1 + rand(3) end else # If user is a MONSTER, you can edit the following section. @wpn_dmg = 1 +rand(6) end #Return value, if attack is NOT MAGIC if rolledNumber == 20 # If critical hit @custom_Formula_Result = @wpn_dmg * 2 elsif is_it_a_hit > b.def + b.agi # if simple hit @custom_Formula_Result = @wpn_dmg else # if no hit @custom_Formula_Result = 0 end return @custom_Formula_Result end #--------------------------------------------------------------------------## # Effects on magic success ## #--------------------------------------------------------------------------## #Method: dnd_magic start---------------------------------------------------## def dnd_magic(a,b,magic,effect = 1,id = 1) attackBonus = a.atk + a.agi rolledNumber = 1 + rand(20) is_it_a_hit = rolledNumber + attackBonus spellcasting_abilityBonus = (a.mat / 10 + a.mdf) /2 if magic == 1 # CERTAIN HIT MAGIC #If you want an effect for all your Certain hit spells put it here. elsif magic == 2 # USE SPELLCASTING Ability Bonus + Attack Bonus is_it_a_hit += spellcasting_abilityBonus if is_it_a_hit > b.def + b.agi msgbox_p("Spell Success") else msgbox_p("Spell Fail") return 0 end elsif magic >= 3 # Countered as a DC spell_DC = 11 + spellcasting_abilityBonus if magic == 3 # Reflex DC - Agility check if spell_DC < 1 + rand(20) + b.agi else return 0 end elsif magic == 4 #Fortitude DC - MHP check if spell_DC < 1 + rand(20) + b.hp / 10 else return 0 end elsif magic == 5 #Will DC - WillPower check willpower = ( b.mat / 10 + b.mdf ) / 2 + 1 if spell_DC < willpower else return 0 end end end ## Determining effect Based on argument if effect == 0 # Damage 1 return (a.mat - b.mdf) elsif effect == 1 # Add State to user a.add_state(id) elsif effect == 2 b.add_state(id) # Add State to target #elsif effect == 3 # Add your own effects here end end #-------------------------------------------------------------dnd_magic end##end #Game_Battler 
 

Well in order to balance the stats, I have these Parameter Ranges (for a Mage class):

Max HP : 6 to 105
Max Mp: 60 to 1050
Attack : 1 to 7

DEF : 10 stable

MAT : 5 to 50

MDF : 1 to 15 

AGI : 1 to 4

Luck : 9 stable

Sorry I don't know how to make scripts that support notetags , so I tried to make it as user-friendly as I could without them.
I hope you like my script and tell me if there can be any improvement...
 
I don't think adding those msgbox_p calls is a good idea for a public script... If you want to add debug messages use the p method so that it prints to the console instead of popping up message boxes...

On your dnd_wpn you took a third parameter called magic which defaults to zero, but you never used it anywhere in that method.

The methods themselves can use a lot of improvement, especially to make them more user-friendly.
Thanks for noticing.  I had the msg things for debugging and I was so consumed with creating the Introduction that I forgot to remove them. 
The same for the extra parameter . At first I had dnd_magic inside dnd_wpn. But then I forgot to remove it. I have removed them now.
Fixed script format, credit Josephkhland.
Code:
#--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # DnD Style dmg Formula - Damage for weapons and Spells.
  # DnD DFWAS v 1.0
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
 
  ###########################################################################
  ###########################################################################
  ### SCRIPT BY Josephkhland ################################################
  ### ###################### ################################################
  ##  ######################  ###############################################
  #    ####################    ##############################################
  #-------------------------------------------------------------------------#
  ## USAGE ##---------------------------------------------------------------#
  ##----------------------------# WEAPONS #---------------------------------#
  ## - In the weapon configuration section below set your weapons.#---------#
  ## - In the skills you wish to use the following formula just write #-----#
  ##                                                                       ##
  ##            a.dnd_wpn(a, b)                                            ##
  ##                                                                       ##
  ##----------------------------# MAGIC #----------------------------------##
  ##                                                                       ##
  ##            a.dnd_magic(a,b,magic,effect,id)                           ##
  ##                                                                       ##
  ##       magic : use an int. Selects in what way to determine if you     ##
  ##               succeed or not. 1 for CERTAIN HITS, 2 for SPELLS with   ##
  ##               Attack Bonus and Spellcasting ability.                  ##
  ##               3 for setting Reflex DC, 4 for Fortitude DC, 5 for Will ##
  ##               DC. You may create your own.                            ##
  ##      effect : use an int. You may found magic effects at the end of   ##
  ##               script, in the method of dnd_magic. You can add your    ##
  ##               own effects if you want.By default set to 0             ##
  ##          id : use an int. If you have chosen an effect that adds a    ##
  ##               state or anything else with an id just right the id of  ##
  ##               the item you want it. By default it is set to 1         ##
  ##-----------------------------------------------------------------------##
  ###########################################################################
  ###########################################################################
  ###########################################################################
  ## I hope you like my script. It is uncomplete yet, if you want you cans ##
  ## suggest some improvements.                                            ##
  ##                                                                       ##
  ## It is not exaclty DnD since I use the original stats ( I just reduced ##
  ## them to values close to thos of DnD).                                 ##
  ## Reflex DCs are countered with agility                                 ##
  ## Fortitude DCs are countered by Max HP / 10                            ##
  ## Will DCs are countered by (Magic attack/10 + Magic Defence)/2 + 1     ##
  ###########################################################################
  ###########################################################################
 
         
class Game_Battler < Game_BattlerBase
  #-------------------------------------------------------------------------#
  # Formula for Weapons and Monsters
  #-------------------------------------------------------------------------#
 
  def dnd_wpn(a, b)
    attackBonus = a.atk + a.agi
    rolledNumber = 1 + rand(20)
    is_it_a_hit = rolledNumber + attackBonus
    if a.actor? #If user is an ACTOR
      #Weapon enumeration ( ADD ANY MORE WEAPON WITH POSSIBLE DAMAGE HERE)
      if a.weapons.include?($data_weapons[2]) #Quarterstaff
        staff_double = rand(2)
        if staff_double == 0
          @wpn_dmg = (1 + rand(6))
        else
          msgbox_p("Staff Lands two strikes")
          @wpn_dmg = 2 + rand(6) + rand(6)
        end
      elsif a.weapons.include?($data_weapons[3])
        @wpn_dmg = (1 + rand(6))
      elsif a.weapons.include?($data_weapons[4])
        @wpn_dmg = (1 + rand(8))
      else
        @wpn_dmg = 1 + rand(3)
      end
    else # If user is a MONSTER, you can edit the following section.
      @wpn_dmg = 1 +rand(6)
    end
    #Return value, if attack is NOT MAGIC
    if rolledNumber == 20                     # If critical hit
      @custom_Formula_Result = @wpn_dmg * 2
    elsif is_it_a_hit > b.def + b.agi         # if simple hit
      @custom_Formula_Result = @wpn_dmg
    else                                      # if no hit
      @custom_Formula_Result = 0
    end
    return @custom_Formula_Result
  end

  #--------------------------------------------------------------------------##
  # Effects on magic success                                                 ##
  #--------------------------------------------------------------------------##
  #Method: dnd_magic start---------------------------------------------------##
  def dnd_magic(a,b,magic,effect = 1,id = 1)
    attackBonus = a.atk + a.agi
    rolledNumber = 1 + rand(20)
    is_it_a_hit = rolledNumber + attackBonus
    spellcasting_abilityBonus = (a.mat / 10 + a.mdf) /2
    if magic == 1              # CERTAIN HIT MAGIC
      #If you want an effect for all your Certain hit spells put it here.
    elsif magic == 2           # USE SPELLCASTING Ability Bonus + Attack Bonus
      is_it_a_hit += spellcasting_abilityBonus
      if is_it_a_hit > b.def + b.agi
        msgbox_p("Spell Success")
      else
        msgbox_p("Spell Fail")
        return 0
      end
    elsif magic >= 3          # Countered as a DC
      spell_DC = 11 + spellcasting_abilityBonus
      if magic == 3   # Reflex DC - Agility check
        if spell_DC < 1 + rand(20) + b.agi
        else
          return 0
        end
      elsif magic == 4       #Fortitude DC - MHP check
        if spell_DC < 1 + rand(20) + b.hp / 10
        else
          return 0
        end
      elsif magic == 5       #Will DC - WillPower check
        willpower = ( b.mat / 10 + b.mdf ) / 2 + 1
        if spell_DC < willpower
        else
          return 0
        end
      end
    end
    ## Determining effect Based on argument
    if effect == 0 # Damage 1
      return (a.mat - b.mdf)
    elsif effect == 1 # Add State to user
      a.add_state(id)  
    elsif effect == 2
      b.add_state(id) # Add State to target
    #elsif effect == 3   # Add your own effects here
    end
  end
  #-------------------------------------------------------------dnd_magic end##
end #Game_Battler

Original thread: https://forums.rpgmakerweb.com/threads/josephkhlands-dnd-style-damage-formula-dfwas.40852/