Allow enemies to fire missiles.

This commit is contained in:
Steve 2015-10-30 21:55:01 +00:00
parent c506ad32cf
commit aaf58614f4
5 changed files with 22 additions and 4 deletions

View File

@ -17,5 +17,9 @@
"x" : 8,
"y" : 0
}
]
],
"missiles" : {
"type" : "MISSILE_MISSILE",
"ammo" : 2
}
}

View File

@ -17,5 +17,9 @@
"x" : 8,
"y" : 0
}
]
],
"missiles" : {
"type" : "MISSILE_MISSILE",
"ammo" : 2
}
}

View File

@ -287,9 +287,16 @@ static int hasClearShot(void)
static void preAttack(void)
{
if (!self->reload && self->guns[0].type)
if (!self->reload)
{
fireGuns(self);
if (self->missiles.ammo == 0 || (rand() % 50) > 0)
{
fireGuns(self);
}
else
{
fireMissile(self);
}
}
}

View File

@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int mod(int n, int x);
extern int getDistance(int x1, int y1, int x2, int y2);
extern void fireGuns(Entity *owner);
extern void fireMissile(Entity *owner);
extern float getAngle(int x1, int y1, int x2, int y2);
extern void applyFighterThrust(void);
extern void applyFighterBrakes(void);

View File

@ -104,6 +104,8 @@ static void randomizeDart(Entity *dart)
randomizeDartGuns(dart);
dart->missiles.ammo = rand() % 3;
sprintf(textureName, "gfx/fighters/dart0%d.png", 1 + rand() % 7);
dart->texture = getTexture(textureName);