16 HAS_FRAG_GRENADE = 128
35 class SCR_AIInfoComponent : SCR_AIInfoBaseComponent
37 protected EUnitState m_iUnitStates;
38 protected EUnitAIState m_iAIStates;
39 protected SCR_InventoryStorageManagerComponent m_inventoryManagerComponent;
40 protected BaseWeaponManagerComponent m_weaponManagerComponent;
49 protected float m_fUnconsciousBloodLevel;
53 protected bool m_bWeaponRaised;
54 protected int m_iAttackCount;
55 protected int m_unitID;
58 override protected void OnPostInit(IEntity owner)
60 super.OnPostInit(owner);
61 SetEventMask(owner, EntityEvent.INIT);
69 void OnVehicleEntered( IEntity vehicle, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID )
71 BaseCompartmentSlot compSlot = manager.FindCompartment(slotID, mgrID);
73 AddUnitState(EUnitState.IN_TURRET);
81 void OnVehicleLeft( IEntity vehicle, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID )
86 BaseCompartmentSlot compSlot = manager.FindCompartment(slotID, mgrID);
90 RemoveUnitState(EUnitState.IN_TURRET);
100 m_fUnconsciousBloodLevel = m_BloodHitZone.GetMaxHealth() * m_BloodHitZone.GetDamageStateThreshold(
EDamageState.STATE3);
104 override protected void EOnInit(IEntity owner)
107 AIAgent agent = AIAgent.Cast(owner);
109 ent = agent.GetControlledEntity();
113 m_inventoryManagerComponent = SCR_InventoryStorageManagerComponent.Cast(ent.FindComponent(SCR_InventoryStorageManagerComponent));
114 m_weaponManagerComponent = BaseWeaponManagerComponent.Cast(ent.FindComponent(BaseWeaponManagerComponent));
117 m_CombatComponent = SCR_AICombatComponent.Cast(ent.FindComponent(SCR_AICombatComponent));
123 m_Perception = PerceptionComponent.Cast(ent.FindComponent(PerceptionComponent));
126 if (m_CompartmentAccessComponent)
128 m_CompartmentAccessComponent.GetOnCompartmentEntered().Insert(OnVehicleEntered);
129 m_CompartmentAccessComponent.GetOnCompartmentLeft().Insert(OnVehicleLeft);
137 EvaluateWoundedState();
143 void ~SCR_AIInfoComponent()
150 override protected void OnDelete(IEntity owner)
152 if (m_CompartmentAccessComponent)
154 m_CompartmentAccessComponent.GetOnCompartmentEntered().Remove(OnVehicleEntered);
155 m_CompartmentAccessComponent.GetOnCompartmentLeft().Remove(OnVehicleLeft);
169 bool IsOwnerAgent(AIAgent agent)
184 case EUnitRole.MEDIC:
return m_inventoryManagerComponent.GetHealthComponentCount() > 0;
202 typename t = EUnitRole;
203 int tVarCount = t.GetVariableCount();
205 for (
int i = 0; i < tVarCount; i++)
208 t.GetVariableValue(
null, i, flag);
220 void AddUnitState(EUnitState state)
222 m_iUnitStates = m_iUnitStates | state;
228 void RemoveUnitState(EUnitState state)
230 if (HasUnitState(state))
231 m_iUnitStates = m_iUnitStates & ~state;
238 bool HasUnitState(EUnitState state)
240 return ( m_iUnitStates & state );
246 EUnitState GetUnitStates()
248 return m_iUnitStates;
255 void SetAIState(EUnitAIState state)
262 EUnitAIState GetAIState()
272 int GetMagazineCountByWellType(
typename magazinyWellType)
311 m_bWeaponRaised = raised;
316 bool GetWeaponRaised()
318 return m_bWeaponRaised;
331 EAIThreatState GetThreatState()
336 return EAIThreatState.SAFE;
350 protected void EvaluateWoundedState()
354 AddUnitState(EUnitState.WOUNDED);
356 RemoveUnitState(EUnitState.WOUNDED);
365 EvaluateWoundedState();
374 EvaluateWoundedState();
382 RemoveUnitState(EUnitState.UNCONSCIOUS);
384 AddUnitState(EUnitState.UNCONSCIOUS);
389 float GetBleedTimeToUnconscious()
391 if (!m_BloodHitZone || !m_fUnconsciousBloodLevel)
394 float bleedingPerSec = m_BloodHitZone.GetDamageOverTime(
EDamageType.BLEEDING);
396 float timeToUnconscious = -1;
398 if (bleedingPerSec > 0)
399 timeToUnconscious = (m_BloodHitZone.GetHealth() - m_fUnconsciousBloodLevel) / bleedingPerSec;
401 return timeToUnconscious;
410 void DebugPrintToWidget(TextWidget w)
413 str = str +
string.Format(
"\n%1 %2", m_iAIStates,
typename.EnumToString(EUnitAIState, m_iAIStates));
419 string GetBehaviorEditorDebugName()
421 AIAgent agent = AIAgent.Cast(
GetOwner());
423 SCR_CallsignCharacterComponent callsignComp = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
425 FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(agent.GetControlledEntity().FindComponent(FactionAffiliationComponent));
431 string faction = factionComp.GetAffiliatedFaction().GetFactionKey();
432 str = str +
string.Format(
"[%1] ", faction);
437 string company, platoon, squad, character, format;
438 bool setCallsign = callsignComp.GetCallsignNames(company, platoon, squad, character, format);
441 string callsign = WidgetManager.Translate(format, company, platoon, squad, character);
442 str = str +
string.Format(
" %1", callsign);