Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIActivityIllumFlareFeature.c
Go to the documentation of this file.
2{
3 static bool GetAgentIllumWeaponAndMuzzle(SCR_AIInfoComponent infoComp, out BaseWeaponComponent weaponComponent, out BaseMagazineComponent magazineComponent, out int muzzleId)
4 {
5 if (!infoComp)
6 return false;
7
8 SCR_AICombatComponent combatComp = infoComp.GetCombatComponent();
9 if (!combatComp)
10 return false;
11
12 // Find illum mags
14 magazineComponent = combatComp.m_WeaponTargetSelector.FindMagazineWithTraits(traits, false);
15 if (!magazineComponent)
16 return false;
17
18 BaseMagazineWell magWell = magazineComponent.GetMagazineWell();
19
20 if (!magWell)
21 return false;
22
23 typename magWellType = magWell.Type();
24 muzzleId = -1;
25 weaponComponent = combatComp.m_WeaponTargetSelector.FindWeaponAndMuzzleForMagazineWell(magWellType, false, muzzleId);
26
27 return weaponComponent && muzzleId != -1;
28 }
29
30 //-------------------------------------------------------------------------------------
31 bool Execute(notnull SCR_AIGroupUtilityComponent groupUtility, vector targetPosition, SCR_AIActivityBase activity)
32 {
33 BaseWeaponComponent weaponComponent;
34 BaseMagazineComponent magazineComponent;
35 int muzzleId;
36 bool agentFound;
38
39 foreach (SCR_AIInfoComponent infoComp: groupUtility.m_aInfoComponents)
40 {
41 agent = SCR_ChimeraAIAgent.Cast(infoComp.GetOwner());
42 if (!agent)
43 continue;
44
45 // Ignore agents that are not "available", considered combat ready
46 if (!IsAgentAvailable(agent))
47 continue;
48
49 agentFound = SCR_AIActivityIllumFlareFeature.GetAgentIllumWeaponAndMuzzle(infoComp, weaponComponent, magazineComponent, muzzleId);
50 if (agentFound)
51 break;
52 }
53
54 if (agentFound)
55 {
56 AICommunicationComponent comms = groupUtility.m_Owner.GetCommunicationComponent();
57 if (!comms)
58 return false;
59
60 // Everything is set, now we will adjust target position and send order to agent
61 IEntity character = agent.GetControlledEntity();
62 if (character)
63 {
64 // Adjust target position for UGL flares
65 vector position = character.GetOrigin();
66 vector direction = vector.Direction(position, targetPosition).Normalized();
67 targetPosition = position + (direction * Math.RandomFloat(150, 170));
68 targetPosition[1] = targetPosition[1] + Math.RandomFloat(60, 90);
69 }
70
72 msg.m_RelatedGroupActivity = activity;
73 msg.m_fPriorityLevel = SCR_AIActionBase.PRIORITY_BEHAVIOR_THROW_GRENADE;
74 msg.SetReceiver(agent);
75 comms.RequestBroadcast(msg, agent);
76
77 return true;
78 }
79
80 return false;
81 }
82}
void SCR_AIActivityBase(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint)
vector direction
vector position
proto external vector GetOrigin()
Definition Math.c:13
bool IsAgentAvailable(SCR_ChimeraAIAgent agent)
SCR_AICombatComponent GetCombatComponent()