diff --git a/src/battle/entities.c b/src/battle/entities.c index b175082..6c349f4 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -276,6 +276,19 @@ void activateEntities(char *name) } } +void activateEntityGroup(char *groupName) +{ + Entity *e; + + for (e = battle.entityHead.next ; e != NULL ; e = e->next) + { + if (strcmp(e->groupName, groupName) == 0) + { + e->active = 1; + } + } +} + static void activateEpicFighters(int n, int side) { Entity *e; diff --git a/src/battle/triggers.c b/src/battle/triggers.c index fdaed63..a46763a 100644 --- a/src/battle/triggers.c +++ b/src/battle/triggers.c @@ -74,6 +74,10 @@ static void fireTrigger(Trigger *trigger) activateEntities(trigger->actionValue); break; + case TA_ACTIVE_ENTITY_GROUP: + activateEntityGroup(trigger->actionValue); + break; + case TA_ACTIVE_OBJECTIVE: activateObjective(atoi(trigger->actionValue)); break; diff --git a/src/battle/triggers.h b/src/battle/triggers.h index af86fc5..b25fbdb 100644 --- a/src/battle/triggers.h +++ b/src/battle/triggers.h @@ -28,6 +28,7 @@ extern void failMission(void); extern void addHudMessage(SDL_Color c, char *format, ...); extern void activateEntities(char *name); extern void activateObjective(int num); +extern void activateEntityGroup(char *groupName); extern Battle battle; extern Colors colors; diff --git a/src/defs.h b/src/defs.h index 87958b6..1e613ed 100644 --- a/src/defs.h +++ b/src/defs.h @@ -178,6 +178,7 @@ enum TA_COMPLETE_MISSION, TA_FAIL_MISSION, TA_ACTIVE_ENTITY, + TA_ACTIVE_ENTITY_GROUP, TA_ACTIVE_OBJECTIVE }; diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 00cecd1..f2609e6 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -115,6 +115,8 @@ void failMission(void) battle.status = MS_FAILED; battle.missionFinishedTimer = FPS; selectWidget("retry", "battleLost"); + + failIncompleteObjectives(); } } @@ -242,7 +244,7 @@ static void loadFighters(cJSON *node) static void loadFighterGroups(cJSON *node) { Entity *f; - char **types, *name, *type; + char **types, *name, *groupName, *type; int side, scatter, number, active; int i, numTypes; float x, y; @@ -256,6 +258,8 @@ static void loadFighterGroups(cJSON *node) while (node) { + groupName = NULL; + types = toFighterTypeArray(cJSON_GetObjectItem(node, "types")->valuestring, &numTypes); side = lookup(cJSON_GetObjectItem(node, "side")->valuestring); number = cJSON_GetObjectItem(node, "number")->valueint; @@ -263,6 +267,11 @@ static void loadFighterGroups(cJSON *node) x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH; y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT; + if (cJSON_GetObjectItem(node, "groupName")) + { + groupName = cJSON_GetObjectItem(node, "groupName")->valuestring; + } + if (cJSON_GetObjectItem(node, "scatter")) { scatter = cJSON_GetObjectItem(node, "scatter")->valueint; @@ -285,6 +294,11 @@ static void loadFighterGroups(cJSON *node) f->active = active; STRNCPY(f->name, name, MAX_NAME_LENGTH); + + if (groupName) + { + STRNCPY(f->groupName, groupName, MAX_NAME_LENGTH); + } } node = node->next; @@ -341,7 +355,7 @@ static void loadEntities(cJSON *node) static void loadEntityGroups(cJSON *node) { Entity *e; - char *name; + char *name, *groupName; int i, type, scatter, number; float x, y; @@ -358,12 +372,18 @@ static void loadEntityGroups(cJSON *node) x = cJSON_GetObjectItem(node, "x")->valuedouble * GRID_CELL_WIDTH; y = cJSON_GetObjectItem(node, "y")->valuedouble * GRID_CELL_HEIGHT; name = NULL; + groupName = NULL; if (cJSON_GetObjectItem(node, "name")) { name = cJSON_GetObjectItem(node, "name")->valuestring; } + if (cJSON_GetObjectItem(node, "groupName")) + { + groupName = cJSON_GetObjectItem(node, "groupName")->valuestring; + } + if (cJSON_GetObjectItem(node, "scatter")) { scatter = cJSON_GetObjectItem(node, "scatter")->valueint; @@ -383,6 +403,11 @@ static void loadEntityGroups(cJSON *node) STRNCPY(e->name, name, MAX_NAME_LENGTH); } + if (groupName) + { + STRNCPY(e->groupName, groupName, MAX_NAME_LENGTH); + } + e->id = battle.entId++; e->x = x; e->y = y; diff --git a/src/structs.h b/src/structs.h index 0c3e396..4d94d9e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -73,6 +73,7 @@ struct Entity { int type; char name[MAX_NAME_LENGTH]; char defName[MAX_NAME_LENGTH]; + char groupName[MAX_NAME_LENGTH]; int active; int id; int side; diff --git a/src/system/lookup.c b/src/system/lookup.c index 3053fd6..ccdc6af 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -110,6 +110,7 @@ void initLookups(void) addLookup("TA_FAIL_MISSION", TA_FAIL_MISSION); addLookup("TA_ACTIVE_ENTITY", TA_ACTIVE_ENTITY); addLookup("TA_ACTIVE_OBJECTIVE", TA_ACTIVE_OBJECTIVE); + addLookup("TA_ACTIVE_ENTITY_GROUP", TA_ACTIVE_ENTITY_GROUP); } static void addLookup(char *name, long value)