DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ContaminatedArea_Dynamic.c
См. документацию.
2{
3 INIT = 1, // The dynamic area is initializing
4 START = 2, // The dynamic area is starting
5 LIVE = 3, // The dynamic area is live
6 DECAY_START = 4, // The dynamic area decay has started
7 DECAY_END = 5, // The dynamic area will soon be deleted
8}
9
10// The parameters for the explosion light when creating dynamic area
11class ShellLight extends PointLightBase
12{
13 protected float m_DefaultBrightness = 10;
14 protected float m_DefaultRadius = 100;
15
17 {
18 SetVisibleDuringDaylight(false);
19 SetRadiusTo(m_DefaultRadius);
20 SetBrightnessTo(m_DefaultBrightness);
21 SetFlareVisible(false);
22 SetAmbientColor(1.0, 1.0, 0.3);
23 SetDiffuseColor(1.0, 1.0, 0.3);
24 SetLifetime(0.15);
25 SetDisableShadowsWithinRadius(-1);
26 SetCastShadow( false );
27 }
28}
29
30// The dynamic Contaminated area, using it's own default settings
32{
33 protected ref Timer m_StartupTimer;
34 protected ref Timer m_FXTimer;
36 protected ShellLight m_ShellLight; // Light used upon ariborne shell detonation
37 protected vector m_OffsetPos; // This will be the position at which we spawn all future airborne FX
38 protected int m_DecayState = eAreaDecayStage.INIT; // The current state in which the area is
39
40 // Constants used for startup events
42 const int AREA_SETUP_DELAY = 10;
43 const float AIRBORNE_FX_OFFSET = 50;
44 const float ARTILLERY_SHELL_SPEED = 100; // Units per second
45
46 // Constants used for dissapearing events
47 const float DECAY_START_PART_SIZE = 32;
49 const float DECAY_END_PART_SIZE = 17;
51 const float START_DECAY_LIFETIME = 900;
52 const float FINISH_DECAY_LIFETIME = 300;
53
54 // Item Spawning upon area creation, the 4 arrays bellow have to have the same amount of elements
55 const ref array<string> SPAWN_ITEM_TYPE = {"Grenade_ChemGas"};//item classnames
56 const ref array<int> SPAWN_ITEM_COUNT = {Math.RandomIntInclusive(2,5)};//how many of each type
57 const ref array<float> SPAWN_ITEM_RAD_MIN = {5};//min distance the item will be spawned from the area position(epicenter)
58 const ref array<float> SPAWN_ITEM_RAD_MAX = {15};//max distance the item will be spawned from the area position(epicenter)
59
60
62 {
63 RegisterNetSyncVariableInt("m_DecayState");
64 }
65
66 override void EEOnCECreate()
67 {
68 // We get the PPE index for future usage and synchronization ( we must do it here for dynamic as it is not read through file )
69 if ( GetGame().IsServer() )
70 m_PPERequesterIdx = GetRequesterIndex(m_PPERequesterType);
71
72 SetSynchDirty();
73
74 // If this is the first initialization, we delay it in order to play cool effects
75 if ( m_DecayState == eAreaDecayStage.INIT )
76 {
77 vector areaPos = GetPosition();
78 m_OffsetPos = areaPos;
80
81 // play artillery sound, sent to be played for everyone on server
83 vector closestPoint = areaPos;
84 int dist = 0;
85 int temp;
86 int index = 0;
87 for ( int i = 0; i < artilleryPoints.Count(); i++ )
88 {
89 temp = vector.DistanceSq( artilleryPoints.Get( i ), areaPos );
90 if ( temp < dist || dist == 0 )
91 {
92 dist = temp;
93 index = i;
94 }
95 }
96
97 closestPoint = artilleryPoints.Get( index );
98
99 // We calculate the delay depending on distance from firing position to simulate shell travel time
100 float delay = vector.Distance( closestPoint, areaPos );
101 delay = delay / ARTILLERY_SHELL_SPEED;
102 delay += AIRBORNE_EXPLOSION_DELAY; // We add the base, minimum time ( no area can start before this delay )
103
104 Param3<vector, vector, float> pos; // The value to be sent through RPC
105 array<ref Param> params; // The RPC params
106
107 // We prepare to send the message
108 pos = new Param3<vector, vector, float>( closestPoint, areaPos, delay );
109 params = new array<ref Param>;
110
111 // We send the message with this set of coords
112 params.Insert( pos );
113 GetGame().RPC( null, ERPCs.RPC_SOUND_ARTILLERY_SINGLE, params, true );
114
116 m_FXTimer.Run( delay, this, "PlayFX" );
117
118 delay += AREA_SETUP_DELAY; // We have an additional delay between shell detonation and finalization of area creation
119 // setup zone
121 m_StartupTimer.Run( delay, this, "InitZone" );
122 }
123 }
124
126 {
127 return GetLifetime();
128 }
129
131 {
133 }
134
136 {
138 }
139
140 override void Tick()
141 {
143 {
144 // The second state of decay, further reduction of particle density and size
145 SetDecayState( eAreaDecayStage.DECAY_END );
146 }
148 {
149 // The first state of decay, slight reduction in particle density and size
150 SetDecayState( eAreaDecayStage.DECAY_START );
151 }
152
153 }
154
155 // Set the new state of the Area
156 void SetDecayState( int newState )
157 {
158 if (m_DecayState != newState)
159 {
160 m_DecayState = newState;
161
162 // We update the trigger state values as we also want to update player bound effects
163 if ( m_Trigger )
164 ContaminatedTrigger_Dynamic.Cast( m_Trigger ).SetAreaState( m_DecayState );
165
166 SetSynchDirty();
167 }
168 }
169
170 override void EEInit()
171 {
172 // We make sure we have the particle array
173 if ( !m_ToxicClouds )
174 m_ToxicClouds = new array<Particle>;
175
176 // We set the values for dynamic area as these are not set through JSON and are standardized
177 m_Name = "Default Dynamic";
178 m_Radius = 120;
179 m_PositiveHeight = 7;
180 m_NegativeHeight = 10;
181 m_InnerRings = 1;
182 m_InnerSpacing = 40;
183 m_OuterSpacing = 30;
184 m_OuterRingOffset = 0;
185 m_Type = eZoneType.DYNAMIC;
186 m_TriggerType = "ContaminatedTrigger_Dynamic";
187
188 SetSynchDirty();
189
190 #ifdef DEVELOPER
191 // Debugs when placing entity by hand using internal tools
192 /*if ( GetGame().IsServer() && !GetGame().IsMultiplayer() )
193 {
194 Debug.Log("YOU CAN IGNORE THE FOLLOWING DUMP");
195 InitZone();
196 Debug.Log("YOU CAN USE FOLLOWING DATA PROPERLY");
197 }*/
198 #endif
199
202
203 // If a player arrives slightly later during the creation process we check if playing the flare FX is relevant
204 if ( m_DecayState == eAreaDecayStage.INIT )
205 PlayFlareVFX();
206
207 if ( m_DecayState == eAreaDecayStage.LIVE )
208 InitZone(); // If it has already been created, we simply do the normal setup, no cool effects, force the LIVE state
209 else if ( GetGame().IsClient() && m_DecayState > eAreaDecayStage.LIVE )
210 InitZoneClient(); // Same as before but without state forcing
211
212 super.EEInit();
213 }
214
215 // We spawn particles and setup trigger
216 override void InitZone()
217 {
219 SetSynchDirty();
220
221 super.InitZone();
222 }
223
224 override void InitZoneServer()
225 {
226 super.InitZoneServer();
227
228 SpawnItems();
229 // We create the trigger on server
230 if ( m_TriggerType != "" )
232 }
233
235 {
236 //Print("---------============ Spawning items at pos:"+m_Position);
237 foreach (int j, string type:SPAWN_ITEM_TYPE)
238 {
239 //Print("----------------------------------");
240 for (int i = 0; i < SPAWN_ITEM_COUNT[j]; i++)
241 {
242 vector randomDir2d = vector.RandomDir2D();
244 vector spawnPos = m_Position + (randomDir2d * randomDist);
246 vector mat[4];
248 mat[3] = spawnPos;
249 il.SetGround(NULL, mat);
250 //Print("Spawning item:"+ type + " at position:" + il.GetPos());
251 GetGame().CreateObjectEx(type, il.GetPos(), ECE_PLACE_ON_SURFACE);
252 }
253 }
254 }
255
256 override void InitZoneClient()
257 {
258 super.InitZoneClient();
259
260 if ( !m_ToxicClouds )
261 m_ToxicClouds = new array<Particle>;
262
263 // We spawn VFX on client
264 PlaceParticles( GetWorldPosition(), m_Radius, m_InnerRings, m_InnerSpacing, m_OuterRingToggle, m_OuterSpacing, m_OuterRingOffset, m_ParticleID );
265 }
266
268 {
269 super.OnParticleAllocation(pm, particles);
270
271 if ( m_DecayState > eAreaDecayStage.LIVE )
272 {
273 foreach ( ParticleSource p : particles )
274 {
275 if ( m_DecayState == eAreaDecayStage.DECAY_END )
276 {
277 p.SetParameter( 0, EmitorParam.BIRTH_RATE, DECAY_END_PART_BIRTH_RATE );
278 p.SetParameter( 0, EmitorParam.SIZE, DECAY_END_PART_SIZE );
279 }
280 else
281 {
282 p.SetParameter( 0, EmitorParam.BIRTH_RATE, DECAY_START_PART_BIRTH_RATE );
283 p.SetParameter( 0, EmitorParam.SIZE, DECAY_START_PART_SIZE );
284 }
285 }
286 }
287 }
288
289 override void CreateTrigger( vector pos, int radius )
290 {
291 super.CreateTrigger( pos, radius );
292
293 // This handles the specific case of dynamic triggers as some additionnal parameters are present
294 ContaminatedTrigger_Dynamic dynaTrigger = ContaminatedTrigger_Dynamic.Cast( m_Trigger );
295 if ( dynaTrigger )
296 {
297 dynaTrigger.SetLocalEffects( m_AroundParticleID, m_TinyParticleID, m_PPERequesterIdx );
298 dynaTrigger.SetAreaState( m_DecayState );
299 }
300 }
301
302 void PlayFX()
303 {
304 if ( GetGame().IsServer() )
305 {
306 Param1<vector> pos; // The value to be sent through RPC
307 array<ref Param> params; // The RPC params
308
309 // We prepare to send the message
310 pos = new Param1<vector>( vector.Zero );
311 params = new array<ref Param>;
312
313 // We send the message with this set of coords
314 pos.param1 = m_OffsetPos;
315 params.Insert( pos );
316 GetGame().RPC( null, ERPCs.RPC_SOUND_CONTAMINATION, params, true );
317
318 // We go to the next stage
320 SetSynchDirty();
321 }
322 }
323
325 {
327 }
328
330 {
331 if ( GetGame().IsClient() || ( GetGame().IsServer() && !GetGame().IsMultiplayer() ) )
332 {
333 // We spawn locally the dummy object which will be used to move and manage the particle
334 DynamicArea_Flare dummy = DynamicArea_Flare.Cast( GetGame().CreateObjectEx( "DynamicArea_Flare", m_OffsetPos, ECE_SETUP | ECE_LOCAL ) );
335
336 // We add some light to reinforce the effect
337 m_FlareLight = FlareLightContamination.Cast(ScriptedLightBase.CreateLight( FlareLightContamination, m_OffsetPos ));
338 }
339 }
340
341 override void EEDelete( EntityAI parent )
342 {
343 super.EEDelete( parent );
344 }
345
347 {
348 super.OnVariablesSynchronized();
349
350 if ( !m_ToxicClouds )
351 m_ToxicClouds = new array<Particle>;
352
353 switch ( m_DecayState )
354 {
355 case eAreaDecayStage.START:
357 break;
358 case eAreaDecayStage.LIVE:
360
361 break;
362 case eAreaDecayStage.DECAY_START:
363 {
364 // We go through all the particles bound to this area and update relevant parameters
365 //Debug.Log("We start decay");
366 foreach ( Particle p : m_ToxicClouds )
367 {
368 p.SetParameter( 0, EmitorParam.BIRTH_RATE, DECAY_START_PART_BIRTH_RATE );
369 p.SetParameter( 0, EmitorParam.SIZE, DECAY_START_PART_SIZE );
370 }
371
372 break;
373 }
374 case eAreaDecayStage.DECAY_END:
375 {
376 // We go through all the particles bound to this area and update relevant parameters
377 //Debug.Log("We finish decay");
378 foreach ( Particle prt : m_ToxicClouds )
379 {
380 prt.SetParameter( 0, EmitorParam.BIRTH_RATE, DECAY_END_PART_BIRTH_RATE );
381 prt.SetParameter( 0, EmitorParam.SIZE, DECAY_END_PART_SIZE );
382 }
383
384 break;
385 }
386 default:
387 break;
388 }
389 }
390}
eBleedingSourceType m_Type
Определения BleedingSource.c:25
float m_Radius
Определения AIGroupBehaviour.c:10
const int ECE_LOCAL
Определения CentralEconomy.c:24
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int ECE_SETUP
Определения CentralEconomy.c:9
float m_DefaultRadius
Определения ContaminatedArea_Dynamic.c:14
enum eAreaDecayStage m_DefaultBrightness
void ShellLight()
Определения ContaminatedArea_Dynamic.c:16
eAreaDecayStage
Определения ContaminatedArea_Dynamic.c:2
@ DECAY_START
Определения ContaminatedArea_Dynamic.c:6
@ DECAY_END
Определения ContaminatedArea_Dynamic.c:7
@ LIVE
Определения ContaminatedArea_Dynamic.c:5
void ContaminatedTrigger_Dynamic()
Определения ContaminatedTrigger.c:96
ERPCs
Определения ERPCs.c:2
vector m_Position
Cached world position.
Определения Effect.c:41
eZoneType
Определения EffectArea.c:3
class SEffectManager START
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
class SyncedValue m_Name
void CreateTrigger()
Определения TrapBase.c:475
proto native void RPC(Object target, int rpcType, notnull array< ref Param > params, bool guaranteed, PlayerIdentity recipient=null)
Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on ser...
proto native Object CreateObjectEx(string type, vector pos, int iFlags, int iRotation=RF_DEFAULT)
Creates object of certain type.
proto native Mission GetMission()
const ref array< float > SPAWN_ITEM_RAD_MAX
Определения ContaminatedArea_Dynamic.c:58
const int DECAY_END_PART_BIRTH_RATE
Определения ContaminatedArea_Dynamic.c:50
const float ARTILLERY_SHELL_SPEED
Определения ContaminatedArea_Dynamic.c:44
override void OnVariablesSynchronized()
Определения ContaminatedArea_Dynamic.c:346
ref Timer m_StartupTimer
Определения ContaminatedArea_Dynamic.c:33
override void InitZone()
Определения ContaminatedArea_Dynamic.c:216
const float FINISH_DECAY_LIFETIME
Определения ContaminatedArea_Dynamic.c:52
override void EEDelete(EntityAI parent)
Определения ContaminatedArea_Dynamic.c:341
override void InitZoneServer()
Определения ContaminatedArea_Dynamic.c:224
const float DECAY_START_PART_SIZE
Определения ContaminatedArea_Dynamic.c:47
float GetStartDecayLifetime()
Определения ContaminatedArea_Dynamic.c:130
void ContaminatedArea_Dynamic()
Определения ContaminatedArea_Dynamic.c:61
override void CreateTrigger(vector pos, int radius)
Определения ContaminatedArea_Dynamic.c:289
const float DECAY_END_PART_SIZE
Определения ContaminatedArea_Dynamic.c:49
override void EEInit()
Определения ContaminatedArea_Dynamic.c:170
const float AIRBORNE_FX_OFFSET
Определения ContaminatedArea_Dynamic.c:43
ShellLight m_ShellLight
Определения ContaminatedArea_Dynamic.c:36
const ref array< string > SPAWN_ITEM_TYPE
Определения ContaminatedArea_Dynamic.c:55
const float START_DECAY_LIFETIME
Определения ContaminatedArea_Dynamic.c:51
override void Tick()
Определения ContaminatedArea_Dynamic.c:140
const ref array< int > SPAWN_ITEM_COUNT
Определения ContaminatedArea_Dynamic.c:56
const int AREA_SETUP_DELAY
Определения ContaminatedArea_Dynamic.c:42
void SetDecayState(int newState)
Определения ContaminatedArea_Dynamic.c:156
override void OnParticleAllocation(ParticleManager pm, array< ParticleSource > particles)
Определения ContaminatedArea_Dynamic.c:267
const int AIRBORNE_EXPLOSION_DELAY
Определения ContaminatedArea_Dynamic.c:41
override void InitZoneClient()
Определения ContaminatedArea_Dynamic.c:256
float GetFinishDecayLifetime()
Определения ContaminatedArea_Dynamic.c:135
const ref array< float > SPAWN_ITEM_RAD_MIN
Определения ContaminatedArea_Dynamic.c:57
const int DECAY_START_PART_BIRTH_RATE
Определения ContaminatedArea_Dynamic.c:48
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:66
FlareLight m_FlareLight
Определения ContaminatedArea_Dynamic.c:35
Определения Building.c:6
Определения FlareLight.c:46
InventoryLocation.
Определения InventoryLocation.c:29
Определения EnMath3D.c:28
Определения EnMath.c:7
WorldData GetWorldData()
Определения gameplay.c:743
Определения EntityAI.c:95
Legacy way of using particles in the game.
Определения Particle.c:7
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:124
Определения DayZPlayerImplement.c:63
array< vector > GetArtyFiringPos()
Определения WorldData.c:247
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Zero
Определения EnConvert.c:110
static vector RandomDir2D()
Returns randomly generated XZ unit vector with the Y(up) axis set to 0.
Определения EnConvert.c:260
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
proto native CGame GetGame()
@ INIT
Определения EnEntity.c:81
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Определения EnMath3D.c:256
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
EmitorParam
Определения EnVisual.c:114
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
const int CALL_CATEGORY_GAMEPLAY
Определения tools.c:10