Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_IdentityInventoryItemComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Misc", description: "")]
5
6class SCR_IdentityInventoryItemComponent : InventoryItemComponent
7{
8 [Attribute("1", desc: "Check if identity item is of a hostile faction and only then will it be considered a valuable intel. The CanShowValuableIntel() function is able to force the check for faction")]
9 protected bool m_bCheckIfItemIsHostileFaction;
10
11 [RplProp()]//onRplName: "OnLinkedIdentitySet")]
12 protected RplId m_RplIdLinkedIdentity = -1;
13
14 [RplProp(onRplName: "OnIntelFactionSet")] //~ Will be set to faction int which will determine if the item has valuable intel of the given faction
15 protected int m_iValuableIntelFaction = -1;
16
17 protected Faction m_IntelFaction;
18
19 //------------------------------------------------------------------------------------------------
20 void SCR_IdentityInventoryItemComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
21 {
23 return;
24
26 if ((gameMode && !gameMode.IsMaster()) || (!gameMode && Replication.IsClient()))
27 return;
28
29 //~ Call a frame later so SCR_ExtendedCharacterIdentityComponent can init correctly
30 GetGame().GetCallqueue().CallLater(DelayedInit, param1: ent);
31 }
32
33 //------------------------------------------------------------------------------------------------
34 protected override bool ShouldChangeVisibilityOfHierarchy()
35 {
36 return true;
37 }
38
39 //------------------------------------------------------------------------------------------------
40 protected void DelayedInit(IEntity owner)
41 {
42 if (!owner)
43 return;
44
45 ChimeraCharacter character;
46 IEntity parent = owner.GetParent();
47
48 while (parent)
49 {
50 character = ChimeraCharacter.Cast(parent);
51 if (character)
52 break;
53
54 parent = parent.GetParent();
55 }
56
57 if (!character)
58 return;
59
61 if (!rootExtendedIdentity)
62 return;
63
64 RplComponent rplComp = RplComponent.Cast(rootExtendedIdentity.GetOwner().FindComponent(RplComponent));
65 if (!rplComp)
66 return;
67
68 m_RplIdLinkedIdentity = Replication.FindItemId(rplComp);
69
70 //~ This identity holds valuable intel. So make sure that is shown
71 m_iValuableIntelFaction = rootExtendedIdentity.OnIdentityItemAdded_S(this, SCR_IdentityManagerComponent.Static_IsGenerateValuableIntelEnabled());
72
73 if (m_iValuableIntelFaction >= 0)
75
76 Replication.BumpMe();
77 }
78
79 //------------------------------------------------------------------------------------------------
81 {
82 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(m_RplIdLinkedIdentity));
83 if (!rplComponent)
84 return null;
85
86 IEntity owner = rplComponent.GetEntity();
87 if (!owner)
88 return null;
89
91 }
92
93 //------------------------------------------------------------------------------------------------
98 bool HasValuableIntel(bool forceCheckForFaction = false, PlayerController playerController = null)
99 {
100 if (m_iValuableIntelFaction < 0 || !m_IntelFaction || !SCR_IdentityManagerComponent.Static_IsGenerateValuableIntelEnabled())
101 return false;
102
103 if (forceCheckForFaction || ShouldCheckIfItemIsHostileFaction())
104 {
105 //~ Get local player controller if none was given
106 if (!playerController)
107 playerController = GetGame().GetPlayerController();
108
109 Faction playerFaction;
110
111 //~ Get player faction
112 if (playerController)
113 playerFaction = SCR_FactionManager.SGetPlayerFaction(playerController.GetPlayerId());
114 else
115 playerFaction = SCR_FactionManager.SGetLocalPlayerFaction();
116
117 if (!playerFaction)
118 return false;
119
120 //~ Only show intel for hostile faction identity items
121 SCR_Faction scrFaction = SCR_Faction.Cast(playerFaction);
122 if ((scrFaction && scrFaction.DoCheckIfFactionFriendly(m_IntelFaction)) || (!scrFaction && playerFaction.IsFactionFriendly(m_IntelFaction)))
123 return false;
124 }
125
126 return true;
127 }
128
129 //------------------------------------------------------------------------------------------------
132 {
133 return m_bCheckIfItemIsHostileFaction;
134 }
135
136 //------------------------------------------------------------------------------------------------
138 {
139 return m_iValuableIntelFaction;
140 }
141
142 //------------------------------------------------------------------------------------------------
144 {
145 return m_IntelFaction;
146 }
147
148 //------------------------------------------------------------------------------------------------
150 {
151 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(m_RplIdLinkedIdentity));
152 if (!rplComponent)
153 return null;
154
155 IEntity owner = rplComponent.GetEntity();
156 if (!owner)
157 return null;
158
160 }
161
162 //------------------------------------------------------------------------------------------------
163 protected void OnIntelFactionSet()
164 {
165 if (m_iValuableIntelFaction < 0)
166 return;
167
168 m_IntelFaction = GetGame().GetFactionManager().GetFactionByIndex(m_iValuableIntelFaction);
169 }
170
171 //------------------------------------------------------------------------------------------------
172 /*void ReplicateIdentity()
173 {
174 //~ Call on Parent changed
175
176 //~ Create the identity component
177 //~ Send over values
178 //~ Fill in the identity components with given values
179
180 //~ Other values to set up are: GroupCallsign, Rank
181 }*/
182
183 //------------------------------------------------------------------------------------------------
184 /*protected void OnLinkedIdentitySet()
185 {
186 //Print(m_RplIdLinkedIdentity);
187 } */
188}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
override void DelayedInit(IEntity owner)
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override void DelayedInit()
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_CallsignBaseComponent GetLinkedCallsignComponent()
bool ShouldCheckIfItemIsHostileFaction()
bool HasValuableIntel(bool forceCheckForFaction=false, PlayerController playerController=null)
Faction GetValuableIntelFaction()
SCR_ExtendedIdentityComponent GetLinkedExtendedIdentity()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto external IEntity GetParent()
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
sealed bool IsMaster()
Component of assigning and storing squad names.
int OnIdentityItemAdded_S(SCR_IdentityInventoryItemComponent item, bool generateValuableIntel)
override bool DoCheckIfFactionFriendly(Faction faction)
static bool IsEditMode()
Definition Functions.c:1566
SCR_FieldOfViewSettings Attribute
Tuple param1