57 TargetableObjects = targetableObjects;
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;
102 float boxHeight = coneMaxHeight - coneMinHeight;
104 vector boxSize =
Vector(boxWidth, boxHeight, coneLength);
108 vector offset = xzDir * coneLength * 0.5;
109 vector boxCenter = coneOrigin + offset + centerHeight;
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();
142 int hitComponent = -1;
144 float csSum =
float.
MAX;
157 if (bResult.proxyInfo)
159 foreach (BoxCollidingResult pInfo : bResult.proxyInfo)
172 if (hitComponent == -1 || csSum ==
float.
MAX)
178 float sum = targetDistance2;
185 allTargets.Insert(obj);
200 foreach (ComponentInfo cInfo : bResult.componentInfo)
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());
243 if (componentDistance2 > componentMaxDist2)
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)
bool EvaluateComponentEx(Object obj, ComponentInfo cInfo, MeleeTargetSettings settings, out ComponentResult result, array< string > blacklistedDamageZones)
bool FindMostSuitableComponentEx(Object obj, BoxCollidingResult bResult, MeleeTargetSettings settings, out float sum, out ComponentResult result, array< string > blacklistedDamageZones)
ref array< typename > TargetableObjects void MeleeTargetSettings(vector coneOrigin, float coneLength, float coneHalfAngle, float coneMinHeight, float coneMaxHeight, vector rayStart, vector dir, float maxDist, EntityAI pToIgnore, array< typename > targetableObjects)
bool FindMostSuitableComponent(Object obj, BoxCollidingResult bResult, MeleeTargetSettings settings, out float sum, out ComponentResult result)
MeleeTargetData GetMeleeTarget(MeleeTargetSettings settings, out array< Object > allTargets=null)
bool IsMeleeTargetObstructed(vector rayStart, vector rayEnd)
bool EvaluateComponent(Object obj, ComponentInfo cInfo, MeleeTargetSettings settings, out ComponentResult result)
class MeleeTargetData ConeOrigin
class ComponentResult MELEE_TARGET_OBSTRUCTION_LAYERS
MeleeTargetData GetMeleeTargetEx(MeleeTargetSettings settings, out array< Object > allTargets=null, array< string > blacklistedDamageZones=null)
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 proto bool RayCastBullet(vector begPos, vector endPos, PhxInteractionLayers layerMask, Object ignoreObj, out Object hitObject, out vector hitPosition, out vector hitNormal, out float hitFraction)
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
void MeleeTargetData(Object o, vector p, int c)
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 void ConePoints(vector origin, float length, float halfAngle, float angleOffset, out vector leftPoint, out vector rightPoint)
Calculates the points of a right 2D cone in 3D space.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float SqrFloat(float f)
Returns squared value.
static proto float Tan(float angle)
Returns tangent of angle in radians.
static proto float Atan2(float y, float x)
Returns angle in radians from tangent.
static const float RAD2DEG
static const float DEG2RAD
static proto float AbsFloat(float f)
Returns absolute value.