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";
54 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
55 : '<a href="?%s">%s</a>',
56 $id && "order=$id", $name
59 :><table class="units">
62 <th><:= coltoggle('name', '') :></th>
63 <th class="val min"><img src="/minerals.png" alt="min"></th>
64 <th class="val gas"><img src="/gas.png" alt="gas"></th>
65 <th class="val time"><:= coltoggle(qw'build cost') :></th>
66 <th class="unit" colspan="4"><:= coltoggle(qw'size size') :></th>
67 <th class="val unit-hp">HP</th>
68 <th class="val unit-shield">shield</th>
69 <th class="val unit-armor">armor</th>
70 <th class="val hurt" colspan="2">ground</th>
71 <th class="val hurt" colspan="2">air</th>
72 <th class="val unit-range">range</th>
73 <th class="val unit-sight">sight</th>
74 <th class="val unit-speed">speed</th>
75 <th class="unit-magic">specials</th>
80 $_ = int($_ + .5) for $min, $max; # round halves up
81 return $min == $max ? $min : "$min-$max";
85 my ($row, @elements) = @_;
89 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
90 if (ref $value eq 'ARRAY') {
97 defined $min or return '';
99 if ($row->{upgrade}) {
100 for (@{ $row->{upgrade} }) {
101 my $increase = $_ or next;
102 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
103 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
104 $max += $increase if $increase;
108 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
109 my $attack = $row->{ $elements[0] }->{ $elements[1] };
110 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
111 my $type = $attack->{type} or next;
112 if ($type eq 'explosive') {
115 elsif ($type eq 'implosive') {
119 return showrange($min, $max);
123 my ($row, $area) = @_;
124 my $attack = $row->{attack}->{$area};
125 if (not ref $attack) {
126 # reference to another area
128 $attack = $row->{attack}->{$area};
131 return '<td colspan="2" class="hurt">' unless $attack;
133 my $tagbase = '<td class="val hurt';
134 if (ref $attack and $attack->{type}) {
135 if ($attack->{type} eq 'explosive') {
136 $tagbase .= ' unit-l';
138 elsif ($attack->{type} eq 'implosive') {
139 $tagbase .= ' unit-s';
144 my $out = showval($row, 'attack', $area, 'damage');
145 $out .= '<span class="unit-splash">+</span>' if $attack->{splash};
146 $attack->{dps} = $attack->{cooldown} && [
147 map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) }
148 map { ref $_ ? @{$_} : $_ }
150 #TODO: upgrade (zergling)
152 $out .= '<td class="val hurt hurtrel">' . showval($row, 'attack', $area, 'dps');
153 return $tagbase . $out;
158 my $specials = $row->{special} or return '';
159 return join ' ', map {
160 sprintf '<span%s title="%s">%s</span>',
161 $_->{duration} < 0 && ' class="magic-perma"',
164 $_->{desc} ? ": $_->{desc}" : '',
165 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
166 $_->{range} ? "range $_->{range}" : (),
167 $_->{cost} ? sprintf('cost %.0f%%',
168 100 * $_->{cost} / $row->{energy}
172 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
173 } grep { defined $_->{abbr} } @{$specials};
179 $_->{hp} += $_->{shield} if $_->{shield};
182 $suitchar = [qw/? s m l/]->[$_->{suit}];
184 elsif ($_->{cargo} > 0) {
185 $suitchar = [qw/? s m l l h h h h/]->[abs $_->{cargo}];
188 $suitchar = [qw/s m l h h h/]->[$_->{size}];
190 elsif ($_->{attr} and $_->{attr}->{light}) {
193 elsif ($_->{attr} and $_->{attr}->{armored}) {
198 '<td class="val min">' . ($_->{min} // ''),
199 '<td class="val gas">' . ($_->{gas} || ''),
200 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
201 !!$_->{base} && '<span class="unit-composed">+</span>',
204 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
205 '<td class="val unit">' . (
206 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit}
208 '<td class="unit unit-type">' . join('', grep { $_ }
209 (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech})
210 && '<span class="unit-u" title="mechanic">m</span>',
211 ($_->{organic} || $_->{attr}->{organic})
212 && '<span class="unit-o" title="organic">o</span>',
213 $_->{attr}->{psionic}
214 && '<span class="unit-p" title="psionic">ψ</span>',
216 '<td class="unit unit-attr">' . join('', grep { $_ }
217 $_->{attr}->{armored}
218 && '<span class="unit unit-l" title="armored">A</span>',
220 && '<span class="unit unit-s" title="light">L</span>',
222 '<td class="val unit-hp">' . $_->{hp} // '',
223 '<td class="val unit-shield">' . (
224 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
226 '<td class="val unit-armor">' . showval($_, 'armor'),
227 showattack($_, 'ground'),
228 showattack($_, 'air'),
229 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
230 '<td class="val unit-sight">' . sprintf(
231 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
234 '<td class="val unit-speed">' . showval($_, 'speed'),
235 $_->{attr}->{massive} && '<span class="unit-massive">☇</span>',
236 '<td class="unit-magic">' . showmagic($_),
241 my $grouped = 1; # race headers
242 if (exists $get{order}) {
245 if ($get{order} eq 'size') {
246 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
248 elsif ($get{order} eq 'cost') {
249 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
252 $units->[$_]->{order} = $_ for 0 .. $#$units;
255 my @rows = @{$units};
256 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
258 my ($race, $cat) = ('', '');
261 printf '<tbody id="%s"><tr class="race"><th colspan="20"><h2>%s</h2>'."\n",
262 $race = $_->{race}, ucfirst $race
263 unless $race eq $_->{race};
266 $_->{cat} = $_->{race};
271 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
276 for my $subrow (@{ $_->{special} }) {
277 $subrow->{alt} or next;
279 '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
280 showunitcols($subrow),
292 <dd>minerals+gas required to create one unit
293 <dd>includes total expenses if based on existing units
295 <dd>relative time needed to create at least one unit
296 <dd>excludes construction of dependencies such as buildings
297 and <span class="unit-composed">+</span>parent units
300 if ($scver{major} > 1) {
301 :>transports can fit 8 <span class="unit unit-s">S</span>mall,
302 4 <span class="unit unit-m">M</span>edium,
303 2 <span class="unit unit-l">L</span>arge,
304 or a single <span class="unit unit-h">H</span>uge unit<:
306 :>affected by <span class="unit unit-s">S</span>mall,
307 <span class="unit unit-m">M</span>edium, or
308 <span class="unit unit-l">L</span>arge unit damage<:
310 <dd>number of command points taken per unit
312 if ($scver{major} > 1) {
313 :>received damage depends on
314 <span class="unit unit-o">o</span>rganic,
315 <span class="unit unit-u">m</span>echanic,
316 <span class="unit unit-p">ψ</span>(ps)ionic,
317 <span class="unit unit-s">L</span>ight, and
318 <span class="unit unit-l">A</span>rmored
321 :><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit<:
324 total number of hitpoints (including shields)
326 <dd>percentage of HP in shields
327 <dd>shields always take full damage, irrelevant of unit size
328 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
331 <dd>can be increased by upto 3 at various facilities
332 <dd>each point decreases damage per hit by one, upto a minimum of ½
333 <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>
335 <dd>damage done per single attack against ground/air units
336 <dd>2nd column indicates relative amount of damage done in
337 1 second of fastest game time
338 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
339 <dd><span class="hurt unit-l">explosive</span> damage does only
340 50% damage to small units, 75% to medium, 100% to large
341 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
342 25% to large, 50% medium, 100% to small units
344 <dd>range in which the unit detects other units
345 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
347 <dd>maximum range of weapon (note siege tank also has a minimum range)
349 <dd>relative speed of movement (when in full motion, startup speed ignored)
351 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
352 <dd>parentheses () indicate that it needs to be researched first
353 <dd>hover for description
354 <dd>range is maximum range required to activate
355 <dd>cost is percentage of total energy lost
359 When two values are given (1-2), second value indicates attribute after all