77 {
79
80
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;
87
88 vector coneLeft = settings.ConeLeftPoint;
89 vector coneRight = settings.ConeRightPoint;
90
91 vector rayStart = settings.RayStart;
92 vector rayEnd = settings.RayEnd;
94 vector xzDir = settings.XZDir;
95 float maxDist = settings.MaxDist;
96
97 EntityAI pToIgnore = settings.Attacker;
99
100
102 float boxHeight = coneMaxHeight - coneMinHeight;
103
104 vector boxSize =
Vector(boxWidth, boxHeight, coneLength);
105
106
108 vector offset = xzDir * coneLength * 0.5;
109 vector boxCenter = coneOrigin + offset + centerHeight;
110
111
116 if (
GetGame().IsBoxCollidingGeometryProxy(params, toIgnore, results))
117 {
118
119 float retVal = float.MAX;
120 float tgAngle =
Math.
Tan(radAngle);
121
122 #ifdef DIAG_DEVELOPER
125 #endif
126
127
128 foreach (BoxCollidingResult bResult : results)
129 {
131
132
133 if (!obj.IsAnyInherited(targetableObjects) || !obj.IsAlive())
134 {
135 continue;
136 }
137
138
139 vector targetPos = obj.GetPosition();
142 int hitComponent = -1;
143
144 float csSum =
float.
MAX;
145
146
149 {
154 }
155
156
157 if (bResult.proxyInfo)
158 {
159 foreach (BoxCollidingResult pInfo : bResult.proxyInfo)
160 {
162 {
167 }
168 }
169 }
170
171
172 if (hitComponent == -1 || csSum ==
float.
MAX)
173 {
174 continue;
175 }
176
177
178 float sum = targetDistance2;
179 if (sum < retVal)
180 {
182 retVal = sum;
183 }
184
185 allTargets.Insert(obj);
186 }
187 }
188
189 return ret;
190 }
bool FindMostSuitableComponentEx(Object obj, BoxCollidingResult bResult, MeleeTargetSettings settings, out float sum, out ComponentResult result, array< string > blacklistedDamageZones)
proto native void SetParams(vector center, vector orientation, vector edgeLength, ObjIntersect primaryType, ObjIntersect secondaryType, bool fullComponentInfo)
Set the parameters.
Class that holds parameters to feed into CGame.IsBoxCollidingGeometryProxy.
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float AngleFromPosition(vector origin, vector originDir, vector target)
Angle that a target is from the direction of an origin.
static proto vector NearestPoint(vector beg, vector end, vector pos)
Point on line beg .. end nearest to pos.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Tan(float angle)
Returns tangent of angle in radians.
static const float RAD2DEG
static proto float AbsFloat(float f)
Returns absolute value.