Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CustomTriggerConditionsFactionControl.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Factions triggering control over trigger radius")]
5 protected ref array<FactionKey> m_aControlFactionKeys;
6
7 [Attribute(desc: "Ignored factions, not counting towards control check")]
8 protected ref array<FactionKey> m_aIgnoredFactionKeys;
9
10 [Attribute(uiwidget: UIWidgets.ComboBox, enumType: SCR_EScenarioFrameworkComparisonOperator)]
12
13 [Attribute("0.5", UIWidgets.Slider, "Control faction ratio over rest of checked factions", params: "0 1 0.1")]
14 protected float m_fControlRatio;
15
16 [Attribute(desc: "(optional) Custom Trigger getter")]
18
19 protected SCR_FactionAliasComponent m_FactionAliasComponent;
20 //------------------------------------------------------------------------------------------------
23 override bool Init(IEntity entity)
24 {
26 {
27 PrintFormat("SCR_CustomTriggerConditionsFactionControl: No control faction keys provided for condition %1.", this, level: LogLevel.ERROR);
28 return false;
29 }
30
32 {
33 FactionManager factionManager = GetGame().GetFactionManager();
34 if (factionManager)
35 m_FactionAliasComponent = SCR_FactionAliasComponent.Cast(GetGame().GetFactionManager().FindComponent(SCR_FactionAliasComponent));
36 }
37
39 {
40 SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_TriggerGetter.Get());
41 if (!entityWrapper)
42 {
43 PrintFormat("ScenarioFramework Action: Issue with Getter detected for Condition %1.", this, level:LogLevel.ERROR);
44 return false;
45 }
46
47 entity = entityWrapper.GetValue();
48 }
49
51 if (!trigger)
52 {
53 PrintFormat("SCR_CustomTriggerConditionsFactionControl: Provided entity is not SCR_ScenarioFrameworkTriggerEntity for condition %1.", this, level: LogLevel.ERROR);
54 return false;
55 }
56
57 array <IEntity> entities = {};
58 trigger.GetEntitiesInside(entities);
59 int controlFactionCount, opposingFactionCount;
60 FactionAffiliationComponent factionComp;
61 FactionKey factionKey;
62
63 foreach (IEntity ent : entities)
64 {
65 factionComp = FactionAffiliationComponent.Cast(ent.FindComponent(FactionAffiliationComponent));
66 if (!factionComp)
67 continue;
68
69 factionKey = factionComp.GetAffiliatedFactionKey();
70 //Check, if faction is ignored first
72 continue;
73
75 controlFactionCount++;
76 else
77 opposingFactionCount++;
78 }
79
80 float ratio = controlFactionCount / Math.Max(controlFactionCount + opposingFactionCount, 1);
81
82 return (
88 }
89
90 //------------------------------------------------------------------------------------------------
91 protected bool CheckFactionKey(FactionKey factionKey, notnull array<FactionKey> arrayToCheck)
92 {
94 {
95 array<string> aliases = m_FactionAliasComponent.GetAllFactionKeyAliases(factionKey);
96 foreach (string alias : aliases)
97 {
98 if (arrayToCheck.Contains(alias))
99 return true;
100 }
101 }
102
103 return arrayToCheck.Contains(factionKey);
104 }
105}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
bool CheckFactionKey(FactionKey factionKey, notnull array< FactionKey > arrayToCheck)
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute