UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_campaign.h
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#pragma once
27
29
30class Employee;
31#define MAX_CAMPAIGNS 16
32
33#include "../../DateTime.h"
34#include "cp_cgame_callbacks.h"
35#include "cp_alien_interest.h"
36#include "cp_rank.h"
37#include "cp_save.h"
38#include "cp_parse.h"
39#include "cp_event.h"
40#include "cp_ufopedia.h"
41#include "cp_research.h"
42#include "cp_radar.h"
43#include "cp_aircraft.h"
44#include "cp_base.h"
45#include "cp_employee.h"
46#include "cp_transfer.h"
47#include "cp_nation.h"
48#include "cp_installation.h"
49#include "cp_produce.h"
50#include "cp_uforecovery.h"
51#include "cp_airfight.h"
52#include "cp_messageoptions.h"
53#include "cp_alienbase.h"
54#include "cp_market.h"
55#include "cp_statistics.h"
56#include "cp_component.h"
57
58/* Maximum alien groups per alien team category */
59#define MAX_ALIEN_GROUP_PER_CATEGORY 8
60/* Maximum alien team category defined in scripts */
61#define ALIENCATEGORY_MAX 64
62#define MAX_PROJECTILESONGEOSCAPE 32
63
67#define HOURS_PER_ONE_INTEREST 24
68
72#define INITIAL_OVERALL_INTEREST 20
73#define FINAL_OVERALL_INTEREST 400
74
78#define DELAY_BETWEEN_MISSION_SPAWNING 12
79
84#define EARLY_UFO_RUSH_INTEREST 50
85
89#define NON_OCCURRENCE_PROBABILITY 0.75
90
100
119
137
139typedef struct battleParam_s {
140 struct mission_s* mission;
142 char* param;
146 bool day;
147 const char* zoneType;
149 struct nation_s* nation;
152
162
212
213int CP_GetSalaryUpKeepBase(const salary_t* salary, const base_t* base);
214
221
223typedef void (*missionResultFunction_t) (const struct missionResults_s* results);
224
229typedef struct ccs_s {
233
235
237
242
247 bool startXVI;
248 float timer;
250
251 struct {
252 struct mission_s* selectedMission;
257 } geoscape;
258
259 /* == misc == */
263
264 /* how fast the game is running */
267
268 /* already paid in this month? */
269 bool paid;
270
271 /* == employees == */
272 /* A list of all phalanx employees (soldiers, scientists, workers, etc...) */
274
275 /* == technologies == */
276 /* A list of all research-topics resp. the research-tree. */
279
280 /* == bases == */
281 /* A list of _all_ bases ... even unbuilt ones. */
284
285 /* a list of all templates for building bases */
288
289 /* == aircraft == */
291
292 /* == Alien bases == */
294
295 /* == Nations == */
298
299 /* == Cities == */
302
303 /* Projectiles on geoscape (during fights) */
306
307 /* == Transfers == */
309
310 /* UFO components. */
313
314 /* == stored UFOs == */
316
317 /* Alien Team Package used during battle */
320
321 /* == ufopedia == */
322 /* A list of all UFOpaedia chapters. */
324 /* Total number of UFOpaedia chapters */
327
330
333
336
337 /* == buildings in bases == */
338 /* A list of all possible unique buildings. */
341 /* A list of the building-list per base. (new buildings in a base get copied from buildingTypes) */
343 /* Total number of buildings per base. */
345
346 /* == installations == */
347 /* A template for each possible installation with configurable values */
350
351 /* A list of _all_ installations */
353
354 /* UFOs on geoscape */
357
358 /* message categories */
361
362 /* entries for message categories */
365
366 /* == Ranks == */
367 /* Global list of all ranks defined in medals.ufo. */
369 /* The number of entries in the list above. */
371
372 /* cache for techdef technologies */
374
375 /* cache for item technologies */
377
380
383
386
389
391} ccs_t;
392
393typedef struct {
394 int x, y;
396
397extern ccs_t ccs;
398extern const int DETECTION_INTERVAL;
399extern cvar_t* cp_missiontest;
400
401#define MAX_CREDITS 10000000
402
403#include "../cgame.h"
404extern const cgame_import_t* cgi;
405
406/* Campaign functions */
407void CP_InitStartup(void);
408campaign_t* CP_GetCampaign(const char* name);
409void CP_CampaignInit(campaign_t* campaign, bool load);
410void CP_ParseCampaignData(void);
411void CP_ReadCampaignData(const campaign_t* campaign);
412bool CP_IsRunning(void);
413
414void CP_CampaignRun(campaign_t* campaign, float secondsSinceLastFrame);
415void CP_CheckLostCondition(const campaign_t* campaign);
416void CP_EndCampaign(bool won);
417
418void CP_Shutdown(void);
419void CP_ResetCampaignData(void);
420
421void CP_StartSelectedMission(void);
422
423/* Credits management */
424bool CP_CheckCredits (int costs);
425void CP_UpdateCredits(int credits);
426
427bool CP_OnGeoscape(void);
DateTime class definition.
Client game mode interface.
#define MAX_TEAMDEFS
Definition chr_shared.h:228
Class describing a point of time.
Definition DateTime.h:31
Header file for aircraft stuff.
#define MAX_AIRCRAFT
Definition cp_aircraft.h:31
Header file for airfights.
Alien interest header.
interestCategory_t
@ INTERESTCATEGORY_MAX
Header for base management related stuff.
#define MAX_BASETEMPLATES
Definition cp_base.h:33
#define MAX_BASES
Definition cp_base.h:32
#define MAX_BUILDINGS
Definition cp_base.h:34
memPool_t * cp_campaignPool
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
cvar_t * cp_missiontest
ccs_t ccs
const cgame_import_t * cgi
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
void CP_Shutdown(void)
Campaign closing actions.
bool CP_OnGeoscape(void)
Returns if we are currently on the Geoscape.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
#define MAX_PROJECTILESONGEOSCAPE
Definition cp_campaign.h:62
void CP_CampaignRun(campaign_t *campaign, float secondsSinceLastFrame)
Called every frame when we are in geoscape view.
#define MAX_ALIEN_GROUP_PER_CATEGORY
Definition cp_campaign.h:59
#define ALIENCATEGORY_MAX
Definition cp_campaign.h:61
int CP_GetSalaryUpKeepBase(const salary_t *salary, const base_t *base)
void CP_InitStartup(void)
void CP_CheckLostCondition(const campaign_t *campaign)
Checks whether the player has lost the campaign.
void CP_StartSelectedMission(void)
Starts a selected mission.
void CP_CampaignInit(campaign_t *campaign, bool load)
Called at new game and load game.
void CP_ParseCampaignData(void)
Read the data for campaigns.
Definition cp_parse.cpp:641
mapAction_t
@ MA_NONE
@ MA_NEWINSTALLATION
@ MA_NEWBASE
void(* missionResultFunction_t)(const struct missionResults_s *results)
void CP_EndCampaign(bool won)
Function to handle the campaign end.
#define MAX_CAMPAIGNS
Definition cp_campaign.h:31
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
mapType_t
Definition cp_campaign.h:92
@ MAPTYPE_POPULATION
Definition cp_campaign.h:95
@ MAPTYPE_NATIONS
Definition cp_campaign.h:96
@ MAPTYPE_CULTURE
Definition cp_campaign.h:94
@ MAPTYPE_TERRAIN
Definition cp_campaign.h:93
@ MAPTYPE_MAX
Definition cp_campaign.h:98
void CP_ReadCampaignData(const campaign_t *campaign)
Definition cp_parse.cpp:692
void(* missionSpawnFunction_t)(void)
Header file for Aircraft and item components.
#define MAX_ASSEMBLIES
Header for employee related stuff.
@ MAX_EMPL
Definition cp_employee.h:36
Header for geoscape event related stuff.
#define MAX_CAMPAIGN_TRIGGER_EVENTS
Definition cp_event.h:96
#define MAX_EVENTMAILS
Definition cp_event.h:28
Header for installation management related stuff.
#define MAX_INSTALLATION_TEMPLATES
Header for single player market stuff.
Header file for messageoptions related stuff.
#define MAX_MESSAGECATEGORIES
@ NT_NUM_NOTIFYTYPE
Nation code.
Campaign parsing header.
Header for production related stuff.
#define MAX_UFOONGEOSCAPE
Definition cp_radar.h:27
#define MAX_RANKS
Definition cp_rank.h:26
Header for research related stuff.
#define MAX_TECHNOLOGIES
Definition cp_research.h:31
Defines some savefile structures.
Campaign statistic headers.
Header file for Transfer stuff.
Header file for UFOpaedia script interpreter.
#define MAX_PEDIACHAPTERS
Definition cp_ufopedia.h:28
UFO recovery and storing.
#define MAX_TEAMS_PER_MISSION
Definition inv_shared.h:618
#define MAX_OBJDEFS
Definition inv_shared.h:37
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
#define MAX_VAR
Definition shared.h:36
An aircraft with all it's data.
projectile used during fight between two or more aircraft
Definition cp_airfight.h:43
alien team category definition
linkedList_t * equipment
interestCategory_t missionCategories[INTERESTCATEGORY_MAX]
alienTeamGroup_t alienTeamGroups[MAX_ALIEN_GROUP_PER_CATEGORY]
alien team group definition.
const chrTemplate_t * alienChrTemplates[MAX_TEAMS_PER_MISSION]
const teamDef_t * alienTeams[MAX_TEAMS_PER_MISSION]
A base with all it's data.
Definition cp_base.h:84
template for creating a base
Definition cp_base.h:130
alienTeamGroup_t * alienTeamGroup
char alienEquipment[MAX_VAR]
char civTeam[MAX_VAR]
struct mission_s * mission
const char * zoneType
struct nation_s * nation
A building with all it's data.
Definition cp_building.h:73
char asymptoticMarket[MAX_VAR]
salary_t salaries
const equipDef_t * asymptoticMarketDef
float healingRate
char text[MAX_VAR]
int initialInterest
char map[MAX_VAR]
class DateTime date
bool defaultCampaign
char researched[MAX_VAR]
const campaignEvents_t * events
float ufoReductionRate
char name[MAX_VAR]
float produceRate
float liquidationRate
char market[MAX_VAR]
char firstBaseTemplate[MAX_VAR]
const equipDef_t * marketDef
int maxAllowedXVIRateUntilLost
int alienBaseInterest
signed int difficulty
float minhappiness
char soldierEquipment[MAX_VAR]
char equipment[MAX_VAR]
int negativeCreditsUntilLost
linkedList_t * initialCraft
float componentRate
float researchRate
float employeeRate
client campaign structure
int numBases
pediaChapter_t upChapters[MAX_PEDIACHAPTERS]
technology_t technologies[MAX_TECHNOLOGIES]
baseTemplate_t baseTemplates[MAX_BASETEMPLATES]
int numBuildingTemplates
linkedList_t * aircraft
battleParam_t battleParameters
int numMsgCategoryEntries
float timer
missionResultFunction_t missionResultCallback
building_t buildings[MAX_BASES][MAX_BUILDINGS]
int civiliansKilled
int numCampaigns
int lastMissionSpawnedDelay
int credits
linkedList_t * employees[MAX_EMPL]
market_t eMarket
aircraft_t ufos[MAX_UFOONGEOSCAPE]
bool startXVI
components_t components[MAX_ASSEMBLIES]
linkedList_t * updateCharacters
aircraft_t aircraftTemplates[MAX_AIRCRAFT]
aircraftProjectile_t projectiles[MAX_PROJECTILESONGEOSCAPE]
linkedList_t * nations
float frametime
bool paid
int gameLapse
linkedList_t * storedUFOs
int numCampaignEventDefinitions
stats_t campaignStats
mapAction_t mapAction
int gameTimeScale
linkedList_t * missions
linkedList_t * installations
linkedList_t * cities
eventMail_t eventMails[MAX_EVENTMAILS]
vec2_t newBasePos
msgCategoryEntry_t msgCategoryEntries[NT_NUM_NOTIFYTYPE+MAX_MESSAGECATEGORIES]
int lastInterestIncreaseDelay
int numCampaignTriggerEvents
msgCategory_t messageCategories[MAX_MESSAGECATEGORIES]
class DateTime date
int aliensKilled
struct mission_s * selectedMission
equipDef_t eMission
rank_t ranks[MAX_RANKS]
campaign_t campaigns[MAX_CAMPAIGNS]
int numEventMails
int numInstallationTemplates
installationTemplate_t installationTemplates[MAX_INSTALLATION_TEMPLATES]
int numTechnologies
int numMsgCategories
alienTeamCategory_t alienCategories[ALIENCATEGORY_MAX]
int numUFOs
aircraft_t * selectedAircraft
int numUnreadMails
campaignTriggerEvent_t campaignTriggerEvents[MAX_CAMPAIGN_TRIGGER_EVENTS]
aircraft_t * interceptAircraft
technology_t * teamDefTechs[MAX_TEAMDEFS]
int numAircraftTemplates
aircraft_t * missionAircraft
int numAlienCategories
missionSpawnFunction_t missionSpawnCallback
int numCities
base_t bases[MAX_BASES]
campaignEvents_t campaignEvents[MAX_CAMPAIGNS]
int numRanks
campaign_t * curCampaign
int numProjectiles
int overallInterest
int numNations
technology_t * objDefTechs[MAX_OBJDEFS]
int numBuildings[MAX_BASES]
linkedList_t * alienBases
int interest[INTERESTCATEGORY_MAX]
int numBaseTemplates
int numComponents
linkedList_t * transfers
int numChapters
building_t buildingTemplates[MAX_BUILDINGS]
aircraft_t * selectedUFO
The definition of a "components" entry (i.e. an assembly of several items) parsed from a ufo-file.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition cvar.h:71
available mails for a tech - mail and mail_pre in script files
Definition cp_event.h:38
Describes a rank that a recruit can gain.
Definition cp_rank.h:29
int base[MAX_EMPL]
int rankBonus[MAX_EMPL]
int aircraftFactor
float debtInterest
int baseUpkeep
int aircraftDivisor
This is the technology parsed from research.ufo.
vec_t vec2_t[2]
Definition ufotypes.h:38