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;
49 .units tr th:first-child {
52 .units tbody tr:hover:not(.race) {
61 .units thead th, .units tfoot th {
66 .unit-o {color: #C08} /* organic */
67 .unit-u {color: #44C} /* mechanic */
72 .unit.unit-s {color: #770}
73 .unit.unit-m {color: #C70}
74 .unit.unit-l {color: #D22}
75 .hurt.unit-s::before {
79 .hurt.unit-l::before {
86 .hurtrel, .units .hurtrel {
94 .unit-detect::before {
98 vertical-align: super;
104 text-decoration: underline;
140 my ($name, $id) = @_;
142 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
143 : '<a href="?%s">%s</a>',
144 $id && "order=$id", $name
147 :><table class="units">
150 <th><:= coltoggle('name', '') :></th>
151 <th class="val min"><img src="/minerals.png" alt="min"></th>
152 <th class="val gas"><img src="/gas.png" alt="gas"></th>
153 <th class="val time"><:= coltoggle(qw'build cost') :></th>
154 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
155 <th class="val unit-hp">HP</th>
156 <th class="val unit-shield">shield</th>
157 <th class="val unit-armor">armor</th>
158 <th class="val hurt" colspan="2">ground</th>
159 <th class="val hurt" colspan="2">air</th>
160 <th class="val unit-range">range</th>
161 <th class="val unit-sight">sight</th>
162 <th class="val unit-speed">speed</th>
163 <th class="unit-magic">specials</th>
167 my ($min, $max) = @_;
168 $_ = int($_ + .5) for $min, $max; # round halves up
169 return $min == $max ? $min : "$min-$max";
173 my ($row, @elements) = @_;
177 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
178 if (ref $value eq 'ARRAY') {
183 $min = $max = $value;
185 defined $min or return '';
187 if ($row->{upgrade}) {
188 for (@{ $row->{upgrade} }) {
189 my $increase = $_ or next;
190 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
191 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
192 $max += $increase if $increase;
196 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
197 my $attack = $row->{ $elements[0] }->{ $elements[1] };
198 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
199 my $type = $attack->{type} or next;
200 if ($type eq 'explosive') {
203 elsif ($type eq 'implosive') {
207 return showrange($min, $max);
211 my ($row, $area) = @_;
212 my $attack = $row->{attack}->{$area};
213 if (not ref $attack) {
214 # reference to another area
216 $attack = $row->{attack}->{$area};
219 return '<td colspan="2" class="hurt">' unless $attack;
221 my $tagbase = '<td class="val hurt';
222 if (ref $attack and $attack->{type}) {
223 if ($attack->{type} eq 'explosive') {
224 $tagbase .= ' unit-l';
226 elsif ($attack->{type} eq 'implosive') {
227 $tagbase .= ' unit-s';
232 my $out = showval($row, 'attack', $area, 'damage');
233 $out .= '<span class="unit-splash">+</span>' if $attack->{splash};
234 $attack->{dps} = $attack->{cooldown} && [
235 map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) }
236 map { ref $_ ? @{$_} : $_ }
238 #TODO: upgrade (zergling)
240 $out .= '<td class="val hurt hurtrel">' . showval($row, 'attack', $area, 'dps');
241 return $tagbase . $out;
246 my $specials = $row->{special} or return '';
247 return join ' ', map {
248 sprintf '<span%s title="%s">%s</span>',
249 $_->{duration} < 0 && ' class="magic-perma"',
252 $_->{desc} ? ": $_->{desc}" : '',
253 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
254 $_->{range} ? "range $_->{range}" : (),
255 $_->{cost} ? sprintf('cost %.0f%%',
256 100 * $_->{cost} / $row->{energy}
260 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
261 } grep { defined $_->{abbr} } @{$specials};
267 $_->{hp} += $_->{shield} if $_->{shield};
270 $suitchar = [qw/? s m l/]->[$_->{suit}];
274 '<td class="val min">' . ($_->{min} // ''),
275 '<td class="val gas">' . ($_->{gas} || ''),
276 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
277 !!$_->{base} && '<span class="unit-composed">+</span>',
280 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
281 '<td class="val unit">' . join('',
282 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
283 defined $_->{organic} && sprintf(
284 '<span class="unit-%s" title="%s">%s</span>',
285 $_->{organic} ? 'o' : 'u',
286 $_->{organic} ? 'organic' : 'mechanic',
287 $_->{organic} ? 'o' : 'm',
290 '<td class="val unit-hp">' . $_->{hp} // '',
291 '<td class="val unit-shield">' . (
292 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
294 '<td class="val unit-armor">' . showval($_, 'armor'),
295 showattack($_, 'ground'),
296 showattack($_, 'air'),
297 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
298 '<td class="val unit-sight">' . sprintf(
299 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
302 '<td class="val unit-speed">' . showval($_, 'speed'),
303 '<td class="unit-magic">' . showmagic($_),
308 my $units = do $datafile;
309 die "Cannot open unit data: $_\n" for $@ || $! || ();
310 my $grouped = 1; # race headers
311 if (exists $get{order}) {
314 if ($get{order} eq 'size') {
315 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
317 elsif ($get{order} eq 'cost') {
318 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
321 $units->[$_]->{order} = $_ for 0 .. $#$units;
324 my @rows = @{$units};
325 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
327 my ($race, $cat) = ('', '');
330 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n",
331 $race = $_->{race}, ucfirst $race
332 unless $race eq $_->{race};
335 $_->{cat} = $_->{race};
340 sprintf('<t%s class="cat">%s',
341 $cat ne $_->{cat} ? ('h', $cat = $_->{cat}) : ('d', ' ')
347 for my $subrow (@{ $_->{special} }) {
348 $subrow->{alt} or next;
350 '<tr class="alt"><td class="cat"><td>' . $subrow->{alt},
351 showunitcols($subrow),
363 <dd>minerals+gas required to create one unit
364 <dd>includes total expenses if based on existing units
366 <dd>relative time needed to create at least one unit
367 <dd>excludes construction of dependencies such as buildings
368 and <span class="unit-composed">+</span>parent units
370 <dd>affected by <span class="unit unit-s">S</span>mall,
371 <span class="unit unit-m">M</span>edium,
372 or <span class="unit unit-l">L</span>arge unit damage
373 <dd>number of command points taken per unit
374 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
376 total number of hitpoints (including shields)
378 <dd>percentage of HP in shields
379 <dd>shields always take full damage, irrelevant of unit size
380 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
383 <dd>can be increased by upto 3 at various facilities
384 <dd>each point decreases damage per hit by one, upto a minimum of ½
385 <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>
387 <dd>damage done per single attack against ground/air units
388 <dd>2nd column indicates relative amount of damage done in
389 1 second of fastest game time
390 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
391 <dd><span class="hurt unit-l">explosive</span> damage does only
392 50% damage to small units, 75% to medium, 100% to large
393 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
394 25% to large, 50% medium, 100% to small units
396 <dd>range in which the unit detects other units
397 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
399 <dd>maximum range of weapon (note siege tank also has a minimum range)
401 <dd>relative speed of movement (when in full motion, startup speed ignored)
403 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
404 <dd>parentheses () indicate that it needs to be researched first
405 <dd>hover for description
406 <dd>range is maximum range required to activate
407 <dd>cost is percentage of total energy lost
411 When two values are given (1-2), second value indicates attribute after all