/
stratdef.h
299 lines (206 loc) · 7.41 KB
/
stratdef.h
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#ifndef _stratdef_h_
#define _stratdef_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
stratgey block. We gain game control via the strategy blocks
the overall sturcture is basically game independent, though if you
do not use module mapblocks
The description
of the world is in two structures. These are the Module Map block and the
strategy block. A object does not need to have a strategy block. In this case
in is simply something to be drawn and/or used for standard collsions. Objects
that have an existance beyond simple engine controls has a strategy block.
Control.
1 creation and destruction of strategy blocks. After Showviews we generate/remove any
displayblocks that we have responsibilty for. Most predictable elements of the
world are handeled by Chris, though we do need to supply him with a function
that attaches SBs to MOdMBs when needed.
2 Strategies are run.
Rather than passing the DBs to the stratgey functions we pass the SBs. we
switch on the I_SBtype and use the SBdataptr via a cast to contain and modify the
behaviour in a function specific to that I_SBType. The first element of the SBdata
structure (whatever it is) MUST CONTAIN THE I_SBtype. This is the only check on the
validity of the data as we are passing data via a cast.
changes
Loading of the SBdataptr is entirley game-tool related and does not concern the
over all design of how strategy blocks work
TEMPLATES templates no longer exist
Entities, entitities.c and entity.c We are keeping entities as names for objects
(ModMBs) which have attached strategy blocks
Relation to ObStrategy. The Obstrategy still can desiginate how something will behave.
If we have a simplistic moving object it can have a OBstratgey. These still can run under
display block control for Bwards stuff.
generation
strategy blocks. Post loading attaching of stratgey blocks. (useful for testing)
Certain objects may be created at run time eg missiles, dropped guns. We need functions
that can initialise a stratgey block for these objects. Functions can be also wriiten for
attaching testing strategies to objects.
B Laoding Map
StrategyBlock
StrategyExtensionBLock
if you still want ot use templates to fill out strategy blocks you can.
*/
#include "hmodel.h"
typedef enum bhvr_type
{
I_BehaviourNull,
I_BehaviourMarinePlayer,
I_BehaviourPredatorPlayer,
I_BehaviourAlienPlayer,
I_BehaviourAlien,
I_BehaviourQueenAlien,
I_BehaviourFaceHugger,
I_BehaviourPredator,
I_BehaviourXenoborg,
I_BehaviourMarine,
I_BehaviourSeal,
I_BehaviourPredatorAlien,
I_BehaviourProximityDoor,
I_BehaviourLiftDoor,
I_BehaviourSwitchDoor,
I_BehaviourSimpleAnimation,
I_BehaviourBinarySwitch,
I_BehaviourLift,
I_BehaviourPlatform,
I_BehaviourAutoGun,
I_BehaviourAutoGunMuzzleFlash,
I_BehaviourGenerator,
I_BehaviourDatabase,
I_BehaviourHierarchicalFragment,
I_BehaviourAlienFragment,
I_BehaviourSmokeGenerator,
/* KJL 12:51:18 03/20/97 -
this fragment behaviour will be used by all objects */
I_BehaviourFragment,
I_BehaviourGrenade,
I_BehaviourFlameProjectile,
I_BehaviourRocket,
I_BehaviourSonicPulse,
I_BehaviourPPPlasmaBolt,
I_BehaviourSpeargunBolt,
I_BehaviourNPCPredatorDisc,
I_BehaviourPredatorDisc_SeekTrack,
I_BehaviourPredatorEnergyBolt,
I_BehaviourXenoborgEnergyBolt,
I_BehaviourOneShot,
I_BehaviourOneShotAnim,
I_BehaviourInanimateObject,
I_BehaviourNetGhost, /* for preliminary network support */
I_BehaviourPulseGrenade,
I_BehaviourFlareGrenade,
I_BehaviourFragmentationGrenade,
I_BehaviourProximityGrenade,
I_BehaviourMolotov,
// added by john for link switches
I_BehaviourLinkSwitch,
I_BehaviourClusterGrenade,
I_BehaviourAlienSpit,
I_BehaviourTest,
I_BehaviourXenoborgMorphRoom,
I_BehaviourLightFX,
I_BehaviourPlacedSound,
I_BehaviourMissionComplete,
I_BehaviourTrackObject,
I_BehaviourFan,
I_BehaviourMessage,
I_BehaviourNetCorpse,
I_BehaviourRubberDuck,
I_BehaviourPlacedHierarchy,
I_BehaviourPlacedLight,
I_BehaviourPowerCable,
I_BehaviourDormantPredator,
I_BehaviourDeathVolume,
I_BehaviourSelfDestruct,
I_BehaviourGrapplingHook,
I_BehaviourDummy,
I_BehaviourParticleGenerator,
I_BehaviourVideoScreen,
I_BehaviourFrisbee,
I_BehaviourFrisbeeEnergyBolt,
}AVP_BEHAVIOUR_TYPE;
/* put the tags in here */
#define SB_NAME_LENGTH 8 /* DO NOT CHANGE THIS! */
#define MAX_PRESERVED_SB 20
typedef struct
{
char name [SB_NAME_LENGTH];
} SBNAMEBLOCK;
typedef struct sb_flags_bitfield
{
unsigned int please_destroy_me :1;
unsigned int no_displayblock :1;
unsigned int request_operate :1;
unsigned int preserve_until_end_of_level:1; /*strategy block targeted by something else , so must stay until end of level*/
unsigned int destroyed_but_preserved:1;
unsigned int not_on_motiontracker :1;
}SBFLAGS;
/* CDF 12/11/97 Damage structures moved to hmodel.h */
typedef struct strategyblock
{
AVP_BEHAVIOUR_TYPE I_SBtype; /* Strategy Extension Type*/
void * SBdataptr; /* Strategy Extension Data Pointer*/
struct displayblock* SBdptr; /* pointer to DB if drawn or collided*/
struct dynamicsblock* DynPtr; /* KJL 17:17:15 11/05/96 - pointer to a DYNAMICSBLOCK */
/* (If this is NULL the object cannot move AND cannot be collided with.) */
int integrity;
/* CDF 15/9/97 New Damage System */
DAMAGEBLOCK SBDamageBlock;
/* CDF 15/9/97 New Damage System */
SBFLAGS SBflags; /* flags */
char SBname[SB_NAME_LENGTH];
#if SupportModules
struct module *SBmoptr; /* needed if DBdeS are deallocted*/
struct modulemapblock* SBmomptr; /* module map block ref*/
#endif
#if SupportMorphing
struct morphctrl *SBmorphctrl;
#endif
/* patrick 15/1/97 - these fields are for object visibility management system */
char maintainVisibility;
struct module *containingModule;
int shapeIndex;
#if debug
short SBIsValid;
#endif
char* name;
} STRATEGYBLOCK;
// interface to Creating StrategyBlocks
extern void AssignNewSBName(STRATEGYBLOCK *sbPtr);
extern STRATEGYBLOCK * AttachNewStratBlock(struct module* moptr,
struct modulemapblock* momptr,
struct displayblock* dptr);
extern void InitialiseSBValues(STRATEGYBLOCK* sbptr);
extern STRATEGYBLOCK* FindSBWithName(char* id_name);
// interface to removing strategy blocks
extern void DestroyAnyStrategyBlock(STRATEGYBLOCK* sbptr);
extern void RemoveDestroyedStrategyBlocks(void);
extern void DestroyAllStrategyBlocks(void);
/* This should be in PLAYER. But Kevin was on holiday with his files checked out. */
extern void GivePlayerCloakAway(void);
// for lift and airlock code
extern void InitPreservedSBs();
extern void PreserveStBlocksInModule();
extern BOOL SBNeededForNextEnv();
extern void AddPreservedSBsToActiveList();
extern void TeleportPreservedSBsToNewEnvModule(MODULE* old_pos_module, MODULE* new_pos, int orient_diff);
extern int NumActiveStBlocks;
extern STRATEGYBLOCK *ActiveStBlockList[];
/****** MACROS FOR NAME COMAPRISONS AND COPYS*******/
#define COPY_NAME(name1, name2) \
{ \
GLOBALASSERT(SB_NAME_LENGTH == 8); \
*(int*)name1 = *(int*)name2; \
*((int*)name1 + 1) = *((int*)name2 + 1);\
}
#define NAME_ISEQUAL(name1, name2) \
((*(int*)name1 == *(int*)name2) && \
(*(((int*)name1) + 1) == *(((int*)name2) + 1)))
#define NAME_ISNULL(name1) \
((*(int*)name1 == '\0') && \
(*(((int*)name1) + 1) == '\0'))
#ifdef __cplusplus
};
#endif
#endif