1 /*--------------Patrick 14/2/97---------------- 2 Header file for marine support functions 3 ---------------------------------------------*/ 4 5 #ifndef _bhmarin_h_ 6 #define _bhmarin_h_ 1 7 8 9 #ifdef __cplusplus 10 11 extern "C" { 12 13 #endif 14 15 16 #include "bh_pred.h" 17 #include "psndproj.h" 18 #include "sfx.h" 19 /*-------------------------------------------- 20 enums of marine far and near behaviour states 21 --------------------------------------------*/ 22 typedef enum marine_bhstate 23 { 24 MBS_Waiting, 25 /* Waiting - stand and do nothing, 26 until you get a call, see an enemy, 27 or begin to fidget. */ 28 MBS_Wandering, 29 /* Go from module to module around the environment. */ 30 MBS_Retreating, 31 MBS_Sentry, 32 MBS_Approaching, 33 MBS_Firing, 34 MBS_Avoidance, 35 MBS_Dying, 36 MBS_Responding, 37 MBS_Returning, 38 MBS_Pathfinding, 39 MBS_Taunting, 40 MBS_PanicFire, 41 MBS_Reloading, 42 MBS_PumpAction, 43 MBS_GetWeapon, 44 MBS_PanicReloading, 45 MBS_AcidAvoidance, 46 } MARINE_BHSTATE; 47 48 typedef enum marine_movement_style { 49 MMS_Stationary=0, 50 MMS_Bored, 51 MMS_Alert, 52 MMS_Combat, 53 MMS_Sprint, 54 } MARINE_MOVEMENT_STYLE; 55 56 typedef enum state_return_condition { 57 SRC_No_Change, 58 SRC_Request_Approach, 59 SRC_Request_Fire, 60 SRC_Request_Wander, 61 SRC_Request_Avoidance, 62 SRC_Request_Wait, 63 SRC_Request_Retreat, 64 SRC_Request_Respond, 65 SRC_Request_Return, 66 SRC_Request_Taunt, 67 SRC_Request_PanicFire, 68 SRC_Request_Reload, 69 SRC_Request_PumpAction, 70 SRC_Request_PullPistol, 71 SRC_Request_PanicReload, 72 } STATE_RETURN_CONDITION; 73 74 /*-------------------------------------------- 75 Enum of marine animation sequences 76 --------------------------------------------*/ 77 78 typedef enum MarineSequence 79 { 80 MSQ_Walk, 81 MSQ_StandDieFront, 82 MSQ_StandDieBack, 83 MSQ_StartStandingFire, 84 MSQ_StandingFire, 85 MSQ_StandDeadFront, 86 MSQ_StandDeadBack, 87 MSQ_Crawl, 88 MSQ_CrouchDie, 89 MSQ_CrouchDead, 90 MSQ_RunningFire, 91 MSQ_Crouch, 92 MSQ_Stand, 93 MSQ_Jump, 94 MSQ_Taunt, 95 MSQ_Walk_Backwards, 96 MSQ_Crawl_Backwards, 97 MSQ_RunningFire_Backwards, 98 99 MSQ_StandingFireSecondary, 100 MSQ_RunningFireSecondary, 101 MSQ_RunningFireSecondary_Backwards, 102 103 MSQ_BaseOfCudgelAttacks=40, 104 }MARINE_SEQUENCE; 105 106 typedef enum MarineMissions { 107 MM_Wait_Then_Wander, // Should do nothing until visible. 108 MM_Wander, 109 MM_Guard, 110 MM_LocalGuard, 111 MM_NonCom, 112 MM_Pathfinder, 113 MM_RunAroundOnFire, 114 }MARINE_MISSION; 115 116 /***** Marine squad command state *****/ 117 118 typedef struct squadcommand { 119 int alertStatus; 120 int responseLevel; 121 AIMODULE *alertZone; 122 int alertPriority; 123 124 int Squad_Suspicion; 125 VECTORCH squad_suspect_point; 126 127 /* Now some stats. */ 128 int RespondingMarines; 129 int Alt_RespondingMarines; 130 131 int NearUnpanickedMarines; 132 int Alt_NearUnpanickedMarines; 133 134 int NearPanickedMarines; 135 int Alt_NearPanickedMarines; 136 137 int NearBurningMarines; 138 int Alt_NearBurningMarines; 139 140 int Squad_Delta_Morale; 141 int Nextframe_Squad_Delta_Morale; 142 143 } SQUAD_COMMAND_STATE; 144 145 /*-------------------------------------------- 146 Data for civilian accoutement stuff 147 --------------------------------------------*/ 148 149 struct hierarchy_shape_replacement; 150 typedef struct hierarchy_variant_data 151 { 152 struct hierarchy_shape_replacement * replacements; 153 int voice; 154 unsigned int female :1; 155 } HIERARCHY_VARIANT_DATA; 156 157 /*-------------------------------------------- 158 Marine behaviour data block 159 --------------------------------------------*/ 160 typedef struct marineStatusBlock 161 { 162 signed int health; 163 signed int volleySize; 164 signed int primaryWeaponDamage; 165 166 MARINE_BHSTATE behaviourState; 167 MARINE_BHSTATE lastState; 168 169 STRATEGYBLOCK *Target; 170 MARINE_MISSION Mission; 171 char Target_SBname[SB_NAME_LENGTH]; 172 173 char death_target_ID[SB_NAME_LENGTH]; //another strategy can be notified of the marine's death 174 STRATEGYBLOCK* death_target_sbptr; 175 int death_target_request; 176 177 STRATEGYBLOCK* generator_sbptr;//0 unless created by a generator 178 179 AIMODULE *lastmodule; 180 AIMODULE *destinationmodule; 181 AIMODULE *missionmodule; 182 AIMODULE *fearmodule; 183 VECTORCH my_spot; 184 VECTORCH my_facing_point; 185 /* Movement data. */ 186 signed int nearSpeed; 187 int acceleration; 188 int speedConstant; 189 int accelerationConstant; 190 /* Sense data */ 191 int mtracker_timer; 192 VECTORCH suspect_point; 193 int suspicious; 194 int previous_suspicion; 195 int using_squad_suspicion; 196 int sawlastframe; 197 int gotapoint; 198 int lastframe_fallingspeed; 199 /* Pathfinder parameters */ 200 int path; 201 int stepnumber; 202 /* Pathfinder parameters */ 203 int stateTimer; 204 int internalState; 205 HMODELCONTROLLER HModelController; 206 VECTORCH weaponTarget; /* position for firing weapon at */ 207 DISPLAYBLOCK *myGunFlash; 208 int soundHandle; 209 int soundHandle2; 210 NPC_OBSTRUCTIONREPORT obstruction; 211 NPC_MOVEMENTDATA moveData; 212 NPC_WANDERDATA wanderData; 213 int IAmCrouched; 214 /* CDF 15/12/97 */ 215 struct marine_weapon_data *My_Weapon; 216 SECTION_DATA *My_Gunflash_Section; 217 SECTION_DATA *My_Elevation_Section; /* For elevation computation. */ 218 int lastroundhit; 219 SECTION_DATA *lasthitsection; 220 221 int GibbFactor; 222 int Wounds; 223 224 int incidentFlag; 225 int incidentTimer; 226 227 int weapon_variable; 228 int weapon_variable2; 229 int clipammo; 230 int roundsForThisTarget; 231 232 int Female; 233 int Android; 234 int Skill; 235 int Courage; 236 int Voice; 237 int VoicePitch; 238 239 int FiringAnim; 240 int Expression; 241 int Target_Expression; 242 int Blink; 243 int SpotFlag; 244 245 NPC_AVOIDANCEMANAGER avoidanceManager; 246 WAYPOINT_MANAGER waypointManager; 247 248 }MARINE_STATUS_BLOCK; 249 250 typedef enum marine_npc_weapons { 251 252 MNPCW_PulseRifle, 253 MNPCW_Flamethrower, 254 MNPCW_Smartgun, 255 MNPCW_SADAR, 256 MNPCW_GrenadeLauncher, 257 MNPCW_Minigun, 258 MNPCW_MShotgun, 259 MNPCW_MPistol, 260 MNPCW_MFlamer, 261 MNPCW_MUnarmed, 262 MNPCW_MMolotov, 263 MNPCW_PistolMarine, 264 MNPCW_Android, 265 MNPCW_AndroidSpecial, 266 MNPCW_Android_Pistol_Special, 267 MNPCW_Scientist_A, 268 MNPCW_Scientist_B, 269 MNPCW_TwoPistols, 270 MNPCW_Skeeter, 271 MNPCW_End, 272 273 } MARINE_NPC_WEAPONS; 274 275 /*-------------------------------------------- 276 Tools data template 277 --------------------------------------------*/ 278 typedef struct tools_data_marine 279 { 280 struct vectorch position; 281 struct vectorch facing_point; 282 int shapeIndex; 283 char nameID[SB_NAME_LENGTH]; 284 MARINE_MISSION Mission; 285 char death_target_ID[SB_NAME_LENGTH]; 286 int death_target_request; 287 288 enum marine_npc_weapons marine_type; 289 290 int path; 291 int stepnumber; 292 293 int textureID; 294 295 }TOOLS_DATA_MARINE; 296 297 /*-------------------------------------------- 298 Weapon Behaviour Type. 299 --------------------------------------------*/ 300 301 302 typedef struct marine_weapon_data { 303 304 MARINE_NPC_WEAPONS id; 305 enum SFX_ID SfxID; 306 STATE_RETURN_CONDITION (*WeaponFireFunction)(STRATEGYBLOCK *); 307 void (*WeaponMisfireFunction)(SECTION_DATA *, int *); 308 STATE_RETURN_CONDITION (*WeaponPanicFireFunction)(STRATEGYBLOCK *); 309 char *Riffname; 310 char *HierarchyName; 311 char *GunflashName; 312 char *ElevationSection; 313 char *HitLocationTableName; 314 char *TemplateName; 315 char *ClipName; 316 int MinRange; 317 int ForceFireRange; 318 int MaxRange; 319 int Accuracy; 320 int FiringRate; 321 int FiringTime; 322 int MinimumBurstSize; 323 enum AMMO_ID Ammo_Type; 324 int clip_size; 325 int Reload_Sequence; 326 int TargetCallibrationShift; 327 SOUNDINDEX StartSound; 328 SOUNDINDEX LoopSound; 329 SOUNDINDEX EndSound; 330 unsigned int EnableGrenades :1; 331 unsigned int UseElevation :1; 332 unsigned int EnableTracker :1; 333 unsigned int ARealMarine :1; 334 unsigned int Android :1; 335 336 }MARINE_WEAPON_DATA; 337 338 /*-------------------------------------------- 339 Some defines.... 340 --------------------------------------------*/ 341 #define MARINE_STATE_PRINT 0 342 #define MARINE_STARTING_HEALTH 30 343 #define NO_OF_FRAGMENTS_FROM_DEAD_MARINE 10 344 // #define MARINE_NEAR_SPEED 6000 /* mm/s */ 345 /* Experiment. Can they take the ramps? */ 346 #define MARINE_NEAR_SPEED 6000 /* mm/s */ 347 #define MARINE_NEAR_VIEW_WIDTH 500 /* mm */ 348 #define MARINE_WEAPON_DAMAGE 5 349 #define MARINE_CLOSE_APPROACH_DISTANCE 3000 /* mm */ 350 #define MARINE_FIRINGPOINT_INFRONT 3000 /* 900 mm */ 351 #define MARINE_FIRINGPOINT_ACROSS 300 /* 300 mm */ 352 #define MARINE_FIRINGPOINT_UP 200 /* 200 mm */ 353 #define MARINE_FIRINGPOINT_INFRONT_CROUCHED 900 /* mm */ 354 #define MARINE_FIRINGPOINT_ACROSS_CROUCHED 200 /* mm */ 355 #define MARINE_FIRINGPOINT_UP_CROUCHED 100 /* mm */ 356 #define MARINE_WEAPON_VOLLEYSIZE (1+(FastRandom()&0x02)) /* 1,2 or 3 1/4 second bursts */ 357 #define MARINE_CHANCEOFGRENADE (3) 358 #define MARINE_TOO_CLOSE_TO_GRENADE_FOOL 3000 359 #define MARINE_PARANOIA_TIME (ONE_FIXED*10) 360 #define MARINE_PANIC_TIME (ONE_FIXED*120) 361 #define SQUAD_PARANOIA_TIME (ONE_FIXED) 362 363 /* 1.5-2 seconds in 1/16 second. NB DO NOT INCREASE THIS */ 364 #define MARINE_FAR_MOVE_TIME ((24+(FastRandom()&0x07))*(ONE_FIXED>>4)) 365 /* 1-2 seconds in 1/8ths of a second */ 366 #define MARINE_NEAR_TIMEBETWEENFIRING ((8+(FastRandom()&0x07))*(ONE_FIXED>>3)) 367 // #define MARINE_NEAR_FIRE_TIME (ONE_FIXED>>2) /* 1/4 second */ 368 #define MARINE_NEAR_FIRE_TIME (ONE_FIXED) /* 1 second */ 369 /* random time between 1 and 2 seconds,in fixed point,with granularity 1/8th second */ 370 #define MARINE_NEARWAITTIME (ONE_FIXED+((FastRandom()&0x7)*(ONE_FIXED>>3))) 371 372 #define SEAL_NEAR_SPEED 7000 373 #define SEAL_WEAPON_DAMAGE 15 374 #define SEAL_STARTING_HEALTH 150 375 376 //#define MINIGUN_IDLE_SPEED (ONE_FIXED>>2) 377 #define MINIGUN_IDLE_SPEED (0) 378 #define MINIGUN_MAX_SPEED (ONE_FIXED*20) 379 #define MINIGUN_MINIMUM_BURST (25) 380 381 /*-------------------------------------------- 382 Some prototypes... 383 --------------------------------------------*/ 384 void InitMarineBehaviour(void* bhdata, STRATEGYBLOCK *sbPtr); 385 void InitSealBehaviour(void* bhdata, STRATEGYBLOCK *sbPtr); 386 void SendRequestToMarine(STRATEGYBLOCK* sbPtr,BOOL state,int extended_data); 387 void MarineBehaviour(STRATEGYBLOCK *sbPtr); 388 void MakeMarineNear(STRATEGYBLOCK *sbPtr); 389 void MakeMarineFar(STRATEGYBLOCK *sbPtr); 390 void MarineIsDamaged(STRATEGYBLOCK *sbPtr, DAMAGE_PROFILE *damage, int multiple, int wounds,SECTION_DATA *Section, VECTORCH *incoming); 391 void WarnMarineOfAttack(STRATEGYBLOCK *marine,STRATEGYBLOCK *attacker); 392 393 DISPLAYBLOCK* AddNPCGunFlashEffect(VECTORCH *position, MATRIXCH* orientation, enum SFX_ID sfxID); 394 void RemoveNPCGunFlashEffect(DISPLAYBLOCK* dPtr); 395 void MaintainNPCGunFlashEffect(DISPLAYBLOCK* dPtr, VECTORCH *position, MATRIXCH* orientation); 396 397 int Validate_Target(STRATEGYBLOCK *target,char *SBname); 398 int Validate_Strategy(STRATEGYBLOCK *target,char *SBname); 399 AIMODULE *NearNPC_GetTargetAIModuleForRetreat(STRATEGYBLOCK *sbPtr, NPC_MOVEMENTDATA *moveData); 400 extern void InitSquad(void); 401 extern void DoSquad(void); 402 extern void ZoneAlert(int level,AIMODULE *targetModule); 403 extern void Marine_CorpseSightingTest(STRATEGYBLOCK *corpse); 404 int MarineSight_FrustrumReject(STRATEGYBLOCK *sbPtr,VECTORCH *localOffset,STRATEGYBLOCK *target); 405 406 #ifdef __cplusplus 407 408 } 409 410 #endif 411 412 413 #endif 414