8 AIWaypoint m_GroupWaypoint;
9 SCR_AIUtilityComponent m_UtilityComponent;
10 SCR_AIInfoComponent m_InfoComponent;
13 protected FactionAffiliationComponent m_FactionAffiliationComponent;
14 protected int m_iPendingPlayerId;
17 override void EOnInit(IEntity owner)
20 if (!controlledEntity)
23 ChimeraCharacter character = ChimeraCharacter.Cast(controlledEntity);
31 GetGame().GetCallqueue().CallLater(EnsureAILimit, 1,
false);
34 m_InfoComponent = SCR_AIInfoComponent.Cast(FindComponent(SCR_AIInfoComponent));
35 m_UtilityComponent = SCR_AIUtilityComponent.Cast(FindComponent(SCR_AIUtilityComponent));
48 auto aiWorld =
GetGame().GetAIWorld();
52 if (aiWorld.CanLimitedAIBeAdded())
56 if (!
EntityUtils.IsPlayer(controlledEntity) && !IsPlayerPending_S())
63 protected void SendWoundedMsg()
69 if (!damageMgr.IsDamagedOverTime(
EDamageType.BLEEDING))
79 msgReceiverGroup = slaveGroup;
81 msgReceiverGroup = myGroup;
84 if (!msgReceiverGroup)
89 AICommunicationComponent comms = msgReceiverGroup.GetCommunicationComponent();
94 msg.SetReceiver(msgReceiverGroup);
95 comms.RequestBroadcast(msg, msgReceiverGroup);
105 GetControlComponent().DeactivateAI();
109 commsHandler.SetSuspended(
true);
115 GetControlComponent().DeactivateAI();
118 commsHandler.Reset();
124 bool possesingMainEntity =
false;
125 array<int> players =
new array<int>;
126 GetGame().GetPlayerManager().GetPlayers(players);
127 foreach (
int playerId: players)
131 possesingMainEntity =
true;
137 GetControlComponent().ActivateAI();
139 AICommunicationComponent comms = GetCommunicationComponent();
149 ClearDangerEvents(GetDangerEventsCount());
154 commsHandler.SetSuspended(
false);
159 Faction GetFaction(IEntity entity)
162 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(entity);
163 if (character && character.m_pFactionComponent)
165 return character.m_pFactionComponent.GetAffiliatedFaction();
168 Vehicle vehicle = Vehicle.Cast(entity);
169 if (vehicle && vehicle.m_pFactionComponent)
171 return vehicle.m_pFactionComponent.GetAffiliatedFaction();
175 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(entity.FindComponent(FactionAffiliationComponent));
176 if (factionAffiliation)
177 return factionAffiliation.GetAffiliatedFaction();
183 bool IsEnemy(IEntity entity)
185 Faction otherFaction = GetFaction(entity);
191 if (!otherFaction || !myFaction)
194 return myFaction.IsFactionEnemy(otherFaction);
198 void OnGroupWaypointChanged(AIWaypoint newWaypoint)
200 m_GroupWaypoint = newWaypoint;
204 void SetPlayerPending_S(
int playerId)
206 if (m_iPendingPlayerId != 0 && playerId != 0)
208 Print(
"Trying to set pending player on an already pending agent!", LogLevel.ERROR);
212 m_iPendingPlayerId = playerId;
216 bool IsPlayerPending_S()
218 return m_iPendingPlayerId != 0;