cp_mission_xvi.c

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018 See the GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00024 */
00025 
00026 #include "../../cl_shared.h"
00027 #include "../cp_campaign.h"
00028 #include "../cp_missions.h"
00029 #include "../cp_time.h"
00030 #include "../cp_alien_interest.h"
00031 #include "../cp_ufo.h"
00032 
00037 void CP_XVIMissionIsSuccess (mission_t *mission)
00038 {
00039     CL_ChangeIndividualInterest(-0.3f, INTERESTCATEGORY_XVI);
00040     CL_ChangeIndividualInterest(0.1f, INTERESTCATEGORY_HARVEST);
00041     CL_ChangeIndividualInterest(0.05f, INTERESTCATEGORY_BUILDING);
00042 
00043     CP_MissionRemove(mission);
00044 }
00045 
00050 void CP_XVIMissionIsFailure (mission_t *mission)
00051 {
00052     CL_ChangeIndividualInterest(0.1f, INTERESTCATEGORY_INTERCEPT);
00053     CL_ChangeIndividualInterest(0.05f, INTERESTCATEGORY_TERROR_ATTACK);
00054     CL_ChangeIndividualInterest(0.01f, INTERESTCATEGORY_BASE_ATTACK);
00055 
00056     CP_MissionRemove(mission);
00057 }
00058 
00063 static void CP_XVIMissionStart (mission_t *mission)
00064 {
00065     const date_t minMissionDelay = {2, 0};
00066     const date_t missionDelay = {3, 0};
00067 
00068     mission->stage = STAGE_SPREAD_XVI;
00069 
00070     /* mission appear on geoscape, player can go there */
00071     CP_MissionAddToGeoscape(mission, qfalse);
00072 
00073     if (mission->ufo) {
00074         mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay));
00075         /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/
00076         CP_UFORemoveFromGeoscape(mission, qfalse);
00077     } else {
00078         /* Go to next stage on next frame */
00079         mission->finalDate = ccs.date;
00080     }
00081 }
00082 
00090 int CP_XVIMissionAvailableUFOs (const mission_t const *mission, ufoType_t *ufoTypes)
00091 {
00092     int num = 0;
00093 
00094     ufoTypes[num++] = UFO_SCOUT;
00095     ufoTypes[num++] = UFO_FIGHTER;
00096     if (UFO_ShouldAppearOnGeoscape(UFO_CORRUPTER))
00097         ufoTypes[num++] = UFO_CORRUPTER;
00098 
00099     return num;
00100 }
00101 
00106 void CP_XVIMissionNextStage (mission_t *mission)
00107 {
00108     switch (mission->stage) {
00109     case STAGE_NOT_ACTIVE:
00110         /* Create XVI Spreading mission */
00111         CP_MissionBegin(mission);
00112         break;
00113     case STAGE_COME_FROM_ORBIT:
00114         /* Go to mission */
00115         CP_HarvestMissionGo(mission);
00116         break;
00117     case STAGE_MISSION_GOTO:
00118         /* just arrived on a new XVI Spreading mission: start it */
00119         CP_XVIMissionStart(mission);
00120         break;
00121     case STAGE_SPREAD_XVI:
00122         /* Leave earth */
00123         CP_ReconMissionLeave(mission);
00124         break;
00125     case STAGE_RETURN_TO_ORBIT:
00126         /* mission is over, remove mission */
00127         CP_XVIMissionIsSuccess(mission);
00128         break;
00129     default:
00130         Com_Printf("CP_XVIMissionNextStage: Unknown stage: %i, removing mission.\n", mission->stage);
00131         CP_MissionRemove(mission);
00132         break;
00133     }
00134 }

Generated by  doxygen 1.6.2