-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaiaware.h
209 lines (154 loc) · 4.27 KB
/
aiaware.h
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
@Copyright Looking Glass Studios, Inc.
1996,1997,1998,1999,2000 Unpublished Work.
*/
///////////////////////////////////////////////////////////////////////////////
// $Header: r:/t2repos/thief2/src/ai/aiaware.h,v 1.9 2000/01/04 19:28:50 BFarquha Exp $
//
//
//
#ifndef __AIAWARE_H
#define __AIAWARE_H
#include <aitype.h>
#include <aiutils.h>
#include <linktype.h>
F_DECLARE_INTERFACE(IRelation);
#pragma once
#pragma pack(4)
///////////////////////////////////////////////////////////////////////////////
void AIInitAwareness();
void AITermAwareness();
///////////////////////////////////////
//
// Awareness links. It is *strongly* recommended code use the functions on
// IInternalAI and IAISenses to access these.
//
extern IRelation * g_pAIAwarenessLinks;
///////////////////////////////////////////////////////////////////////////////
//
// Enums and constants
//
enum eAIAwarenessFlags
{
// The object can be sensed
kAIAF_Seen = 0x01,
kAIAF_Heard = 0x02,
kAIAF_Sensed = (kAIAF_Seen | kAIAF_Heard),
// Could have LOS if had 360 vision
kAIAF_CanRaycast = 0x04,
// Have line of sight
kAIAF_HaveLOS = 0x08,
// Blind to the object
kAIAF_Blind = 0x10,
// Deaf to the object
kAIAF_Deaf = 0x20,
kAIAF_Highest = 0x40,
kAIAF_FirstHand = 0x80,
kAIAF_Freshened = 0x0100
};
///////////////////////////////////////////////////////////////////////////////
//
// STRUCT: sAIAwareCapacitor
//
// Describes how long it takes, in the absense of stimulation, for an awareness
// link to "cool down"
//
struct sAIAwareCapacitor
{
union
{
struct
{
// Time to discharge from 1 to 0
int low;
// Time to discharge from 2 to 1
int medium;
// Time to discharge from 3 to 2
int high;
};
int dischargeTimes[3];
};
// For future use
int reserved;
};
///////////////////////////////////////
extern sAIAwareCapacitor g_AIDefAwareCap;
///////////////////////////////////////////////////////////////////////////////
//
// Reaction times
//
struct sAIAwareDelay
{
unsigned toTwo;
unsigned toThree;
unsigned twoReuse;
unsigned threeReuse;
unsigned ignoreRange;
};
///////////////////////////////////////////////////////////////////////////////
//
// STRUCT: sAIAwareness
//
// Describes how aware of an object an AI is
//
struct sAIAwareness
{
sAIAwareness()
{
memset(this, 0, sizeof(*this));
}
eAIAwareLevel DecLev()
{
return (eAIAwareLevel)(--(*((int *)&level)));
}
eAIAwareLevel IncLev()
{
return (eAIAwareLevel)(++(*((int *)&level)));
}
BOOL ValidLastPos() const
{
return !(lastPos.x == FLT_MAX && lastPos.y == FLT_MAX && lastPos.z == FLT_MAX);
}
ulong TimeSinceContact() const
{
return AIGetTime() - lastContact;
}
// Of what the awareness pertains
ObjID object;
// Flags
unsigned flags;
// Current awareness
eAIAwareLevel level;
// Highest awareness of object
eAIAwareLevel peak;
// Time entered current level
int time;
// Time of last contact
int lastContact;
// Location of last contact
mxs_vector lastPos;
// Level of last pulse
eAIAwareLevel lastPulse;
// Vision cone, if any, that is the source of the awareness
int sourceCone;
// Vision management data
ulong updateTime;
ulong LOSTime;
LinkID linkID;
// True last contact (ignoring forced freshness)
int trueLastContact;
int freshness;
// Set first time going to high alert.
BOOL bDidHighAlert;
};
///////////////////////////////////////
EXTERN sAIAwareness g_AINullAwarenessScratch;
inline const sAIAwareness * AINullAware(ObjID object)
{
g_AINullAwarenessScratch.object = object;
g_AINullAwarenessScratch.lastPos = kInvalidLoc;
return &g_AINullAwarenessScratch;
}
///////////////////////////////////////////////////////////////////////////////
#pragma pack()
#endif /* !__AIAWARE_H */