Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CharacterTriggerEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Triggers", description: "")]
3 {
4 }
5 
6 enum TA_EActivationPresence // TODO: SCR_
7 {
8  PLAYER = 0,
12 }
13 
14 void ScriptInvokerTriggerUpdated(float activationCountdownTimer, float tempWaitTime, int playersCountByFactionInside, int playersCountByFaction, string playerActivationNotificationTitle, bool triggerConditionsStatus, float minimumPlayersNeededPercentage);
16 
17 class SCR_CharacterTriggerEntity : SCR_BaseTriggerEntity
18 {
19  [Attribute(desc: "Faction which is used for area control calculation. Leave empty for any faction.", category: "Trigger")]
20  protected FactionKey m_sOwnerFactionKey;
21 
22  [Attribute("0", UIWidgets.ComboBox, "By whom the trigger is activated", "", ParamEnumArray.FromEnum(TA_EActivationPresence), category: "Trigger")]
23  protected TA_EActivationPresence m_eActivationPresence;
24 
25  [Attribute(desc: "Fill the entity names here for detection. Is combined with other filters using OR.", category: "Trigger")]
26  protected ref array<string> m_aSpecificEntityNames;
27 
28  [Attribute(desc: "Fill the class names here for detection. Is combined with other filters using OR.", category: "Trigger")]
29  protected ref array<string> m_aSpecificClassNames;
30 
31  [Attribute(desc: "Which Prefabs and if their children will be detected by the trigger. Is combined with other filters using OR.", category: "Trigger")]
32  protected ref array<ref SCR_ScenarioFrameworkPrefabFilter> m_aPrefabFilter;
33 
34  [Attribute(desc: "Here you can input custom trigger conditions that you can create by extending the SCR_CustomTriggerConditions", uiwidget: UIWidgets.Object)]
35  protected ref array<ref SCR_CustomTriggerConditions> m_aCustomTriggerConditions;
36 
37  [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")]
38  protected bool m_bSearchVehicleInventory;
39 
40  [Attribute(defvalue: "1", UIWidgets.CheckBox, desc: "Activate the trigger once or everytime the activation condition is true?", category: "Trigger")]
41  protected bool m_bOnce;
42 
43  [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")]
44  protected float m_fMinimumPlayersNeededPercentage;
45 
46  [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")]
47  protected float m_fActivationCountdownTimer;
48 
49  [Attribute(defvalue: "0", UIWidgets.CheckBox, desc: "Whether or not the notification is allowed to be displayed", category: "Trigger")]
50  protected bool m_bNotificationEnabled;
51 
52  [Attribute(defvalue: "{47864BB47AB0B1F4}UI/layouts/HUD/CampaignMP/CampaignMainHUD.layout", category: "Trigger")]
53  protected ResourceName m_sCountdownHUD;
54 
55  [Attribute(desc: "Notification title text that will be displayed when the PLAYER Activation presence is selected", category: "Trigger")]
56  protected string m_sPlayerActivationNotificationTitle;
57 
58  [Attribute(defvalue: "0", UIWidgets.CheckBox, desc: "Whether or not the audio sound is played and affected by the trigger", category: "Trigger")]
59  protected bool m_bEnableAudio;
60 
61  [Attribute("", UIWidgets.EditBox, desc: "Audio sound that will be playing when countdown is active.", category: "Trigger")]
62  protected string m_sCountdownAudio;
63 
64  protected ref set<BaseContainer> m_aPrefabContainerSet = new set<BaseContainer>();
65 
66  protected ref ScriptInvoker m_OnChange;
67  protected Faction m_OwnerFaction;
68  protected float m_fTempWaitTime = m_fActivationCountdownTimer;
69  protected bool m_bInitSequenceDone = false;
70  protected bool m_bCountdownMusicPlaying;
71  protected ref array<IEntity> m_aEntitiesInside = {};
72  protected ref array<IEntity> m_aPlayersInside = {};
73  protected MusicManager m_MusicManager;
74  protected bool m_bTriggerConditionsStatus;
75  protected bool m_bTimerActive;
76  protected int m_iCountInsideTrigger;
77 
78  static ref ScriptInvokerBase<ScriptInvokerTriggerUpdated> s_OnTriggerUpdated = new ScriptInvokerBase<ScriptInvokerTriggerUpdated>();
79  static ref ScriptInvokerInt s_OnTriggerUpdatedPlayerNotPresent = new ScriptInvokerInt();
80 
81  //------------------------------------------------------------------------------------------------
83  void SetActivationPresence(TA_EActivationPresence EActivationPresence)
84  {
85  m_eActivationPresence = EActivationPresence;
86  }
87 
88  //------------------------------------------------------------------------------------------------
90  void SetSpecificClassName(array<string> aClassName)
91  {
92  foreach (string className : aClassName)
93  {
94  if (!m_aSpecificClassNames.Contains(className))
95  m_aSpecificClassNames.Insert(className);
96  }
97  }
98 
99  //------------------------------------------------------------------------------------------------
101  void SetPrefabFilters(array<ref SCR_ScenarioFrameworkPrefabFilter> aPrefabFilter)
102  {
103  foreach (SCR_ScenarioFrameworkPrefabFilter prefabFilter : aPrefabFilter)
104  {
105  if (!m_aPrefabFilter.Contains(prefabFilter))
106  m_aPrefabFilter.Insert(prefabFilter);
107  }
108  }
109 
110  //------------------------------------------------------------------------------------------------
112  void SetSearchVehicleInventory(bool search)
113  {
114  m_bSearchVehicleInventory = search;
115  }
116 
117  //------------------------------------------------------------------------------------------------
119  void SetOnce(bool bOnce)
120  {
121  m_bOnce = bOnce;
122  }
123 
124  //------------------------------------------------------------------------------------------------
126  void SetNotificationEnabled(bool notificationEnabled)
127  {
128  m_bNotificationEnabled = notificationEnabled;
129  }
130 
131  //------------------------------------------------------------------------------------------------
133  void SetTriggerConditionsStatus(bool status)
134  {
136  }
137 
138  //------------------------------------------------------------------------------------------------
140  void SetEnableAudio(bool enableAudio)
141  {
142  m_bEnableAudio = enableAudio;
143  }
144 
145  //------------------------------------------------------------------------------------------------
147  void SetMinimumPlayersNeeded(float minimumPlayersNeededPercentage)
148  {
149  m_fMinimumPlayersNeededPercentage = minimumPlayersNeededPercentage;
150  }
151 
152  //------------------------------------------------------------------------------------------------
154  void SetPlayerActivationNotificationTitle(string sTitle)
155  {
157  }
158 
159  //------------------------------------------------------------------------------------------------
161  void SetActivationCountdownTimer(float activationCountdownTimer)
162  {
163  m_fActivationCountdownTimer = activationCountdownTimer;
164  }
165 
166  //------------------------------------------------------------------------------------------------
168  void SetCountdownAudio(string sAudioName)
169  {
170  m_sCountdownAudio = sAudioName;
171  }
172 
173  //------------------------------------------------------------------------------------------------
175  void SetCustomTriggerConditions(array<ref SCR_CustomTriggerConditions> triggerConditions)
176  {
177  m_aCustomTriggerConditions = triggerConditions;
178  }
179 
180  //------------------------------------------------------------------------------------------------
182  void SetOwnerFaction(FactionKey sFaction)
183  {
184  FactionManager factionManager = GetGame().GetFactionManager();
185  if (factionManager)
186  m_OwnerFaction = factionManager.GetFactionByKey(sFaction);
187  }
188 
189  //------------------------------------------------------------------------------------------------
191  bool IsMaster()
192  {
193  RplComponent comp = RplComponent.Cast(FindComponent(RplComponent));
194  return comp && comp.IsMaster();
195  }
196 
197  //------------------------------------------------------------------------------------------------
199  Faction GetOwnerFaction()
200  {
201  return m_OwnerFaction;
202  }
203 
204  //------------------------------------------------------------------------------------------------
206  ResourceName GetCountdownHUD()
207  {
208  return m_sCountdownHUD;
209  }
210 
211  //------------------------------------------------------------------------------------------------
213  float GetActivationCountdownTimer()
214  {
216  }
217 
218  //------------------------------------------------------------------------------------------------
220  float GetActivationCountdownTimerTemp()
221  {
222  return m_fTempWaitTime;
223  }
224 
225  //------------------------------------------------------------------------------------------------
227  float GetMinimumPlayersNeededPercentage()
228  {
230  }
231 
232  //------------------------------------------------------------------------------------------------
234  string GetPlayerActivationNotificationTitle()
235  {
237  }
238 
239  //------------------------------------------------------------------------------------------------
241  bool GetNotificationEnabled()
242  {
243  return m_bNotificationEnabled;
244  }
245 
246  //------------------------------------------------------------------------------------------------
248  bool GetTriggerConditionsStatus()
249  {
251  }
252 
253  //------------------------------------------------------------------------------------------------
255  int GetCountInsideTrigger()
256  {
257  return m_iCountInsideTrigger;
258  }
259 
260  //------------------------------------------------------------------------------------------------
262  int GetCountEntitiesInside()
263  {
265  return m_aEntitiesInside.Count();
266  }
267 
268  //------------------------------------------------------------------------------------------------
270  int GetPlayersCountByFaction()
271  {
272  int iCnt = 0;
273  array<int> aPlayerIDs = {};
274  SCR_PlayerController playerController;
275  GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
276  foreach (int iPlayerID : aPlayerIDs)
277  {
278  if (!m_OwnerFaction)
279  {
280  iCnt++; //Faction not set == ANY faction
281  }
282  else
283  {
284  playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
285  if (!playerController)
286  continue;
287 
288  if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
289  iCnt++;
290  }
291  }
292 
293  return iCnt;
294  }
295 
296  //------------------------------------------------------------------------------------------------
298  int GetSpecificClassCountInsideTrigger(string className, int targetCount = -1)
299  {
300  if (className.IsEmpty())
301  return 0;
302 
304  {
305  array<IEntity> aItemsToAdd = {};
306  foreach (IEntity entity : m_aEntitiesInside)
307  {
308  if (!entity)
309  continue;
310 
311  if (!Vehicle.Cast(entity))
312  continue;
313 
315  if (!inventoryComponent)
316  continue;
317 
318  array<IEntity> aItems = {};
319  inventoryComponent.GetItems(aItems);
320  if (!aItems.IsEmpty())
321  aItemsToAdd.InsertAll(aItems);
322  }
323 
324  if (!aItemsToAdd.IsEmpty())
325  m_aEntitiesInside.InsertAll(aItemsToAdd);
326  }
327 
328  int iCnt = 0;
330  foreach (IEntity entity : m_aEntitiesInside)
331  {
332  if (!entity)
333  continue;
334 
335  if (entity.IsInherited(className.ToType()))
336  iCnt++;
337 
338  if (iCnt == targetCount)
339  break;
340  }
341 
342  return iCnt;
343  }
344 
345  //------------------------------------------------------------------------------------------------
347  int GetSpecificPrefabCountInsideTrigger(BaseContainer prefabContainer, int targetCount = -1, bool includeInheritance = false)
348  {
349  int iCnt;
351 
353  {
354  array<IEntity> aItemsToAdd = {};
355  foreach (IEntity entity : m_aEntitiesInside)
356  {
357  if (!entity)
358  continue;
359 
360  if (!Vehicle.Cast(entity))
361  continue;
362 
364  if (!inventoryComponent)
365  continue;
366 
367  array<IEntity> aItems = {};
368  inventoryComponent.GetItems(aItems);
369  if (!aItems.IsEmpty())
370  aItemsToAdd.InsertAll(aItems);
371  }
372 
373  if (!aItemsToAdd.IsEmpty())
374  m_aEntitiesInside.InsertAll(aItemsToAdd);
375  }
376 
377  foreach (IEntity entity : m_aEntitiesInside)
378  {
379  if (!entity)
380  continue;
381 
382  EntityPrefabData prefabData = entity.GetPrefabData();
383  if (!prefabData)
384  continue;
385 
386  BaseContainer container = prefabData.GetPrefab();
387  if (!container)
388  continue;
389 
390  if (!includeInheritance)
391  {
392  if (container != prefabContainer)
393  continue;
394 
395  iCnt++;
396  }
397  else
398  {
399  while (container)
400  {
401  if (container == prefabContainer)
402  {
403  iCnt++;
404  break;
405  }
406 
407  container = container.GetAncestor();
408  }
409  }
410 
411  if (iCnt == targetCount)
412  break;
413  }
414 
415  return iCnt;
416  }
417 
418  //------------------------------------------------------------------------------------------------
420  int GetCharacterCountByFactionInsideTrigger(Faction faction, int targetCount = -1)
421  {
422  int iCnt = 0;
423  SCR_ChimeraCharacter chimeraCharacter;
425  foreach (IEntity entity : m_aEntitiesInside)
426  {
427  if (!entity)
428  continue;
429 
430  chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
431  if (!chimeraCharacter)
432  continue;
433 
434  if (faction && chimeraCharacter.GetFaction() != faction)
435  continue;
436 
437  iCnt++;
438  if (iCnt == targetCount)
439  break;
440  }
441 
442  return iCnt;
443  }
444 
445  //------------------------------------------------------------------------------------------------
447  int GetPlayersCountByFactionInsideTrigger(Faction faction)
448  {
449  int iCnt = 0;
450  m_aPlayersInside.Clear();
452  SCR_ChimeraCharacter chimeraCharacter;
453  foreach (IEntity entity : m_aEntitiesInside)
454  {
455  if (!entity)
456  continue;
457 
458  chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
459  if (!chimeraCharacter)
460  continue;
461 
462  if (faction && chimeraCharacter.GetFaction() != faction)
463  continue;
464 
465  if (!EntityUtils.IsPlayer(entity))
466  continue;
467 
468  iCnt++;
469  m_aPlayersInside.Insert(entity);
470  }
471 
472  return iCnt;
473  }
474 
475  //------------------------------------------------------------------------------------------------
477  void GetPlayersByFactionInsideTrigger(notnull out array<IEntity> aOut)
478  {
479  SCR_ChimeraCharacter chimeraCharacter;
481  foreach (IEntity entity : m_aEntitiesInside)
482  {
483  if (!entity)
484  continue;
485 
486  chimeraCharacter = SCR_ChimeraCharacter.Cast(entity);
487  if (!chimeraCharacter)
488  continue;
489 
490  //Faction not set == ANY faction
491  if (!m_OwnerFaction)
492  {
493  if (EntityUtils.IsPlayer(entity))
494  aOut.Insert(entity)
495  }
496  else
497  {
498  if (chimeraCharacter.GetFaction() != m_OwnerFaction)
499  continue;
500 
501  if (EntityUtils.IsPlayer(entity))
502  aOut.Insert(entity);
503  }
504  }
505  }
506 
507  //------------------------------------------------------------------------------------------------
509  void GetPlayersByFaction(notnull out array<IEntity> aOut)
510  {
511  array<int> aPlayerIDs = {};
512  SCR_PlayerController playerController;
513  GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
514  foreach (int iPlayerID : aPlayerIDs)
515  {
516  playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
517  if (!playerController)
518  continue;
519 
520  if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
521  aOut.Insert(playerController.GetLocalMainEntity());
522  }
523  }
524 
525  //------------------------------------------------------------------------------------------------
527  override bool ScriptedEntityFilterForQuery(IEntity ent)
528  {
529  if (m_eActivationPresence == TA_EActivationPresence.PLAYER || m_eActivationPresence == TA_EActivationPresence.ANY_CHARACTER)
530  {
531  SCR_ChimeraCharacter chimeraCharacter = SCR_ChimeraCharacter.Cast(ent);
532  if (!chimeraCharacter)
533  return false;
534 
535  if (m_OwnerFaction && chimeraCharacter.GetFaction() != m_OwnerFaction)
536  return false;
537 
538  if (!IsAlive(ent))
539  return false;
540 
541  if (m_eActivationPresence == TA_EActivationPresence.PLAYER)
542  return EntityUtils.IsPlayer(ent);
543 
544  return true;
545  }
546 
547  //In case of vehicle, we first need to check if it is alive and then check the faction
548  Vehicle vehicle = Vehicle.Cast(ent);
549  if (vehicle)
550  {
551  if (!IsAlive(ent))
552  return false;
553 
554  if (!m_OwnerFaction)
555  return true;
556 
557  return vehicle.GetFaction() == m_OwnerFaction;
558  }
559 
560  if (!m_OwnerFaction)
561  return true;
562 
563  FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(ent.FindComponent(FactionAffiliationComponent));
564  if (!factionAffiliation)
565  return true;
566 
567  return factionAffiliation.GetAffiliatedFaction() == m_OwnerFaction;
568  }
569 
570  //------------------------------------------------------------------------------------------------
572  void FinishTrigger(IEntity ent)
573  {
574  if (m_bEnableAudio)
575  StopMusic(m_sCountdownAudio);
576 
577  if (m_bOnce)
578  Deactivate();
579 
580  m_OnActivate.Invoke(ent);
581  OnChange(ent);
582  }
583 
584  //------------------------------------------------------------------------------------------------
586  void ActivationPresenceConditions()
587  {
589  if (m_eActivationPresence == TA_EActivationPresence.PLAYER)
590  {
591  m_iCountInsideTrigger = GetPlayersCountByFactionInsideTrigger(m_OwnerFaction);
592  float minPlayersNeeded = Math.Ceil(GetPlayersCountByFaction() * m_fMinimumPlayersNeededPercentage);
593  if (m_iCountInsideTrigger >= minPlayersNeeded && m_iCountInsideTrigger > 0)
595 
596  return;
597  }
598 
600  }
601 
602  //------------------------------------------------------------------------------------------------
604  protected void CustomTriggerConditions()
605  {
606  foreach (SCR_CustomTriggerConditions condition : m_aCustomTriggerConditions)
607  {
608  condition.CustomTriggerConditions(this)
609  }
610  }
611 
612  //------------------------------------------------------------------------------------------------
614  protected void HandleNetworkComponentForPlayersInside(IEntity ent)
615  {
616  if (m_aPlayersInside.IsEmpty())
617  m_iCountInsideTrigger = GetPlayersCountByFactionInsideTrigger(m_OwnerFaction);
618 
619  foreach (IEntity entity : m_aPlayersInside)
620  {
621  ProcessPlayerNetworkComponent(entity, false);
622  }
623 
624  //This handles Network component for players that left the trigger
625  if (ent)
626  ProcessPlayerNetworkComponent(ent, true);
627  }
628 
629  //------------------------------------------------------------------------------------------------
631  protected void ProcessPlayerNetworkComponent(IEntity entity, bool leftTrigger = false)
632  {
633  PlayerManager playerManager = GetGame().GetPlayerManager();
634  int playerId = playerManager.GetPlayerIdFromControlledEntity(entity);
635  SCR_PlayerController playerController = SCR_PlayerController.Cast(playerManager.GetPlayerController(playerId));
636  if (!playerController)
637  return;
638 
639  SCR_ScenarioFrameworkTriggerNetworkComponent triggerNetwork = SCR_ScenarioFrameworkTriggerNetworkComponent.Cast(playerController.FindComponent(SCR_ScenarioFrameworkTriggerNetworkComponent));
640  if (!triggerNetwork)
641  return;
642 
643  triggerNetwork.ReplicateTriggerState(this, leftTrigger);
644  }
645 
646  //------------------------------------------------------------------------------------------------
648  protected void HandleTimer()
649  {
650  if (!m_bTimerActive)
651  {
652  m_bTimerActive = true;
654  // Call later in this case will be more efficient than handling it via EOnFrame
655  GetGame().GetCallqueue().CallLater(UpdateTimer, 1000, true);
656  }
657 
658  if (GetCountInsideTrigger() == 0)
659  {
660  GetGame().GetCallqueue().Remove(UpdateTimer);
662  m_bTimerActive = false;
663  }
664  }
665 
666  //------------------------------------------------------------------------------------------------
668  protected void UpdateTimer()
669  {
672  else
673  m_fTempWaitTime--;
674 
676  return;
677 
678  HandleNetworkComponentForPlayersInside(null);
679  }
680 
681  //------------------------------------------------------------------------------------------------
682  override protected event void OnActivate(IEntity ent)
683  {
684  }
685 
686  //------------------------------------------------------------------------------------------------
687  override event protected void OnQueryFinished(bool bIsEmpty)
688  {
689  super.OnQueryFinished(bIsEmpty);
690 
691  if (bIsEmpty)
692  return;
693 
694  if (!IsMaster())
695  return;
696 
697  if (!m_bInitSequenceDone)
698  return;
699 
700  ActivationPresenceConditions();
701  CustomTriggerConditions();
702  HandleTimer();
703 
704  if (m_bEnableAudio)
705  HandleAudio();
706 
708  FinishTrigger(this);
709  }
710 
711  //------------------------------------------------------------------------------------------------
712  override protected event void OnDeactivate(IEntity ent)
713  {
714  //This method is triggered when the trigger is deactivated but the said entity is still inside.
715  //We need to perform this method after the entity leaves the trigger.
716  GetGame().GetCallqueue().CallLater(OnDeactivateCalledLater, 100, false, ent);
717  }
718 
719  //------------------------------------------------------------------------------------------------
720  void OnDeactivateCalledLater(IEntity ent)
721  {
722  if (!m_bInitSequenceDone)
723  return;
724 
725  m_aPlayersInside.RemoveItem(ent);
726 
727  ActivationPresenceConditions();
728  CustomTriggerConditions();
729  HandleTimer();
730 
732  HandleNetworkComponentForPlayersInside(ent);
733 
734  if (m_bEnableAudio)
735  HandleAudio();
736 
737  m_OnDeactivate.Invoke();
738  OnChange(ent);
739  }
740 
741  //------------------------------------------------------------------------------------------------
742  void HandleAudio()
743  {
745  {
747  PlayMusic(m_sCountdownAudio);
748  }
749  else
750  {
751  StopMusic(m_sCountdownAudio);
752  }
753  }
754 
755  //------------------------------------------------------------------------------------------------
756  void PlayMusic(string sAudio)
757  {
758 
759  if (!m_MusicManager)
760  {
761  ChimeraWorld world = GetGame().GetWorld();
762  if (world)
763  m_MusicManager = world.GetMusicManager();
764  }
765 
766  if (!m_MusicManager)
767  return;
768 
770  m_MusicManager.Play(sAudio);
771 
772  Rpc(RpcDo_PlayMusic, sAudio);
773  }
774 
775  //------------------------------------------------------------------------------------------------
776  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
777  protected void RpcDo_PlayMusic(string sAudio)
778  {
779  if (!m_MusicManager)
780  {
781  ChimeraWorld world = GetGame().GetWorld();
782  if (world)
783  m_MusicManager = world.GetMusicManager();
784  }
785 
786  if (!m_MusicManager)
787  return;
788 
790  m_MusicManager.Play(sAudio);
791  }
792 
793  //------------------------------------------------------------------------------------------------
794  void StopMusic(string sAudio)
795  {
796  if (!m_MusicManager)
797  {
798  ChimeraWorld world = GetGame().GetWorld();
799  if (world)
800  m_MusicManager = world.GetMusicManager();
801  }
802 
803  if (!m_MusicManager)
804  return;
805 
806  m_bCountdownMusicPlaying = false;
807  m_MusicManager.Stop(sAudio);
808 
809  Rpc(RpcDo_StopMusic, sAudio);
810  }
811 
812  //------------------------------------------------------------------------------------------------
813  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
814  protected void RpcDo_StopMusic(string sAudio)
815  {
816  if (!m_MusicManager)
817  {
818  ChimeraWorld world = GetGame().GetWorld();
819  if (world)
820  m_MusicManager = world.GetMusicManager();
821  }
822 
823  if (!m_MusicManager)
824  return;
825 
826  m_bCountdownMusicPlaying = false;
827  m_MusicManager.Stop(sAudio);
828  }
829 
830  //------------------------------------------------------------------------------------------------
831  void OnChange(IEntity ent)
832  {
833  if (m_OnChange)
834  {
835  SCR_ScenarioFrameworkParam<IEntity> param = new SCR_ScenarioFrameworkParam<IEntity>(ent);
836  m_OnChange.Invoke(param);
837  }
838  }
839 
840  //------------------------------------------------------------------------------------------------
841  ScriptInvoker GetOnChange()
842  {
843  if (!m_OnChange)
844  m_OnChange = new ScriptInvoker();
845 
846  return m_OnChange;
847  }
848 
849  //------------------------------------------------------------------------------------------------
851  protected void SetInitSequenceDone()
852  {
853  foreach (SCR_CustomTriggerConditions condition : m_aCustomTriggerConditions)
854  {
855  condition.Init(this);
856  }
857 
858  PrefabFilter prefabFilter;
859  foreach (SCR_ScenarioFrameworkPrefabFilter prefabFilterInput : m_aPrefabFilter)
860  {
861  prefabFilter = new PrefabFilter();
862  prefabFilter.SetPrefab(prefabFilterInput.m_sSpecificPrefabName);
863  prefabFilter.SetCheckPrefabHierarchy(prefabFilterInput.m_bIncludeChildren);
864  AddPrefabFilter(prefabFilter);
865  }
866 
867  foreach (ResourceName className : m_aSpecificClassNames)
868  {
869  AddClassType(className.ToType());
870  }
871 
872  m_bInitSequenceDone = true;
873  }
874 
875  //------------------------------------------------------------------------------------------------
877  override protected void EOnInit(IEntity owner)
878  {
879  //TODO: we need a time to spawn entities inside the trigger, but we don't want to activate the trigger yet.
880  //It will be done better by knowing the entities inside the trigger on its creation
881  GetGame().GetCallqueue().CallLater(SetInitSequenceDone, 1000);
882  SetOwnerFaction(m_sOwnerFactionKey);
883 
884  ChimeraWorld world = GetGame().GetWorld();
885  if (world)
886  m_MusicManager = world.GetMusicManager();
887  }
888 }
889 
890 //Baseclass that is supposed to be extended and filled with custom conditions
892 class SCR_CustomTriggerConditions
893 {
894  //------------------------------------------------------------------------------------------------
896  void Init(SCR_CharacterTriggerEntity trigger);
897 
898  //------------------------------------------------------------------------------------------------
901 }
902 
904 class SCR_CustomTriggerConditionsSpecificPrefabCount : SCR_CustomTriggerConditions
905 {
906  [Attribute(desc: "Which Prefabs and if their children will be accounted for", category: "Trigger")]
907  protected ref array<ref SCR_ScenarioFrameworkPrefabFilterCount> m_aPrefabFilter;
908 
909  //------------------------------------------------------------------------------------------------
910  override void Init(SCR_CharacterTriggerEntity trigger)
911  {
912  Resource resource;
913  BaseContainer baseContainer;
914  PrefabFilter prefabFilter;
915  foreach (SCR_ScenarioFrameworkPrefabFilterCount prefabFilterCount : m_aPrefabFilter)
916  {
917  prefabFilter = new PrefabFilter();
918  prefabFilter.SetPrefab(prefabFilterCount.m_sSpecificPrefabName);
919  prefabFilter.SetCheckPrefabHierarchy(prefabFilterCount.m_bIncludeChildren);
920  trigger.AddPrefabFilter(prefabFilter);
921 
922  resource = Resource.Load(prefabFilterCount.m_sSpecificPrefabName);
923  if (!resource.IsValid())
924  continue;
925 
926  prefabFilterCount.m_Resource = resource;
927  prefabFilterCount.m_PrefabContainer = resource.GetResource().ToBaseContainer();
928  }
929  }
930 
931  //------------------------------------------------------------------------------------------------
933  override void CustomTriggerConditions(SCR_CharacterTriggerEntity trigger)
934  {
935  bool triggerStatus;
937  {
938  if (trigger.GetSpecificPrefabCountInsideTrigger(prefabFilter.m_PrefabContainer, prefabFilter.m_iPrefabCount, prefabFilter.m_bIncludeChildren) >= prefabFilter.m_iPrefabCount)
939  {
940  triggerStatus = true;
941  }
942  else
943  {
944  triggerStatus = false;
945  break;
946  }
947  }
948 
949  trigger.SetTriggerConditionsStatus(triggerStatus);
950  }
951 }
952 
954 class SCR_CustomTriggerConditionsSpecificClassNameCount : SCR_CustomTriggerConditions
955 {
956  [Attribute(desc: "If SPECIFIC_CLASS is selected, fill the class name here.", category: "Trigger")]
957  protected ref array<string> m_aSpecificClassNames;
958 
959  [Attribute(defvalue: "1", desc: "How many entities of specific prefab are requiered to be inside the trigger", params: "0 100000 1", category: "Trigger")]
960  protected int m_iClassnameCount;
961 
962  //------------------------------------------------------------------------------------------------
963  override void Init(SCR_CharacterTriggerEntity trigger)
964  {
965  trigger.SetSpecificClassName(m_aSpecificClassNames);
966 
967  typename type;
968  foreach (string className : m_aSpecificClassNames)
969  {
970  type = className.ToType();
971  if (type)
972  trigger.AddClassType(type);
973  }
974  }
975 
976  //------------------------------------------------------------------------------------------------
979  {
980  bool triggerStatus;
981  foreach (string className : m_aSpecificClassNames)
982  {
983  if (trigger.GetSpecificClassCountInsideTrigger(className) >= m_iClassnameCount)
984  {
985  triggerStatus = true;
986  }
987  else
988  {
989  triggerStatus = false;
990  break;
991  }
992  }
993 
994  trigger.SetTriggerConditionsStatus(triggerStatus);
995  }
996 }
m_aCustomTriggerConditions
protected ref array< ref SCR_CustomTriggerConditions > m_aCustomTriggerConditions
Definition: SCR_CharacterTriggerEntity.c:32
SCR_ScenarioFrameworkPrefabFilter
Definition: SCR_ScenarioFrameworkPrefabFilter.c:2
ChimeraWorld
Definition: ChimeraWorld.c:12
m_OwnerFaction
protected Faction m_OwnerFaction
Definition: SCR_CharacterTriggerEntity.c:64
SCR_PlayerController
Definition: SCR_PlayerController.c:31
m_bCountdownMusicPlaying
protected bool m_bCountdownMusicPlaying
Definition: SCR_CharacterTriggerEntity.c:67
m_sCountdownAudio
protected string m_sCountdownAudio
Definition: SCR_CharacterTriggerEntity.c:59
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_ScenarioFrameworkPrefabFilterCount
Definition: SCR_ScenarioFrameworkPrefabFilter.c:24
AddClassType
proto external void AddClassType(typename classType)
Add a class type to the filter.
ScriptInvokerInt
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
Definition: SCR_ScriptInvokerHelper.c:24
m_sPlayerActivationNotificationTitle
protected string m_sPlayerActivationNotificationTitle
Definition: SCR_CharacterTriggerEntity.c:53
PLAYER
SCR_CharacterTriggerEntityClass PLAYER
m_bTriggerConditionsStatus
protected bool m_bTriggerConditionsStatus
Definition: SCR_CharacterTriggerEntity.c:71
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SPECIFIC_CLASS
SCR_CharacterTriggerEntityClass SPECIFIC_CLASS
ScriptInvokerTriggerUpdated
func ScriptInvokerTriggerUpdated
Definition: SCR_CharacterTriggerEntity.c:15
m_eActivationPresence
protected TA_EActivationPresence m_eActivationPresence
Definition: SCR_CharacterTriggerEntity.c:20
IsAlive
bool IsAlive()
Definition: SpectateTargetComponent.c:23
CustomTriggerConditions
protected void CustomTriggerConditions()
This method handles custom conditions.
Definition: SCR_CharacterTriggerEntity.c:601
m_OnActivate
SCR_BaseTriggerEntityClass m_OnActivate
Basic scripted trigger which offers external invoekrs for major events like activation or deactivatio...
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
func
func
Definition: SCR_AIThreatSystem.c:5
ANY_CHARACTER
SCR_CharacterTriggerEntityClass ANY_CHARACTER
Init
void Init(IEntity entity=null, vector worldPos=vector.Zero, float timestamp=0.0, EAITargetInfoCategory category=0)
Definition: SCR_AITargetInfo.c:27
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_CharacterTriggerEntityClass
Definition: SCR_CharacterTriggerEntity.c:2
m_fActivationCountdownTimer
protected float m_fActivationCountdownTimer
Definition: SCR_CharacterTriggerEntity.c:44
AddPrefabFilter
proto external void AddPrefabFilter(PrefabFilter prefabFilter)
Add a prefab filter to the filters.
m_bSearchVehicleInventory
protected bool m_bSearchVehicleInventory
Definition: SCR_CharacterTriggerEntity.c:35
m_OnChange
protected ref ScriptInvoker_EditableDescriptorLocationChange m_OnChange
Definition: SCR_EditableDescriptorComponent.c:22
m_fTempWaitTime
protected float m_fTempWaitTime
Definition: SCR_CharacterTriggerEntity.c:65
PrefabFilter
Definition: PrefabFilter.c:12
InventoryStorageManagerComponent
Definition: InventoryStorageManagerComponent.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_OnDeactivate
protected ref ScriptInvoker m_OnDeactivate
Definition: SCR_BaseTriggerEntity.c:10
m_sCountdownHUD
protected ResourceName m_sCountdownHUD
Definition: SCR_CharacterTriggerEntity.c:50
m_bOnce
protected bool m_bOnce
Definition: SCR_CharacterTriggerEntity.c:38
m_fMinimumPlayersNeededPercentage
protected float m_fMinimumPlayersNeededPercentage
Definition: SCR_CharacterTriggerEntity.c:41
m_aEntitiesInside
protected ref array< IEntity > m_aEntitiesInside
Definition: SCR_CharacterTriggerEntity.c:68
Deactivate
protected void Deactivate()
Definition: SCR_BaseHintCondition.c:27
BaseContainerProps
SCR_CharacterTriggerEntity SCR_BaseTriggerEntity BaseContainerProps()] class SCR_CustomTriggerConditions
Definition: SCR_CharacterTriggerEntity.c:891
Faction
Definition: Faction.c:12
m_bNotificationEnabled
protected bool m_bNotificationEnabled
Definition: SCR_CharacterTriggerEntity.c:47
m_aSpecificClassNames
protected ref array< string > m_aSpecificClassNames
Definition: SCR_CharacterTriggerEntity.c:26
GetEntitiesInside
proto external int GetEntitiesInside(out notnull array< IEntity > outEntities)
SPECIFIC_PREFAB_NAME
SCR_CharacterTriggerEntityClass SPECIFIC_PREFAB_NAME
SCR_CharacterTriggerEntity
Definition: SCR_CharacterTriggerEntity.c:17
m_bEnableAudio
protected bool m_bEnableAudio
Definition: SCR_CharacterTriggerEntity.c:56
m_aPrefabFilter
protected ref array< ref SCR_ScenarioFrameworkPrefabFilter > m_aPrefabFilter
Definition: SCR_CharacterTriggerEntity.c:29
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
m_aPlayersInside
protected ref array< IEntity > m_aPlayersInside
Definition: SCR_CharacterTriggerEntity.c:69
SCR_BaseTriggerEntityClass
Definition: SCR_BaseTriggerEntity.c:2
m_iCountInsideTrigger
protected int m_iCountInsideTrigger
Definition: SCR_CharacterTriggerEntity.c:73
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
EntityUtils
Definition: EntityUtils.c:12
m_bInitSequenceDone
protected bool m_bInitSequenceDone
Definition: SCR_CharacterTriggerEntity.c:66
m_bTimerActive
protected bool m_bTimerActive
Definition: SCR_CharacterTriggerEntity.c:72
PlayerManager
Definition: PlayerManager.c:12
m_MusicManager
protected MusicManager m_MusicManager
Definition: SCR_CharacterTriggerEntity.c:70
m_sOwnerFactionKey
protected FactionKey m_sOwnerFactionKey
Definition: SCR_CharacterTriggerEntity.c:17
SCR_CustomTriggerConditionsSpecificPrefabCount
Definition: SCR_CharacterTriggerEntity.c:904
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180