]> git.pond.sub.org Git - empserver/commitdiff
torpedo: Fix mobility cost of retreat after hit
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 4 Jan 2015 12:12:48 +0000 (13:12 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 28 Feb 2015 15:21:35 +0000 (16:21 +0100)
torp() applies torpedo damage after retreat.  Wrong, because mobility
cost increases with damage.  Broken since retreat was added in
Chainsaw.

Fix by applying damage before retreat.  Bonus: bulletins make more
sense.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/torp.c
tests/retreat/final.xdump
tests/retreat/journal.log

index 1801a8229d96cefdb30e7f77b53de919fb536718..b09faaf266ad6c4797c30d1b241b97cae0af91d2 100644 (file)
@@ -31,7 +31,7 @@
  *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2010
+ *     Markus Armbruster, 2004-2015
  */
 
 #include <config.h>
@@ -178,11 +178,9 @@ torp(void)
                wu(0, vshipown, "%s in %s torpedoed %s for %d damage.\n",
                   prsub(&sub), xyas(sub.shp_x, sub.shp_y, vshipown),
                   prship(&vship), dam);
-           if (vship.shp_rflags & RET_TORPED) {
+           shipdamage(&vship, dam);
+           if (vship.shp_rflags & RET_TORPED)
                retreat_ship(&vship, 't');
-               shipdamage(&vship, dam);
-           } else
-               shipdamage(&vship, dam);
            pr("Torpedo hit %s for %d damage.\n", prship(&vship), dam);
 
            if (vship.shp_effic < SHIP_MINEFF)
index 5200363eee06620d0974e7ef689bf7fea8075df5..2ea0af95b8e59c4a89dcbebc94dd73813da1470b 100644 (file)
@@ -125,10 +125,10 @@ uid owner xloc yloc type effic mobil off tech opx opy mission radius fleet civil
 97 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 0 0 0 () ""
 98 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 0 0 0 () ""
 99 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 0 0 0 () ""
-100 2 2 4 2 38 37 0 20 0 0 none 0 "" 0 4 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
+100 2 2 4 2 38 -29 0 20 0 0 none 0 "" 0 4 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
 101 2 0 2 2 100 127 0 20 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (injured torped helpless) "nn"
-102 2 2 4 2 64 62 0 20 0 0 none 0 "" 0 6 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
-103 2 2 4 2 21 20 0 20 0 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
+102 2 2 4 2 64 35 0 20 0 0 none 0 "" 0 6 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 () ""
+103 2 1 3 2 21 -42 0 20 0 0 none 0 "" 0 2 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (injured torped helpless) "n"
 104 2 0 2 2 100 127 0 20 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" -3 1 1 (injured torped helpless) "nn"
 105 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 0 0 0 () ""
 106 0 0 0 0 0 127 0 0 0 0 none 0 "" 0 10 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 "" 0 0 0 () ""
index 9e094500f7144d993912c6d33a04b11de9ccd1f1..b7646b390f402d468f3b8b860f24d4f86efe3e3f 100644 (file)
     Play#0 output Play#0 1
     Play#0 output Play#0 1 0,2 takes 6% collateral damage
     Play#0 output Play#0 1 sub in -1,3 torpedoed cs   cargo ship (#100) for 75 damage.
-    Play#0 output Play#0 1 cs   cargo ship (#100) was hit by a torpedo, and retreated to 2,4
     Play#0 output Play#0 1     cs   cargo ship (#100) takes 62
+    Play#0 output Play#0 1 cs   cargo ship (#100) was hit by a torpedo, and retreated to 2,4
     Play#0 output Play#0 1 Torpedo sighted @ -1,3 by cs   cargo ship (#101)
     Play#0 output Play#0 1 sub in -1,3 torpedoed cs   cargo ship (#102) for 44 damage.
-    Play#0 output Play#0 1 cs   cargo ship (#102) was hit by a torpedo, and retreated to 2,4
     Play#0 output Play#0 1     cs   cargo ship (#102) takes 36
+    Play#0 output Play#0 1 cs   cargo ship (#102) was hit by a torpedo, and retreated to 2,4
     Play#0 output Play#0 1 sub in -1,3 torpedoed cs   cargo ship (#103) for 95 damage.
-    Play#0 output Play#0 1 cs   cargo ship (#103) was hit by a torpedo, and retreated to 2,4
     Play#0 output Play#0 1     cs   cargo ship (#103) takes 79
+    Play#0 output Play#0 1 cs   cargo ship (#103) was hit by a torpedo,
+    Play#0 output Play#0 1 but ran out of mobility, and couldn't retreat fully!
     Play#0 output Play#0 1 Torpedo sighted @ -1,3 by cs   cargo ship (#104)
     Play#0 output Play#0 1 Sonar ping from -6,0 detected by sb   submarine (#120)!
     Play#0 output Play#0 1 sb   submarine (#120) detected a sonar ping, and retreated to -9,1
     Play#0 output Play#0 1   2   82 dd   destroyer      0,2       100%   0  10   0   0  0  0  0  0 127   70
     Play#0 output Play#0 1   2   83 dd   destroyer      2,4        29%   0   3   0   0  0  0  0  0 -28   70
     Play#0 output Play#0 1   2   84 dd   destroyer      0,2       100%   0  10   0   0  0  0  0  0 127   70
-    Play#0 output Play#0 1   2  100 cs   cargo ship     2,4        38%   0   4   0   0  0  0  0  0  37   20
+    Play#0 output Play#0 1   2  100 cs   cargo ship     2,4        38%   0   4   0   0  0  0  0  0 -29   20
     Play#0 output Play#0 1   2  101 cs   cargo ship     0,2       100%   0  10   0   0  0  0  0  0 127   20
-    Play#0 output Play#0 1   2  102 cs   cargo ship     2,4        64%   0   6   0   0  0  0  0  0  62   20
-    Play#0 output Play#0 1   2  103 cs   cargo ship     2,4        21%   0   2   0   0  0  0  0  0  20   20
+    Play#0 output Play#0 1   2  102 cs   cargo ship     2,4        64%   0   6   0   0  0  0  0  0  35   20
+    Play#0 output Play#0 1   2  103 cs   cargo ship     1,3        21%   0   2   0   0  0  0  0  0 -42   20
     Play#0 output Play#0 1   2  104 cs   cargo ship     0,2       100%   0  10   0   0  0  0  0  0 127   20
     Play#0 output Play#0 1   2  120 sb   submarine     -9,1       100%   0  10   0   0  0  0  0  0  93   60
     Play#0 output Play#0 1   2  130 tt   troop trans   -9,1       100%   0  10   0   0  0  0  0  0  95   60
     Play#0 output Play#0 1   2   82 dd   destroyer      0,2      nn                  ihb
     Play#0 output Play#0 1   2   84 dd   destroyer      0,2      nn                  ihb
     Play#0 output Play#0 1   2  101 cs   cargo ship     0,2      nn                  ith
+    Play#0 output Play#0 1   2  103 cs   cargo ship     1,3      n                   ith
     Play#0 output Play#0 1   2  104 cs   cargo ship     0,2      nn                  ith
-    Play#0 output Play#0 1 24 ships
+    Play#0 output Play#0 1 25 ships
     Play#0 output Play#0 6 0 639
     Play#0 input miss s * ?mission#0 q
     Play#0 command mission