Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ammunitionpiles.c
Go to the documentation of this file.
3 {
4  static ref map<string, float> m_AmmoWeightByBulletType = new map<string, float>();
5 
6  static float GetAmmoWeightByBulletType(string bulletType)
7  {
8  if (m_AmmoWeightByBulletType.Contains(bulletType))
9  {
10  return m_AmmoWeightByBulletType.Get(bulletType);
11  }
12  else
13  {
14  float ammoWeight;
15  string ammoTypeName;
16  GetGame().ConfigGetText( string.Format("CfgAmmo %1 spawnPileType", bulletType) , ammoTypeName);
17  if (ammoTypeName)
18  ammoWeight = GetGame().ConfigGetFloat(string.Format("CfgMagazines %1 weight", ammoTypeName));
19  else
20  ErrorEx("empty 'spawnPileType' for bullet type:" + bulletType);
21  if (ammoWeight)
22  m_AmmoWeightByBulletType.Insert(bulletType, ammoWeight);
23  return ammoWeight;
24  }
25  }
26 
27  override void SetActions()
28  {
29  super.SetActions();
30 
32  }
33 
34  override bool IsAmmoPile()
35  {
36  return true;
37  }
38 
39  override protected float GetWeightSpecialized(bool forceRecalc = false)
40  {
41  #ifdef DEVELOPER
42  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
43  {
44  WeightDebugData data = WeightDebug.GetWeightDebug(this);
45  data.SetCalcDetails("TAmmo: ("+GetAmmoCount()+"(Ammo count) * "+ GetConfigWeightModifiedDebugText());
46  }
47  #endif
48 
49  return GetAmmoCount() * GetConfigWeightModified();
50  }
51 
52  override void SetQuantityToMinimum()
53  {
54  ServerSetAmmoCount(1);
55  }
56 
57  override void SetFromProjectile(ProjectileStoppedInfo info)
58  {
59  float dmgPerUse = GetGame().ConfigGetFloat("cfgAmmo " + info.GetAmmoType() + " dmgPerUse");
60  float totalDmg = info.GetProjectileDamage() + dmgPerUse;
61  float health = Math.Max(1 - totalDmg, 0);
62 
63  SetQuantityToMinimum();
64  SetHealth01("","", health);
65 
66  // SetCartridgeDamageAtIndex() MUST be called AFTER SetHealth01()!!
67  // otherwise, decreasing health by less than an entire health level get ignored
68  SetCartridgeDamageAtIndex(0, totalDmg);
69  }
70 };
71 
91 {
92  override bool IsInventoryVisible()
93  {
95  return CanBeActionTarget();
96  }
97 
98  override bool CanBeActionTarget()
99  {
100  if (super.CanBeActionTarget())
101  {
102  EntityAI parent = EntityAI.Cast(GetParent());
103  if (parent)
104  {
105  return !parent.IsManagingArrows();
106  }
107  }
108  return true;
109  }
110 
111  override void EEParentedTo(EntityAI parent)
112  {
113  if (!parent)
114  return;
115 
116  ArrowManagerBase arrowManager = parent.GetArrowManager();
117  if (arrowManager)
118  {
119  arrowManager.AddArrow(this);
120  }
121  }
122 
123  override void EEParentedFrom(EntityAI parent)
124  {
125  if (!parent)
126  return;
127 
128  ArrowManagerBase arrowManager = parent.GetArrowManager();
129  if (arrowManager)
130  {
131  arrowManager.RemoveArrow(this);
132  }
133  }
134 }
135 
136 class Ammo_DartSyringe: Ammunition_Base {};
142 
143 //bolts
145 
146 class Ammo_ImprovisedBolt_1 : Bolt_Base
147 {
148  override void SetActions()
149  {
150  super.SetActions();
151 
153  }
154 }
155 
157 class Ammo_CupidsBolt : Bolt_Base
158 {
159  override void EEParentedTo(EntityAI parent)
160  {
161  Delete();
162  }
163 
164  override void EEParentedFrom(EntityAI parent);
165 
166  static void PlayOnHitParticle(vector position)
167  {
168  ParticleManager.GetInstance().PlayInWorld(ParticleList.BOLT_CUPID_HIT, position);
169  }
170 }
171 
172 // 40mm
173 
175 {
176  override bool IsTakeable()
177  {
178  return GetAnimationPhase("Visibility") == 0;
179  }
180 
181  override bool IsInventoryVisible()
182  {
183  if (!super.IsInventoryVisible())
184  {
185  return false;
186  }
187 
188  return IsTakeable();
189  }
190 };
191 
193 {
194  override bool ShootsExplosiveAmmo()
195  {
196  return true;
197  }
198 
199  override void OnActivatedByItem(notnull ItemBase item)
200  {
201  if (GetGame().IsServer())
202  {
203  DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", item.GetPosition(), DamageType.EXPLOSION);
204  }
205  }
206 
207  override void EEKilled(Object killer)
208  {
209  super.EEKilled(killer);
210  DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", GetPosition(), DamageType.EXPLOSION);
211  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
212  }
213 
214  override void OnDamageDestroyed(int oldLevel)
215  {
216  super.OnDamageDestroyed(oldLevel);
217  #ifndef SERVER
218  ClearFlags(EntityFlags.VISIBLE, false);
219  #endif
220  }
221 }
222 //class Ammo_40mm_Grenade_Gas: Ammo_40mm_Base {};
223 class Ammo_40mm_ChemGas: Ammo_40mm_Base
224 {
225  override void OnActivatedByItem(notnull ItemBase item)
226  {
227  if (GetGame().IsServer())
228  {
229  GetGame().CreateObject("ContaminatedArea_Local", item.GetPosition());
230  }
231  }
232 
233  override void EEKilled(Object killer)
234  {
235  super.EEKilled(killer);
236  GetGame().CreateObject("ContaminatedArea_Local", GetPosition());
237  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
238  }
239 
240  override void OnDamageDestroyed(int oldLevel)
241  {
242  super.OnDamageDestroyed(oldLevel);
243 
244  #ifndef SERVER
245  ClearFlags(EntityFlags.VISIBLE, false);
246  ParticleManager.GetInstance().PlayInWorld(ParticleList.GRENADE_CHEM_BREAK, GetPosition());
247  #endif
248  }
249 
250 
251 }
252 
254 {
255  protected Particle m_ParticleSmoke;
256  protected float m_ParticleLifetime;
257  protected int m_ParticleId;
258  protected bool m_Activated;
259 
261  {
262  RegisterNetSyncVariableBool("m_Activated");
263  }
264 
265  override void OnVariablesSynchronized()
266  {
267  super.OnVariablesSynchronized();
268 
269  if (m_Activated)
270  {
271  #ifndef SERVER
272  string particleStrIdentifier = GetGame().ConfigGetTextOut(string.Format("CfgMagazines %1 particleStrIdentifier", GetType()));
273  m_ParticleId = ParticleList.GetParticleIDByName(particleStrIdentifier);
274  if (m_ParticleId > 0)
275  {
276  m_ParticleSmoke = ParticleManager.GetInstance().PlayOnObject(m_ParticleId, this);
277  m_ParticleSmoke.SetWiggle(7, 0.3);
278  }
279  #endif
280  }
281  }
282 
283  protected void Activate()
284  {
285  m_ParticleLifetime = GetGame().ConfigGetFloat(string.Format("CfgMagazines %1 particleLifeTime", GetType()));
286  m_Activated = true;
287  SetSynchDirty();
288 
289  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, m_ParticleLifetime * 1000);
290  }
291 
293  override void EEKilled(Object killer)
294  {
295  //analytics (behaviour from EntityAI)
296  GetGame().GetAnalyticsServer().OnEntityKilled(killer, this);
297  }
298 
299  override void EEDelete(EntityAI parent)
300  {
301  #ifndef SERVER
302  if (m_ParticleSmoke)
303  {
304  m_ParticleSmoke.Stop();
305  }
306  #endif
307 
308  super.EEDelete(parent);
309  }
310 
311  override bool CanPutInCargo( EntityAI parent )
312  {
313  return !m_Activated;
314  }
315 
316  override void OnActivatedByItem(notnull ItemBase item)
317  {
318  SetHealth("", "", 0.0);
319  Activate();
320  }
321 }
322 
323 class Ammo_40mm_Smoke_Red: Ammo_40mm_Smoke_ColorBase {};
ItemBase
Definition: inventoryitem.c:730
ProjectileStoppedInfo
Definition: dayzgame.c:17
GetGame
proto native CGame GetGame()
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
Ammo_556x45Tracer
Definition: ammunitionpiles.c:78
Ammo_308Win
Definition: ammunitionpiles.c:73
Ammo_545x39Tracer
Definition: ammunitionpiles.c:89
ClearFlags
proto native int ClearFlags(int flags, bool immedUpdate=true)
OnActivatedByItem
Ammo_40mm_Explosive Ammo_40mm_Base OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Definition: ammunitionpiles.c:225
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
Ammo_ImprovisedBolt_2
Definition: ammunitionpiles.c:156
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
Ammo_GrenadeM4
Definition: ammunitionpiles.c:141
Ammo_40mm_Smoke_Black
Definition: ammunitionpiles.c:326
Ammo_45ACP
Definition: ammunitionpiles.c:72
Ammo_762x39Tracer
Definition: ammunitionpiles.c:82
WeightDebugData
Definition: debug.c:939
SetActions
Ammo_HuntingBolt Bolt_Base SetActions()
Definition: ammunitionpiles.c:148
Ammo_LAW_HE
Definition: ammunitionpiles.c:140
EEParentedFrom
override void EEParentedFrom(EntityAI parent)
Ammo_RPG7_AP
Definition: ammunitionpiles.c:139
Ammo_545x39
Definition: ammunitionpiles.c:88
Ammo_357
Definition: ammunitionpiles.c:87
Ammunition_Base
ammo pile base
Definition: ammunitionpiles.c:2
Ammo_40mm_Base
Definition: ammunitionpiles.c:174
Ammo_RPG7_HE
Definition: ammunitionpiles.c:138
ErrorEx
enum ShapeType ErrorEx
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
OnDamageDestroyed
override void OnDamageDestroyed(int oldLevel)
Definition: ammunitionpiles.c:187
ParticleList
Definition: particlelist.c:11
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
Ammo_40mm_Smoke_Green
Definition: ammunitionpiles.c:324
Ammo_308WinTracer
Definition: ammunitionpiles.c:74
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
ActionCraftBoltsFeather
Definition: actioncraftboltsfeather.c:11
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
EEKilled
override void EEKilled(Object killer)
Definition: ammunitionpiles.c:180
Ammo_762x54
Definition: ammunitionpiles.c:79
Ammo_556x45
Definition: ammunitionpiles.c:77
Bolt_Base
Definition: ammunitionpiles.c:90
ActionSortAmmoPile
Definition: actionsortammopile.c:9
Ammo_40mm_Smoke_ColorBase
Definition: ammunitionpiles.c:253
Ammo_9x19
Definition: ammunitionpiles.c:75
Ammo_380
Definition: ammunitionpiles.c:76
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
Ammo_762x54Tracer
Definition: ammunitionpiles.c:80
Ammo_762x39
Definition: ammunitionpiles.c:81
Ammo_12gaSlug
Definition: ammunitionpiles.c:86
Ammo_22
Definition: ammunitionpiles.c:84
Ammo_9x39
Definition: ammunitionpiles.c:83
Ammo_12gaPellets
Definition: ammunitionpiles.c:85
Math
Definition: enmath.c:6
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
Magazine_Base
Magazine Magazine_Base
Definition: magazine.c:1
Ammo_HuntingBolt
Definition: ammunitionpiles.c:144
ArrowManagerBase
Definition: arrowmanagerbase.c:1
EntityAI
Definition: building.c:5
EEParentedTo
Ammo_40mm_Base EEParentedTo
m_ParticleSmoke
protected Particle m_ParticleSmoke
particle
Definition: smokegrenadebase.c:23
Ammo_40mm_Smoke_White
Definition: ammunitionpiles.c:325
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
Ammo_40mm_Explosive
Definition: ammunitionpiles.c:192
Ammo_Flare
Definition: ammunitionpiles.c:137