3 protected static string TARGET_ENTITY_PORT =
"TargetEntity";
4 protected static string TARGET_POSITION_PORT =
"TargetPosition";
5 protected static string VECTOR_IN_PORT =
"VectorIn";
6 protected static string INITIAL_SPEED_COEFFICIENT =
"InitialSpeedCoefficient";
8 protected static string VECTOR_OUT_PORT =
"VectorOut";
10 protected BaseWeaponManagerComponent m_WeaponMgr;
13 override void OnInit(AIAgent owner)
15 IEntity ent = owner.GetControlledEntity();
18 m_WeaponMgr = BaseWeaponManagerComponent.Cast(ent.FindComponent(BaseWeaponManagerComponent));
22 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
25 return ENodeResult.FAIL;
30 float initSpeedCoef = 1.0;
31 GetVariableIn(VECTOR_IN_PORT, vin);
32 GetVariableIn(INITIAL_SPEED_COEFFICIENT, initSpeedCoef);
38 if (GetVariableIn(TARGET_ENTITY_PORT, targetEntity))
42 Print(
"GetAimDistanceCompensation: provided null entity", LogLevel.WARNING);
43 return ENodeResult.FAIL;
45 targetPos = targetEntity.GetOrigin();
48 GetVariableIn(TARGET_POSITION_PORT, targetPos);
54 currentWeapon = m_WeaponMgr.GetCurrentWeapon();
56 currentMuzzle = currentWeapon.GetCurrentMuzzle();
62 vector muzzleMatrix[4];
63 m_WeaponMgr.GetCurrentMuzzleTransform(muzzleMatrix);
64 distance = vector.Distance(targetPos, muzzleMatrix[3]);
67 distance = vector.Distance(targetPos, owner.GetControlledEntity().GetOrigin());
72 if (currentWeapon && currentMuzzle)
77 else if (currentWeapon)
80 heightOffset =
BallisticTable.GetHeightFromProjectile(
distance, flightTime, currentWeapon.GetOwner(), initSpeedCoef);
85 vector vHeightCompensation;
86 vHeightCompensation[1] = heightOffset;
88 vHeightCompensation = targetEntity.VectorToLocal(vHeightCompensation);
91 vout = vin + vHeightCompensation;
95 SetVariableOut(VECTOR_OUT_PORT, vout);
97 return ENodeResult.SUCCESS;
101 protected static ref TStringArray s_aVarsOut = {VECTOR_OUT_PORT};
102 override TStringArray GetVariablesOut() {
return s_aVarsOut; }
105 protected static ref TStringArray s_aVarsIn = {TARGET_ENTITY_PORT, TARGET_POSITION_PORT, VECTOR_IN_PORT, INITIAL_SPEED_COEFFICIENT};
106 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
109 override bool VisibleInPalette() {
return true;}
112 protected override string GetOnHoverDescription() {
return "Returns vertical offset for ballistic compensation of range to target";}