/** * @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) { 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, nullptr)) { int counter; for (counter = 0; counter < MAX_POS_LOOP; counter++) { if (!CP_GetRandomPosOnGeoscapeWithParameters(mission->pos, mission->mapDef->terrains, mission->mapDef->cultures, mission->mapDef->populations, nullptr)) continue; if (GEO_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; } 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 Terror attack mission, and go to Terror attack mission pos. * @note Terror attack mission -- Stage 1 * @note Terror missions can only take place in city: pick one in ccs.cities. */ static void CP_TerrorMissionGo (mission_t *mission) { int counter; mission->stage = STAGE_MISSION_GOTO; /* Choose a map */ for (counter = 0; counter < MAX_POS_LOOP; counter++) { city_t *city = CP_ChooseCity(); if (!city) continue; if (GEO_PositionCloseToBase(city->pos)) continue; if (!CP_ChooseMap(mission, city->pos)) continue; if (CP_TerrorInCity(city)) continue; Vector2Copy(city->pos, mission->pos); mission->data.city = city; mission->posAssigned = true; break; } if (counter >= MAX_POS_LOOP) { Com_DPrintf(DEBUG_CLIENT, "CP_TerrorMissionGo: Could not set position.\n"); CP_MissionRemove(mission); return; } 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) { mission->stage = STAGE_MISSION_GOTO; /* Choose a map */ if (CP_ChooseMap(mission, nullptr)) { int counter; linkedList_t* nationList = nullptr; const bool 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 : nullptr)) continue; if (GEO_PositionCloseToBase(mission->pos)) continue; mission->posAssigned = true; break; } if (counter >= MAX_POS_LOOP) { Com_Printf("CP_HarvestMissionGo: Error, could not set position.\n"); CP_MissionRemove(mission); return; } cgi->LIST_Delete(&nationList); } else { Com_Printf("CP_HarvestMissionGo: No map found, remove mission.\n"); CP_MissionRemove(mission); return; } if (mission->ufo) { CP_MissionDisableTimeLimit(mission); UFO_SendToDestination(mission->ufo, mission->pos); } else { /* Go to next stage on next frame */ mission->finalDate = ccs.date; } }