3 my $datafile = 'sc-units.inc.pl';
4 if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
5 $datafile = 'sc2-units.inc.pl';
9 title => 'starcraft unit cheat sheet',
12 'Reference of StarCraft unit properties,'
13 . ' comparing various statistics of all the units in Brood War'
14 . ' including costs, damage, defense, speed, ranges, and abilities.',
17 starcraft game unit statistics stats comparison table sheet cheat
18 reference software attributes properties
20 stylesheet => [qw'light'],
21 raw => '<link rel="stylesheet" type="text/css" media="all" href="/sc.css?1.1" title="light">',
26 <h1>StarCraft units</h1>
29 Unit properties as seen or measured in Brood War
30 <span title="no known changes as of v1.16.1">version≥1.08</span>.
37 (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s ▼'
38 : '<a href="?%s">%s</a>',
39 $id && "order=$id", $name
42 :><table class="units">
45 <th><:= coltoggle('name', '') :></th>
46 <th class="val min"><img src="/minerals.png" alt="min"></th>
47 <th class="val gas"><img src="/gas.png" alt="gas"></th>
48 <th class="val time"><:= coltoggle(qw'build cost') :></th>
49 <th class="unit" colspan="2"><:= coltoggle(qw'size size') :></th>
50 <th class="val unit-hp">HP</th>
51 <th class="val unit-shield">shield</th>
52 <th class="val unit-armor">armor</th>
53 <th class="val hurt" colspan="2">ground</th>
54 <th class="val hurt" colspan="2">air</th>
55 <th class="val unit-range">range</th>
56 <th class="val unit-sight">sight</th>
57 <th class="val unit-speed">speed</th>
58 <th class="unit-magic">specials</th>
63 $_ = int($_ + .5) for $min, $max; # round halves up
64 return $min == $max ? $min : "$min-$max";
68 my ($row, @elements) = @_;
72 $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
73 if (ref $value eq 'ARRAY') {
80 defined $min or return '';
82 if ($row->{upgrade}) {
83 for (@{ $row->{upgrade} }) {
84 my $increase = $_ or next;
85 $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
86 $increase = $increase->[-1] if ref $increase eq 'ARRAY';
87 $max += $increase if $increase;
91 if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
92 my $attack = $row->{ $elements[0] }->{ $elements[1] };
93 ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
94 my $type = $attack->{type} or next;
95 if ($type eq 'explosive') {
98 elsif ($type eq 'implosive') {
102 return showrange($min, $max);
106 my ($row, $area) = @_;
107 my $attack = $row->{attack}->{$area};
108 if (not ref $attack) {
109 # reference to another area
111 $attack = $row->{attack}->{$area};
114 return '<td colspan="2" class="hurt">' unless $attack;
116 my $tagbase = '<td class="val hurt';
117 if (ref $attack and $attack->{type}) {
118 if ($attack->{type} eq 'explosive') {
119 $tagbase .= ' unit-l';
121 elsif ($attack->{type} eq 'implosive') {
122 $tagbase .= ' unit-s';
127 my $out = showval($row, 'attack', $area, 'damage');
128 $out .= '<span class="unit-splash">+</span>' if $attack->{splash};
129 $attack->{dps} = $attack->{cooldown} && [
130 map { 24 * $_ / $attack->{cooldown} * ($attack->{count} // 1) }
131 map { ref $_ ? @{$_} : $_ }
133 #TODO: upgrade (zergling)
135 $out .= '<td class="val hurt hurtrel">' . showval($row, 'attack', $area, 'dps');
136 return $tagbase . $out;
141 my $specials = $row->{special} or return '';
142 return join ' ', map {
143 sprintf '<span%s title="%s">%s</span>',
144 $_->{duration} < 0 && ' class="magic-perma"',
147 $_->{desc} ? ": $_->{desc}" : '',
148 $_->{range} || $_->{cost} ? sprintf(' (%s)', join ', ',
149 $_->{range} ? "range $_->{range}" : (),
150 $_->{cost} ? sprintf('cost %.0f%%',
151 100 * $_->{cost} / $row->{energy}
155 sprintf($_->{build} ? '(%s)' : '%s', $_->{abbr}),
156 } grep { defined $_->{abbr} } @{$specials};
162 $_->{hp} += $_->{shield} if $_->{shield};
165 $suitchar = [qw/? s m l/]->[$_->{suit}];
169 '<td class="val min">' . ($_->{min} // ''),
170 '<td class="val gas">' . ($_->{gas} || ''),
171 !defined $_->{build} ? '<td>' : sprintf('<td class="val time">%s%.0f',
172 !!$_->{base} && '<span class="unit-composed">+</span>',
175 !$suitchar ? '<td>' : sprintf('<td class="unit unit-%s">%s', $suitchar, ucfirst $suitchar),
176 '<td class="val unit">' . join('',
177 defined $_->{unit} && $_->{unit} == .5 ? '½' : $_->{unit},
178 defined $_->{organic} && sprintf(
179 '<span class="unit-%s" title="%s">%s</span>',
180 $_->{organic} ? 'o' : 'u',
181 $_->{organic} ? 'organic' : 'mechanic',
182 $_->{organic} ? 'o' : 'm',
185 '<td class="val unit-hp">' . $_->{hp} // '',
186 '<td class="val unit-shield">' . (
187 $_->{shield} ? sprintf('%.0f%%', 100 * $_->{shield} / $_->{hp}) : ' '
189 '<td class="val unit-armor">' . showval($_, 'armor'),
190 showattack($_, 'ground'),
191 showattack($_, 'air'),
192 '<td class="val unit-range">' . showval($_, 'attack', 'range'),
193 '<td class="val unit-sight">' . sprintf(
194 $_->{detect} ? '<strong class="unit-detect">%s</strong>' : '%s',
197 '<td class="val unit-speed">' . showval($_, 'speed'),
198 '<td class="unit-magic">' . showmagic($_),
203 my $units = do $datafile;
204 die "Cannot open unit data: $_\n" for $@ || $! || ();
205 my $grouped = 1; # race headers
206 if (exists $get{order}) {
209 if ($get{order} eq 'size') {
210 $_->{order} = $_->{unit}*8 + $_->{suit} + $_->{hp}/512 + $_->{min}/8192 for @$units;
212 elsif ($get{order} eq 'cost') {
213 $_->{order} = $_->{gas}*1.5 + $_->{min} + $_->{unit}/8 + $_->{build}/256/8 for @$units;
216 $units->[$_]->{order} = $_ for 0 .. $#$units;
219 my @rows = @{$units};
220 @rows = sort {$a->{order} <=> $b->{order}} @rows unless $grouped;
222 my ($race, $cat) = ('', '');
225 printf '<tbody id="%s"><tr class="race"><th colspan="18"><h2>%s</h2>'."\n",
226 $race = $_->{race}, ucfirst $race
227 unless $race eq $_->{race};
230 $_->{cat} = $_->{race};
235 '<th class="cat">', $cat ne $_->{cat} && ($cat = $_->{cat}),
240 for my $subrow (@{ $_->{special} }) {
241 $subrow->{alt} or next;
243 '<tr class="alt"><td class="cat"><td>', $subrow->{alt},
244 showunitcols($subrow),
256 <dd>minerals+gas required to create one unit
257 <dd>includes total expenses if based on existing units
259 <dd>relative time needed to create at least one unit
260 <dd>excludes construction of dependencies such as buildings
261 and <span class="unit-composed">+</span>parent units
263 <dd>affected by <span class="unit unit-s">S</span>mall,
264 <span class="unit unit-m">M</span>edium,
265 or <span class="unit unit-l">L</span>arge unit damage
266 <dd>number of command points taken per unit
267 <dd><span class="unit unit-o">o</span>rganic/<span class="unit unit-u">m</span>echanic unit
269 total number of hitpoints (including shields)
271 <dd>percentage of HP in shields
272 <dd>shields always take full damage, irrelevant of unit size
273 <dd>does not take armor bonuses, but upgrades can decrease damage to any shield hit by upto 3
276 <dd>can be increased by upto 3 at various facilities
277 <dd>each point decreases damage per hit by one, upto a minimum of ½
278 <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>
280 <dd>damage done per single attack against ground/air units
281 <dd>2nd column indicates relative amount of damage done in
282 1 second of fastest game time
283 <dd>splash damage<span class="unit-splash">+</span> hits nearby objects as well
284 <dd><span class="hurt unit-l">explosive</span> damage does only
285 50% damage to small units, 75% to medium, 100% to large
286 <dd><span class="hurt unit-s">concussive/plasma</span> damage does
287 25% to large, 50% medium, 100% to small units
289 <dd>range in which the unit detects other units
290 <dd><strong class="unit-detect">emphasis</strong> indicates ability to detect cloaked units
292 <dd>maximum range of weapon (note siege tank also has a minimum range)
294 <dd>relative speed of movement (when in full motion, startup speed ignored)
296 <dd>special abilities are usually casted manually, but some are <span class="magic-perma">always active</span>
297 <dd>parentheses () indicate that it needs to be researched first
298 <dd>hover for description
299 <dd>range is maximum range required to activate
300 <dd>cost is percentage of total energy lost
304 When two values are given (1-2), second value indicates attribute after all