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" title="armor">⛨</th>
70 <th class="val hurt" colspan=3>attack</th>
71 <th class="hurt hurtrel">dps</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->{$_}
90 : ref $value eq 'ARRAY' && $value->[$_] or last for @elements;
91 if (ref $value eq 'ARRAY') {
98 defined $min or return '';
100 if ($row->{upgrade}) {
101 for (@{ $row->{upgrade} }) {
102 my $increase = $_ or next;
103 $increase = ref $increase eq 'HASH' ? $increase->{$_}
104 : ref $increase eq 'ARRAY' && $increase->[$_] or last for @elements;
105 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
106 $max += $increase if $increase;
110 if ($elements[0] eq 'attack' and $elements[2] eq 'dps') {{
111 my $attack = $row->{ $elements[0] }->[ $elements[1] ];
112 my $type = $attack->{type} or next;
113 if ($type eq 'explosive') {
116 elsif ($type eq 'implosive') {
120 return showrange($min, $max);
124 my ($row, $area) = @_;
125 my $attack = $row->{attack}->[$area]
126 or return '<td colspan=4 class="hurt">';
129 $tagbase .= '<td class="unit hurt-g">' . '▽' x !!($attack->{anti} & 1);
130 $tagbase .= '<td class="unit hurt-a">' . '△' x !!($attack->{anti} & 2);
131 $tagbase .= '<td class="val hurt';
132 if (ref $attack and $attack->{type}) {
133 if ($attack->{type} eq 'explosive') {
134 $tagbase .= ' unit-l';
136 elsif ($attack->{type} eq 'implosive') {
137 $tagbase .= ' unit-s';
142 my $out = showval($row, 'attack', $area, 'damage');
143 $out .= sprintf('<span class="unit-splash" title="%s">%s</span>',
144 $attack->{splash} eq 'line' ? ('linear', '×') : ('splash', '+')
145 ) if $attack->{splash};
146 $attack->{dps} = $attack->{cooldown} && [
147 map { $_ / $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%%%s',
168 100 * $_->{cost} / $row->{energy},
169 defined $_->{maint} && sprintf('+%.1f%%/s',
170 100 * $_->{maint} / $row->{energy},
175 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
176 } grep { defined $_->{abbr} } @{$specials};
182 $_->{hp} += $_->{shield} if $_->{shield};
184 if ($_->{attr}->{structure}) {
188 $suitchar = [qw/? s m l/]->[$_->{suit}];
190 elsif ($_->{cargo} > 0) {
191 $suitchar = [qw/? s m l l h h h h/]->[abs $_->{cargo}];
194 $suitchar = [qw/s m l h h h/]->[$_->{size}];
196 elsif ($_->{attr} and $_->{attr}->{light}) {
199 elsif ($_->{attr} and $_->{attr}->{armored}) {
204 '<td class="val min">' . ($_->{min} // ''),
205 '<td class="val gas">' . ($_->{gas} || ''),
206 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
207 !!$_->{base} && '<span class="unit-composed">+</span>',
210 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s%s',
211 $suitchar, ucfirst $suitchar,
212 $_->{attr}->{massive}
213 && '<span class="unit-massive" title="massive">⚓</span>',
215 '<td class="val unit">' . (
216 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit}
218 '<td class="unit unit-type">' . join('', grep { $_ }
219 (defined $_->{organic} ? !$_->{organic} : $_->{attr}->{mech})
220 && '<span class="unit-u" title="mechanic">m</span>',
221 ($_->{organic} || $_->{attr}->{organic})
222 && '<span class="unit-o" title="organic">o</span>',
223 $_->{attr}->{psionic}
224 && '<span class="unit-p" title="psionic">ψ</span>',
226 '<td class="unit unit-attr">' . join('', grep { $_ }
227 $_->{attr}->{armored}
228 && '<span class="unit unit-l" title="armored">A</span>',
230 && '<span class="unit unit-s" title="light">L</span>',
232 '<td class="val unit-hp">' . $_->{hp} // '',
233 $_->{shield} ? sprintf('<td class="val unit-shield">%.0f%%<td',
234 100 * $_->{shield} / $_->{hp}
236 ' class="val unit-armor">' . showval($_, 'armor'),
238 '<td class="val unit-range">' . showval($_, 'attack', 0, 'range'),
239 '<td class="val unit-sight">' . sprintf(
240 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
243 '<td class="val unit-speed">' . showval($_, 'speed'),
245 && qq'<span class="unit unit-jump" title="$_->{attr}->{jump}">↕</span>',
247 && qq'<span class="unit unit-jump" title="flying">↑</span>',
248 '<td class="unit-magic">' . showmagic($_),
249 !$_->{attack}->[1] ? () : (
250 '<tr><td colspan=12>', showattack($_, 1), '<td colspan=4>'
256 my $grouped = 1; # race headers
257 if (exists $get{order}) {
260 if ($get{order} eq 'size') {
261 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
263 elsif ($get{order} eq 'cost') {
264 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
267 $units->[$_]->{order} = $_ for 0 .. $#$units;
270 my @rows = @{$units};
271 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
273 my ($race, $cat) = ('', '');
276 printf '<tbody id="%s"><tr class="race"><th colspan="20"><h2>%s</h2>'."\n",
277 $race = $_->{race}, ucfirst $race
278 unless $race eq $_->{race};
281 $_->{cat} = $_->{race};
286 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
291 for my $subrow (@{ $_->{special} }) {
292 $subrow->{alt} or next;
294 '<tr class="alt"><th class="cat"><td>', $subrow->{alt},
295 showunitcols($subrow),
307 <dd>minerals+gas required to create one unit
308 <dd>includes total expenses if based on existing units
310 <dd>relative time needed to create at least one unit
311 <dd>excludes construction of dependencies such as buildings
312 and <span class="unit-composed">+</span>parent units
315 if ($scver{major} > 1) {
316 :>transports can fit 8 <span class="unit unit-s">S</span>mall,
317 4 <span class="unit unit-m">M</span>edium,
318 2 <span class="unit unit-l">L</span>arge,
319 or a single <span class="unit unit-h">H</span>uge unit
320 <dd>massive <span class="unit-massive">⚓</span> units
321 cannot be lifted or slowed and can break force fields<:
323 :>affected by <span class="unit unit-s">S</span>mall,
324 <span class="unit unit-m">M</span>edium, or
325 <span class="unit unit-l">L</span>arge unit damage<:
327 <dd>number of command points taken per unit
329 if ($scver{major} > 1) {
330 :>received damage depends on
331 <span class="unit unit-o">o</span>rganic,
332 <span class="unit unit-u">m</span>echanic,
333 <span class="unit unit-p">ψ</span>(ps)ionic,
334 <span class="unit unit-s">L</span>ight, and
335 <span class="unit unit-l">A</span>rmored
338 :><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit<:
341 total number of hitpoints (including shields)
343 <dd>percentage of HP in shields
344 <dd>shields always take full damage, irrelevant of unit size
345 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
348 <dd>can be increased by upto 3 at various facilities
349 <dd>each point decreases damage per hit by one, upto a minimum of ½
350 <dd>reduction applies to initial damage, before size penalties
351 <small>(so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)</small>
353 <dd>targets <span class="hurt-g">▽</span> ground
354 and/or <span class="hurt-a">△</span> air
355 <dd>damage given per single hit
356 <dd><em>dps</em> indicates relative amount of damage done in
357 1 second of in-game time
358 <dd>splash damage hits all objects nearby <span class="unit-splash">+</span>
359 or in a straight line <span class="unit-splash">×</span>.
360 <dd><span class="hurt unit-l">explosive</span> damage does only
361 50% damage to small units, 75% to medium, 100% to large
362 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
363 25% to large, 50% medium, 100% to small units
365 <dd>range in which the unit detects other units
366 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
368 <dd>maximum range of weapon (note siege tank also has a minimum range)
370 <dd>relative speed of movement (when in full motion, startup speed ignored)
372 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
373 <dd>parentheses () indicate that it needs to be researched first
374 <dd>hover for description
375 <dd>range is maximum range required to activate
376 <dd>cost is percentage of total energy lost
380 When two values are given (1-2), second value indicates attribute after all