8 [
Attribute(
"1",
desc:
"Show player left notification if player left.")]
9 protected bool m_bShowPlayerLeftNotification;
11 [
Attribute(
"10",
desc:
"Is killfeed enabled and what info will be displayed (Full killfeed is always displayed in open unlimited Editor)", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(
EKillFeedType))]
14 [
Attribute(
"40",
desc:
"If killfeed is enabled, what is the relationship between the player that died and the local player. (Full killfeed is always displayed in open unlimited Editor)", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EKillFeedReceiveType))]
15 protected EKillFeedReceiveType m_iReceiveKillFeedType;
18 protected ref array<ref SCR_NotificationKillfeedTypeName> m_aKillfeedTypeNames;
21 protected ref array<ref SCR_NotificationKillfeedreceiveTypeName> m_aKillfeedReceiveTypeNames;
23 [
Attribute(
"{D3BFEE28E7D5B6A1}Configs/ServerBrowser/KickDialogs.conf",
desc:
"If disconnect reason has a preset set to it then it will send a kick/ban notification",
params:
"conf")]
37 if (Replication.IsClient())
43 RplComponent entityRpl = RplComponent.Cast(entity.FindComponent(RplComponent));
44 RplComponent instigatorRpl;
47 instigatorRpl = RplComponent.Cast(killerEntity.FindComponent(RplComponent));
49 RplId entityRplId = RplId.Invalid();
50 RplId instigatorRplId = RplId.Invalid();
53 entityRplId = entityRpl.Id();
56 instigatorRplId = instigatorRpl.Id();
58 OnControllableDestroyedBroadCast(entityRplId, instigatorRplId);
59 Rpc(OnControllableDestroyedBroadCast, entityRplId,instigatorRplId);
66 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
67 protected void OnControllableDestroyedBroadCast(RplId entityRplId, RplId instigatorRplId)
72 RplComponent entityRpl = RplComponent.Cast(Replication.FindItem(entityRplId));
73 RplComponent instigatorRpl = RplComponent.Cast(Replication.FindItem(instigatorRplId));
76 entity = entityRpl.GetEntity();
79 instigator = instigatorRpl.GetEntity();
81 OnControllableDestroyedHotfix(entity, instigator);
87 protected void OnControllableDestroyedHotfix(IEntity entity, IEntity instigator)
93 bool isUnlimitedEditorOpened =
false;
98 isUnlimitedEditorOpened = !editorManager.IsLimited() && editorManager.IsOpened();
101 if (!isUnlimitedEditorOpened && m_iKillFeedType ==
EKillFeedType.DISABLED)
104 int playerId = SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(entity);
109 if (!isUnlimitedEditorOpened && m_iReceiveKillFeedType != EKillFeedReceiveType.ALL)
118 if (!localPlayerFaction)
124 switch (m_iReceiveKillFeedType)
127 case EKillFeedReceiveType.GROUP_ONLY :
130 if (localPlayerID != playerId)
133 if (!localPlayerFaction.IsFactionFriendly(killedPlayerFaction))
141 SCR_AIGroup localPlayerGroup = groupManager.GetPlayerGroup(localPlayerID);
144 if (!localPlayerGroup || !localPlayerGroup.IsPlayerInGroup(playerId))
152 case EKillFeedReceiveType.SAME_FACTION_ONLY :
155 if (localPlayerID != playerId)
158 if (!localPlayerFaction || localPlayerFaction != killedPlayerFaction)
162 if (!localPlayerFaction.IsFactionFriendly(localPlayerFaction))
170 case EKillFeedReceiveType.ALLIES_ONLY :
173 if (localPlayerID != playerId)
176 if (!localPlayerFaction || !localPlayerFaction.IsFactionFriendly(killedPlayerFaction))
184 case EKillFeedReceiveType.ENEMIES_ONLY :
187 if (localPlayerID == playerId)
191 if (localPlayerFaction.IsFactionFriendly(killedPlayerFaction))
200 if (!isUnlimitedEditorOpened && m_iKillFeedType ==
EKillFeedType.UNKNOWN_KILLER)
202 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_DIED, playerId);
207 if (entity == instigator)
210 killerId = SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(instigator);
212 SCR_EditableCharacterComponent killerEditableCharacterComponent;
214 if (instigator && killerId <= 0)
216 killerEditableCharacterComponent = SCR_EditableCharacterComponent.Cast(instigator.FindComponent(SCR_EditableCharacterComponent));
219 if (!killerEditableCharacterComponent)
220 killerEditableCharacterComponent = GetKillerFromVehicle(instigator, instigator.IsInherited(Vehicle));
222 if (killerEditableCharacterComponent)
223 killerId = SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(killerEditableCharacterComponent.GetOwner());
226 bool playerIsPossessed =
false;
227 bool killerIsPossessed =
false;
230 SCR_PossessingManagerComponent possesionManager = SCR_PossessingManagerComponent.GetInstance();
231 if (possesionManager)
233 playerIsPossessed = possesionManager.IsPossessing(playerId);
236 killerIsPossessed = possesionManager.IsPossessing(killerId);
241 if (playerId == killerId || !instigator)
244 if (!playerIsPossessed)
245 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_DIED, playerId);
248 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.POSSESSED_AI_DIED, playerId);
251 else if (killerId > 0)
254 if (!playerIsPossessed && !killerIsPossessed)
256 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_KILLED_PLAYER, killerId, playerId);
259 else if (!playerIsPossessed && killerIsPossessed)
261 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.POSSESSED_AI_KILLED_PLAYER, killerId, playerId);
262 SCR_NotificationsComponent.SendLocalLimitedEditor(
ENotification.AI_KILLED_PLAYER, killerId, playerId);
265 else if (playerIsPossessed && !killerIsPossessed)
267 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.PLAYER_KILLED_POSSESSED_AI, killerId, playerId);
272 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.POSSESSED_AI_KILLED_POSSESSED_AI, killerId, playerId);
276 else if (killerEditableCharacterComponent)
278 int killerRplId = Replication.FindId(killerEditableCharacterComponent);
280 if (!playerIsPossessed)
281 SCR_NotificationsComponent.SendLocal(
ENotification.AI_KILLED_PLAYER, killerRplId, playerId);
283 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.AI_KILLED_POSSESSED_AI, killerRplId, playerId);
288 if (!playerIsPossessed)
289 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_DIED, playerId);
291 SCR_NotificationsComponent.SendLocalUnlimitedEditor(
ENotification.POSSESSED_AI_DIED, playerId);
296 protected SCR_EditableCharacterComponent GetKillerFromVehicle(IEntity veh,
bool pilot)
298 BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(veh.FindComponent(BaseCompartmentManagerComponent));
300 if (!compartmentManager)
303 array<BaseCompartmentSlot> compartments = {};
305 for (
int i = 0, compart = compartmentManager.GetCompartments(compartments); i < compart; i++)
307 BaseCompartmentSlot slot = compartments[i];
311 if (slot.GetOccupant())
312 return SCR_EditableCharacterComponent.Cast(slot.GetOccupant().FindComponent(SCR_EditableCharacterComponent));
316 if (slot.GetOccupant())
317 return SCR_EditableCharacterComponent.Cast(slot.GetOccupant().FindComponent(SCR_EditableCharacterComponent));
331 int playerID = editorManager.GetPlayerID();
335 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_PLAYER_NO_LONGER_GM, playerID);
338 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_PLAYER_BECAME_GM, playerID);
345 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_JOINED, playerId);
360 editorManager = core.GetEditorManager(playerId);
362 bool hasUnlimitedEditor = editorManager && !editorManager.IsLimited();
365 if (hasUnlimitedEditor)
366 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_GM_LEFT, playerId);
368 bool isKickedOrBanned =
false;
371 if (m_PlayerKickReasonsConfig)
373 string groupId, reasonId;
378 GetGame().GetFullKickReason(cause, groupInt, reasonInt, groupId, reasonId);
382 isKickedOrBanned = preset !=
null && !preset.m_sMessage.IsEmpty();
387 Print(
"'SCR_NotificationSenderComponent' has no 'm_PlayerKickReasonsConfig'! Make sure it is added else it will never know if a player was kicked!", LogLevel.ERROR);
391 if (isKickedOrBanned || timeout != 0)
393 SCR_DataCollectorComponent dataCollector =
GetGame().GetDataCollector();
396 SCR_PlayerData playerData = dataCollector.GetPlayerData(playerId);
400 float banTimeOut = playerData.GetTimeOut();
403 if (banTimeOut > 0 && banTimeOut > timeout)
404 timeout = banTimeOut;
410 SCR_NotificationsComponent.SendToEveryone(
ENotification.PLAYER_KICKED, playerId, cause, timeout);
412 else if (timeout < 0)
413 SCR_NotificationsComponent.SendToEveryone(
ENotification.PLAYER_BANNED_NO_DURATION, playerId, cause, timeout);
416 SCR_NotificationsComponent.SendToEveryone(
ENotification.PLAYER_BANNED, playerId, cause, timeout);
419 else if (m_bShowPlayerLeftNotification && !hasUnlimitedEditor)
421 SCR_NotificationsComponent.SendToEveryone(
ENotification.PLAYER_LEFT, playerId);
438 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(
ENotification.PLAYER_JOINED_FACTION, playerId);
450 void OnWeatherChangedNotification(
int playerID)
452 if (Replication.IsClient())
458 GetGame().GetCallqueue().CallLater(OnWeatherChangedNotificationDelay, 0 ,
false, playerID);
463 protected void OnWeatherChangedNotificationDelay(
int playerID)
471 TimeAndWeatherManagerEntity weatherManager = world.GetTimeAndWeatherManager();
475 WeatherState currentState = weatherManager.GetCurrentWeatherState();
480 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(
ENotification.EDITOR_ATTRIBUTES_WEATHER_CHANGED, playerID, currentState.GetStateID());
489 int GetKillFeedTypeNames(notnull array<ref SCR_NotificationKillfeedTypeName> killFeedTypeNames)
491 killFeedTypeNames.Clear();
492 foreach (SCR_NotificationKillfeedTypeName killfeedTypeName: m_aKillfeedTypeNames)
494 killFeedTypeNames.Insert(killfeedTypeName);
497 return killFeedTypeNames.Count();
504 int GetKillFeedReceiveTypeNames(notnull array<ref SCR_NotificationKillfeedreceiveTypeName> killFeedReceiveTypeNames)
506 killFeedReceiveTypeNames.Clear();
509 killFeedReceiveTypeNames.Insert(killfeedReceiveTypeName);
512 return killFeedReceiveTypeNames.Count();
519 return m_iKillFeedType;
526 void SetKillFeedType(
EKillFeedType killFeedType,
int playerNotificationId = -1)
531 SetKillFeedTypeBroadcast(killFeedType);
532 Rpc(SetKillFeedTypeBroadcast, killFeedType);
534 if (playerNotificationId > 0)
535 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_CHANGED_KILLFEED_TYPE, playerNotificationId, killFeedType,
false);
540 EKillFeedReceiveType GetReceiveKillFeedType()
542 return m_iReceiveKillFeedType;
549 void SetReceiveKillFeedType(EKillFeedReceiveType receiveKillFeedType,
int playerNotificationId = -1)
554 SetReceiveKillFeedTypeBroadcast(receiveKillFeedType);
555 Rpc(SetReceiveKillFeedTypeBroadcast, receiveKillFeedType);
557 if (playerNotificationId > 0)
558 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_CHANGED_KILLFEED_RECEIVE_TYPE, playerNotificationId, receiveKillFeedType,
true);
562 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
563 protected void SetKillFeedTypeBroadcast(
EKillFeedType killFeedType)
565 m_iKillFeedType = killFeedType;
569 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
570 protected void SetReceiveKillFeedTypeBroadcast(EKillFeedReceiveType receiveKillFeedType)
572 m_iReceiveKillFeedType = receiveKillFeedType;
578 override bool RplSave(ScriptBitWriter writer)
580 writer.WriteInt(m_iKillFeedType);
581 writer.WriteInt(m_iReceiveKillFeedType);
587 override bool RplLoad(ScriptBitReader reader)
590 EKillFeedReceiveType receiveKillFeedType;
592 reader.ReadInt(killFeedType);
593 reader.ReadInt(receiveKillFeedType);
595 SetKillFeedTypeBroadcast(killFeedType);
596 SetReceiveKillFeedTypeBroadcast(receiveKillFeedType);
604 override void EOnInit(IEntity owner)
612 super.EOnInit(owner);
618 SetEventMask(owner, EntityEvent.INIT);
620 super.OnPostInit(owner);
626 protected override void OnDelete(IEntity owner)
632 super.OnDelete(owner);
648 enum EKillFeedReceiveType
660 class SCR_NotificationKillfeedTypeName
665 [
Attribute(
desc:
"Name displayed in Notification", uiwidget: UIWidgets.LocaleEditBox)]
672 return m_iKillfeedType;
679 return m_sKillfeedTypeName;
687 [
Attribute(
desc:
"Killfeed receive type", uiwidget : UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EKillFeedReceiveType))]
688 protected EKillFeedReceiveType m_iKillfeedreceiveType;
690 [
Attribute(
desc:
"Name displayed in Notification", uiwidget: UIWidgets.LocaleEditBox)]
697 return m_iKillfeedreceiveType;
704 return m_sKillfeedReceiveTypeName;