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;
129 -webkit-column-break-before: avoid;
151 my ($name, $id) = @_;
153 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
154 : '<a href="?%s">%s</a>',
155 $id && "order=$id", $name
158 :><table class="units">
161 <th><:= coltoggle('name', '') :></th>
162 <th class="val min"><img src="/minerals.png" alt="min"></th>
163 <th class="val gas"><img src="/gas.png" alt="gas"></th>
164 <th class="val time"><:= coltoggle(qw'build cost') :></th>
165 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
166 <th class="val unit-hp">HP</th>
167 <th class="val unit-shield">shield</th>
168 <th class="val unit-armor">armor</th>
169 <th class="val hurt" colspan="2">ground</th>
170 <th class="val hurt" colspan="2">air</th>
171 <th class="val unit-range">range</th>
172 <th class="val unit-sight">sight</th>
173 <th class="val unit-speed">speed</th>
174 <th class="unit-magic">specials</th>
178 my ($row, @elements) = @_;
182 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
183 if (ref $value eq 'ARRAY') {
188 $min = $max = $value;
190 defined $min or return '';
192 if ($row->{upgrade}) {
193 for (@{ $row->{upgrade} }) {
194 my $increase = $_ or next;
195 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
196 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
197 $max += $increase if $increase;
201 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
202 my $attack = $row->{ $elements[0] }->{ $elements[1] };
203 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
204 my $type = $attack->{type} or next;
205 if ($type eq 'explosive') {
208 elsif ($type eq 'implosive') {
212 $_ = int($_ + .5) for $min, $max; # round halves up
214 return $min == $max ? $min : "$min-$max";
218 my ($row, $area) = @_;
219 local $_ = $row->{attack}->{$area};
221 # reference to another area
223 $_ = $row->{attack}->{$area};
226 return '<td colspan="2" class="hurt">' unless $_;
228 my $tagbase = '<td class="val hurt';
229 if (ref $_ and $_->{type}) {
230 if ($_->{type} eq 'explosive') {
231 $tagbase .= ' unit-l';
233 elsif ($_->{type} eq 'implosive') {
234 $tagbase .= ' unit-s';
239 my $out = showrange($row, 'attack', $area, 'damage');
240 $out .= '<span class="unit-splash">+</span>' if $_->{splash};
241 $out .= '<td class="val hurt hurtrel">' . showrange($row, 'attack', $area, 'dps');
242 return $tagbase . $out;
247 my $specials = $row->{special} or return '';
248 return join ' ', map {
249 sprintf '<span title="%s">%s</span>',
252 $_->{desc} ? ": $_->{desc}" : '',
253 $_->{range} ? sprintf(' (%s)', join ', ',
267 $suitchar = [qw/? s m l/]->[$_->{suit}];
271 '<td class="val min">' . ($_->{min} // ''),
272 '<td class="val gas">' . ($_->{gas} || ''),
273 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
274 !!$_->{base} && '<span class="unit-composed">+</span>',
277 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
278 '<td class="val unit">' . join('',
279 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
280 defined $_->{organic} && sprintf(
281 '<span class="unit-%s" title="%s">%s</span>',
282 $_->{organic} ? 'o' : 'u',
283 $_->{organic} ? 'organic' : 'mechanic',
284 $_->{organic} ? 'o' : 'm',
287 '<td class="val unit-hp">' . $_->{hp} // '',
288 '<td class="val unit-shield">' . (
289 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
291 '<td class="val unit-armor">' . showrange($_, 'armor'),
292 showattack($_, 'ground'),
293 showattack($_, 'air'),
294 '<td class="val unit-range">' . showrange($_, 'attack', 'range'),
295 '<td class="val unit-sight">' . sprintf(
296 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
297 showrange($_, 'sight')
299 '<td class="val unit-speed">' . showrange($_, 'speed'),
300 '<td class="unit-magic">' . showmagic($_),
305 my $units = do $datafile;
306 die "Cannot open unit data: $_\n" for $@ || $! || ();
307 my $grouped = !exists $get{order};
308 if (exists $get{order}) {
310 if ($get{order} eq 'size') {
311 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
313 elsif ($get{order} eq 'cost') {
314 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
317 $units->[$_]->{order} = $_ for 0 .. $#$units;
320 my @rows = $grouped ? @$units : sort {$a->{order} <=> $b->{order}} @$units;
322 my ($race, $cat) = ('', '');
325 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n", $race, ucfirst $race
326 if $grouped and $race ne $_->{race};
327 $_->{cat} = $_->{race} if not $grouped;
328 $_->{hp} += $_->{shield};
331 sprintf('<t%s class="cat">%s', $cat ne $_->{cat} ? ('h', $cat = $_->{cat}) : ('d', ' ')),
336 for my $alt (grep { $_->{alt} } @{ $_->{special} }) {
338 '<tr class="alt"><td class="cat"><td>' . $alt->{alt},
351 <dd>minerals+gas required to create one unit
352 <dd>includes total expenses if based on existing units
354 <dd>relative time needed to create at least one unit
355 <dd>excludes construction of dependencies such as buildings
356 and <span class="unit-composed">+</span>parent units
358 <dd>affected by <span class="unit unit-s">S</span>mall,
359 <span class="unit unit-m">M</span>edium,
360 or <span class="unit unit-l">L</span>arge unit damage
361 <dd>number of command points taken per unit
362 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
364 total number of hitpoints (including shields)
366 <dd>percentage of HP in shields
367 <dd>shields always take full damage, irrelevant of unit size
368 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
371 <dd>can be increased by upto 3 at various facilities
372 <dd>each point decreases damage per hit by one, upto a minimum of ½
373 <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>
375 <dd>damage done per single attack against ground/air units
376 <dd>2nd column indicates relative amount of damage done in
377 <span title="the time in which a dragoon fires a shot">a certain
378 amount</span> of time
379 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
380 <dd><span class="hurt unit-l">explosive</span> damage does only
381 50% damage to small units, 75% to medium, 100% to large
382 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
383 25% to large, 50% medium, 100% to small units
385 <dd>range in which the unit detects other units
386 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
388 <dd>maximum range of weapon (note siege tank also has a minimum range)
390 <dd>relative speed of movement (when in full motion, startup speed ignored)
392 <dd>special abilities
393 <dd>parentheses () indicate that it needs to be researched first
394 <dd>hover for description
395 <dd>range is maximum range required to activate
396 <dd>cost is percentage of total energy lost
400 When two values are given (1-2), second value indicates attribute after all