Added AIF_MOVES_TO_PLAYER flag.

This commit is contained in:
Steve 2015-11-28 14:33:05 +00:00
parent 9de6d6c737
commit dec3538956
18 changed files with 37 additions and 29 deletions

View File

@ -7,6 +7,7 @@
"shieldRechargeRate" : 5, "shieldRechargeRate" : 5,
"textureName" : "gfx/fighters/ataf.png", "textureName" : "gfx/fighters/ataf.png",
"flags" : "EF_NO_EPIC", "flags" : "EF_NO_EPIC",
"aiFlags" : "AIF_MOVES_TO_PLAYER",
"guns" : [ "guns" : [
{ {
"type" : "BT_PLASMA", "type" : "BT_PLASMA",

View File

@ -7,5 +7,5 @@
"shieldRechargeRate" : 0, "shieldRechargeRate" : 0,
"textureName" : "gfx/craft/civilian01.png", "textureName" : "gfx/craft/civilian01.png",
"flags" : "EF_MISSION_TARGET+EF_RETREATING", "flags" : "EF_MISSION_TARGET+EF_RETREATING",
"aiFlags" : "AIF_GOAL_EXTRACTION+AIF_AVOIDS_COMBAT" "aiFlags" : "AIF_GOAL_EXTRACTION+AIF_AVOIDS_COMBAT+AIF_FOLLOWS_PLAYER"
} }

View File

@ -24,5 +24,6 @@
} }
], ],
"combinedGuns" : 1, "combinedGuns" : 1,
"missiles" : 3 "missiles" : 3,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -24,5 +24,5 @@
} }
], ],
"missiles" : 6, "missiles" : 6,
"aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE" "aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE+AIF_MOVES_TO_PLAYER"
} }

View File

@ -28,5 +28,6 @@
"y" : -12 "y" : -12
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -28,5 +28,6 @@
"y" : -12 "y" : -12
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -28,5 +28,6 @@
"y" : -12 "y" : -12
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -23,5 +23,6 @@
"y" : -16 "y" : -16
} }
], ],
"missiles" : 3 "missiles" : 3,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -18,5 +18,6 @@
"y" : -2 "y" : -2
} }
], ],
"missiles" : 3 "missiles" : 3,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -28,5 +28,6 @@
"y" : -12 "y" : -12
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -28,5 +28,6 @@
"y" : 0 "y" : 0
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -7,5 +7,5 @@
"shieldRechargeRate" : 60, "shieldRechargeRate" : 60,
"textureName" : "gfx/craft/shuttle.png", "textureName" : "gfx/craft/shuttle.png",
"flags" : "EF_COLLECTS_ITEMS", "flags" : "EF_COLLECTS_ITEMS",
"aiFlags" : "AIF_AVOIDS_COMBAT+AIF_COLLECTS_ITEMS+AIF_UNLIMITED_RANGE" "aiFlags" : "AIF_AVOIDS_COMBAT+AIF_COLLECTS_ITEMS+AIF_MOVES_TO_PLAYER"
} }

View File

@ -18,5 +18,6 @@
"y" : -12 "y" : -12
} }
], ],
"missiles" : 4 "missiles" : 4,
"aiFlags" : "AIF_MOVES_TO_PLAYER"
} }

View File

@ -14,5 +14,5 @@
} }
], ],
"flags" : "EF_HAS_ROPE", "flags" : "EF_HAS_ROPE",
"aiFlags" : "AIF_AVOIDS_COMBAT+AIF_TOWS" "aiFlags" : "AIF_AVOIDS_COMBAT+AIF_TOWS+AIF_MOVES_TO_PLAYER"
} }

View File

@ -87,7 +87,7 @@ void doAI(void)
return; return;
} }
if (self->aiFlags & AIF_FOLLOWS_PLAYER) if (self->aiFlags & (AIF_FOLLOWS_PLAYER|AIF_MOVES_TO_PLAYER))
{ {
lookForPlayer(); lookForPlayer();
return; return;
@ -114,7 +114,7 @@ static void doFighterAI(void)
if (self->target == NULL) if (self->target == NULL)
{ {
if (self->aiFlags & AIF_FOLLOWS_PLAYER && player != NULL) if (self->aiFlags & AIF_MOVES_TO_PLAYER && player != NULL)
{ {
moveToPlayer(); moveToPlayer();
} }
@ -627,7 +627,7 @@ static void moveToTowableCraft(void)
static void lookForPlayer(void) static void lookForPlayer(void)
{ {
long range = (self->aiFlags & AIF_UNLIMITED_RANGE) ? MAX_TARGET_RANGE : 1000; int range = (self->aiFlags & AIF_MOVES_TO_PLAYER) ? MAX_TARGET_RANGE : 2000;
if (player != NULL && getDistance(self->x, self->y, player->x, player->y) < range) if (player != NULL && getDistance(self->x, self->y, player->x, player->y) < range)
{ {

View File

@ -52,11 +52,6 @@ Entity *spawnFighter(char *name, int x, int y, int side)
{ {
case SIDE_ALLIES: case SIDE_ALLIES:
f->aiAggression = rand() % 3; f->aiAggression = rand() % 3;
f->aiFlags |= AIF_FOLLOWS_PLAYER;
if (!(f->aiFlags & AIF_AVOIDS_COMBAT))
{
f->aiFlags |= AIF_UNLIMITED_RANGE;
}
break; break;
case SIDE_PIRATE: case SIDE_PIRATE:
@ -557,6 +552,7 @@ void retreatAllies(void)
e->aiFlags |= AIF_UNLIMITED_RANGE; e->aiFlags |= AIF_UNLIMITED_RANGE;
e->aiFlags |= AIF_GOAL_EXTRACTION; e->aiFlags |= AIF_GOAL_EXTRACTION;
e->aiFlags &= ~AIF_FOLLOWS_PLAYER; e->aiFlags &= ~AIF_FOLLOWS_PLAYER;
e->aiFlags &= ~AIF_MOVES_TO_PLAYER;
} }
} }
} }

View File

@ -78,14 +78,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AIF_NONE 0 #define AIF_NONE 0
#define AIF_FOLLOWS_PLAYER (2 << 0) #define AIF_FOLLOWS_PLAYER (2 << 0)
#define AIF_UNLIMITED_RANGE (2 << 1) #define AIF_MOVES_TO_PLAYER (2 << 1)
#define AIF_COLLECTS_ITEMS (2 << 2) #define AIF_UNLIMITED_RANGE (2 << 2)
#define AIF_TOWS (2 << 3) #define AIF_COLLECTS_ITEMS (2 << 3)
#define AIF_RETREATS (2 << 4) #define AIF_TOWS (2 << 4)
#define AIF_GOAL_EXTRACTION (2 << 5) #define AIF_RETREATS (2 << 5)
#define AIF_AVOIDS_COMBAT (2 << 6) #define AIF_GOAL_EXTRACTION (2 << 6)
#define AIF_DEFENSIVE (2 << 7) #define AIF_AVOIDS_COMBAT (2 << 7)
#define AIF_MISSILE_BOAT (2 << 8) #define AIF_DEFENSIVE (2 << 8)
#define AIF_MISSILE_BOAT (2 << 9)
/* player abilities */ /* player abilities */
#define BOOST_RECHARGE_TIME (FPS * 7) #define BOOST_RECHARGE_TIME (FPS * 7)

View File

@ -44,6 +44,7 @@ void initLookups(void)
addLookup("EF_NO_EPIC", EF_NO_EPIC); addLookup("EF_NO_EPIC", EF_NO_EPIC);
addLookup("AIF_NONE", AIF_NONE); addLookup("AIF_NONE", AIF_NONE);
addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER);
addLookup("AIF_FOLLOWS_PLAYER", AIF_FOLLOWS_PLAYER); addLookup("AIF_FOLLOWS_PLAYER", AIF_FOLLOWS_PLAYER);
addLookup("AIF_UNLIMITED_RANGE", AIF_UNLIMITED_RANGE); addLookup("AIF_UNLIMITED_RANGE", AIF_UNLIMITED_RANGE);
addLookup("AIF_COLLECTS_ITEMS", AIF_COLLECTS_ITEMS); addLookup("AIF_COLLECTS_ITEMS", AIF_COLLECTS_ITEMS);