16 [
Attribute(
"250",
desc:
"Minimum allowed spawn distance, in meters.")]
19 [
Attribute(
"1000",
desc:
"Maximum allowed spawn distance, in meters.")]
22 [
Attribute(
"200",
desc:
"Buffer distance, in meters, added beyond spawn distance before entities are despawned.")]
25 [
Attribute(
"250",
desc:
"Minimum allowed despawn distance, in meters.")]
28 [
Attribute(
"1000",
desc:
"Maximum allowed despawn distance, in meters.")]
38 protected ref array<SCR_AmbientPatrolSpawnPointComponent>
m_aPatrols = {};
49 override event protected void OnInit()
58 int fractionOfVD =
GetGame().GetViewDistance() * 0.3;
94 m_fTimer += args.GetTimeSliceSeconds();
149 array<int> playerIds = {};
151 int playersCount = pc.GetPlayers(playerIds);
153 foreach (
int playerId : playerIds)
155 IEntity player = pc.GetPlayerControlledEntity(playerId);
160 CharacterControllerComponent comp = CharacterControllerComponent.Cast(player.
FindComponent(CharacterControllerComponent));
162 if (!comp || comp.IsDead())
178 SCR_AmbientPatrolSpawnPointComponent spawnpoint =
m_aPatrols[spawnpointIndex];
179 if (!spawnpoint || (spawnpoint.GetMembersAlive() == 0 && !spawnpoint.GetIsSpawned()))
184 if (spawnpoint.GetRespawnTimestamp().Greater(currentTime))
187 if (!spawnpoint.GetIsSpawned())
189 spawnpoint.SpawnPatrol();
194 bool playersVeryNear;
195 bool playersFar =
true;
200 int spawnPointSpawnDistance = spawnpoint.GetSpawnDistanceOverride();
201 if (spawnPointSpawnDistance >= 0)
205 int spawnPointDespawnDistance = spawnpoint.GetDespawnDistanceOverride();
206 if (spawnPointDespawnDistance >= 0)
230 playersVeryNear =
true;
235 AIWorld aiWorld =
GetGame().GetAIWorld();
238 int maxChars = aiWorld.GetLimitOfActiveAIs();
241 isAIOverLimit =
true;
243 isAIOverLimit = ((
float)aiWorld.GetCurrentNumOfActiveAIs() / (
float)maxChars) > spawnpoint.GetAILimitThreshold();
246 if (!isAIOverLimit && !playersVeryNear)
247 spawnpoint.SetIsPaused(
false);
249 if (playersNear && !spawnpoint.GetIsPaused() && !spawnpoint.IsGroupActive())
254 spawnpoint.SetIsPaused(
true);
258 spawnpoint.ActivateGroup();
263 if (spawnpoint.GetIsSpawned() && playersFar && spawnpoint.IsGroupActive())
268 spawnpoint.SetDespawnTimestamp(currentTime.PlusMilliseconds(
DESPAWN_TIMEOUT));
270 else if (currentTime.Greater(despawnT))
272 spawnpoint.DeactivateGroup();
277 spawnpoint.SetDespawnTimestamp(null);
307 int GetPatrols(notnull out array<SCR_AmbientPatrolSpawnPointComponent> patrols)
ArmaReforgerScripted GetGame()
bool AreGameFlagsSet(EGameFlags checkGameFlags)
EGameFlags
GameMode Game Flags represented by bit mask.
SCR_BaseGameMode GetGameMode()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
static const int DESPAWN_TIMEOUT
void OnPlayerSpawnedOrDeleted(int playerId, IEntity player)
void RegisterPatrol(notnull SCR_AmbientPatrolSpawnPointComponent patrol)
void ProcessSpawnpoint(int spawnpointIndex)
int m_iMaxDespawnDistanceSq
static const int SPAWN_RADIUS_BLOCK_SQ
static SCR_AmbientPatrolSystem GetInstance()
int ClampDespawnDistanceSq(int despawnDistanceSq)
override event bool ShouldBePaused()
ref array< SCR_AmbientPatrolSpawnPointComponent > m_aPatrols
int m_iDespawnBufferDistanceSq
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
int m_iMinDespawnDistanceSq
int GetPatrols(notnull out array< SCR_AmbientPatrolSpawnPointComponent > patrols)
void OnPlayerDisconnected(int playerId, KickCauseCode cause=KickCauseCode.NONE, int timeout=-1)
int m_iDespawnBufferDistance
void UnregisterPatrol(notnull SCR_AmbientPatrolSpawnPointComponent patrol)
void OnUpdatePoint(WorldUpdatePointArgs args)
void UpdateCheckInterval()
int m_iMaxDespawnDistance
int m_iMinDespawnDistance
static const int CHECK_INTERVAL
int m_iMinSpawnDistanceSq
int ClampSpawnDistanceSq(int spawnDistanceSq)
int m_iMaxSpawnDistanceSq
ref array< IEntity > m_aPlayers
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > GetOnPlayerDisconnected()
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerSpawned()
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
static sealed bool IsLoadInProgress(float msSinceLoad=1000.0)
Structure holding world system meta-information required by the engine.
Structure holding extra data of WorldSystem update point.
WorldSystemPoint ESystemPoint
WorldSystemLocation ESystemLocation
SCR_FieldOfViewSettings Attribute
int IsEnabled()
Returns true if the light is enabled.