Minor Update (02/04/08): Condensed the script some and took out the unedited parts to make it shorter (DEMO has NOT been updated with shorter script - but it still works the same).
This is my DnD damage formula. The regular attack formula is almost the same as the real one. The skill formula on the other hand has a home brewed twist. The biggest advantage of this DnD system is that you can control the number of "dice" and the number of "sides" on the dice in the database. You can also set weapons to be melee and ranged, but that has to be done within the script (at the top).
Anyway here's a quick overview of what I think are the pros and cons...
Advantages:
-control damage rolls from database!
-melee and range weapons types
-DnD style damage
Disadvantages:
-can only roll up to 9, 99 sided dice (for normal attack)
-weapon types still have to be assigned in script
-script still needs a little tidying
Ok now for a quick run down of how to control the "dice" in the database...
First we need to go to weapons.
Here the value of ATT is broken down into two parts:
> the first digit is the number of dice
> the second digits are the number of side on the dice
so for example...
106 = 1d6
210 = 2d10
and so on
this means if you had a weapon with 2d8 (ATT = 108) you could "roll" as much as 16
(plus modifiers) or as little as 2 (plus mods).
Further Explanations on Normal Attack:
Skills - a quick run down of what you might wanta know:
After looking at the script one can probably tell I'm still new at scripting so if
anyone finds any bugs or notices something that can be cleaned up please let me
know. (For example how to group all of the 'range' keys together rather then having
to keep making new ones).
Demo: http://www.mediafire.com/?wzyxnbxwy6b
(note* I forgot to set the gun to range attack when I uploaded the demo)
Script:
Anyways hope you like it!
This is my DnD damage formula. The regular attack formula is almost the same as the real one. The skill formula on the other hand has a home brewed twist. The biggest advantage of this DnD system is that you can control the number of "dice" and the number of "sides" on the dice in the database. You can also set weapons to be melee and ranged, but that has to be done within the script (at the top).
Anyway here's a quick overview of what I think are the pros and cons...
Advantages:
-control damage rolls from database!
-melee and range weapons types
-DnD style damage
Disadvantages:
-can only roll up to 9, 99 sided dice (for normal attack)
-weapon types still have to be assigned in script
-script still needs a little tidying
Ok now for a quick run down of how to control the "dice" in the database...
First we need to go to weapons.
Here the value of ATT is broken down into two parts:
> the first digit is the number of dice
> the second digits are the number of side on the dice
so for example...
106 = 1d6
210 = 2d10
and so on
this means if you had a weapon with 2d8 (ATT = 108) you could "roll" as much as 16
(plus modifiers) or as little as 2 (plus mods).
Further Explanations on Normal Attack:
str, dex and int and the modifiers work same as in DnD
(for those of you that aren't familar mod = (stat - 10)/ 2 )
and agi is the attack bonus (AB)
attack roll:
a few of the numbers in the formulas are slightly different (ie: 19 for critical chance and 9 in armour class) because I used rand(20) for attack rolls which includes 0...19 rather then 1...20 but in theory it works almost the same (actually one has a slightly better chance to hit)
again for those who aren't familar with DnD or D20
hit[DnD] = attack roll + stat mod + AB > 10 + AR + dex mod
or
hit[this one] = rand(20) + stat mod + AB > 9 + def + dex mod
(where stat mod is either dex(range) or str(melee))
damage roll:
damage rolls are the same as DnD
dmg = XdY + stat mod (min of 1)
(where X = number of dice and Y = sides)
(for those of you that aren't familar mod = (stat - 10)/ 2 )
and agi is the attack bonus (AB)
attack roll:
a few of the numbers in the formulas are slightly different (ie: 19 for critical chance and 9 in armour class) because I used rand(20) for attack rolls which includes 0...19 rather then 1...20 but in theory it works almost the same (actually one has a slightly better chance to hit)
again for those who aren't familar with DnD or D20
hit[DnD] = attack roll + stat mod + AB > 10 + AR + dex mod
or
hit[this one] = rand(20) + stat mod + AB > 9 + def + dex mod
(where stat mod is either dex(range) or str(melee))
damage roll:
damage rolls are the same as DnD
dmg = XdY + stat mod (min of 1)
(where X = number of dice and Y = sides)
Skills - a quick run down of what you might wanta know:
Skills have more options to them but run similarly to the normal attack.
Rather then explaining the formulas I'll explain how each value in the Skills section of the data base effects them.
SP Cost: same as always
Power: a "skill damage roll" like normal attacks except now the first TWO numbers control the number of dice and the last TWO control the sides. use a negative power for healing skills.
ATK-F: multiplier based on NORMAL damage (note** value is divided by 10)
STR-F: control whether or not a strength modifier is used in the calculations the value controls how much of the multiplier is used by a percent, 100 being the full thing 0 being none at all, a 50 would use half the multiplier.
DEX-F,
INT-F,
AGI-F: all the same as STR-F except for the other stats note you can use as many or as little of the modifiers as you want in your skill calculation
Hit Rate: adjust hit rate by a %
PDEF: controls how much and whether pdef is used in checking if an attack succeeds
MDEF: same as PDEF except for with MDEF
Varaince: nothing at the moment
note* if there is a value > 0 in both Power and ATK-F then the result is added together.
(if one is zero that part will be ignored)
Rather then explaining the formulas I'll explain how each value in the Skills section of the data base effects them.
SP Cost: same as always
Power: a "skill damage roll" like normal attacks except now the first TWO numbers control the number of dice and the last TWO control the sides. use a negative power for healing skills.
ATK-F: multiplier based on NORMAL damage (note** value is divided by 10)
STR-F: control whether or not a strength modifier is used in the calculations the value controls how much of the multiplier is used by a percent, 100 being the full thing 0 being none at all, a 50 would use half the multiplier.
DEX-F,
INT-F,
AGI-F: all the same as STR-F except for the other stats note you can use as many or as little of the modifiers as you want in your skill calculation
Hit Rate: adjust hit rate by a %
PDEF: controls how much and whether pdef is used in checking if an attack succeeds
MDEF: same as PDEF except for with MDEF
Varaince: nothing at the moment
note* if there is a value > 0 in both Power and ATK-F then the result is added together.
(if one is zero that part will be ignored)
After looking at the script one can probably tell I'm still new at scripting so if
anyone finds any bugs or notices something that can be cleaned up please let me
know. (For example how to group all of the 'range' keys together rather then having
to keep making new ones).
Demo: http://www.mediafire.com/?wzyxnbxwy6b
(note* I forgot to set the gun to range attack when I uploaded the demo)
Script:
#==============================================================================
# ** CW: DnD Formula ** ver. 1.01 (02/04/08)
#------------------------------------------------------------------------------
# Clockwise [B.Gale]
# PLEASE GIVE CRIDIT IF YOU ARE GOING TO USE THIS SCRIPT
#
#==============================================================================
class Game_Battler
Default_Weapn = 'Melee'
Type = { 1 => 'Range', 5 => 'Range'}
#===============================================================================
# How to control the "dice" in the database...
# First we need to go to weapons.
# Here the value of ATT is broken down into two parts:
# > the first digit is the number of dice
# > the second digits are the number of side on the dice
# so for example...
# 106 = 1d6
# 210 = 2d10
# and so on
# this means if you had a weapon with 2d8 (ATT = 108) you could "roll" as much as
# 16 (plus modifiers) or as little as 2 (plus mods)
#===============================================================================
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
# attacker : battler
#--------------------------------------------------------------------------
def attack_effect(attacker)
# Clear critical flag
self.critical = false
# Formulas #
atk_roll = rand(20)
atk_bonus = attacker.agi
dodge = ((self.dex - 10) / 2)
hit_con = attacker.hit
if Type.has_key?(attacker.weapon_id)
atk_mod = (attacker.dex - 10) / 2 #Range
else
atk_mod = (attacker.str - 10) / 2 #Melee or Enemy
end
#### CALCULATE #####========================================================
# Hit Detection #
hit_result = (hit_con * (atk_mod + atk_roll + atk_bonus) > 9 + self.pdef + dodge)
if hit_result == true or atk_roll == 19
# Calculate Base Damage #---------------------------------------------
atk = attacker.atk.to_s
dice = atk.chop.chop.to_i
side = atk[-2,2].to_i
self.damage = [dice * rand(side) + atk_mod,1].max
#---------------------------------------------------------------------
# Element correction
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Critical Chance #-------------------------------------------------
if atk_roll == 19
crit_roll = rand(20)
crit_result = (atk_mod + crit_roll + atk_bonus > 9 + self.pdef + dodge)
if crit_result == true
self.damage *= 2
self.critical = true
end
end
#-------------------------------------------------------------------
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Second hit detection
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# If hit occurs
if hit_result == true
# State Removed by Shock
remove_states_shock
# Substract damage from HP
self.hp -= self.damage
# State change
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# When missing
else
# Set damage to "Miss"
self.damage = "Miss"
# Clear critical flag
self.critical = false
end
# End Method
return true
end
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
# If skill scope is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
#### SKILL FORMULAS #####================================================
# Basic Damage Roll #
b_atk = user.atk.to_s
b_dice = b_atk.chop.chop.to_i
b_side = b_atk[-2,2].to_i
base_dmg = [b_dice * rand(b_side),1].max
# Skill Damage Roll #
s_atk = skill.power.to_s
s_dice = s_atk.chop.chop.to_i
s_side = s_atk[-2,2].to_i
skill_dmg = s_dice * rand(s_side)
# Basic Damage Multiplier #
dmg_mod = skill.atk_f
# Stat Modifiers #
stat_mod = ((user.str - 10) / 2) * (skill.str_f / 100)
stat_mod += ((user.dex - 10) / 2) * (skill.dex_f / 100)
stat_mod += ((user.int - 10) / 2) * (skill.int_f / 100)
stat_mod += ((user.agi - 10) / 2) * (skill.agi_f / 100)
# Defenses #
skill_pdef = (self.pdef * skill.pdef_f / 100)
skill_mdef = (((user.int - 10) / 2) + self.mdef) * (skill.mdef_f / 100)
dodge = ((self.dex - 10) / 2)
#===========================================================================
# Hit Detection#
hit = skill.hit
if skill.power > 0 or skill.atk_f > 0
hit *= user.hit / 100
skill_roll = rand(20)
hit_result = (hit * (skill_roll + stat_mod) > skill_pdef + skill_mdef + dodge)
else
hit_result = (hit > rand(100))
stat_mod *= (-1)
end
# Set effective flag if skill is uncertain
effective |= hit < 100 # Set effective flag if skill is uncertain
# If hit occurs
if hit_result == true or skill_roll == 19
### DAMAGE ###------------------------------------------------------------
self.damage = (skill_dmg + (base_dmg * dmg_mod / 10) + stat_mod).to_i
#-------------------------------------------------------------------------
# Element correction #
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Substract damage from HP
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# State change
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0 and skill.atk_f == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
end
# ** CW: DnD Formula ** ver. 1.01 (02/04/08)
#------------------------------------------------------------------------------
# Clockwise [B.Gale]
# PLEASE GIVE CRIDIT IF YOU ARE GOING TO USE THIS SCRIPT
#
#==============================================================================
class Game_Battler
Default_Weapn = 'Melee'
Type = { 1 => 'Range', 5 => 'Range'}
#===============================================================================
# How to control the "dice" in the database...
# First we need to go to weapons.
# Here the value of ATT is broken down into two parts:
# > the first digit is the number of dice
# > the second digits are the number of side on the dice
# so for example...
# 106 = 1d6
# 210 = 2d10
# and so on
# this means if you had a weapon with 2d8 (ATT = 108) you could "roll" as much as
# 16 (plus modifiers) or as little as 2 (plus mods)
#===============================================================================
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
# attacker : battler
#--------------------------------------------------------------------------
def attack_effect(attacker)
# Clear critical flag
self.critical = false
# Formulas #
atk_roll = rand(20)
atk_bonus = attacker.agi
dodge = ((self.dex - 10) / 2)
hit_con = attacker.hit
if Type.has_key?(attacker.weapon_id)
atk_mod = (attacker.dex - 10) / 2 #Range
else
atk_mod = (attacker.str - 10) / 2 #Melee or Enemy
end
#### CALCULATE #####========================================================
# Hit Detection #
hit_result = (hit_con * (atk_mod + atk_roll + atk_bonus) > 9 + self.pdef + dodge)
if hit_result == true or atk_roll == 19
# Calculate Base Damage #---------------------------------------------
atk = attacker.atk.to_s
dice = atk.chop.chop.to_i
side = atk[-2,2].to_i
self.damage = [dice * rand(side) + atk_mod,1].max
#---------------------------------------------------------------------
# Element correction
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Critical Chance #-------------------------------------------------
if atk_roll == 19
crit_roll = rand(20)
crit_result = (atk_mod + crit_roll + atk_bonus > 9 + self.pdef + dodge)
if crit_result == true
self.damage *= 2
self.critical = true
end
end
#-------------------------------------------------------------------
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Second hit detection
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# If hit occurs
if hit_result == true
# State Removed by Shock
remove_states_shock
# Substract damage from HP
self.hp -= self.damage
# State change
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# When missing
else
# Set damage to "Miss"
self.damage = "Miss"
# Clear critical flag
self.critical = false
end
# End Method
return true
end
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
# If skill scope is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
#### SKILL FORMULAS #####================================================
# Basic Damage Roll #
b_atk = user.atk.to_s
b_dice = b_atk.chop.chop.to_i
b_side = b_atk[-2,2].to_i
base_dmg = [b_dice * rand(b_side),1].max
# Skill Damage Roll #
s_atk = skill.power.to_s
s_dice = s_atk.chop.chop.to_i
s_side = s_atk[-2,2].to_i
skill_dmg = s_dice * rand(s_side)
# Basic Damage Multiplier #
dmg_mod = skill.atk_f
# Stat Modifiers #
stat_mod = ((user.str - 10) / 2) * (skill.str_f / 100)
stat_mod += ((user.dex - 10) / 2) * (skill.dex_f / 100)
stat_mod += ((user.int - 10) / 2) * (skill.int_f / 100)
stat_mod += ((user.agi - 10) / 2) * (skill.agi_f / 100)
# Defenses #
skill_pdef = (self.pdef * skill.pdef_f / 100)
skill_mdef = (((user.int - 10) / 2) + self.mdef) * (skill.mdef_f / 100)
dodge = ((self.dex - 10) / 2)
#===========================================================================
# Hit Detection#
hit = skill.hit
if skill.power > 0 or skill.atk_f > 0
hit *= user.hit / 100
skill_roll = rand(20)
hit_result = (hit * (skill_roll + stat_mod) > skill_pdef + skill_mdef + dodge)
else
hit_result = (hit > rand(100))
stat_mod *= (-1)
end
# Set effective flag if skill is uncertain
effective |= hit < 100 # Set effective flag if skill is uncertain
# If hit occurs
if hit_result == true or skill_roll == 19
### DAMAGE ###------------------------------------------------------------
self.damage = (skill_dmg + (base_dmg * dmg_mod / 10) + stat_mod).to_i
#-------------------------------------------------------------------------
# Element correction #
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Substract damage from HP
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# State change
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0 and skill.atk_f == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
end
Anyways hope you like it!