95 {
96
98
100
103
104 float retVal = dist * 2;
106
107
108
110 {
111 if (ent == pToIgnore)
112 {
113 continue;
114 }
115
117 if(obj)
118 {
119
120 if( !obj.IsAnyInherited(targetableObjects) )
121 { continue; }
122
123 if( !obj.IsAlive() )
124 { continue; }
125 }
126
127 vector entpos = ent.GetPosition();
128
129 vector diff = entpos - pos;
131 if (cDistSq > dist*dist)
132 {
133
134 continue;
135 }
136
137 float frontDist = diff[0]*dir[0] + diff[2]*dir[2];
138 if (frontDist < 0.1)
139 {
140
141 continue;
142 }
143
144 vector project = pos + dir * frontDist;
145 vector posdiff =
Vector(project[0] - entpos[0], 0, project[2] - entpos[2]);
146 float sideDist = posdiff.
LengthSq();
147
148 if (sideDist > tgAngle)
149 {
150
151 continue;
152 }
153
154 float sum = frontDist + sideDist;
155 if (sum < retVal)
156 {
157 ret = ent;
158 retVal = sum;
159 }
160 else
161 {
162
163 }
164
165
166
167
168
169 allTargets.Insert(ent);
170 }
171
172 return ret;
173 }
static ref array< Object > m_CachedEntList
static proto native void GetEntitiesInCone(vector pos, vector dir, float angle, float dist, float minHeigh, float maxHeight, out array< Object > entList)
static void InitCachedEntList()
Super root of all classes in Enforce script.
proto native float LengthSq()
Returns squared length (magnitudeSqr)
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Tan(float angle)
Returns tangent of angle in radians.
static const float DEG2RAD