1 #ifndef _stratdef_h_ 2 #define _stratdef_h_ 1 3 4 #include "unaligned.h" 5 6 #ifdef __cplusplus 7 8 extern "C" { 9 10 #endif 11 12 13 14 /* 15 stratgey block. We gain game control via the strategy blocks 16 the overall sturcture is basically game independent, though if you 17 do not use module mapblocks 18 19 The description 20 of the world is in two structures. These are the Module Map block and the 21 strategy block. A object does not need to have a strategy block. In this case 22 in is simply something to be drawn and/or used for standard collsions. Objects 23 that have an existance beyond simple engine controls has a strategy block. 24 25 26 27 Control. 28 29 1 creation and destruction of strategy blocks. After Showviews we generate/remove any 30 displayblocks that we have responsibilty for. Most predictable elements of the 31 world are handeled by Chris, though we do need to supply him with a function 32 that attaches SBs to MOdMBs when needed. 33 34 2 Strategies are run. 35 36 Rather than passing the DBs to the stratgey functions we pass the SBs. we 37 switch on the I_SBtype and use the SBdataptr via a cast to contain and modify the 38 behaviour in a function specific to that I_SBType. The first element of the SBdata 39 structure (whatever it is) MUST CONTAIN THE I_SBtype. This is the only check on the 40 validity of the data as we are passing data via a cast. 41 42 43 44 changes 45 46 Loading of the SBdataptr is entirley game-tool related and does not concern the 47 over all design of how strategy blocks work 48 49 TEMPLATES templates no longer exist 50 51 Entities, entitities.c and entity.c We are keeping entities as names for objects 52 (ModMBs) which have attached strategy blocks 53 54 Relation to ObStrategy. The Obstrategy still can desiginate how something will behave. 55 If we have a simplistic moving object it can have a OBstratgey. These still can run under 56 display block control for Bwards stuff. 57 58 59 60 generation 61 62 strategy blocks. Post loading attaching of stratgey blocks. (useful for testing) 63 Certain objects may be created at run time eg missiles, dropped guns. We need functions 64 that can initialise a stratgey block for these objects. Functions can be also wriiten for 65 attaching testing strategies to objects. 66 67 B Laoding Map 68 StrategyBlock 69 StrategyExtensionBLock 70 71 72 if you still want ot use templates to fill out strategy blocks you can. 73 74 */ 75 76 #include "hmodel.h" 77 78 typedef enum bhvr_type 79 { 80 I_BehaviourNull, 81 82 I_BehaviourMarinePlayer, 83 I_BehaviourPredatorPlayer, 84 I_BehaviourAlienPlayer, 85 86 I_BehaviourAlien, 87 I_BehaviourQueenAlien, 88 I_BehaviourFaceHugger, 89 I_BehaviourPredator, 90 I_BehaviourXenoborg, 91 I_BehaviourMarine, 92 I_BehaviourSeal, 93 I_BehaviourPredatorAlien, 94 95 I_BehaviourProximityDoor, 96 I_BehaviourLiftDoor, 97 I_BehaviourSwitchDoor, 98 I_BehaviourSimpleAnimation, 99 I_BehaviourBinarySwitch, 100 I_BehaviourLift, 101 I_BehaviourPlatform, 102 I_BehaviourAutoGun, 103 I_BehaviourAutoGunMuzzleFlash, 104 I_BehaviourGenerator, 105 I_BehaviourDatabase, 106 107 108 I_BehaviourHierarchicalFragment, 109 110 I_BehaviourAlienFragment, 111 I_BehaviourSmokeGenerator, 112 113 /* KJL 12:51:18 03/20/97 - 114 this fragment behaviour will be used by all objects */ 115 I_BehaviourFragment, 116 117 I_BehaviourGrenade, 118 I_BehaviourFlameProjectile, 119 I_BehaviourRocket, 120 I_BehaviourSonicPulse, 121 I_BehaviourPPPlasmaBolt, 122 I_BehaviourSpeargunBolt, 123 124 I_BehaviourNPCPredatorDisc, 125 I_BehaviourPredatorDisc_SeekTrack, 126 I_BehaviourPredatorEnergyBolt, 127 I_BehaviourXenoborgEnergyBolt, 128 129 I_BehaviourOneShot, 130 I_BehaviourOneShotAnim, 131 I_BehaviourInanimateObject, 132 133 I_BehaviourNetGhost, /* for preliminary network support */ 134 135 I_BehaviourPulseGrenade, 136 I_BehaviourFlareGrenade, 137 I_BehaviourFragmentationGrenade, 138 I_BehaviourProximityGrenade, 139 I_BehaviourMolotov, 140 141 // added by john for link switches 142 I_BehaviourLinkSwitch, 143 144 I_BehaviourClusterGrenade, 145 146 I_BehaviourAlienSpit, 147 148 I_BehaviourTest, 149 150 I_BehaviourXenoborgMorphRoom, 151 152 I_BehaviourLightFX, 153 I_BehaviourPlacedSound, 154 I_BehaviourMissionComplete, 155 I_BehaviourTrackObject, 156 I_BehaviourFan, 157 I_BehaviourMessage, 158 I_BehaviourNetCorpse, 159 160 I_BehaviourRubberDuck, 161 I_BehaviourPlacedHierarchy, 162 I_BehaviourPlacedLight, 163 I_BehaviourPowerCable, 164 I_BehaviourDormantPredator, 165 I_BehaviourDeathVolume, 166 I_BehaviourSelfDestruct, 167 168 I_BehaviourGrapplingHook, 169 I_BehaviourDummy, 170 I_BehaviourParticleGenerator, 171 I_BehaviourVideoScreen, 172 173 I_BehaviourFrisbee, 174 I_BehaviourFrisbeeEnergyBolt, 175 176 }AVP_BEHAVIOUR_TYPE; 177 178 179 /* put the tags in here */ 180 181 #define SB_NAME_LENGTH 8 /* DO NOT CHANGE THIS! */ 182 #define MAX_PRESERVED_SB 20 183 184 typedef struct 185 { 186 char name [SB_NAME_LENGTH]; 187 } SBNAMEBLOCK; 188 189 190 typedef struct sb_flags_bitfield 191 { 192 unsigned int please_destroy_me :1; 193 unsigned int no_displayblock :1; 194 unsigned int request_operate :1; 195 unsigned int preserve_until_end_of_level:1; /*strategy block targeted by something else , so must stay until end of level*/ 196 unsigned int destroyed_but_preserved:1; 197 unsigned int not_on_motiontracker :1; 198 199 }SBFLAGS; 200 201 /* CDF 12/11/97 Damage structures moved to hmodel.h */ 202 203 typedef struct strategyblock 204 { 205 AVP_BEHAVIOUR_TYPE I_SBtype; /* Strategy Extension Type*/ 206 void * SBdataptr; /* Strategy Extension Data Pointer*/ 207 struct displayblock* SBdptr; /* pointer to DB if drawn or collided*/ 208 struct dynamicsblock* DynPtr; /* KJL 17:17:15 11/05/96 - pointer to a DYNAMICSBLOCK */ 209 /* (If this is NULL the object cannot move AND cannot be collided with.) */ 210 int integrity; 211 /* CDF 15/9/97 New Damage System */ 212 DAMAGEBLOCK SBDamageBlock; 213 /* CDF 15/9/97 New Damage System */ 214 215 SBFLAGS SBflags; /* flags */ 216 char SBname[SB_NAME_LENGTH]; 217 #if SupportModules 218 struct module *SBmoptr; /* needed if DBdeS are deallocted*/ 219 struct modulemapblock* SBmomptr; /* module map block ref*/ 220 #endif 221 #if SupportMorphing 222 struct morphctrl *SBmorphctrl; 223 #endif 224 225 /* patrick 15/1/97 - these fields are for object visibility management system */ 226 char maintainVisibility; 227 struct module *containingModule; 228 int shapeIndex; 229 #if debug 230 short SBIsValid; 231 #endif 232 char* name; 233 234 } STRATEGYBLOCK; 235 236 237 238 // interface to Creating StrategyBlocks 239 240 241 extern void AssignNewSBName(STRATEGYBLOCK *sbPtr); 242 extern STRATEGYBLOCK * AttachNewStratBlock(struct module* moptr, 243 struct modulemapblock* momptr, 244 struct displayblock* dptr); 245 246 extern void InitialiseSBValues(STRATEGYBLOCK* sbptr); 247 248 extern STRATEGYBLOCK* FindSBWithName(char* id_name); 249 250 251 // interface to removing strategy blocks 252 253 254 extern void DestroyAnyStrategyBlock(STRATEGYBLOCK* sbptr); 255 extern void RemoveDestroyedStrategyBlocks(void); 256 extern void DestroyAllStrategyBlocks(void); 257 258 /* This should be in PLAYER. But Kevin was on holiday with his files checked out. */ 259 extern void GivePlayerCloakAway(void); 260 261 262 263 264 // for lift and airlock code 265 266 extern void InitPreservedSBs(); 267 extern void PreserveStBlocksInModule(); 268 extern BOOL SBNeededForNextEnv(); 269 extern void AddPreservedSBsToActiveList(); 270 extern void TeleportPreservedSBsToNewEnvModule(MODULE* old_pos_module, MODULE* new_pos, int orient_diff); 271 272 273 274 extern int NumActiveStBlocks; 275 extern STRATEGYBLOCK *ActiveStBlockList[]; 276 277 /****** MACROS FOR NAME COMAPRISONS AND COPYS*******/ 278 279 #define COPY_NAME(name1, name2) \ 280 { \ 281 GLOBALASSERT(SB_NAME_LENGTH == 8); \ 282 *(unaligned_s32*)name1 = *(unaligned_s32*)name2; \ 283 *((unaligned_s32*)name1 + 1) = *((unaligned_s32*)name2 + 1);\ 284 } 285 286 #define NAME_ISEQUAL(name1, name2) \ 287 ((*(unaligned_s32*)name1 == *(unaligned_s32*)name2) && \ 288 (*(((unaligned_s32*)name1) + 1) == *(((unaligned_s32*)name2) + 1))) 289 290 #define NAME_ISNULL(name1) \ 291 ((*(unaligned_s32*)name1 == '\0') && \ 292 (*(((unaligned_s32*)name1) + 1) == '\0')) 293 294 295 #ifdef __cplusplus 296 297 }; 298 299 #endif 300 301 #endif 302