1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/* Starshatter: The Open Source Project
Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
AUTHOR: John DiCamillo
OVERVIEW
========
Campaign defines a strategic military scenario. This class
owns (or generates) the Mission list that defines the action
in the campaign.
*/
#ifndef Campaign_h
#define Campaign_h
#include <starshatter/definition.h>
#include "Types.h"
#include "Bitmap.h"
#include "Geometry.h"
#include "Text.h"
#include "List.h"
// +--------------------------------------------------------------------+
class Campaign;
class CampaignPlan;
class Combatant;
class CombatAction;
class CombatEvent;
class CombatGroup;
class CombatUnit;
class CombatZone;
class DataLoader;
class Mission;
class MissionTemplate;
class StarSystem;
// +--------------------------------------------------------------------+
class MissionInfo
{
public:
static const char* TYPENAME() { return "MissionInfo"; }
MissionInfo();
~MissionInfo();
int operator == (const MissionInfo& m) const { return id == m.id; }
int operator < (const MissionInfo& m) const { return id < m.id; }
int operator <= (const MissionInfo& m) const { return id <= m.id; }
bool IsAvailable();
int id;
Text name;
Text player_info;
Text description;
Text system;
Text region;
Text script;
int start;
int type;
int min_rank;
int max_rank;
int action_id;
int action_status;
int exec_once;
int start_before;
int start_after;
Mission* mission;
};
class TemplateList
{
public:
static const char* TYPENAME() { return "TemplateList"; }
TemplateList();
~TemplateList();
int mission_type;
int group_type;
int index;
List<MissionInfo> missions;
};
// +--------------------------------------------------------------------+
class Campaign
{
public:
static const char* TYPENAME() { return "Campaign"; }
enum CONSTANTS {
TRAINING_CAMPAIGN = 1,
DYNAMIC_CAMPAIGN,
MOD_CAMPAIGN = 100,
SINGLE_MISSIONS = 1000,
MULTIPLAYER_MISSIONS,
CUSTOM_MISSIONS,
NUM_IMAGES = 6
};
enum STATUS {
CAMPAIGN_INIT,
CAMPAIGN_ACTIVE,
CAMPAIGN_SUCCESS,
CAMPAIGN_FAILED
};
Campaign(int id, const char* name=0);
Campaign(int id, const char* name, const char* path);
virtual ~Campaign();
int operator == (const Campaign& s) const { return name == s.name; }
int operator < (const Campaign& s) const { return campaign_id < s.campaign_id; }
// operations:
virtual void Load();
virtual void Prep();
virtual void Start();
virtual void ExecFrame();
virtual void Unload();
virtual void Clear();
virtual void LockoutEvents(int seconds);
virtual void CheckPlayerGroup();
void CreatePlanners();
// accessors:
const char* Name() const { return name; }
const char* Description() const { return description; }
const char* Path() const { return path; }
const char* Situation() const { return situation; }
const char* Orders() const { return orders; }
void SetSituation(const char* s) { situation = s; }
void SetOrders(const char* o) { orders = o; }
int GetPlayerTeamScore();
List<MissionInfo>& GetMissionList() { return missions; }
List<Combatant>& GetCombatants() { return combatants; }
List<CombatZone>& GetZones() { return zones; }
List<StarSystem>& GetSystemList() { return systems; }
List<CombatAction>& GetActions() { return actions; }
List<CombatEvent>& GetEvents() { return events; }
CombatEvent* GetLastEvent();
CombatAction* FindAction(int id);
int CountNewEvents() const;
int GetPlayerIFF();
CombatGroup* GetPlayerGroup() { return player_group; }
void SetPlayerGroup(CombatGroup* pg);
CombatUnit* GetPlayerUnit() { return player_unit; }
void SetPlayerUnit(CombatUnit* pu);
Combatant* GetCombatant(const char* name);
CombatGroup* FindGroup(int iff, int type, int id);
CombatGroup* FindGroup(int iff, int type, CombatGroup* near_group=0);
CombatGroup* FindStrikeTarget(int iff, CombatGroup* strike_group);
StarSystem* GetSystem(const char* sys);
CombatZone* GetZone(const char* rgn);
MissionInfo* CreateNewMission();
void DeleteMission(int id);
Mission* GetMission();
Mission* GetMission(int id);
Mission* GetMissionByFile(const char* filename);
MissionInfo* GetMissionInfo(int id);
MissionInfo* FindMissionTemplate(int msn_type, CombatGroup* player_group);
void ReloadMission(int id);
void LoadNetMission(int id, const char* net_mission);
void StartMission();
void RollbackMission();
void SetCampaignId(int id);
int GetCampaignId() const { return campaign_id; }
void SetMissionId(int id);
int GetMissionId() const { return mission_id; }
Bitmap* GetImage(int n) { return &image[n]; }
long double GetTime() const { return time; }
long double LoadTime() const;
void SetLoadTime(long double value);
long double StartTime() const;
void SetStartTime(long double value);
bool InCutscene() const;
bool IsDynamic() const;
bool IsTraining() const;
bool IsScripted() const;
bool IsSequential() const;
bool IsSaveGame() const { return loaded_from_savegame; }
void SetSaveGame(bool s) { loaded_from_savegame = s; }
bool IsActive() const { return status == CAMPAIGN_ACTIVE; }
bool IsComplete() const { return status == CAMPAIGN_SUCCESS; }
bool IsFailed() const { return status == CAMPAIGN_FAILED; }
void SetStatus(int s);
int GetStatus() const { return status; }
int GetAllCombatUnits(int iff, List<CombatUnit>& units);
static void Initialize();
static void Close();
static Campaign* GetCampaign();
static List<Campaign>&
GetAllCampaigns();
static int GetLastCampaignId();
static Campaign* SelectCampaign(const char* name);
static Campaign* CreateCustomCampaign(const char* name, const char* path);
static long double Stardate();
protected:
void LoadCampaign(DataLoader* loader, bool full=false);
void LoadTemplateList(DataLoader* loader);
void LoadMissionList(DataLoader* loader);
void LoadCustomMissions(DataLoader* loader);
void ParseGroup(TermStruct* val,
CombatGroup* force,
CombatGroup* clone,
const char* filename);
void ParseAction(TermStruct* val,
const char* filename);
CombatGroup* CloneOver(CombatGroup* force,
CombatGroup* clone,
CombatGroup* group);
void SelectDefaultPlayerGroup(CombatGroup* g, int type);
TemplateList* GetTemplateList(int msn_type, int grp_type);
// attributes:
int campaign_id;
int status;
char filename[64];
char path[64];
Text name;
Text description;
Text situation;
Text orders;
Bitmap image[NUM_IMAGES];
bool scripted;
bool sequential;
bool loaded_from_savegame;
List<Combatant> combatants;
List<StarSystem> systems;
List<CombatZone> zones;
List<CampaignPlan> planners;
List<MissionInfo> missions;
List<TemplateList> templates;
List<CombatAction> actions;
List<CombatEvent> events;
CombatGroup* player_group;
CombatUnit* player_unit;
int mission_id;
Mission* mission;
Mission* net_mission;
long double time;
long double load_time;
long double start_time;
int lockout;
};
#endif // Campaign_h
|