3 my $datafile = 'sc-units.inc.pl';
4 if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
5 $datafile = 'sc2-units.inc.pl';
9 title => 'starcraft unit cheat sheet',
12 'Reference of StarCraft unit properties,'
13 . ' comparing various statistics of all the units in Brood War'
14 . ' including costs, damage, defense, speed, ranges, and abilities.',
17 starcraft game unit statistics stats comparison table sheet cheat
18 reference software attributes properties
20 stylesheet => [qw'light'],
25 <h1>StarCraft units</h1>
28 Unit properties as seen or measured in Brood War
29 <span title="no known changes as of v1.16.1">version≥1.08</span>.
32 <style type="text/css">
34 border-collapse: separate;
39 .units th, .units td {
42 background: transparent;
47 border-top-style: dashed;
49 .units tr th:first-child {
52 .units tr:hover:not(.race) {
61 .units thead th, .units tfoot th {
66 .unit-o {color: #C08} /* organic */
67 .unit-u {color: #44C} /* mechanic */
68 img.unit-o, img.unit-u {
70 vertical-align: middle;
80 .unit.unit-s {color: #770}
81 .unit.unit-m {color: #C70}
82 .unit.unit-l {color: #D22}
83 .hurt.unit-s::before {
87 .hurt.unit-l::before {
94 .hurtrel, .units .hurtrel {
102 .unit-detect::before {
106 vertical-align: super;
112 text-decoration: underline;
132 -webkit-column-break-before: avoid;
154 my ($name, $id) = @_;
156 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
157 : '<a href="?%s">%s</a>',
158 $id && "order=$id", $name
161 :><table class="units">
164 <th><:= coltoggle('name', '') :></th>
165 <th class="val min"><img src="/minerals.png" alt="min"></th>
166 <th class="val gas"><img src="/gas.png" alt="gas"></th>
167 <th class="val time"><:= coltoggle(qw'build cost') :></th>
168 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
169 <th class="val unit-hp">HP</th>
170 <th class="val unit-shield">shield</th>
171 <th class="val unit-armor">armor</th>
172 <th class="val hurt" colspan="2">ground</th>
173 <th class="val hurt" colspan="2">air</th>
174 <th class="val unit-range">range</th>
175 <th class="val unit-sight">sight</th>
176 <th class="val unit-speed">speed</th>
177 <th class="unit-magic">specials</th>
181 my ($row, @elements) = @_;
185 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
186 if (ref $value eq 'ARRAY') {
191 $min = $max = $value;
193 defined $min or return '';
195 if ($row->{upgrade}) {
196 for (@{ $row->{upgrade} }) {
197 my $increase = $_ or next;
198 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
199 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
200 $max += $increase if $increase;
204 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
205 my $attack = $row->{ $elements[0] }->{ $elements[1] };
206 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
207 my $type = $attack->{type} or next;
208 if ($type eq 'explosive') {
211 elsif ($type eq 'implosive') {
215 $_ = int($_ + .5) for $min, $max; # round halves up
217 return $min == $max ? $min : "$min-$max";
221 my ($row, $area) = @_;
222 local $_ = $row->{attack}->{$area};
224 # reference to another area
226 $_ = $row->{attack}->{$area};
229 return '<td colspan="2" class="hurt">' unless $_;
231 my $tagbase = '<td class="val hurt';
232 if (ref $_ and $_->{type}) {
233 if ($_->{type} eq 'explosive') {
234 $tagbase .= ' unit-l';
236 elsif ($_->{type} eq 'implosive') {
237 $tagbase .= ' unit-s';
242 my $out = showrange($row, 'attack', $area, 'damage');
243 $out .= '<span class="unit-splash">+</span>' if $_->{splash};
244 $out .= '<td class="val hurt hurtrel">' . showrange($row, 'attack', $area, 'dps');
245 return $tagbase . $out;
250 my $specials = $row->{special} or return '';
251 return join ' ', map {
252 sprintf '<span%s title="%s">%s</span>',
253 $_->{duration} < 0 && ' class="magic-perma"',
256 $_->{desc} ? ": $_->{desc}" : '',
257 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
258 $_->{range} ? "range $_->{range}" : (),
259 $_->{cost} ? sprintf('cost %.0f%%',
260 100 * $_->{cost} / $row->{energy}
264 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
265 } grep { defined $_->{abbr} } @{$specials};
271 $_->{hp} += $_->{shield} if $_->{shield};
274 $suitchar = [qw/? s m l/]->[$_->{suit}];
278 '<td class="val min">' . ($_->{min} // ''),
279 '<td class="val gas">' . ($_->{gas} || ''),
280 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
281 !!$_->{base} && '<span class="unit-composed">+</span>',
284 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
285 '<td class="val unit">' . join('',
286 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
287 defined $_->{organic} && sprintf(
288 '<span class="unit-%s" title="%s">%s</span>',
289 $_->{organic} ? 'o' : 'u',
290 $_->{organic} ? 'organic' : 'mechanic',
291 $_->{organic} ? 'o' : 'm',
294 '<td class="val unit-hp">' . $_->{hp} // '',
295 '<td class="val unit-shield">' . (
296 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
298 '<td class="val unit-armor">' . showrange($_, 'armor'),
299 showattack($_, 'ground'),
300 showattack($_, 'air'),
301 '<td class="val unit-range">' . showrange($_, 'attack', 'range'),
302 '<td class="val unit-sight">' . sprintf(
303 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
304 showrange($_, 'sight')
306 '<td class="val unit-speed">' . showrange($_, 'speed'),
307 '<td class="unit-magic">' . showmagic($_),
312 my $units = do $datafile;
313 die "Cannot open unit data: $_\n" for $@ || $! || ();
314 my $grouped = !exists $get{order};
315 if (exists $get{order}) {
317 if ($get{order} eq 'size') {
318 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
320 elsif ($get{order} eq 'cost') {
321 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
324 $units->[$_]->{order} = $_ for 0 .. $#$units;
327 my @rows = $grouped ? @$units : sort {$a->{order} <=> $b->{order}} @$units;
329 my ($race, $cat) = ('', '');
332 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n", $race, ucfirst $race
333 if $grouped and $race ne $_->{race};
334 $_->{cat} = $_->{race} if not $grouped;
337 sprintf('<t%s class="cat">%s', $cat ne $_->{cat} ? ('h', $cat = $_->{cat}) : ('d', ' ')),
342 for my $alt (grep { $_->{alt} } @{ $_->{special} }) {
344 '<tr class="alt"><td class="cat"><td>' . $alt->{alt},
357 <dd>minerals+gas required to create one unit
358 <dd>includes total expenses if based on existing units
360 <dd>relative time needed to create at least one unit
361 <dd>excludes construction of dependencies such as buildings
362 and <span class="unit-composed">+</span>parent units
364 <dd>affected by <span class="unit unit-s">S</span>mall,
365 <span class="unit unit-m">M</span>edium,
366 or <span class="unit unit-l">L</span>arge unit damage
367 <dd>number of command points taken per unit
368 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
370 total number of hitpoints (including shields)
372 <dd>percentage of HP in shields
373 <dd>shields always take full damage, irrelevant of unit size
374 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
377 <dd>can be increased by upto 3 at various facilities
378 <dd>each point decreases damage per hit by one, upto a minimum of ½
379 <dd>reduction applies to initial damage, before size penalties <small>(so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)</small>
381 <dd>damage done per single attack against ground/air units
382 <dd>2nd column indicates relative amount of damage done in
383 <span title="the time in which a dragoon fires a shot">a certain
384 amount</span> of time
385 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
386 <dd><span class="hurt unit-l">explosive</span> damage does only
387 50% damage to small units, 75% to medium, 100% to large
388 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
389 25% to large, 50% medium, 100% to small units
391 <dd>range in which the unit detects other units
392 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
394 <dd>maximum range of weapon (note siege tank also has a minimum range)
396 <dd>relative speed of movement (when in full motion, startup speed ignored)
398 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
399 <dd>parentheses () indicate that it needs to be researched first
400 <dd>hover for description
401 <dd>range is maximum range required to activate
402 <dd>cost is percentage of total energy lost
406 When two values are given (1-2), second value indicates attribute after all