Template:UnitData: Difference between revisions

From Mechabellum Wiki
(update 0.7.13)
(move value calculation from UnitInfobox)
Line 37: Line 37:
   | Error: Unit "{{{1|{{PAGENAME}}}}}" undefined!
   | Error: Unit "{{{1|{{PAGENAME}}}}}" undefined!
   | <!-- no error -  -->
   | <!-- no error -  -->
   {{#if:{{{2|}}}
   {{#vardefine:atk_tmp | {{#ifexpr: ({{#explode: {{#var:row}} | ; | 2 }}) < 1  <!-- if melting damage -->
    |<!-- return val --> {{#switch: {{{2}}}
      | #default = Error: Var "{{{2}}}" undefined!
      | hp = {{#expr: {{#explode: {{#var:row}} | ; | 0 }} * {{{level|1}}} }}
      | speed = {{#explode: {{#var:row}} | ; | 1 }}
      | atk = {{#ifexpr: ({{#explode: {{#var:row}} | ; | 2 }}) < 1  <!-- if melting damage -->
           | {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 0 }} * {{{level|1}}}  
           | {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 0 }} * {{{level|1}}}  
             }} - {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 1 }} * {{{level|1}}} }}
             }} - {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 1 }} * {{{level|1}}} }}
Line 50: Line 45:
           }}
           }}
       }}
       }}
  }} 
     
  {{#if:{{{2|}}}
    |<!-- return val --> {{#switch: {{{2}}}
      | #default = Error: Var "{{{2}}}" undefined!
      | hp = {{#expr: {{#explode: {{#var:row}} | ; | 0 }} * {{{level|1}}} }}
      | speed = {{#explode: {{#var:row}} | ; | 1 }}
      | atk = {{#var:atk_tmp}}
       | atkint = {{#explode: {{#var:row}} | ; | 3 }}
       | atkint = {{#explode: {{#var:row}} | ; | 3 }}
       | range = {{#explode: {{#var:row}} | ; | 4 }}
       | range = {{#explode: {{#var:row}} | ; | 4 }}
Line 63: Line 66:
     }}{{#vardefine:hp | {{#expr: {{#explode: {{#var:row}} | ; | 0 }} * {{#var:level}} }}
     }}{{#vardefine:hp | {{#expr: {{#explode: {{#var:row}} | ; | 0 }} * {{#var:level}} }}
     }}{{#vardefine:speed | {{#explode: {{#var:row}} | ; | 1 }}
     }}{{#vardefine:speed | {{#explode: {{#var:row}} | ; | 1 }}
     }}{{#vardefine:atk | {{#ifexpr: ({{#explode: {{#var:row}} | ; | 2 }}) < 1 <!-- if melting damage -->
     }}{{#vardefine:atk | {{#var:atk_tmp}}
          | {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 0 }} * {{#var:level}}
            }} - {{#expr: {{#explode: {{#explode: {{#var:row}} | ; | 2 }} | - | 1 }} * {{#var:level}} }}
          | {{#if: {{#pos: {{#explode: {{#var:row}} | ; | 2 }} | * }} <!-- if * 4 missels -->
            | {{#expr: {{#explode: {{#var:row}} | ; | 2 }} * {{#var:level}} / 4 }} * 4
            | {{#expr: {{#explode: {{#var:row}} | ; | 2 }} * {{#var:level}} }}
          }}
      }}
     }}{{#vardefine:atkint | {{#explode: {{#var:row}} | ; | 3 }}
     }}{{#vardefine:atkint | {{#explode: {{#var:row}} | ; | 3 }}
     }}{{#vardefine:range | {{#explode: {{#var:row}} | ; | 4 }}
     }}{{#vardefine:range | {{#explode: {{#var:row}} | ; | 4 }}
Line 86: Line 82:
         | {{#expr: {{#explode: {{#var:atk|-0}} | - | 1 }} * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
         | {{#expr: {{#explode: {{#var:atk|-0}} | - | 1 }} * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
         | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
         | {{#expr: abs({{#var:atk|0}}) * {{#var:units|1}} / {{#var:atkint|1}} round 0 }}
      }}
    }}<!-- more variables
    -->{{#vardefine:min_cost | {{#expr: {{#var:cost}} / {{#var:units}} round 1}}
    }}{{#vardefine:max_cost | {{#expr: ({{#var:cost}} + {{#var:unlockcost}}) / {{#var:units}} round 1}}
    }}{{#vardefine:min_hp_val | {{#expr: ({{#var:hp}} * {{#var:units}}) / ({{#var:cost}} + {{#var:unlockcost}}) round 1}}
    }}{{#vardefine:max_hp_val | {{#expr: ({{#var:hp}} * {{#var:units}}) / {{#var:cost}} round 1}}
    }}{{#vardefine:min_burst_val | {{#expr: {{#var:burst}} / ({{#var:cost}} + {{#var:unlockcost}}) round 1}}
    }}{{#vardefine:max_burst_val | {{#expr: {{#var:burst}} / {{#var:cost}} round 1}}
    }}{{#vardefine:min_dps_val | {{#expr: {{#var:dps}} / ({{#var:cost}} + {{#var:unlockcost}}) round 1}}
    }}{{#vardefine:max_dps_val | {{#expr: {{#var:dps}} / {{#var:cost}} round 1}}
    }}{{#vardefine:splash_index | {{#expr:
        {{#ifeq: {{#var:splash}} | 0 | 1 | {{#var:splash}} }}
        {{#if: {{#pos: {{#var:atk}} | * }} | * 4 }}
        {{#if: {{#pos: {{#var:atk}} | - }} | * .025 <!-- damage build up --> |
          {{#ifexpr: ({{#var:atk}}) < 350 | * (({{#var:atk}}) / 350) }}
        }}
        * {{#var:units}}
        / {{#ifeq: {{{1|{{PAGENAME}}}}} | Hacker | 3 <!-- slow switching --> | {{#var:atkint}} }}
        round 1
       }}
       }}
     }}<!-- end vardefine -->
     }}<!-- end vardefine -->
   }}
   }}
}}
}}

Revision as of 17:35, 16 July 2023

This template contains all unit data (HP, Speed, Attack, (Attack) Interval, Range, Splash (Range), Target, Units, Giant, Mobility, Cost, Unlock Cost)

Using the Template with a unit name sets the variables {{UnitData|Fortress}}

On the unit pages the data is automatically pulled and placed in variables (hp, speed, atk, atkint, range, splash, target, units, giant, mobility, cost, unlockcost, burst, dps), ready to use on the page with e.g. {{#var:speed}}.

A single value can be pulled without overriding the variables {{UnitData|Fortress|speed}}.

Melting damage is set as a range "1 - 9000" allowing the math to work.

Missiles usually cam in packs of 4 but the damage/attack shown is for one missile, so add a multiplier e.g. "555 * 4" looks nicer and math works fine.


Error: Unit "UnitData" undefined!