15 IEntity shooter = eventWeaponFire.GetObject();
17 if (!shooter || !eventWeaponFire)
20 IEntity instigatorEntity = eventWeaponFire.GetInstigatorEntity();
21 if (!instigatorEntity)
25 Faction instigatorFaction = SCR_AIFactionHandling.GetEntityPerceivedFaction(instigatorEntity);
27 if (!instigatorFaction)
32 bool myFactionIsMilitary = utility.IsMilitary();
33 if (myFactionIsMilitary && !agent.
IsEnemy(instigatorFaction))
37 vector shotPos = eventWeaponFire.GetPosition();
38 vector shotDir = eventWeaponFire.GetDirection();
39 bool isShotSuppressed = eventWeaponFire.IsSuppressed();
41 vector myOrigin = utility.m_OwnerEntity.GetOrigin();
48 float maxAudibleDistance;
53 bool isAudible =
distance < maxAudibleDistance;
56 float timeTillFlyby_s =
float.MAX;
57 float timeTillGunshotHeard_s =
float.MAX;
60 float projectileSpeed = eventWeaponFire.GetInitialSpeed();
62 float flightTime_s =
distance / projectileSpeed;
64 timeTillFlyby_s = flybyTimestamp.DiffSeconds(
GetGame().GetWorld().GetTimestamp());
66 if (timeTillFlyby_s < 0)
71 utility, dangerEventCount, shotPos);
79 WorldTimestamp wavefrontArrivalTimestamp = eventTimestamp.PlusSeconds(wavefrontTravelTime_s);
80 timeTillGunshotHeard_s = wavefrontArrivalTimestamp.DiffSeconds(
GetGame().GetWorld().GetTimestamp());
85 bool ignoreGunshotHeard = isFlyby && timeTillFlyby_s < timeTillGunshotHeard_s;
87 if (!ignoreGunshotHeard)
89 if (timeTillGunshotHeard_s < 0)
93 utility.GetCallqueue().CallLater(
OnGunshotHeard, 1000*timeTillGunshotHeard_s,
false,
94 utility,
distance, dangerEventCount, shotPos);
99 if (isFlyby || isAudible)
104 AIGroup myGroup = utility.GetOwner().GetParentGroup();
105 if (myGroup && myGroup.GetLeaderAgent() == agent)
107 float timeTillGroupNotified_s =
Math.Min(timeTillFlyby_s, timeTillGunshotHeard_s);
109 if (timeTillGroupNotified_s < 0)
110 NotifyGroup(myGroup, shooter, instigatorEntity, instigatorFaction, shotPos, endangeringForGroup);
113 utility.GetCallqueue().CallLater(
NotifyGroup, 1000*timeTillGroupNotified_s,
false,
114 myGroup, shooter, instigatorEntity, instigatorFaction, shotPos, endangeringForGroup);
140 PerceptionManager pm =
GetGame().GetPerceptionManager();
143 if (!groupUtilityComp || !pm)
153 targetEntity = shooterEntity;
154 else if (
Turret.Cast(shooterEntity))
157 if (
Vehicle.Cast(shooterEntityRoot))
158 targetEntity = shooterEntityRoot;
160 targetEntity = instigatorEntity;
167 float timestamp = pm.GetTime();