4 protected static const string BASE_TARGET_PORT =
"BaseTarget";
5 protected static const string WEAPON_IS_READY =
"WeaponReady";
9 protected static const string PORT_LAST_SEEN_POSITION =
"LastSeenPosition";
10 protected static const string PORT_VISIBLE =
"Visible";
11 protected static const string PORT_FIRE_TREE_ID =
"FireTreeId";
12 static const string PORT_AIMPOINT_TYPE_0 =
"AimpointType0";
13 static const string PORT_AIMPOINT_TYPE_1 =
"AimpointType1";
16 protected const int FIRE_TREE_INVALID = -1;
17 protected const int FIRE_TREE_LOOK = 0;
18 protected const int FIRE_TREE_BURST = 1;
19 protected const int FIRE_TREE_SINGLE = 2;
20 protected const int FIRE_TREE_SUPPRESSIVE = 3;
21 protected const int FIRE_TREE_MELEE = 4;
23 protected const float MELEE_MAX_DISTANCE = 2.0;
24 protected const float BURST_FIRE_MAX_DISTANCE = 50.0;
26 protected SCR_AICombatComponent m_CombatComponent;
27 protected CharacterControllerComponent m_CharacterController;
28 protected PerceptionComponent m_PerceptionComponent;
29 protected SCR_AIUtilityComponent m_UtilityComponent;
32 protected bool m_bFirstSimulate =
true;
34 protected bool m_bWeaponHasBurstOrAuto;
38 override void OnInit(AIAgent owner)
40 m_UtilityComponent = SCR_AIUtilityComponent.Cast(owner.FindComponent(SCR_AIUtilityComponent));
42 IEntity myEntity = owner.GetControlledEntity();
45 m_CombatComponent = SCR_AICombatComponent.Cast(myEntity.FindComponent(SCR_AICombatComponent));
47 m_CharacterController = CharacterControllerComponent.Cast(myEntity.FindComponent(CharacterControllerComponent));
50 m_bFirstSimulate =
true;
54 override void OnAbort(AIAgent owner, Node nodeCausingAbort)
56 m_bFirstSimulate =
true;
60 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
63 GetVariableIn(BASE_TARGET_PORT, target);
66 GetVariableIn(WEAPON_IS_READY, weaponReady);
69 return ENodeResult.FAIL;
76 m_bWeaponHasBurstOrAuto = WeaponHasBurstOrAutoMode(selectedWeaponComp, selectedMuzzleId);
80 SetVariableOut(PORT_LAST_SEEN_POSITION, target.GetLastSeenPosition());
84 SetVariableOut(PORT_VISIBLE, visible);
88 int fireTreeId = ResolveFireTree(target, visible, weaponReady);
89 SetVariableOut(PORT_FIRE_TREE_ID, fireTreeId);
97 ResolveAimpointTypes(target, aimpointType0, aimpointType1);
98 SetVariableOut(PORT_AIMPOINT_TYPE_0, aimpointType0);
99 SetVariableOut(PORT_AIMPOINT_TYPE_1, aimpointType1);
103 m_bFirstSimulate =
false;
105 return ENodeResult.SUCCESS;
110 int ResolveFireTree(
BaseTarget target,
bool visible,
bool weaponReady)
114 if (executedBehavior && executedBehavior.m_bUseCombatMove && !m_UtilityComponent.m_CombatMoveState.m_bAimAtTarget)
115 return FIRE_TREE_INVALID;
119 return FIRE_TREE_LOOK;
122 int selectedMuzzleId;
126 float weaponMinDist, weaponMaxDist;
127 m_CombatComponent.GetSelectedWeaponProperties(weaponMinDist, weaponMaxDist, directDamage);
129 if (!selectedWeaponComp)
130 return FIRE_TREE_LOOK;
132 EWeaponType weaponType = selectedWeaponComp.GetWeaponType();
134 float targetDistance = target.GetDistance();
137 if (targetDistance < MELEE_MAX_DISTANCE &&
141 return FIRE_TREE_MELEE;
147 return FIRE_TREE_LOOK;
153 if (targetDistance < weaponMinDist || targetDistance > weaponMaxDist)
158 return FIRE_TREE_LOOK;
170 return FIRE_TREE_BURST;
171 else if (targetDistance < BURST_FIRE_MAX_DISTANCE && m_bWeaponHasBurstOrAuto)
172 return FIRE_TREE_BURST;
174 return FIRE_TREE_SINGLE;
187 float lastSeenThreshold;
189 lastSeenThreshold = SCR_AICombatComponent.TARGET_MAX_LAST_SEEN_INDIRECT_ATTACK_MG;
191 lastSeenThreshold = SCR_AICombatComponent.TARGET_MAX_LAST_SEEN_INDIRECT_ATTACK;
193 if ((!directDamage || weaponType !=
EWeaponType.WT_ROCKETLAUNCHER) &&
194 target.GetTimeSinceSeen() < lastSeenThreshold &&
195 target.GetTraceFraction() > 0.5)
196 return FIRE_TREE_SUPPRESSIVE;
198 return FIRE_TREE_LOOK;
201 return FIRE_TREE_LOOK;
207 array<BaseMuzzleComponent> muzzles = {};
208 weaponComp.GetMuzzlesList(muzzles);
210 if (!muzzles.IsIndexValid(muzzleId))
217 array<BaseFireMode> fireModes = {};
218 muzzle.GetFireModesList(fireModes);
231 IEntity targetEntity = target.GetTargetEntity();
239 ChimeraCharacter character = ChimeraCharacter.Cast(targetEntity);
244 if (character.IsInVehicle())
277 protected ref TStringArray s_aVarsIn = {
281 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
283 protected ref TStringArray s_aVarsOut = {
285 PORT_LAST_SEEN_POSITION,
287 PORT_AIMPOINT_TYPE_0,
290 override TStringArray GetVariablesOut() {
return s_aVarsOut; }
292 override bool VisibleInPalette() {
return true; }
294 override string GetOnHoverDescription() {
return "Special node which is used in attack behavior"; };