Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkTriggerEntity.c
Go to the documentation of this file.
5
6void ScriptInvokerTriggerUpdated(float activationCountdownTimer, float tempWaitTime, int playersCountByFactionInside, int playersCountByFaction, string playerActivationNotificationTitle, bool triggerConditionsStatus, float minimumPlayersNeededPercentage);
8
9class SCR_ScenarioFrameworkTriggerEntity : SCR_BaseTriggerEntity
10{
11 [Attribute(desc: "Faction which is used for area control calculation. Leave empty for any faction.", category: "Trigger")]
13
14 [Attribute("0", UIWidgets.ComboBox, "By whom the trigger is activated", "", ParamEnumArray.FromEnum(SCR_EScenarioFrameworkTriggerActivation), category: "Trigger")]
15 protected SCR_EScenarioFrameworkTriggerActivation m_eActivationPresence;
16
17 [Attribute(desc: "Fill the entity names here for detection. Is combined with other filters using OR.", category: "Trigger")]
18 protected ref array<string> m_aSpecificEntityNames;
19
20 [Attribute(desc: "Fill the class names here for detection. Is combined with other filters using OR.", category: "Trigger")]
21 protected ref array<string> m_aSpecificClassNames;
22
23 [Attribute(desc: "Which Prefabs and if their children will be detected by the trigger. Is combined with other filters using OR.", category: "Trigger")]
24 protected ref array<ref SCR_ScenarioFrameworkPrefabFilter> m_aPrefabFilter;
25
26 [Attribute(desc: "Here you can input custom trigger conditions that you can create by extending the SCR_CustomTriggerConditions", uiwidget: UIWidgets.Object)]
27 protected ref array<ref SCR_ScenarioFrameworkActivationConditionBase> m_aCustomTriggerConditions;
28
29 [Attribute(defvalue: SCR_EScenarioFrameworkLogicOperators.AND.ToString(), UIWidgets.ComboBox, "Which Boolean Logic will be used for Custom Trigger Conditions.", "", enums: SCR_EScenarioFrameworkLogicOperatorHelper.GetParamInfo(), category: "Trigger")]
31
32 [Attribute(defvalue: "1", UIWidgets.CheckBox, desc: "If you set some vehicle to be detected by the trigger, it will also search the inventory for vehicle prefabs/classes that are set", category: "Trigger")]
34
35 [Attribute(defvalue: "1", UIWidgets.CheckBox, desc: "Activate the trigger once or everytime the activation condition is true?", category: "Trigger")]
36 protected bool m_bOnce;
37
38 [Attribute(defvalue: "0", desc: "Activate the trigger once it is empty", category: "Trigger")]
39 protected bool m_bActivateOnEmpty;
40
41 [Attribute(defvalue: "0", UIWidgets.Slider, desc: "Minimum players needed to activate this trigger when PLAYER Activation presence is selected", params: "0 1 0.01", precision: 2, category: "Trigger")]
43
44 [Attribute(defvalue: "0", UIWidgets.Slider, desc: "For how long the trigger conditions must be true in order for the trigger to activate. If conditions become false, timer resets", params: "0 86400 1", category: "Trigger")]
46
47 [Attribute(defvalue: "0", UIWidgets.CheckBox, desc: "Whether or not the notification is allowed to be displayed", category: "Trigger")]
48 protected bool m_bNotificationEnabled;
49
50 [Attribute(defvalue: "{47864BB47AB0B1F4}UI/layouts/HUD/CampaignMP/CampaignMainHUD.layout", category: "Trigger")]
52
53 [Attribute(desc: "Notification title text that will be displayed when the PLAYER Activation presence is selected", category: "Trigger")]
55
56 [Attribute(defvalue: "0", UIWidgets.CheckBox, desc: "Whether or not the audio sound is played and affected by the trigger", category: "Trigger")]
57 protected bool m_bEnableAudio;
58
59 [Attribute("", UIWidgets.EditBox, desc: "Audio sound that will be playing when countdown is active.", category: "Trigger")]
60 protected string m_sCountdownAudio;
61
62 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aEntityEnteredActions = {};
63 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aEntityLeftActions = {};
64 protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aFinishedActions = {};
65
66 protected ref set<BaseContainer> m_aPrefabContainerSet = new set<BaseContainer>();
67
71 protected bool m_bInitSequenceDone = false;
73 protected ref array<IEntity> m_aEntitiesInside = {};
74 protected ref array<IEntity> m_aPlayersInside = {};
75 protected MusicManager m_MusicManager;
77 protected bool m_bTimerActive;
78 protected int m_iCountInsideTrigger;
79
80 static ref ScriptInvokerBase<ScriptInvokerTriggerUpdated> s_OnTriggerUpdated = new ScriptInvokerBase<ScriptInvokerTriggerUpdated>();
82
83 //------------------------------------------------------------------------------------------------
85 void SetActivationPresence(SCR_EScenarioFrameworkTriggerActivation EActivationPresence)
86 {
87 m_eActivationPresence = EActivationPresence;
88 }
89
90 //------------------------------------------------------------------------------------------------
92 void SetSpecificClassName(notnull array<string> aClassName)
93 {
94 foreach (ResourceName className : aClassName)
95 {
96 AddClassType(className.ToType());
97 }
98 }
99
100 //------------------------------------------------------------------------------------------------
102 void AddSpecificEntityNameFilter(notnull array<string> aEntityName)
103 {
104 foreach (ResourceName entityName : aEntityName)
105 {
106 AddFilterName(entityName);
107 }
108 }
109
110 //------------------------------------------------------------------------------------------------
112 void SetPrefabFilters(notnull array<ref SCR_ScenarioFrameworkPrefabFilter> aPrefabFilter)
113 {
114 PrefabFilter prefabFilter;
115 foreach (SCR_ScenarioFrameworkPrefabFilter prefabFilterInput : aPrefabFilter)
116 {
117 prefabFilter = new PrefabFilter();
118 prefabFilter.SetPrefab(prefabFilterInput.m_sSpecificPrefabName);
119 prefabFilter.SetCheckPrefabHierarchy(prefabFilterInput.m_bIncludeChildren);
120 AddPrefabFilter(prefabFilter);
121 }
122 }
123
124 //------------------------------------------------------------------------------------------------
127 {
129 }
130
131 //------------------------------------------------------------------------------------------------
133 void SetOnce(bool bOnce)
134 {
135 m_bOnce = bOnce;
136 }
137
138 //------------------------------------------------------------------------------------------------
140 void SetActivateOnEmpty(bool activateOnEmpty)
141 {
142 m_bActivateOnEmpty = activateOnEmpty;
143 }
144
145 //------------------------------------------------------------------------------------------------
147 void SetNotificationEnabled(bool notificationEnabled)
148 {
149 m_bNotificationEnabled = notificationEnabled;
150 }
151
152 //------------------------------------------------------------------------------------------------
155 {
157 }
158
159 //------------------------------------------------------------------------------------------------
161 void SetEnableAudio(bool enableAudio)
162 {
163 m_bEnableAudio = enableAudio;
164 }
165
166 //------------------------------------------------------------------------------------------------
168 void SetMinimumPlayersNeeded(float minimumPlayersNeededPercentage)
169 {
170 m_fMinimumPlayersNeededPercentage = minimumPlayersNeededPercentage;
171 }
172
173 //------------------------------------------------------------------------------------------------
179
180 //------------------------------------------------------------------------------------------------
182 void SetActivationCountdownTimer(float activationCountdownTimer)
183 {
184 m_fActivationCountdownTimer = activationCountdownTimer;
185 }
186
187 //------------------------------------------------------------------------------------------------
189 void SetCountdownAudio(string sAudioName)
190 {
191 m_sCountdownAudio = sAudioName;
192 }
193
194 //------------------------------------------------------------------------------------------------
196 void SetCustomTriggerConditions(notnull array<ref SCR_ScenarioFrameworkActivationConditionBase> triggerConditions)
197 {
198 m_aCustomTriggerConditions = triggerConditions;
199 SCR_CustomTriggerConditions triggerCondition;
200 foreach (SCR_ScenarioFrameworkActivationConditionBase condition : triggerConditions)
201 {
202 triggerCondition = SCR_CustomTriggerConditions.Cast(condition);
203 if (!triggerCondition)
204 continue;
205
206 triggerCondition.Prepare(this);
207 }
208 }
209
210 //------------------------------------------------------------------------------------------------
213 {
214 m_eCustomTriggerConditionLogic = customTriggerConditionLogic;
215 }
216
217 //------------------------------------------------------------------------------------------------
219 void SetEntityEnteredActions(array<ref SCR_ScenarioFrameworkActionBase> entityEnteredActions)
220 {
221 foreach (SCR_ScenarioFrameworkActionBase entityEnteredAction : entityEnteredActions)
222 {
223 m_aEntityEnteredActions.Insert(entityEnteredAction);
224 }
225 }
226
227 //------------------------------------------------------------------------------------------------
229 void SetEntityLefActions(array<ref SCR_ScenarioFrameworkActionBase> entityLefActions)
230 {
231 foreach (SCR_ScenarioFrameworkActionBase entityLefAction : entityLefActions)
232 {
233 m_aEntityLeftActions.Insert(entityLefAction);
234 }
235 }
236
237 //------------------------------------------------------------------------------------------------
239 void SetFinishedActions(array<ref SCR_ScenarioFrameworkActionBase> finishedActions)
240 {
241 foreach (SCR_ScenarioFrameworkActionBase finishedAction : finishedActions)
242 {
243 m_aFinishedActions.Insert(finishedAction);
244 }
245 }
246
247 //------------------------------------------------------------------------------------------------
250 {
251 FactionManager factionManager = GetGame().GetFactionManager();
252 if (factionManager)
253 m_OwnerFaction = factionManager.GetFactionByKey(sFaction);
254 }
255
256 //------------------------------------------------------------------------------------------------
258 bool IsMaster()
259 {
260 RplComponent comp = RplComponent.Cast(FindComponent(RplComponent));
261 return comp && comp.IsMaster();
262 }
263
264 //------------------------------------------------------------------------------------------------
267 {
268 return m_OwnerFaction;
269 }
270
271 //------------------------------------------------------------------------------------------------
277
278 //------------------------------------------------------------------------------------------------
284
285 //------------------------------------------------------------------------------------------------
288 {
289 return m_fTempWaitTime;
290 }
291
292 //------------------------------------------------------------------------------------------------
298
299 //------------------------------------------------------------------------------------------------
305
306 //------------------------------------------------------------------------------------------------
309 {
311 }
312
313 //------------------------------------------------------------------------------------------------
319
320 //------------------------------------------------------------------------------------------------
323 {
325 }
326
327 //------------------------------------------------------------------------------------------------
334
335 //------------------------------------------------------------------------------------------------
338 {
339 int iCnt = 0;
340 array<int> aPlayerIDs = {};
341 SCR_PlayerController playerController;
342 GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
343 foreach (int iPlayerID : aPlayerIDs)
344 {
345 if (!m_OwnerFaction)
346 {
347 iCnt++; //Faction not set == ANY faction
348 }
349 else
350 {
351 playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
352 if (!playerController)
353 continue;
354
355 if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
356 iCnt++;
357 }
358 }
359
360 return iCnt;
361 }
362
363 //------------------------------------------------------------------------------------------------
365 int GetSpecificClassCountInsideTrigger(string className, int targetCount = -1)
366 {
367 if (className.IsEmpty())
368 return 0;
369
371 {
372 array<IEntity> aItemsToAdd = {};
373 foreach (IEntity entity : m_aEntitiesInside)
374 {
375 if (!entity)
376 continue;
377
378 if (!Vehicle.Cast(entity))
379 continue;
380
382 if (!inventoryComponent)
383 continue;
384
385 array<IEntity> aItems = {};
386 inventoryComponent.GetItems(aItems);
387 if (!aItems.IsEmpty())
388 aItemsToAdd.InsertAll(aItems);
389 }
390
391 if (!aItemsToAdd.IsEmpty())
392 m_aEntitiesInside.InsertAll(aItemsToAdd);
393 }
394
395 int iCnt = 0;
397 foreach (IEntity entity : m_aEntitiesInside)
398 {
399 if (!entity)
400 continue;
401
402 if (entity.IsInherited(className.ToType()))
403 iCnt++;
404
405 if (iCnt == targetCount)
406 break;
407 }
408
409 return iCnt;
410 }
411
412 //------------------------------------------------------------------------------------------------
414 int GetSpecificPrefabCountInsideTrigger(BaseContainer prefabContainer, int targetCount = -1, bool includeInheritance = false)
415 {
416 int iCnt;
418
420 {
421 array<IEntity> aItemsToAdd = {};
422 foreach (IEntity entity : m_aEntitiesInside)
423 {
424 if (!entity)
425 continue;
426
427 if (!Vehicle.Cast(entity))
428 continue;
429
431 if (!inventoryComponent)
432 continue;
433
434 array<IEntity> aItems = {};
435 inventoryComponent.GetItems(aItems);
436 if (!aItems.IsEmpty())
437 aItemsToAdd.InsertAll(aItems);
438 }
439
440 if (!aItemsToAdd.IsEmpty())
441 m_aEntitiesInside.InsertAll(aItemsToAdd);
442 }
443
444 foreach (IEntity entity : m_aEntitiesInside)
445 {
446 if (!entity)
447 continue;
448
449 EntityPrefabData prefabData = entity.GetPrefabData();
450 if (!prefabData)
451 continue;
452
453 BaseContainer container = prefabData.GetPrefab();
454 if (!container)
455 continue;
456
457 if (!includeInheritance)
458 {
459 if (container != prefabContainer)
460 continue;
461
462 iCnt++;
463 }
464 else
465 {
466 while (container)
467 {
468 if (container == prefabContainer)
469 {
470 iCnt++;
471 break;
472 }
473
474 container = container.GetAncestor();
475 }
476 }
477
478 if (iCnt == targetCount)
479 break;
480 }
481
482 return iCnt;
483 }
484
485 //------------------------------------------------------------------------------------------------
487 int GetCharacterCountByFactionInsideTrigger(Faction faction, int targetCount = -1)
488 {
489 int iCnt = 0;
490 SCR_ChimeraCharacter chimeraCharacter;
492 foreach (IEntity entity : m_aEntitiesInside)
493 {
494 if (!entity)
495 continue;
496
497 chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
498 if (!chimeraCharacter)
499 continue;
500
501 if (faction && chimeraCharacter.GetFaction() != faction)
502 continue;
503
504 iCnt++;
505 if (iCnt == targetCount)
506 break;
507 }
508
509 return iCnt;
510 }
511
512 //------------------------------------------------------------------------------------------------
515 {
516 int iCnt = 0;
517 m_aPlayersInside.Clear();
519 SCR_ChimeraCharacter chimeraCharacter;
520 foreach (IEntity entity : m_aEntitiesInside)
521 {
522 if (!entity)
523 continue;
524
525 chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
526 if (!chimeraCharacter)
527 continue;
528
529 if (faction && chimeraCharacter.GetFaction() != faction)
530 continue;
531
532 if (!EntityUtils.IsPlayer(entity))
533 continue;
534
535 iCnt++;
536 m_aPlayersInside.Insert(entity);
537 }
538
539 return iCnt;
540 }
541
542 //------------------------------------------------------------------------------------------------
544 void GetPlayersByFactionInsideTrigger(notnull out array<IEntity> aOut)
545 {
546 SCR_ChimeraCharacter chimeraCharacter;
548 foreach (IEntity entity : m_aEntitiesInside)
549 {
550 if (!entity)
551 continue;
552
553 chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
554 if (!chimeraCharacter)
555 continue;
556
557 //Faction not set == ANY faction
558 if (!m_OwnerFaction)
559 {
560 if (EntityUtils.IsPlayer(entity))
561 aOut.Insert(entity)
562 }
563 else
564 {
565 if (chimeraCharacter.GetFaction() != m_OwnerFaction)
566 continue;
567
568 if (EntityUtils.IsPlayer(entity))
569 aOut.Insert(entity);
570 }
571 }
572 }
573
574 //------------------------------------------------------------------------------------------------
576 void GetPlayersByFaction(notnull out array<IEntity> aOut)
577 {
578 array<int> aPlayerIDs = {};
579 SCR_PlayerController playerController;
580 GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
581 foreach (int iPlayerID : aPlayerIDs)
582 {
583 playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
584 if (!playerController)
585 continue;
586
587 if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
588 aOut.Insert(playerController.GetLocalMainEntity());
589 }
590 }
591
592 //------------------------------------------------------------------------------------------------
595 {
596 if (m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.PLAYER || m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.ANY_CHARACTER)
597 {
598 SCR_ChimeraCharacter chimeraCharacter = SCR_ChimeraCharacter.Cast(ent);
599 if (!chimeraCharacter)
600 return false;
601
602 if (m_OwnerFaction && chimeraCharacter.GetFaction() != m_OwnerFaction)
603 return false;
604
605 if (!IsAlive(ent))
606 return false;
607
608 if (m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.PLAYER)
609 return EntityUtils.IsPlayer(ent);
610
611 return true;
612 }
613
614 //In case of vehicle, we first need to check if it is alive and then check the faction
615 Vehicle vehicle = Vehicle.Cast(ent);
616 if (vehicle)
617 {
618 if (!IsAlive(ent))
619 return false;
620
621 if (!m_OwnerFaction)
622 return true;
623
624 return vehicle.GetFaction() == m_OwnerFaction;
625 }
626
627 if (!m_OwnerFaction)
628 return true;
629
630 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(ent.FindComponent(FactionAffiliationComponent));
631 if (!factionAffiliation)
632 return true;
633
634 return factionAffiliation.GetAffiliatedFaction() == m_OwnerFaction;
635 }
636
637 //------------------------------------------------------------------------------------------------
640 {
641 if (m_bEnableAudio)
643
644 if (m_bOnce)
646
647 m_OnActivate.Invoke(ent);
648 OnChange(ent);
649
650 foreach (SCR_ScenarioFrameworkActionBase finishedActions : m_aFinishedActions)
651 {
652 finishedActions.OnActivate(this);
653 }
654 }
655
656 //------------------------------------------------------------------------------------------------
659 {
661 if (m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.PLAYER)
662 {
664 float minPlayersNeeded = Math.Ceil(GetPlayersCountByFaction() * m_fMinimumPlayersNeededPercentage);
665 if (m_iCountInsideTrigger >= minPlayersNeeded && m_iCountInsideTrigger > 0)
667
668 return;
669 }
670
673 }
674
675 //------------------------------------------------------------------------------------------------
684
685 //------------------------------------------------------------------------------------------------
688 {
689 if (m_aPlayersInside.IsEmpty())
691
692 foreach (IEntity entity : m_aPlayersInside)
693 {
694 ProcessPlayerNetworkComponent(entity, false);
695 }
696
697 //This handles Network component for players that left the trigger
698 if (ent)
700 }
701
702 //------------------------------------------------------------------------------------------------
704 protected void ProcessPlayerNetworkComponent(IEntity entity, bool leftTrigger = false)
705 {
706 PlayerManager playerManager = GetGame().GetPlayerManager();
707 int playerId = playerManager.GetPlayerIdFromControlledEntity(entity);
708 SCR_PlayerController playerController = SCR_PlayerController.Cast(playerManager.GetPlayerController(playerId));
709 if (!playerController)
710 return;
711
712 SCR_ScenarioFrameworkTriggerNetworkComponent triggerNetwork = SCR_ScenarioFrameworkTriggerNetworkComponent.Cast(playerController.FindComponent(SCR_ScenarioFrameworkTriggerNetworkComponent));
713 if (!triggerNetwork)
714 return;
715
716 triggerNetwork.ReplicateTriggerState(this, leftTrigger);
717 }
718
719 //------------------------------------------------------------------------------------------------
721 protected void HandleTimer()
722 {
723 if (!m_bTimerActive)
724 {
725 m_bTimerActive = true;
727 // Call later in this case will be more efficient than handling it via EOnFrame
729 }
730
731 if (GetCountInsideTrigger() == 0)
732 {
735 m_bTimerActive = false;
736 }
737 }
738
739 //------------------------------------------------------------------------------------------------
741 protected void UpdateTimer()
742 {
745 else
747
749 return;
750
752 }
753
754 //------------------------------------------------------------------------------------------------
756 override protected event void OnActivate(IEntity ent)
757 {
759 {
760 enteredActions.OnActivate(this);
761 }
762 }
763
764 //------------------------------------------------------------------------------------------------
766 override event protected void OnQueryFinished(bool bIsEmpty)
767 {
768 super.OnQueryFinished(bIsEmpty);
769
770 if (bIsEmpty)
771 {
773 FinishTrigger(this);
774
775 return;
776 }
777
779 return;
780
781 if (!IsMaster())
782 return;
783
785 return;
786
788
791
792 HandleTimer();
793
794 if (m_bEnableAudio)
795 HandleAudio();
796
798 FinishTrigger(this);
799 }
800
801 //------------------------------------------------------------------------------------------------
803 override protected event void OnDeactivate(IEntity ent)
804 {
805 //This method is triggered when the trigger is deactivated but the said entity is still inside.
806 //We need to perform this method after the entity leaves the trigger.
808 }
809
810 //------------------------------------------------------------------------------------------------
813 {
815 return;
816
817 m_aPlayersInside.RemoveItem(ent);
818
821 HandleTimer();
822
825
826 if (m_bEnableAudio)
827 HandleAudio();
828
829 m_OnDeactivate.Invoke();
830 OnChange(ent);
831
833 {
834 leftActions.OnActivate(this);
835 }
836 }
837
838 //------------------------------------------------------------------------------------------------
841 {
843 {
846 }
847 else
848 {
850 }
851 }
852
853 //------------------------------------------------------------------------------------------------
856 void PlayMusic(string sAudio)
857 {
858
859 if (!m_MusicManager)
860 {
861 ChimeraWorld world = GetGame().GetWorld();
862 if (world)
863 m_MusicManager = world.GetMusicManager();
864 }
865
866 if (!m_MusicManager)
867 return;
868
870 m_MusicManager.Play(sAudio);
871
872 Rpc(RpcDo_PlayMusic, sAudio);
873 }
874
875 //------------------------------------------------------------------------------------------------
878 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
879 protected void RpcDo_PlayMusic(string sAudio)
880 {
881 if (!m_MusicManager)
882 {
883 ChimeraWorld world = GetGame().GetWorld();
884 if (world)
885 m_MusicManager = world.GetMusicManager();
886 }
887
888 if (!m_MusicManager)
889 return;
890
892 m_MusicManager.Play(sAudio);
893 }
894
895 //------------------------------------------------------------------------------------------------
898 void StopMusic(string sAudio)
899 {
900 if (!m_MusicManager)
901 {
902 ChimeraWorld world = GetGame().GetWorld();
903 if (world)
904 m_MusicManager = world.GetMusicManager();
905 }
906
907 if (!m_MusicManager)
908 return;
909
911 m_MusicManager.Stop(sAudio);
912
913 Rpc(RpcDo_StopMusic, sAudio);
914 }
915
916 //------------------------------------------------------------------------------------------------
919 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
920 protected void RpcDo_StopMusic(string sAudio)
921 {
922 if (!m_MusicManager)
923 {
924 ChimeraWorld world = GetGame().GetWorld();
925 if (world)
926 m_MusicManager = world.GetMusicManager();
927 }
928
929 if (!m_MusicManager)
930 return;
931
933 m_MusicManager.Stop(sAudio);
934 }
935
936 //------------------------------------------------------------------------------------------------
939 {
940 if (m_OnChange)
941 {
942 SCR_ScenarioFrameworkParam<IEntity> param = new SCR_ScenarioFrameworkParam<IEntity>(ent);
943 m_OnChange.Invoke(param);
944 }
945 }
946
947 //------------------------------------------------------------------------------------------------
950 {
951 if (!m_OnChange)
953
954 return m_OnChange;
955 }
956
957 //------------------------------------------------------------------------------------------------
959 void SetInitSequenceDone(bool init)
960 {
961 m_bInitSequenceDone = init;
962 }
963
964 //------------------------------------------------------------------------------------------------
966 override protected void EOnInit(IEntity owner)
967 {
968 ChimeraWorld world = GetGame().GetWorld();
969 if (world)
970 m_MusicManager = world.GetMusicManager();
971
972 SCR_CustomTriggerConditions triggerCondition;
974 {
975 triggerCondition = SCR_CustomTriggerConditions.Cast(condition);
976 if (!triggerCondition)
977 continue;
978
979 triggerCondition.Prepare(this);
980 }
981
982 PrefabFilter prefabFilter;
983 foreach (SCR_ScenarioFrameworkPrefabFilter prefabFilterInput : m_aPrefabFilter)
984 {
985 prefabFilter = new PrefabFilter();
986 prefabFilter.SetPrefab(prefabFilterInput.m_sSpecificPrefabName);
987 prefabFilter.SetCheckPrefabHierarchy(prefabFilterInput.m_bIncludeChildren);
988 AddPrefabFilter(prefabFilter);
989 }
990
991 foreach (ResourceName className : m_aSpecificClassNames)
992 {
993 AddClassType(className.ToType());
994 }
995
996 foreach (string entityName : m_aSpecificEntityNames)
997 {
998 AddFilterName(entityName);
999 }
1000
1002
1003 m_bInitSequenceDone = true;
1004 }
1005}
ArmaReforgerScripted GetGame()
Definition game.c:1398
params precision
SCR_BaseTriggerEntityClass m_OnActivate
Basic scripted trigger which offers external invoekrs for major events like activation or deactivatio...
ref ScriptInvoker m_OnDeactivate
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
static Faction GetLocalControlledEntityFaction()
static IEntity GetLocalMainEntity()
static ScriptCallQueue GetCallQueuePausable()
int GetPlayersCountByFaction()
Returns number of players in game by the faction set for this trigger.
ref array< ref SCR_ScenarioFrameworkPrefabFilter > m_aPrefabFilter
void SetInitSequenceDone(bool init)
Sets Init sequence as done or not.
void SetSpecificClassName(notnull array< string > aClassName)
Sets specific classnames to be searched in the trigger.
void AddSpecificEntityNameFilter(notnull array< string > aEntityName)
Adds specific entity name to be searched in the trigger.
void SetCountdownAudio(string sAudioName)
Sets which audio can be played from activating this trigger.
int GetPlayersCountByFactionInsideTrigger(Faction faction)
Returns number of players from the selected faction that are inside this trigger.
void SetFinishedActions(array< ref SCR_ScenarioFrameworkActionBase > finishedActions)
SCR_EScenarioFrameworkTriggerActivation m_eActivationPresence
float GetActivationCountdownTimerTemp()
Returns activation countdown timer temporary value which is calculated by the trigger but changes ove...
bool GetNotificationEnabled()
Returns if HUD notifications are enabled.
void SetOnce(bool bOnce)
Sets if trigger can be finished just once.
void SetPlayerActivationNotificationTitle(string sTitle)
Sets HUD activation notification title.
string GetPlayerActivationNotificationTitle()
Returns player activation notification title.
int GetCharacterCountByFactionInsideTrigger(Faction faction, int targetCount=-1)
Returns number of characters from the selected faction that are inside this trigger.
override bool ScriptedEntityFilterForQuery(IEntity ent)
Override this method in inherited class to define a new filter.
ref array< ref SCR_ScenarioFrameworkActionBase > m_aEntityEnteredActions
void SetEntityEnteredActions(array< ref SCR_ScenarioFrameworkActionBase > entityEnteredActions)
void SetOwnerFaction(FactionKey sFaction)
Sets faction that "owns" this trigger.
void SetEntityLefActions(array< ref SCR_ScenarioFrameworkActionBase > entityLefActions)
static ref ScriptInvokerBase< ScriptInvokerTriggerUpdated > s_OnTriggerUpdated
void SetPrefabFilters(notnull array< ref SCR_ScenarioFrameworkPrefabFilter > aPrefabFilter)
Sets specific prefab filters to be searched in the trigger.
ref array< ref SCR_ScenarioFrameworkActionBase > m_aEntityLeftActions
bool GetTriggerConditionsStatus()
Returns trigger conditions status.
int GetCountInsideTrigger()
Returns number of all the entities that are inside this trigger.
ref array< ref SCR_ScenarioFrameworkActivationConditionBase > m_aCustomTriggerConditions
int GetSpecificClassCountInsideTrigger(string className, int targetCount=-1)
Returns number of specific class that is inside of this trigger.
float GetActivationCountdownTimer()
Returns activation countdown timer.
void SetTriggerConditionsStatus(bool status)
Sets trigger conditions status.
static ref ScriptInvokerInt s_OnTriggerUpdatedPlayerNotPresent
void HandleNetworkComponentForPlayersInside(IEntity ent)
Handles players inside the trigger or those who left it.
void GetPlayersByFactionInsideTrigger(notnull out array< IEntity > aOut)
Returns all the players by the faction set for this trigger.
Faction GetOwnerFaction()
Returns trigger faction owner.
int GetSpecificPrefabCountInsideTrigger(BaseContainer prefabContainer, int targetCount=-1, bool includeInheritance=false)
Returns number of specific prefab that is inside of this trigger.
void ProcessPlayerNetworkComponent(IEntity entity, bool leftTrigger=false)
Processes the entity and its Network component to replicate only for each player inside the trigger.
void HandleAudio()
Checks if trigger conditions are met, plays countdown music if true, stops if false.
void SetActivationPresence(SCR_EScenarioFrameworkTriggerActivation EActivationPresence)
Sets Activation Presence.
ref array< ref SCR_ScenarioFrameworkActionBase > m_aFinishedActions
void SetMinimumPlayersNeeded(float minimumPlayersNeededPercentage)
Sets minimum player percentage needed to finish this trigger.
void UpdateTimer()
Updates the timer value and passes info to HUD.
void SetCustomTriggerConditionLogic(SCR_EScenarioFrameworkLogicOperators customTriggerConditionLogic)
Sets Custom Trigger Condition Logic.
float GetMinimumPlayersNeededPercentage()
Returns minimum players needed percentage.
void SetEnableAudio(bool enableAudio)
Sets if audio features from this trigger are enabled.
void ActivationPresenceConditions()
Checks activation presesence conditions.
void SetCustomTriggerConditions(notnull array< ref SCR_ScenarioFrameworkActivationConditionBase > triggerConditions)
ResourceName GetCountdownHUD()
Returns the countdown HUD resource name.
void SetSearchVehicleInventory(bool search)
Sets if trigger should also search vehicle inventory when looking for prefabs/classnames inside.
void HandleTimer()
Handles if timer should be ticking or not.
void SetActivationCountdownTimer(float activationCountdownTimer)
Sets activation coundown timer.
void CustomTriggerConditions()
This method handles custom conditions.
void EOnInit(IEntity owner)
Initializes the trigger.
void SetNotificationEnabled(bool notificationEnabled)
Sets if HUD notifications are enabled.
SCR_EScenarioFrameworkLogicOperators m_eCustomTriggerConditionLogic
bool IsMaster()
Returns if this is executed in a server environment.
void GetPlayersByFaction(notnull out array< IEntity > aOut)
Returns all the players in the game.
int GetCountEntitiesInside()
Returns all entities that are inside this trigger.
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
proto external void AddClassType(typename classType)
Add a class type to the filter.
proto external int GetEntitiesInside(out notnull array< IEntity > outEntities)
proto external void AddFilterName(string name)
Add a name to the filter.
proto external void EnablePeriodicQueries(bool enable)
proto external void AddPrefabFilter(PrefabFilter prefabFilter)
Add a prefab filter to the filters.
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134