Allow aliens to attack "less desirable" targets if they can't find a good one.

The way it previously was, in particular, Sid 100% refused to attack
fighting vessels and Phoebe and Ursula 100% refused to attack
non-fighting vessels.  This was most notable with the Urusor mission,
where Sid would just become completely idle after disabling the last
non-combat vessel and would often just drift off into the distance
as a result (especially annoying in Classic difficulty as this
could make it very difficult to find the remaining enemies).

So now, instead these targets are treated as "undesirables", which
normally will be avoided but will be accepted after 30 frames.
This stops allies from idling around forever.

This rule has also been applied to a rule that didn't allow targeting
enemies beyond a particular distance.

I'm keeping it in Classic difficulty for now, but might add an
exception later.
This commit is contained in:
Julie Marchant 2019-06-22 08:34:57 -04:00
parent cda23d7f7c
commit 75327aa3f8
3 changed files with 22 additions and 4 deletions

View File

@ -869,6 +869,7 @@ void aliens_init()
aliens[i].active = 0;
aliens[i].shield = -1;
aliens[i].flags = 0;
aliens[i].badTargetCount = 0;
}
switch (game.area)
@ -1651,12 +1652,14 @@ void alien_searchForTarget(Object *alien)
{
int i;
Object *targetEnemy;
int badTarget = 0;
if (alien->flags & FL_WEAPCO)
{
if (CHANCE(1 / 10.))
{
alien->target = &player;
alien->badTargetCount = 0;
return;
}
}
@ -1668,8 +1671,11 @@ void alien_searchForTarget(Object *alien)
// return fire. This will save him from messing about (unless we're on the last mission)
if ((alien->classDef == CD_SID) && (game.area != MISN_EARTH))
{
if ((targetEnemy->flags & FL_DISABLED) || (!(targetEnemy->flags & FL_NOFIRE)))
if (targetEnemy->flags & FL_DISABLED)
return;
if (!(targetEnemy->flags & FL_NOFIRE))
badTarget = 1;
}
// Tell Phoebe and Ursula not to attack ships that cannot fire or are disabled (unless we're on the last mission)
@ -1683,7 +1689,7 @@ void alien_searchForTarget(Object *alien)
if ((targetEnemy->flags & FL_DISABLED) ||
(targetEnemy->flags & FL_NOFIRE))
return;
badTarget = 1;
}
}
@ -1697,12 +1703,20 @@ void alien_searchForTarget(Object *alien)
return;
if (abs((int)alien->x - (int)alien->target->x) > 550)
return;
badTarget = 1;
if (abs((int)alien->y - (int)alien->target->y) > 400)
return;
badTarget = 1;
if (badTarget)
{
alien->badTargetCount++;
if (alien->badTargetCount < BAD_TARGET_ALLOW_TIME)
return;
}
alien->target = targetEnemy;
alien->badTargetCount = 0;
}
/*

View File

@ -89,6 +89,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ALIEN_WARP_SPEED MIN(-15, -3 * screen->w / 160)
#define ALIEN_WARP_ACCEL (game.difficulty == DIFFICULTY_ORIGINAL ? -15: -0.5)
#define BAD_TARGET_ALLOW_TIME 30
#define SLAVE_RESCUE_TARGET 250
#define PIXFONT_LINE_HEIGHT 16

View File

@ -45,6 +45,8 @@ typedef struct Object_ {
int face; // Either 0 or 1
int badTargetCount;
struct Object_ *owner; // Who owns this Object
int chance[2]; // Chance of using the weapons (out of 1000)