46 RayEnd = rayStart +
Math.SqrFloat(coneLength) * dir;
57 TargetableObjects = targetableObjects;
68 float ComponentDistance2;
81 vector coneOrigin = settings.ConeOrigin;
82 float coneLength = settings.ConeLength;
83 float coneHalfAngle = settings.ConeHalfAngle;
84 float radAngle = settings.ConeHalfAngleRad;
85 float coneMinHeight = settings.ConeMinHeight;
86 float coneMaxHeight = settings.ConeMaxHeight;
88 vector coneLeft = settings.ConeLeftPoint;
89 vector coneRight = settings.ConeRightPoint;
91 vector rayStart = settings.RayStart;
92 vector rayEnd = settings.RayEnd;
94 vector xzDir = settings.XZDir;
95 float maxDist = settings.MaxDist;
97 EntityAI pToIgnore = settings.Attacker;
101 float boxWidth =
vector.Distance(coneLeft, coneRight);
102 float boxHeight = coneMaxHeight - coneMinHeight;
104 vector boxSize =
Vector(boxWidth, boxHeight, coneLength);
107 vector centerHeight =
Vector(0,
Math.Lerp(coneMinHeight, coneMaxHeight, 0.5), 0);
108 vector offset = xzDir * coneLength * 0.5;
109 vector boxCenter = coneOrigin + offset + centerHeight;
113 params.SetParams(boxCenter, xzDir.VectorToAngles(), boxSize, ObjIntersect.Fire, ObjIntersect.Fire,
true);
116 if (
GetGame().IsBoxCollidingGeometryProxy(params, toIgnore, results))
119 float retVal =
float.MAX;
120 float tgAngle =
Math.Tan(radAngle);
122 #ifdef DIAG_DEVELOPER
128 foreach (BoxCollidingResult bResult : results)
133 if (!obj.IsAnyInherited(targetableObjects) || !obj.IsAlive())
139 vector targetPos = obj.GetPosition();
140 float targetAngle =
Math.RAD2DEG *
Math.AbsFloat(
Math3D.AngleFromPosition(coneOrigin, dir, targetPos));
141 float targetDistance2 =
vector.DistanceSq(targetPos,
Math3D.NearestPoint(rayStart, rayEnd, targetPos));
142 int hitComponent = -1;
144 float csSum =
float.MAX;
150 targetPos = result.ComponentPos;
151 targetAngle = result.ComponentAngle;
152 targetDistance2 = result.ComponentDistance2;
153 hitComponent = result.ComponentIdx;
157 if (bResult.proxyInfo)
159 foreach (BoxCollidingResult pInfo : bResult.proxyInfo)
163 targetPos = result.ComponentPos;
164 targetAngle = result.ComponentAngle;
165 targetDistance2 = result.ComponentDistance2;
166 hitComponent = result.ComponentIdx;
172 if (hitComponent == -1 || csSum ==
float.
MAX)
178 float sum = targetDistance2;
185 allTargets.Insert(obj);
200 foreach (ComponentInfo cInfo : bResult.componentInfo)
210 float cSum = cResult.ComponentDistance2;
218 return result !=
null;
229 foreach (
string zoneName: blacklistedDamageZones)
231 if (obj.GetDamageZoneNameByComponentIndex(cInfo.component) == zoneName)
237 vector componentPos = cInfo.componentCenter;
240 float componentMaxDist2 =
Math.SqrFloat(settings.MaxDist + cInfo.componentRadius * obj.GetScale());
241 vector nearestPoint =
Math3D.NearestPoint(settings.RayStart, settings.RayEnd, componentPos);
242 float componentDistance2 =
vector.DistanceSq(componentPos, nearestPoint);
243 if (componentDistance2 > componentMaxDist2)
251 float componentAngle =
Math.RAD2DEG *
Math.AbsFloat(
Math3D.AngleFromPosition(settings.ConeOrigin, settings.XZDir, componentPos));
252 if (componentAngle > settings.ConeHalfAngle)
264 result.ComponentPos = componentPos;
265 result.ComponentAngle = componentAngle;
266 result.ComponentDistance2 = componentDistance2;
267 result.ComponentIdx = cInfo.component;
279 if (rayStart == rayEnd)