This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fixing repair


Here are a few feeble attempts of mine to get the AI to better repair
its units when they get damaged.

I'm pretty sure the code in ai.c is wrong, but without it units would
get very easily distracted from the task of going back for repair (you
could see their tasks flicker between some offensive thingie and
repair).  Of course it created (or exposed) a different problem -
units staying in passive state - as noted in the comment, so I'm sure
there is a better solution.  If the repair code can work like the
resupply code, then we should be OK.

2001-08-17  Jim Kingdon  <kingdon@panix.com>

	* lib/stdunit.g: Up repair-percent to 75 - much too easy to kill
	off bombers (and others) at the default 35.
	* kernel/ai.c (ai_decide_plan): Don't try to do anything if we are
	heading back for repairs.
	* kernel/task.c (do_repair_task): Only look for repair from a
	transport which can provide it.

Index: kernel/ai.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/ai.c,v
retrieving revision 1.41
diff -u -r1.41 ai.c
--- ai.c	2000/12/28 15:10:46	1.41
+++ ai.c	2001/08/18 05:40:54
@@ -514,6 +514,21 @@
 
     /* First check that the unit's target (if it has one) is valid. */
     check_current_target(unit);
+
+    /* If a unit is (or should be) heading back for repair, that takes
+       priority.  Trying to attack or defend will just get us killed. */
+    if (unit->hp <= (u_hp_max(unit->type) 
+		     * unit_doctrine(unit)->repair_percent) / 100
+        && (u_hp_recovery(unit->type) > 0 || any_auto_repair)) {
+      /* If we just return, that's close, but if the unit is passive,
+	 it will stay passive.  Do we need a net_set_repair_task
+	 similar to net_set_resupply_task? (I'm pretty confused about
+	 what we can do here without confusing the network protocol
+	 and general logic.  Calling repair_if_damaged directly
+	 seems off, for example). */
+      return;
+    }
+
     /* Deal with tactical emergencies. */
     defensive_reaction(unit);
     offensive_reaction(unit);
Index: kernel/task.c
===================================================================
RCS file: /cvs/xconq/xconq/kernel/task.c,v
retrieving revision 1.33
diff -u -r1.33 task.c
--- task.c	2000/12/07 17:07:52	1.33
+++ task.c	2001/08/18 05:41:06
@@ -1362,7 +1362,9 @@
 	    set_unit_reserve(unit->side, unit, TRUE, FALSE);
 	}
     	return TASK_IS_INCOMPLETE;
-    } else if (unit->transport != NULL /* and transport repairs */) {
+    } else if (unit->transport != NULL
+	       && uu_auto_repair(unit->transport->type, unit->type) > 0
+	       /* || explicit repair */) {
 	set_unit_reserve(unit->side, unit, TRUE, FALSE);
     	return TASK_IS_INCOMPLETE;
     } else if ((unit2 = repair_here(ux, uy)) != NULL
Index: lib/stdunit.g
===================================================================
RCS file: /cvs/xconq/xconq/lib/stdunit.g,v
retrieving revision 1.8
diff -u -r1.8 stdunit.g
--- stdunit.g	2001/02/01 02:38:27	1.8
+++ stdunit.g	2001/08/18 05:41:08
@@ -600,6 +600,7 @@
 (doctrine default-doctrine
   (construction-run (u* 1))
   (rearm-percent 40)
+  (repair-percent 75)
   )
 
 (doctrine place-doctrine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]