diff --git a/src/alien.c b/src/alien.c index 96ce245..098c8d6 100644 --- a/src/alien.c +++ b/src/alien.c @@ -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; } /* diff --git a/src/defs.h b/src/defs.h index aea8c7c..8424b66 100644 --- a/src/defs.h +++ b/src/defs.h @@ -89,6 +89,8 @@ along with this program. If not, see . #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 diff --git a/src/structs.h b/src/structs.h index 60d0fe5..954d4ea 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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)