Difference between revisions of "Template:Apparel AP Calculation"

From RimWorld Wiki
Jump to navigation Jump to search
(Created page with "The armor rating is reduced by the armor penetration value, dependent on the weapon. This gives the "effective armor rating" The effective armor rating is then compared agains...")
 
Line 1: Line 1:
The armor rating is reduced by the armor penetration value, dependent on the weapon. This gives the "effective armor rating"
+
{{#vardefine: effectiveArmor |{{#expr: {{{1|armor}}} - {{{2|ap}}}}} }}<!--
The effective armor rating is then compared against a random number from 0 to 100:
 
If the random number is under half the armor rating, the damage deflects harmlessly.
 
If the random number is over half the armor rating, but not higher than the armor rating, the damage is halved.
 
If the random number is greater than the armor rating, the armor has no effect.
 
  
{{#vardefine: effectiveArmor |{{#expr: {{{1|armor}}} - {{{2|ap}}}}} }}
+
-->{{#vardefine: effectiveArmor | 150 }} <!--
  
{{#vardefine: effectiveArmor | 150 }}  
+
-->{{#ifexpr: {{#var: effectiveArmor}} < 0| {{#vardefine: effectiveArmor | 0 }} }}<!--
  
{{#ifexpr: {{#var: effectiveArmor}} < 0| {{#vardefine: effectiveArmor | 0 }} }}
 
  
 
+
-->{{#expr: ({{#ifexpr: (100-{{#var: effectiveArmor}}) > 0 | {{#expr:100-{{#var: effectiveArmor}}}} | 0}}/100.0) + ({{#ifexpr: ({{#var: effectiveArmor}}/2.0) < (100.0-{{#var: effectiveArmor}}/2.0) | {{#expr:{{#var: effectiveArmor}}/2.0}} | {{#expr:100.0-{{#var: effectiveArmor}}/2.0}} }}/100)* 0.5}}
{{#expr: ({{#ifexpr: (100-{{#var: effectiveArmor}}) > 0 | {{#expr:100-{{#var: effectiveArmor}}}} | 0}}/100.0) + ({{#ifexpr: ({{#var: effectiveArmor}}/2.0) < (100.0-{{#var: effectiveArmor}}/2.0) | {{#expr:{{#var: effectiveArmor}}/2.0}} | {{#expr:100.0-{{#var: effectiveArmor}}/2.0}} }}/100)* 0.5}}
 

Revision as of 05:22, 22 March 2021

0.125