6 patch => '<span title="no known changes as of v1.16.1">version≥1.08</span>',
12 if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
15 name => 'Heart of the Swarm',
16 patch => 'patch 2.1.3 BU',
17 title => 'starcraft2',
18 game => 'StarCraft II',
22 my $datafile = "sc-units-$scver{id}.inc.pl";
25 title => "$scver{title} unit cheat sheet",
28 "Reference of $scver{game} unit properties,"
29 . " comparing various statistics of all the units in $scver{name}"
30 . ' including costs, damage, defense, speed, ranges, and abilities.',
34 starcraft game unit statistics stats comparison table sheet cheat
35 reference software attributes properties
37 $scver{major} < 2 ? qw' bw broodwar brood war ' : qw' starcraft2 hots ',
39 stylesheet => [qw'light'],
40 raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
44 print "<h1>$scver{game} units</h1>\n\n";
45 print "<p>Unit properties as seen or measured in $scver{name}\n$scver{patch}.\n</p>\n\n";
50 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
51 : '<a href="?%s">%s</a>',
52 $id && "order=$id", $name
55 :><table class="units">
58 <th><:= coltoggle('name', '') :></th>
59 <th class="val min"><img src="/minerals.png" alt="min"></th>
60 <th class="val gas"><img src="/gas.png" alt="gas"></th>
61 <th class="val time"><:= coltoggle(qw'build cost') :></th>
62 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
63 <th class="val unit-hp">HP</th>
64 <th class="val unit-shield">shield</th>
65 <th class="val unit-armor">armor</th>
66 <th class="val hurt" colspan="2">ground</th>
67 <th class="val hurt" colspan="2">air</th>
68 <th class="val unit-range">range</th>
69 <th class="val unit-sight">sight</th>
70 <th class="val unit-speed">speed</th>
71 <th class="unit-magic">specials</th>
76 $_ = int($_ + .5) for $min, $max; # round halves up
77 return $min == $max ? $min : "$min-$max";
81 my ($row, @elements) = @_;
85 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
86 if (ref $value eq 'ARRAY') {
93 defined $min or return '';
95 if ($row->{upgrade}) {
96 for (@{ $row->{upgrade} }) {
97 my $increase = $_ or next;
98 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
99 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
100 $max += $increase if $increase;
104 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
105 my $attack = $row->{ $elements[0] }->{ $elements[1] };
106 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
107 my $type = $attack->{type} or next;
108 if ($type eq 'explosive') {
111 elsif ($type eq 'implosive') {
115 return showrange($min, $max);
119 my ($row, $area) = @_;
120 my $attack = $row->{attack}->{$area};
121 if (not ref $attack) {
122 # reference to another area
124 $attack = $row->{attack}->{$area};
127 return '<td colspan="2" class="hurt">' unless $attack;
129 my $tagbase = '<td class="val hurt';
130 if (ref $attack and $attack->{type}) {
131 if ($attack->{type} eq 'explosive') {
132 $tagbase .= ' unit-l';
134 elsif ($attack->{type} eq 'implosive') {
135 $tagbase .= ' unit-s';
140 my $out = showval($row, 'attack', $area, 'damage');
141 $out .= '<span class="unit-splash">+</span>' if $attack->{splash};
142 $attack->{dps} = $attack->{cooldown} && [
143 map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) }
144 map { ref $_ ? @{$_} : $_ }
146 #TODO: upgrade (zergling)
148 $out .= '<td class="val hurt hurtrel">' . showval($row, 'attack', $area, 'dps');
149 return $tagbase . $out;
154 my $specials = $row->{special} or return '';
155 return join ' ', map {
156 sprintf '<span%s title="%s">%s</span>',
157 $_->{duration} < 0 && ' class="magic-perma"',
160 $_->{desc} ? ": $_->{desc}" : '',
161 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
162 $_->{range} ? "range $_->{range}" : (),
163 $_->{cost} ? sprintf('cost %.0f%%',
164 100 * $_->{cost} / $row->{energy}
168 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
169 } grep { defined $_->{abbr} } @{$specials};
175 $_->{hp} += $_->{shield} if $_->{shield};
178 $suitchar = [qw/? s m l/]->[$_->{suit}];
182 '<td class="val min">' . ($_->{min} // ''),
183 '<td class="val gas">' . ($_->{gas} || ''),
184 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
185 !!$_->{base} && '<span class="unit-composed">+</span>',
188 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
189 '<td class="val unit">' . join('',
190 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
191 defined $_->{organic} && sprintf(
192 '<span class="unit-%s" title="%s">%s</span>',
193 $_->{organic} ? 'o' : 'u',
194 $_->{organic} ? 'organic' : 'mechanic',
195 $_->{organic} ? 'o' : 'm',
198 '<td class="val unit-hp">' . $_->{hp} // '',
199 '<td class="val unit-shield">' . (
200 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
202 '<td class="val unit-armor">' . showval($_, 'armor'),
203 showattack($_, 'ground'),
204 showattack($_, 'air'),
205 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
206 '<td class="val unit-sight">' . sprintf(
207 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
210 '<td class="val unit-speed">' . showval($_, 'speed'),
211 '<td class="unit-magic">' . showmagic($_),
216 my $units = do $datafile;
217 die "Cannot open unit data: $_\n" for $@ || $! || ();
218 my $grouped = 1; # race headers
219 if (exists $get{order}) {
222 if ($get{order} eq 'size') {
223 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
225 elsif ($get{order} eq 'cost') {
226 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
229 $units->[$_]->{order} = $_ for 0 .. $#$units;
232 my @rows = @{$units};
233 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
235 my ($race, $cat) = ('', '');
238 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n",
239 $race = $_->{race}, ucfirst $race
240 unless $race eq $_->{race};
243 $_->{cat} = $_->{race};
248 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
253 for my $subrow (@{ $_->{special} }) {
254 $subrow->{alt} or next;
256 '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
257 showunitcols($subrow),
269 <dd>minerals+gas required to create one unit
270 <dd>includes total expenses if based on existing units
272 <dd>relative time needed to create at least one unit
273 <dd>excludes construction of dependencies such as buildings
274 and <span class="unit-composed">+</span>parent units
276 <dd>affected by <span class="unit unit-s">S</span>mall,
277 <span class="unit unit-m">M</span>edium,
278 or <span class="unit unit-l">L</span>arge unit damage
279 <dd>number of command points taken per unit
280 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
282 total number of hitpoints (including shields)
284 <dd>percentage of HP in shields
285 <dd>shields always take full damage, irrelevant of unit size
286 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
289 <dd>can be increased by upto 3 at various facilities
290 <dd>each point decreases damage per hit by one, upto a minimum of ½
291 <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>
293 <dd>damage done per single attack against ground/air units
294 <dd>2nd column indicates relative amount of damage done in
295 1 second of fastest game time
296 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
297 <dd><span class="hurt unit-l">explosive</span> damage does only
298 50% damage to small units, 75% to medium, 100% to large
299 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
300 25% to large, 50% medium, 100% to small units
302 <dd>range in which the unit detects other units
303 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
305 <dd>maximum range of weapon (note siege tank also has a minimum range)
307 <dd>relative speed of movement (when in full motion, startup speed ignored)
309 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
310 <dd>parentheses () indicate that it needs to be researched first
311 <dd>hover for description
312 <dd>range is maximum range required to activate
313 <dd>cost is percentage of total energy lost
317 When two values are given (1-2), second value indicates attribute after all