Challenge #8, defend extraction point. Added flag to allow AI to sometimes ignore extraction point.
This commit is contained in:
parent
e28390a496
commit
922b39c0ea
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"name" : "Defend Extraction Point",
|
||||||
|
"description" : "Defend Extraction Point",
|
||||||
|
"background" : "AUTO",
|
||||||
|
"planet" : "AUTO",
|
||||||
|
"music" : "AUTO",
|
||||||
|
"player" : {
|
||||||
|
"type" : "Leopard",
|
||||||
|
"side" : "SIDE_ALLIES",
|
||||||
|
"pilot" : "-",
|
||||||
|
"squadron" : "-",
|
||||||
|
"x" : 25,
|
||||||
|
"y" : 25
|
||||||
|
},
|
||||||
|
"challenge" : {
|
||||||
|
"timeLimit" : 90,
|
||||||
|
"killLimit" : 12,
|
||||||
|
"escapeLimit" : 12,
|
||||||
|
"challenges" : [
|
||||||
|
{
|
||||||
|
"type" : "CHALLENGE_PLAYER_KILLS",
|
||||||
|
"value" : 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type" : "CHALLENGE_PLAYER_KILLS",
|
||||||
|
"value" : 9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type" : "CHALLENGE_PLAYER_KILLS",
|
||||||
|
"value" : 12
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fighters" : [
|
||||||
|
{
|
||||||
|
"groupName" : "Dart",
|
||||||
|
"types" : "Dart",
|
||||||
|
"x" : 25,
|
||||||
|
"y" : 28,
|
||||||
|
"side" : "SIDE_REBEL",
|
||||||
|
"scatter" : 5000,
|
||||||
|
"number" : 12,
|
||||||
|
"flags" : "+EF_RETREATING",
|
||||||
|
"aiFlags" : "+AIF_GOAL_EXTRACTION+AIF_UNLIMITED_RANGE+AIF_DEFENSIVE+AIF_COVERS_RETREAT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entities" : [
|
||||||
|
{
|
||||||
|
"type" : "ET_EXTRACTION_POINT",
|
||||||
|
"x" : 25.1,
|
||||||
|
"y" : 25.1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -58,14 +58,18 @@ void doAI(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 25 && nearEnemies())
|
if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 10 && nearEnemies())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((self->aiFlags & AIF_GOAL_EXTRACTION) && nearExtractionPoint())
|
if ((self->aiFlags & AIF_GOAL_EXTRACTION) && nearExtractionPoint())
|
||||||
{
|
{
|
||||||
return;
|
/* near extraction point, but you might decide to continue to fight, anyway */
|
||||||
|
if ((self->aiFlags & AIF_COVERS_RETREAT) && rand() % 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((self->aiFlags & AIF_COLLECTS_ITEMS) && nearItems())
|
if ((self->aiFlags & AIF_COLLECTS_ITEMS) && nearItems())
|
||||||
|
@ -544,7 +548,7 @@ static int nearEnemies(void)
|
||||||
int i, numEnemies;
|
int i, numEnemies;
|
||||||
Entity *e, **candidates;
|
Entity *e, **candidates;
|
||||||
|
|
||||||
candidates = getAllEntsWithin(self->x - (self->w / 2) - 500, self->y - (self->h / 2) - 500, 1000, 1000, self);
|
candidates = getAllEntsWithin(self->x - 500, self->y - 500, 1000, 1000, self);
|
||||||
|
|
||||||
self->target = NULL;
|
self->target = NULL;
|
||||||
self->targetLocation.x = self->targetLocation.y = 0;
|
self->targetLocation.x = self->targetLocation.y = 0;
|
||||||
|
@ -555,9 +559,12 @@ static int nearEnemies(void)
|
||||||
{
|
{
|
||||||
if ((e->flags & EF_TAKES_DAMAGE) && e->side != self->side && !(e->flags & EF_DISABLED))
|
if ((e->flags & EF_TAKES_DAMAGE) && e->side != self->side && !(e->flags & EF_DISABLED))
|
||||||
{
|
{
|
||||||
self->targetLocation.x += e->x;
|
if (getDistance(e->x, e->y, self->x, self->y) < 1000)
|
||||||
self->targetLocation.y += e->y;
|
{
|
||||||
numEnemies++;
|
self->targetLocation.x += e->x;
|
||||||
|
self->targetLocation.y += e->y;
|
||||||
|
numEnemies++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,6 +579,7 @@ static int nearEnemies(void)
|
||||||
|
|
||||||
self->action = fleeEnemies;
|
self->action = fleeEnemies;
|
||||||
self->aiActionTime = FPS * 2;
|
self->aiActionTime = FPS * 2;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,11 @@ static int challengeFinished(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.currentMission->challengeData.escapeLimit > 0 && (battle.stats[STAT_ENEMIES_KILLED_PLAYER] + battle.stats[STAT_ENEMIES_ESCAPED]) >= game.currentMission->challengeData.escapeLimit)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (game.currentMission->challengeData.waypointLimit > 0 && battle.stats[STAT_WAYPOINTS_VISITED] >= game.currentMission->challengeData.waypointLimit)
|
if (game.currentMission->challengeData.waypointLimit > 0 && battle.stats[STAT_WAYPOINTS_VISITED] >= game.currentMission->challengeData.waypointLimit)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -111,6 +111,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define AIF_MOVES_TO_LEADER (2 << 12)
|
#define AIF_MOVES_TO_LEADER (2 << 12)
|
||||||
#define AIF_EVADE (2 << 13)
|
#define AIF_EVADE (2 << 13)
|
||||||
#define AIF_WANDERS (2 << 14)
|
#define AIF_WANDERS (2 << 14)
|
||||||
|
#define AIF_COVERS_RETREAT (2 << 15)
|
||||||
|
|
||||||
/* player abilities */
|
/* player abilities */
|
||||||
#define BOOST_RECHARGE_TIME (FPS * 7)
|
#define BOOST_RECHARGE_TIME (FPS * 7)
|
||||||
|
|
|
@ -79,6 +79,7 @@ Mission *loadMissionMeta(char *filename)
|
||||||
|
|
||||||
mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0) * FPS;
|
mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0) * FPS;
|
||||||
mission->challengeData.killLimit = getJSONValue(node, "killLimit", 0);
|
mission->challengeData.killLimit = getJSONValue(node, "killLimit", 0);
|
||||||
|
mission->challengeData.escapeLimit = getJSONValue(node, "escapeLimit", 0);
|
||||||
mission->challengeData.waypointLimit = getJSONValue(node, "waypointLimit", 0);
|
mission->challengeData.waypointLimit = getJSONValue(node, "waypointLimit", 0);
|
||||||
mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0);
|
mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0);
|
||||||
mission->challengeData.noECM = getJSONValue(node, "noECM", 0);
|
mission->challengeData.noECM = getJSONValue(node, "noECM", 0);
|
||||||
|
|
|
@ -43,6 +43,7 @@ typedef struct Trophy Trophy;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int debug;
|
int debug;
|
||||||
int takeScreenshots;
|
int takeScreenshots;
|
||||||
|
char *screenshotFolder;
|
||||||
int noAIWeapons;
|
int noAIWeapons;
|
||||||
int showFPS;
|
int showFPS;
|
||||||
int playerImmortal;
|
int playerImmortal;
|
||||||
|
@ -247,6 +248,7 @@ typedef struct {
|
||||||
int killLimit;
|
int killLimit;
|
||||||
int lossLimit;
|
int lossLimit;
|
||||||
int itemLimit;
|
int itemLimit;
|
||||||
|
int escapeLimit;
|
||||||
int waypointLimit;
|
int waypointLimit;
|
||||||
int noMissiles;
|
int noMissiles;
|
||||||
int noBoost;
|
int noBoost;
|
||||||
|
|
|
@ -76,6 +76,7 @@ void initLookups(void)
|
||||||
addLookup("AIF_LONG_RANGE_FIRE", AIF_LONG_RANGE_FIRE);
|
addLookup("AIF_LONG_RANGE_FIRE", AIF_LONG_RANGE_FIRE);
|
||||||
addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER);
|
addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER);
|
||||||
addLookup("AIF_WANDERS", AIF_WANDERS);
|
addLookup("AIF_WANDERS", AIF_WANDERS);
|
||||||
|
addLookup("AIF_COVERS_RETREAT", AIF_COVERS_RETREAT);
|
||||||
|
|
||||||
addLookup("DT_ANY", DT_ANY);
|
addLookup("DT_ANY", DT_ANY);
|
||||||
addLookup("DT_NO_SPIN", DT_NO_SPIN);
|
addLookup("DT_NO_SPIN", DT_NO_SPIN);
|
||||||
|
|
Loading…
Reference in New Issue