X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/1de61e5745ecf3dd1a41e1e932bae2f7568353a4..f5e535f48dc60fdcaa93b9b6ee523801448b9f82:/sc.plp
diff --git a/sc.plp b/sc.plp
index 55dbd09..09ae989 100644
--- a/sc.plp
+++ b/sc.plp
@@ -1,42 +1,93 @@
<(common.inc.plp)><:
+use List::Util qw(max sum);
+
+my %scver = (
+ id => 'bw',
+ name => 'Brood War',
+ title => 'starcraft',
+ game => 'StarCraft',
+ major => 1,
+);
-my $scver = 'bw';
if ($ENV{PATH_INFO} and $ENV{PATH_INFO} eq '/2') {
- my $scver = 'hots';
+ %scver = (
+ id => 'hots',
+ name => 'Heart of the Swarm',
+ title => 'starcraft2',
+ game => 'StarCraft II',
+ major => 2,
+ );
}
-my $datafile = "sc-units-$scver.inc.pl";
+my $datafile = "sc-units-$scver{id}.inc.pl";
Html({
- title => 'starcraft unit cheat sheet',
- version => 'v1.0',
+ title => "$scver{title} unit cheat sheet",
+ version => 'v1.1',
description => [
- 'Reference of StarCraft unit properties,'
- . ' comparing various statistics of all the units in Brood War'
+ "Reference of $scver{game} unit properties,"
+ . " comparing various statistics of all the units in $scver{name}"
. ' including costs, damage, defense, speed, ranges, and abilities.',
],
- keywords => [qw'
+ keywords => [
+ qw'
starcraft game unit statistics stats comparison table sheet cheat
reference software attributes properties
- '],
+ ',
+ $scver{major} < 2 ? qw' bw broodwar brood war ' : qw' starcraft2 hots ',
+ ],
stylesheet => [qw'light'],
raw => '',
data => [$datafile],
});
-:>
-
StarCraft units
+print "
$scver{game} units
\n\n";
-
-Unit properties as seen or measured in Brood War
-versionâ¥1.08.
-
+my $units = do $datafile;
+die "Cannot open unit data: $_\n" for $@ || $! || ();
+my $patch = shift @{$units}
+ or die "Cannot open unit data: metadata not found\n";
+
+print "
Unit properties as seen or measured in $scver{name}\n$patch.\n";
+print "Also see the $_ table.\n" for join(', ',
+ ('StarCraft 2: HotS') x ($scver{major} < 2),
+ ('original SC: Brood War') x ($scver{major} > 1),
+);
+print "
\n\n";
+
+sub addupgrade {
+ my ($ref, $increase, $org) = @_;
+ if (ref $increase eq 'HASH') {
+ addupgrade(\${$ref}->{$_}, $increase->{$_}, $org->{$_}) for keys %{$increase};
+ }
+ elsif (ref $increase eq 'ARRAY') {
+ addupgrade(\${$ref}->[$_], $increase->[$_], $org->[$_]) for 0 .. $#{$increase};
+ }
+ ${$ref} //= $org;
+ ${$ref} += $increase if $increase =~ /^-?[0-9.]+/;
+}
+
+for my $unit (@{$units}) {
+ for my $upgrade (@{ $unit->{upgrade} }) {
+ while (my ($col, $increase) = each %{$upgrade}) {
+ defined $unit->{$col} or next;
+ addupgrade(\$unit->{upgraded}->{$col}, $increase, $unit->{$col});
+ }
+ }
+ for my $special (@{ $unit->{special} }) {
+ for my $upgrade (@{ $special->{upgrade} }) {
+ while (my ($col, $increase) = each %{$upgrade}) {
+ defined $special->{$col} or next;
+ addupgrade(\$special->{upgraded}->{$col}, $increase, $special->{$col});
+ }
+ }
+ }
+}
-<:
sub coltoggle {
- my ($name, $id) = @_;
+ my ($name, $id, $nolink) = @_;
return sprintf(
(defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s â¼'
- : '%s',
+ : $nolink ? '%2$s' : '%s',
$id && "order=$id", $name
);
}
@@ -47,13 +98,13 @@ sub coltoggle {
<:= coltoggle(qw'build cost') :>
-
<:= coltoggle(qw'size size') :>
+
<:= coltoggle(qw'size size') :>
HP
shield
-
armor
-
ground
-
air
-
range
+
â¨
+
attack
+
<:= coltoggle(qw'dps attack 1') :>
+
range
sight
speed
specials
@@ -61,80 +112,96 @@ sub coltoggle {
<:
sub showrange {
my ($min, $max) = @_;
- $_ = int($_ + .5) for $min, $max; # round halves up
- return $min == $max ? $min : "$min-$max";
+ return '' if not defined $min;
+ $_ &&= int($_ + .5) for $min, $max; # round halves up
+ return $min if not defined $max or $min == $max;
+ return "$min-$max";
}
-sub showval {
- my ($row, @elements) = @_;
- my ($min, $max);
+ sub showattack {
+ my ($row, $area) = @_;
+ my $attack = $row->{attack}->[$area]
+ or return '
';
- my $value = $row;
- $value = ref $value eq 'HASH' && $value->{$_} or last for @elements;
- if (ref $value eq 'ARRAY') {
- $min = $value->[0];
- $max = $value->[-1];
- }
- else {
- $min = $max = $value;
- }
- defined $min or return '';
+ my $upattack = $row->{upgraded}->{attack}->[$area];
+ my $damage = $attack->{damage};
+ my $maxdamage = $upattack->{damage} // $damage;
+ $maxdamage += ($upattack->{upgrade} // $attack->{upgrade}) * 3;
- if ($row->{upgrade}) {
- for (@{ $row->{upgrade} }) {
- my $increase = $_ or next;
- $increase = ref $increase eq 'HASH' && $increase->{$_} or last for @elements;
- $increase = $increase->[-1] if ref $increase eq 'ARRAY';
- $max += $increase if $increase;
- }
+ my $out = '
each point decreases damage per hit by one, upto a minimum of ½
-
reduction applies to initial damage, before size penalties (so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)
-
ground/air
-
damage done per single attack against ground/air units
-
2nd column indicates relative amount of damage done in
- 1 second of fastest game time
-
splash damage+ hits nearby objects as well
-
explosive damage does only
+
reduction applies to initial damage, before size penalties
+ (so a plasma hit of 12 to 4 armor large deals 2 damage, not ½)
+
attack
+
damage given per single hit
+
dps indicates relative amount of damage
+ done in 1 second of in-game time
+
splash damage hits all objects nearby â
+ or in a straight line +.
+
<:
+if ($scver{major} > 1) {
+ :>does not include ≥bonus damage
+ dealt to susceptible unit types
+
â¢projectile shots are negated by
+ Point Defense Drones<:
+} else {
+ :>*explosive damage does only
50% damage to small units, 75% to medium, 100% to large
-
concussive/plasma damage does
- 25% to large, 50% medium, 100% to small units
+
~concussive/plasma damage does
+ 25% to large, 50% medium, 100% to small units<:
+} :>
+
targets â½ ground
+ and/or â³ air
+
range
+
maximum range of weapon (note siege tank also has a minimum range)
sight
range in which the unit detects other units
emphasis indicates ability to detect cloaked units
-
range
-
maximum range of weapon (note siege tank also has a minimum range)
speed
relative speed of movement (when in full motion, startup speed ignored)
specials
-
special abilities are usually casted manually, but some are always active
parentheses () indicate that it needs to be researched first
+