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="2"><:= 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}];
186 '<td class="val min">' . ($_->{min} // ''),
187 '<td class="val gas">' . ($_->{gas} || ''),
188 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
189 !!$_->{base} && '<span class="unit-composed">+</span>',
192 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
193 '<td class="val unit">' . join('',
194 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
195 defined $_->{organic} && sprintf(
196 '<span class="unit-%s" title="%s">%s</span>',
197 $_->{organic} ? 'o' : 'u',
198 $_->{organic} ? 'organic' : 'mechanic',
199 $_->{organic} ? 'o' : 'm',
202 '<td class="val unit-hp">' . $_->{hp} // '',
203 '<td class="val unit-shield">' . (
204 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
206 '<td class="val unit-armor">' . showval($_, 'armor'),
207 showattack($_, 'ground'),
208 showattack($_, 'air'),
209 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
210 '<td class="val unit-sight">' . sprintf(
211 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
214 '<td class="val unit-speed">' . showval($_, 'speed'),
215 '<td class="unit-magic">' . showmagic($_),
220 my $grouped = 1; # race headers
221 if (exists $get{order}) {
224 if ($get{order} eq 'size') {
225 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
227 elsif ($get{order} eq 'cost') {
228 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
231 $units->[$_]->{order} = $_ for 0 .. $#$units;
234 my @rows = @{$units};
235 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
237 my ($race, $cat) = ('', '');
240 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n",
241 $race = $_->{race}, ucfirst $race
242 unless $race eq $_->{race};
245 $_->{cat} = $_->{race};
250 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
255 for my $subrow (@{ $_->{special} }) {
256 $subrow->{alt} or next;
258 '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
259 showunitcols($subrow),
271 <dd>minerals+gas required to create one unit
272 <dd>includes total expenses if based on existing units
274 <dd>relative time needed to create at least one unit
275 <dd>excludes construction of dependencies such as buildings
276 and <span class="unit-composed">+</span>parent units
278 <dd>affected by <span class="unit unit-s">S</span>mall,
279 <span class="unit unit-m">M</span>edium,
280 or <span class="unit unit-l">L</span>arge unit damage
281 <dd>number of command points taken per unit
282 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
284 total number of hitpoints (including shields)
286 <dd>percentage of HP in shields
287 <dd>shields always take full damage, irrelevant of unit size
288 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
291 <dd>can be increased by upto 3 at various facilities
292 <dd>each point decreases damage per hit by one, upto a minimum of ½
293 <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>
295 <dd>damage done per single attack against ground/air units
296 <dd>2nd column indicates relative amount of damage done in
297 1 second of fastest game time
298 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
299 <dd><span class="hurt unit-l">explosive</span> damage does only
300 50% damage to small units, 75% to medium, 100% to large
301 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
302 25% to large, 50% medium, 100% to small units
304 <dd>range in which the unit detects other units
305 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
307 <dd>maximum range of weapon (note siege tank also has a minimum range)
309 <dd>relative speed of movement (when in full motion, startup speed ignored)
311 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
312 <dd>parentheses () indicate that it needs to be researched first
313 <dd>hover for description
314 <dd>range is maximum range required to activate
315 <dd>cost is percentage of total energy lost
319 When two values are given (1-2), second value indicates attribute after all