]> git.pond.sub.org Git - empserver/commitdiff
power: Use ship, plane, land unit tech instead of nation's
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 27 May 2016 18:08:39 +0000 (20:08 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 12:05:31 +0000 (14:05 +0200)
Actual abilities of ships, planes and land units depend almost
completely on the individual unit's tech, not the nation's tech.  The
power factor should reflect that.

The power value of a unit is of the form

    base value * (20 + nation's tech level) / 500

Change it to

    base value * (20 + unit's tech level) / 500

Note that a plane's base value still depends on the nation's tech
level.  This commit merely makes the absurdity stand out a bit more.
To be fixed later.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
info/power.t
src/lib/commands/powe.c
tests/smoke/journal.log
tests/update/journal.log

index 3f5b3ae8abb99d3aca62f6282be7e2deb70d202e..b3e8748c3341e082e0ecbf3162c1e3af5d45db2b 100644 (file)
@@ -70,9 +70,10 @@ The \*Qpower factor\*U is determined by the following equation:
 power factor = (  power value of money
                 + power value of sectors
                 + power value of commodities in sectors
-                + power value of ships, planes and land units
                 + power value of commodities loaded on ships and land units)
                * (20 + nation tech level) / 500
+             + power value of ships, planes and land units
+               * (20 + their tech level) / 500
 .FI
 .s1
 The power value of money is dollars / 100.
index 707300cc50d6edb1ccff96ebb138d2d5a8a4fdc5..f14cffe5b7b27e9da8bd2684b3ff8a437b99d23e 100644 (file)
@@ -51,6 +51,7 @@ static void out5(double, int, int);
 static void gen_power(struct powstr *, int);
 static int powcmp(const void *, const void *);
 static void addtopow(short *, struct powstr *);
+static float power_tech_factor(float);
 static float item_power(short[]);
 
 int
@@ -215,6 +216,7 @@ update_power(void)
 static void
 gen_power(struct powstr *powbuf, int save)
 {
+    float upower[MAXNOC];
     float *f_ptr;
     float *f_pt2;
     struct powstr *pow;
@@ -230,6 +232,7 @@ gen_power(struct powstr *powbuf, int save)
 
     player->btused += 10;
     memset(powbuf, 0, MAXNOC * sizeof(*powbuf));
+    memset(upower, 0, sizeof(upower));
     snxtsct_all(&ns);
     while (nxtsct(&ns, &sect)) {
        if (sect.sct_own == 0)
@@ -249,7 +252,7 @@ gen_power(struct powstr *powbuf, int save)
            * (land.lnd_effic / 100.0);
        f += (lchr[land.lnd_type].l_mat[I_HCM] / 10.0)
            * (land.lnd_effic / 100.0);
-       pow->p_power += f * 2;
+       upower[land.lnd_own] += f * 2 * power_tech_factor(land.lnd_tech);
        if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
            pow->p_units += 1.0;
     }
@@ -263,7 +266,7 @@ gen_power(struct powstr *powbuf, int save)
            * (ship.shp_effic / 100.0);
        f += (mchr[ship.shp_type].m_mat[I_HCM] / 10.0)
            * (ship.shp_effic / 100.0);
-       pow->p_power += f * 2;
+       upower[ship.shp_own] += f * 2 * power_tech_factor(ship.shp_tech);
        pow->p_ships += 1.0;
     }
     snxtitem_all(&ni, EF_PLANE);
@@ -273,8 +276,9 @@ gen_power(struct powstr *powbuf, int save)
        pow = &powbuf[plane.pln_own];
        pow->p_planes += 1.0;
        natp = getnatp(plane.pln_own);
-       pow->p_power += 20 * (plane.pln_effic / 100.0) *
+       = 20 * (plane.pln_effic / 100.0) *
            (20 + natp->nat_level[NAT_TLEV]) / 500.0;
+       upower[plane.pln_own] += f * power_tech_factor(plane.pln_tech);
     }
     for (i = 1; NULL != (natp = getnatp(i)); i++) {
        pow = &powbuf[i];
@@ -290,7 +294,8 @@ gen_power(struct powstr *powbuf, int save)
            pow->p_power += pow->p_sects
                * (pow->p_effic / pow->p_sects / 100.0)
                * 10.0;
-       pow->p_power *= (20 + natp->nat_level[NAT_TLEV]) / 500.0;
+       pow->p_power *= power_tech_factor(natp->nat_level[NAT_TLEV]);
+       pow->p_power += upower[i];
        /* ack.  add this vec to the "world power" element */
        f_pt2 = &powbuf[0].p_sects;
        f_ptr = &pow->p_sects;
@@ -344,6 +349,12 @@ addtopow(short *vec, struct powstr *pow)
     pow->p_power += item_power(vec);
 }
 
+static float
+power_tech_factor(float tech)
+{
+    return (20 + tech) / 500.0;
+}
+
 static float
 item_power(short item[])
 {
index 56130b2dee4b69dda17a82bca4fb71f0872ebb1b..1a20748ca840ecf98835d8a431e0bcd695669227 100644 (file)
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  31   37% 6.8K  60    0    0    0  4.5K 418  122    0    1    0   23K
-    Play#0 output Play#0 1     58.31
+    Play#0 output Play#0 1     58.23
     Play#0 output Play#0 1         6   3  100% 2.8K 110    0    0    0    0  404    0    0    0    0   27K
     Play#0 output Play#0 1     29.09
     Play#0 output Play#0 1         8   3  100% 2.8K 110    0    0    0    0  402    0    0    0    0   27K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  31   41% 8.8K  52    0    0    0  4.7K 378  190    0    1    0   22K
-    Play#0 output Play#0 1     81.06
+    Play#0 output Play#0 1     80.89
     Play#0 output Play#0 1         8  29   10% 3.0K 110    0    0    0    0  407    0    0    0    0   28K
     Play#0 output Play#0 1     33.09
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   28K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  32   44%  11K  52    0    0    0  5.4K 718  234    0    1    0   20K
-    Play#0 output Play#0 1    112.67
+    Play#0 output Play#0 1    112.41
     Play#0 output Play#0 1         8  29   10% 3.0K 110    0    0    0    0  407    0    0    0    0   29K
     Play#0 output Play#0 1     36.42
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   29K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  32   55%  13K  52    0    0    0  6.3K 1.6K 249    0    1    0   20K
-    Play#0 output Play#0 1    165.93
+    Play#0 output Play#0 1    165.58
     Play#0 output Play#0 1         8  29   17% 3.9K 110    0    0    0  474  1.5K   0    0    0    0   29K
     Play#0 output Play#0 1     57.47
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   30K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  32   73%  17K  52    0    0    0  7.6K 1.7K 619    0    1    0   19K
-    Play#0 output Play#0 1    237.26
+    Play#0 output Play#0 1    236.81
     Play#0 output Play#0 1         8  29   21% 5.1K 110    0    0    0  2.4K 1.8K   0    0    0    0   30K
     Play#0 output Play#0 1     74.54
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   31K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33   87%  22K  52    0    0    0  8.7K 2.5K 788    0    1    0   19K
-    Play#0 output Play#0 1    344.05
+    Play#0 output Play#0 1    343.50
     Play#0 output Play#0 1         8  29   28% 6.7K 110    0    0    0  5.0K 2.3K   0    0    0    0   30K
     Play#0 output Play#0 1    100.24
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   32K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33   95%  28K  82   51    0    0  9.2K 2.1K 812    0    1    0   23K
-    Play#0 output Play#0 1    456.98
+    Play#0 output Play#0 1    456.32
     Play#0 output Play#0 1         8  29   37% 8.7K 110    0    0    0  7.4K 2.1K 299    0    0    0   31K
     Play#0 output Play#0 1    130.22
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   33K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33   98%  31K 115  136    4    0  9.5K 1.8K 723    0    4    5   28K
-    Play#0 output Play#0 1    547.82
+    Play#0 output Play#0 1    547.04
     Play#0 output Play#0 1         8  29   43%  11K 110    0    0    0   10K 1.9K 480    0    0    0   32K
     Play#0 output Play#0 1    164.04
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   33K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33  100%  31K 147  243    9    0  9.6K 1.5K 608    0    2    4   32K
-    Play#0 output Play#0 1    634.16
+    Play#0 output Play#0 1    632.85
     Play#0 output Play#0 1         8  29   59%  15K 110    0    0    0   12K 1.9K 483    0    0    0   29K
     Play#0 output Play#0 1    233.54
     Play#0 output Play#0 1         6   3  100% 3.0K 110    0    0    0    0  404    0    0    0    0   34K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33  100%  31K 180  372   15    0  9.2K 1.2K 866    0    3    4   39K
-    Play#0 output Play#0 1    752.06
+    Play#0 output Play#0 1    750.07
     Play#0 output Play#0 1         8  29   73%  19K 110    0    0    0   13K 2.1K 365    0    0    0   24K
     Play#0 output Play#0 1    344.74
     Play#0 output Play#0 1         2  30   15% 3.7K   0    0    0    0    0  1.1K   0    0    0    0   34K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33  100%  31K 213  514   22    0  9.1K 849  1.2K   3    5    4   46K
-    Play#0 output Play#0 1    886.30
+    Play#0 output Play#0 1    883.35
     Play#0 output Play#0 1         8  29   91%  25K 110  101    0    0   14K 2.8K 527    0    0    0   21K
     Play#0 output Play#0 1    507.49
     Play#0 output Play#0 1         2  30   28% 4.9K   0    0    0    0  1.7K 1.3K 170    0    0    0   35K
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  33  100%  31K 235  659   30  994  8.9K 524  1.0K   3    5    4   51K
-    Play#0 output Play#0 1   1014.32
+    Play#0 output Play#0 1   1009.88
     Play#0 output Play#0 1         8  29  100%  29K 105  215    5    0   15K 2.5K 541    0    0    0   23K
     Play#0 output Play#0 1    648.10
     Play#0 output Play#0 1         2  30   33% 6.3K   0    0    0    0  3.2K 1.2K 523    0    0    0   36K
index eee9fc558e3e1fc9f6c22ab7d11b0743fb583620..77ab15a8639ab9c1e5ed59b1676f541fe02e3e73 100644 (file)
     Play#0 output Play#0 1
     Play#0 output Play#0 1          sects  eff civ  mil  shell gun pet  iron dust oil  pln ship unit money
     Play#0 output Play#0 1         1  96   62%  28K 1.2K   0    0    0  2.5K 340  580   21   32   16   25K
-    Play#0 output Play#0 1   1594.49
+    Play#0 output Play#0 1   1557.40
     Play#0 output Play#0 1         3  64   14%  17K 170    0    0    0    0    0    0    0    0    0 -100
     Play#0 output Play#0 1    451.42
     Play#0 output Play#0 1         6   8   88% 4.0K 168    0    0    0    0    0    0    3    1    3   25K
-    Play#0 output Play#0 1    414.49
+    Play#0 output Play#0 1    417.19
     Play#0 output Play#0 1         7   8   88% 4.0K 160    0    0    0    0    0    0    0    3    0   25K
-    Play#0 output Play#0 1    409.34
+    Play#0 output Play#0 1    407.81
     Play#0 output Play#0 1         4  64    8%  25K 1.1K   0    0    0   20K  21  4.0K   0   10   10   25K
-    Play#0 output Play#0 1    381.02
+    Play#0 output Play#0 1    378.22
     Play#0 output Play#0 1         2  32   22% 7.1K 1.9K   0    0    0    0    1    5    3    3    3  100
-    Play#0 output Play#0 1    338.51
+    Play#0 output Play#0 1    333.05
     Play#0 output Play#0 1         5   0    0%   0    0    0    0    0    0    0    0    0    0    0   25K
     Play#0 output Play#0 1     60.00
     Play#0 output Play#0 1           ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----