The following patch (from my repository) builds on Jimmy's work and
takes into account home planets that may have been moved as part of a
scenario, or where new home planets are nominated by the PLANETS setting
in etc/sysdef.

I've tested this to my satisfaction, by running a game with the robots
and using xsg to move things around.

One thing I did notice, which I'm calling for help on from anyone who
knows the code better ... is that the robots would stop concentrating on
the enemy planets in favour of the third space planets, if those third
space planets were within range of them.

Move a few Orion planets to the front between Romulan and Federation,
and the robots just orbit them with shields down, presumably trying to
bomb, and dying.

I think I've seen this in situations with unmodified planet positions.

-- 
James Cameron    mailto:quozl at us.netrek.org     http://quozl.netrek.org/
-------------- next part --------------
Wed May 10 17:31:41 EST 2006  quozl at us.netrek.org
  * robots to cloak near any home planet
  Factorised the decision of what makes a res death risk, and included a
  check for proximity to any home planet.  Used ntserv/enter.c and max
  phaser distance to determine a rectangular area of risk.
diff -rN -u old-netrek-server/Vanilla/NEWS new-netrek-server/Vanilla/NEWS
--- old-netrek-server/Vanilla/NEWS	2006-05-10 22:16:31.000000000 +1000
+++ new-netrek-server/Vanilla/NEWS	2006-05-10 22:16:31.000000000 +1000
@@ -1,3 +1,4 @@
+- fix practice robots to cloak when bombing near home planet [Huang]
 - fix INL confine to knock ships out of orbit [Cameron]
 - describe a local unnamed server as "server on this computer" [Cameron]
 - fix cambot regression [Cameron]
diff -rN -u old-netrek-server/Vanilla/robotd/assault.c new-netrek-server/Vanilla/robotd/assault.c
--- old-netrek-server/Vanilla/robotd/assault.c	2006-05-10 22:16:31.000000000 +1000
+++ new-netrek-server/Vanilla/robotd/assault.c	2006-05-10 22:16:31.000000000 +1000
@@ -43,6 +43,30 @@
    }
 }
 
+/* determine if there is risk of death due to res of opponent */
+static int risk_res_death(struct planet *pl)
+{
+  if (pl == NULL) return 0;
+  /* One of the home planets identified by server etc/sysdef PLANETS */
+  if (pl->pl_flags & PLHOME) return 1;
+  /* Altair in standard position */
+  if (pl->pl_no == 7 && pl->pl_x == 11000 && pl->pl_y == 75000) return 1;
+  /* Draconis in standard position */
+  if (pl->pl_no == 16 && pl->pl_x == 28000 && pl->pl_y == 23000) return 1;
+  /* Scorpii in standard position */
+  if (pl->pl_no == 26 && pl->pl_x == 70720 && pl->pl_y == 26320) return 1;
+  /* Within rectangular phaser distance of any home planet res point */
+  int i;
+  for (i=0,pl=planets;i<MAXPLANETS;i++,pl++) {
+    if (pl->pl_flags & PLHOME) {
+      if(ABS(pl->pl_x - me->p_x) < 12000 && ABS(pl->pl_y - me->p_y) < 12000) {
+	return 1;
+      }
+    }
+  }
+  return 0;
+}
+
 goto_assault_planet()
 {
    Player		*e = _state.closest_e;
@@ -79,17 +103,7 @@
    /* cloak bomb near enemy core, so you don't get res-killed */
 
    if (pdist < 7000) {
-     if (pl && pl->pl_flags&PLHOME)
-       cloak=1;
-
-     if (pl && pl->pl_no == 7) /* Altair */
-       cloak=1;
-
-     if (pl && pl->pl_no == 16) /* Draconis */
-       cloak=1;
-
-     if (pl && pl->pl_no == 26) /* Scorpii */
-       cloak=1;
+     if (risk_res_death(pl)) cloak = 1;
    }
 
    if(pdist < 10000 && edist < 18000)
@@ -174,17 +188,7 @@
    }
 
    /* cloak bomb near enemy core, so you don't get res-killed */
-   if (pl && pl->pl_flags&PLHOME)
-     cloak=1;
-
-   if (pl && pl->pl_no == 7) /* Altair */
-     cloak=1;
-
-   if (pl && pl->pl_no == 16) /* Draconis */
-     cloak=1;
-
-   if (pl && pl->pl_no == 26) /* Scorpii */
-     cloak=1;
+   if (risk_res_death(pl)) cloak = 1;
 
    if(cloak)
       req_cloak_on();

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.us.netrek.org/pipermail/netrek-dev/attachments/20060510/2d3932f9/attachment-0001.pgp