4 if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
7 my $datafile = "sc-units-$scver.inc.pl";
10 title => 'starcraft unit cheat sheet',
13 'Reference of StarCraft unit properties,'
14 . ' comparing various statistics of all the units in Brood War'
15 . ' including costs, damage, defense, speed, ranges, and abilities.',
18 starcraft game unit statistics stats comparison table sheet cheat
19 reference software attributes properties
21 stylesheet => [qw'light'],
22 raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
27 <h1>StarCraft units</h1>
30 Unit properties as seen or measured in Brood War
31 <span title="no known changes as of v1.16.1">version≥1.08</span>.
38 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
39 : '<a href="?%s">%s</a>',
40 $id && "order=$id", $name
43 :><table class="units">
46 <th><:= coltoggle('name', '') :></th>
47 <th class="val min"><img src="/minerals.png" alt="min"></th>
48 <th class="val gas"><img src="/gas.png" alt="gas"></th>
49 <th class="val time"><:= coltoggle(qw'build cost') :></th>
50 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
51 <th class="val unit-hp">HP</th>
52 <th class="val unit-shield">shield</th>
53 <th class="val unit-armor">armor</th>
54 <th class="val hurt" colspan="2">ground</th>
55 <th class="val hurt" colspan="2">air</th>
56 <th class="val unit-range">range</th>
57 <th class="val unit-sight">sight</th>
58 <th class="val unit-speed">speed</th>
59 <th class="unit-magic">specials</th>
64 $_ = int($_ + .5) for $min, $max; # round halves up
65 return $min == $max ? $min : "$min-$max";
69 my ($row, @elements) = @_;
73 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
74 if (ref $value eq 'ARRAY') {
81 defined $min or return '';
83 if ($row->{upgrade}) {
84 for (@{ $row->{upgrade} }) {
85 my $increase = $_ or next;
86 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
87 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
88 $max += $increase if $increase;
92 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
93 my $attack = $row->{ $elements[0] }->{ $elements[1] };
94 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
95 my $type = $attack->{type} or next;
96 if ($type eq 'explosive') {
99 elsif ($type eq 'implosive') {
103 return showrange($min, $max);
107 my ($row, $area) = @_;
108 my $attack = $row->{attack}->{$area};
109 if (not ref $attack) {
110 # reference to another area
112 $attack = $row->{attack}->{$area};
115 return '<td colspan="2" class="hurt">' unless $attack;
117 my $tagbase = '<td class="val hurt';
118 if (ref $attack and $attack->{type}) {
119 if ($attack->{type} eq 'explosive') {
120 $tagbase .= ' unit-l';
122 elsif ($attack->{type} eq 'implosive') {
123 $tagbase .= ' unit-s';
128 my $out = showval($row, 'attack', $area, 'damage');
129 $out .= '<span class="unit-splash">+</span>' if $attack->{splash};
130 $attack->{dps} = $attack->{cooldown} && [
131 map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) }
132 map { ref $_ ? @{$_} : $_ }
134 #TODO: upgrade (zergling)
136 $out .= '<td class="val hurt hurtrel">' . showval($row, 'attack', $area, 'dps');
137 return $tagbase . $out;
142 my $specials = $row->{special} or return '';
143 return join ' ', map {
144 sprintf '<span%s title="%s">%s</span>',
145 $_->{duration} < 0 && ' class="magic-perma"',
148 $_->{desc} ? ": $_->{desc}" : '',
149 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
150 $_->{range} ? "range $_->{range}" : (),
151 $_->{cost} ? sprintf('cost %.0f%%',
152 100 * $_->{cost} / $row->{energy}
156 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
157 } grep { defined $_->{abbr} } @{$specials};
163 $_->{hp} += $_->{shield} if $_->{shield};
166 $suitchar = [qw/? s m l/]->[$_->{suit}];
170 '<td class="val min">' . ($_->{min} // ''),
171 '<td class="val gas">' . ($_->{gas} || ''),
172 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
173 !!$_->{base} && '<span class="unit-composed">+</span>',
176 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
177 '<td class="val unit">' . join('',
178 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
179 defined $_->{organic} && sprintf(
180 '<span class="unit-%s" title="%s">%s</span>',
181 $_->{organic} ? 'o' : 'u',
182 $_->{organic} ? 'organic' : 'mechanic',
183 $_->{organic} ? 'o' : 'm',
186 '<td class="val unit-hp">' . $_->{hp} // '',
187 '<td class="val unit-shield">' . (
188 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
190 '<td class="val unit-armor">' . showval($_, 'armor'),
191 showattack($_, 'ground'),
192 showattack($_, 'air'),
193 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
194 '<td class="val unit-sight">' . sprintf(
195 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
198 '<td class="val unit-speed">' . showval($_, 'speed'),
199 '<td class="unit-magic">' . showmagic($_),
204 my $units = do $datafile;
205 die "Cannot open unit data: $_\n" for $@ || $! || ();
206 my $grouped = 1; # race headers
207 if (exists $get{order}) {
210 if ($get{order} eq 'size') {
211 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
213 elsif ($get{order} eq 'cost') {
214 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
217 $units->[$_]->{order} = $_ for 0 .. $#$units;
220 my @rows = @{$units};
221 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
223 my ($race, $cat) = ('', '');
226 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n",
227 $race = $_->{race}, ucfirst $race
228 unless $race eq $_->{race};
231 $_->{cat} = $_->{race};
236 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
241 for my $subrow (@{ $_->{special} }) {
242 $subrow->{alt} or next;
244 '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
245 showunitcols($subrow),
257 <dd>minerals+gas required to create one unit
258 <dd>includes total expenses if based on existing units
260 <dd>relative time needed to create at least one unit
261 <dd>excludes construction of dependencies such as buildings
262 and <span class="unit-composed">+</span>parent units
264 <dd>affected by <span class="unit unit-s">S</span>mall,
265 <span class="unit unit-m">M</span>edium,
266 or <span class="unit unit-l">L</span>arge unit damage
267 <dd>number of command points taken per unit
268 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
270 total number of hitpoints (including shields)
272 <dd>percentage of HP in shields
273 <dd>shields always take full damage, irrelevant of unit size
274 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
277 <dd>can be increased by upto 3 at various facilities
278 <dd>each point decreases damage per hit by one, upto a minimum of ½
279 <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>
281 <dd>damage done per single attack against ground/air units
282 <dd>2nd column indicates relative amount of damage done in
283 1 second of fastest game time
284 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
285 <dd><span class="hurt unit-l">explosive</span> damage does only
286 50% damage to small units, 75% to medium, 100% to large
287 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
288 25% to large, 50% medium, 100% to small units
290 <dd>range in which the unit detects other units
291 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
293 <dd>maximum range of weapon (note siege tank also has a minimum range)
295 <dd>relative speed of movement (when in full motion, startup speed ignored)
297 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
298 <dd>parentheses () indicate that it needs to be researched first
299 <dd>hover for description
300 <dd>range is maximum range required to activate
301 <dd>cost is percentage of total energy lost
305 When two values are given (1-2), second value indicates attribute after all