DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ContaminatedArea_Dynamic.c
См. документацию.
1// The parameters for the explosion light when creating dynamic area
3{
4 protected float m_DefaultBrightness = 10;
5 protected float m_DefaultRadius = 100;
6
7 void ShellLight()
8 {
9 SetVisibleDuringDaylight(false);
10 SetRadiusTo(m_DefaultRadius);
11 SetBrightnessTo(m_DefaultBrightness);
12 SetFlareVisible(false);
13 SetAmbientColor(1.0, 1.0, 0.3);
14 SetDiffuseColor(1.0, 1.0, 0.3);
15 SetLifetime(0.15);
16 SetDisableShadowsWithinRadius(-1);
17 SetCastShadow( false );
18 }
19}
20
21// The dynamic Contaminated area, using it's own default settings
22class ContaminatedArea_Dynamic : ContaminatedArea_DynamicBase
23{
24 protected vector m_OffsetPos; // This will be the position at which we spawn all future airborne FX
25 protected ref Timer m_StartupTimer;
26 protected ref Timer m_FXTimer;
28 protected ShellLight m_ShellLight; // Light used upon ariborne shell detonation
29
30 // Constants used for startup events
32 const int AREA_SETUP_DELAY = 10;
33 const float AIRBORNE_FX_OFFSET = 50;
34 const float ARTILLERY_SHELL_SPEED = 100; // Units per second
35
36 // Item Spawning upon area creation, the 4 arrays bellow have to have the same amount of elements
37 const ref array<string> SPAWN_ITEM_TYPE = {"Grenade_ChemGas"};//item classnames
38 const ref array<int> SPAWN_ITEM_COUNT = {Math.RandomIntInclusive(2,5)};//how many of each type
39 const ref array<float> SPAWN_ITEM_RAD_MIN = {5};//min distance the item will be spawned from the area position(epicenter)
40 const ref array<float> SPAWN_ITEM_RAD_MAX = {15};//max distance the item will be spawned from the area position(epicenter)
41
42 override void EEOnCECreate()
43 {
44 // We get the PPE index for future usage and synchronization ( we must do it here for dynamic as it is not read through file )
45 m_PPERequesterIdx = GetRequesterIndex(m_PPERequesterType);
46
47 // If this is the first initialization, we delay it in order to play cool effects
48 if (m_DecayState == eAreaDecayStage.INIT)
49 {
50 vector areaPos = GetPosition();
51 m_OffsetPos = areaPos;
53 vector closestPoint = areaPos;
54
55 // play artillery sound, sent to be played for everyone on server
56 array<vector> artilleryPoints = g_Game.GetMission().GetWorldData().GetArtyFiringPos();
57 int index = 0;
58 foreach (int i, vector artilleryPoint : artilleryPoints)
59 {
60 int dist = 0;
61 int temp = vector.DistanceSq(artilleryPoint, areaPos);
62 if (temp < dist || dist == 0)
63 {
64 dist = temp;
65 index = i;
66 }
67 }
68
69 closestPoint = artilleryPoints.Get(index);
70
71 // We calculate the delay depending on distance from firing position to simulate shell travel time
72 float delay = vector.Distance(closestPoint, areaPos);
73 delay = delay / ARTILLERY_SHELL_SPEED;
74 delay += AIRBORNE_EXPLOSION_DELAY; // We add the base, minimum time ( no area can start before this delay )
75
76 Param3<vector, vector, float> pos = new Param3<vector, vector, float>(closestPoint, areaPos, delay);
78 // We send the message with this set of coords
79 params.Insert(pos);
80 g_Game.RPC(null, ERPCs.RPC_SOUND_ARTILLERY_SINGLE, params, true);
81
83 m_FXTimer.Run(delay, this, "PlayFX");
84
85 delay += AREA_SETUP_DELAY; // We have an additional delay between shell detonation and finalization of area creation
86 // setup zone
88 m_StartupTimer.Run(delay, this, "InitZone");
89 }
90
91 SetSynchDirty();
92 }
93
95 {
96 super.OnVariablesSynchronized();
97
98 switch (m_DecayState)
99 {
100 case eAreaDecayStage.START:
102 break;
103 }
104 }
105
106 override void Tick()
107 {
109 {
110 // The second state of decay, further reduction of particle density and size
111 SetDecayState( eAreaDecayStage.DECAY_END );
112 }
114 {
115 // The first state of decay, slight reduction in particle density and size
116 SetDecayState( eAreaDecayStage.DECAY_START );
117 }
118
119 }
120
121 override void SetupZoneData(EffectAreaParams params)
122 {
123 params.m_ParamName = string.Format("Dynamic area (%1)", m_Position.ToString());
124 params.m_ParamPartId = ParticleList.CONTAMINATED_AREA_GAS_BIGASS;
125 params.m_ParamAroundPartId = ParticleList.CONTAMINATED_AREA_GAS_AROUND;
126 params.m_ParamTinyPartId = ParticleList.CONTAMINATED_AREA_GAS_TINY;
127 params.m_ParamPosHeight = 7;
128 params.m_ParamNegHeight = 10;
129 params.m_ParamRadius = 120;
130 params.m_ParamInnerRings = 1;
131 params.m_ParamInnerSpace = 40;
132 params.m_ParamOuterSpace = 30;
133 params.m_ParamOuterOffset = 0;
134 params.m_ParamTriggerType = "ContaminatedTrigger_Dynamic";
135
136 super.SetupZoneData(params);
137 }
138
139 override void DeferredInit()
140 {
141 // We make sure we have the particle array
142 if (!m_ToxicClouds)
143 m_ToxicClouds = new array<Particle>();
144
148
149 SetupZoneData(new EffectAreaParams);
150
151 // If a player arrives slightly later during the creation process we check if playing the flare FX is relevant
152 if (m_DecayState == eAreaDecayStage.INIT)
153 PlayFlareVFX();
154
155 if (m_DecayState >= eAreaDecayStage.LIVE)
156 InitZone(); // If it has already been created, we simply do the normal setup, no cool effects, force the LIVE state
157
158 super.DeferredInit();
159 }
160
161 override void InitZoneServer()
162 {
163 SpawnItems();
164
165 super.InitZoneServer();
166 }
167
169 {
170 //Print("---------============ Spawning items at pos:"+m_Position);
171 foreach (int j, string type : SPAWN_ITEM_TYPE)
172 {
173 //Print("----------------------------------");
174 for (int i = 0; i < SPAWN_ITEM_COUNT[j]; ++i)
175 {
176 vector randomDir2d = vector.RandomDir2D();
178 vector spawnPos = m_Position + (randomDir2d * randomDist);
180 vector mat[4];
182 mat[3] = spawnPos;
183 il.SetGround(null, mat);
184 //Print("Spawning item:"+ type + " at position:" + il.GetPos());
185 g_Game.CreateObjectEx(type, il.GetPos(), ECE_PLACE_ON_SURFACE);
186 }
187 }
188 }
189
190 override void CreateTrigger(vector pos, int radius)
191 {
192 super.CreateTrigger(pos, radius);
193
194 // This handles the specific case of dynamic triggers as some additionnal parameters are present
195 ContaminatedTrigger_Dynamic dynaTrigger = ContaminatedTrigger_Dynamic.Cast( m_Trigger );
196 if ( dynaTrigger )
197 {
198 dynaTrigger.SetLocalEffects( m_AroundParticleID, m_TinyParticleID, m_PPERequesterIdx );
199 dynaTrigger.SetAreaState( m_DecayState );
200 }
201 }
202
203 void PlayFX()
204 {
205 if (g_Game.IsServer())
206 {
207 Param1<vector> pos = new Param1<vector>(vector.Zero); // The value to be sent through RPC
208 array<ref Param> params = new array<ref Param>(); // The RPC params
209
210 // We send the message with this set of coords
211 pos.param1 = m_OffsetPos;
212 params.Insert(pos);
213 g_Game.RPC(null, ERPCs.RPC_SOUND_CONTAMINATION, params, true);
214
215 // We go to the next stage
217 SetSynchDirty();
218 }
219 }
220
222 {
224 }
225
227 {
228 if ( g_Game.IsClient() || ( g_Game.IsServer() && !g_Game.IsMultiplayer() ) )
229 {
230 // We spawn locally the dummy object which will be used to move and manage the particle
231 DynamicArea_Flare dummy = DynamicArea_Flare.Cast( g_Game.CreateObjectEx( "DynamicArea_Flare", m_OffsetPos, ECE_SETUP | ECE_LOCAL ) );
232
233 // We add some light to reinforce the effect
234 m_FlareLight = FlareLightContamination.Cast(ScriptedLightBase.CreateLight( FlareLightContamination, m_OffsetPos ));
235 }
236 }
237}
const int ECE_LOCAL
Определения CentralEconomy.c:24
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int ECE_SETUP
Определения CentralEconomy.c:9
override void DeferredInit()
Определения ContaminatedArea.c:49
override void InitZoneServer()
Определения ContaminatedArea.c:56
void PlayFlareVFX()
Определения ContaminatedArea_Dynamic.c:226
ref Timer m_FXTimer
Определения ContaminatedArea_Dynamic.c:26
const int AIRBORNE_EXPLOSION_DELAY
Определения ContaminatedArea_Dynamic.c:31
const int AREA_SETUP_DELAY
Определения ContaminatedArea_Dynamic.c:32
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
override void Tick()
Определения ContaminatedArea_Dynamic.c:106
void PlayExplosionLight()
Определения ContaminatedArea_Dynamic.c:221
ShellLight m_OffsetPos
void SpawnItems()
Определения ContaminatedArea_Dynamic.c:168
const float AIRBORNE_FX_OFFSET
Определения ContaminatedArea_Dynamic.c:33
const ref array< string > SPAWN_ITEM_TYPE
Определения ContaminatedArea_Dynamic.c:37
const ref array< int > SPAWN_ITEM_COUNT
Определения ContaminatedArea_Dynamic.c:38
const ref array< float > SPAWN_ITEM_RAD_MIN
Определения ContaminatedArea_Dynamic.c:39
FlareLight m_FlareLight
Определения ContaminatedArea_Dynamic.c:27
override void OnVariablesSynchronized()
Определения ContaminatedArea_Dynamic.c:94
void PlayFX()
Определения ContaminatedArea_Dynamic.c:203
const ref array< float > SPAWN_ITEM_RAD_MAX
Определения ContaminatedArea_Dynamic.c:40
const float ARTILLERY_SHELL_SPEED
Определения ContaminatedArea_Dynamic.c:34
ShellLight m_ShellLight
Определения ContaminatedArea_Dynamic.c:28
override void SetupZoneData(EffectAreaParams params)
Определения ContaminatedArea_Dynamic.c:121
ref Timer m_StartupTimer
Определения ContaminatedArea_Dynamic.c:25
override void InitZone()
Определения ContaminatedArea_DynamicBase.c:61
float GetFinishDecayLifetime()
Определения ContaminatedArea_DynamicBase.c:40
void ContaminatedArea_DynamicBase()
Определения ContaminatedArea_DynamicBase.c:22
enum eAreaDecayStage m_DecayState
float GetStartDecayLifetime()
Определения ContaminatedArea_DynamicBase.c:35
eAreaDecayStage
Определения ContaminatedArea_DynamicBase.c:2
void SetDecayState(int newState)
Определения ContaminatedArea_DynamicBase.c:46
void ContaminatedTrigger_Dynamic()
Определения ContaminatedTrigger.c:96
DayZGame g_Game
Определения DayZGame.c:3942
ERPCs
Определения ERPCs.c:2
vector m_Position
Cached world position.
Определения Effect.c:43
float GetRemainingTime()
Определения NotificationSystem.c:40
void CreateTrigger()
Определения TrapBase.c:465
Определения FlareLight.c:46
InventoryLocation.
Определения InventoryLocation.c:30
Определения EnMath3D.c:28
Определения EnMath.c:7
static const int CONTAMINATED_AREA_GAS_BIGASS
Определения ParticleList.c:303
static const int CONTAMINATED_AREA_GAS_AROUND
Определения ParticleList.c:302
static const int CONTAMINATED_AREA_GAS_TINY
Определения ParticleList.c:301
Определения ParticleList.c:12
float m_DefaultRadius
Определения ContaminatedArea_Dynamic.c:5
void ShellLight()
Определения ContaminatedArea_Dynamic.c:7
float m_DefaultBrightness
Определения ContaminatedArea_Dynamic.c:4
Определения DayZPlayerImplement.c:39
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:123
static vector RandomDir2D()
Returns randomly generated XZ unit vector with the Y(up) axis set to 0.
Определения EnConvert.c:273
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:119
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
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10