1 /*--------------Patrick 7/11/96----------------
2   Header file for Alien AI support functions
3   ---------------------------------------------*/
4 
5 #ifndef _bhalien_h_
6 	#define _bhalien_h_ 1
7 
8 
9 	#ifdef __cplusplus
10 
11 		extern "C" {
12 
13 	#endif
14 
15 #include "bh_pred.h"
16 
17  /*--------------------------------------------
18    Enum of alien behaviour states
19    --------------------------------------------*/
20 
21  typedef enum AlienBhState
22  {
23    ABS_Wait,
24    ABS_Approach,
25    ABS_Hunt,
26    ABS_Wander,
27    ABS_Retreat,
28    ABS_Attack,
29    ABS_Avoidance,
30    ABS_Dying,
31    ABS_Pounce,
32    ABS_Jump,
33    ABS_Dormant,
34    ABS_Awakening,
35    ABS_Taunting,
36  }ALIEN_BHSTATE;
37 
38  /*--------------------------------------------
39   Enum of alien animation sequences
40   --------------------------------------------*/
41 
42  typedef enum AlienSequence
43  {
44 	ASQ_Run,
45  	ASQ_StandingAttack_Claw,
46  	ASQ_Crawl,
47 	ASQ_Stand,
48 	ASQ_Crouch,
49 	ASQ_CrouchedAttack_Claw,
50 	ASQ_CrawlingAttack_Claw,
51 	ASQ_RunningAttack_Claw,
52 	ASQ_Pain,
53 	ASQ_Jump,
54 	/* Additions by ChrisF, 20/4/98 */
55 	ASQ_StandingTailPoise,
56 	ASQ_StandingTailStrike,
57 	ASQ_CrouchedTailPoise,
58 	ASQ_CrouchedTailStrike,
59 	ASQ_RunningTailPoise,
60 	ASQ_RunningTailStrike,
61 	ASQ_CrawlingTailPoise,
62 	ASQ_CrawlingTailStrike,
63 	ASQ_Eat,
64 	ASQ_Pounce,
65 	ASQ_JumpingTailPoise,
66 	ASQ_JumpingTailStrike,
67 	ASQ_Taunt,
68 	ASQ_CrouchEat,
69 	ASQ_Scamper,
70 	/* More additions for reversing, 8/5/98 */
71 	ASQ_Run_Backwards,
72  	ASQ_Crawl_Backwards,
73 	ASQ_RunningAttack_Claw_Backwards,
74 	ASQ_RunningTailPoise_Backwards,
75 	ASQ_RunningTailStrike_Backwards,
76 	ASQ_CrawlingTailPoise_Backwards,
77 	ASQ_CrawlingTailStrike_Backwards,
78 	ASQ_CrawlingAttack_Claw_Backwards,
79 	ASQ_Scamper_Backwards,
80  }ALIEN_SEQUENCE;
81 
82  #include "sequnces.h"
83 
84  typedef enum AlienMissions {
85  	AM_UndefinedBehaviour, // Should do nothing.
86  	AM_Hunt,
87  	AM_GlobalHunt,
88  } ALIEN_MISSION;
89 
90  typedef enum AlienType {
91  	AT_Standard=0,
92 	AT_Predalien,
93 	AT_Praetorian,
94  } ALIEN_TYPE;
95 
96  /*--------------------------------------------
97   Alien behaviour data block
98   --------------------------------------------*/
99  typedef struct alienStatusBlock
100  {
101 	ALIEN_TYPE Type;
102 	signed char Health;
103 	int GibbFactor;
104 	int MaxSpeed;
105 	int Wounds;
106 	int last_anim_length;
107 	ALIEN_BHSTATE BehaviourState;
108 	ATTACK_DATA *current_attack;
109 	int PounceDetected;
110 	int JumpDetected;
111 	int EnablePounce;
112 	int EnableWaypoints;
113 	int PreferToCrouch;
114 
115 	MODULE *my_containing_module;
116 	AIMODULE *huntingModule;
117 
118 	int incidentFlag;
119 	int incidentTimer;
120 
121 	STRATEGYBLOCK *Target;
122 	char Target_SBname[SB_NAME_LENGTH];
123 	ALIEN_MISSION Mission;
124 
125 	int CurveRadius;
126 	int CurveLength;
127 	int CurveTimeOut;
128 	int FarStateTimer;
129 	int NearStateTimer;
130 	int IAmCrouched;
131 	NPC_MOVEMENTDATA moveData;
132 	NPC_WANDERDATA wanderData;
133 
134 	NPC_AVOIDANCEMANAGER avoidanceManager;
135 	WAYPOINT_MANAGER waypointManager;
136 
137 	HMODELCONTROLLER HModelController;
138 
139 	char death_target_ID[SB_NAME_LENGTH]; //another strategy can be notified of the alien's death
140 	STRATEGYBLOCK* death_target_sbptr;
141 
142 	STRATEGYBLOCK* generator_sbptr;//0 unless created by a generator
143 
144 	DPID aliensIgniterId;//Which player in a multiplayer game toasted this poor beast?
145 
146 	int soundHandle;
147 	int soundHandle2;
148 
149 	/*The following three values are used by the extrapolation code for network games.
150 	It doesn't particularly matter if they aren't initialised*/
151 	int timeOfLastSend;
152 	VECTORCH lastFacingSent;
153 	VECTORCH lastVelocitySent;
154 
155  }ALIEN_STATUS_BLOCK;
156 
157 
158  /*--------------------------------------------
159   Tools data template
160   --------------------------------------------*/
161  typedef struct tools_data_alien
162  {
163 	struct vectorch position;
164 	int shapeIndex;
165 	char nameID[SB_NAME_LENGTH];
166 	char death_target_ID[SB_NAME_LENGTH];
167 	ALIEN_TYPE type;
168 	int start_inactive;
169 	struct euler starteuler;
170  }TOOLS_DATA_ALIEN;
171 
172 
173 
174 /*--------------------------------------------
175   Defines
176   --------------------------------------------*/
177 
178 	#define ULTRAVIOLENCE						0
179 	#define ALIEN_STATE_PRINT					0
180 	#define WOUNDING_SPEED_EFFECTS				1
181 
182   	#define ALIEN_STARTING_HEALTH				(30)
183 	#define NO_OF_FRAGMENTS_FROM_DEAD_ALIEN (10)
184 
185   	/* random time between 1.5 and 2 seconds,in fixed point, with granularity 1/32th second */
186 	#if ULTRAVIOLENCE
187   	#define ALIEN_FAR_MOVE_TIME					((48+(FastRandom()&0xF))*(ONE_FIXED>>7))
188 	#else
189   	#define ALIEN_FAR_MOVE_TIME					((48+(FastRandom()&0xF))*(ONE_FIXED>>5))
190 	#endif
191 	/* random time between 1.5 and 2 seconds,in fixed point, with granularity 1/32th second */
192   	#define ALIEN_FAR_RETREAT_TIME				((48+(FastRandom()&0xF))*(ONE_FIXED>>5))
193 	#define ALIEN_JUMPVELOCITY 					(8000)
194 	#define ALIEN_FORWARDVELOCITY 				(12000)
195 	#define ALIEN_CURVEDISTANCE 				(8000)
196 	#define ALIEN_ATTACKDISTANCE_MIN			(2000)
197 	/* Above (1500) for Ken: reduced from 2000 */
198 	/* 1/6/98, changed back to 2000.  It was well bust. */
199 	#define ALIEN_ATTACKDISTANCE_MAX			(4000)
200 	#define ALIEN_ATTACKRANGE 					(3000)
201 	/* Range check for damage validity. */
202 	#define ALIEN_ATTACKTIME 					(ONE_FIXED>>1)
203 	/* random time between 1 and 2 seconds,in fixed point,with granularity 1/8th second */
204 	#define ALIEN_NEARWAITTIME					(ONE_FIXED+((FastRandom()&0x7)*(ONE_FIXED>>3)))
205 
206 	#define PREDALIEN_SPEED_FACTOR				((ONE_FIXED*8)/10)
207 	#define PRAETORIAN_SPEED_FACTOR				((ONE_FIXED*8)/10)
208 	#define PRAETORIAN_WALKSPEED_FACTOR			((ONE_FIXED*6)/5)
209 	#define PRAETORIAN_CRAWLSPEED_FACTOR		(ONE_FIXED*2)
210 
211 	#define ALIEN_POUNCE_MAXRANGE 				(12000)
212 	#define ALIEN_POUNCE_STARTMAXRANGE 			(8000)
213 	#define ALIEN_POUNCE_MINRANGE 				(3000)
214 	#define ALIEN_JUMP_SPEED					(25000)
215 	#define PREDALIEN_JUMP_SPEED				(25000)
216 	#define PRAETORIAN_JUMP_SPEED				(25000)
217 
218 	#define ALIEN_JUMPINESS						(13106)
219 	#define PREDALIEN_JUMPINESS					(13106)
220 	#define PRAETORIAN_JUMPINESS				(13106)
221 
222 	#define ALIEN_MASS							(160)
223 	#define PREDALIEN_MASS						(200)
224 	#define PRAETORIAN_MASS						(250)
225 
226 	#define ALL_NEW_AVOIDANCE_ALIEN				0
227 
228 /*--------------------------------------------
229   Prototypes
230   --------------------------------------------*/
231 
232 	void CreateAlienDynamic(STRATEGYBLOCK *Generator , ALIEN_TYPE type_of_alien);
233 	void InitAlienBehaviour(void* bhdata, STRATEGYBLOCK *sbPtr);
234 	void AlienBehaviour(STRATEGYBLOCK *sbPtr);
235 	void AlienIsDamaged(STRATEGYBLOCK *sbPtr, DAMAGE_PROFILE *damage, int multiple, int wounds,SECTION_DATA *Section,VECTORCH *incoming,DISPLAYBLOCK *frag);
236  	void MakeAlienNear(STRATEGYBLOCK *sbPtr);
237 	void MakeAlienFar(STRATEGYBLOCK *sbPtr);
238 	int AlienShouldBeCrawling(STRATEGYBLOCK *sbPtr);
239 	void SetAlienShapeAnimSequence(STRATEGYBLOCK *sbPtr,HMODEL_SEQUENCE_TYPES type, int subtype, int length);
240 	void SetAlienShapeAnimSequence_Core(STRATEGYBLOCK *sbPtr,HMODEL_SEQUENCE_TYPES type, int subtype, int length, int tweeningtime);
241 	int AlienIsAwareOfTarget(STRATEGYBLOCK *sbPtr);
242 	int AlienHasPathToOfTarget(STRATEGYBLOCK *sbPtr);
243 	int GetAlienSpeedFactor(STRATEGYBLOCK *sbPtr);
244 	int GetAlienSpeedFactor_ForSequence(STRATEGYBLOCK *sbPtr, HMODEL_SEQUENCE_TYPES sequence_type,int subsequence);
245 	void RecomputeAlienSpeed(STRATEGYBLOCK *sbPtr);
246 	void Alien_GoToApproach(STRATEGYBLOCK *sbPtr);
247 	void Alien_Awaken(STRATEGYBLOCK *sbPtr);
248 	int AlienIsCrawling(STRATEGYBLOCK *sbPtr);
249     void DoAlienLimbLossSound(VECTORCH *position);
250 
251 	#ifdef __cplusplus
252 
253 		}
254 
255 	#endif
256 
257 
258 #endif
259