Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkActions.c
Go to the documentation of this file.
1 class SCR_ContainerActionTitle : BaseContainerCustomTitle
2 {
3  //------------------------------------------------------------------------------------------------
4  override bool _WB_GetCustomTitle(BaseContainer source, out string title)
5  {
6  title = source.GetClassName();
7  title.Replace("SCR_ScenarioFrameworkAction", "");
8  string sOriginal = title;
9  SplitStringByUpperCase(sOriginal, title);
10  return true;
11  }
12 
13  //------------------------------------------------------------------------------------------------
17  void SplitStringByUpperCase(string input, out string output)
18  {
19  output = "";
20  bool wasPreviousUpperCase;
21  int asciiChar;
22  for (int i, count = input.Length(); i < count; i++)
23  {
24  asciiChar = input.ToAscii(i);
25  bool isLowerCase = (asciiChar > 96 && asciiChar < 123);
26  if (i > 0 && !wasPreviousUpperCase && !isLowerCase)
27  {
28  output += " " + asciiChar.AsciiToString();
29  wasPreviousUpperCase = true;
30  }
31  else
32  {
33  if (isLowerCase)
34  wasPreviousUpperCase = false;
35 
36  output += asciiChar.AsciiToString();
37  }
38  }
39  }
40 }
41 
42 // TODO: make this a generic action which can be used anywhere anytime (i.e. on task finished, etc)
44 class SCR_ScenarioFrameworkActionBase
45 {
46  [Attribute(defvalue: "-1", uiwidget: UIWidgets.Graph, params: "-1 10000 1", desc: "How many times this action can be performed if this gets triggered? Value -1 for infinity")]
47  int m_iMaxNumberOfActivations;
48 
49  IEntity m_Entity;
50  int m_iNumberOfActivations;
51 
52  //------------------------------------------------------------------------------------------------
55  void Init(IEntity entity)
56  {
57  if (!SCR_BaseTriggerEntity.Cast(entity))
58  {
59  OnActivate(entity);
60  m_Entity = entity;
61  return;
62  }
63 
64  m_Entity = entity;
65  ScriptInvoker pOnActivateInvoker = SCR_BaseTriggerEntity.Cast(entity).GetOnActivate();
66  if (pOnActivateInvoker)
67  pOnActivateInvoker.Insert(OnActivate);
68 
69  ScriptInvoker pOnDeactivateInvoker = SCR_BaseTriggerEntity.Cast(entity).GetOnDeactivate();
70  if (pOnDeactivateInvoker)
71  pOnDeactivateInvoker.Insert(OnActivate); //registering OnDeactivate to OnActivate - we need both changes
72  }
73 
74  //------------------------------------------------------------------------------------------------
77  bool CanActivate()
78  {
79  if (m_iMaxNumberOfActivations != -1 && m_iNumberOfActivations >= m_iMaxNumberOfActivations)
80  {
81  if (m_Entity)
82  Print(string.Format("ScenarioFramework Action: Maximum number of activations reached for Action %1 attached on %2. Action won't do anything.", this, m_Entity.GetName()), LogLevel.ERROR);
83  else
84  Print(string.Format("ScenarioFramework Action: Maximum number of activations reached for Action %1. Action won't do anything.", this), LogLevel.ERROR);
85 
86  return false;
87  }
88 
89  m_iNumberOfActivations++;
90  return true;
91  }
92 
93  //------------------------------------------------------------------------------------------------
97  bool ValidateInputEntity(IEntity object, SCR_ScenarioFrameworkGet getter, out IEntity entity)
98  {
99  if (!getter && object)
100  {
102  if (!layer)
103  {
104  Print(string.Format("ScenarioFramework Action: Action %1 attached on %2 is not called from layer and won't do anything.", this, object.GetName()), LogLevel.ERROR);
105  return false;
106  }
107 
108  entity = layer.GetSpawnedEntity();
109  }
110  else
111  {
112  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(getter.Get());
113  if (!entityWrapper)
114  {
115  if (object)
116  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
117  else
118  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
119 
120  return false;
121  }
122 
123  entity = IEntity.Cast(entityWrapper.GetValue());
124  }
125 
126  if (!entity)
127  {
128  if (object)
129  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
130  else
131  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
132 
133  return false;
134  }
135 
136  return true;
137  }
138 
139  //------------------------------------------------------------------------------------------------
141  void OnActivate(IEntity object);
142 
143  //------------------------------------------------------------------------------------------------
147  void SpawnObjects(notnull array<string> aObjectsNames, SCR_ScenarioFrameworkEActivationType eActivationType)
148  {
149  IEntity object;
151 
152  foreach (string sObjectName : aObjectsNames)
153  {
154  object = GetGame().GetWorld().FindEntityByName(sObjectName);
155  if (!object)
156  {
157  Print(string.Format("ScenarioFramework Action: Can't spawn object set in slot %1. Slot doesn't exist", sObjectName), LogLevel.ERROR);
158  continue;
159  }
160 
161  layer = SCR_ScenarioFrameworkLayerBase.Cast(object.FindComponent(SCR_ScenarioFrameworkLayerBase));
162  if (!layer)
163  {
164  Print(string.Format("Can't spawn object - the slot doesn't have SCR_ScenarioFrameworkLayerBase component", sObjectName), LogLevel.ERROR);
165  continue;
166  }
167 
168  layer.Init(null, eActivationType);
169  layer.SetActivationType(SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
170  }
171  }
172 }
173 
175 class SCR_ScenarioFrameworkActionIncrementCounter : SCR_ScenarioFrameworkActionBase
176 {
177  [Attribute(uiwidget: UIWidgets.EditBox, desc: "Counter to increment")]
178  string m_sCounterName;
179 
180  //------------------------------------------------------------------------------------------------
181  override void Init(IEntity entity)
182  {
183  if (!m_sCounterName)
184  return;
185 
186  super.Init(entity);
187  }
188 
189  //------------------------------------------------------------------------------------------------
190  override void OnActivate(IEntity object)
191  {
192  if (!CanActivate())
193  return;
194 
195  IEntity entity = GetGame().GetWorld().FindEntityByName(m_sCounterName);
196  if (!entity)
197  {
198  PrintFormat("ScenarioFramework Action: Could not find %1 for Action %2", m_sCounterName, this, LogLevel.ERROR);
199  return;
200  }
201 
202  SCR_ScenarioFrameworkLogic counter = SCR_ScenarioFrameworkLogic.Cast(entity.FindComponent(SCR_ScenarioFrameworkLogic));
203  if (counter)
204  {
205  counter.OnInput(1, object);
206  return;
207  }
208 
209  SCR_ScenarioFrameworkLogicCounter logicCounter = SCR_ScenarioFrameworkLogicCounter.Cast(entity);
210  if (logicCounter)
211  logicCounter.OnInput(1, object);
212  }
213 }
214 
216 class SCR_ScenarioFrameworkActionSpawnObjects : SCR_ScenarioFrameworkActionBase
217 {
218  [Attribute(defvalue: "", UIWidgets.EditComboBox, desc: "These objects will spawn once the trigger becomes active.")]
219  ref array<string> m_aNameOfObjectsToSpawnOnActivation;
220 
221  //------------------------------------------------------------------------------------------------
222  override void OnActivate(IEntity object)
223  {
224  if (!CanActivate())
225  return;
226 
227  SpawnObjects(m_aNameOfObjectsToSpawnOnActivation, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
228  }
229 }
230 
232 class SCR_ScenarioFrameworkActionSetEntityPosition : SCR_ScenarioFrameworkActionBase
233 {
234  [Attribute(desc: "Entity to be teleported (Optional if action is attached on Slot that spawns target entity)")]
235  ref SCR_ScenarioFrameworkGet m_EntityGetter;
236 
237  [Attribute(defvalue: "0 0 0", desc: "Position that the entity will be teleported to")]
238  vector m_vDestination;
239 
240  [Attribute(desc: "Name of the entity that above selected entity will be teleported to (Optional)")]
241  ref SCR_ScenarioFrameworkGet m_DestinationEntityGetter;
242 
243  [Attribute(defvalue: "0 0 0", desc: "Position that will be used in relation to the entity for the position to teleport to (Optional)")]
244  vector m_vDestinationEntityRelativePosition;
245 
246  //------------------------------------------------------------------------------------------------
247  override void OnActivate(IEntity object)
248  {
249  if (!CanActivate())
250  return;
251 
252  IEntity entity;
253  if (!ValidateInputEntity(object, m_EntityGetter, entity))
254  return;
255 
256  if (!m_DestinationEntityGetter)
257  {
258  entity.SetOrigin(m_vDestination);
259  return;
260  }
261 
262  SCR_ScenarioFrameworkParam<IEntity> destinationEntityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_DestinationEntityGetter.Get());
263  if (!destinationEntityWrapper)
264  {
265  Print(string.Format("ScenarioFramework Action: Destination Entity Getter has issues for action %1. Action won't do anything.", this), LogLevel.ERROR);
266  return;
267  }
268 
269  IEntity destinationEntity = IEntity.Cast(destinationEntityWrapper.GetValue());
270  if (!destinationEntity)
271  {
272  Print(string.Format("ScenarioFramework Action: Destination Entity could not be found for action %1. Action won't do anything.", this), LogLevel.ERROR);
273  return;
274  }
275 
276  entity.SetOrigin(destinationEntity.GetOrigin() + m_vDestinationEntityRelativePosition);
277  }
278 }
279 
281 class SCR_ScenarioFrameworkActionDeleteEntity : SCR_ScenarioFrameworkActionBase
282 {
283  [Attribute(desc: "Entity to be deleted (Optional if action is attached on Slot that spawns target entity)")]
284  ref SCR_ScenarioFrameworkGet m_Getter;
285 
286  //------------------------------------------------------------------------------------------------
287  override void OnActivate(IEntity object)
288  {
289  if (!CanActivate())
290  return;
291 
292  IEntity entity;
293  if (!ValidateInputEntity(object, m_Getter, entity))
294  return;
295 
296  SCR_EntityHelper.DeleteEntityAndChildren(entity);
297  }
298 }
299 
301 class SCR_ScenarioFrameworkActionChangeLayerTerminationStatus : SCR_ScenarioFrameworkActionBase
302 {
303  [Attribute(desc: "Name of the layer to change the termination status")]
304  ref SCR_ScenarioFrameworkGet m_Getter;
305 
306  [Attribute(desc: "If layer will be terminated or not")]
307  bool m_bTerminated;
308 
309  //------------------------------------------------------------------------------------------------
310  override void OnActivate(IEntity object)
311  {
312  if (!CanActivate())
313  return;
314 
315  if (!m_Getter)
316  {
318  if (layer)
319  layer.SetIsTerminated(m_bTerminated);
320 
321  return;
322  }
323 
324  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
325  if (!entityWrapper)
326  {
327  Print(string.Format("ScenarioFramework Action: Getter has issues for action %1. Action won't do anything.", this), LogLevel.ERROR);
328  return;
329  }
330 
331  IEntity entity = IEntity.Cast(entityWrapper.GetValue());
332  if (!entity)
333  {
334  Print(string.Format("ScenarioFramework Action: Entity could not be found for action %1. Action won't do anything.", this), LogLevel.ERROR);
335  return;
336  }
337 
339  if (!layer)
340  {
341  Print(string.Format("ScenarioFramework Action: Entity is not LayerBase for action %1. Action won't do anything.", this), LogLevel.ERROR);
342  return;
343  }
344 
345  layer.SetIsTerminated(m_bTerminated);
346  }
347 }
348 
350 class SCR_ScenarioFrameworkActionKillEntity : SCR_ScenarioFrameworkActionBase
351 {
352  [Attribute(desc: "Entity to be killed (Optional if action is attached on Slot that spawns target entity)")]
353  ref SCR_ScenarioFrameworkGet m_Getter;
354 
355  [Attribute(desc: "If target entity is Character, it will randomize ragdoll upon death")]
356  bool m_bRandomizeRagdoll;
357 
358  //------------------------------------------------------------------------------------------------
359  override void OnActivate(IEntity object)
360  {
361  if (!CanActivate())
362  return;
363 
364  IEntity entity;
365  if (!ValidateInputEntity(object, m_Getter, entity))
366  return;
367 
368  SCR_DamageManagerComponent damageMananager = SCR_DamageManagerComponent.Cast(entity.FindComponent(SCR_DamageManagerComponent));
369  if (damageMananager)
370  damageMananager.Kill(Instigator.CreateInstigator(object));
371 
372  if (!m_bRandomizeRagdoll)
373  return;
374 
375  CharacterAnimationComponent animationComponent = CharacterAnimationComponent.Cast(entity.FindComponent(CharacterAnimationComponent));
376  if (!animationComponent)
377  {
378  Print(string.Format("ScenarioFramework Action: Entity does not have animation component needed for action %1. Action won't randomize the ragdoll.", this), LogLevel.ERROR);
379  return;
380  }
381 
382  Math.Randomize(-1);
383 
384  vector randomDir = "0 0 0";
385  randomDir[0] = Math.RandomIntInclusive(1, 3);
386  randomDir[1] = Math.RandomIntInclusive(1, 3);
387  randomDir[2] = Math.RandomIntInclusive(1, 3);
388 
389  animationComponent.AddRagdollEffectorDamage("1 1 1", randomDir, Math.RandomFloatInclusive(0, 50), Math.RandomFloatInclusive(0, 10), Math.RandomFloatInclusive(0, 20));
390  }
391 }
392 
394 class SCR_ScenarioFrameworkActionEndMission : SCR_ScenarioFrameworkActionBase
395 {
396  [Attribute(UIWidgets.CheckBox, desc: "If true, it will override any previously set game over type with selected one down bellow")]
397  bool m_bOverrideGameOverType;
398 
399  [Attribute("1", UIWidgets.ComboBox, "Game Over Type", "", ParamEnumArray.FromEnum(EGameOverTypes))]
400  EGameOverTypes m_eOverriddenGameOverType;
401 
402  //------------------------------------------------------------------------------------------------
403  override void OnActivate(IEntity object)
404  {
405  if (!CanActivate())
406  return;
407 
408  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
409  if (!manager)
410  return;
411 
412  if (m_bOverrideGameOverType)
413  manager.SetMissionEndScreen(m_eOverriddenGameOverType);
414 
415  manager.Finish();
416  }
417 }
418 
420 class SCR_ScenarioFrameworkActionWaitAndExecute : SCR_ScenarioFrameworkActionBase
421 {
422  [Attribute(desc: "How long to wait before executing action")]
423  int m_iDelayInSeconds;
424 
425  [Attribute(desc: "If this is set to a number larger than Delay In Seconds, it will randomize resulted delay between these two values")]
426  int m_iDelayInSecondsMax;
427 
428  [Attribute(UIWidgets.CheckBox, desc: "If true, it will activate actions in looped manner using Delay settings as the frequency. If randomized, it will randomize the time each time it loops.")]
429  bool m_bLooped;
430 
431  [Attribute(defvalue: "1", desc: "Which actions will be executed once set time passes", UIWidgets.Auto)]
432  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
433 
434  protected int m_iDelay;
435  //------------------------------------------------------------------------------------------------
438  void ExecuteActions(IEntity object)
439  {
440  if (m_bLooped)
441  {
442  m_iDelay = m_iDelayInSeconds;
443  Math.Randomize(-1);
444  if (m_iDelayInSecondsMax > m_iDelayInSeconds)
445  m_iDelay = Math.RandomIntInclusive(m_iDelayInSeconds, m_iDelayInSecondsMax);
446  }
447 
448  foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
449  {
450  actions.OnActivate(object);
451  }
452  }
453 
454  //------------------------------------------------------------------------------------------------
455  override void OnActivate(IEntity object)
456  {
457  if (!CanActivate())
458  return;
459 
460  m_iDelay = m_iDelayInSeconds;
461  Math.Randomize(-1);
462  if (m_iDelayInSecondsMax > m_iDelayInSeconds)
463  m_iDelay = Math.RandomIntInclusive(m_iDelayInSeconds, m_iDelayInSecondsMax);
464 
465  //Used to delay the call as it is the feature of this action
466  GetGame().GetCallqueue().CallLater(ExecuteActions, m_iDelay * 1000, m_bLooped, object);
467  }
468 }
469 
471 class SCR_ScenarioFrameworkActionLoopOverNotRandomlySelectedLayers : SCR_ScenarioFrameworkActionBase
472 {
473  [Attribute(desc: "Use GetRandomLayerBase")]
474  ref SCR_ScenarioFrameworkGet m_Getter;
475 
476  [Attribute(defvalue: "1", desc: "Which actions will be executed for each layer that was not randomly selected", UIWidgets.Auto)]
477  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
478 
479  //------------------------------------------------------------------------------------------------
480  override void OnActivate(IEntity object)
481  {
482  if (!CanActivate())
483  return;
484 
485  if (!m_Getter)
486  {
487  Print(string.Format("ScenarioFramework Action: Missing Getter for action %1.", this), LogLevel.ERROR);
488  return;
489  }
490 
491  SCR_ScenarioFrameworkGetRandomLayerBase randomLayerGetter = SCR_ScenarioFrameworkGetRandomLayerBase.Cast(m_Getter);
492  if (!randomLayerGetter)
493  {
494  Print(string.Format("ScenarioFramework Action: Used wrong Getter for Action %1. Use GetRandomLayerBase instead.", this), LogLevel.ERROR);
495  return;
496  }
497 
498  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
499  if (!entityWrapper)
500  {
501  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
502  return;
503  }
504 
505  IEntity entity = IEntity.Cast(entityWrapper.GetValue());
506  if (!entity)
507  {
508  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
509  return;
510  }
511 
512  string excludedEntity = entity.GetName();
513  IEntity notSelectedEntity;
514 
515  foreach (string layer : randomLayerGetter.m_aNameOfLayers)
516  {
517  if (layer == excludedEntity)
518  continue;
519 
520  notSelectedEntity = m_Getter.FindEntityByName(layer);
521  if (!notSelectedEntity)
522  continue;
523 
524  foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
525  {
526  actions.OnActivate(notSelectedEntity);
527  }
528  }
529  }
530 }
531 
533 class SCR_ScenarioFrameworkActionCompareCounterAndExecute : SCR_ScenarioFrameworkActionBase
534 {
535 
536  [Attribute("0", UIWidgets.ComboBox, "Operator", "", ParamEnumArray.FromEnum(SCR_EScenarioFrameworkComparisonOperator))]
537  SCR_EScenarioFrameworkComparisonOperator m_eComparisonOperator;
538 
539  [Attribute(desc: "Value")]
540  int m_iValue;
541 
542  [Attribute(uiwidget: UIWidgets.EditBox, desc: "Counter to increment")]
543  string m_sCounterName;
544 
545  [Attribute(defvalue: "1", desc: "What to do once counter is reached", UIWidgets.Auto, category: "OnActivate")]
546  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
547 
548  //------------------------------------------------------------------------------------------------
549  override void OnActivate(IEntity object)
550  {
551  if (!CanActivate())
552  return;
553 
554  IEntity entity = GetGame().GetWorld().FindEntityByName(m_sCounterName);
555  if (!entity)
556  {
557  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1 with provided name %1.", this, m_sCounterName), LogLevel.ERROR);
558  return;
559  }
560 
561  int counterValue;
562  string className = entity.ClassName();
563  if (className == "SCR_ScenarioFrameworkLogicCounter")
564  {
565  SCR_ScenarioFrameworkLogicCounter logicCounter = SCR_ScenarioFrameworkLogicCounter.Cast(entity);
566  counterValue = logicCounter.m_iCnt;
567  }
568 
569  if (
570  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_THAN) && (counterValue < m_iValue)) ||
571  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.LESS_OR_EQUAL) && (counterValue <= m_iValue)) ||
572  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.EQUAL) && (counterValue == m_iValue)) ||
573  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_OR_EQUAL) && (counterValue >= m_iValue)) ||
574  ((m_eComparisonOperator == SCR_EScenarioFrameworkComparisonOperator.GREATER_THEN) && (counterValue > m_iValue))
575  )
576  {
577  foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
578  {
579  actions.OnActivate(object);
580  }
581  }
582  }
583 }
584 
586 class SCR_ScenarioFrameworkActionSetMissionEndScreen : SCR_ScenarioFrameworkActionBase
587 {
588  [Attribute("1", UIWidgets.ComboBox, "Game Over Type", "", ParamEnumArray.FromEnum(EGameOverTypes))]
590 
591  [Attribute()]
592  LocalizedString m_sSubtitle;
593 
594  //------------------------------------------------------------------------------------------------
595  override void OnActivate(IEntity object)
596  {
597  if (!CanActivate())
598  return;
599 
601  if (!gamemode)
602  return;
603 
604  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(gamemode.FindComponent(SCR_GameModeSFManager));
605  if (!manager)
606  return;
607 
608  manager.SetMissionEndScreen(m_eGameOverType);
609 
610  SCR_GameOverScreenManagerComponent gameOverScreenMgr = SCR_GameOverScreenManagerComponent.Cast(gamemode.FindComponent(SCR_GameOverScreenManagerComponent));
611  if (!gameOverScreenMgr)
612  return;
613 
614  SCR_GameOverScreenConfig m_GameOverScreenConfig = gameOverScreenMgr.GetGameOverConfig();
615  if (!m_GameOverScreenConfig)
616  return;
617 
618  SCR_BaseGameOverScreenInfo targetScreenInfo;
619  m_GameOverScreenConfig.GetGameOverScreenInfo(m_eGameOverType, targetScreenInfo);
620  if (!targetScreenInfo)
621  return;
622 
623  SCR_BaseGameOverScreenInfoOptional optionalParams = targetScreenInfo.GetOptionalParams();
624  if (!optionalParams)
625  return;
626 
627  optionalParams.m_sSubtitle = m_sSubtitle;
628  }
629 }
630 
632 class SCR_ScenarioFrameworkActionSetBriefingEntryText : SCR_ScenarioFrameworkActionBase
633 {
634  [Attribute(desc: "Faction key that corresponds with the SCR_Faction set in FactionManager")]
635  FactionKey m_sFactionKey;
636 
637  [Attribute()]
638  int m_iEntryID;
639 
640  [Attribute()]
641  string m_sTargetText;
642 
643  //------------------------------------------------------------------------------------------------
644  override void OnActivate(IEntity object)
645  {
646  if (!CanActivate())
647  return;
648 
650  if (!gamemode)
651  return;
652 
653  SCR_RespawnBriefingComponent respawnBriefing = SCR_RespawnBriefingComponent.Cast(gamemode.FindComponent(SCR_RespawnBriefingComponent));
654  if (!respawnBriefing)
655  return;
656 
657  SCR_JournalSetupConfig journalSetupConfig = respawnBriefing.GetJournalSetup();
658  if (!journalSetupConfig)
659  return;
660 
661  SCR_JournalConfig journalConfig = journalSetupConfig.GetJournalConfig(m_sFactionKey);
662  if (!journalConfig)
663  return;
664 
665  array<ref SCR_JournalEntry> journalEntries = {};
666  journalEntries = journalConfig.GetEntries();
667  if (journalEntries.IsEmpty())
668  return;
669 
670  SCR_JournalEntry targetJournalEntry;
671  foreach (SCR_JournalEntry journalEntry : journalEntries)
672  {
673  if (journalEntry.GetEntryID() != m_iEntryID)
674  continue;
675 
676  targetJournalEntry = journalEntry;
677  break;
678  }
679 
680  if (!targetJournalEntry)
681  return;
682 
683  targetJournalEntry.SetEntryText(WidgetManager.Translate(m_sTargetText));
684  }
685 }
686 
688 class SCR_ScenarioFrameworkActionAppendBriefingEntryText : SCR_ScenarioFrameworkActionBase
689 {
690  [Attribute(desc: "Faction key that corresponds with the SCR_Faction set in FactionManager")]
691  FactionKey m_sFactionKey;
692 
693  [Attribute()]
694  int m_iEntryID;
695 
696  [Attribute()]
697  string m_sTargetText;
698 
699  //------------------------------------------------------------------------------------------------
700  override void OnActivate(IEntity object)
701  {
702  if (!CanActivate())
703  return;
704 
706  if (!gamemode)
707  return;
708 
709  SCR_RespawnBriefingComponent respawnBriefing = SCR_RespawnBriefingComponent.Cast(gamemode.FindComponent(SCR_RespawnBriefingComponent));
710  if (!respawnBriefing)
711  return;
712 
713  SCR_JournalSetupConfig journalSetupConfig = respawnBriefing.GetJournalSetup();
714  if (!journalSetupConfig)
715  return;
716 
717  SCR_JournalConfig journalConfig = journalSetupConfig.GetJournalConfig(m_sFactionKey);
718  if (!journalConfig)
719  return;
720 
721  array<ref SCR_JournalEntry> journalEntries = {};
722  journalEntries = journalConfig.GetEntries();
723  if (journalEntries.IsEmpty())
724  return;
725 
726  SCR_JournalEntry targetJournalEntry;
727  foreach (SCR_JournalEntry journalEntry : journalEntries)
728  {
729  if (journalEntry.GetEntryID() != m_iEntryID)
730  continue;
731 
732  targetJournalEntry = journalEntry;
733  break;
734  }
735 
736  if (!targetJournalEntry)
737  return;
738 
739  string finalText = targetJournalEntry.GetEntryText() + "<br/>" + "<br/>" + m_sTargetText;
740  targetJournalEntry.SetEntryText(finalText);
741  }
742 }
743 
745 class SCR_ScenarioFrameworkActionAppendBriefingEntryTextBasedOnTask : SCR_ScenarioFrameworkActionBase
746 {
747  [Attribute(desc: "Faction key that corresponds with the SCR_Faction set in FactionManager")]
748  FactionKey m_sFactionKey;
749 
750  [Attribute()]
751  int m_iEntryID;
752 
753  [Attribute(desc: "From which task to fetch text")]
754  ref SCR_ScenarioFrameworkGet m_Getter;
755 
756  //------------------------------------------------------------------------------------------------
757  override void OnActivate(IEntity object)
758  {
759  if (!m_Getter || !CanActivate())
760  return;
761 
762  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
763  if (!entityWrapper)
764  return;
765 
766  SCR_ScenarioFrameworkTask task = SCR_ScenarioFrameworkTask.Cast(entityWrapper.GetValue());
767  if (!task)
768  return;
769 
771  if (!gamemode)
772  return;
773 
774  SCR_RespawnBriefingComponent respawnBriefing = SCR_RespawnBriefingComponent.Cast(gamemode.FindComponent(SCR_RespawnBriefingComponent));
775  if (!respawnBriefing)
776  return;
777 
778  SCR_JournalSetupConfig journalSetupConfig = respawnBriefing.GetJournalSetup();
779  if (!journalSetupConfig)
780  return;
781 
782  SCR_JournalConfig journalConfig = journalSetupConfig.GetJournalConfig(m_sFactionKey);
783  if (!journalConfig)
784  return;
785 
786  array<ref SCR_JournalEntry> journalEntries = {};
787  journalEntries = journalConfig.GetEntries();
788  if (journalEntries.IsEmpty())
789  return;
790 
791  SCR_JournalEntry targetJournalEntry;
792  foreach (SCR_JournalEntry journalEntry : journalEntries)
793  {
794  if (journalEntry.GetEntryID() != m_iEntryID)
795  continue;
796 
797  targetJournalEntry = journalEntry;
798  break;
799  }
800 
801  if (!targetJournalEntry)
802  return;
803 
804  array<string> previousStrings = {};
805  array<string> taskStrings = {};
806  previousStrings = respawnBriefing.GetBriefingStringParamByID(m_iEntryID);
807  if (previousStrings)
808  taskStrings.InsertAll(previousStrings);
809 
810  taskStrings.Insert(task.GetTaskExecutionBriefing());
811  taskStrings.Insert(task.GetSpawnedEntityName());
812 
813  respawnBriefing.RewriteEntry_SA(m_sFactionKey, m_iEntryID, targetJournalEntry.GetEntryText(), taskStrings);
814  }
815 }
816 
818 class SCR_ScenarioFrameworkActionSetBriefingEntryTextBasedOnGeneratedTasks : SCR_ScenarioFrameworkActionBase
819 {
820  [Attribute(desc: "Faction key that corresponds with the SCR_Faction set in FactionManager", category: "Asset")]
821  FactionKey m_sFactionKey;
822 
823  [Attribute()]
824  int m_iEntryID;
825 
826  [Attribute(desc: "Text that you want to use. Leave empty if you want to utilize the one set in config.")]
827  string m_sTargetText;
828 
829  //------------------------------------------------------------------------------------------------
830  override void OnActivate(IEntity object)
831  {
832  if (!CanActivate())
833  return;
834 
836  if (!gamemode)
837  return;
838 
839  SCR_RespawnBriefingComponent respawnBriefing = SCR_RespawnBriefingComponent.Cast(gamemode.FindComponent(SCR_RespawnBriefingComponent));
840  if (!respawnBriefing)
841  return;
842 
843  SCR_JournalSetupConfig journalSetupConfig = respawnBriefing.GetJournalSetup();
844  if (!journalSetupConfig)
845  return;
846 
847  SCR_JournalConfig journalConfig = journalSetupConfig.GetJournalConfig(m_sFactionKey);
848  if (!journalConfig)
849  return;
850 
851  array<ref SCR_JournalEntry> journalEntries = {};
852  journalEntries = journalConfig.GetEntries();
853  if (journalEntries.IsEmpty())
854  return;
855 
856  SCR_JournalEntry targetJournalEntry;
857  foreach (SCR_JournalEntry journalEntry : journalEntries)
858  {
859  if (journalEntry.GetEntryID() != m_iEntryID)
860  continue;
861 
862  targetJournalEntry = journalEntry;
863  break;
864  }
865 
866  SCR_BaseTaskManager taskManager = GetTaskManager();
867  if (!taskManager)
868  return;
869 
870  array<SCR_BaseTask> tasks = {};
871  taskManager.GetTasks(tasks);
872 
873  array<string> taskStrings = {};
874  foreach (SCR_BaseTask task : tasks)
875  {
876  taskStrings.Insert(task.GetTitle());
877  taskStrings.Insert("");
878  }
879 
880  string tasksToShow;
881  foreach (SCR_BaseTask task : tasks)
882  {
883  tasksToShow = tasksToShow + "<br/>" + string.Format(task.GetTitle());
884  }
885 
886  if (!targetJournalEntry)
887  return;
888 
889  if (m_sTargetText.IsEmpty())
890  m_sTargetText = targetJournalEntry.GetEntryText();
891 
892  respawnBriefing.RewriteEntry_SA(m_sFactionKey, m_iEntryID, m_sTargetText, taskStrings);
893  }
894 }
895 
897 class SCR_ScenarioFrameworkActionSetExecutionEntryTextBasedOnGeneratedTasks : SCR_ScenarioFrameworkActionBase
898 {
899  [Attribute(desc: "Faction key that corresponds with the SCR_Faction set in FactionManager", category: "Asset")]
900  FactionKey m_sFactionKey;
901 
902  [Attribute()]
903  int m_iEntryID;
904 
905  [Attribute(desc: "Text that you want to use. Leave empty if you want to utilize the one set in config.")]
906  string m_sTargetText;
907 
908  //------------------------------------------------------------------------------------------------
909  override void OnActivate(IEntity object)
910  {
911  if (!CanActivate())
912  return;
913 
915  if (!gamemode)
916  return;
917 
918  SCR_RespawnBriefingComponent respawnBriefing = SCR_RespawnBriefingComponent.Cast(gamemode.FindComponent(SCR_RespawnBriefingComponent));
919  if (!respawnBriefing)
920  return;
921 
922  SCR_JournalSetupConfig journalSetupConfig = respawnBriefing.GetJournalSetup();
923  if (!journalSetupConfig)
924  return;
925 
926  SCR_JournalConfig journalConfig = journalSetupConfig.GetJournalConfig(m_sFactionKey);
927  if (!journalConfig)
928  return;
929 
930  array<ref SCR_JournalEntry> journalEntries = {};
931  journalEntries = journalConfig.GetEntries();
932  if (journalEntries.IsEmpty())
933  return;
934 
935  SCR_JournalEntry targetJournalEntry;
936  foreach (SCR_JournalEntry journalEntry : journalEntries)
937  {
938  if (journalEntry.GetEntryID() != m_iEntryID)
939  continue;
940 
941  targetJournalEntry = journalEntry;
942  break;
943  }
944 
945  if (!targetJournalEntry)
946  return;
947 
948  SCR_BaseTaskManager taskManager = GetTaskManager();
949  if (!taskManager)
950  return;
951 
952  array<SCR_BaseTask> tasks = {};
953  taskManager.GetTasks(tasks);
954 
955  array<SCR_ScenarioFrameworkTask> frameworkTasks = {};
956  foreach (SCR_BaseTask task : tasks)
957  {
958  if (SCR_ScenarioFrameworkTask.Cast(task))
959  frameworkTasks.Insert(SCR_ScenarioFrameworkTask.Cast(task));
960  }
961 
962  string tasksToShow;
963  array<string> taskStrings = {};
964  foreach (SCR_ScenarioFrameworkTask frameworkTask : frameworkTasks)
965  {
966  taskStrings.Insert(frameworkTask.GetTaskExecutionBriefing());
967  taskStrings.Insert(frameworkTask.GetSpawnedEntityName());
968  }
969 
970  if (m_sTargetText.IsEmpty())
971  m_sTargetText = targetJournalEntry.GetEntryText();
972 
973  respawnBriefing.RewriteEntry_SA(m_sFactionKey, m_iEntryID, m_sTargetText, taskStrings);
974  }
975 }
976 
978 class SCR_ScenarioFrameworkActionFeedParamToTaskDescription : SCR_ScenarioFrameworkActionBase
979 {
980  [Attribute(desc: "Name of the slot task to influence the description parameter")]
981  ref SCR_ScenarioFrameworkGet m_Getter;
982 
983  [Attribute(desc: "Which Prefabs and how many of them will be converted to a description string")]
984  ref array<ref SCR_ScenarioFrameworkPrefabFilterCount> m_aPrefabFilter;
985 
986  //------------------------------------------------------------------------------------------------
987  override void OnActivate(IEntity object)
988  {
989  if (!CanActivate())
990  return;
991 
992  IEntity entity;
993  if (!m_Getter && object)
994  {
995  entity = object;
996  }
997  else if (m_Getter)
998  {
999  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
1000  if (!entityWrapper)
1001  return;
1002 
1003  entity = IEntity.Cast(entityWrapper.GetValue());
1004  if (!entity)
1005  return;
1006  }
1007 
1008  SCR_ScenarioFrameworkSlotTask slotTask = SCR_ScenarioFrameworkSlotTask.Cast(entity.FindComponent(SCR_ScenarioFrameworkSlotTask));
1009  if (!slotTask)
1010  return;
1011 
1012  string descriptionExtension;
1013 
1014  Resource resource;
1015  IEntitySource entitySource;
1016  string displayName;
1017  IEntityComponentSource editableEntitySource;
1018  IEntityComponentSource weaponEntitySource;
1019  IEntityComponentSource inventoryEntitySource;
1020 
1022  {
1023  resource = Resource.Load(filter.m_sSpecificPrefabName);
1024  if (!resource || !resource.IsValid())
1025  continue;
1026 
1027  entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
1028  if (!entitySource)
1029  return;
1030 
1031  editableEntitySource = SCR_EditableEntityComponentClass.GetEditableEntitySource(entitySource);
1032  weaponEntitySource = SCR_ComponentHelper.GetWeaponComponentSource(entitySource);
1033  inventoryEntitySource = SCR_ComponentHelper.GetInventoryItemComponentSource(entitySource);
1034 
1035  if (editableEntitySource)
1036  {
1037  SCR_EditableEntityUIInfo editableEntityUiInfo = SCR_EditableEntityComponentClass.GetInfo(editableEntitySource);
1038  if (editableEntityUiInfo)
1039  displayName = editableEntityUiInfo.GetName();
1040  }
1041  else if (weaponEntitySource)
1042  {
1043  WeaponUIInfo weaponEntityUiInfo = SCR_ComponentHelper.GetWeaponComponentInfo(weaponEntitySource);
1044  if (weaponEntityUiInfo)
1045  displayName = weaponEntityUiInfo.GetName();
1046  }
1047  else if (inventoryEntitySource)
1048  {
1049  SCR_ItemAttributeCollection inventoryEntityUiInfo = SCR_ComponentHelper.GetInventoryItemInfo(inventoryEntitySource);
1050  if (inventoryEntityUiInfo)
1051  {
1052  UIInfo uiInfo = inventoryEntityUiInfo.GetUIInfo();
1053  if (uiInfo)
1054  displayName = uiInfo.GetName();
1055  else
1056  continue;
1057  }
1058  else
1059  {
1060  continue;
1061  }
1062  }
1063 
1064  int count = filter.m_iPrefabCount;
1065  if (SCR_StringHelper.IsEmptyOrWhiteSpace(descriptionExtension))
1066  descriptionExtension += count.ToString() + "x " + displayName;
1067  else
1068  descriptionExtension += ", " + count.ToString() + "x " + displayName;
1069  }
1070 
1071  slotTask.m_TaskLayer.m_SupportEntity.SetSpawnedEntityName(slotTask.m_TaskLayer.m_Task, descriptionExtension);
1072  }
1073 }
1074 
1076 class SCR_ScenarioFrameworkActionShowHint : SCR_ScenarioFrameworkActionBase
1077 {
1078  [Attribute()]
1079  string m_sTitle;
1080 
1081  [Attribute()]
1082  string m_sText;
1083 
1084  [Attribute(defvalue: "15")]
1085  int m_iTimeout;
1086 
1087  [Attribute()]
1088  FactionKey m_sFactionKey;
1089 
1090  [Attribute(desc: "Getter to get either a specific player or array of player entities")]
1091  ref SCR_ScenarioFrameworkGet m_Getter;
1092 
1093  //------------------------------------------------------------------------------------------------
1094  override void OnActivate(IEntity object)
1095  {
1096  if (!CanActivate())
1097  return;
1098 
1099  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
1100  if (!manager)
1101  return;
1102 
1103  PlayerManager playerManager = GetGame().GetPlayerManager();
1104  if (!playerManager)
1105  return;
1106 
1107  int playerID = -1;
1108  if (EntityUtils.IsPlayer(object))
1109  playerID = playerManager.GetPlayerIdFromControlledEntity(object);
1110 
1111  array<IEntity> aEntities;
1112 
1113  if (m_Getter)
1114  {
1115  // Getter takes the priority. We set it back to -1 in case that object was player.
1116  playerID = -1;
1117 
1118  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
1119  if (!entityWrapper)
1120  {
1121  SCR_ScenarioFrameworkParam<array<IEntity>> arrayOfEntitiesWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_Getter.Get());
1122  if (!arrayOfEntitiesWrapper)
1123  return;
1124 
1125  aEntities = array<IEntity>.Cast(arrayOfEntitiesWrapper.GetValue());
1126  if (!aEntities)
1127  return;
1128  }
1129  else
1130  {
1131  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
1132  if (entityFrom)
1133  playerID = playerManager.GetPlayerIdFromControlledEntity(entityFrom);
1134  }
1135  }
1136 
1137  if (!aEntities)
1138  {
1139  manager.ShowHint(m_sText, m_sTitle, m_iTimeout, m_sFactionKey, playerID);
1140  }
1141  else
1142  {
1143  foreach (IEntity entity : aEntities)
1144  {
1145  if (!EntityUtils.IsPlayer(entity))
1146  continue;
1147 
1148  playerID = playerManager.GetPlayerIdFromControlledEntity(entity);
1149  manager.ShowHint(m_sText, m_sTitle, m_iTimeout, m_sFactionKey, playerID);
1150  }
1151  }
1152  }
1153 }
1154 
1156 class SCR_ScenarioFrameworkActionShowPopupNotification : SCR_ScenarioFrameworkActionBase
1157 {
1158  [Attribute()]
1159  string m_sTitle;
1160 
1161  [Attribute()]
1162  string m_sText;
1163 
1164  [Attribute()]
1165  FactionKey m_sFactionKey;
1166 
1167  [Attribute(desc: "Getter to get either a specific player or array of player entities")]
1168  ref SCR_ScenarioFrameworkGet m_Getter;
1169 
1170  //------------------------------------------------------------------------------------------------
1171  override void OnActivate(IEntity object)
1172  {
1173  if (!CanActivate())
1174  return;
1175 
1176  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
1177  if (!manager)
1178  return;
1179 
1180  PlayerManager playerManager = GetGame().GetPlayerManager();
1181  if (!playerManager)
1182  return;
1183 
1184  int playerID = -1;
1185  if (EntityUtils.IsPlayer(object))
1186  playerID = playerManager.GetPlayerIdFromControlledEntity(object);
1187 
1188  array<IEntity> aEntities;
1189 
1190  if (m_Getter)
1191  {
1192  // Getter takes the priority. We set it back to -1 in case that object was player.
1193  playerID = -1;
1194 
1195  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
1196  if (!entityWrapper)
1197  {
1198  SCR_ScenarioFrameworkParam<array<IEntity>> arrayOfEntitiesWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_Getter.Get());
1199  if (!arrayOfEntitiesWrapper)
1200  return;
1201 
1202  aEntities = array<IEntity>.Cast(arrayOfEntitiesWrapper.GetValue());
1203  if (!aEntities)
1204  return;
1205  }
1206  else
1207  {
1208  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
1209  if (entityFrom)
1210  playerID = playerManager.GetPlayerIdFromControlledEntity(entityFrom);
1211  }
1212  }
1213 
1214  if (!aEntities)
1215  {
1216  manager.PopUpMessage(m_sText, m_sTitle, m_sFactionKey, playerID);
1217  }
1218  else
1219  {
1220  foreach (IEntity entity : aEntities)
1221  {
1222  if (!EntityUtils.IsPlayer(entity))
1223  continue;
1224 
1225  playerID = playerManager.GetPlayerIdFromControlledEntity(entity);
1226  manager.PopUpMessage(m_sText, m_sTitle, m_sFactionKey, playerID);
1227  }
1228  }
1229  }
1230 }
1231 
1233 class SCR_ScenarioFrameworkActionSpawnClosestObjectFromList : SCR_ScenarioFrameworkActionBase
1234 {
1235  [Attribute(desc: "Closest to what - use getter")]
1236  ref SCR_ScenarioFrameworkGet m_Getter;
1237 
1238  [Attribute(defvalue: "", UIWidgets.EditComboBox, desc: "The closest one from the list will be spawned")]
1239  ref array<string> m_aListOfObjects;
1240 
1241  //------------------------------------------------------------------------------------------------
1242  override void OnActivate(IEntity object)
1243  {
1244  if (!CanActivate())
1245  return;
1246 
1247  IEntity entity;
1248  if (!m_Getter)
1249  {
1250  if (object)
1251  {
1252  entity = object;
1253  }
1254  else
1255  {
1256  Print(string.Format("ScenarioFramework Action: The object the distance is calculated from is missing!"), LogLevel.ERROR);
1257  return;
1258  }
1259  }
1260 
1261  if (!entity)
1262  {
1263  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
1264  if (!entityWrapper)
1265  {
1266  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
1267  return;
1268  }
1269 
1270  entity = IEntity.Cast(entityWrapper.GetValue());
1271  }
1272 
1273  IEntity entityInList;
1274  SCR_ScenarioFrameworkLayerBase selectedLayer;
1275  if (!entity)
1276  {
1277  Print(string.Format("ScenarioFramework Action: Getter returned null object. Random object spawned instead."), LogLevel.WARNING);
1278  array<string> aRandomObjectToSpawn = {};
1279  aRandomObjectToSpawn.Insert(m_aListOfObjects[m_aListOfObjects.GetRandomIndex()]);
1280 
1281  entityInList = GetGame().GetWorld().FindEntityByName(aRandomObjectToSpawn[0]);
1282  if (!entityInList)
1283  {
1284  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
1285  return;
1286  }
1287 
1288  SpawnObjects(aRandomObjectToSpawn, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1289  return;
1290  }
1291 
1292  IEntity closestEntity;
1293  float fDistance = float.MAX;
1294  foreach (string sObjectName : m_aListOfObjects)
1295  {
1296  entityInList = GetGame().GetWorld().FindEntityByName(sObjectName);
1297  if (!entityInList)
1298  {
1299  Print(string.Format("ScenarioFramework Action: Object %1 doesn't exist", sObjectName), LogLevel.ERROR);
1300  continue;
1301  }
1302 
1303  selectedLayer = SCR_ScenarioFrameworkLayerBase.Cast(entityInList.FindComponent(SCR_ScenarioFrameworkLayerBase));
1304  if (!selectedLayer)
1305  continue;
1306 
1307  float fActualDistance = Math.AbsFloat(vector.Distance(entity.GetOrigin(), entityInList.GetOrigin()));
1308 
1309  if (fActualDistance < fDistance)
1310  {
1311  closestEntity = entityInList;
1312  fDistance = fActualDistance;
1313  }
1314  }
1315 
1316  if (!closestEntity)
1317  return;
1318 
1319  selectedLayer = SCR_ScenarioFrameworkLayerBase.Cast(closestEntity.FindComponent(SCR_ScenarioFrameworkLayerBase));
1320 
1321  if (selectedLayer)
1322  {
1323  selectedLayer.Init(null, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1324  selectedLayer.SetActivationType(SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
1325  }
1326  else
1327  {
1328  Print(string.Format("ScenarioFramework Action: Can't spawn slot %1 - the slot doesn't have SCR_ScenarioFrameworkLayerBase component", closestEntity.GetName()), LogLevel.ERROR);
1329  }
1330  }
1331 }
1332 
1334 class SCR_ScenarioFrameworkActionSpawnObjectBasedOnDistance : SCR_ScenarioFrameworkActionBase
1335 {
1336  [Attribute(desc: "Measure distance from what - use getter")]
1337  ref SCR_ScenarioFrameworkGet m_Getter;
1338 
1339  [Attribute(desc: "It will select only objects that are at least x amount of meters away")]
1340  int m_iMinDistance;
1341 
1342  [Attribute(desc: "You can also set max distance to setup the hard limit of the max distance - but be aware that there might be a situation where it would not spawn anything.")]
1343  int m_iMaxDistance;
1344 
1345  [Attribute(defvalue: "", UIWidgets.EditComboBox, desc: "List of objects that are to be compared")]
1346  ref array<string> m_aListOfObjects;
1347 
1348  [Attribute(defvalue: "0", UIWidgets.ComboBox, desc: "Spawn all objects, only random one or random multiple ones?", "", ParamEnumArray.FromEnum(SCR_EScenarioFrameworkSpawnChildrenType))]
1350 
1351  [Attribute(defvalue: "100", desc: "If the RANDOM_MULTIPLE option is selected, what's the percentage? ", UIWidgets.Graph, "0 100 1")]
1352  int m_iRandomPercent;
1353 
1354  //------------------------------------------------------------------------------------------------
1355  void SpawnRandomObject(notnull array<string> aObjectsNames)
1356  {
1357  IEntity object = GetGame().GetWorld().FindEntityByName(aObjectsNames.GetRandomElement());
1358  if (!object)
1359  {
1360  Print(string.Format("ScenarioFramework Action: Can't spawn object set in slot %1. Slot doesn't exist", object), LogLevel.ERROR);
1361  return;
1362  }
1363 
1365  if (!layer)
1366  {
1367  Print(string.Format("ScenarioFramework Action: Can't spawn object - the slot doesn't have SCR_ScenarioFrameworkLayerBase component", object), LogLevel.ERROR);
1368  return;
1369  }
1370 
1371  layer.Init(null, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1372  }
1373 
1374  //------------------------------------------------------------------------------------------------
1375  void SpawnRandomMultipleObjects(notnull array<string> aObjectsNames)
1376  {
1377  array<SCR_ScenarioFrameworkLayerBase> aChildren = {};
1378  IEntity object;
1380  SCR_ScenarioFrameworkLayerBase cachedLayer;
1381  foreach (string objectName : aObjectsNames)
1382  {
1383  object = GetGame().GetWorld().FindEntityByName(objectName);
1384  if (!object)
1385  {
1386  Print(string.Format("ScenarioFramework Action: Can't spawn object set in slot %1. Slot doesn't exist", objectName), LogLevel.ERROR);
1387  continue;
1388  }
1389 
1390  layer = SCR_ScenarioFrameworkLayerBase.Cast(object.FindComponent(SCR_ScenarioFrameworkLayerBase));
1391  if (!layer)
1392  {
1393  Print(string.Format("ScenarioFramework Action: Can't spawn object - the slot doesn't have SCR_ScenarioFrameworkLayerBase component", objectName), LogLevel.ERROR);
1394  continue;
1395  }
1396 
1397  if (!cachedLayer)
1398  cachedLayer = layer;
1399 
1400  if (!aChildren.Contains(layer))
1401  aChildren.Insert(layer);
1402  }
1403 
1404  if (aChildren.IsEmpty())
1405  return;
1406 
1407  if (m_SpawnObjects == SCR_EScenarioFrameworkSpawnChildrenType.RANDOM_BASED_ON_PLAYERS_COUNT)
1408  m_iRandomPercent = Math.Ceil(cachedLayer.GetPlayersCount() / cachedLayer.GetMaxPlayersForGameMode() * 100);
1409 
1410  int randomMultipleNumber = Math.Round(aObjectsNames.Count() * 0.01 * m_iRandomPercent);
1412  for (int i = 1; i <= randomMultipleNumber; i++)
1413  {
1414  if (aChildren.IsEmpty())
1415  break;
1416 
1417  Math.Randomize(-1);
1418  child = aChildren.GetRandomElement();
1419  child.Init(null, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1420  child.SetActivationType(SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
1421  aChildren.RemoveItem(child);
1422  }
1423  }
1424 
1425  //------------------------------------------------------------------------------------------------
1426  override void OnActivate(IEntity object)
1427  {
1428  if (!CanActivate())
1429  return;
1430 
1431  IEntity entityFrom;
1432  if (!m_Getter)
1433  {
1434  if (object)
1435  {
1436  entityFrom = object;
1437  }
1438  else
1439  {
1440  Print(string.Format("ScenarioFramework Action: The object the distance is calculated from is missing!"), LogLevel.ERROR);
1441  return;
1442  }
1443  }
1444 
1445  array<IEntity> aEntities = {};
1446 
1447  if (m_Getter)
1448  {
1449  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
1450  if (!entityWrapper)
1451  {
1452  SCR_ScenarioFrameworkParam<array<IEntity>> arrayOfEntitiesWrapper = SCR_ScenarioFrameworkParam<array<IEntity>>.Cast(m_Getter.Get());
1453  if (!arrayOfEntitiesWrapper)
1454  {
1455  Print(string.Format("ScenarioFramework Action: Issue with Array Getter detected for Action %1.", this), LogLevel.ERROR);
1456  return;
1457  }
1458 
1459  aEntities = array<IEntity>.Cast(arrayOfEntitiesWrapper.GetValue());
1460  if (!aEntities)
1461  {
1462  Print(string.Format("ScenarioFramework Action: Issue with retrieved array detected for Action %1.", this), LogLevel.ERROR);
1463  return;
1464  }
1465 
1466  if (!entityFrom && entityWrapper)
1467  entityFrom = IEntity.Cast(entityWrapper.GetValue());
1468  }
1469  }
1470 
1471  bool entitiesAreEmpty = aEntities.IsEmpty();
1472 
1473  Math.Randomize(-1);
1474  IEntity entityInList;
1475  SCR_ScenarioFrameworkLayerBase selectedLayer;
1476  if (!entityFrom && entitiesAreEmpty)
1477  {
1478  Print(string.Format("ScenarioFramework Action: Getter returned null object. Random object spawned instead."), LogLevel.WARNING);
1479  array<string> aRandomObjectToSpawn = {};
1480  aRandomObjectToSpawn.Insert(m_aListOfObjects[m_aListOfObjects.GetRandomIndex()]);
1481 
1482  entityInList = GetGame().GetWorld().FindEntityByName(aRandomObjectToSpawn[0]);
1483  if (!entityInList)
1484  {
1485  Print(string.Format("ScenarioFramework Action: Object %1 doesn't exist", aRandomObjectToSpawn[0]), LogLevel.ERROR);
1486  return;
1487  }
1488 
1489  SpawnObjects(aRandomObjectToSpawn, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1490  return;
1491  }
1492 
1493  array<string> aObjectsNames = {};
1494 
1495  foreach (string objectName : m_aListOfObjects)
1496  {
1497  entityInList = GetGame().GetWorld().FindEntityByName(objectName);
1498  if (!entityInList)
1499  {
1500  Print(string.Format("ScenarioFramework Action: Object %1 doesn't exist", objectName), LogLevel.ERROR);
1501  continue;
1502  }
1503 
1504  if (entitiesAreEmpty)
1505  {
1506  float fActualDistance = Math.AbsFloat(vector.Distance(entityFrom.GetOrigin(), entityInList.GetOrigin()));
1507 
1508  if (fActualDistance <= m_iMaxDistance && fActualDistance >= m_iMinDistance)
1509  aObjectsNames.Insert(objectName)
1510  }
1511  else
1512  {
1513  bool entityInRange;
1514  foreach (IEntity targetEntity : aEntities)
1515  {
1516  float fActualDistance = Math.AbsFloat(vector.Distance(targetEntity.GetOrigin(), entityInList.GetOrigin()));
1517 
1518  if (fActualDistance <= m_iMaxDistance && fActualDistance >= m_iMinDistance)
1519  {
1520  entityInRange = true;
1521  }
1522  else
1523  {
1524  entityInRange = false;
1525  break;
1526  }
1527  }
1528 
1529  if (entityInRange)
1530  aObjectsNames.Insert(objectName)
1531  }
1532  }
1533 
1534  if (m_SpawnObjects == SCR_EScenarioFrameworkSpawnChildrenType.RANDOM_ONE)
1535  {
1536  //We need to introduce slight delay for the randomization by time seed to occur
1537  GetGame().GetCallqueue().CallLater(SpawnRandomObject, Math.RandomInt(1, 10), false, aObjectsNames);
1538  return;
1539  }
1540 
1541  if (m_SpawnObjects == SCR_EScenarioFrameworkSpawnChildrenType.ALL)
1542  {
1543  foreach (string objectName : aObjectsNames)
1544  {
1545  entityInList = GetGame().GetWorld().FindEntityByName(objectName);
1546  selectedLayer = SCR_ScenarioFrameworkLayerBase.Cast(entityInList.FindComponent(SCR_ScenarioFrameworkLayerBase));
1547  if (selectedLayer)
1548  {
1549  SCR_ScenarioFrameworkArea area = selectedLayer.GetParentArea();
1550  if (!area)
1551  continue;
1552 
1553  area.SetAreaSelected(true);
1554  SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(selectedLayer);
1555  if (layerTask)
1556  selectedLayer.GetParentArea().SetLayerTask(layerTask);
1557 
1558  selectedLayer.Init(area, SCR_ScenarioFrameworkEActivationType.ON_TRIGGER_ACTIVATION);
1559  selectedLayer.SetActivationType(SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
1560  }
1561  else
1562  {
1563  Print(string.Format("ScenarioFramework Action: Can't spawn slot %1 - the slot doesn't have SCR_ScenarioFrameworkLayerBase component", selectedLayer.GetName()), LogLevel.ERROR);
1564  }
1565  }
1566 
1567  return;
1568  }
1569 
1570  SpawnRandomMultipleObjects(aObjectsNames);
1571  }
1572 }
1573 
1575 class SCR_ScenarioFrameworkActionItemSafeguard : SCR_ScenarioFrameworkActionBase
1576 {
1577  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
1578  ref SCR_ScenarioFrameworkGet m_Getter;
1579 
1580  [Attribute(desc: "Actions that will be executed when target item is dropped", UIWidgets.Auto)]
1581  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemDropped;
1582 
1583  [Attribute(desc: "Actions that will be executed when target item is possesed by someone/something", UIWidgets.Auto)]
1584  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemPossessed;
1585 
1586  protected IEntity m_ItemEntity;
1587 
1588  //------------------------------------------------------------------------------------------------
1589  void OnItemPossessed(IEntity item, BaseInventoryStorageComponent pStorageOwner)
1590  {
1591  if(!item || item != m_ItemEntity)
1592  return;
1593 
1594  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemPossessed)
1595  {
1596  action.OnActivate(pStorageOwner.GetOwner());
1597  }
1598  }
1599 
1600  //------------------------------------------------------------------------------------------------
1601  void OnItemDropped(IEntity item, BaseInventoryStorageComponent pStorageOwner)
1602  {
1603  if(!item || item != m_ItemEntity)
1604  return;
1605 
1606  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemDropped)
1607  {
1608  action.OnActivate(pStorageOwner.GetOwner());
1609  }
1610  }
1611 
1612  //------------------------------------------------------------------------------------------------
1613  protected void OnItemCarrierChanged(InventoryStorageSlot oldSlot, InventoryStorageSlot newSlot)
1614  {
1615  EventHandlerManagerComponent eventHandlerMgr;
1616  if (oldSlot)
1617  {
1618  eventHandlerMgr = EventHandlerManagerComponent.Cast(oldSlot.GetOwner().FindComponent(EventHandlerManagerComponent));
1619  if (eventHandlerMgr)
1620  eventHandlerMgr.RemoveScriptHandler("OnDestroyed", this, OnDestroyed);
1621  }
1622 
1623  if (newSlot)
1624  {
1625  eventHandlerMgr = EventHandlerManagerComponent.Cast(newSlot.GetOwner().FindComponent(EventHandlerManagerComponent));
1626  if (eventHandlerMgr)
1627  eventHandlerMgr.RegisterScriptHandler("OnDestroyed", this, OnDestroyed);
1628  }
1629  }
1630 
1631  //------------------------------------------------------------------------------------------------
1633  protected void OnDestroyed(IEntity destroyedEntity)
1634  {
1635  if (!destroyedEntity)
1636  return;
1637 
1638  if (!m_ItemEntity)
1639  return;
1640 
1641  InventoryItemComponent invComp = InventoryItemComponent.Cast(m_ItemEntity.FindComponent(InventoryItemComponent));
1642  if (!invComp)
1643  return;
1644 
1645  InventoryStorageSlot parentSlot = invComp.GetParentSlot();
1646  if (!parentSlot)
1647  return;
1648 
1649  InventoryStorageManagerComponent inventoryComponent = InventoryStorageManagerComponent.Cast(destroyedEntity.FindComponent(InventoryStorageManagerComponent));
1650  if (!inventoryComponent)
1651  return;
1652 
1653  if (!inventoryComponent.Contains(m_ItemEntity))
1654  return;
1655 
1656  inventoryComponent.TryRemoveItemFromStorage(m_ItemEntity, parentSlot.GetStorage());
1657  m_ItemEntity.SetOrigin(destroyedEntity.GetOrigin());
1658  }
1659 
1660  //------------------------------------------------------------------------------------------------
1661  protected void OnDisconnected(int playerID)
1662  {
1663  IEntity player = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
1664  if (!player)
1665  return;
1666 
1667  OnDestroyed(player);
1668  }
1669 
1670  //------------------------------------------------------------------------------------------------
1671  protected void RegisterPlayer(int playerID, IEntity playerEntity)
1672  {
1673  IEntity player = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
1674  if (!player)
1675  return;
1676 
1677  SCR_InventoryStorageManagerComponent inventoryComponent = SCR_InventoryStorageManagerComponent.Cast(player.FindComponent(SCR_InventoryStorageManagerComponent));
1678  if (!inventoryComponent)
1679  return;
1680 
1681  inventoryComponent.m_OnItemAddedInvoker.Insert(OnItemPossessed);
1682  inventoryComponent.m_OnItemRemovedInvoker.Insert(OnItemDropped);
1683 
1684  EventHandlerManagerComponent eventHandlerMgr = EventHandlerManagerComponent.Cast(player.FindComponent(EventHandlerManagerComponent));
1685  if (eventHandlerMgr)
1686  eventHandlerMgr.RegisterScriptHandler("OnDestroyed", this, OnDestroyed);
1687  }
1688 
1689  //------------------------------------------------------------------------------------------------
1690  override void OnActivate(IEntity object)
1691  {
1692  if (!CanActivate())
1693  return;
1694 
1695  if (!ValidateInputEntity(object, m_Getter, m_ItemEntity))
1696  return;
1697 
1698  InventoryItemComponent invComp = InventoryItemComponent.Cast(m_ItemEntity.FindComponent(InventoryItemComponent));
1699  if (!invComp)
1700  return;
1701 
1702  invComp.m_OnParentSlotChangedInvoker.Insert(OnItemCarrierChanged);
1703 
1704  array<int> aPlayerIDs = {};
1705  int iNrOfPlayersConnected = GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
1706 
1707  foreach (int playerID : aPlayerIDs)
1708  {
1709  RegisterPlayer(playerID, null);
1710  }
1711 
1713  if (!gameMode)
1714  return;
1715 
1716  gameMode.GetOnPlayerSpawned().Insert(RegisterPlayer);
1717  gameMode.GetOnPlayerDisconnected().Insert(OnDisconnected);
1718  }
1719 }
1720 
1722 class SCR_ScenarioFrameworkActionAddItemToInventory : SCR_ScenarioFrameworkActionBase
1723 {
1724  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
1725  ref SCR_ScenarioFrameworkGet m_Getter;
1726 
1727  [Attribute(desc: "Which Prefabs and how many out of each will be added to the inventory of target entity")]
1728  ref array<ref SCR_ScenarioFrameworkPrefabFilterCountNoInheritance> m_aPrefabFilter
1729 
1730  //------------------------------------------------------------------------------------------------
1731  override void OnActivate(IEntity object)
1732  {
1733  if (!CanActivate())
1734  return;
1735 
1736  IEntity entity;
1737  if (!ValidateInputEntity(object, m_Getter, entity))
1738  return;
1739 
1741  if (!inventoryComponent)
1742  {
1743  if (object)
1744  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
1745  else
1746  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1.", this), LogLevel.ERROR);
1747 
1748  return;
1749  }
1750 
1751  EntitySpawnParams spawnParams = new EntitySpawnParams();
1752  entity.GetWorldTransform(spawnParams.Transform);
1753  spawnParams.TransformMode = ETransformMode.WORLD;
1754  //--- Apply rotation
1755  vector angles = Math3D.MatrixToAngles(spawnParams.Transform);
1756  Math3D.AnglesToMatrix(angles, spawnParams.Transform);
1757 
1758  foreach (SCR_ScenarioFrameworkPrefabFilterCountNoInheritance prefabFilter : m_aPrefabFilter)
1759  {
1760  for (int i = 0; i < prefabFilter.m_iPrefabCount; i++)
1761  {
1762  Resource resource = Resource.Load(prefabFilter.m_sPrefabName);
1763  if (!resource)
1764  continue;
1765 
1766  IEntity item = GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
1767  if (!item)
1768  continue;
1769 
1770  SCR_InvCallBackCheck pInvCallback = new SCR_InvCallBackCheck();
1771  pInvCallback.m_sNameMaster = entity.GetName();
1772  pInvCallback.m_sNameItem = item.GetName();
1773 
1774  inventoryComponent.TryInsertItem(item, EStoragePurpose.PURPOSE_ANY, pInvCallback)
1775  }
1776  }
1777  }
1778 }
1779 
1781 class SCR_ScenarioFrameworkActionRemoveItemFromInventory : SCR_ScenarioFrameworkActionBase
1782 {
1783  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
1784  ref SCR_ScenarioFrameworkGet m_Getter;
1785 
1786  [Attribute(desc: "Which Prefabs and how many out of each will be added to the inventory of target entity")]
1787  ref array<ref SCR_ScenarioFrameworkPrefabFilterCount> m_aPrefabFilter;
1788 
1789  //------------------------------------------------------------------------------------------------
1790  override void OnActivate(IEntity object)
1791  {
1792  //Due to how invokers are setup, deletion is sometimes triggered before said item is actually in said inventory
1793  GetGame().GetCallqueue().CallLater(OnActivateCalledLater, 1000, false, object);
1794  }
1795 
1796  //------------------------------------------------------------------------------------------------
1798  void OnActivateCalledLater(IEntity object)
1799  {
1800  if (!CanActivate())
1801  return;
1802 
1803  IEntity entity;
1804  if (!ValidateInputEntity(object, m_Getter, entity))
1805  return;
1806 
1808  if (!inventoryComponent)
1809  {
1810  if (object)
1811  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
1812  else
1813  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1.", this), LogLevel.ERROR);
1814 
1815  return;
1816  }
1817 
1818  array<IEntity> items = {};
1819  inventoryComponent.GetItems(items);
1820  if (items.IsEmpty())
1821  return;
1822 
1823  Resource resource;
1824  BaseContainer prefabContainer;
1825  array<IEntity> itemsToRemove = {};
1827  {
1828  resource = Resource.Load(prefabFilter.m_sSpecificPrefabName);
1829  if (!resource.IsValid())
1830  continue;
1831 
1832  prefabContainer = resource.GetResource().ToBaseContainer();
1833  if (!prefabContainer)
1834  continue;
1835 
1836  int count;
1837  int targetCount = prefabFilter.m_iPrefabCount;
1838 
1839  bool includeInheritance = prefabFilter.m_bIncludeChildren;
1840 
1841  foreach (IEntity item : items)
1842  {
1843  if (!item)
1844  continue;
1845 
1846  EntityPrefabData prefabData = item.GetPrefabData();
1847  if (!prefabData)
1848  continue;
1849 
1850  BaseContainer container = prefabData.GetPrefab();
1851  if (!container)
1852  continue;
1853 
1854  if (!includeInheritance)
1855  {
1856  if (container != prefabContainer)
1857  continue;
1858 
1859  itemsToRemove.Insert(item);
1860  count++;
1861  if (count == targetCount)
1862  break;
1863  }
1864  else
1865  {
1866  while (container)
1867  {
1868  if (container == prefabContainer)
1869  {
1870  itemsToRemove.Insert(item);
1871  count++;
1872  break;
1873  }
1874 
1875  container = container.GetAncestor();
1876  }
1877  }
1878 
1879  if (count == targetCount)
1880  break;
1881  }
1882 
1883  for (int i = itemsToRemove.Count() - 1; i >= 0; i--)
1884  {
1885  inventoryComponent.TryDeleteItem(itemsToRemove[i]);
1886  }
1887  }
1888  }
1889 }
1890 
1892 class SCR_ScenarioFrameworkActionCountInventoryItemsAndExecuteAction : SCR_ScenarioFrameworkActionBase
1893 {
1894  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
1895  ref SCR_ScenarioFrameworkGet m_Getter;
1896 
1897  [Attribute(desc: "Which Prefabs and how many out of each will be added to the inventory of target entity")]
1898  ref array<ref SCR_ScenarioFrameworkPrefabFilterCount> m_aPrefabFilter;
1899 
1900  [Attribute(UIWidgets.Auto, desc: "If conditions from Prefab Filter are true, it will execute these actions")]
1901  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsToExecute;
1902 
1903  //------------------------------------------------------------------------------------------------
1904  override void OnActivate(IEntity object)
1905  {
1906  if (!CanActivate())
1907  return;
1908 
1909  IEntity entity;
1910  if (!ValidateInputEntity(object, m_Getter, entity))
1911  return;
1912 
1914  if (!inventoryComponent)
1915  {
1916  if (object)
1917  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
1918  else
1919  Print(string.Format("ScenarioFramework Action: Inventory Component not found for Action %1.", this), LogLevel.ERROR);
1920 
1921  return;
1922  }
1923 
1924  array<IEntity> items = {};
1925  inventoryComponent.GetItems(items);
1926  if (items.IsEmpty())
1927  return;
1928 
1929  bool countCondition;
1930  Resource resource;
1931  BaseContainer prefabContainer;
1933  {
1934  resource = Resource.Load(prefabFilter.m_sSpecificPrefabName);
1935  if (!resource.IsValid())
1936  continue;
1937 
1938  prefabContainer = resource.GetResource().ToBaseContainer();
1939  if (!prefabContainer)
1940  continue;
1941 
1942  int count;
1943  int targetCount = prefabFilter.m_iPrefabCount;
1944  bool includeInheritance = prefabFilter.m_bIncludeChildren;
1945  countCondition = false;
1946 
1947  foreach (IEntity item : items)
1948  {
1949  if (!item)
1950  continue;
1951 
1952  EntityPrefabData prefabData = item.GetPrefabData();
1953  if (!prefabData)
1954  continue;
1955 
1956  BaseContainer container = prefabData.GetPrefab();
1957  if (!container)
1958  continue;
1959 
1960  if (!includeInheritance)
1961  {
1962  if (container != prefabContainer)
1963  continue;
1964 
1965  count++;
1966  if (count == targetCount)
1967  {
1968  countCondition = true;
1969  break;
1970  }
1971  }
1972  else
1973  {
1974  while (container)
1975  {
1976  if (container == prefabContainer)
1977  {
1978  count++;
1979  break;
1980  }
1981 
1982  container = container.GetAncestor();
1983  }
1984  }
1985 
1986  if (count == targetCount)
1987  {
1988  countCondition = true;
1989  break;
1990  }
1991  }
1992 
1993  //If just one prefab filter is false, we don't count any further and return
1994  if (!countCondition)
1995  return;
1996  }
1997 
1998  if (countCondition)
1999  {
2000  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsToExecute)
2001  {
2002  action.OnActivate(object);
2003  }
2004  }
2005  }
2006 }
2007 
2009 class SCR_ScenarioFrameworkActionLockOrUnlockAllTargetVehiclesInTrigger : SCR_ScenarioFrameworkActionBase
2010 {
2011  [Attribute(desc: "Slot which spawns the trigger")]
2012  ref SCR_ScenarioFrameworkGet m_Getter;
2013 
2014  [Attribute(defvalue: "true", desc: "If set to true, it will lock all vehicles, if set to false it will unlock all vehicles")]
2015  bool m_bLock;
2016 
2017  //------------------------------------------------------------------------------------------------
2022  bool CanActivateTriggerVariant(IEntity object, out SCR_CharacterTriggerEntity trigger)
2023  {
2024  trigger = SCR_CharacterTriggerEntity.Cast(object);
2025  if (m_iMaxNumberOfActivations != -1 && m_iNumberOfActivations >= m_iMaxNumberOfActivations)
2026  {
2027  if (trigger)
2028  {
2029  trigger.GetOnActivate().Remove(OnActivate);
2030  trigger.GetOnDeactivate().Remove(OnActivate);
2031  }
2032 
2033  return false;
2034  }
2035 
2036  m_iNumberOfActivations++;
2037  return true;
2038  }
2039 
2040  //------------------------------------------------------------------------------------------------
2043  void LockOrUnlockAllVehicles(SCR_CharacterTriggerEntity trigger = null)
2044  {
2045  if (!trigger)
2046  return;
2047 
2048  array<IEntity> entitesInside = {};
2049  trigger.GetEntitiesInside(entitesInside);
2050  if (entitesInside.IsEmpty())
2051  return;
2052 
2053  foreach (IEntity entity : entitesInside)
2054  {
2055  if (!Vehicle.Cast(entity))
2056  continue;
2057 
2058  SCR_VehicleSpawnProtectionComponent spawnProtectionComponent = SCR_VehicleSpawnProtectionComponent.Cast(entity.FindComponent(SCR_VehicleSpawnProtectionComponent));
2059  if (m_bLock)
2060  {
2061  spawnProtectionComponent.SetProtectOnlyDriverSeat(false);
2062  spawnProtectionComponent.SetReasonText("#AR-Campaign_Action_BuildBlocked-UC");
2063  spawnProtectionComponent.SetVehicleOwner(-2);
2064  }
2065  else
2066  {
2067  spawnProtectionComponent.SetProtectOnlyDriverSeat(true);
2068  spawnProtectionComponent.SetReasonText("#AR-Campaign_Action_CannotEnterVehicle-UC");
2069  spawnProtectionComponent.ReleaseProtection();
2070  }
2071  }
2072  }
2073 
2074  //------------------------------------------------------------------------------------------------
2075  override void OnActivate(IEntity object)
2076  {
2078  if (!CanActivateTriggerVariant(object, trigger))
2079  return;
2080 
2081  if (trigger)
2082  {
2083  LockOrUnlockAllVehicles(trigger);
2084  return;
2085  }
2086 
2087  if (!m_Getter)
2088  {
2089  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2090  return;
2091  }
2092 
2093  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2094  if (!entityWrapper)
2095  {
2096  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2097  return;
2098  }
2099 
2100  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2101  if (!entityFrom)
2102  {
2103  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2104  return;
2105  }
2106 
2107  trigger = SCR_CharacterTriggerEntity.Cast(entityFrom);
2108  if (trigger)
2109  {
2110  LockOrUnlockAllVehicles(trigger);
2111  return;
2112  }
2113  }
2114 }
2115 
2117 class SCR_ScenarioFrameworkActionLockOrUnlockVehicle : SCR_ScenarioFrameworkActionBase
2118 {
2119  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
2120  ref SCR_ScenarioFrameworkGet m_Getter;
2121 
2122  [Attribute(defvalue: "true", desc: "If set to true, it will lock the vehicle, if set to false it will unlock the vehicle")]
2123  bool m_bLock;
2124 
2125  //------------------------------------------------------------------------------------------------
2126  override void OnActivate(IEntity object)
2127  {
2128  if (!CanActivate())
2129  return;
2130 
2131  IEntity entity;
2132  if (!ValidateInputEntity(object, m_Getter, entity))
2133  return;
2134 
2135  if (!Vehicle.Cast(entity))
2136  return;
2137 
2138  SCR_VehicleSpawnProtectionComponent spawnProtectionComponent = SCR_VehicleSpawnProtectionComponent.Cast(entity.FindComponent(SCR_VehicleSpawnProtectionComponent));
2139  if (!spawnProtectionComponent)
2140  {
2141  if (object)
2142  Print(string.Format("ScenarioFramework Action: Spawn Protection Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2143  else
2144  Print(string.Format("ScenarioFramework Action: Spawn Protection Component Component not found for Action %1.", this), LogLevel.ERROR);
2145 
2146  return;
2147  }
2148 
2149  if (m_bLock)
2150  {
2151  spawnProtectionComponent.SetProtectOnlyDriverSeat(false);
2152  spawnProtectionComponent.SetReasonText("#AR-Campaign_Action_BuildBlocked-UC");
2153  spawnProtectionComponent.SetVehicleOwner(-2);
2154  }
2155  else
2156  {
2157  spawnProtectionComponent.SetProtectOnlyDriverSeat(true);
2158  spawnProtectionComponent.SetReasonText("#AR-Campaign_Action_CannotEnterVehicle-UC");
2159  spawnProtectionComponent.ReleaseProtection();
2160  }
2161  }
2162 }
2163 
2165 class SCR_ScenarioFrameworkActionFailTaskIfVehiclesInTriggerDestroyed : SCR_ScenarioFrameworkActionBase
2166 {
2167  [Attribute(desc: "Trigger Getter")]
2168  ref SCR_ScenarioFrameworkGet m_Getter;
2169 
2170  [Attribute(desc: "Target Layer Task. If this is attached to the Layer Task you intend to work with, you can leave it empty")]
2171  string m_sTargetLayerTask;
2172 
2173  [Attribute(defvalue: "false", desc: "If set to true, it will fail the task only when player caused the destruction")]
2174  bool m_bCausedByPlayer;
2175 
2176  bool m_bAlreadyDestroyed;
2178  ref array<IEntity> m_aTargetEntities = {};
2179 
2180  //------------------------------------------------------------------------------------------------
2185  bool CanActivateTriggerVariant(IEntity object, out SCR_CharacterTriggerEntity trigger)
2186  {
2187  trigger = SCR_CharacterTriggerEntity.Cast(object);
2188  if (m_iMaxNumberOfActivations != -1 && m_iNumberOfActivations >= m_iMaxNumberOfActivations)
2189  {
2190  if (trigger)
2191  {
2192  trigger.GetOnActivate().Remove(OnActivate);
2193  trigger.GetOnDeactivate().Remove(OnActivate);
2194  }
2195 
2196  return false;
2197  }
2198 
2199  m_iNumberOfActivations++;
2200  return true;
2201  }
2202 
2203  //------------------------------------------------------------------------------------------------
2207  void AddListener(IEntity object = null, SCR_CharacterTriggerEntity trigger = null)
2208  {
2209  if (!object)
2210  return;
2211 
2212  if (!trigger)
2213  return;
2214 
2215  SCR_ScenarioFrameworkLayerTask layerTask = SCR_ScenarioFrameworkLayerTask.Cast(object.FindComponent(SCR_ScenarioFrameworkLayerTask));
2216  if (!layerTask)
2217  return;
2218 
2219  m_Task = layerTask.GetTask();
2220  if (!m_Task)
2221  return;
2222 
2223  array<IEntity> entitesInside = {};
2224  trigger.GetEntitiesInside(entitesInside);
2225  if (entitesInside.IsEmpty())
2226  return;
2227 
2228  foreach (IEntity entity : entitesInside)
2229  {
2230  if (!Vehicle.Cast(entity))
2231  continue;
2232 
2233  SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(entity.FindComponent(SCR_DamageManagerComponent));
2234  if (objectDmgManager)
2235  {
2236  m_aTargetEntities.Insert(entity);
2237  objectDmgManager.GetOnDamageStateChanged().Insert(OnObjectDamage);
2238  }
2239  }
2240  }
2241 
2242  //------------------------------------------------------------------------------------------------
2244  void OnObjectDamage(EDamageState state)
2245  {
2246  if (state != EDamageState.DESTROYED || m_bAlreadyDestroyed)
2247  return;
2248 
2249  if (m_bCausedByPlayer)
2250  {
2251  bool destroyedByPlayer;
2252  foreach (IEntity entity : m_aTargetEntities)
2253  {
2254  SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(entity.FindComponent(SCR_DamageManagerComponent));
2255  if (!objectDmgManager)
2256  continue;
2257 
2258  if (objectDmgManager.GetState() == EDamageState.DESTROYED)
2259  {
2260 
2261  Instigator instigator = objectDmgManager.GetInstigator();
2262  if (!instigator)
2263  continue;
2264 
2265  InstigatorType instigatorType = instigator.GetInstigatorType();
2266  if (instigatorType && instigatorType == InstigatorType.INSTIGATOR_PLAYER)
2267  {
2268  destroyedByPlayer = true;
2269  break;
2270  }
2271  }
2272  }
2273 
2274  if (!destroyedByPlayer)
2275  return;
2276  }
2277 
2279  if (!supportEntity)
2280  return;
2281 
2282  m_bAlreadyDestroyed = true;
2283  if (m_Task)
2284  supportEntity.FailTask(m_Task);
2285  }
2286 
2287  //------------------------------------------------------------------------------------------------
2288  override void OnActivate(IEntity object)
2289  {
2290  if (!m_sTargetLayerTask.IsEmpty())
2291  {
2292  IEntity entity = GetGame().GetWorld().FindEntityByName(m_sTargetLayerTask);
2293  if (entity)
2294  object = entity;
2295  }
2296 
2298  if (!CanActivateTriggerVariant(object, trigger))
2299  return;
2300 
2301  if (trigger)
2302  {
2303  AddListener(object, trigger);
2304  return;
2305  }
2306 
2307  if (!m_Getter)
2308  {
2309  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2310  return;
2311  }
2312 
2313  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2314  if (!entityWrapper)
2315  {
2316  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2317  return;
2318  }
2319 
2320  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2321  if (!entityFrom)
2322  {
2323  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2324  return;
2325 
2326  }
2327 
2328  trigger = SCR_CharacterTriggerEntity.Cast(entityFrom);
2329  if (trigger)
2330  AddListener(object, trigger);
2331  }
2332 }
2333 
2335 class SCR_ScenarioFrameworkActionOnCompartmentEnteredOrLeft : SCR_ScenarioFrameworkActionBase
2336 {
2337  [Attribute(defvalue: "1", UIWidgets.CheckBox, desc: "If true, we execute actions On Compartmented Entered. Otherwise On Compartment Left")]
2338  bool m_bEnteredOrLeft;
2339 
2340  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
2341  ref SCR_ScenarioFrameworkGet m_Getter;
2342 
2343  [Attribute(desc: "(Optional) If used, it will get executed only when specific entity enters the compartment")]
2344  ref SCR_ScenarioFrameworkGet m_OccupantGetter;
2345 
2346  [Attribute(desc: "(Optional) If used, it will get executed only when specific compartment slots are entered")]
2347  ref array<int> m_aSlotIDs;
2348 
2349  [Attribute(desc: "Actions that will be executed on compartment entered", UIWidgets.Auto)]
2350  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
2351 
2352  IEntity m_OccupantEntity;
2353 
2354  //------------------------------------------------------------------------------------------------
2360  void OnCompartmentEnteredOrLeft(IEntity vehicle, BaseCompartmentManagerComponent mgr, IEntity occupant, int managerId, int slotID)
2361  {
2362  if (m_OccupantEntity && occupant != m_OccupantEntity)
2363  return;
2364 
2365  if (m_aSlotIDs && !m_aSlotIDs.IsEmpty() && !m_aSlotIDs.Contains(slotID))
2366  return;
2367 
2368  foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
2369  {
2370  actions.OnActivate(m_Entity);
2371  }
2372  }
2373 
2374  //------------------------------------------------------------------------------------------------
2375  override void OnActivate(IEntity object)
2376  {
2377  if (!CanActivate())
2378  return;
2379 
2380  IEntity entity;
2381  if (!ValidateInputEntity(object, m_Getter, entity))
2382  return;
2383 
2384  if (m_OccupantGetter)
2385  {
2386  SCR_ScenarioFrameworkParam<IEntity> occupantWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_OccupantGetter.Get());
2387  if (!occupantWrapper)
2388  return;
2389 
2390  m_OccupantEntity = IEntity.Cast(occupantWrapper.GetValue());
2391  if (!m_OccupantEntity)
2392  return;
2393  }
2394 
2395  if (Vehicle.Cast(entity))
2396  {
2397  EventHandlerManagerComponent ehManager = EventHandlerManagerComponent.Cast(entity.FindComponent(EventHandlerManagerComponent));
2398  if (!ehManager)
2399  {
2400  if (object)
2401  Print(string.Format("ScenarioFramework Action: Event Handler Manager Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2402  else
2403  Print(string.Format("ScenarioFramework Action: Event Handler Manager Component not found for Action %1.", this), LogLevel.ERROR);
2404 
2405  return;
2406  }
2407 
2408  if (m_bEnteredOrLeft)
2409  ehManager.RegisterScriptHandler("OnCompartmentEntered", this, OnCompartmentEnteredOrLeft, true, false);
2410  else
2411  ehManager.RegisterScriptHandler("OnCompartmentLeft", this, OnCompartmentEnteredOrLeft, true, false);
2412  }
2413  }
2414 }
2415 
2417 class SCR_ScenarioFrameworkActionOnEngineStartedOrStop : SCR_ScenarioFrameworkActionBase
2418 {
2419  [Attribute(defvalue: "1", UIWidgets.CheckBox, desc: "If true, we execute actions On Engine Started. Otherwise On Engine Stop")]
2420  bool m_bStartedOrStop;
2421 
2422  [Attribute(desc: "Target entity (Optional if action is attached on Slot that spawns target entity)")]
2423  ref SCR_ScenarioFrameworkGet m_Getter;
2424 
2425  [Attribute(desc: "Actions that will be executed on one of these circumstances", UIWidgets.Auto)]
2426  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
2427 
2428  //------------------------------------------------------------------------------------------------
2429  void OnEngineStartedOrStop()
2430  {
2431  foreach (SCR_ScenarioFrameworkActionBase actions : m_aActions)
2432  {
2433  actions.OnActivate(m_Entity);
2434  }
2435  }
2436 
2437  //------------------------------------------------------------------------------------------------
2438  override void OnActivate(IEntity object)
2439  {
2440  if (!CanActivate())
2441  return;
2442 
2443  IEntity entity;
2444  if (!ValidateInputEntity(object, m_Getter, entity))
2445  return;
2446 
2447  VehicleControllerComponent_SA vehicleController = VehicleControllerComponent_SA.Cast(entity.FindComponent(VehicleControllerComponent_SA));
2448  if (!vehicleController)
2449  {
2450  if (object)
2451  Print(string.Format("ScenarioFramework Action: Vehicle Controller Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2452  else
2453  Print(string.Format("ScenarioFramework Action: Vehicle Controller Component not found for Action %1.", this), LogLevel.ERROR);
2454 
2455  return;
2456  }
2457 
2458  if (m_bStartedOrStop)
2459  vehicleController.GetOnEngineStart().Insert(OnEngineStartedOrStop);
2460  else
2461  vehicleController.GetOnEngineStop().Insert(OnEngineStartedOrStop);
2462  }
2463 }
2464 
2466 class SCR_ScenarioFrameworkActionToggleLights : SCR_ScenarioFrameworkActionBase
2467 {
2468  [Attribute(desc: "Target entity to manipulate lights with (Optional if action is attached on Slot that spawns target entity)")]
2469  ref SCR_ScenarioFrameworkGet m_Getter;
2470 
2471  [Attribute(defvalue: ELightType.Head.ToString(), UIWidgets.ComboBox, desc: "Which lights to be toggled", "", ParamEnumArray.FromEnum(ELightType))]
2472  ELightType m_eLightType;
2473 
2474  [Attribute(defvalue: "1", desc: "If true, light will be turned on. Otherwise it will turn it off.")]
2475  bool m_bTurnedOn;
2476 
2477  //------------------------------------------------------------------------------------------------
2478  override void OnActivate(IEntity object)
2479  {
2480  if (!CanActivate())
2481  return;
2482 
2483  IEntity entity;
2484  if (!ValidateInputEntity(object, m_Getter, entity))
2485  return;
2486 
2487  BaseLightManagerComponent lightManager = BaseLightManagerComponent.Cast(entity.FindComponent(BaseLightManagerComponent));
2488  if (!lightManager)
2489  {
2490  if (object)
2491  Print(string.Format("ScenarioFramework Action: Light Manager Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2492  else
2493  Print(string.Format("ScenarioFramework Action: Light Manager Component not found for Action %1.", this), LogLevel.ERROR);
2494 
2495  return;
2496  }
2497 
2498  lightManager.SetLightsState(m_eLightType, m_bTurnedOn);
2499  }
2500 }
2501 
2503 class SCR_ScenarioFrameworkActionToggleEngine : SCR_ScenarioFrameworkActionBase
2504 {
2505  [Attribute(desc: "Target entity to turn on/off the engine (Optional if action is attached on Slot that spawns target entity")]
2506  ref SCR_ScenarioFrameworkGet m_Getter;
2507 
2508  [Attribute(defvalue: "1", desc: "If true, engine will be turned on. Otherwise it will turn it off.")]
2509  bool m_bTurnedOn;
2510 
2511  //------------------------------------------------------------------------------------------------
2512  override void OnActivate(IEntity object)
2513  {
2514  if (!CanActivate())
2515  return;
2516 
2517  IEntity entity;
2518  if (!ValidateInputEntity(object, m_Getter, entity))
2519  return;
2520 
2521  VehicleWheeledSimulation_SA vehicleSimulation = VehicleWheeledSimulation_SA.Cast(entity.FindComponent(VehicleWheeledSimulation_SA));
2522  if (!vehicleSimulation)
2523  {
2524  if (object)
2525  Print(string.Format("ScenarioFramework Action: Vehicle Wheeled Simulation Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2526  else
2527  Print(string.Format("ScenarioFramework Action: Vehicle Wheeled Simulation Component not found for Action %1.", this), LogLevel.ERROR);
2528 
2529  return;
2530  }
2531 
2532  if (m_bTurnedOn)
2533  vehicleSimulation.EngineStart();
2534  else
2535  vehicleSimulation.EngineStop();
2536  }
2537 }
2538 
2540 class SCR_ScenarioFrameworkActionDamageWheel : SCR_ScenarioFrameworkActionBase
2541 {
2542  [Attribute(desc: "Target entity to manipulate fuel (Optional if action is attached on Slot that spawns target entity")]
2543  ref SCR_ScenarioFrameworkGet m_Getter;
2544 
2545  [Attribute(defvalue: "", desc: "Name of Slots that are defined on the SlotManagerComponent on target vehicle")]
2546  ref array<string> m_aSlotNamesOnSlotManager;
2547 
2548  [Attribute(defvalue: "100", desc: "Health Percentage to be set for target wheels", UIWidgets.Graph, "0 100 1")]
2549  int m_iHealthPercentage;
2550 
2551  //------------------------------------------------------------------------------------------------
2552  override void OnActivate(IEntity object)
2553  {
2554  if (!CanActivate())
2555  return;
2556 
2557  IEntity entity;
2558  if (!ValidateInputEntity(object, m_Getter, entity))
2559  return;
2560 
2561  SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
2562  if (!slotManager)
2563  {
2564  if (object)
2565  Print(string.Format("ScenarioFramework Action: Slot Manager Component not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2566  else
2567  Print(string.Format("ScenarioFramework Action: Slot Manager Component not found for Action %1.", this), LogLevel.ERROR);
2568 
2569  return;
2570  }
2571 
2572  foreach (string slotName : m_aSlotNamesOnSlotManager)
2573  {
2574  EntitySlotInfo slotInfo = slotManager.GetSlotByName(slotName);
2575  if (!slotInfo)
2576  {
2577  if (object)
2578  Print(string.Format("ScenarioFramework Action: Name of the slot %1 not found on target entity for Action %2 attached on %3.", slotName, this, object.GetName()), LogLevel.ERROR);
2579  else
2580  Print(string.Format("ScenarioFramework Action: Name of the slot %1 not found on target entity for Action %1.", slotName, this), LogLevel.ERROR);
2581 
2582  return;
2583  }
2584 
2585  IEntity wheelEntity = slotInfo.GetAttachedEntity();
2586  if (!wheelEntity)
2587  {
2588  if (object)
2589  Print(string.Format("ScenarioFramework Action: Retrieving target wheel entity failed for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2590  else
2591  Print(string.Format("ScenarioFramework Action: Retrieving target wheel entity failed for Action %1.", this), LogLevel.ERROR);
2592 
2593  return;
2594  }
2595 
2596  SCR_DamageManagerComponent damageManager = SCR_DamageManagerComponent.GetDamageManager(wheelEntity);
2597  if (!damageManager)
2598  {
2599  if (object)
2600  Print(string.Format("ScenarioFramework Action: Retrieving Damage Manager of target entity failed for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2601  else
2602  Print(string.Format("ScenarioFramework Action: Retrieving Damage Manager of target entity failed for Action %1.", this), LogLevel.ERROR);
2603 
2604  return;
2605  }
2606 
2607  damageManager.SetHealthScaled(m_iHealthPercentage * 0.01);
2608  }
2609  }
2610 }
2611 
2613 class SCR_ScenarioFrameworkActionSetFuelPercentage : SCR_ScenarioFrameworkActionBase
2614 {
2615  [Attribute(desc: "Target entity to manipulate fuel (Optional if action is attached on Slot that spawns target entity")]
2616  ref SCR_ScenarioFrameworkGet m_Getter;
2617 
2618  [Attribute(defvalue: "75", desc: "Percentage of a fuel to be set.", UIWidgets.Graph, "0 100 1")]
2619  int m_iFuelPercentage;
2620 
2621  //------------------------------------------------------------------------------------------------
2622  override void OnActivate(IEntity object)
2623  {
2624  if (!CanActivate())
2625  return;
2626 
2627  IEntity entity;
2628  if (!ValidateInputEntity(object, m_Getter, entity))
2629  return;
2630 
2631  array<SCR_FuelManagerComponent> fuelManagers = {};
2632  SCR_FuelManagerComponent.GetAllFuelManagers(entity, fuelManagers);
2633  if (fuelManagers.IsEmpty())
2634  {
2635  if (object)
2636  Print(string.Format("ScenarioFramework Action: No Fuel Managers found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
2637  else
2638  Print(string.Format("ScenarioFramework Action: No Fuel Managers found for Action %1.", this), LogLevel.ERROR);
2639 
2640  return;
2641  }
2642 
2643  SCR_FuelManagerComponent.SetTotalFuelPercentageOfFuelManagers(fuelManagers, m_iFuelPercentage * 0.01, 0, SCR_EFuelNodeTypeFlag.IS_FUEL_STORAGE);
2644  }
2645 }
2646 
2648 class SCR_ScenarioFrameworkActionChangeTriggerActivationPresence : SCR_ScenarioFrameworkActionBase
2649 {
2650  [Attribute(desc: "Closest to what - use getter")]
2651  ref SCR_ScenarioFrameworkGet m_Getter;
2652 
2653  [Attribute("0", UIWidgets.ComboBox, "By whom the trigger is activated", "", ParamEnumArray.FromEnum(TA_EActivationPresence), category: "Trigger")]
2654  TA_EActivationPresence m_eActivationPresence;
2655 
2656  //------------------------------------------------------------------------------------------------
2661  bool CanActivateTriggerVariant(IEntity object, out SCR_CharacterTriggerEntity trigger)
2662  {
2663  trigger = SCR_CharacterTriggerEntity.Cast(object);
2664  if (m_iMaxNumberOfActivations != -1 && m_iNumberOfActivations >= m_iMaxNumberOfActivations)
2665  {
2666  if (trigger)
2667  {
2668  trigger.GetOnActivate().Remove(OnActivate);
2669  trigger.GetOnDeactivate().Remove(OnActivate);
2670  }
2671 
2672  return false;
2673  }
2674 
2675  m_iNumberOfActivations++;
2676  return true;
2677  }
2678 
2679  //------------------------------------------------------------------------------------------------
2680  override void OnActivate(IEntity object)
2681  {
2683  if (!CanActivateTriggerVariant(object, trigger))
2684  return;
2685 
2686  if (trigger)
2687  {
2688  trigger.SetActivationPresence(m_eActivationPresence);
2689  return;
2690  }
2691 
2692  if (!m_Getter)
2693  {
2694  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2695  return;
2696  }
2697 
2698  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2699  if (!entityWrapper)
2700  {
2701  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2702  return;
2703  }
2704 
2705  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2706  if (!entityFrom)
2707  {
2708  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2709  return;
2710  }
2711 
2713  if (!layer)
2714  {
2715  Print(string.Format("ScenarioFramework Action: Entity is not Layer Base for Action %1.", this), LogLevel.ERROR);
2716  return;
2717  }
2718 
2720  if (area)
2721  {
2722  trigger = SCR_CharacterTriggerEntity.Cast(area.GetTrigger());
2723  }
2724  else
2725  {
2726  IEntity entity = layer.GetSpawnedEntity();
2727  if (!BaseGameTriggerEntity.Cast(entity))
2728  {
2729  Print(string.Format("ScenarioFramework Action: SlotTrigger - The selected prefab is not trigger!"), LogLevel.ERROR);
2730  return;
2731  }
2732  trigger = SCR_CharacterTriggerEntity.Cast(entity);
2733  }
2734 
2735  trigger.SetActivationPresence(m_eActivationPresence);
2736  }
2737 }
2738 
2740 class SCR_ScenarioFrameworkActionChangeLayerActivationType : SCR_ScenarioFrameworkActionBase
2741 {
2742  [Attribute(desc: "Closest to what - use getter")]
2743  ref SCR_ScenarioFrameworkGet m_Getter;
2744 
2745  [Attribute("0", uiwidget: UIWidgets.ComboBox, "", "", ParamEnumArray.FromEnum(SCR_ScenarioFrameworkEActivationType), category: "Activation")]
2746  SCR_ScenarioFrameworkEActivationType m_eActivationType;
2747 
2748  //------------------------------------------------------------------------------------------------
2749  override void OnActivate(IEntity object)
2750  {
2751  if (!CanActivate())
2752  return;
2753 
2754  if (!m_Getter)
2755  {
2756  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2757  return;
2758  }
2759 
2760  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2761  if (!entityWrapper)
2762  {
2763  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2764  return;
2765  }
2766 
2767  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2768  if (!entityFrom)
2769  {
2770  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2771  return;
2772  }
2773 
2775  if (!layer)
2776  {
2777  Print(string.Format("ScenarioFramework Action: Entity is not Layer Base for Action %1.", this), LogLevel.ERROR);
2778  return;
2779  }
2780 
2781  layer.SetActivationType(m_eActivationType);
2782  }
2783 }
2784 
2786 class SCR_ScenarioFrameworkActionRestoreLayerToDefault : SCR_ScenarioFrameworkActionBase
2787 {
2788  [Attribute(desc: "Layer to be restored to default (Optional if action is attached on layer that is supposed to be restored to default)")]
2789  ref SCR_ScenarioFrameworkGet m_Getter;
2790 
2791  [Attribute(defvalue: "true", desc: "If checked, it will also restore child layers to default state as well.")]
2792  bool m_bIncludeChildren;
2793 
2794  [Attribute(desc: "If checked, it will reinit the layer after the restoration")]
2795  bool m_bReinitAfterRestoration;
2796 
2797  //------------------------------------------------------------------------------------------------
2798  override void OnActivate(IEntity object)
2799  {
2800  if (!CanActivate())
2801  return;
2802 
2803  IEntity entity;
2804  if (!ValidateInputEntity(object, m_Getter, entity))
2805  return;
2806 
2808  if (!layer)
2809  {
2810  Print(string.Format("ScenarioFramework Action: Entity is not Layer Base for Action %1.", this), LogLevel.ERROR);
2811  return;
2812  }
2813 
2814  layer.RestoreToDefault(m_bIncludeChildren, m_bReinitAfterRestoration);
2815  }
2816 }
2817 
2819 class SCR_ScenarioFrameworkActionPrepareAreaFromDynamicDespawn : SCR_ScenarioFrameworkActionBase
2820 {
2821  [Attribute(desc: "Closest to what - use getter")]
2822  ref SCR_ScenarioFrameworkGet m_Getter;
2823 
2824  [Attribute(desc: "If set to false, area will be despawned")]
2825  bool m_bStaySpawned;
2826 
2827  [Attribute(defvalue: "750", desc: "How close at least one observer camera must be in order to trigger dynamic spawn/despawn")]
2828  int m_iDynamicDespawnRange;
2829 
2830  //------------------------------------------------------------------------------------------------
2831  override void OnActivate(IEntity object)
2832  {
2833  if (!CanActivate())
2834  return;
2835 
2836  if (!m_Getter)
2837  {
2838  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2839  return;
2840  }
2841 
2842  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
2843  if (!manager)
2844  return;
2845 
2846  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2847  if (!entityWrapper)
2848  {
2849  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2850  return;
2851  }
2852 
2853  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2854  if (!entityFrom)
2855  {
2856  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2857  return;
2858  }
2859 
2860  SCR_ScenarioFrameworkArea area = SCR_ScenarioFrameworkArea.Cast(entityFrom.FindComponent(SCR_ScenarioFrameworkArea));
2861  if (!area)
2862  {
2863  Print(string.Format("ScenarioFramework Action: Entity is not Area for Action %1.", this), LogLevel.ERROR);
2864  return;
2865  }
2866 
2867  area.SetDynamicDespawnRange(m_iDynamicDespawnRange);
2868  manager.PrepareAreaSpecificDynamicDespawn(area, m_bStaySpawned);
2869  }
2870 }
2871 
2873 class SCR_ScenarioFrameworkActionRemoveAreaFromDynamicDespawn : SCR_ScenarioFrameworkActionBase
2874 {
2875  [Attribute(desc: "Closest to what - use getter")]
2876  ref SCR_ScenarioFrameworkGet m_Getter;
2877 
2878  [Attribute(desc: "If set to false, area will be despawned")]
2879  bool m_bStaySpawned;
2880 
2881  //------------------------------------------------------------------------------------------------
2882  override void OnActivate(IEntity object)
2883  {
2884  if (!CanActivate())
2885  return;
2886 
2887  if (!m_Getter)
2888  {
2889  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
2890  return;
2891  }
2892 
2893  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
2894  if (!manager)
2895  return;
2896 
2897  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
2898  if (!entityWrapper)
2899  {
2900  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
2901  return;
2902  }
2903 
2904  IEntity entityFrom = IEntity.Cast(entityWrapper.GetValue());
2905  if (!entityFrom)
2906  {
2907  Print(string.Format("ScenarioFramework Action: Entity not found for Action %1.", this), LogLevel.ERROR);
2908  return;
2909  }
2910 
2911  SCR_ScenarioFrameworkArea area = SCR_ScenarioFrameworkArea.Cast(entityFrom.FindComponent(SCR_ScenarioFrameworkArea));
2912  if (!area)
2913  {
2914  Print(string.Format("ScenarioFramework Action: Entity is not Area for Action %1.", this), LogLevel.ERROR);
2915  return;
2916  }
2917 
2918  manager.RemoveAreaSpecificDynamicDespawn(area, m_bStaySpawned);
2919  }
2920 }
2921 
2923 class SCR_ScenarioFrameworkActionPlaySound : SCR_ScenarioFrameworkActionBase
2924 {
2925  [Attribute(desc: "Sound to play.")]
2926  string m_sSound;
2927 
2928  //------------------------------------------------------------------------------------------------
2929  override void OnActivate(IEntity object)
2930  {
2931  if (!CanActivate())
2932  return;
2933 
2934  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
2935  if (!manager)
2936  return;
2937 
2938  GetGame().GetCallqueue().CallLater(manager.PlaySoundOnEntity, 2000, false, null, m_sSound);
2939  }
2940 }
2941 
2943 class SCR_ScenarioFrameworkActionPlaySoundOnEntity : SCR_ScenarioFrameworkActionBase
2944 {
2945  [Attribute(desc: "Entity to play the sound on (Optional if action is attached on Slot that spawns target entity")]
2946  ref SCR_ScenarioFrameworkGet m_Getter;
2947 
2948  [Attribute(desc: "Sound to play.")]
2949  string m_sSound;
2950 
2951  //------------------------------------------------------------------------------------------------
2952  override void OnActivate(IEntity object)
2953  {
2954  if (!CanActivate())
2955  return;
2956 
2957  IEntity entity;
2958  if (!ValidateInputEntity(object, m_Getter, entity))
2959  return;
2960 
2961  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
2962  if (!manager)
2963  return;
2964 
2965  GetGame().GetCallqueue().CallLater(manager.PlaySoundOnEntity, 2000, false, entity, m_sSound);
2966  }
2967 }
2968 
2970 class SCR_ScenarioFrameworkActionIntroVoicelineBasedOnTasks : SCR_ScenarioFrameworkActionBase
2971 {
2972  [Attribute(desc: "Sound to play.")]
2973  string m_sSound;
2974 
2975  [Attribute(desc: "(Optional) If getter is provided, sound will come from the provided entity")]
2976  ref SCR_ScenarioFrameworkGet m_Getter;
2977 
2978  ref array<int> m_aAffectedPlayers = {};
2979 
2980  //------------------------------------------------------------------------------------------------
2981  override void OnActivate(IEntity object)
2982  {
2983  if (!CanActivate())
2984  return;
2985 
2986  PlayerManager playerManager = GetGame().GetPlayerManager();
2987  if (!playerManager)
2988  return;
2989 
2990  int playerID = playerManager.GetPlayerIdFromControlledEntity(object);
2991  if (m_aAffectedPlayers.Contains(playerID))
2992  return;
2993 
2994  m_aAffectedPlayers.Insert(playerID);
2995 
2996  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
2997  if (!manager)
2998  return;
2999 
3000  EntityID entityID;
3001  if (m_Getter)
3002  {
3003  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
3004  if (entityWrapper)
3005  {
3006  IEntity entity = IEntity.Cast(entityWrapper.GetValue());
3007  if (entity)
3008  entityID = entity.GetID();
3009  }
3010  }
3011 
3012  manager.PlayIntroVoiceline(playerID, m_sSound, entityID);
3013  }
3014 }
3015 
3017 class SCR_ScenarioFrameworkActionProcessVoicelineEnumAndString : SCR_ScenarioFrameworkActionBase
3018 {
3019  [Attribute(desc: "Name of the enum to work with")]
3020  string m_sTargetEnum;
3021 
3022  //------------------------------------------------------------------------------------------------
3023  override void OnActivate(IEntity object)
3024  {
3025  if (!CanActivate())
3026  return;
3027 
3028  SCR_GameModeSFManager manager = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
3029  if (!manager)
3030  return;
3031 
3032  SCR_BaseTaskManager taskManager = GetTaskManager();
3033  if (!taskManager)
3034  return;
3035 
3036  array<SCR_BaseTask> tasks = {};
3037  taskManager.GetTasks(tasks);
3038 
3039  typename targetEnum = m_sTargetEnum.ToType();
3040  foreach (SCR_BaseTask task : tasks)
3041  {
3042  SCR_ScenarioFrameworkTask frameworkTask = SCR_ScenarioFrameworkTask.Cast(task);
3043  if (frameworkTask)
3044  manager.ProcessVoicelineEnumAndString(targetEnum, frameworkTask.m_sTaskIntroVoiceline)
3045  }
3046  }
3047 }
3048 
3051 class SCR_ScenarioFrameworkActionChangeTaskState : SCR_ScenarioFrameworkActionBase
3052 {
3053  [Attribute(desc: "Which task to work with")]
3054  ref SCR_ScenarioFrameworkGet m_Getter;
3055 
3056  [Attribute("1", UIWidgets.ComboBox, "Task state", "", ParamEnumArray.FromEnum(SCR_TaskState))]
3057  SCR_TaskState m_eTaskState;
3058 
3059  //------------------------------------------------------------------------------------------------
3060  override void OnActivate(IEntity object)
3061  {
3062  if (!CanActivate())
3063  return;
3064 
3065  if (!m_Getter)
3066  {
3067  Print(string.Format("ScenarioFramework Action: Getter not found for Action %1.", this), LogLevel.ERROR);
3068  return;
3069  }
3070 
3071  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_Getter.Get());
3072  if (!entityWrapper)
3073  {
3074  Print(string.Format("ScenarioFramework Action: Issue with Getter detected for Action %1.", this), LogLevel.ERROR);
3075  return;
3076  }
3077 
3078  SCR_ScenarioFrameworkTask task = SCR_ScenarioFrameworkTask.Cast(entityWrapper.GetValue());
3079  if (!task)
3080  {
3081  if (object)
3082  Print(string.Format("ScenarioFramework Action: Task not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
3083  else
3084  Print(string.Format("ScenarioFramework Action: Task not found for Action %1.", this), LogLevel.ERROR);
3085 
3086  return;
3087  }
3088 
3089  SCR_ScenarioFrameworkTaskSupportEntity supportEntity = task.GetSupportEntity();
3090  if (!supportEntity)
3091  {
3092  if (object)
3093  Print(string.Format("ScenarioFramework Action: Task support entity not found for Action %1 attached on %2.", this, object.GetName()), LogLevel.ERROR);
3094  else
3095  Print(string.Format("ScenarioFramework Action: Task not found for Action %1.", this), LogLevel.ERROR);
3096 
3097  return;
3098  }
3099 
3100  //Task system is a mess, so this is why we have to tackle it this abysmal way:
3101  if (m_eTaskState == SCR_TaskState.FINISHED)
3102  supportEntity.FinishTask(task);
3103  else if (m_eTaskState == SCR_TaskState.REMOVED)
3104  supportEntity.FailTask(task);
3105  else if (m_eTaskState == SCR_TaskState.CANCELLED)
3106  supportEntity.CancelTask(task.GetTaskID());
3107  else
3108  task.SetState(m_eTaskState);
3109 
3110  SCR_ScenarioFrameworkLayerTask layerTask = task.GetLayerTask();
3111  if (!layerTask)
3112  return;
3113 
3114  layerTask.SetLayerTaskState(m_eTaskState);
3115  }
3116 }
3117 
3119 class SCR_ScenarioFrameworkActionResetCounter : SCR_ScenarioFrameworkActionBase
3120 {
3121  //------------------------------------------------------------------------------------------------
3122  override void OnActivate(IEntity object)
3123  {
3124  if (!CanActivate())
3125  return;
3126 
3127  if (!object)
3128  {
3129  Print(string.Format("ScenarioFramework Action: Object not found for Action %1.", this), LogLevel.ERROR);
3130  return;
3131  }
3132 
3133  SCR_ScenarioFrameworkLogicCounter counter = SCR_ScenarioFrameworkLogicCounter.Cast(object.FindComponent(SCR_ScenarioFrameworkLogicCounter));
3134  if (!counter)
3135  {
3136  Print(string.Format("ScenarioFramework Action: Counter not found for Action %1.", this), LogLevel.ERROR);
3137  return;
3138  }
3139 
3140  counter.Reset();
3141  }
3142 }
3143 
3145 class SCR_ScenarioFrameworkActionExecuteFunction : SCR_ScenarioFrameworkActionBase
3146 {
3147  [Attribute(desc: "Object the method will be called")]
3148  ref SCR_ScenarioFrameworkGet m_ObjectToCallTheMethodFrom;
3149 
3150  [Attribute(desc: "Method to call")]
3151  string m_sMethodToCall;
3152 
3153  [Attribute(desc: "Parameter1 to pass (string only)")]
3154  string m_sParameter;
3155 
3156  [Attribute(desc: "Parameter2 to pass (string only)")]
3157  string m_sParameter2;
3158 
3159  [Attribute(desc: "Parameter3 to pass (string only)")]
3160  string m_sParameter3;
3161 
3162  [Attribute(desc: "Parameter4 to pass (string only)")]
3163  string m_sParameter4;
3164 
3165  [Attribute(desc: "Parameter5 to pass (string only)")]
3166  string m_sParameter5;
3167 
3168  //------------------------------------------------------------------------------------------------
3169  override void OnActivate(IEntity object)
3170  {
3171  if (!CanActivate())
3172  return;
3173 
3174  SCR_ScenarioFrameworkParam<IEntity> entityWrapper = SCR_ScenarioFrameworkParam<IEntity>.Cast(m_ObjectToCallTheMethodFrom.Get());
3175  if (!entityWrapper)
3176  return;
3177 
3178  SCR_ScenarioFrameworkArea area = SCR_ScenarioFrameworkArea.Cast(entityWrapper.GetValue().FindComponent(SCR_ScenarioFrameworkArea));
3179  SCR_ScenarioFrameworkLayerBase layerBase = SCR_ScenarioFrameworkLayerBase.Cast(entityWrapper.GetValue().FindComponent(SCR_ScenarioFrameworkLayerBase));
3180  SCR_ScenarioFrameworkLayerTask layer = SCR_ScenarioFrameworkLayerTask.Cast(entityWrapper.GetValue().FindComponent(SCR_ScenarioFrameworkLayerTask));
3181  if (layer)
3182  GetGame().GetCallqueue().CallByName(layer, m_sMethodToCall, m_sParameter, m_sParameter2, m_sParameter3, m_sParameter4, m_sParameter5);
3183  else if (layerBase)
3184  GetGame().GetCallqueue().CallByName(layerBase, m_sMethodToCall, m_sParameter, m_sParameter2, m_sParameter3, m_sParameter4, m_sParameter5);
3185  else if (area)
3186  GetGame().GetCallqueue().CallByName(area, m_sMethodToCall, m_sParameter, m_sParameter2, m_sParameter3, m_sParameter4, m_sParameter5);
3187  else
3188  GetGame().GetCallqueue().CallByName(entityWrapper.GetValue(), m_sMethodToCall, m_sParameter, m_sParameter2, m_sParameter3, m_sParameter4, m_sParameter5);
3189  }
3190 }
m_iRandomPercent
protected int m_iRandomPercent
Definition: SCR_ScenarioFrameworkLayerBase.c:28
SCR_JournalSetupConfig
Definition: SCR_JournalConfig.c:12
m_iDelay
protected int m_iDelay
Definition: SCR_MenuActionsComponent.c:11
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_BaseGameOverScreenInfo
Definition: SCR_BaseGameOverScreenInfo.c:2
InstigatorType
InstigatorType
Definition: InstigatorType.c:12
m_eActivationType
protected SCR_ScenarioFrameworkEActivationType m_eActivationType
Definition: SCR_ScenarioFrameworkLayerBase.c:43
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
Init
override void Init(IEntity entity)
Definition: SCR_ScenarioFrameworkActions.c:48
GetName
string GetName()
Definition: SCR_ScenarioFrameworkLayerBase.c:85
SCR_ScenarioFrameworkPrefabFilterCount
Definition: SCR_ScenarioFrameworkPrefabFilter.c:24
m_Task
SCR_EditableTaskComponentClass m_Task
Editable SCR_BaseTask.
InventoryStorageSlot
Definition: InventoryStorageSlot.c:12
m_eGameOverType
EGameOverTypes m_eGameOverType
Definition: SCR_GameModeSFManager.c:63
m_aActions
ref SCR_SortedArray< SCR_BaseEditorAction > m_aActions
Definition: SCR_BaseActionsEditorComponent.c:8
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
m_eActivationPresence
protected TA_EActivationPresence m_eActivationPresence
Definition: SCR_CharacterTriggerEntity.c:20
m_iValue
protected int m_iValue
Definition: SCR_VotingBase.c:3
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
SCR_ScenarioFrameworkActionIncrementCounter
Definition: SCR_ScenarioFrameworkActions.c:175
SCR_StringHelper
Definition: SCR_StringHelper.c:1
SCR_JournalConfig
Definition: SCR_JournalConfig.c:45
EDamageState
EDamageState
Definition: EDamageState.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_Entity
enum EAITargetInfoCategory m_Entity
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
m_sFactionKey
protected FactionKey m_sFactionKey
Definition: SCR_ScenarioFrameworkLayerBase.c:25
SCR_ContainerActionTitle
Definition: SCR_ScenarioFrameworkActions.c:1
Instigator
Definition: Instigator.c:6
EntitySlotInfo
Adds ability to attach an object to a slot.
Definition: EntitySlotInfo.c:8
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
EGameOverTypes
EGameOverTypes
Definition: EGameOverTypes.c:1
ELightType
ELightType
Definition: ELightType.c:7
InventoryStorageManagerComponent
Definition: InventoryStorageManagerComponent.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_ContainerActionTitle
SCR_ContainerActionTitle BaseContainerCustomTitle SCR_ContainerActionTitle()] class SCR_ScenarioFrameworkActionBase
Definition: SCR_ScenarioFrameworkActions.c:43
OnDestroyed
protected void OnDestroyed(IEntity owner)
Definition: SCR_EditableVehicleComponent.c:32
SCR_ScenarioFrameworkArea
Definition: SCR_ScenarioFrameworkArea.c:24
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_ComponentHelper
Definition: SCR_ComponentHelper.c:1
SCR_BaseTaskManager
Definition: SCR_BaseTaskManager.c:25
EntityID
SCR_CompositionSlotManagerComponentClass EntityID
BaseContainerProps
SCR_ContainerActionTitle BaseContainerCustomTitle BaseContainerProps()
SCR_ScenarioFrameworkTaskSupportEntity
Definition: SCR_ScenarioFrameworkTaskSupportEntity.c:8
WeaponUIInfo
Definition: WeaponUIInfo.c:3
SCR_BaseTaskSupportEntity
Definition: SCR_BaseTaskSupportEntity.c:8
InventoryItemComponent
Definition: InventoryItemComponent.c:12
m_bIncludeChildren
bool m_bIncludeChildren
Definition: SCR_ScenarioFrameworkPrefabFilter.c:6
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
SCR_FuelManagerComponent
void SCR_FuelManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_FuelManagerComponent.c:475
SCR_JournalEntry
Definition: SCR_JournalConfig.c:65
SCR_CharacterTriggerEntity
Definition: SCR_CharacterTriggerEntity.c:17
EStoragePurpose
EStoragePurpose
Definition: EStoragePurpose.c:12
SCR_TaskState
SCR_TaskState
Definition: SCR_TaskState.c:2
m_aPrefabFilter
protected ref array< ref SCR_ScenarioFrameworkPrefabFilter > m_aPrefabFilter
Definition: SCR_CharacterTriggerEntity.c:29
SCR_EScenarioFrameworkSpawnChildrenType
SCR_EScenarioFrameworkSpawnChildrenType
Definition: SCR_ScenarioFrameworkLayerBase.c:11
SCR_GameOverScreenConfig
Definition: SCR_GameOverScreenConfig.c:2
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
EntityUtils
Definition: EntityUtils.c:12
m_sCounterName
string m_sCounterName
Definition: SCR_ScenarioFrameworkActions.c:45
SCR_ScenarioFrameworkTask
Definition: SCR_ScenarioFrameworkTask.c:7
SCR_EditableEntityComponentClass
Definition: SCR_EditableEntityComponentClass.c:2
SCR_ScenarioFrameworkGet
Definition: SCR_ScenarioFrameworkActionsGetters.c:26
LocalizedString
Definition: LocalizedString.c:21
PlayerManager
Definition: PlayerManager.c:12
OnDisconnected
void OnDisconnected(int playerID)
Definition: SCR_FiringRangeScoringComponent.c:15
OnObjectDamage
void OnObjectDamage(EDamageState state)
Definition: SCR_ScenarioFrameworkSlotBase.c:67
m_sText
class SCR_BaseEditorAttribute m_sText
SCR_BaseGameOverScreenInfoOptional
Definition: SCR_BaseGameOverScreenInfo.c:360
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
OnActivate
override void OnActivate(IEntity object)
callback - activation - occurs when and entity which fulfills the filter definitions enters the Trigg...
Definition: SCR_ScenarioFrameworkActions.c:57