]> git.pond.sub.org Git - empserver/commitdiff
torpedo: Let torpedo hit land only when target is in range
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 15 Feb 2015 13:25:39 +0000 (14:25 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:52 +0000 (08:20 +0100)
Telling the player his torpedo "slams into land" can give a clue on
the direction to the target.  No good when the target is out of range,
because we shouldn't tell the player more than that then.

Screwed up in 4.2.2.  Fix by checking range before line of sight.

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

index 7c0902dade0af8cbbc7daaf10664a4d894f78602..ee215ff089dca8d42942eb2a01cdb94b229ed0c1 100644 (file)
@@ -161,19 +161,16 @@ torp(void)
        if (range <= erange) {
            pr("Hitchance = %d%%\n", (int)(hitchance * 100));
        }
-       /* Now, can the torpedo even get there? */
-       if (!line_of_sight(NULL, sub.shp_x, sub.shp_y,
-                          vship.shp_x, vship.shp_y)) {
+       if (range > erange)
+           pr("Out of range\n");
+       else if (!line_of_sight(NULL, sub.shp_x, sub.shp_y,
+                               vship.shp_x, vship.shp_y)) {
            pr("BOOM!... Torpedo slams into land before reaching target.\n");
            /* We only tell the victim if we were within range. */
-           if (range <= erange) {
-               if (vshipown != 0)
-                   wu(0, vshipown, "Torpedo sighted @ %s by %s\n",
-                      xyas(sub.shp_x, sub.shp_y, vshipown),
-                      prship(&vship));
-           }
-       } else if (range > erange) {
-           pr("Out of range\n");
+           if (vshipown != 0)
+               wu(0, vshipown, "Torpedo sighted @ %s by %s\n",
+                  xyas(sub.shp_x, sub.shp_y, vshipown),
+                  prship(&vship));
        } else if (chance(hitchance)) {
            pr("BOOM!...\n");
            if (vshipown != 0)
index 0a5a2e5428e14a0747272f854ff79b87877e4dda..b9022167d13573e165549513f5de2460bdc4b70c 100644 (file)
@@ -95,7 +95,7 @@
     Play#1 command torpedo
     Play#1 output Play#1 1 1 ships are eligible to torpedo
     Play#1 output Play#1 1 Effective torpedo range is 3.0
-    Play#1 output Play#1 1 Whooosh... BOOM!... Torpedo slams into land before reaching target.
+    Play#1 output Play#1 1 Whooosh... Out of range
     Play#1 output Play#1 6 0 595
     Play#1 input torp 0 45
     Play#1 command torpedo