UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_mission_ufocarrier.cpp
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#include "../../../cl_shared.h"
28#include "../cp_campaign.h"
29#include "../cp_geoscape.h"
30#include "../cp_ufo.h"
31#include "../cp_missions.h"
32#include "../cp_time.h"
33#include "../cp_xvi.h"
36
38{
39 MIS_Foreach(mission) {
40 if (mission->category == INTERESTCATEGORY_UFOCARRIER)
41 return mission;
42 }
43
44 return nullptr;
45}
46
51{
52 mission->idx = ++ccs.campaignStats.missions;
53 mission->finalDate = ccs.date;
54 mission->stage = STAGE_RECON_AIR;
55}
56
58{
59 /* delay the next update for some time */
60 const DateTime delay(2, 0);
61 mission->finalDate = ccs.date + delay;
62
64 cgi->UI_PopupButton(_("UFO-Carrier"), _("The Carrier UFO is in range. Should we launch the payload?"),
65 "ui_pop;", _("Wait"), _("Don't attack the UFO-Carrier yet"),
66 "cp_attack_ufocarrier;ui_pop;", _("Launch"), _("Attack the UFO-Carrier now"),
67 nullptr, nullptr, nullptr);
68 }
69}
70
76{
77 switch (mission->stage) {
80 break;
81 default:
83 break;
84 }
85}
86
91{
92 /* only one carrier missions is allowed */
93 if (CP_GetCarrierMission() != nullptr)
94 return;
95
97 if (!installationTemplate)
98 return;
99
100 if (cgi->Cmd_Argc() == 3) {
101 const vec2_t pos = Vector2FromInt(atof(cgi->Cmd_Argv(1)), atof(cgi->Cmd_Argv(2)));
102 if (!MapIsWater(GEO_GetColor(pos, MAPTYPE_TERRAIN, nullptr))) {
103 INS_Build(installationTemplate, pos, _(installationTemplate->name));
105 CL_EventAddMail("ufocarrier");
106 }
107 }
108
110}
111
117{
118 mission_t* mission = CP_GetCarrierMission();
119 if (mission == nullptr)
120 return;
121
123 return;
124
125#if 1
127 cgi->UI_RegisterText(TEXT_STANDARD, "*msgid:campaignwin");
128 CP_EndCampaign(true);
129#else
130 /* check max amount - we can't win if we can't add the ufo */
131 if (ccs.numUFOs >= MAX_UFOONGEOSCAPE)
132 return;
133
134 const aircraft_t* ufoTemplate = UFO_GetTemplate(UFO_CARRIER);
135 aircraft_t* ufo = UFO_CreateFromTemplate(ufoTemplate);
136 if (ufo == nullptr) {
137 cgi->Com_Error(ERR_DROP, "Could not add UFO-Carrier to geoscape");
138 return;
139 }
140 ufo->mission = mission;
141 mission->ufo = ufo;
142 CP_GetRandomPosOnGeoscape(ufo->pos, true);
144 if (mission->mapDef != nullptr) {
145 cgi->Com_Printf("spawned mapdef: %s\n", mission->mapDef->id);
146 }
147#endif
148}
Share stuff between the different cgame implementations.
#define _(String)
Definition cl_shared.h:44
Class describing a point of time.
Definition DateTime.h:31
#define ERR_DROP
Definition common.h:211
Alien interest header.
@ INTERESTCATEGORY_UFOCARRIER
void CP_EndCampaign(bool won)
Function to handle the campaign end.
ccs_t ccs
Header file for single player campaign control.
const cgame_import_t * cgi
@ MAPTYPE_TERRAIN
Definition cp_campaign.h:93
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame.
Definition cp_event.cpp:507
const byte * GEO_GetColor(const vec2_t pos, mapType_t type, bool *coast)
Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given p...
void GEO_CenterPosition(const vec2_t pos)
Start to rotate or shift the globe to the given position.
void CP_GetRandomPosOnGeoscape(vec2_t pos, bool noWater)
Determines a random position on geoscape.
Header for Geoscape management.
#define MapIsWater(color)
Definition cp_geoscape.h:32
installation_t * INS_Build(const installationTemplate_t *installationTemplate, const vec2_t pos, const char *name)
Build a new installation.
const installationTemplate_t * INS_GetInstallationTemplateByType(installationType_t type)
Returns the installation Template for a given installation type.
bool INS_HasType(installationType_t type, installationStatus_t status)
Checks whether the given installation type is available.
@ INSTALLATION_ORBIT
void CP_SpawnUFOCarrier_f(void)
Spawns a UFO-Carrier mission.
void CP_UFOCarrierNextStage(mission_t *mission)
Determine what action should be performed when a UFOCarriering mission stage ends.
void CP_AttackUFOCarrier_f(void)
Decide whether you hit and destroyed the carrier and spawns a new carrier crash site mission.
static mission_t * CP_GetCarrierMission(void)
static void CP_UFOCarrierMissionStart(mission_t *mission)
Start UFO-Carrier mission.
static void CP_UFOCarrierMissionUpdate(mission_t *mission)
Campaign mission headers.
mission_t * CP_CreateNewMission(interestCategory_t category, bool beginNow)
Create a new mission of given category.
void CP_SpawnCrashSiteMission(aircraft_t *ufo)
Spawn a new crash site after a UFO has been destroyed.
Campaign missions headers.
#define MIS_Foreach(var)
iterates through missions
@ STAGE_NOT_ACTIVE
Definition cp_missions.h:35
@ STAGE_RECON_AIR
Definition cp_missions.h:38
#define MAX_UFOONGEOSCAPE
Definition cp_radar.h:27
Campaign geoscape time header.
aircraft_t * UFO_CreateFromTemplate(const aircraft_t *ufoTemplate)
Creates a new ufo on the geoscape from the given aircraft template.
Definition cp_ufo.cpp:741
const aircraft_t * UFO_GetTemplate(ufoType_t ufoType)
Get the template data for the given ufo type.
Definition cp_ufo.cpp:695
Campaign XVI header.
An aircraft with all it's data.
struct mission_s * mission
char * id
Definition q_shared.h:463
mission definition
Definition cp_missions.h:86
aircraft_t * ufo
mapDef_t * mapDef
Definition cp_missions.h:89
missionStage_t stage
Definition cp_missions.h:99
class DateTime finalDate
vec_t vec2_t[2]
Definition ufotypes.h:38
@ TEXT_STANDARD
Definition ui_dataids.h:30
#define Vector2FromInt(x, y)
Definition vector.h:40