4 protected static const string PORT_DISTANCE_COMPENSATION =
"DistanceCompensation";
5 protected static const string PORT_TARGET_POSITION =
"TargetPos";
7 protected ref TraceParam m_TraceParam;
17 override bool TestFunction(AIAgent owner)
19 SCR_ChimeraCharacter myCharacter = SCR_ChimeraCharacter.Cast(owner.GetControlledEntity());
24 GetVariableIn(PORT_TARGET_POSITION, targetPos);
26 vector distanceCompensation;
27 GetVariableIn(PORT_DISTANCE_COMPENSATION, distanceCompensation);
29 vector traceFrom = myCharacter.EyePosition();
30 vector targetPosCompensated = targetPos + distanceCompensation;
31 vector traceTo = 0.5*(traceFrom + targetPosCompensated);
35 m_TraceParam =
new TraceParam();
37 m_TraceParam.Start = traceFrom;
38 m_TraceParam.End = traceTo;
39 m_TraceParam.Exclude = myCharacter;
40 m_TraceParam.LayerMask = EPhysicsLayerDefs.Projectile;
41 m_TraceParam.Flags = TraceFlags.ENTS | TraceFlags.OCEAN | TraceFlags.WORLD | TraceFlags.ANY_CONTACT;
43 float traceResult =
GetGame().GetWorld().TraceMove(m_TraceParam,
null);
44 bool traceHit = traceResult != 1.0;
53 lineColor = Color.GREEN;
55 lineColor = Color.RED;
58 lineVerts[0] = m_TraceParam.Start;
59 lineVerts[1] = m_TraceParam.End;
60 Shape lineShape = Shape.CreateLines(lineColor, ShapeFlags.DEFAULT, lineVerts, 2);
65 vector hitPos = m_TraceParam.Start + traceResult * (m_TraceParam.End - m_TraceParam.Start);
66 Shape sphereShape = Shape.CreateSphere(Color.RED, ShapeFlags.DEFAULT, hitPos, 0.2);
76 override string GetOnHoverDescription() {
return "Estimates if projectile ballistic path can reach destination. It is performance heavy, use with some timer."; }
77 override bool VisibleInPalette() {
return true; }
79 protected static ref TStringArray s_aVarsIn = { PORT_DISTANCE_COMPENSATION, PORT_TARGET_POSITION };
80 override TStringArray GetVariablesIn() {
return s_aVarsIn; }