/** * @brief Set ground mission, and go to ground mission pos. * @note Recon mission -- Stage 1 * @note ground mission can be spawned without UFO * @sa CP_ReconMissionSelect */ void CP_ReconMissionGroundGo (mission_t *mission) { const nation_t *nation; mission->stage = STAGE_MISSION_GOTO; /* maybe the UFO just finished a ground mission and starts a new one? */ if (mission->ufo) { CP_MissionRemoveFromGeoscape(mission); mission->ufo->landed = false; } /* Choose a map */ if (CP_ChooseMap(mission, NULL)) { int counter; for (counter = 0; counter < MAX_POS_LOOP; counter++) { if (!CP_GetRandomPosOnGeoscapeWithParameters(mission->pos, mission->mapDef->terrains, mission->mapDef->cultures, mission->mapDef->populations, NULL)) continue; if (MAP_PositionCloseToBase(mission->pos)) continue; mission->posAssigned = true; break; } if (counter >= MAX_POS_LOOP) { Com_Printf("CP_ReconMissionGroundGo: Error, could not set position.\n"); CP_MissionRemove(mission); return; } } else { Com_Printf("CP_ReconMissionGroundGo: No map found, remove mission.\n"); CP_MissionRemove(mission); return; } nation = MAP_GetNation(mission->pos); if (nation) { Com_sprintf(mission->location, sizeof(mission->location), "%s", _(nation->name)); } else { Com_sprintf(mission->location, sizeof(mission->location), "%s", _("No nation")); } if (mission->ufo) { CP_MissionDisableTimeLimit(mission); UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ mission->finalDate = ccs.date; } }
/** * @brief Set Harvest mission, and go to mission pos. * @note Harvesting attack mission -- Stage 1 * @todo Remove me when CP_XVIMissionGo will be implemented * This function should take a location close to an XVI infection point * see gameplay proposal on wiki */ void CP_HarvestMissionGo (mission_t *mission) { const nation_t *nation; mission->stage = STAGE_MISSION_GOTO; /* Choose a map */ if (CP_ChooseMap(mission, NULL)) { int counter; linkedList_t *nationList = NULL; const qboolean nationTest = CP_ChooseNation(mission, &nationList); for (counter = 0; counter < MAX_POS_LOOP; counter++) { if (!CP_GetRandomPosOnGeoscapeWithParameters(mission->pos, mission->mapDef->terrains, mission->mapDef->cultures, mission->mapDef->populations, nationTest ? nationList : NULL)) continue; if (MAP_PositionCloseToBase(mission->pos)) continue; mission->posAssigned = qtrue; break; } if (counter >= MAX_POS_LOOP) { Com_Printf("CP_HarvestMissionGo: Error, could not set position.\n"); CP_MissionRemove(mission); return; } LIST_Delete(&nationList); } else { Com_Printf("CP_HarvestMissionGo: No map found, remove mission.\n"); CP_MissionRemove(mission); return; } nation = MAP_GetNation(mission->pos); if (nation) { Com_sprintf(mission->location, sizeof(mission->location), "%s", _(nation->name)); } else { Com_sprintf(mission->location, sizeof(mission->location), "%s", _("No nation")); } if (mission->ufo) { CP_MissionDisableTimeLimit(mission); UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ mission->finalDate = ccs.date; } }
static void SCP_ParseMission (const char *name, const char **text) { const char *errhead = "SCP_ParseMission: unexpected end of file (mission "; staticMission_t *ms; const value_t *vp; const char *token; int i; size_t writtenBytes; token = Com_Parse(text); if (token[0] == '\0' || text[0] == '\0') { Com_Printf("SCP_ParseMission: mission def \"%s\" without name ignored\n", name); return; } /* search for missions with same name */ for (i = 0; i < scd->numMissions; i++) if (Q_streq(token, scd->missions[i].id)) break; if (i < scd->numMissions) { Com_Printf("SCP_ParseMission: mission def \"%s\" with same name found, second ignored\n", token); return; } if (scd->numMissions >= MAX_STATIC_MISSIONS) { Com_Printf("SCP_ParseMission: Too many missions, ignore '%s'\n", token); return; } /* initialize the menu */ ms = &scd->missions[scd->numMissions]; OBJZERO(*ms); Q_strncpyz(ms->id, token, sizeof(ms->id)); /* get it's body */ token = Com_Parse(text); if (text[0] == '\0' || !Q_streq(token, "{")) { Com_Printf("SCP_ParseMission: mission def \"%s\" without body ignored\n", ms->id); return; } do { token = Com_EParse(text, errhead, ms->id); if (text[0] == '\0') break; if (token[0] == '}') break; for (vp = mission_vals; vp->string; vp++) if (Q_streq(token, vp->string)) { /* found a definition */ token = Com_EParse(text, errhead, ms->id); if (text[0] == '\0') return; if (vp->ofs) { Com_ParseValue(ms, token, vp->type, vp->ofs, vp->size, &writtenBytes); } else { Com_Printf("SCP_ParseMission: unknown token '%s'\n", token); } break; } if (!vp->string) { if (Q_streq(token, "city")) { const city_t *city; token = Com_EParse(text, errhead, ms->id); if (text[0] == '\0') return; city = CP_GetCity(token); if (city == NULL) Com_Printf("SCP_ParseMission: unknown city \"%s\" ignored (mission %s)\n", token, ms->id); else Vector2Copy(city->pos, ms->pos); } else { Com_Printf("SCP_ParseMission: unknown token \"%s\" ignored (mission %s)\n", token, ms->id); } } } while (*text); mapDef_t *mapDef = cgi->Com_GetMapDefinitionByID(ms->id); if (mapDef == NULL) { Com_Printf("SCP_ParseMission: invalid mapdef for '%s'\n", ms->id); return; } if (Vector2Empty(ms->pos)) { if (!CP_GetRandomPosOnGeoscapeWithParameters(ms->pos, mapDef->terrains, mapDef->cultures, mapDef->populations, NULL)) { Com_Printf("SCP_ParseMission: could not find a valid position for '%s'\n", ms->id); return; } } scd->numMissions++; }
static void SCP_ParseStageSet (const char *name, const char **text) { const char *errhead = "SCP_ParseStageSet: unexpected end of file (stageset "; stageSet_t *sp; const value_t *vp; char missionstr[256]; const char *token, *misp; int j; size_t writtenBytes; /* initialize the stage */ sp = &scd->stageSets[scd->numStageSets++]; OBJZERO(*sp); Q_strncpyz(sp->name, name, sizeof(sp->name)); /* get it's body */ token = Com_Parse(text); if (text[0] == '\0' || !Q_streq(token, "{")) { Com_Printf("SCP_ParseStageSet: stageset def \"%s\" without body ignored\n", sp->name); scd->numStageSets--; return; } do { token = Com_EParse(text, errhead, sp->name); if (!*text) break; if (token[0] == '}') break; /* check for some standard values */ for (vp = stageset_vals; vp->string; vp++) if (Q_streq(token, vp->string)) { /* found a definition */ token = Com_EParse(text, errhead, sp->name); if (!*text) return; Com_ParseValue(sp, token, vp->type, vp->ofs, vp->size, &writtenBytes); break; } if (vp->string) continue; /* get mission set */ if (Q_streq(token, "missions")) { token = Com_EParse(text, errhead, sp->name); if (!*text) return; Q_strncpyz(missionstr, token, sizeof(missionstr)); misp = missionstr; /* add mission options */ sp->numMissions = 0; do { token = Com_Parse(&misp); if (!misp) break; for (j = 0; j < scd->numMissions; j++) { if (Q_streq(token, scd->missions[j].id)) { sp->missions[sp->numMissions++] = j; break; } } if (j == scd->numMissions) { const mapDef_t *mapDef = cgi->Com_GetMapDefinitionByID(token); if (mapDef != NULL) { if (j < MAX_STATIC_MISSIONS - 1) { /* we don't need and mission definition in the scripts if we just would like to link a mapdef */ staticMission_t *mis = &scd->missions[j]; OBJZERO(*mis); Q_strncpyz(mis->id, token, sizeof(mis->id)); if (!CP_GetRandomPosOnGeoscapeWithParameters(mis->pos, mapDef->terrains, mapDef->cultures, mapDef->populations, NULL)) { Com_Printf("SCP_ParseMission: could not find a valid position for '%s'\n", mis->id); continue; } sp->missions[sp->numMissions++] = scd->numMissions++; } } else { Com_Printf("SCP_ParseStageSet: unknown mission \"%s\" ignored (stageset %s)\n", token, sp->name); } } } while (misp && sp->numMissions < MAX_SETMISSIONS); continue; } Com_Printf("SCP_ParseStageSet: unknown token \"%s\" ignored (stageset %s)\n", token, sp->name); } while (*text); }