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