Added SECONDARY_TARGET flag.

This commit is contained in:
Steve 2015-12-10 12:40:23 +00:00
parent e3ec8017af
commit 05f58e0971
4 changed files with 21 additions and 9 deletions

View File

@ -100,7 +100,7 @@
"y" : -250,
"reloadTime" : 40,
"type" : "BT_ROCKET",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -110,7 +110,7 @@
"y" : -250,
"reloadTime" : 40,
"type" : "BT_ROCKET",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -120,7 +120,7 @@
"y" : 20,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -130,7 +130,7 @@
"y" : 100,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -140,7 +140,7 @@
"y" : 180,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -150,7 +150,7 @@
"y" : 20,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -160,7 +160,7 @@
"y" : 100,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
{
@ -170,7 +170,7 @@
"y" : 180,
"reloadTime" : 10,
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE",
"flags" : "EF_TAKES_DAMAGE+EF_SECONDARY_TARGET",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
}
]

View File

@ -255,6 +255,16 @@ static void huntAndAttackTarget(void)
nextAction();
}
static int attackSecondaryTarget(Entity *e)
{
if (self->target->aiFlags & AIF_AVOIDS_COMBAT || self->target->flags & EF_SECONDARY_TARGET)
{
return rand() % 4 == 0;
}
return 1;
}
static void findTarget(void)
{
int i;
@ -275,7 +285,7 @@ static void findTarget(void)
if (dist < closest)
{
if (!self->target || ((self->target->aiFlags & AIF_AVOIDS_COMBAT) == 0) || ((self->target->aiFlags & AIF_AVOIDS_COMBAT) && rand() % 10) == 0)
if (!self->target || attackSecondaryTarget(e))
{
self->target = e;
closest = dist;

View File

@ -81,6 +81,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EF_NO_EPIC (2 << 9)
#define EF_STATIC (2 << 10)
#define EF_TAKES_DAMAGE (2 << 11)
#define EF_SECONDARY_TARGET (2 << 12)
#define AIF_NONE 0
#define AIF_FOLLOWS_PLAYER (2 << 0)

View File

@ -45,6 +45,7 @@ void initLookups(void)
addLookup("EF_NO_EPIC", EF_NO_EPIC);
addLookup("EF_STATIC", EF_STATIC);
addLookup("EF_TAKES_DAMAGE", EF_TAKES_DAMAGE);
addLookup("EF_SECONDARY_TARGET", EF_SECONDARY_TARGET);
addLookup("AIF_NONE", AIF_NONE);
addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER);