1[
EntityEditorProps(
category:
"GameScripted/DataCollection/", description:
"Main component used for collecting player data.")]
9 protected ref array<ref SCR_DataCollectorModule> m_aModules;
14 [
Attribute(
"3",
desc:
"Optional kicking: Penalty score for killing a friendly player.")]
17 [
Attribute(
"1",
desc:
"Penalty score for killing a friendly AI.")]
20 [
Attribute(
"10",
desc:
"Penalty score limit for a kick from the match.")]
23 [
Attribute(
"1800",
desc:
"Ban duration after a kick (in seconds, -1 for a session-long ban).")]
26 [
Attribute(
"900",
desc:
"How often penalty score subtraction happens (in seconds).")]
29 [
Attribute(
"2",
desc:
"How many penalty points get substracted after each subtraction period.")]
45 protected bool m_bLocalEntityListening =
false;
46 protected int m_iInitializingTimer = 0;
47 protected bool m_bVisualDisplay =
false;
55 module.OnGameModeEnd();
60 PlayerController playerController;
61 SCR_DataCollectorCommunicationComponent communicationComponent;
64 SCR_ChimeraCharacter playerChimera;
74 playerChimera = SCR_ChimeraCharacter.Cast(playerManager.GetPlayerControlledEntity(playerID));
78 faction = playerChimera.GetFaction();
87 array<FactionKey> factionKeys = {};
88 array<float> factionValues = {};
93 factionKeys.Insert(key);
94 factionValues.InsertAll(value);
96 valuesSize = value.Count();
102 playerController = playerManager.GetPlayerController(playerID);
103 if (!playerController)
106 communicationComponent = SCR_DataCollectorCommunicationComponent.Cast(playerController.FindComponent(SCR_DataCollectorCommunicationComponent));
107 if (!communicationComponent)
110 communicationComponent.SendData(
m_mPlayerData.Get(playerID), factionKeys, factionValues, valuesSize);
118 FactionManager factionManager =
GetGame().GetFactionManager();
121 Faction winFaction = factionManager.GetFactionByIndex(
data.GetWinnerFactionId());
123 dataEvent.name_winner_faction = winFaction.GetFactionKey();
163 int statsCount = stats.Count();
165 if (statsCount == 0 || factionStats.Count() != statsCount)
167 Print(
"ERROR WHEN ADDING FACTIONSTATS IN DATA COLLECTOR: Size of faction stats is different than expected size! Expected size was" + statsCount +
" but real size was "+ factionStats.Count(),
LogLevel.WARNING);
171 for (
int i = 0; i < statsCount; i++)
173 factionStats[i] = factionStats[i] + stats[i];
196 for (
int i = m_aModules.Count() - 1; i >= 0; i--)
199 return m_aModules[i];
207 RplComponent rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
208 return (rplComponent && rplComponent.IsMaster());
245 if (!playerData && createNew)
247 playerData =
new SCR_PlayerData(playerID,
true, requestFromBackend);
278 Print(
"Player with id " + playerId +
" was auditted succesfully and admitted on the Data Collector",
LogLevel.DEBUG);
285 module.OnPlayerAuditSuccess(playerId);
302 module.OnPlayerDisconnected(playerId);
314 IEntity player =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
315 SCR_ChimeraCharacter playerChimera = SCR_ChimeraCharacter.Cast(player);
318 Faction faction = playerChimera.GetFaction();
332 int playerId = requestComponent.GetPlayerId();
335 module.OnPlayerSpawned(playerId, entity);
342 int playerId = instigatorContextData.GetVictimPlayerID();
343 IEntity playerEntity = instigatorContextData.GetVictimEntity();
344 IEntity killerEntity = instigatorContextData.GetKillerEntity();
345 Instigator instigator = instigatorContextData.GetInstigator();
349 module.OnPlayerKilled(playerId, playerEntity, killerEntity, instigator, instigatorContextData);
353 m_OptionalKicking.OnControllableDestroyed(playerEntity, killerEntity, instigator, instigatorContextData);
361 module.OnAIKilled(AIEntity, killerEntity, instigator, instigatorContextData);
365 m_OptionalKicking.OnControllableDestroyed(AIEntity, killerEntity, instigator, instigatorContextData);
373 IEntity entity = instigatorContextData.GetVictimEntity();
375 if (!SCR_ChimeraCharacter.Cast(entity))
388 if (instigatorContextData.GetVictimPlayerID() > 0)
391 OnAIKilled(entity, instigatorContextData.GetKillerEntity(), instigatorContextData.GetInstigator(), instigatorContextData);
400 foreach (SCR_DataCollectorModule module : m_aModules)
402 module.OnControlledEntityChanged(from, to);
408 protected void ListenToLocalControllerEntityChanged()
412 if (playerController)
414 m_bLocalEntityListening =
true;
421 protected void CreateStatVisualizations()
426 for (
int i = m_aModules.Count() - 1; i >= 0; i--)
428 m_aModules[i].CreateVisualization();
434 SCR_DataCollectorUI GetUIHandler()
476 bool writingRights =
false;
483 writingRights = baStorage.GetOnlineWritePrivilege();
488 Print(
"DataCollectorComponent: StartDataCollectorSession: This server has no writing privileges. Will use local storage instead.",
LogLevel.DEBUG);
490 Print(
"DataCollectorComponent: StartDataCollectorSession: Using online backend storage.",
LogLevel.DEBUG);
493 Print(
"DataCollectorComponent: StartDataCollectorSession: m_Owner is null. Can't add the EntityEvent.FRAME flag thus data collector will not work properly.",
LogLevel.ERROR);
523 CreateStatVisualizations();
530 for (
int i = m_aModules.Count() - 1; i >= 0; i--)
532 m_aModules[i].Update(timeSlice);
546 GetGame().RegisterDataCollector(
this);
ArmaReforgerScripted GetGame()
SCR_DataCollectorComponent GetDataCollector()
override void OnGameModeEnd(SCR_GameModeEndData data)
override void OnGameEnd()
Called on all machines when the world ends.
SCR_AnalyticsDataCollectionModule FindModule(typename type)
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override void OnGameModeStart()
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Managed GetPlayerDataStats(int playerID)
void DisableModules()
Use this method to disable all the modules.
void OnAIKilled(IEntity AIEntity, IEntity killerEntity, notnull Instigator instigator, notnull SCR_InstigatorContextData instigatorContextData)
void StartDataCollectorSession()
ref SCR_SessionData m_SessionData
int m_iOptionalKickingPenaltySubtractionPeriod
SCR_SessionData GetSessionData()
int GetPlayers(out notnull array< int > outPlayers)
int m_iOptionalKickingFriendlyAIKillPenalty
int m_iOptionalKickingBanDuration
int m_iOptionalKickingPenaltySubtractionPoints
ref SCR_LocalPlayerPenalty m_OptionalKicking
SCR_PlayerData GetPlayerData(int playerID, bool createNew=true, bool requestFromBackend=true)
ref map< int, ref SCR_PlayerData > m_mPlayerData
ref map< FactionKey, ref array< float > > m_mFactionScore
ref SCR_DataCollectorUI m_UiHandler
void RemovePlayer(int playerID)
map< FactionKey, ref array< float > > GetAllFactionStats()
int m_iOptionalKickingFriendlyPlayerKillPenalty
array< float > GetFactionStats(FactionKey key)
void AddStatsToFaction(FactionKey key, notnull array< float > stats)
Managed GetSessionDataStats()
override void OnPlayerAuditSuccess(int playerId)
int m_iOptionalKickingKickPenaltyLimit
Get all prefabs that have the spawner data
void OnControllableDestroyed(IEntity entity, IEntity killerEntity, Instigator instigator, notnull SCR_InstigatorContextData instigatorContextData)
void SCR_LocalPlayerPenalty(int friendlyPlayerKillPenalty, int friendlyAIKillPenalty, int penaltyLimit, int banDuration, int penaltySubtractionPeriod, int penaltySubtractionPoints)
override void EOnFrame(IEntity owner, float timeSlice)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
enum EVehicleType IEntity
SCR_EGameModeState GetState()
ref OnControlledEntityChangedPlayerControllerInvoker m_OnControlledEntityChanged
sealed array< float > CalculateStatsDifference()
sealed void StoreProfile()
Managed GetDataEventStats()
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
proto external PlayerController GetPlayerController()
void OnPlayerConnected(int playerId)