6 protected override void InitModule()
11 RplComponent rplComp = RplComponent.Cast(
GetGame().
GetGameMode().FindComponent(RplComponent));
12 if (rplComp.IsMaster())
18 SCR_CampaignNetworkComponent.GetOnSuppliesDelivered().Insert(SuppliesDelivered);
21 if (supportStationManager)
23 supportStationManager.GetOnSupportStationExecutedSuccessfully().Insert(OnSupportStationUsed);
31 SCR_MineInventoryItemComponent.GetOnMinePlaced().Insert(MinePlaced);
38 protected override void AddInvokers(IEntity player)
41 SCR_ChimeraCharacter chimeraPlayer = SCR_ChimeraCharacter.Cast(player);
46 if (!characterController)
49 characterController.m_OnItemUseEndedInvoker.Insert(OnItemUsed);
53 protected override void RemoveInvokers(IEntity player)
55 SCR_ChimeraCharacter chimeraPlayer = SCR_ChimeraCharacter.Cast(player);
60 if (!characterController)
63 characterController.m_OnItemUseEndedInvoker.Remove(OnItemUsed);
73 SCR_MineInventoryItemComponent.GetOnMinePlaced().Remove(MinePlaced);
75 SCR_CampaignNetworkComponent.GetOnSuppliesDelivered().Remove(SuppliesDelivered);
78 if (supportStationManager)
80 supportStationManager.GetOnSupportStationExecutedSuccessfully().Remove(OnSupportStationUsed);
85 override void OnPlayerKilled(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
88 if (killer.GetInstigatorType() !=
InstigatorType.INSTIGATOR_PLAYER)
93 const int killerId = killer.GetInstigatorPlayerID();
96 if (playerId == killerId)
115 Faction victimFaction = factionManager.GetPlayerFaction(playerId);
121 Faction killerFaction = factionManager.GetPlayerFaction(killerId);
128 if (victimFaction.IsFactionFriendly(killerFaction))
138 override void OnGameModeEnd()
140 array<int> players = {};
141 GetGame().GetPlayerManager().GetPlayers(players);
142 int playerCount = players.Count();
144 SCR_GameModeCombatOpsManager combatOps = SCR_GameModeCombatOpsManager.Cast(
GetGame().
GetGameMode().FindComponent(SCR_GameModeCombatOpsManager));
147 if (!combatOps && !conflict)
154 array<SCR_BaseTask> activeTasks = {};
155 array<SCR_BaseTask> finishedTasks = {};
156 taskManager.GetTasks(activeTasks);
157 taskManager.GetFinishedTasks(finishedTasks);
163 if (finishedTasks.Count() > activeTasks.Count())
165 for(
int i = 0; i < playerCount; i++)
167 CleanSweepCombatOps(players[i]);
168 SecureIntelCombatOps(players[i]);
176 bool foundIntel =
false;
184 if (task.GetTitle().Contains(
"Intel"))
187 for(
int i = 0; i < playerCount; i++)
189 SecureIntelCombatOps(players[i]);
203 if (task.GetTaskState() ==
SCR_TaskState.FINISHED && task.GetTitle().Contains(
"Intel"))
206 for(
int i = 0; i < playerCount; i++)
208 SecureIntelCombatOps(players[i]);
217 else if (conflict && conflict.IsTutorial())
220 if (finishedTasks.Count() >= activeTasks.Count())
222 for(
int i = 0; i < playerCount; i++)
224 CleanSweepTutorial(players[i]);
233 protected void OnItemUsed(IEntity item,
bool actionCompleted,
ItemUseParameters animParams)
236 if (!item || !actionCompleted)
242 SCR_ConsumableItemComponent consumableComp = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
264 IEntity userCharacter = consumableComp.GetCharacterOwner();
270 IEntity targetCharacter = consumableComp.GetTargetCharacter();
271 if (!targetCharacter)
277 if (userCharacter == targetCharacter)
283 int userPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(userCharacter);
284 if (userPlayerId == 0)
290 int targetPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(targetCharacter);
291 if (targetPlayerId == 0)
310 if (actionTarget == actionUser)
316 int userPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionUser);
317 if (userPlayerId == 0)
323 int targetPlayerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(actionTarget);
324 if (targetPlayerId == 0)
338 switch (instrumentType)
341 PianoPlayed(playerId);
344 OrganPlayed(playerId);
350 protected void UnlockAchievement(
int playerId,
AchievementId achievementId)
352 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
353 if (!playerController)
356 SCR_AchievementsHandler handler = SCR_AchievementsHandler.Cast(playerController.FindComponent(SCR_AchievementsHandler));
360 handler.UnlockAchievement(achievementId);
364 protected void IncrementAchievementProgress(
int playerId,
AchievementStatId achievementStatId)
366 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
367 if (!playerController)
370 SCR_AchievementsHandler handler = SCR_AchievementsHandler.Cast(playerController.FindComponent(SCR_AchievementsHandler));
374 handler.IncrementAchievementProgress(achievementStatId);
378 protected void ToiletFlushed(
int playerId)
381 Print(
"Player with id " + playerId +
" flushed a toilet!", LogLevel.DEBUG);
386 protected void VehicleDestroyed(
int playerId)
399 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(playerEntity);
403 Print(
"Player with id " + playerId +
" ranked up to major!", LogLevel.DEBUG);
408 protected void SuppliesDelivered(
int playerId,
int suppliesDelivered,
int totalSuppliesDelivered)
411 const int TARGET_AMOUNT = 5000;
413 if (totalSuppliesDelivered < TARGET_AMOUNT)
416 Print(
"Player with id " + playerId +
" delivered lots of supplies!", LogLevel.DEBUG);
421 protected void CleanSweepCombatOps(
int playerId)
424 Print(
"Player with id " + playerId +
" cleanswept combat ops!", LogLevel.DEBUG);
429 protected void SecureIntelCombatOps(
int playerId)
432 Print(
"Player with id " + playerId +
" has secured the intel!", LogLevel.DEBUG);
437 protected void CleanSweepTutorial(
int playerId)
440 Print(
"Player with id " + playerId +
" has cleanswept the tutorial!", LogLevel.DEBUG);
441 UnlockAchievement(playerId,
AchievementId.SWEAT_SAVES_BLOOD);
445 protected void MinePlaced(
int playerId)
448 Print(
"Player with id " + playerId +
" placed a mine!", LogLevel.DEBUG);
453 protected void PianoPlayed(
int playerId)
456 Print(
"Player with id " + playerId +
" played a Piano!", LogLevel.DEBUG);
461 protected void OrganPlayed(
int playerId)
464 Print(
"Player with id " + playerId +
" played an Organ!", LogLevel.DEBUG);