[airstrike] Missile "Bonus"

Ulf Ekström uekstrom at gmail.com
Wed Feb 15 16:40:26 EST 2006

Hi! Nice that someone is doing something on the game.

On 2/15/06, Erik Auerswald <auerswal at unix-ag.uni-kl.de> wrote:
> Hi,
> I've just commited some changes to control missile sprites with an AI.
> The previously checked in AI "seeker" can be used for that purpose. Turn
> rate and engine strength have not been tuned, the values present in the
> source have been kept. To test the new code use the shell functions
> "sprite", "ai" and "ai_target".

Seems to work fine, although I didn't test it so much.

> I would like to set the AI and the target when creating the missile
> bonus resp. when a ufo shoots a missile, but I was unable to understand
> the creation of missiles by bonus or ufo. Could someone point me to the
> right piece of code or even explain how it works, please?

On line 96 of sprites/ufo.c there is the response to the MSG_FIRE
message. The actual missile is created by

/* fire a missile */
m = sprite_create(&missile); // create the missile sprite
sprite_set_pos(m, s->pos.x, s->pos.y + 20); // Set start position for
the missile
m->vel.y = 0.1; // Set start velocity (down, for some reason which I
don't remember).

If you would like to set the ai to the seeker here you would do

ai_set_sprite_ai(m, "seeker");

Now, the ai in the missile doesn't know what its target is. You can
tell it to target a certain sprite (that you have a pointer to) by
sending a message to the missile sprite:


where m is a pointer to the missile and "target" is a pointer to the target.

Hope this helps, write back and tell us about your progress.


More information about the airstrike mailing list