diff --git a/data/challenges/08.json b/data/challenges/08.json new file mode 100644 index 0000000..a0a4eb5 --- /dev/null +++ b/data/challenges/08.json @@ -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 + } + ] +} diff --git a/src/battle/ai.c b/src/battle/ai.c index 50247b0..7d37d4e 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -58,14 +58,18 @@ void doAI(void) return; } - if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 25 && nearEnemies()) + if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 10 && nearEnemies()) { return; } 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()) @@ -544,7 +548,7 @@ static int nearEnemies(void) int i, numEnemies; 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->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)) { - self->targetLocation.x += e->x; - self->targetLocation.y += e->y; - numEnemies++; + if (getDistance(e->x, e->y, self->x, self->y) < 1000) + { + self->targetLocation.x += e->x; + self->targetLocation.y += e->y; + numEnemies++; + } } } @@ -572,6 +579,7 @@ static int nearEnemies(void) self->action = fleeEnemies; self->aiActionTime = FPS * 2; + return 1; } diff --git a/src/challenges/challenges.c b/src/challenges/challenges.c index 7dcd0fb..6c4063a 100644 --- a/src/challenges/challenges.c +++ b/src/challenges/challenges.c @@ -107,6 +107,11 @@ static int challengeFinished(void) 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) { return 1; diff --git a/src/defs.h b/src/defs.h index 6bafa13..c80f810 100644 --- a/src/defs.h +++ b/src/defs.h @@ -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_EVADE (2 << 13) #define AIF_WANDERS (2 << 14) +#define AIF_COVERS_RETREAT (2 << 15) /* player abilities */ #define BOOST_RECHARGE_TIME (FPS * 7) diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 58327ea..1a9502e 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -79,6 +79,7 @@ Mission *loadMissionMeta(char *filename) mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0) * FPS; mission->challengeData.killLimit = getJSONValue(node, "killLimit", 0); + mission->challengeData.escapeLimit = getJSONValue(node, "escapeLimit", 0); mission->challengeData.waypointLimit = getJSONValue(node, "waypointLimit", 0); mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0); mission->challengeData.noECM = getJSONValue(node, "noECM", 0); diff --git a/src/structs.h b/src/structs.h index cc6dff3..c7dd012 100644 --- a/src/structs.h +++ b/src/structs.h @@ -43,6 +43,7 @@ typedef struct Trophy Trophy; typedef struct { int debug; int takeScreenshots; + char *screenshotFolder; int noAIWeapons; int showFPS; int playerImmortal; @@ -247,6 +248,7 @@ typedef struct { int killLimit; int lossLimit; int itemLimit; + int escapeLimit; int waypointLimit; int noMissiles; int noBoost; diff --git a/src/system/lookup.c b/src/system/lookup.c index f499d10..4a74bf3 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -76,6 +76,7 @@ void initLookups(void) addLookup("AIF_LONG_RANGE_FIRE", AIF_LONG_RANGE_FIRE); addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER); addLookup("AIF_WANDERS", AIF_WANDERS); + addLookup("AIF_COVERS_RETREAT", AIF_COVERS_RETREAT); addLookup("DT_ANY", DT_ANY); addLookup("DT_NO_SPIN", DT_NO_SPIN);