Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
woodbase.c
Go to the documentation of this file.
6
7class WoodBase extends Plant
8{
9
10 static bool m_IsCuttable;
11 static int m_PrimaryDropsAmount = -1;
12 static int m_SecondaryDropsAmount = -1;
13 static float m_ToolDamage = -1.0;
14 static float m_CycleTimeOverride = -1.0;
15 static string m_PrimaryOutput = ""; //some nonsensical item for debugging purposes
16 static string m_SecondaryOutput = ""; //some nonsensical item for debugging purposes
17 static string m_BarkType = "";
18
19 /*
20 bool m_IsCuttable;
21 int m_PrimaryDropsAmount = -1;
22 int m_SecondaryDropsAmount = -1;
23 float m_ToolDamage = -1.0;
24 float m_CycleTimeOverride = -1.0;
25 string m_PrimaryOutput = ""; //some nonsensical item for debugging purposes
26 string m_SecondaryOutput = ""; //some nonsensical item for debugging purposes
27 string m_BarkType = "";
28 */
29
30 void WoodBase()
31 {
32 //InitMiningValues();
33 }
34
35
37 {
38 //m_IsCuttable = false;
39 };
40
41 override bool IsWoodBase()
42 {
43 return true;
44 }
45
46 override bool IsCuttable()
47 {
48 return ConfigGetBool("isCuttable");
49 }
50
52 {
53 return true;
54 }
55
57 {
58 return true;
59 }
60
62 {
63 return ConfigGetInt("primaryDropsAmount");
64 }
65
67 {
68 return ConfigGetInt("secondaryDropsAmount");
69 }
70
72 {
73 return ConfigGetFloat("toolDamage");
74 }
75
77 {
78 return ConfigGetFloat("cycleTimeOverride");
79 }
80
82 {
83 return ConfigGetString("primaryOutput");
84 }
85
87 {
88 return ConfigGetString("secondaryOutput");
89 }
90
91 string GetBarkType()
92 {
93 return ConfigGetString("barkType");
94 }
95
96
97
99 {
100 if ( GetPrimaryDropsAmount() > 0 )
101 {
102 if ( IsTree() && item && ( item.KindOf("Knife") || item.IsInherited(Screwdriver) ) )
103 {
104 return -1;
105 }
106 else
107 {
108 return GetPrimaryDropsAmount();
109 }
110 }
111 else
112 {
113 if ( item && ( item.KindOf("Knife") || item.IsInherited(Screwdriver) ) )
114 {
115 return -1;
116 }
117 else if ( item && item.KindOf("Axe") )
118 {
119 return 3;
120 }
121 else
122 {
123 return 100;
124 }
125 }
126 }
127
129 {
130 if ( GetPrimaryDropsAmount() > 0 )
131 {
132 if ( IsTree() && item && type == EHarvestType.BARK )
133 {
134 return -1;
135 }
136 else
137 {
138 return GetPrimaryDropsAmount();
139 }
140 }
141 else
142 {
143 if ( item && type == EHarvestType.BARK )
144 {
145 return -1;
146 }
147 else if ( item && type == EHarvestType.NORMAL )
148 {
149 return 3;
150 }
151 else
152 {
153 return 100;
154 }
155 }
156 }
157
159 {
160 if ( IsTree() && item && ( item.KindOf("Knife") || item.IsInherited(Screwdriver) ) && GetBarkType() != "" )
161 {
162 output_map.Insert(GetBarkType(),1);
163 }
164 else
165 {
166 output_map.Insert(GetPrimaryOutput(),1);
167 }
168 }
169
171 {
172 if ( IsTree() && item && type == EHarvestType.BARK && GetBarkType() != "" )
173 {
174 output_map.Insert(GetBarkType(),1);
175 }
176 else
177 {
178 output_map.Insert(GetPrimaryOutput(),1);
179 }
180 }
181
183 {
184 if (GetToolDamage() > -1)
185 return GetToolDamage();
186
187 if ( IsTree() )
188 {
189 if ( item && item.KindOf("Knife") )
190 {
191 return 20;
192 }
193 else if ( item && item.KindOf("Axe") )
194 {
195 return 20;
196 }
197 else
198 {
199 return 0;
200 }
201 }
202 else
203 {
204 if ( item && item.KindOf("Knife") )
205 {
206 return 30;
207 }
208 else if ( item && item.KindOf("Axe") )
209 {
210 return 30;
211 }
212 else
213 {
214 return 0;
215 }
216 }
217 }
218
220 {
221 if (GetToolDamage() > -1)
222 return GetToolDamage();
223
224 if ( IsTree() )
225 {
226 if ( item && type == EHarvestType.BARK )
227 {
228 return 20;
229 }
230 else if ( item && type == EHarvestType.NORMAL )
231 {
232 return 20;
233 }
234 else
235 {
236 return 0;
237 }
238 }
239 else
240 {
241 if ( item && type == EHarvestType.BARK )
242 {
243 return 30;
244 }
245 else if ( item && type == EHarvestType.NORMAL )
246 {
247 return 30;
248 }
249 else
250 {
251 return 0;
252 }
253 }
254 }
255
256 override bool CanBeActionTarget()
257 {
258 return super.CanBeActionTarget() && !IsDamageDestroyed();
259 }
260}
261
262class TreeEffecterParameters : EffecterParameters
263{
264 float m_Radius;
265
266 void TreeEffecterParameters(string type, float lifespan, int radius)
267 {
268 m_Radius = radius;
269 }
270}
271
272class TreeEffecter : EffecterBase
273{
275 private float m_Radius = -1;
276 private float m_RadiusSync = -1;
277
278 void TreeEffecter()
279 {
280 if (!g_Game.IsServer() || !g_Game.IsMultiplayer())
281 {
283 }
284
285 RegisterNetSyncVariableFloat("m_RadiusSync");
286 }
287
288 override void Init(int id, EffecterParameters parameters)
289 {
290 super.Init(id, parameters);
291 TreeEffecterParameters par = TreeEffecterParameters.Cast(parameters);
292 SetRadius(par.m_Radius);
293 }
294
295 void SetRadius(float radius)
296 {
297 m_RadiusSync = radius;
298 Process();
299 }
300
301 override void OnVariablesSynchronized()
302 {
303 if (m_RadiusSync != m_Radius)
304 {
305 array<Object> objects = new array<Object>;
306 array<CargoBase> proxies = new array<CargoBase>;
307 EffectParticleGeneral newEffect;
308
309 foreach (EffectParticleGeneral oldEffect : m_Effects)
310 {
311 SEffectManager.DestroyEffect(oldEffect);
312 }
313
314 m_Effects.Clear();
315
316 g_Game.GetObjectsAtPosition(GetWorldPosition(), m_RadiusSync, objects, proxies);
317
318 for (int i = 0; i < objects.Count(); i++)
319 {
320 WoodBase plant = WoodBase.Cast(objects[i]);
321 if (plant)
322 {
323 string particle;
324 int particleID;
325 string configPath = "CfgNonAIVehicles " + plant.GetType() + " FxFallingParticleEffect particle";
326 g_Game.ConfigGetText(configPath, particle);
327
328 if (particle != "")
329 {
330 particleID = ParticleList.RegisterParticle(particle);
331 }
332
333 if (particleID > 0)
334 {
335 LOD lod = plant.GetLODByName(LOD.NAME_MEMORY);
336 Selection selection = lod.GetSelectionByName("ptcFalling");
337 if (selection)
338 {
339 vector selectionPos;
340 for (int j = 0; j < selection.GetVertexCount(); j++)
341 {
342 newEffect = new EffectParticleGeneral();
343 newEffect.SetParticle(particleID);
344 selectionPos = selection.GetVertexPosition(lod, j);
345 SEffectManager.PlayInWorld(newEffect, plant.GetPosition() + selectionPos);
346 m_Effects.Insert(newEffect);
347 }
348
349 //play accompanying sounds
350 selectionPos = ModelToWorld(selectionPos);
351 EffectSound sound = SEffectManager.PlaySoundEnviroment("snow_fallen_trees_SoundSet", selectionPos);
352 sound.SetAutodestroy(true);
353 }
354 }
355 }
356 }
357 }
358
360 {
361 foreach (EffectParticleGeneral effect : m_Effects)
362 {
363 switch (m_CommandSync)
364 {
365 case EffecterCommands.START:
366 if (effect && !effect.IsPlaying())
367 {
368 effect.SetParticle(effect.m_LastParticleID);
369 effect.Start();
370 }
371 break;
372
373 case EffecterCommands.STOP:
374 if (effect && effect.IsPlaying())
375 {
376 effect.Stop();
377 }
378 break;
379
380 case EffecterCommands.REACTIVATE0:
381 case EffecterCommands.REACTIVATE1:
382 if (effect)
383 {
384 effect.SetParticle(effect.m_LastParticleID);
385 }
386 if (!effect.IsPlaying())
387 {
388 effect.Start();
389 }
390 break;
391
392 default:
393 break;
394 }
395 }
397 }
398 }
399
400 void ~TreeEffecter()
401 {
402 if (m_Effects)
403 {
404 foreach (EffectParticleGeneral effect : m_Effects)
405 {
406 SEffectManager.DestroyEffect(effect);
407 }
408 }
409 }
410}
float m_Radius
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override void OnVariablesSynchronized()
DayZGame g_Game
Definition dayzgame.c:3942
override Widget Init()
Definition dayzgame.c:127
@ NORMAL
void EffecterParameters(string type, float lifespan)
void EffectParticleGeneral()
int m_Command
void EffecterBase()
void Process()
int m_CommandSync
string GetSecondaryOutput()
Definition woodbase.c:86
void InitMiningValues()
Definition woodbase.c:36
string GetBarkType()
Definition woodbase.c:91
float GetDamageToMiningItemEachDrop(ItemBase item)
Definition woodbase.c:182
int GetAmountOfDropsEx(ItemBase item, EHarvestType type)
Definition woodbase.c:128
void GetMaterialAndQuantityMapEx(ItemBase item, out map< string, int > output_map, EHarvestType type)
Definition woodbase.c:170
override bool IsCuttable()
Definition woodbase.c:46
void GetMaterialAndQuantityMap(ItemBase item, out map< string, int > output_map)
Definition woodbase.c:158
bool HasPlayerCollisionParticle()
Definition woodbase.c:51
float GetDamageToMiningItemEachDropEx(ItemBase item, EHarvestType type)
Definition woodbase.c:219
float GetToolDamage()
Definition woodbase.c:71
TreeEffecterParameters m_Effects
string GetPrimaryOutput()
Definition woodbase.c:81
override bool IsWoodBase()
Definition woodbase.c:41
bool HasPlayerCollisionSound()
Definition woodbase.c:56
int GetPrimaryDropsAmount()
Definition woodbase.c:61
enum EHarvestType m_IsCuttable
void WoodBase()
Definition woodbase.c:30
override bool CanBeActionTarget()
Definition woodbase.c:256
EHarvestType
Definition woodbase.c:2
@ BARK
Definition woodbase.c:4
int GetSecondaryDropsAmount()
Definition woodbase.c:66
float GetCycleTimeOverride()
Definition woodbase.c:76
int GetAmountOfDrops(ItemBase item)
Definition woodbase.c:98