Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RestrictedDeployableSpawnPointComponent.c
Go to the documentation of this file.
2{
3 NONE = 0,
4 SUPPLIES = 1,
6}
7
8[EntityEditorProps(category: "GameScripted/DeployableItems", description: "")]
9class SCR_RestrictedDeployableSpawnPointComponentClass : SCR_BaseDeployableSpawnPointComponentClass
12
13//------------------------------------------------------------------------------------------------
15class SCR_RestrictedDeployableSpawnPointComponent : SCR_BaseDeployableSpawnPointComponent
16{
17 // Setup
18 [Attribute("{5A258632A5C32E48}Prefabs/MP/Spawning/ItemSpecifics/RestrictedDeployableSpawnPoint_Radio_Supplies.et", uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et", category: "Setup")]
20
21 [Attribute(defvalue: "1", desc: "Should it follow gamemode restrictions", category: "General")]
22 protected bool m_bRestrictDeploy;
23
24 // General
25 [Attribute(defvalue: "1", desc: "Play audio cue once spawn point can/cannot be deployed", category: "General")]
27
28 [Attribute(defvalue: "1", desc: "Show notification once spawn point can/cannot be deployed", category: "General")]
30
31 [Attribute(defvalue: "1", category: "General")]
33
34 // Respawning
35 [Attribute(defvalue: SCR_ESpawnPointBudgetType.SUPPLIES.ToString(), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(SCR_ESpawnPointBudgetType), category: "Respawning"), RplProp()]
37
38 [Attribute(defvalue: "100", category: "Respawning")]
39 protected float m_fSuppliesValue;
40
41 [Attribute(defvalue: "5", category: "Respawning")]
42 protected int m_iMaxRespawns;
43
44 [Attribute(defvalue: "0", category: "Respawning")]
46
47 [Attribute(defvalue: "0", category: "Respawning")]
48 protected bool m_bAllowCustomLoadouts;
49
50 [Attribute(defvalue: "600", params: "0 inf", desc: "Time in seconds after deployment for the spawn to regenerate", category: "Respawning")]
52
53 [Attribute(defvalue: "0", params: "0 inf", desc: "Amount of tickets to be regenerated", category: "Respawning")]
55
56 // Queries
57 [Attribute(defvalue: "1.0", desc: "Rate at which spawn point will check if it can be deployed or not", category: "Queries")]
58 protected float m_fUpdateRate;
59
60 [Attribute(defvalue: "0", desc: "Can be deployed only when in faction radio range", category: "Queries")]
62
63 [Attribute(defvalue: "1", desc: "Check if bases are nearby before deploying", category: "Queries")]
64 protected bool m_bQueryBases;
65
66 [Attribute(defvalue: "0", desc: "Check if spawn points are nearby before deploying", category: "Queries")]
67 protected bool m_bQuerySpawnPoints;
68
69 [Attribute(defvalue: "0", desc: "Check if characters are nearby before deploying", category: "Queries")]
70 protected bool m_bQueryCharacters;
71
72 [Attribute(defvalue: "300.0", desc: "Query radius for military bases", category: "Queries")]
73 protected float m_fQueryRadiusBases;
74
75 [Attribute(defvalue: "250.0", desc: "Query radius for other existing spawn points", category: "Queries")]
77
78 [Attribute(defvalue: "100.0", desc: "Query radius for enemy characters", category: "Queries")]
79 protected float m_fQueryRadiusCharacters;
80
81 [Attribute(defvalue: "0", desc: "Query all military bases, not just Main Operating Bases", category: "Queries")]
82 protected bool m_bQueryAllBases;
83
84 [Attribute(defvalue: "0", category: "Queries")]
85 protected bool m_bIgnoreEnemyBases;
86
87 [Attribute(defvalue: "0", category: "Queries")]
89
90 [Attribute(defvalue: "0", category: "Queries")]
92
93 // User actions
94 [Attribute(defvalue: "0", category: "User Actions")]
96
97 [Attribute(defvalue: "0", category: "User Actions")]
99
100 [Attribute(defvalue: "#AR-DeployableSpawnPoints_UserAction_OutsideDeployArea", category: "User Actions")]
102
103 [Attribute(defvalue: "#AR-DeployableSpawnPoints_UserAction_DeployLimitReached", category: "User Actions")]
105
106 [Attribute(defvalue: "#AR-DeployableSpawnPoints_UserAction_NoGroupJoined", category: "User Actions")]
107 protected string m_sNoGroupJoinedMessage;
108
109 [Attribute(defvalue: "1", desc: "Should notify if friendly dismantles the spawnpoint", category: "Notifications")]
110 protected bool m_bNotifyDismantle;
111
112 [RplProp()]
113 protected int m_iGroupID = -1;
114
115 [RplProp()]
117
119
120 protected static ref array<int> s_aActiveDeployedSpawnPointGroupIDs = {};
121
123 protected bool m_bNoGroupJoined;
124 protected bool m_bSpawnLimitReached;
125 protected bool m_bIsWornByPlayer;
126
127 protected int m_iRespawnCount;
128 protected float m_fTimeSinceUpdate;
129 protected float m_fRespawnGenerationTimer = float.INFINITY;
130
131#ifdef ENABLE_DIAG
132 protected static ref array<ref Shape> s_aDebugShapes = {};
133#endif
134
135 //------------------------------------------------------------------------------------------------
136 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
137 protected void RPC_AddSpawnPointGroupBroadcast(int groupID)
138 {
140 }
141
142 //------------------------------------------------------------------------------------------------
143 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
144 protected void RPC_RemoveSpawnPointGroupBroadcast(int groupID)
145 {
146 s_aActiveDeployedSpawnPointGroupIDs.RemoveItem(groupID);
147 }
148
149 //------------------------------------------------------------------------------------------------
150 [RplRpc(RplChannel.Unreliable, RplRcver.Broadcast)]
151 protected void RPC_PlaySoundOnZoneEnteredBroadcast(bool entered)
152 {
153 SoundComponent soundComp = SoundComponent.Cast(GetOwner().FindComponent(SoundComponent));
154 if (!soundComp)
155 return;
156
157 if (entered)
158 soundComp.SoundEvent(SCR_SoundEvent.SOUND_DEPLOYED_RADIO_ENTER_ZONE);
159 else
160 soundComp.SoundEvent(SCR_SoundEvent.SOUND_DEPLOYED_RADIO_EXIT_ZONE);
161 }
162
163 //------------------------------------------------------------------------------------------------
165 protected bool EntityQuery(notnull array<IEntity> entities, notnull Faction spawnPointFaction, vector spawnPointOrigin)
166 {
167 if (entities.IsEmpty())
168 return true;
169
170 float queryRadius = 100; // Default 100 meters
171 bool isBase, isSpawnPoint, isCharacter;
172
173 if (SCR_MilitaryBaseComponent.Cast(entities[0].FindComponent(SCR_MilitaryBaseComponent)))
174 {
175 queryRadius = m_fQueryRadiusBases;
176 isBase = true;
177 }
178 else if (SCR_SpawnPoint.Cast(entities[0]))
179 {
180 queryRadius = m_fQueryRadiusSpawnPoints;
181 isSpawnPoint = true;
182 }
183 else if (SCR_ChimeraCharacter.Cast(entities[0]))
184 {
185 queryRadius = m_fQueryRadiusCharacters;
186 isCharacter = true;
187 }
188
189 float radiusSq = queryRadius * queryRadius;
190
191 foreach (IEntity e : entities)
192 {
193 vector origin = e.GetOrigin();
194
195#ifdef ENABLE_DIAG
196 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS_ENABLE_DIAG))
197 s_aDebugShapes.Insert(Shape.CreateSphere(Color.RED, ShapeFlags.WIREFRAME, origin, queryRadius));
198#endif
199
200 float distanceToItemSq = vector.DistanceSq(spawnPointOrigin, origin);
201 bool isWithinRadius = distanceToItemSq < radiusSq;
202
203 if (!isWithinRadius)
204 continue;
205
207 if (!faction)
208 return false;
209
210 bool isFriendlyFaction = faction.DoCheckIfFactionFriendly(spawnPointFaction);
211
212 if (isBase)
213 {
214 if (!isFriendlyFaction && !m_bIgnoreEnemyBases)
215 return false;
216 }
217 else if (isSpawnPoint)
218 {
219 if (!isFriendlyFaction && !m_bIgnoreEnemySpawnPoints)
220 return false;
221 }
222 else if (isCharacter)
223 {
224 if (!isFriendlyFaction && !m_bIgnoreEnemyCharacters)
225 return false;
226 }
227 }
228
229 return true;
230 }
231
232 //------------------------------------------------------------------------------------------------
233 protected bool CanActionBeShown(notnull IEntity userEntity, bool checkFaction, bool checkGroupID)
234 {
236 return false;
237
238 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(userEntity.FindComponent(FactionAffiliationComponent));
239 if (!factionAffiliation)
240 return false;
241
242 Faction affiliatedFaction = factionAffiliation.GetAffiliatedFaction();
243 if (!affiliatedFaction)
244 return false;
245
246 FactionKey userFactionKey = affiliatedFaction.GetFactionKey();
247 if (!userFactionKey)
248 return false;
249
250 if (userFactionKey != m_FactionKey && !m_bUnlockActionsForEnemyFactions && checkFaction)
251 return false;
252
253 SCR_PossessingManagerComponent possessingManagerComp = SCR_PossessingManagerComponent.GetInstance();
254 if (!possessingManagerComp)
255 return false;
256
257 int userID = possessingManagerComp.GetIdFromControlledEntity(userEntity);
258
259 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
260 if (!playerControllerGroupComp)
261 return false;
262
263 int userGroupID = playerControllerGroupComp.GetGroupID();
264
265 if (userFactionKey == m_FactionKey && userGroupID != m_iGroupID && !m_bUnlockActionsForAllGroups && checkGroupID)
266 return false;
267
268 return true;
269 }
270
271 //------------------------------------------------------------------------------------------------
272 protected bool CanBeDeployedAtPosition(vector position, notnull IEntity userEntity, out int notification = -1)
273 {
274 array<IEntity> entities = {};
275
276 FactionManager factionManager = GetGame().GetFactionManager();
277 if (!factionManager)
278 return false;
279
280 SCR_Faction faction = SCR_Faction.Cast(factionManager.GetFactionByKey(m_FactionKey));
281
282 // Check if the entity is in faction radio range
284 {
285 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
286 if (campaign)
287 {
288 SCR_CampaignMilitaryBaseManager campaignBaseManager = campaign.GetBaseManager();
289 if (campaignBaseManager)
290 {
291 if (!campaignBaseManager.IsEntityInFactionRadioSignal(GetOwner(), faction))
292 {
293 notification = ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
294 return false;
295 }
296 }
297 }
298 }
299
300 // Check for nearby bases and prevent deploy if there are any
301 if (m_bQueryBases)
302 {
304 if (!baseManager)
305 return false;
306
307 array<SCR_MilitaryBaseComponent> baseComponents = {};
308
309 baseManager.GetBases(baseComponents);
310
311 foreach (SCR_MilitaryBaseComponent baseComponent : baseComponents)
312 {
313 if (!baseComponent)
314 continue;
315
316 if (baseComponent.GetFaction() != faction)
317 {
319 {
320 entities.Insert(baseComponent.GetOwner());
321 continue;
322 }
323
324 SCR_CampaignMilitaryBaseComponent campaignBaseComponent = SCR_CampaignMilitaryBaseComponent.Cast(baseComponent);
325 if (!campaignBaseComponent || !campaignBaseComponent.IsHQ())
326 continue;
327
328 entities.Insert(baseComponent.GetOwner());
329 }
330 }
331
332 if (!EntityQuery(entities, faction, position))
333 {
334 notification = ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
335 return false;
336 }
337 }
338
339 // Check for nearby spawnpoints and prevent deploy if there are any
341 {
342 entities = {};
343
344 array<SCR_SpawnPoint> spawnPoints = SCR_SpawnPoint.GetSpawnPoints();
345
346 foreach (SCR_SpawnPoint spawnPoint : spawnPoints)
347 {
348 if (!spawnPoint)
349 continue;
350
351 if (!SCR_PlayerRadioSpawnPoint.Cast(spawnPoint) && spawnPoint.GetFactionKey() != faction.GetFactionKey())
352 entities.Insert(spawnPoint);
353 }
354
355 if (!EntityQuery(entities, faction, position))
356 {
357 notification = ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
358 return false;
359 }
360 }
361
362 // Check for nearby enemy characters and prevent deploy if there are any
364 {
365 entities = {};
366
367 array<SCR_ChimeraCharacter> characters = SCR_CharacterRegistrationComponent.GetChimeraCharacters();
368 if (!characters)
369 return false;
370
371 foreach (SCR_ChimeraCharacter character : characters)
372 {
373 if (!character)
374 continue;
375
376 if (character == userEntity || character.GetCharacterController().IsDead())
377 continue;
378
379 entities.Insert(character);
380 }
381
382 if (!EntityQuery(entities, faction, position))
383 {
384 notification = ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_EXITED;
385 return false;
386 }
387 }
388
389 notification = ENotification.DEPLOYABLE_SPAWNPOINTS_ZONE_ENTERED;
390 return true;
391 }
392
393 //------------------------------------------------------------------------------------------------
395 {
397 return false;
398
399 return m_LocalPlayerGroup.GetDeployedRadioCount() >= m_iMaxSpawnPointsPerGroup;
400 }
401
402 //------------------------------------------------------------------------------------------------
404 {
405 Resource resource;
407 resource = Resource.Load(m_sSpawnPointPrefabSupplies);
408 else
409 resource = Resource.Load(m_sSpawnPointPrefab);
410
411 if (!resource.IsValid())
412 return null;
413
415 params.Transform = m_aOriginalTransform;
416 params.TransformMode = ETransformMode.WORLD;
417 return SCR_DeployableSpawnPoint.Cast(GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), params));
418 }
419
420 //------------------------------------------------------------------------------------------------
422 override void Deploy(IEntity userEntity, bool reload = false)
423 {
424 //~ Not allowed to deploy
426 return;
427
428 if (!m_RplComponent || m_RplComponent.IsProxy())
429 return;
430
431 int userID = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(userEntity);
432
433 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
434 if (!playerControllerGroupComp)
435 return;
436
437 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
438 if (!groupsManager)
439 return;
440
441 groupsManager.GetOnPlayableGroupRemoved().Insert(OnGroupRemoved);
442
443 const int groupId = playerControllerGroupComp.GetGroupID();
444 SCR_AIGroup playerGroup = groupsManager.FindGroup(groupId);
445 if (!playerGroup)
446 return;
447
448 DeployByGroup(playerGroup, userEntity, reload);
449 }
450
451 //------------------------------------------------------------------------------------------------
452 void DeployByGroup(notnull SCR_AIGroup group, IEntity userEntity = null, bool reload = false)
453 {
454 m_iGroupID = group.GetGroupID();
455 group.IncreaseDeployedRadioCount();
456
457 super.Deploy(userEntity, reload);
458
459 if (!m_SpawnPoint)
460 return;
461
463 if (!restrictedSpawnPoint)
464 return;
465
467 restrictedSpawnPoint.SetGroupID(m_iGroupID);
468 restrictedSpawnPoint.SetBudgetType(m_eRespawnBudgetType);
469
470 restrictedSpawnPoint.SetRespawnCount(m_iRespawnCount);
471 restrictedSpawnPoint.SetMaxRespawns(m_iMaxRespawns);
472 restrictedSpawnPoint.SetLoadoutAllowed(m_bAllowCustomLoadouts);
473
475
477 m_bIsOutsideExclusionZone = true; // Savegame load will not have called update prior and will not have worn it on disassembly
478
479 Replication.BumpMe();
480 }
481
482 //------------------------------------------------------------------------------------------------
484 override void Dismantle(IEntity userEntity = null, bool reload = false)
485 {
486 if (!m_RplComponent || m_RplComponent.IsProxy())
487 return;
488
489 m_fRespawnGenerationTimer = float.INFINITY;
490
491 if (m_SpawnPoint)
492 {
494 if (!restrictedSpawnPoint)
495 return;
496
497 SetRespawnCount(restrictedSpawnPoint.GetRespawnCount());
498 GetSuppliesValue(true); // Refresh
499 }
500
501 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
502 if (groupsManager)
503 {
504 groupsManager.GetOnPlayableGroupRemoved().Remove(OnGroupRemoved);
505
506 SCR_AIGroup playerGroup = groupsManager.FindGroup(m_iGroupID);
507 if (playerGroup)
508 {
509 playerGroup.DecreaseDeployedRadioCount();
510
512 {
513 SCR_ChimeraCharacter dismantlingCharacter = SCR_ChimeraCharacter.Cast(userEntity);
514 if (dismantlingCharacter)
515 {
516 int dismantlingPlayerID = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(dismantlingCharacter);
517
518 Faction dismantlingFaction = dismantlingCharacter.GetFaction();
519 Faction groupFaction = playerGroup.GetFaction();
520
521 if (dismantlingFaction && dismantlingFaction == groupFaction)
522 SCR_NotificationsComponent.SendToGroup(m_iGroupID, ENotification.GROUP_RADIO_DISMANTLED_BY_FRIENDLY, dismantlingPlayerID);
523 }
524 }
525 }
526 }
527
528 m_iGroupID = -1; // reset groupID
529 Replication.BumpMe();
530
531 super.Dismantle(userEntity, reload);
532 }
533
534 //------------------------------------------------------------------------------------------------
536 void ShowInfo(notnull IEntity userEntity)
537 {
538 SCR_PossessingManagerComponent possessingManagerComp = SCR_PossessingManagerComponent.GetInstance();
539 if (!possessingManagerComp)
540 return;
541
542 const int userID = possessingManagerComp.GetIdFromControlledEntity(userEntity);
543 const int respawnsLeft = m_iMaxRespawns - m_iRespawnCount;
544
546 {
547 SCR_NotificationsComponent.SendToPlayer(userID, ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_RESPAWN_COUNT, respawnsLeft, m_iMaxRespawns);
548 return;
549 }
550
551 SCR_PlayerControllerGroupComponent playerControllerGroupComp = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(userID);
552 if (!playerControllerGroupComp)
553 return;
554
555 const int userGroupID = playerControllerGroupComp.GetGroupID();
556 if (userGroupID != m_iGroupID)
557 {
558 SCR_NotificationsComponent.SendToPlayer(userID, ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_GROUP, m_iGroupID);
559 return;
560 }
561
562 SCR_NotificationsComponent.SendToPlayer(userID, ENotification.DEPLOYABLE_SPAWNPOINTS_DISPLAY_RESPAWN_COUNT, respawnsLeft, m_iMaxRespawns);
563 }
564
565 //------------------------------------------------------------------------------------------------
567 void ToggleSpawningWithLoadout(IEntity userEntity = null)
568 {
570 }
571
572 //------------------------------------------------------------------------------------------------
573 void SetSpawningWithLoadout(bool allow, IEntity userEntity = null)
574 {
575 m_bAllowCustomLoadouts = allow;
576
578 if (!restrictedSpawnPoint)
579 return;
580
581 restrictedSpawnPoint.SetLoadoutAllowed(m_bAllowCustomLoadouts);
582
583 if (!userEntity)
584 return;
585
586 SCR_PossessingManagerComponent possessingManagerComp = SCR_PossessingManagerComponent.GetInstance();
587 if (!possessingManagerComp)
588 return;
589
590 const int userID = possessingManagerComp.GetIdFromControlledEntity(userEntity);
591 if (userID == 0)
592 return;
593
595 SCR_NotificationsComponent.SendToPlayer(userID, ENotification.DEPLOYABLE_SPAWNPOINTS_LOADOUTS_ALLOWED);
596 else
597 SCR_NotificationsComponent.SendToPlayer(userID, ENotification.DEPLOYABLE_SPAWNPOINTS_LOADOUTS_BANNED);
598 }
599
600 //------------------------------------------------------------------------------------------------
602 {
604 }
605
606 //------------------------------------------------------------------------------------------------
622
623 //------------------------------------------------------------------------------------------------
624 override bool CanDeployBeShown(notnull IEntity userEntity)
625 {
626 if (!CanActionBeShown(userEntity, true, false))
627 return false;
628
629 return !m_bIsDeployed;
630 }
631
632 //------------------------------------------------------------------------------------------------
633 override bool CanDismantleBeShown(notnull IEntity userEntity)
634 {
635 if (!CanActionBeShown(userEntity, false, false))
636 return false;
637
638 return m_bIsDeployed;
639 }
640
641 //------------------------------------------------------------------------------------------------
644 bool CanInfoBeShown(notnull IEntity userEntity)
645 {
646 return m_eRespawnBudgetType == SCR_ESpawnPointBudgetType.SPAWNTICKET && CanActionBeShown(userEntity, true, false);
647 }
648
649 //------------------------------------------------------------------------------------------------
652 bool CanOpenStorageBeShown(notnull IEntity userEntity)
653 {
654 if (m_eRespawnBudgetType != SCR_ESpawnPointBudgetType.SUPPLIES || !CanActionBeShown(userEntity, true, true))
655 return false;
656
657 return m_bIsDeployed;
658 }
659
660 //------------------------------------------------------------------------------------------------
664 {
665 IEntity ownerEntity = GetGame().GetPlayerManager().GetPlayerControlledEntity(m_iItemOwnerID);
666 if (!ownerEntity || ownerEntity != userEntity)
667 return false;
668
669 if (m_eRespawnBudgetType != SCR_ESpawnPointBudgetType.SUPPLIES || !CanActionBeShown(userEntity, true, true))
670 return false;
671
672 return m_bIsDeployed;
673 }
674
675 //------------------------------------------------------------------------------------------------
681
682 //------------------------------------------------------------------------------------------------
688
689 //------------------------------------------------------------------------------------------------
692 {
693 return m_iGroupID;
694 }
695
696 //------------------------------------------------------------------------------------------------
699 {
701 }
702
703 //------------------------------------------------------------------------------------------------
705 void SetRespawnCount(int respawnCount)
706 {
707 m_iRespawnCount = respawnCount;
708 }
709
710 //------------------------------------------------------------------------------------------------
712 {
713 return m_iRespawnCount;
714 }
715
716 //------------------------------------------------------------------------------------------------
718 {
719 return m_iMaxRespawns;
720 }
721
722 //------------------------------------------------------------------------------------------------
724 void SetMaxRespawns(int maxRespawns)
725 {
726 if (!m_RplComponent || m_RplComponent.IsProxy())
727 return;
728
729 m_iMaxRespawns = maxRespawns;
730 Reload();
731 }
732
733 //------------------------------------------------------------------------------------------------
736 {
737 if (!m_RplComponent || m_RplComponent.IsProxy())
738 return;
739
740 m_eRespawnBudgetType = budgetType;
741 Replication.BumpMe();
742 Reload();
743 }
744
745 //------------------------------------------------------------------------------------------------
750
751 //------------------------------------------------------------------------------------------------
752 void SetSuppliesValue(float value, bool refreshDeployedContainer = true)
753 {
754 m_fSuppliesValue = value;
755
756 if (!refreshDeployedContainer || !m_SpawnPoint)
757 return;
758
759 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(m_SpawnPoint.FindComponent(SCR_ResourceComponent));
760 if (!resourceComponent)
761 return;
762
763 SCR_ResourceContainer container = resourceComponent.GetContainer(EResourceType.SUPPLIES);
764 if (container)
766 }
767
768 //------------------------------------------------------------------------------------------------
769 float GetSuppliesValue(bool refreshFromDeployedContainer = true)
770 {
771 if (refreshFromDeployedContainer && m_SpawnPoint)
772 {
773 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(m_SpawnPoint.FindComponent(SCR_ResourceComponent));
774 if (resourceComponent)
775 {
776 SCR_ResourceContainer container = resourceComponent.GetContainer(EResourceType.SUPPLIES);
777 if (container)
779 }
780 }
781
782 return m_fSuppliesValue;
783 }
784
785 //------------------------------------------------------------------------------------------------
786 protected void OnGroupChanged(int groupID)
787 {
788 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
789 if (!groupsManager)
790 return;
791
792 m_LocalPlayerGroup = groupsManager.FindGroup(groupID);
794 m_bNoGroupJoined = true;
795 else
796 m_bNoGroupJoined = false;
797 }
798
799 //------------------------------------------------------------------------------------------------
800 protected void OnGroupRemoved(SCR_AIGroup group)
801 {
802 if (group.GetGroupID() == m_iGroupID)
803 Dismantle(); // Dismantle item if removed group is the same as the item group; otherwise deployed item would be unusable
804 }
805
806 //------------------------------------------------------------------------------------------------
808 {
809 SetBudgetType(budgetType);
810 }
811
812 //------------------------------------------------------------------------------------------------
813 protected void OnSpawnPointTicketAmountChanged(int tickets)
814 {
815 SetMaxRespawns(tickets);
816 }
817
818 //------------------------------------------------------------------------------------------------
821 protected void GenerateRespawns(int amount)
822 {
823 if (amount <= 0)
824 return;
825
827 if (!restrictedSpawnPoint)
828 return;
829
830 SetRespawnCount(Math.Max(m_iRespawnCount - amount, 0));
831 restrictedSpawnPoint.SetRespawnCount(m_iRespawnCount);
832 }
833
834 //------------------------------------------------------------------------------------------------
835 override void Update(float timeSlice)
836 {
837 super.Update(owner, timeSlice);
838
840 {
841 m_fTimeSinceUpdate += timeSlice;
842 return;
843 }
844
847 {
850 }
851
853
854 //timed execution
855
856#ifdef ENABLE_DIAG
858 s_aDebugShapes.Clear();
859#endif
860
862 return;
863
864 if (!m_RplComponent || m_RplComponent.IsProxy())
865 return;
866
867 //server code
868
870 if (!item)
871 return;
872
873 InventoryStorageSlot parentSlot = item.GetParentSlot();
874 if (!parentSlot)
875 {
876 m_bIsWornByPlayer = false;
877 return;
878 }
879
880 IEntity parentEntity;
881 while (parentSlot)
882 {
883 parentEntity = parentSlot.GetStorage().GetOwner();
884 parentSlot = parentSlot.GetStorage().GetParentSlot();
885 }
886
887 if (!parentEntity || !SCR_ChimeraCharacter.Cast(parentEntity))
888 {
889 m_bIsWornByPlayer = false;
890 return;
891 }
892
893 int userID = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(parentEntity);
894 if (userID <= 0)
895 {
896 m_bIsWornByPlayer = false;
897 return;
898 }
899
900 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(parentEntity.FindComponent(FactionAffiliationComponent));
901 if (!factionAffiliation)
902 return;
903
904 Faction affiliatedFaction = factionAffiliation.GetAffiliatedFaction();
905 if (!affiliatedFaction)
906 return;
907
908 FactionKey userFactionKey = affiliatedFaction.GetFactionKey();
909 if (!userFactionKey)
910 return;
911
912 if (userFactionKey != m_FactionKey)
913 {
914 m_bIsWornByPlayer = false;
915 return;
916 }
917
918 m_bIsWornByPlayer = true;
919
920 int notification;
921 bool canBeDeployedAtPos = CanBeDeployedAtPosition(GetOwner().GetOrigin(), parentEntity, notification);
922
923 if (m_bIsOutsideExclusionZone == canBeDeployedAtPos)
924 return;
925
926 m_bIsOutsideExclusionZone = canBeDeployedAtPos;
927 Replication.BumpMe();
928
929 if (m_bShowNotificationOnZoneEntered && notification > -1)
930 SCR_NotificationsComponent.SendToPlayer(userID, notification);
931
933 if (data && data.IsSoundEnabled() && m_bPlaySoundOnZoneEntered)
934 {
935 RPC_PlaySoundOnZoneEnteredBroadcast(canBeDeployedAtPos);
936 Rpc(RPC_PlaySoundOnZoneEnteredBroadcast, canBeDeployedAtPos);
937 }
938 }
939
940 //------------------------------------------------------------------------------------------------
941 override void EOnInit(IEntity owner)
942 {
943 super.EOnInit(owner);
944
946
947 BaseGameMode gameMode = GetGame().GetGameMode();
948 if (!gameMode)
949 return;
950
952 if (playerSpawnPointManager)
953 {
954 SetBudgetType(playerSpawnPointManager.GetDeployableSpawnPointBudgetType());
955 SetMaxRespawns(playerSpawnPointManager.GetDeployableSpawnPointTicketAmount());
956 playerSpawnPointManager.GetOnSpawnPointBudgetTypeChanged().Insert(OnSpawnPointBudgetTypeChanged);
958 }
959
960 PlayerController playerController = GetGame().GetPlayerController();
961 if (!playerController)
962 return;
963
964 SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
965 if (!groupComponent)
966 return;
967
968 groupComponent.GetOnGroupChanged().Insert(OnGroupChanged);
969
970 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
971 if (!groupsManager)
972 return;
973
974 m_LocalPlayerGroup = groupsManager.GetPlayerGroup(playerController.GetPlayerId());
976
978 }
979
980 //------------------------------------------------------------------------------------------------
981 override void OnDelete(IEntity owner)
982 {
983 super.OnDelete(owner);
984
985 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
986 if (groupsManager)
987 groupsManager.GetOnPlayableGroupRemoved().Remove(OnGroupRemoved);
988
989 BaseGameMode gameMode = GetGame().GetGameMode();
990 SCR_PlayerSpawnPointManagerComponent playerSpawnPointManager;
991 if (gameMode)
992 playerSpawnPointManager = SCR_PlayerSpawnPointManagerComponent.Cast(gameMode.FindComponent(SCR_PlayerSpawnPointManagerComponent));
993
994 if (playerSpawnPointManager)
995 {
996 playerSpawnPointManager.GetOnSpawnPointBudgetTypeChanged().Remove(OnSpawnPointBudgetTypeChanged);
998 }
999
1000#ifdef ENABLE_DIAG
1002 s_aDebugShapes.Clear();
1003#endif
1004
1005 SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
1006 if (groupComponent)
1007 groupComponent.GetOnGroupChanged().Remove(OnGroupChanged);
1008
1009 if (!m_bIsDeployed || !m_RplComponent || m_RplComponent.IsProxy() || !groupsManager)
1010 return;
1011
1012 SCR_AIGroup playerGroup = groupsManager.FindGroup(m_iGroupID);
1013 if (playerGroup)
1014 playerGroup.DecreaseDeployedRadioCount();
1015 }
1016}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector GetOrigin()
void ConnectToDeployableSpawnPointSystem()
ResourceName m_sSpawnPointPrefab
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
RplComponent m_RplComponent
SCR_SpawnPoint m_SpawnPoint
void SCR_CharacterRegistrationComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_CharacterSoundComponentClass GetComponentData()
vector position
Get all prefabs that have the spawner data
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum SCR_ESpawnPointBudgetType EntityEditorProps(category:"GameScripted/DeployableItems", description:"")
Definition Color.c:13
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
int GetGroupID()
Faction GetFaction()
void DecreaseDeployedRadioCount()
bool IsEntityInFactionRadioSignal(notnull IEntity entity, notnull Faction faction)
override bool DoCheckIfFactionFriendly(Faction faction)
static Faction GetEntityFaction(notnull IEntity entity)
int GetBases(notnull out array< SCR_MilitaryBaseComponent > bases)
static SCR_MilitaryBaseSystem GetInstance()
bool SetResourceValue(float value, bool notifyChange=true)
Deployable spawn point with configurable conditions.
void OnSpawnPointBudgetTypeChanged(SCR_ESpawnPointBudgetType budgetType)
bool CanBeDeployedAtPosition(vector position, notnull IEntity userEntity, out int notification=-1)
void ShowInfo(notnull IEntity userEntity)
Display amount of respawns left - called from SCR_ShowDeployableSpawnPointInfo.PerformAction.
void SetSuppliesValue(float value, bool refreshDeployedContainer=true)
override void Deploy(IEntity userEntity, bool reload=false)
Check if deploy is possible, then call super.Deploy().
bool EntityQuery(notnull array< IEntity > entities, notnull Faction spawnPointFaction, vector spawnPointOrigin)
Returns true when there are no entities in the specified area that could prevent deploying.
bool CanActionBeShown(notnull IEntity userEntity, bool checkFaction, bool checkGroupID)
void DeployByGroup(notnull SCR_AIGroup group, IEntity userEntity=null, bool reload=false)
void ToggleSpawningWithLoadout(IEntity userEntity=null)
Toggles spawning with custom loadout.
override void Dismantle(IEntity userEntity=null, bool reload=false)
Cache respawn count; then call super.Dismantle().
Basically SCR_SpawnPoint with the ability to limit respawn amount.
void SetAllowAllGroupsToSpawn(bool allowAllGroupsToSpawn)
void SetBudgetType(SCR_ESpawnPointBudgetType budgetType)
Spawn point entity defines positions on which players can possibly spawn.
Instance of created debug visualizer.
Definition Shape.c:14
void EntitySpawnParams()
Definition gameLib.c:130
IEntity GetOwner()
Owner entity of the fuel tank.
ShapeFlags
Definition ShapeFlags.c:13
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14