UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_mission_xvi.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #include "../../../cl_shared.h"
27 #include "../cp_campaign.h"
28 #include "../cp_missions.h"
29 #include "../cp_time.h"
30 #include "../cp_alien_interest.h"
31 #include "../cp_ufo.h"
32 #include "cp_mission_recon.h"
33 #include "cp_mission_harvest.h"
34 #include "cp_mission_xvi.h"
35 
41 {
45 
46  CP_MissionRemove(mission);
47 }
48 
54 {
58 
59  CP_MissionRemove(mission);
60 }
61 
66 static void CP_XVIMissionStart (mission_t* mission)
67 {
68  const date_t minMissionDelay = {2, 0};
69  const date_t missionDelay = {3, 0};
70 
71  mission->stage = STAGE_SPREAD_XVI;
72 
73  if (mission->ufo) {
74  mission->finalDate = Date_Add(ccs.date, Date_Random(minMissionDelay, missionDelay));
75  /* ufo becomes invisible on geoscape, but don't remove it from ufo global array (may reappear)*/
76  CP_UFORemoveFromGeoscape(mission, false);
77  } else {
78  /* Go to next stage on next frame */
79  mission->finalDate = ccs.date;
80  }
81 
82  /* mission appear on geoscape, player can go there */
83  CP_MissionAddToGeoscape(mission, false);
84 }
85 
91 {
92  switch (mission->stage) {
93  case STAGE_NOT_ACTIVE:
94  /* Create XVI Spreading mission */
95  CP_MissionBegin(mission);
96  break;
98  /* Go to mission */
99  CP_HarvestMissionGo(mission);
100  break;
101  case STAGE_MISSION_GOTO:
102  /* just arrived on a new XVI Spreading mission: start it */
103  CP_XVIMissionStart(mission);
104  break;
105  case STAGE_SPREAD_XVI:
106  /* Leave earth */
107  CP_ReconMissionLeave(mission);
108  break;
110  /* mission is over, remove mission */
111  CP_XVIMissionIsSuccess(mission);
112  break;
113  default:
114  cgi->Com_Printf("CP_XVIMissionNextStage: Unknown stage: %i, removing mission.\n", mission->stage);
115  CP_MissionRemove(mission);
116  break;
117  }
118 }
Campaign mission headers.
date_t date
Definition: cp_campaign.h:245
void INT_ChangeIndividualInterest(float interestFactor, interestCategory_t category)
Change individual interest value.
void CP_ReconMissionLeave(mission_t *mission)
Recon mission ends: UFO leave earth.
mission definition
Definition: cp_missions.h:85
void CP_XVIMissionIsSuccess(mission_t *mission)
XVI Spreading mission is over and is a success: change interest values.
static void CP_XVIMissionStart(mission_t *mission)
Start XVI Spreading mission.
date_t finalDate
Definition: cp_missions.h:102
aircraft_t * ufo
Definition: cp_missions.h:105
void CP_XVIMissionNextStage(mission_t *mission)
Determine what action should be performed when a XVI Spreading mission stage ends.
void CP_HarvestMissionGo(mission_t *mission)
Set Harvest mission, and go to mission pos.
const cgame_import_t * cgi
bool CP_MissionBegin(mission_t *mission)
mission begins: UFO arrive on earth.
void CP_MissionRemove(mission_t *mission)
Removes a mission from mission global array.
void CP_MissionAddToGeoscape(mission_t *mission, bool force)
Add a mission to geoscape: make it visible and stop time.
ccs_t ccs
Definition: cp_campaign.cpp:62
Engine-side time information in the game.
Definition: common.h:290
date_t Date_Add(date_t a, const date_t &b)
Add two dates and return the result.
Definition: cp_time.cpp:272
Campaign mission header.
QGL_EXTERN GLfloat f
Definition: r_gl.h:114
Campaign mission headers.
void CP_UFORemoveFromGeoscape(mission_t *mission, bool destroyed)
Removes (temporarily or permanently) a UFO from geoscape: make it land and call notify functions...
date_t Date_Random(date_t minFrame, date_t maxFrame)
Return a random relative date which lies between a lower and upper limit.
Definition: cp_time.cpp:302
void CP_XVIMissionIsFailure(mission_t *mission)
XVI Spreading mission is over and is a failure: change interest values.
missionStage_t stage
Definition: cp_missions.h:98