Enable AI flags to focus on targets.

This commit is contained in:
Steve 2016-03-29 22:45:46 +01:00
parent 6016e46c37
commit 52691f7be5
3 changed files with 13 additions and 4 deletions

View File

@ -332,12 +332,14 @@ static int canAttack(Entity *e)
{
if (e->aiFlags & (AIF_AVOIDS_COMBAT | AIF_EVADE) || e->flags & EF_SECONDARY_TARGET)
{
if (rand() % 5)
return !(rand() % 5);
}
}
if ((self->aiFlags & AIF_TARGET_FOCUS) && (!(e->flags & EF_AI_TARGET)))
{
return 0;
}
}
}
return selectWeaponForTarget(e);
}
@ -578,6 +580,11 @@ static int nearEnemies(void)
{
if ((e->flags & EF_TAKES_DAMAGE) && e->side != self->side && !(e->flags & EF_DISABLED))
{
if ((self->aiFlags & AIF_TARGET_FOCUS) && (e->flags & EF_AI_TARGET))
{
continue;
}
if (getDistance(e->x, e->y, self->x, self->y) < 1000)
{
self->targetLocation.x += e->x;

View File

@ -115,6 +115,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AIF_EVADE (2 << 13)
#define AIF_WANDERS (2 << 14)
#define AIF_COVERS_RETREAT (2 << 15)
#define AIF_TARGET_FOCUS (2 << 16)
/* player abilities */
#define BOOST_RECHARGE_TIME (FPS * 7)

View File

@ -79,6 +79,7 @@ void initLookups(void)
addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER);
addLookup("AIF_WANDERS", AIF_WANDERS);
addLookup("AIF_COVERS_RETREAT", AIF_COVERS_RETREAT);
addLookup("AIF_TARGET_FOCUS", AIF_TARGET_FOCUS);
addLookup("DT_ANY", DT_ANY);
addLookup("DT_NO_SPIN", DT_NO_SPIN);