Template:Apparel AP Calculation/doc

From RimWorld Wiki
Jump to navigation Jump to search

This template calculates the damage multiplier (as a percentage) for a given set of armors against an attacks's armor penetration. This is mainly used by Template:Apparel Protection Chart.

Formula[edit]

{{Apparel AP Calculation|armor1=|armor2=|armor3=|armor4=|ap=}}
  • armor1 = The armor value of the first set of appeal.
  • armor2 = The armor value of the second set of appeal. Ignored if not present.
  • armor3 = The armor value of the third set of appeal. Ignored if not present.
  • armor4 = The armor value of the fourth set of appeal. Ignored if not present.
  • ap = The armor penetration of the attack being tested. Defaults to 0.

Explanation[edit]

This template has 2 stages. First, it calculates the effective armor for the given ap. If no armor value defined, it uses 0 for this calculation. Then, it obtains the maximum value between the calculated number and 0:

effectiveArmor = max(armor - ap, 0)

For armor1 and each of the other armor values present, it multiples the default value 100 by:

 (max(100-effectiveArmor, 0) + min(effectiveArmor/2, 100-effectiveArmor/2) * 0.5)/100

If all armors were defined, the calculation would be:

100 * (max(100-effectiveArmor1, 0) + min(effectiveArmor1/2, 100-effectiveArmor1/2) * 0.5)/100 * (max(100-effectiveArmor2, 0) + min(effectiveArmor2/2, 100-effectiveArmor2/2) * 0.5)/100 * (max(100-effectiveArmor3, 0) + min(effectiveArmor3/2, 100-effectiveArmor3/2) * 0.5)/100 * (max(100-effectiveArmor4, 0) + min(effectiveArmor4/2, 100-effectiveArmor4/2) * 0.5)/100

Examples[edit]

{{Apparel AP Calculation|armor1={{Q|Marine armor|Armor - Sharp}}|ap={{Q|Chain shotgun|Armor Penetration}} }}

       31

{{Apparel AP Calculation|armor1={{Q|Marine armor|Armor - Sharp}}|ap={{Q|Charge rifle|Armor Penetration}} }}

       46.75

{{Apparel AP Calculation|armor1={{Q|Flack Vest|Armor - Sharp}}|armor2=42|ap={{Q|Charge rifle|Armor Penetration}} }}

       94.75