20 string m_ParamName =
"Default setup";
21 string m_ParamTriggerType =
"ContaminatedTrigger";
22 float m_ParamRadius = 100;
23 float m_ParamPosHeight = 25;
24 float m_ParamNegHeight = 10;
25 int m_ParamInnerRings = 1;
26 int m_ParamInnerSpace = 35;
27 bool m_ParamOuterToggle =
true;
28 int m_ParamOuterSpace = 20;
29 int m_ParamOuterOffset = -5;
30 int m_ParamVertLayers = 0;
31 int m_ParamVerticalOffset = 10;
32 int m_ParamEffectInterval = 0;
33 int m_ParamEffectDuration = 0;
34 int m_ParamEffectModifier = 0;
40 int m_ParamPartId = 0;
41 int m_ParamAroundPartId = 0;
42 int m_ParamTinyPartId = 0;
44 string m_ParamPpeRequesterType =
"PPERequester_ContaminatedAreaTint";
48class EffectArea :
House
51 string m_Name =
"Default setup";
54 vector m_PositionTrigger;
57 bool m_EffectModifier;
61 float m_PositiveHeight = 25;
62 float m_NegativeHeight = 10;
67 int m_InnerSpacing = 35;
69 bool m_OuterRingToggle =
true;
70 int m_OuterRingOffset = -5;
71 int m_OuterSpacing = 20;
73 int m_VerticalLayers = 0;
74 int m_VerticalOffset = 10;
77 int m_ParticleID = ParticleList.CONTAMINATED_AREA_GAS_BIGASS;
78 int m_AroundParticleID = ParticleList.CONTAMINATED_AREA_GAS_AROUND;
79 int m_TinyParticleID = ParticleList.CONTAMINATED_AREA_GAS_TINY;
80 string m_PPERequesterType;
81 int m_PPERequesterIdx = -1;
82 int m_EffectsPriority;
84 const int PARTICLES_MAX = 1000;
87 string m_TriggerType =
"ContaminatedTrigger";
88 EffectTrigger m_Trigger;
90 ref array<Particle> m_ToxicClouds;
98 RegisterNetSyncVariableFloat(
"m_Radius", 0, 0, 2);
99 RegisterNetSyncVariableFloat(
"m_PositiveHeight", 0, 0, 2);
100 RegisterNetSyncVariableFloat(
"m_NegativeHeight", 0, 0, 2);
102 RegisterNetSyncVariableInt(
"m_InnerRings");
103 RegisterNetSyncVariableInt(
"m_InnerSpacing");
104 RegisterNetSyncVariableInt(
"m_OuterRingOffset");
105 RegisterNetSyncVariableInt(
"m_OuterSpacing");
106 RegisterNetSyncVariableInt(
"m_VerticalLayers");
107 RegisterNetSyncVariableInt(
"m_VerticalOffset");
109 RegisterNetSyncVariableInt(
"m_ParticleID");
115 RegisterNetSyncVariableBool(
"m_OuterRingToggle");
126 if ( params.m_ParamName !=
"" )
127 m_Name = params.m_ParamName;
128 if ( params.m_ParamTriggerType !=
"" )
129 m_TriggerType = params.m_ParamTriggerType;
131 if ( params.m_ParamRadius > 0 )
133 if ( params.m_ParamPosHeight > -1 )
134 m_PositiveHeight = params.m_ParamPosHeight;
135 if ( params.m_ParamNegHeight > -1 )
136 m_NegativeHeight = params.m_ParamNegHeight;
138 m_InnerRings = params.m_ParamInnerRings;
139 if ( params.m_ParamInnerSpace > -1 )
140 m_InnerSpacing = params.m_ParamInnerSpace;
142 m_OuterRingToggle = params.m_ParamOuterToggle;
143 if ( params.m_ParamOuterSpace > -1 )
144 m_OuterSpacing = params.m_ParamOuterSpace;
145 m_OuterRingOffset = params.m_ParamOuterOffset;
147 if ( params.m_ParamVertLayers > 0 )
148 m_VerticalLayers = params.m_ParamVertLayers;
149 if ( params.m_ParamVerticalOffset > 0 )
150 m_VerticalOffset = params.m_ParamVerticalOffset;
152 m_EffectInterval = params.m_ParamEffectInterval;
153 m_EffectDuration = params.m_ParamEffectDuration;
154 m_EffectModifier = params.m_ParamEffectModifier;
156 m_ParticleID = params.m_ParamPartId;
157 m_AroundParticleID = params.m_ParamAroundPartId;
158 m_TinyParticleID = params.m_ParamTinyPartId;
160 if ( params.m_ParamPpeRequesterType !=
"" )
162 m_PPERequesterType = params.m_ParamPpeRequesterType;
163 m_PPERequesterIdx = GetRequesterIndex(m_PPERequesterType);
171 #ifdef ENABLE_LOGGING
172 Debug.Log(
">>>> SetupZoneData: Finished: " +
m_Name);
181 #ifdef DIAG_DEVELOPER
182 #ifdef EFFECT_AREA_VISUAL_DEBUG
203 m_PositionTrigger[1] =
m_Position[1] + ((m_PositiveHeight - m_NegativeHeight) * 0.5);
205 if (!
GetGame().IsDedicatedServer())
237 override bool CanBeTargetedByAI(
EntityAI ai )
246 void PlaceParticles( vector pos,
float radius,
int nbRings,
int innerSpacing,
bool outerToggle,
int outerSpacing,
int outerOffset,
int partId )
255 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: no particle defined, skipping area particle generation" );
260 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: Radius of contaminated zone is set to 0, this should not happen");
263 if ( outerToggle && radius == outerOffset )
265 Error(
"[WARNING] :: [EffectArea PlaceParticles] :: Your outerOffset is EQUAL to your Radius, this will result in division by 0");
271 ParticlePropertiesArray props =
new ParticlePropertiesArray();
274 if (innerSpacing == 0)
278 for (
int i = 0; i <= nbRings + outerToggle; ++i )
282 SpawnParticles(props, pos, pos, partCount);
287 float angleIncrement;
289 vector temp = vector.Zero;
295 ab = radius - outerOffset;
298 angleIncrement = Math.Acos( 1 - ( ( outerSpacing * outerSpacing ) / ( 2 * Math.SqrInt(ab) ) ) );
299 temp[2] = temp[2] + ab;
305 ab = ( radius / ( nbRings + 1 ) ) * i;
308 angleIncrement = Math.Acos( 1 - ( ( innerSpacing * innerSpacing ) / ( 2 * Math.SqrInt(ab) ) ) );
309 temp[2] = temp[2] + ab;
314 for (
int j = 0; j <= ( Math.PI2 / angleIncrement ); j++ )
319 float sinAngle = Math.Sin(angleIncrement * j);
320 float cosAngle = Math.Cos(angleIncrement * j);
322 vector partPos = vector.RotateAroundZero( temp, vector.Up, cosAngle, sinAngle );
325 SpawnParticles(props, pos, partPos, partCount);
330 InsertParticles(props, partCount, partId);
334 void FillWithParticles(vector pos,
float areaRadius,
float outwardsBleed,
float partSize,
int partId)
351 float radiusMax = areaRadius + outwardsBleed;
352 float radiusPart = partSize / 2;
354 bool centerPart =
true;
356 ParticlePropertiesArray props =
new ParticlePropertiesArray();
360 if (radiusMax > radiusPart * 1.5)
362 if (radiusMax < radiusPart * 2.5)
364 ringDist = radiusMax - radiusPart;
370 radiusMax -= radiusPart;
371 ringCount = Math.Ceil(radiusMax / partSize);
372 ringDist = radiusMax / ringCount;
380 for (
int ring = 0; ring <= ringCount; ++ring)
382 if (ring == 0 && centerPart)
384 SpawnParticles(props, pos, pos, partCount);
388 float ringRadius = ringDist * ring;
389 float circumference = 2 * Math.PI2 * ringRadius;
391 int count = Math.Floor(circumference / partSize);
392 float angleInc = Math.PI2 / count;
394 for (
int i = 0; i < count; ++i)
396 vector partPos = pos;
397 float x = ringRadius * Math.Sin(angleInc * i);
398 float z = ringRadius * Math.Cos(angleInc * i);
400 partPos[0] = partPos[0] +
x;
401 partPos[2] = partPos[2] + z;
403 SpawnParticles(props, pos, partPos, partCount);
408 InsertParticles(props, partCount, partId);
411 protected void SpawnParticles(ParticlePropertiesArray props, vector centerPos, vector partPos, inout
int count)
416 for (
int layer = 0; layer <= m_VerticalLayers; ++layer)
418 partPos[1] = partPos[1] + (m_VerticalOffset * layer);
421 if (count < PARTICLES_MAX && Math.IsInRange(partPos[1], centerPos[1] - m_NegativeHeight, centerPos[1] + m_PositiveHeight))
423 props.Insert(ParticleProperties(partPos, ParticlePropertiesFlags.PLAY_ON_CREATION, null,
GetGame().GetSurfaceOrientation( partPos[0], partPos[2] ),
this));
429 private void InsertParticles(ParticlePropertiesArray props,
int count,
int partId)
431 m_ToxicClouds.Reserve(count);
435 array<ParticleSource> createdParticles = gPM.CreateParticlesByIdArr(partId, props, count);
436 if (createdParticles.Count() != count)
438 if (gPM.IsFinishedAllocating())
440 ErrorEx(
string.Format(
"Not enough particles in pool for EffectArea: %1",
m_Name));
458 foreach (ParticleSource p : particles)
460 if (p.GetOwner() ==
this)
462 m_ToxicClouds.Insert(p);
467 int GetRequesterIndex(
string type)
469 typename t = type.
ToType();
484 #ifdef DIAG_DEVELOPER
485 #ifdef EFFECT_AREA_VISUAL_DEBUG
492 if (Class.CastTo(m_Trigger,
GetGame().CreateObjectEx(m_TriggerType, pos,
ECE_NONE)))
495 float centerHeightCorrection = (m_PositiveHeight - m_NegativeHeight) * 0.5;
497 m_Trigger.SetCollisionCylinderTwoWay(radius, -(m_NegativeHeight + centerHeightCorrection), (m_PositiveHeight - centerHeightCorrection));
498 m_Trigger.SetPosition(pos);
501 #ifdef DIAG_DEVELOPER
502 #ifdef EFFECT_AREA_VISUAL_DEBUG
511 vector colliderPosDebug = pos;
513 colliderPosDebug[1] = pos[1] + (m_PositiveHeight - centerHeightCorrection);
514 m_DebugTargets.Insert(
Debug.DrawSphere(colliderPosDebug, 0.15, 0x1f0000ff,
ShapeFlags.NOZWRITE));
517 m_DebugTargets.Insert(
Debug.DrawSphere(pos, 0.15, 0x1fff0000,
ShapeFlags.NOZWRITE));
521 colliderPosDebug[1] = pos[1] - (m_NegativeHeight + centerHeightCorrection);
522 m_DebugTargets.Insert(
Debug.DrawSphere(colliderPosDebug, 0.15, 0x1f00ff00,
ShapeFlags.NOZWRITE));
525 float triggerHeight = (m_PositiveHeight + m_NegativeHeight);
526 m_DebugTargets.Insert(
Debug.DrawCylinder(pos, radius, triggerHeight, 0x1f0000ff,
ShapeFlags.TRANSP|
ShapeFlags.NOZWRITE));
531 if ( m_Trigger.IsInherited(EffectTrigger))
534 EffectTrigger.Cast(m_Trigger).SetLocalEffects(m_AroundParticleID, m_TinyParticleID, m_PPERequesterIdx);
536 m_Trigger.
Init(
this, m_EffectsPriority);
553 if ( (
GetGame().IsClient() || !
GetGame().IsMultiplayer()) && m_ToxicClouds )
555 foreach ( Particle p : m_ToxicClouds )
561 super.EEDelete( parent );
566 player.IncreaseEffectAreaCount();
570 player.DecreaseEffectAreaCount();
573 #ifdef DIAG_DEVELOPER
574 #ifdef EFFECT_AREA_VISUAL_DEBUG
575 protected ref array<Shape> m_DebugTargets =
new array<Shape>();
579 foreach (
Shape shape : shapes)
580 Debug.RemoveShape(shape);
eBleedingSourceType m_Type
override void OnPlayerExitServer(PlayerBase player, EffectTrigger trigger)
override void OnPlayerEnterServer(PlayerBase player, EffectTrigger trigger)
override void InitZoneServer()
override void InitZoneClient()
override void EEDelete(EntityAI parent)
override void SetupZoneData(EffectAreaParams params)
override void OnParticleAllocation(ParticleManager pm, array< ParticleSource > particles)
override bool DisableVicinityIcon()
class DayZProfilesOptions UNDEFINED
void CleanupDebugShapes(array< Shape > shapesArr)
DEPRECATED.
vector m_Position
Cached world position.
enum eZoneType HOT_SPRING
override void OnCEUpdate()
override bool CanPutInCargo(EntityAI parent)
override bool CanPutIntoHands(EntityAI parent)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
proto native float SurfaceY(float x, float z)
proto native void ObjectDelete(Object obj)
void Init(EffectArea area, int priority)
int GetRequesterIDX()
Returns requester index.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
@ STATIC
Static objects are included in the query.
@ DYNAMIC
Dynamic objects are included in the query.
class JsonUndergroundAreaTriggerData GetPosition
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...