Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_IdentityBioGroupConfig.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true), BaseContainerCustomDoubleTitleField("m_sBioGroupID", "m_iWeight")]
3{
4 [Attribute("1", desc: "If false will disable this entry from the pool.", category: "Settings")]
5 protected bool m_bEnabled;
6
7 [Attribute(desc: "Unique ID of group", category: "Settings")]
8 protected string m_sBioGroupID;
9
10 [Attribute("1", desc: "The higher the weight the heigher the chance of a bio in this group being picked by the randomizer (Compared with the other groups in the IdentityManager). Bio's in group will never be randomly assigned nor keep track of assigned bio's if weight is 0 or less. Use this for custom identities you want to assign only through script.\n\nWARNING: All weights (as well as aditional entry weight * list lenght) are counted up together. ake make sure all totals do not exceed max int value: '2147483647'", params: "-1, 9999 1", category: "Settings")]
11 protected int m_iWeight; //0 is never chosen by randomizer. Only set by system
12
13 [Attribute("10", desc: "Additional Weight for the amount of entries the BioGroup has. Calculation: (m_iWeight = m_iWeight + (entries * m_fEntryAmountWeightMulti)) This is to make sure that groups with lesser entries are not chosen as much\n\nWARNING: All weights (as well as aditional entry weight * list lenght) are counted up together. Make sure all totals do not exceed max int value: '2147483647'", params: "0, 100", category: "Settings")]
15
16 [Attribute(desc: "Faction the entity needs in order for it to choose the bio. Leave empty if any faction (or no faction) is valid.", category: "Requirements")]
17 protected ref array<string> m_aNeedsFaction;
18
19 [Attribute(desc: "List of all character bio's in group (Gender Neutral). If the bio group is chosen in the randomizer then one of the bios within will be randomly assigned.", category: "Identities")]
20 protected ref array<ref SCR_IdentityBio> m_aIdentityList;
21
22 //~ Indexes of m_aNeedsFaction
23 protected ref array<int> m_aNeedsFactionIndexes;
24
25 //~ Bio's that can be picked
26 protected ref array<int> m_aAvailableIdentityBioIndexList = {};
27
28 //~ Bio's that cannot be picked but will be resuffled once available is empty
29 protected ref array<int> m_aUnavailableIdentityBioIndexList = {};
30
31 //------------------------------------------------------------------------------------------------
34 bool IsEnabled()
35 {
36 return m_bEnabled;
37 }
38
39 //------------------------------------------------------------------------------------------------
45 {
46 //~ Note that this is in part checked in SCR_CharacterIdentityBioGroupConfig
47 return m_iWeight > 0 && !m_aAvailableIdentityBioIndexList.IsEmpty();
48 }
49
50 //------------------------------------------------------------------------------------------------
54 {
55 return m_iWeight;
56 }
57
58 //------------------------------------------------------------------------------------------------
62 bool IsValidFaction(string factionKey)
63 {
64 if (m_aNeedsFaction.IsEmpty())
65 return true;
66
67 return m_aNeedsFaction.Contains(factionKey);
68 }
69
70 //------------------------------------------------------------------------------------------------
74 bool IsValidFaction(int factionIndex)
75 {
77 return true;
78
79 return m_aNeedsFactionIndexes.Contains(factionIndex);
80 }
81
82 //------------------------------------------------------------------------------------------------
86 {
87 return m_sBioGroupID;
88 }
89
90 //------------------------------------------------------------------------------------------------
96 {
97 if (!m_aIdentityList.IsIndexValid(index))
98 return null;
99
100 return m_aIdentityList[index];
101 }
102
103 //------------------------------------------------------------------------------------------------
108 void AssignRandomAvailableBio(RandomGenerator randomizer, IEntity entity, out int index, out SCR_IdentityBio bio)
109 {
111 return;
112
113 //~ Get random entry
114 int count = m_aAvailableIdentityBioIndexList.Count();
115 int random = randomizer.RandInt(0, count);
116
117 //~ Get actual index of randomized available bio
119 //~ Remove from available bios
120 bio = OnCharacterBioAssigned(entity, index);
121 }
122
123 //------------------------------------------------------------------------------------------------
128 {
130 return null;
131
133 if (!bio)
134 return null;
135
136 //~ Weight zero will never remove from available
137 if (m_iWeight <= 0)
138 return bio;
139
140 //~ Remove from available bios
142
143 //~ Add to unavailable bios (If not unique as unique bio's can only be assigned once per game)
144 if (!bio.IsUnique() && !m_aUnavailableIdentityBioIndexList.Contains(index))
146
147 //~ Refill available list if empty
149 {
150 foreach (int unavailableIndex : m_aUnavailableIdentityBioIndexList)
151 {
152 m_aAvailableIdentityBioIndexList.Insert(unavailableIndex);
153 }
154
156 }
157
158 return bio;
159 }
160
161 //------------------------------------------------------------------------------------------------
164 {
167
168 int count = m_aIdentityList.Count();
169
170 for(int i = 0; i < count; i++)
171 {
173 }
174 }
175
176 //------------------------------------------------------------------------------------------------
177 //~ Init
179 {
180 if (SCR_Global.IsEditMode())
181 return;
182
184 if (!gamemode || !gamemode.IsMaster())
185 return;
186
187 //~ Init available character indexes
189 GetGame().GetCallqueue().CallLater(DelayedInit);
190
192 }
193
194 //------------------------------------------------------------------------------------------------
195 protected void SetAdditionalWeight()
196 {
197 //~ Set Additional Weight for each entry
200 }
201
202 //------------------------------------------------------------------------------------------------
203 protected void DelayedInit()
204 {
205 //~ Highly unlikely that this happens but will send an error if it happens
207 {
208 Print(string.Format("'SCR_IdentityBioGroupConfig' - %1: Bio entries count is greater than %2 which will break replication", m_sBioGroupID, SCR_IdentityManagerComponent.MAX_IDENTITY_ENTRIES), LogLevel.ERROR);
209 }
210
211 FactionManager factionManager = GetGame().GetFactionManager();
212 if (!factionManager)
213 {
214 Print("'SCR_CharacterBioGroupConfig' Needs faction manager else all bio's can be assigned to every faction (or no faction)", LogLevel.WARNING);
215 return;
216 }
217
218 Faction faction;
219
220 foreach(string factionKey: m_aNeedsFaction)
221 {
224
225 faction = factionManager.GetFactionByKey(factionKey);
226
227 //~ If faction not found in the FactionManager make sure it is never used in the randomization by setting it to -1
228 if (!faction && !m_aNeedsFactionIndexes.Contains(-1))
229 m_aNeedsFactionIndexes.Insert(-1);
230
231 m_aNeedsFactionIndexes.Insert(factionManager.GetFactionIndex(faction));
232 }
233 }
234}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_BaseGameMode GetGameMode()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
class SCR_FactionHomeTerritoryConfig BaseContainerCustomDoubleTitleField("m_sID", "m_iWeight")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
sealed bool IsMaster()
static bool IsEditMode()
Definition Functions.c:1566
void ResetAvailable()
Resets all available indexes. Including Unique (Server Only).
SCR_IdentityBio OnCharacterBioAssigned(IEntity entity, int index)
bool IsValidForRandomization(IEntity entity, SCR_ExtendedIdentityComponent extendedIdentity)
ref array< int > m_aUnavailableIdentityBioIndexList
SCR_IdentityBio GetIdentityBio(IEntity entity, int index)
bool IsValidFaction(string factionKey)
void AssignRandomAvailableBio(RandomGenerator randomizer, IEntity entity, out int index, out SCR_IdentityBio bio)
ref array< ref SCR_IdentityBio > m_aIdentityList
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