Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InstigatorContextData.c
Go to the documentation of this file.
2{
3 protected int m_iVictimPlayerID;
4 protected int m_iKillerPlayerID;
5
8
9 protected ref Instigator m_Instigator;
10
12
15
18
19 //------------------------------------------------------------------------------------------------
24 {
25 return SCR_Enum.HasPartialFlag(m_eVictimKillerRelation, relation);
26 }
27
28 //------------------------------------------------------------------------------------------------
34
35 //------------------------------------------------------------------------------------------------
41
42 //------------------------------------------------------------------------------------------------
46 {
47 return SCR_Enum.HasPartialFlag(m_eVictimControlType, controlType);
48 }
49
50 //------------------------------------------------------------------------------------------------
56
57 //------------------------------------------------------------------------------------------------
61 {
62 return SCR_Enum.HasPartialFlag(m_eKillerControlType, controlType);
63 }
64
65 //------------------------------------------------------------------------------------------------
68 {
69 return m_iVictimPlayerID;
70 }
71
72 //------------------------------------------------------------------------------------------------
75 {
76 return m_iKillerPlayerID;
77 }
78
79 //------------------------------------------------------------------------------------------------
82 {
83 return m_VictimEntity;
84 }
85
86 //------------------------------------------------------------------------------------------------
89 {
90 return m_KillerEntity;
91 }
92
93 //------------------------------------------------------------------------------------------------
96 {
97 return m_Instigator;
98 }
99
100 //------------------------------------------------------------------------------------------------
106
107 //------------------------------------------------------------------------------------------------
113
114 //------------------------------------------------------------------------------------------------
119 bool DoesPlayerKillCountAsTeamKill(bool editorKillsCount = false, bool possessedKillsCount = false)
120 {
121 //~ No friendly fire involved or not killed by player character
122 if (m_eVictimKillerRelation != SCR_ECharacterDeathStatusRelations.KILLED_BY_FRIENDLY_PLAYER)
123 return false;
124
125 //~ Friendly kills do not count for admins, GMs
126 if (!editorKillsCount && m_eKillerControlType == SCR_ECharacterControlType.UNLIMITED_EDITOR)
127 return false;
128
129 //~ Check if friendly kills count for AI that are possed by GM
130 if (!possessedKillsCount && m_eKillerControlType == SCR_ECharacterControlType.POSSESSED_AI)
131 return false;
132
133 //~ Victim was disguised as a unknown or hostile faction so do not concider it friendly fire
135 return false;
136
137 //~ Friendly kills only counted if friendly fire is punished
139 if (additionalGameModeSettings && !additionalGameModeSettings.IsTeamKillingPunished())
140 return false;
141
142 return true;
143 }
144
145 //------------------------------------------------------------------------------------------------
150 bool IsEnemyKillPunished(SCR_EDisguisedKillingPunishment punishmentToCheck, bool editorKillsCount = false, bool checkIfAllFlagsValid = false)
151 {
152 //~ Not disguised so no need to check
154 return false;
155
156 //~ Needs to be killing a hostile
158 return false;
159
160 //~ Disguised kills do not count for admins, GMs
161 if (!editorKillsCount && m_eKillerControlType == SCR_ECharacterControlType.UNLIMITED_EDITOR)
162 return false;
163
164 //~ Check if team killing is punished
166 if (additionalGameModeSettings && !additionalGameModeSettings.IsTeamKillingPunished())
167 return false;
168
170 if (!perceivedFactionManager)
171 return false;
172
173 //~ Check if all flags are valid
174 if (checkIfAllFlagsValid)
175 return SCR_Enum.HasFlag(perceivedFactionManager.GetPunishmentKillingWhileDisguisedFlags(), punishmentToCheck);
176
177 return SCR_Enum.HasPartialFlag(perceivedFactionManager.GetPunishmentKillingWhileDisguisedFlags(), punishmentToCheck);
178 }
179
180 //------------------------------------------------------------------------------------------------
187 void SCR_InstigatorContextData(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted = false)
188 {
189 CreateInstigatorData(victimPlayerID, victimEntity, killerEntity, instigator, isDeleted);
190 }
191
192 //------------------------------------------------------------------------------------------------
199 void CreateInstigatorData(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted = false)
200 {
201 m_iVictimPlayerID = victimPlayerID;
202 m_VictimEntity = victimEntity;
203
204 //~ Makes sure it only gets the active killer entity if the current one does no longer exist to avoid Issues with players changing teams
205 if (!killerEntity)
206 m_KillerEntity = instigator.GetInstigatorEntity();
207 else
208 m_KillerEntity = killerEntity;
209
210 m_Instigator = instigator;
211 m_iKillerPlayerID = m_Instigator.GetInstigatorPlayerID();
212
213 //~ Set perceived faction vars of killer and victim
215
216 //~ Character was deleted
217 if (isDeleted)
218 {
219 if (m_iKillerPlayerID > 0)
221 else
223
224 return;
225 }
226
227 //~ Entity destroyed is not a character so no need to track
229 {
231 return;
232 }
233
234 InstigatorType instigatorType = m_Instigator.GetInstigatorType();
235
236 //~ Get player ID if non is set
238 m_iVictimPlayerID = SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(m_VictimEntity);
239
240 //~ Character was killed by an AI
241 if (instigatorType == InstigatorType.INSTIGATOR_AI)
242 {
244 }
245 //~ Character was killed by a Player
246 else if (instigatorType == InstigatorType.INSTIGATOR_PLAYER)
247 {
248 if (m_KillerEntity)
250 else if (m_iKillerPlayerID > 0)
252 }
253 //~ Instigator type is set to GM so player is killed by a GM action
254 else if (instigatorType == InstigatorType.INSTIGATOR_GM)
255 {
256 //~ Get killer controller type if any
257 if (m_iKillerPlayerID > 0)
259
260 //~ Get victim controller type if any
261 if (m_iVictimPlayerID <= 0)
263 else if (m_VictimEntity)
265 else
267
268 //~ Set relation to GM and return
270 return;
271 }
272 else
273 {
274 if (instigatorType == InstigatorType.INSTIGATOR_NONE)
275 Print("SCR_InstigatorContextData: No instigator type is set on Character death. It is likely that the KillerVictimRelation will be set to OTHER_DEATH which will not punish the victim for suicide.", LogLevel.WARNING);
276 else
277 Print("SCR_InstigatorContextData: instigatorType: '" + typename.EnumToString(InstigatorType, instigatorType) + "' is not supported!", LogLevel.ERROR);
278 }
279
280 //~ Get the control type of the victim
281 if (m_VictimEntity)
282 {
283 if (m_iVictimPlayerID <= 0)
285 else
287 }
288 else if (m_iVictimPlayerID > 0)
289 {
291 }
292
293 //~ Killed self (If not the same control type than the player shot himself by possessing another Entity
295 {
297 return;
298 }
299
300 //~ There is no killer. It is not a suicide so is not punished but it is not any of the other deaths either
302 {
304 return;
305 }
306
307 //~ Get the Faction of the victim character
309 if (!victimFaction)
310 {
311 m_eVictimKillerRelation = SCR_ECharacterDeathStatusRelations.VICTIM_IS_NEUTRAL_OR_FACTIONLESS;
312 return;
313 }
314
315 //~ Get the Faction of the killer character
317 SCR_Faction scrVictimFaction = SCR_Faction.Cast(victimFaction);
318
319 if (!scrVictimFaction || !killerFaction)
320 {
321 m_eVictimKillerRelation = SCR_ECharacterDeathStatusRelations.KILLED_BY_NEUTRAL_OR_FACTIONLESS;
322 return;
323 }
324
325 //~ Killed by Enemy
326 if (!scrVictimFaction.DoCheckIfFactionFriendly(killerFaction))
327 {
330 else
332
333 return;
334 }
335 //~ Killed by Friendly
336 else
337 {
340 else
342
343 return;
344 }
345 }
346
347 //------------------------------------------------------------------------------------------------
348 protected void SetPerceivedFaction(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted = false)
349 {
351 if (!perceivedFactionManager || perceivedFactionManager.GetCharacterPerceivedFactionOutfitType() == SCR_EPerceivedFactionOutfitType.DISABLED)
352 return;
353
354 SCR_CharacterFactionAffiliationComponent charFactionAffiliation;
355 if (killerEntity)
356 {
357 charFactionAffiliation = SCR_CharacterFactionAffiliationComponent.Cast(killerEntity.FindComponent(SCR_CharacterFactionAffiliationComponent));
358 if (charFactionAffiliation)
359 m_eKillerDisguiseType = charFactionAffiliation.GetCharacterDisguiseType();
360 }
361
362 if (victimEntity)
363 {
364 charFactionAffiliation = SCR_CharacterFactionAffiliationComponent.Cast(victimEntity.FindComponent(SCR_CharacterFactionAffiliationComponent));
365 if (charFactionAffiliation)
366 m_eVictimDisguiseType = charFactionAffiliation.GetCharacterDisguiseType();
367 }
368 }
369
370 //------------------------------------------------------------------------------------------------
371 //~ Prioritizes getting the faction of the entity but will try get player faction if the faction changes
372 protected Faction GetFaction(IEntity entity, int playerID)
373 {
374 if (!entity)
375 return GetFactionFromPlayerID(playerID);
376
377 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(entity.FindComponent(FactionAffiliationComponent));
378 if (!factionAffiliation)
379 return GetFactionFromPlayerID(playerID);
380
381 return factionAffiliation.GetAffiliatedFaction();
382 }
383
384 //------------------------------------------------------------------------------------------------
385 //~ Get faction off player ID
386 protected Faction GetFactionFromPlayerID(int playerID)
387 {
388 if (playerID <= 0)
389 return null;
390
391 return SCR_FactionManager.SGetPlayerFaction(playerID);
392 }
393}
void SCR_AdditionalGameModeSettingsComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_CampaignFaction GetFaction()
SCR_ECharacterControlType
What kind of controller the character or (in some cases vehicle) has, eg: AI, Player,...
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_PerceivedFactionManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external Managed FindComponent(typename typeName)
override bool DoCheckIfFactionFriendly(Faction faction)
SCR_ECharacterDisguiseType m_eKillerDisguiseType
SCR_ECharacterDeathStatusRelations GetVictimKillerRelation()
SCR_ECharacterControlType m_eKillerControlType
SCR_ECharacterDeathStatusRelations m_eVictimKillerRelation
bool HasAnyVictimCharacterControlType(SCR_ECharacterControlType controlType)
bool IsEnemyKillPunished(SCR_EDisguisedKillingPunishment punishmentToCheck, bool editorKillsCount=false, bool checkIfAllFlagsValid=false)
SCR_ECharacterDisguiseType GetVictimDisguiseType()
void SetPerceivedFaction(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted=false)
bool HasAnyVictimKillerRelation(SCR_ECharacterDeathStatusRelations relation)
SCR_ECharacterControlType m_eVictimControlType
SCR_ECharacterControlType GetKillerCharacterControlType()
void SCR_InstigatorContextData(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted=false)
Faction GetFaction(IEntity entity, int playerID)
bool DoesPlayerKillCountAsTeamKill(bool editorKillsCount=false, bool possessedKillsCount=false)
void CreateInstigatorData(int victimPlayerID, IEntity victimEntity, IEntity killerEntity, notnull Instigator instigator, bool isDeleted=false)
SCR_ECharacterDisguiseType m_eVictimDisguiseType
bool HasAnyKillerCharacterControlType(SCR_ECharacterControlType controlType)
SCR_ECharacterDisguiseType GetKillerDisguiseType()
Faction GetFactionFromPlayerID(int playerID)
SCR_ECharacterControlType GetVictimCharacterControlType()
InstigatorType
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