| | 1 | /* CDF 11/6/98 - AI support functions moved out of bh_pred. */ |
| | 2 | |
| | 3 | #ifndef _bhais_h_ |
| | 4 | #define _bhais_h_ 1 |
| | 5 | |
| | 6 | #include "hmodel.h" |
| | 7 | #include "module.h" |
| | 8 | #include "equipmnt.h" |
| | 9 | |
| | 10 | #define NPC_MAX_VIEWRANGE (50000) |
| | 11 | |
| | 12 | #ifdef __cplusplus |
| | 13 | extern "C" { |
| | 14 | #endif |
| | 15 | |
| | 16 | /*----------------------------- |
| | 17 | General AI Support |
| | 18 | -------------------------------*/ |
| | 19 | typedef struct npc_obstructionreport |
| | 20 | { |
| | 21 | unsigned int environment :1; /* x consecutive obstructive colls against env or indestructible object */ |
| | 22 | unsigned int destructableObject :1; /* x consecutive obstructive colls against destructible object */ |
| | 23 | unsigned int otherCharacter :1; /* single collison with other npc of same type */ |
| | 24 | unsigned int anySingleObstruction :1; /* any single collision of above types */ |
| | 25 | |
| | 26 | } NPC_OBSTRUCTIONREPORT; |
| | 27 | |
| | 28 | typedef enum avoidance_substate |
| | 29 | { |
| | 30 | AvSS_FreeMovement = 0, |
| | 31 | AvSS_FirstAvoidance, |
| | 32 | AvSS_SecondAvoidance, |
| | 33 | AvSS_ThirdAvoidance |
| | 34 | |
| | 35 | } AVOIDANCE_SUBSTATE; |
| | 36 | |
| | 37 | typedef enum avoidance_return_condition |
| | 38 | { |
| | 39 | AvRC_Clear = 0, |
| | 40 | AvRC_Avoidance, |
| | 41 | AvRC_Failure |
| | 42 | |
| | 43 | } AVOIDANCE_RETURN_CONDITION; |
| | 44 | |
| | 45 | typedef struct npc_avoidancemanager |
| | 46 | { |
| | 47 | /* New structure for super-avoidance system - expand at will! */ |
| | 48 | VECTORCH avoidanceDirection; |
| | 49 | VECTORCH incidenceDirection; |
| | 50 | VECTORCH incidentPoint; |
| | 51 | |
| | 52 | VECTORCH aggregateNormal; |
| | 53 | |
| | 54 | int recommendedDistance; |
| | 55 | int timer; |
| | 56 | STRATEGYBLOCK *primaryCollision; |
| | 57 | AVOIDANCE_SUBSTATE substate; |
| | 58 | enum AMMO_ID ClearanceDamage; |
| | 59 | /* Third avoidance parameters! */ |
| | 60 | int stage; |
| | 61 | VECTORCH baseVector; |
| | 62 | VECTORCH basePoint; |
| | 63 | VECTORCH currentVector; |
| | 64 | MATRIXCH rotationMatrix; |
| | 65 | VECTORCH bestVector; |
| | 66 | int bestDistance; |
| | 67 | int bestStage; |
| | 68 | |
| | 69 | } NPC_AVOIDANCEMANAGER; |
| | 70 | |
| | 71 | #define STANDARD_AVOIDANCE_TIME (ONE_FIXED*5) |
| | 72 | #define THIRD_AVOIDANCE_MINDIST (2000) |
| | 73 | |
| | 74 | typedef struct npc_movementdata |
| | 75 | { |
| | 76 | int numObstructiveCollisions; |
| | 77 | VECTORCH avoidanceDirn; |
| | 78 | VECTORCH lastTarget; |
| | 79 | VECTORCH lastVelocity; |
| | 80 | int numReverses; |
| | 81 | AIMODULE *lastModule; |
| | 82 | |
| | 83 | } NPC_MOVEMENTDATA; |
| | 84 | |
| | 85 | typedef struct npc_wanderdata |
| | 86 | { |
| | 87 | int currentModule; |
| | 88 | VECTORCH worldPosition; |
| | 89 | |
| | 90 | } NPC_WANDERDATA; |
| | 91 | |
| | 92 | #define NPC_AVOIDTIME (ONE_FIXED<<1) |
| | 93 | #define NPC_GMD_NOPOLY (-1) |
| | 94 | #define NPC_MIN_MOVEFROMPOLYDIST (650) |
| | 95 | #define NPC_IMPEDING_COL_THRESHOLD (10) |
| | 96 | #define NPC_JUMPSPEED (55) /* mm/s */ |
| | 97 | #define NPC_JUMPHEIGHT (1000) |
| | 98 | //#define NPC_TURNRATE (ONE_FIXED) /* thro' 360 degrees */ |
| | 99 | #define NPC_TURNRATE (4096) |
| | 100 | #define NPC_DEATHTIME (ONE_FIXED>>1) |
| | 101 | #define NPC_TARGETPOINTELEVATION (-400) |
| | 102 | #define NPC_INANIMATEOBJECTDAMAGE (10000) |
| | 103 | #define NPC_NOWANDERMODULE (-1) |
| | 104 | #define NPC_BIMBLINGINMODULE (-2) |
| | 105 | #define NUM_ATTACKFLAGS (3) |
| | 106 | |
| | 107 | typedef struct hit_facing |
| | 108 | { |
| | 109 | unsigned int Front: 1; |
| | 110 | unsigned int Back: 1; |
| | 111 | unsigned int Left: 1; |
| | 112 | unsigned int Right: 1; |
| | 113 | |
| | 114 | } HIT_FACING; |
| | 115 | |
| | 116 | typedef struct death_data |
| | 117 | { |
| | 118 | int Sequence_Type; |
| | 119 | int Sub_Sequence; |
| | 120 | int TweeningTime; |
| | 121 | int Sequence_Length; |
| | 122 | int Multiplayer_Code; |
| | 123 | int Unique_Code; //unique across all deaths - for saving |
| | 124 | int wound_flags; /* HModel wound flags */ |
| | 125 | int priority_wounds; |
| | 126 | unsigned int Template:1; |
| | 127 | HIT_FACING Facing; |
| | 128 | unsigned int Burning:1; |
| | 129 | unsigned int Electrical:1; |
| | 130 | unsigned int Crouching:1; |
| | 131 | unsigned int MinorBoom:1; |
| | 132 | unsigned int MajorBoom:1; |
| | 133 | |
| | 134 | } DEATH_DATA; |
| | 135 | |
| | 136 | typedef struct attack_data |
| | 137 | { |
| | 138 | int Sequence_Type; |
| | 139 | int Sub_Sequence; |
| | 140 | int TweeningTime; |
| | 141 | int Sequence_Length; |
| | 142 | int Multiplayer_Code; |
| | 143 | int Unique_Code; //unique across all attacks - for saving |
| | 144 | int wound_flags; |
| | 145 | enum AMMO_ID flag_damage[NUM_ATTACKFLAGS]; |
| | 146 | unsigned int Crouching:1; |
| | 147 | unsigned int Pouncing:1; |
| | 148 | |
| | 149 | } ATTACK_DATA; |
| | 150 | |
| | 151 | typedef enum movement_data_index |
| | 152 | { |
| | 153 | MDI_Marine_Mooch_Bored=0, |
| | 154 | MDI_Marine_Mooch_Alert, |
| | 155 | MDI_Marine_Combat, |
| | 156 | MDI_Marine_Sprint, |
| | 157 | MDI_Civilian_Mooch_Bored, |
| | 158 | MDI_Civilian_Mooch_Alert, |
| | 159 | MDI_Civilian_Combat, |
| | 160 | MDI_Civilian_Sprint, |
| | 161 | MDI_Predator, |
| | 162 | MDI_Casual_Predator, |
| | 163 | MDI_Xenoborg, |
| | 164 | MDI_End |
| | 165 | |
| | 166 | } MOVEMENT_DATA_INDEX; |
| | 167 | |
| | 168 | typedef struct movement_data |
| | 169 | { |
| | 170 | MOVEMENT_DATA_INDEX index; |
| | 171 | unsigned int maxSpeed; |
| | 172 | unsigned int acceleration; |
| | 173 | |
| | 174 | } MOVEMENT_DATA; |
| | 175 | |
| | 176 | extern int CheckAdjacencyValidity(AIMODULE *target,AIMODULE *source,int alien); |
| | 177 | extern int AIModuleIsVisible(AIMODULE *aimodule); |
| | 178 | extern int NPC_IsDead(STRATEGYBLOCK *sbPtr); |
| | 179 | extern void NPC_InitMovementData(NPC_MOVEMENTDATA *moveData); |
| | 180 | extern void NPC_IsObstructed(STRATEGYBLOCK *sbPtr, NPC_MOVEMENTDATA *moveData, NPC_OBSTRUCTIONREPORT *details, STRATEGYBLOCK **destructableObject); |
| | 181 | extern int NPC_CannotReachTarget(NPC_MOVEMENTDATA *moveData, VECTORCH* thisTarget, VECTORCH* thisVelocity); |
| | 182 | extern void NPCGetAvoidanceDirection(STRATEGYBLOCK *sbPtr, VECTORCH *velocityDirection, NPC_OBSTRUCTIONREPORT *details); |
| | 183 | extern void NPCGetTargetPosition(VECTORCH *targetPoint,STRATEGYBLOCK *target); |
| | 184 | extern int NPCSetVelocity(STRATEGYBLOCK *sbPtr, VECTORCH* targetDirn, int in_speed); |
| | 185 | extern int NPCOrientateToVector(STRATEGYBLOCK *sbPtr, VECTORCH *zAxisVector, int turnspeed); |
| | 186 | extern void NPCGetMovementTarget(STRATEGYBLOCK *sbPtr, STRATEGYBLOCK *target, VECTORCH *targetPosition, int* targetIsAirduct,int alien); |
| | 187 | extern void NPCGetMovementDirection(STRATEGYBLOCK *sbPtr, VECTORCH *velocityDirection, VECTORCH* target, WAYPOINT_MANAGER *waypointManager); |
| | 188 | extern void NPC_InitWanderData(NPC_WANDERDATA *wanderData); |
| | 189 | extern void NPC_FindAIWanderTarget(STRATEGYBLOCK *sbPtr, NPC_WANDERDATA *wanderData, NPC_MOVEMENTDATA *moveData, int alien); |
| | 190 | extern AIMODULE *GetNextModuleForLink(AIMODULE *source,AIMODULE *target,int max_depth,int alien); |
| | 191 | extern AIMODULE *GetNextModuleForLink_Core(AIMODULE *source,AIMODULE *target,int max_depth,int visibility_check,int alien); |
| | 192 | extern int GetNextModuleInPath(int current_module, int path); |
| | 193 | extern AIMODULE *TranslatePathIndex(int current_module, int path); |
| | 194 | extern int NPCCanSeeTarget(STRATEGYBLOCK *sbPtr, STRATEGYBLOCK *target); |
| | 195 | |
| | 196 | extern DEATH_DATA *GetAlienDeathSequence(HMODELCONTROLLER *controller, const SECTION *TemplateRoot,int wound_flags,int priority_wounds, |
| | 197 | int hurtiness,HIT_FACING *facing,int burning,int crouching,int electrical); |
| | 198 | |
| | 199 | extern DEATH_DATA *GetMarineDeathSequence(HMODELCONTROLLER *controller, const SECTION *TemplateRoot,int wound_flags,int priority_wounds, |
| | 200 | int hurtiness,HIT_FACING *facing,int burning,int crouching,int electrical); |
| | 201 | |
| | 202 | extern DEATH_DATA *GetPredatorDeathSequence(HMODELCONTROLLER *controller, const SECTION *TemplateRoot,int wound_flags,int priority_wounds, |
| | 203 | int hurtiness,HIT_FACING *facing,int burning,int crouching,int electrical); |
| | 204 | |
| | 205 | extern DEATH_DATA *GetXenoborgDeathSequence(HMODELCONTROLLER *controller, const SECTION *TemplateRoot,int wound_flags,int priority_wounds, |
| | 206 | int hurtiness,HIT_FACING *facing,int burning,int crouching,int electrical); |
| | 207 | |
| | 208 | extern DEATH_DATA *GetThisDeath_FromCode(DEATH_DATA *FirstDeath,int code); |
| | 209 | extern DEATH_DATA *GetThisDeath_FromUniqueCode(int code); |
| | 210 | |
| | 211 | extern ATTACK_DATA *GetAlienAttackSequence(HMODELCONTROLLER *controller,int wound_flags,int crouching); |
| | 212 | extern ATTACK_DATA *GetAlienPounceAttack(HMODELCONTROLLER *controller,int wound_flags,int crouching); |
| | 213 | extern ATTACK_DATA *GetWristbladeAttackSequence(HMODELCONTROLLER *controller,int wound_flags,int crouching); |
| | 214 | extern ATTACK_DATA *GetPredStaffAttackSequence(HMODELCONTROLLER *controller,int wound_flags,int crouching); |
| | 215 | |
| | 216 | extern ATTACK_DATA *GetThisAttack_FromUniqueCode(int code);//for loading |
| | 217 | |
| | 218 | extern AIMODULE *NearNPC_GetTargetAIModuleForRetreat(STRATEGYBLOCK *sbPtr, NPC_MOVEMENTDATA *moveData); |
| | 219 | extern AIMODULE *General_GetAIModuleForRetreat(STRATEGYBLOCK *sbPtr,AIMODULE *fearModule,int max_depth); |
| | 220 | /* All New Avoidance Code! */ |
| | 221 | extern int New_NPC_IsObstructed(STRATEGYBLOCK *sbPtr, NPC_AVOIDANCEMANAGER *manager); |
| | 222 | extern void Initialise_AvoidanceManager(NPC_AVOIDANCEMANAGER *manager); |
| | 223 | extern AVOIDANCE_RETURN_CONDITION AllNewAvoidanceKernel(STRATEGYBLOCK *sbPtr,NPC_AVOIDANCEMANAGER *manager); |
| | 224 | /* All New Avoidance Code! */ |
| | 225 | extern const MOVEMENT_DATA *GetThisMovementData(MOVEMENT_DATA_INDEX index); |
| | 226 | extern void AlignVelocityToGravity(STRATEGYBLOCK *sbPtr,VECTORCH *velocity); |
| | 227 | |
| | 228 | extern int Observer; |
| | 229 | |
| | 230 | typedef struct pathheader |
| | 231 | { |
| | 232 | int path_length; |
| | 233 | AIMODULE** modules_in_path; |
| | 234 | |
| | 235 | } PATHHEADER; |
| | 236 | |
| | 237 | extern int PathArraySize; |
| | 238 | extern PATHHEADER* PathArray; |
| | 239 | |
| | 240 | #ifdef __cplusplus |
| | 241 | } |
| | 242 | #endif |
| | 243 | |
| | 244 | #endif |