The source was originally scrapped from one of my old unfinished projects.
I decided to upload it since one of my friends asked me for the armor calculations i did so i wanted to share it with everyone.
This source is not for further updates as i’m just sharing the calculations i used, you can always share your ideas and changes in the replies.
Video Example
shotgun had very low penetrationlevel and power
Basic Armor Properties
- ArmorLevel (1 to 6, the higher the stronger armor is)
- Destructubility (from 0 to 1, the higher the weaker armor will be) (basically how easy to lower the armor’s durability)
- Durability (from 0 to 1, the higher the more stable armor is) (1 = unbreakable)
- MaxDurability (says for itself)
Bullet Properties
-
PenetrationLevel (same as ArmorLevel) (for example if bullet and armor are the same level it will have 50% chance to penetrate BUT without the PenetrationPower)
-
PenetrationPower (bullet’s level’s power for armor penetration, for more precise calculations) (from 1 to 100, the higher number the easier for bullet to penetrate)
-
BulletForce (how strong the bullet is, the higher the more damage bullet does if it didn’t penetrate the armor) (from 1 to inf)
-
BulletDamage (says for itself, will be used to hit unarmored or when penetrated target)
Calculations Part
1. Calculating damage armor will take
ArmorDamage = Destructibility * PenetrationPower / 100
DurabilityToSet = Durability - ArmorDamage
EffectiveDurability = Durability / Destructibility - Actual armor’s durability based on both factors
2. Calculating penetration
PenetrateCalculation = PenetrationLevel * PenetrationLevel
PenetrationChance = PenetrateCalculation / ArmorLevel / Durability * PenetrationPower / ArmorLevel
CanPenetrate = math.random(PenetrateCalculation, CurrentDurability * 100)
3. Applying calculations
This script was cut from the module i used for armor calculations
DurabilityToSet = Durability - ArmorDamage
if CanPenetrate <= PenetrationChance or PenetrationChance >= CurrentDurability * 100 then
local multipliedDamage = BulletDamage -- there was supposed to be a multiplier
local PenetrationPhysicalDamage
if PenetrationPhysicalDamage then
if EffectiveDurability < 1 then
PenetrationPhysicalDamage = multipliedDamage * EffectiveDurability
elseif EffectiveDurability >= 1 then
PenetrationPhysicalDamage = multipliedDamage / EffectiveDurability
end
end
DurabilityToSet = Durability - ArmorDamage + PenetrationPhysicalDamage / 100
DamageToTake = PenetrationPhysicalDamage
else
local Damage
if BulletForce ~= nil then
print("Using BulletForce to damage")
if EffectiveDurability < 1 then
Damage = BulletForce * EffectiveDurability
else
Damage = BulletForce / EffectiveDurability
end
else
print("Using PenetrationPower")
if EffectiveDurability < 1 then
Damage = PenetrationPower * EffectiveDurability
else
Damage = PenetrationPower / EffectiveDurability
end
end
DamageToTake = Damage
end
armorHit:SetAttribute("Durability", DurabilityToSet)
if armorHit:GetAttribute("Durability") <= 0 then
armorHit:SetAttribute("Durability", 0)
end
The script itself is pretty flexible so you can also use additional calculations like Distance and DamageMultiplier based on body part (e.g. head = x2 damage)
- Distance:
DamageToTake = math.clamp((Damage/(math.clamp(distance/MaxDamageRange,1,6))),MinDamage,Damage)
- Multiplying damage
WeaponDamage * multipliers[realHitPart.Name]
- Useful
- Useless
0 voters