11 if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
14 name => 'Heart of the Swarm',
15 title => 'starcraft2',
16 game => 'StarCraft II',
20 my $datafile = "sc-units-$scver{id}.inc.pl";
23 title => "$scver{title} unit cheat sheet",
26 "Reference of $scver{game} unit properties,"
27 . " comparing various statistics of all the units in $scver{name}"
28 . ' including costs, damage, defense, speed, ranges, and abilities.',
32 starcraft game unit statistics stats comparison table sheet cheat
33 reference software attributes properties
35 $scver{major} < 2 ? qw' bw broodwar brood war ' : qw' starcraft2 hots ',
37 stylesheet => [qw'light'],
38 raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
42 print "<h1>$scver{game} units</h1>\n\n";
44 my $units = do $datafile;
45 die "Cannot open unit data: $_\n" for $@ || $! || ();
46 my $patch = shift @{$units}
47 or die "Cannot open unit data: metadata not found\n";
49 print "<p>Unit properties as seen or measured in $scver{name}\n$patch.\n</p>\n\n";
51 for my $unit (@{$units}) {
52 for my $upgrade (@{ $unit->{upgrade} // $unit->{update} // [] }) {
53 while (my ($col, $increase) = each %{$upgrade}) {
54 defined $unit->{$col} or next;
56 if (ref $increase eq 'ARRAY') {
57 for my $incrow (0 .. $#{$increase}) {
58 while (my ($inccol, $subinc) = each %{ $increase->[$incrow] }) {
59 $unit->{upgraded}->{$col}->[$incrow]->{$inccol}
60 //= ref $unit->{$col}->[$incrow]->{$inccol}
61 ? $unit->{$col}->[$incrow]->{$inccol}->[-1]
62 : $unit->{$col}->[$incrow]->{$inccol};
63 $unit->{upgraded}->{$col}->[$incrow]->{$inccol}
64 += ref $subinc ? $subinc->[-1] : $subinc;
68 elsif ($increase =~ /^-?[0-9.]+/) {
69 $unit->{upgraded}->{$col} //= $unit->{$col};
70 $unit->{upgraded}->{$col} += $increase;
79 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
80 : '<a href="?%s">%s</a>',
81 $id && "order=$id", $name
84 :><table class="units">
87 <th><:= coltoggle('name', '') :></th>
88 <th class="val min"><img src="/minerals.png" alt="min"></th>
89 <th class="val gas"><img src="/gas.png" alt="gas"></th>
90 <th class="val time"><:= coltoggle(qw'build cost') :></th>
91 <th class="unit" colspan="4"><:= coltoggle(qw'size size') :></th>
92 <th class="val unit-hp">HP</th>
93 <th class="val unit-shield">shield</th>
94 <th class="val unit-armor" title="armor">⛨</th>
95 <th class="val hurt" colspan=3>attack</th>
96 <th class="hurt hurtrel">dps</th>
97 <th class="val unit-range">range</th>
98 <th class="val unit-sight">sight</th>
99 <th class="val unit-speed">speed</th>
100 <th class="unit-magic">specials</th>
104 my ($min, $max) = @_;
105 return '' if not defined $min;
106 $_ &&= int($_ + .5) for $min, $max; # round halves up
107 return $min if not defined $max or $min == $max;
112 my ($row, $area) = @_;
113 my $attack = $row->{attack}->[$area]
114 or return '<td colspan=4 class="hurt">';
117 $tagbase .= '<td class="unit hurt-g">' . '▽' x !!($attack->{anti} & 1);
118 $tagbase .= '<td class="unit hurt-a">' . '△' x !!($attack->{anti} & 2);
119 $tagbase .= '<td class="val hurt';
120 if (ref $attack and $attack->{type}) {
121 if ($attack->{type} eq 'explosive') {
122 $tagbase .= ' unit-l';
124 elsif ($attack->{type} eq 'implosive') {
125 $tagbase .= ' unit-s';
130 my $upattack = $row->{upgraded}->{attack}->[$area];
132 my $damage = $attack->{damage};
133 ($damage, $maxdamage) = ($damage->[0], $upattack->{damage} // $damage->[-1])
136 my $out = showrange($damage, $maxdamage);
137 $out .= sprintf('<span class="unit-splash" title="%s">%s</span>',
138 $attack->{splash} eq 'line' ? ('linear', '×') : ('splash', '+')
139 ) if $attack->{splash};
141 $out .= '<td class="val hurt hurtrel">';
142 if ($attack->{cooldown}) {
143 if (my $type = $attack->{type}) {
144 if ($type eq 'explosive') {
147 elsif ($type eq 'implosive') {
151 $damage *= ($attack->{count} // 1) / $attack->{cooldown};
152 $maxdamage *= ($upattack->{count} // $attack->{count} // 1)
153 / ($upattack->{cooldown} // $attack->{cooldown});
154 $out .= showrange($damage, $maxdamage);
157 return $tagbase . $out;
162 my $specials = $row->{special} or return '';
163 return join ' ', map {
164 sprintf '<span%s title="%s">%s</span>',
165 $_->{duration} < 0 && ' class="magic-perma"',
168 $_->{desc} ? ": $_->{desc}" : '',
169 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
170 $_->{range} ? "range $_->{range}" : (),
171 $_->{cost} ? sprintf('cost %.0f%%%s',
172 100 * $_->{cost} / $row->{energy},
173 defined $_->{maint} && sprintf('+%.1f%%/s',
174 100 * $_->{maint} / $row->{energy},
179 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
180 } grep { defined $_->{abbr} } @{$specials};
186 $_->{hp} += $_->{shield} if $_->{shield};
188 if ($_->{attr}->{structure}) {
192 $suitchar = [qw/? s m l/]->[$_->{suit}];
194 elsif ($_->{cargo} > 0) {
195 $suitchar = [qw/? s m l l h h h h/]->[abs $_->{cargo}];
198 $suitchar = [qw/s m l h h h/]->[$_->{size}];
200 elsif ($_->{attr} and $_->{attr}->{light}) {
203 elsif ($_->{attr} and $_->{attr}->{armored}) {
208 '<td class="val min">' . ($_->{min} // ''),
209 '<td class="val gas">' . ($_->{gas} || ''),
210 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
211 !!$_->{base} && '<span class="unit-composed">+</span>',
214 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s%s',
215 $suitchar, ucfirst $suitchar,
216 $_->{attr}->{massive}
217 && '<span class="unit-massive" title="massive">⚓</span>',
219 '<td class="val unit">' . (
220 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit}
222 '<td class="unit unit-type">' . join('', grep { $_ }
223 (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech})
224 && '<span class="unit-u" title="mechanic">m</span>',
225 ($_->{organic} || $_->{attr}->{organic})
226 && '<span class="unit-o" title="organic">o</span>',
227 $_->{attr}->{psionic}
228 && '<span class="unit-p" title="psionic">ψ</span>',
230 '<td class="unit unit-attr">' . join('', grep { $_ }
231 $_->{attr}->{armored}
232 && '<span class="unit unit-l" title="armored">A</span>',
234 && '<span class="unit unit-s" title="light">L</span>',
236 '<td class="val unit-hp">' . $_->{hp} // '',
237 $_->{shield} ? sprintf('<td class="val unit-shield">%.0f%%<td',
238 100 * $_->{shield} / $_->{hp}
240 ' class="val unit-armor">' .
241 showrange($_->{armor}, $_->{upgraded}->{armor}),
243 '<td class="val unit-range">' .
244 showrange(map { $_->{attack}->[0]->{range} } $_, $_->{upgraded}),
245 '<td class="val unit-sight">' . sprintf(
246 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
247 showrange($_->{sight}, $_->{upgraded}->{sight})
249 '<td class="val unit-speed">' .
250 showrange($_->{speed}, $_->{upgraded}->{speed}),
252 && qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
254 && qq'<span class="unit unit-jump" title="flying">↑</span>',
255 '<td class="unit-magic">' . showmagic($_),
256 !$_->{attack}->[1] ? () : (
257 '<tr><td colspan=12>', showattack($_, 1), '<td colspan=4>'
263 my $grouped = 1; # race headers
264 if (exists $get{order}) {
267 if ($get{order} eq 'size') {
268 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
270 elsif ($get{order} eq 'cost') {
271 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
274 $units->[$_]->{order} = $_ for 0 .. $#$units;
277 my @rows = @{$units};
278 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
280 my ($race, $cat) = ('', '');
283 printf '<tbody id="%s"><tr class="race"><th colspan="20"><h2>%s</h2>'."\n",
284 $race = $_->{race}, ucfirst $race
285 unless $race eq $_->{race};
288 $_->{cat} = $_->{race};
293 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
298 for my $subrow (@{ $_->{special} }) {
299 $subrow->{alt} or next;
301 '<tr class="alt"><th class="cat"><td>', $subrow->{alt},
302 showunitcols($subrow),
314 <dd>minerals+gas required to create one unit
315 <dd>includes total expenses if based on existing units
317 <dd>relative time needed to create at least one unit
318 <dd>excludes construction of dependencies such as buildings
319 and <span class="unit-composed">+</span>parent units
322 if ($scver{major} > 1) {
323 :>transports can fit 8 <span class="unit unit-s">S</span>mall,
324 4 <span class="unit unit-m">M</span>edium,
325 2 <span class="unit unit-l">L</span>arge,
326 or a single <span class="unit unit-h">H</span>uge unit
327 <dd>massive <span class="unit-massive">⚓</span> units
328 cannot be lifted or slowed and can break force fields<:
330 :>affected by <span class="unit unit-s">S</span>mall,
331 <span class="unit unit-m">M</span>edium, or
332 <span class="unit unit-l">L</span>arge unit damage<:
334 <dd>number of command points taken per unit
336 if ($scver{major} > 1) {
337 :>received damage depends on
338 <span class="unit unit-o">o</span>rganic,
339 <span class="unit unit-u">m</span>echanic,
340 <span class="unit unit-p">ψ</span>(ps)ionic,
341 <span class="unit unit-s">L</span>ight, and
342 <span class="unit unit-l">A</span>rmored
345 :><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit<:
348 total number of hitpoints (including shields)
350 <dd>percentage of HP in shields
351 <dd>shields always take full damage, irrelevant of unit size
352 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
355 <dd>can be increased by upto 3 at various facilities
356 <dd>each point decreases damage per hit by one, upto a minimum of ½
357 <dd>reduction applies to initial damage, before size penalties
358 <small>(so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)</small>
360 <dd>targets <span class="hurt-g">▽</span> ground
361 and/or <span class="hurt-a">△</span> air
362 <dd>damage given per single hit
363 <dd><em>dps</em> indicates relative amount of damage done in
364 1 second of in-game time
365 <dd>splash damage hits all objects nearby <span class="unit-splash">+</span>
366 or in a straight line <span class="unit-splash">×</span>.
367 <dd><span class="hurt unit-l">explosive</span> damage does only
368 50% damage to small units, 75% to medium, 100% to large
369 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
370 25% to large, 50% medium, 100% to small units
372 <dd>range in which the unit detects other units
373 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
375 <dd>maximum range of weapon (note siege tank also has a minimum range)
377 <dd>relative speed of movement (when in full motion, startup speed ignored)
379 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
380 <dd>parentheses () indicate that it needs to be researched first
381 <dd>hover for description
382 <dd>range is maximum range required to activate
383 <dd>cost is percentage of total energy lost
387 When two values are given (1-2), second value indicates attribute after all