-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathaikillmine.c
executable file
·118 lines (97 loc) · 3.07 KB
/
aikillmine.c
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
#include <stdio.h>
#include <math.h>
#include "main.h"
#include "new3d.h"
#include "quat.h"
#include "mload.h"
#include "compobjects.h"
#include "bgobjects.h"
#include "object.h"
#include "node.h"
#include "networking.h"
#include "ships.h"
#include "text.h"
#include "triggers.h"
#include "sphere.h"
#include "pickups.h"
#include "enemies.h"
#include "ai.h"
#include "secondary.h"
#include "primary.h"
#ifdef OPT_ON
#pragma optimize( "gty", on )
#endif
// Externals
extern float framelag;
extern AIMDATA AimData;
extern VECTOR Forward;
extern VECTOR SlideUp;
extern PRIMARYWEAPONATTRIB PrimaryWeaponAttribs[];
extern SECONDARYWEAPONATTRIB SecondaryWeaponAttribs[];
extern SECONDARYWEAPONBULLET SecBulls[MAXSECONDARYWEAPONBULLETS];
/*===================================================================
Procedure : AIR KillMine
Input : ENEMY * Enemy
Output : Nothing
===================================================================*/
void AI_AIR_KILLMINE( register ENEMY * Enemy )
{
OBJECT * SObject;
VECTOR TempVector;
VECTOR TempUpVector;
VECTOR TempOffset = { 0.0F, 0.0F, 0.0F };
BYTE Weapon;
SObject = &Enemy->Object;
// Is it time to think???
AI_THINK( Enemy , false , false);
Enemy->Timer -= framelag;
if( Enemy->Timer < 0.0F )
Enemy->Timer = 0.0F;
Enemy->PrimaryFireTimer -= framelag;
if( Enemy->PrimaryFireTimer < 0.0F )
Enemy->PrimaryFireTimer = 0.0F;
if( !(Enemy->AIFlags &AI_MINEAVOID) )
{
Enemy->AIFlags &= ~(AI_MINEAVOID + AI_MINEISCLOSE);
AI_SetFOLLOWPATH( Enemy );
return;
}
Enemy->AIFlags &= ~AI_MINEAVOID;
AI_UPDATEGUNS( Enemy );
// Aim at target
AI_AimAtTarget( &SObject->InvMat , &SObject->Pos, &Enemy->MinePos );
if( !( EnemyTypes[Enemy->Type].Behave.Flags & AI_BEHAVIOUR_ICANTPITCH ) )
{
Enemy->AIMoveFlags |= AimData.Flags;
}else{
//This enemy cant look up or down so it has to move up and down to compensate....
Enemy->AIMoveFlags |= ( AimData.Flags & ( AI_CONTROL_TURNLEFT + AI_CONTROL_TURNRIGHT ) );
if( AimData.Flags & AI_CONTROL_TURNUP )
{
Enemy->AIMoveFlags |= AI_CONTROL_UP;
}else if( AimData.Flags & AI_CONTROL_TURNDOWN )
{
Enemy->AIMoveFlags |= AI_CONTROL_DOWN;
}
}
if( Enemy->AvoidTimer && Enemy->AvoidType )
{
Enemy->AIMoveFlags = Enemy->AvoidType;
}else{
Enemy->AvoidTimer = 0.0F;
ApplyMatrix( &SObject->Mat, &Forward, &TempVector );
ApplyMatrix( &SObject->Mat, &SlideUp, &TempUpVector );
if( !(Enemy->Object.Flags & SHIP_Scattered ) && (Enemy->PrimaryFireTimer == 0.0F) && ( EnemyTypes[Enemy->Type].PrimaryWeaponType != NO_PRIMARY ) )
{
Enemy->PrimaryFireTimer = EnemyTypes[Enemy->Type].PrimaryFireRate + (float) Random_Range( (u_int16_t) EnemyTypes[Enemy->Type].PrimaryFireRate );
Weapon = BodgePrimaryWeapon( EnemyTypes[Enemy->Type].PrimaryWeaponType, Enemy->PickupHeld );
EnemyFirePrimary( OWNER_ENEMY, Enemy->Index, ++Enemy->BulletID, Weapon,
Enemy->Object.Group, &Enemy->Object.Pos, &TempOffset, &TempVector, &TempUpVector,
EnemyTypes[Enemy->Type].PowerLevel, 0.0F, false, NULL );
}
}
Enemy->AI_Angle = AimData.Angle;
}
#ifdef OPT_ON
#pragma optimize( "", off )
#endif