Template:Damage info: Difference between revisions

Jump to navigation Jump to search
Slightly better parsing to avoid catching on 'd's when specifying a non-die value
No edit summary
(Slightly better parsing to avoid catching on 'd's when specifying a non-die value)
 
(28 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<includeonly>{{#switch: {{{1}}}
<includeonly>{{#lvardef: die | {{{die|}}} }}{{#lvardef: count | {{{count|}}} }}{{#if: {{#pos: {{lc:{{{1|}}}}} | d20}} | {{#lvardef: die | 20}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d20}} }} }} | {{#if: {{#pos: {{lc:{{{1|}}}}} | d12}} | {{#lvardef: die | 12}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d12}} }} }} | {{#if: {{#pos: {{lc:{{{1|}}}}} | d10}} | {{#lvardef: die | 10}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d10}} }} }} | {{#if: {{#pos: {{lc:{{{1|}}}}} | d8}} | {{#lvardef: die | 8}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d8}} }} }} | {{#if: {{#pos: {{lc:{{{1|}}}}} | d6}} | {{#lvardef: die | 6}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d6}} }} }} | {{#if: {{#pos: {{lc:{{{1|}}}}} | d4}} | {{#lvardef: die | 4}}{{#lvardef: count | {{#sub: {{{1}}} | 0 | {{#pos: {{lc:{{{1|}}}}} | d4}} }} }} | }} }} }} }} }} }}{{#switch: {{{1}}}
| weapon = {{InfoBlob | Normal Weapon Damage }}
| unarmed = {{InfoBlob | [[Unarmed Strike|Unarmed damage]] {{DamageType|Bludgeoning}} }}
| weapon = {{InfoBlob | Normal weapon damage }}
| half weapon = {{InfoBlob | 1/2 Normal weapon damage }}
| superiority die = {{InfoBlob | {{DamageColor|Weapon|{{R|supdie|icononly=yes}}[[Superiority Die]] {{DamageType|Weapon}} damage}} }}
| #default = {{DamageInfo/Primitive
| #default = {{DamageInfo/Primitive
| count = {{{count |
| flat value =
   {{#explode: {{lc: {{{1}}} }} | d | 0 }}
   {{#switch: {{{1}}}  
}}}
  | prof
| die = {{{die |
  | proficiency = proficiency
  <!-- To get the die out of e.g. "2d6 + 3", we turn it into "2+6 + 3", use '+' as the #explode separator. -->
  | #default =  
  {{#explode: {{#replace: {{lc: {{{1}}} }} | d | + }} | + | 1 }}
    {{#if: {{#lvar: die }}
}}}
    | <!--nothing-->
    | {{{1|}}}  
    }}
  }}
| count = {{#lvar: count }}
| die = {{#lvar: die }}
| plus = {{{plus |
| plus = {{{plus |
   {{#if: {{#pos: {{{1}}} | + }}
   {{#if: {{#pos: {{{1}}} | + }}
     | {{#explode: {{lc: {{{1}}} }} | + | -1 }}
     | {{#explode: {{lc: {{{1}}} }} | + | -1 }}
     | 0 }}
     | 0
  }}
}}}
}}}
| type = {{{type | {{{2}}} }}}
| type = {{{type | {{{2}}} }}}
Line 18: Line 27:
| per = {{{per | }}}
| per = {{{per | }}}
| save = {{{save | }}}
| save = {{{save | }}}
| save dc = {{{save dc | }}}
| save effect = {{{save effect | }}}
| save effect = {{{save effect | }}}
| con = {{#ifeq: {{{3|}}} | con | yes | {{{con | }}}}}
| delayed = {{#ifeq: {{{3|}}} | delayed | yes | {{{delayed | }}}}}
}}
}}
}}</includeonly><noinclude>
}}</includeonly><noinclude>
{{hatnote|See also [[Template:Damage info/Primitive]]}}{{documentation|content=
== New usage ==
== New usage ==


Examples:
Examples:
{{code|<nowiki>{{DamageInfo | unarmed }}</nowiki>}}
{{DamageInfo | unarmed }} (works inline)
---
{{code|<nowiki>{{DamageInfo | weapon }}</nowiki>}}
{{DamageInfo | weapon }} (works inline)
---
{{code|<nowiki>{{DamageInfo | half weapon }}</nowiki>}}
{{DamageInfo | half weapon }} (works inline)
---
{{code|<nowiki>{{DamageInfo | superiority die }}</nowiki>}}
{{DamageInfo | superiority die }}
---
''All other variants below are forced onto their own line and can't be used inline.''
---
{{code|<nowiki>{{DamageInfo | 2 | Acid }}</nowiki>}}
{{DamageInfo | 2 | Acid }}
---
{{code|<nowiki>{{DamageInfo | +2 | Acid }}</nowiki>}}
{{DamageInfo | +2 | Acid }}
---


{{code|<nowiki>{{DamageInfo | 1d8 | Slashing}}</nowiki>}}
{{code|<nowiki>{{DamageInfo | 1d8 | Slashing}}</nowiki>}}
Line 77: Line 128:
{{code|<nowiki>{{DamageInfo | 2d6 | Acid | save = Dexterity | save effect = half }}</nowiki>}}
{{code|<nowiki>{{DamageInfo | 2d6 | Acid | save = Dexterity | save effect = half }}</nowiki>}}
{{DamageInfo | 2d6 | Acid | save = Dexterity | save effect = half }}
{{DamageInfo | 2d6 | Acid | save = Dexterity | save effect = half }}
---
{{code|<nowiki>{{DamageInfo | 2d6 | Acid | save = Dexterity | save dc = 15 | save effect = half }}</nowiki>}}
{{DamageInfo | 2d6 | Acid | save = Dexterity | save dc = 15 | save effect = half }}
---
{{code|<nowiki>{{DamageInfo | +2 | Acid | con}}</nowiki>}}
{{DamageInfo | +2 | Acid | con
}}
---
{{code|<nowiki>{{DamageInfo | 2d6 | Acid | con}}</nowiki>}}
{{DamageInfo | 2d6 | Acid | con
}}
---
{{code|<nowiki>{{DamageInfo | 2d6 | Acid | delayed}}</nowiki>}}
{{DamageInfo | 2d6 | Acid | delayed
}}
---
{{code|<nowiki>{{DamageInfo | 2d6 | Healing}}</nowiki>}}
{{DamageInfo | 2d6 | Healing}}


== Legacy usage ==
== Legacy usage ==
Line 131: Line 210:
The {{code|plus}} parameter must be either omitted entirely, or set to a valid number, but never provided with an empty value like {{code|<nowiki>{{... | plus= | ...}}</nowiki>}}.  It can be set to 0, which is the same as omitting it, so if you're using this template from within another, and want to pass on an optional parameter for the plus value, you can pass it on like {{code|<nowiki>{{... | plus = {{{MyOptionalPlus | 0}}} | ...}}</nowiki>}}.
The {{code|plus}} parameter must be either omitted entirely, or set to a valid number, but never provided with an empty value like {{code|<nowiki>{{... | plus= | ...}}</nowiki>}}.  It can be set to 0, which is the same as omitting it, so if you're using this template from within another, and want to pass on an optional parameter for the plus value, you can pass it on like {{code|<nowiki>{{... | plus = {{{MyOptionalPlus | 0}}} | ...}}</nowiki>}}.


[[Category:Damage Info Templates]]
}}
[[Category:Damage info templates]]
</noinclude>
</noinclude>

Navigation menu