]> git.pond.sub.org Git - empserver/commitdiff
assault: Make spies "sneaking ashore" use mobility and hit mines
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jul 2016 21:18:06 +0000 (23:18 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:18 +0000 (20:09 +0200)
Assaulting a foreign sector with nothing but spies is special: the
spies sneak ashore.  It is, however, more special than it should be:
the spies use no mobility and ignore landmines.  They do use mobility
and hit landmines in other assaults.  Assaulting your own sector with
nothing but spies is more costly and more risky than assaulting a
foreign one.  This makes no sense.  Has been that way since spies were
added in 4.0.0.

It's that way because sneaking ashore uses its own code to move the
spies instead of move_in_land() via att_move_in_off().  It can't use
move_in_land(), because that prints an unwanted "now occupies"
message, and destroys the list of assaulting units, which we still
need to catch and shoot spies.

Factor the code to move attacking land units to the target sector out
of move_in_land() into att_move_land(), and use that for sneaking
ashore.  This makes the spies use mobility and hit landmines even when
they sneak.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/combat.h
src/lib/commands/assa.c
src/lib/subs/attsub.c

index 5ced9ff22ca24b308257ec8dc548408d7f42de8e..0f24ae0f17dcc0b6460336ee56daab756d8d08a4 100644 (file)
@@ -28,6 +28,7 @@
  *
  *  Known contributors to this file:
  *     Ken Stevens, 1995
+ *     Markus Armbruster, 2005-2016
  */
 
 #ifndef COMBAT_H
@@ -69,6 +70,8 @@ struct combat {
 
 /* src/lib/subs/attsub.c */
 extern double att_combat_eff(struct combat *);
+extern void att_move_land(int, struct combat *, struct emp_qelem *,
+                         struct combat *);
 extern void att_move_in_off(int, struct combat *, struct emp_qelem *,
                            struct combat *);
 extern int att_combat_init(struct combat *, int);
index 43b585c55fb6c520ddaa8224d5c495b1fa2478cc..e2d0a23bd5d07c79cbccb4f704316576f31af7b3 100644 (file)
@@ -41,7 +41,8 @@
 #include "unit.h"
 
 static int only_spies(struct combat[], struct emp_qelem *);
-static void sneak_ashore(struct emp_qelem *, struct combat *);
+static void sneak_ashore(struct combat[], struct emp_qelem *,
+                        struct combat *);
 
 int
 assa(void)
@@ -139,7 +140,7 @@ assa(void)
     /* If no attacking forces (i.e. we got here with only spies)
      * then try to sneak on-land. */
     if (only_spies(off, &olist)) {
-       sneak_ashore(&olist, def);
+       sneak_ashore(off, &olist, def);
        return RET_OK;
     }
 
@@ -191,7 +192,8 @@ only_spies(struct combat off[], struct emp_qelem *olist)
 }
 
 static void
-sneak_ashore(struct emp_qelem *olist, struct combat *def)
+sneak_ashore(struct combat off[], struct emp_qelem *olist,
+            struct combat *def)
 {
     struct emp_qelem *qp;
     struct ulist *llp;
@@ -200,15 +202,14 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def)
 
     pr("Trying to sneak on shore...\n");
 
+    att_move_land(A_ASSAULT, off, olist, def);
+
     for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
        llp = (struct ulist *)qp;
        lp = &llp->unit.land;
        rel = relations_with(def->own, player->cnum);
        if (chance(0.10) || rel == ALLIED || !def->own) {
            pr("%s made it on shore safely.\n", prland(lp));
-           lp->lnd_x = def->x;
-           lp->lnd_y = def->y;
-           lp->lnd_ship = -1;
        } else {
            pr("%s was spotted", prland(lp));
            if (rel <= HOSTILE) {
@@ -222,9 +223,6 @@ sneak_ashore(struct emp_qelem *olist, struct combat *def)
                   cname(player->cnum), xyas(def->x, def->y,
                                             def->own));
                pr(" but made it ok.\n");
-               lp->lnd_x = def->x;
-               lp->lnd_y = def->y;
-               lp->lnd_ship = -1;
            }
        }
     }
index 59f7258fcc7776e6a94247ec3f171f67164206a1..f0c18647f028d280b09961600e5624e853e3cb40 100644 (file)
@@ -2299,15 +2299,12 @@ ask_move_in(struct combat *off, struct emp_qelem *olist,
     move_in_land(A_ATTACK, off, olist, def);
 }
 
-/* Move offensive land units to the conquered sector or ship */
-
-static void
-move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
-            struct combat *def)
+void
+att_move_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
+             struct combat *def)
 {
     struct emp_qelem *qp, *next;
     struct ulist *llp;
-    char buf[512];
 
     for (qp = olist->q_forw; qp != olist; qp = next) {
        next = qp->q_forw;
@@ -2322,6 +2319,19 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
        else
            llp->unit.land.lnd_ship = -1;
     }
+}
+
+/* Move offensive land units to the conquered sector or ship */
+
+static void
+move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
+            struct combat *def)
+{
+    struct emp_qelem *qp, *next;
+    struct ulist *llp;
+    char buf[512];
+
+    att_move_land(combat_mode, off, olist, def);
 
     if (def->type == EF_SECTOR) {
        if (opt_INTERDICT_ATT) {