DayZ 1.28
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
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 GetGame().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 super.DeferredInit();
142
143 // We make sure we have the particle array
144 if (!m_ToxicClouds)
145 m_ToxicClouds = new array<Particle>();
146
150
151 SetupZoneData(new EffectAreaParams);
152
153 // If a player arrives slightly later during the creation process we check if playing the flare FX is relevant
154 if (m_DecayState == eAreaDecayStage.INIT)
155 PlayFlareVFX();
156
157 if ( m_DecayState == eAreaDecayStage.LIVE )
158 InitZone(); // If it has already been created, we simply do the normal setup, no cool effects, force the LIVE state
159
160 super.DeferredInit();
161 }
162
163 override void InitZoneServer()
164 {
165 SpawnItems();
166
167 super.InitZoneServer();
168 }
169
171 {
172 //Print("---------============ Spawning items at pos:"+m_Position);
173 foreach (int j, string type : SPAWN_ITEM_TYPE)
174 {
175 //Print("----------------------------------");
176 for (int i = 0; i < SPAWN_ITEM_COUNT[j]; ++i)
177 {
178 vector randomDir2d = vector.RandomDir2D();
180 vector spawnPos = m_Position + (randomDir2d * randomDist);
182 vector mat[4];
184 mat[3] = spawnPos;
185 il.SetGround(NULL, mat);
186 //Print("Spawning item:"+ type + " at position:" + il.GetPos());
187 GetGame().CreateObjectEx(type, il.GetPos(), ECE_PLACE_ON_SURFACE);
188 }
189 }
190 }
191
192 override void CreateTrigger(vector pos, int radius)
193 {
194 super.CreateTrigger(pos, radius);
195
196 // This handles the specific case of dynamic triggers as some additionnal parameters are present
197 ContaminatedTrigger_Dynamic dynaTrigger = ContaminatedTrigger_Dynamic.Cast( m_Trigger );
198 if ( dynaTrigger )
199 {
200 dynaTrigger.SetLocalEffects( m_AroundParticleID, m_TinyParticleID, m_PPERequesterIdx );
201 dynaTrigger.SetAreaState( m_DecayState );
202 }
203 }
204
205 void PlayFX()
206 {
207 if (GetGame().IsServer())
208 {
209 Param1<vector> pos = new Param1<vector>(vector.Zero); // The value to be sent through RPC
210 array<ref Param> params = new array<ref Param>(); // The RPC params
211
212 // We send the message with this set of coords
213 pos.param1 = m_OffsetPos;
214 params.Insert(pos);
215 GetGame().RPC(null, ERPCs.RPC_SOUND_CONTAMINATION, params, true);
216
217 // We go to the next stage
219 SetSynchDirty();
220 }
221 }
222
224 {
226 }
227
229 {
230 if ( GetGame().IsClient() || ( GetGame().IsServer() && !GetGame().IsMultiplayer() ) )
231 {
232 // We spawn locally the dummy object which will be used to move and manage the particle
233 DynamicArea_Flare dummy = DynamicArea_Flare.Cast( GetGame().CreateObjectEx( "DynamicArea_Flare", m_OffsetPos, ECE_SETUP | ECE_LOCAL ) );
234
235 // We add some light to reinforce the effect
236 m_FlareLight = FlareLightContamination.Cast(ScriptedLightBase.CreateLight( FlareLightContamination, m_OffsetPos ));
237 }
238 }
239}
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:228
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:223
ShellLight m_OffsetPos
void SpawnItems()
Определения ContaminatedArea_Dynamic.c:170
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:205
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
ERPCs
Определения ERPCs.c:2
vector m_Position
Cached world position.
Определения Effect.c:43
float GetRemainingTime()
Определения NotificationSystem.c:40
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()
Определения FlareLight.c:46
InventoryLocation.
Определения InventoryLocation.c:29
Определения EnMath3D.c:28
Определения EnMath.c:7
WorldData GetWorldData()
Определения gameplay.c:743
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: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()
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
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/tools/tools.c:10