sc: reference shared attacks in data
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 10 Jun 2015 23:29:28 +0000 (01:29 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 10 Jun 2015 23:40:32 +0000 (01:40 +0200)
sc-units.inc.pl
sc.plp

index de7a97b6d4205a9723d8b7e4728ae274c83a8802..b32e5ef4f9c5426854cacdb0cbb68ad8539d2dda 100644 (file)
@@ -52,10 +52,7 @@ attack => {
                damage => 20,
                dps => 27,
        },
-       air => {
-               damage => 20,
-               dps => 27,
-       },
+       air => 'ground',
        range => 7,
 },
 sight => 11,
@@ -126,11 +123,7 @@ attack => {
                dps => [20, 22, 24, 26],
                type => 'explosive',
        },
-       air => {
-               damage => [20, 22, 24, 26],
-               dps => [20, 22, 24, 26],
-               type => 'explosive',
-       },
+       air => 'ground',
        range => 4,
 },
 sight => 8,
@@ -263,11 +256,7 @@ attack => {
                dps => [45, undef, undef, 59],
                splash => 1,
        },
-       air => {
-               damage => [30, 33, 36, 39],
-               dps => [45, undef, undef, 59],
-               splash => 1,
-       },
+       air => 'ground',
        range => 2,
 },
 sight => 8,
@@ -452,13 +441,7 @@ attack => {
                build => 12.7*$FM,
                max => 4,
        },
-       air => {
-               damage => [6, 7, 8, 9],
-               dps => [17, undef, undef, 49],
-               min => 25,
-               build => 12.7*$FM,
-               max => 4,
-       },
+       air => 'ground',
        range => 8,
 },
 sight => 11,
@@ -490,11 +473,7 @@ attack => {
                dps => [7, undef, undef, 9],
                type => 'explosive',
        },
-       air => {
-               damage => [10, 11, 12, 13],
-               dps => [7, undef, undef, 9],
-               type => 'explosive',
-       },
+       air => 'ground',
        range => 5,
 },
 sight => 9,
@@ -725,10 +704,7 @@ attack => {
                damage => [6, 7, 8, 9],
                dps => [12, undef, undef, 18],
        },
-       air => {
-               damage => [6, 7, 8, 9],
-               dps => [12, undef, undef, 18],
-       },
+       air => 'ground',
        range => 4,
 },
 sight => 7,
@@ -750,9 +726,7 @@ special => [
                        ground => {
                                dps => [24, undef, undef, 36],
                        },
-                       air => {
-                               dps => [24, undef, undef, 36],
-                       },
+                       air => 'ground',
                },
                duration => undef, #XXX
        },
@@ -817,11 +791,7 @@ attack => {
                dps => [14, undef, undef, 18],
                type => 'implosive',
        },
-       air => {
-               damage => [10, 11, 12, 13],
-               dps => [14, undef, undef, 18],
-               type => 'implosive',
-       },
+       air => 'ground',
        range => 7,
 },
 sight => 9,
@@ -1090,10 +1060,7 @@ attack => {
                damage => [25, 28, 31, 34],
                dps => [25, 28, 31, 34],
        },
-       air => {
-               damage => [25, 28, 31, 34],
-               dps => [25, 28, 31, 34],
-       },
+       air => 'ground',
        range => 6,
 },
 sight => 11,
@@ -1417,11 +1384,7 @@ attack => {
                dps => [20, 22, 24, 26],
                type => 'explosive',
        },
-       air => {
-               damage => [10, 11, 12, 13],
-               dps => [20, 22, 24, 26],
-               type => 'explosive',
-       },
+       air => 'ground',
        range => 4,
 },
 sight => 6,
@@ -1606,11 +1569,7 @@ attack => {
                dps => [9, 10, 11, 12],
                splash => 1,
        },
-       air => {
-               damage => [9, 10, 11, 12],
-               dps => [9, 10, 11, 12],
-               splash => 1,
-       },
+       air => 'ground',
        range => 3,
 },
 sight => 7,
diff --git a/sc.plp b/sc.plp
index 6b08c9477acb304665a865dc57178ca2f95d5013..d6ccaf62e8f72e3c0f8797726aa75ad2e1099e53 100644 (file)
--- a/sc.plp
+++ b/sc.plp
@@ -193,7 +193,9 @@ sub showrange {
        }
 
        if ($elements[0] eq 'attack' and $elements[1] ne 'range' and $elements[2] eq 'dps') {{
-               my $type = $row->{$elements[0]}->{$elements[1]}->{type} or next;
+               my $attack = $row->{ $elements[0] }->{ $elements[1] };
+               ref $attack or $attack = $row->{ $elements[0] }->{$attack}; # follow
+               my $type = $attack->{type} or next;
                if ($type eq 'explosive') {
                        $min /= 2;
                }
@@ -209,6 +211,11 @@ sub showrange {
        sub showattack {
                my ($row, $area) = @_;
                local $_ = $row->{attack}->{$area};
+               if (not ref $_) {
+                       # reference to another area
+                       $area = $_;
+                       $_ = $row->{attack}->{$area};
+               }
 
                return '<td colspan="2" class="hurt">' unless $_;