[airstrike] Missile "Bonus"

Erik Auerswald auerswal at unix-ag.uni-kl.de
Thu Feb 16 12:59:49 EST 2006


Hi,

On Thu, Feb 16, 2006 at 05:07:31PM +0100, Ulf Ekström wrote:
> I will test tonight.

The attached patch tells the seeker ai about warping. The ai favours
warping from one screen edge to the other over turning more than 90
degrees. This fine for missiles with a huge turn radius and enough speed
to reach its target. It represents a forward looking sensor better than
a missile turning around if its target suddenly warps to its back. But
it is nevertheless strange to watch the missile flying away from its
target (ignoring the warp results in strange maneuvers when the missile
is close to its target when the target warps and the missile warps as
well because it could not turn around fast enough). It would be best if
you could test the svn version as well as this patch to see for
yourself. We can then come to an conclusion what to do.

Erik

P.S. I'll clean the patch a bit if it shall be commited...
-------------- next part --------------
Index: src/engine/ai.c
===================================================================
--- src/engine/ai.c	(revision 73)
+++ src/engine/ai.c	(working copy)
@@ -34,12 +34,23 @@
       /* always accelerate */
       obj_message(control,msg_ctrl(MSG_ACCELERATE));
       /* turn towards target */
-      if(sai->target && obj_alive(sai->target)){
-	if(vcross(control->vel, vsub(sai->target->pos, control->pos)) < 0) {
-	  obj_message(control,msg_ctrl(MSG_UP));
-	} else {
-	  obj_message(control,msg_ctrl(MSG_DOWN));
-	}
+      if(sai->target && obj_alive(sai->target)) {
+        vector_t tmp_v1, tmp_v2;
+        float tmp_f;
+        /* adjust target position to use warping */
+        /* this does not take relative velocity into account */
+        tmp_v1 = vnormalize(vsub(sai->target->pos, control->pos));
+        tmp_v2 = vnormalize(control->vel);
+        tmp_f = vdot(tmp_v1, tmp_v2);
+        if(tmp_f < 0.0) {
+          tmp_v2 = vector(((control->vel.x<0) ? -1 : 1) * 800, 0);
+        }
+        tmp_v1 = vadd(tmp_v2, sai->target->pos);
+        if(vcross(control->vel, vsub(tmp_v1, control->pos)) < 0) {
+          obj_message(control,msg_ctrl(MSG_UP));
+        } else {
+          obj_message(control,msg_ctrl(MSG_DOWN));
+        }
       }
       return MSG_RET_CONT;
     case MSG_SET_TARGET:	/* get sprite to kill */


More information about the airstrike mailing list