Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkAIThreatStateCondition.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "AI Entity to evaluate. Leave empty to use entity spawned by this slot.")]
5 ref SCR_ScenarioFrameworkGet m_Entity;
6
7 [Attribute(defvalue: EAIThreatState.THREATENED.ToString(), UIWidgets.ComboBox, "What threat state should be checked by this condition. If used on a group, return true when at least one member of group has this threat state.", "", ParamEnumArray.FromEnum(EAIThreatState), category: "Common")]
8 EAIThreatState m_eAIThreatState;
9
10 //------------------------------------------------------------------------------------------------
11 override bool Init(IEntity entity)
12 {
13 // Here you can debug specific Condition instance.
14 // This can be also adjusted during runtime via Debug Menu > ScenarioFramework > Condition Inspector
15 if (m_bDebug)
16 Print("[SCR_ScenarioFrameworkAIThreatStateCondition.Init] Condition invoked with debug flag (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.WARNING);
17
18 SCR_AIGroup targetAIGroup;
19
20 if (!m_Entity)
21 {
23 SCR_ScenarioFrameworkSlotTaskAI slotTaskAI = SCR_ScenarioFrameworkSlotTaskAI.Cast(entity.FindComponent(SCR_ScenarioFrameworkSlotTaskAI));
24
25 if (slotAI)
26 targetAIGroup = slotAI.m_AIGroup;
27 else if (slotTaskAI)
28 targetAIGroup = slotTaskAI.m_AIGroup;
29 }
30 else
31 {
32 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Entity.Get());
33 if (!entityWrapper)
34 {
35 Print(string.Format("ScenarioFramework Condition: Entity not found for condition %1.", this), LogLevel.ERROR);
36 return false;
37 }
38
39 ChimeraCharacter chimeraChar = ChimeraCharacter.Cast(entityWrapper.GetValue());
40 if (!chimeraChar)
41 {
42 Print(string.Format("ScenarioFramework Condition: Entity not found for condition %1.", this), LogLevel.ERROR);
43 return false;
44 }
45
46 CharacterControllerComponent charControllerComp = chimeraChar.GetCharacterController();
47 if (!charControllerComp)
48 return false;
49
50 ChimeraAIControlComponent AIControlComponenet = ChimeraAIControlComponent.Cast(charControllerComp.GetAIControlComponent());
51 if (!AIControlComponenet)
52 return false;
53
54 AIAgent agent = AIControlComponenet.GetAIAgent();
55 if (!agent)
56 return false;
57
58 targetAIGroup = SCR_AIGroup.Cast(agent.GetParentGroup());
59 }
60
61 if (!targetAIGroup)
62 {
63 Print(string.Format("ScenarioFramework Action: AI Group not found for Action %1.", this), LogLevel.ERROR);
64 return false;
65 }
66
67 array<AIAgent> agents = {};
68 targetAIGroup.GetAgents(agents);
69
70 SCR_AIInfoComponent infoComponent;
71 SCR_AIThreatSystem threatSystem;
72 SCR_ChimeraAIAgent chimeraAgent;
73
74 foreach (int i, AIAgent agent : agents)
75 {
76 chimeraAgent = SCR_ChimeraAIAgent.Cast(agent);
77 if (!chimeraAgent)
78 continue;
79
80 infoComponent = chimeraAgent.m_InfoComponent;
81 if (!infoComponent)
82 continue;
83
84 threatSystem = infoComponent.GetThreatSystem();
85 if (!threatSystem)
86 continue;
87
88 if (threatSystem.GetState() == m_eAIThreatState)
89 return true;
90 }
91
92 return false;
93 }
94}
override void Init()
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
SCR_AIThreatSystem GetThreatSystem()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute