DayZ 1.24
Loading...
Searching...
No Matches
AmmunitionPiles.c
Go to the documentation of this file.
3{
5
7 {
10 else
11 {
12 float ammoWeight;
13 string ammoTypeName;
14 GetGame().ConfigGetText(string.Format("CfgAmmo %1 spawnPileType", bulletType), ammoTypeName);
15 if (ammoTypeName)
16 ammoWeight = GetGame().ConfigGetFloat(string.Format("CfgMagazines %1 weight", ammoTypeName));
17 else
18 ErrorEx("empty 'spawnPileType' for bullet type:" + bulletType);
19 if (ammoWeight)
21 return ammoWeight;
22 }
23 }
24
25 override void SetActions()
26 {
27 super.SetActions();
28
30 }
31
32 override bool IsAmmoPile()
33 {
34 return true;
35 }
36
37 override protected float GetWeightSpecialized(bool forceRecalc = false)
38 {
39#ifdef DEVELOPER
40 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
41 {
42 WeightDebugData data = WeightDebug.GetWeightDebug(this);
43 data.SetCalcDetails("TAmmo: (" + GetAmmoCount() + "(Ammo count) * " + GetConfigWeightModifiedDebugText());
44 }
45#endif
46
47 return GetAmmoCount() * GetConfigWeightModified();
48 }
49
50 override void SetQuantityToMinimum()
51 {
53 }
54
56 {
57 float dmgPerUse = GetGame().ConfigGetFloat("cfgAmmo " + info.GetAmmoType() + " dmgPerUse");
58 float totalDmg = info.GetProjectileDamage() + dmgPerUse;
59 float health = Math.Max(1 - totalDmg, 0);
60
62 SetHealth01("", "", health);
63
64 // SetCartridgeDamageAtIndex() MUST be called AFTER SetHealth01()!!
65 // otherwise, decreasing health by less than an entire health level get ignored
67 }
68};
69
89{
90 override bool IsInventoryVisible()
91 {
93 return CanBeActionTarget();
94 }
95
96 override bool CanBeActionTarget()
97 {
98 if (super.CanBeActionTarget())
99 {
100 EntityAI parent = EntityAI.Cast(GetParent());
101 if (parent)
102 return !parent.IsManagingArrows();
103 }
104 return true;
105 }
106
107 override void EEParentedTo(EntityAI parent)
108 {
109 if (!parent)
110 return;
111
112 ArrowManagerBase arrowManager = parent.GetArrowManager();
113 if (arrowManager)
114 arrowManager.AddArrow(this);
115 }
116
117 override void EEParentedFrom(EntityAI parent)
118 {
119 if (!parent)
120 return;
121
122 ArrowManagerBase arrowManager = parent.GetArrowManager();
123 if (arrowManager)
124 arrowManager.RemoveArrow(this);
125 }
126}
127
134
135//bolts
137
139{
140 override void SetActions()
141 {
142 super.SetActions();
143
145 }
146}
147
150{
151 override void EEParentedTo(EntityAI parent)
152 {
153 Delete();
154 }
155
156 override void EEParentedFrom(EntityAI parent);
157
159 {
160 ParticleManager.GetInstance().PlayInWorld(ParticleList.BOLT_CUPID_HIT, position);
161 }
162}
163
164// 40mm
165
167{
168 override bool IsTakeable()
169 {
170 return GetAnimationPhase("Visibility") == 0;
171 }
172
173 override bool IsInventoryVisible()
174 {
175 if (!super.IsInventoryVisible())
176 return false;
177
178 return IsTakeable();
179 }
181
183{
184 override bool ShootsExplosiveAmmo()
185 {
186 return true;
187 }
188
190 {
191 if (GetGame().IsServer())
192 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", item.GetPosition(), DamageType.EXPLOSION);
193 }
194
195 override void EEKilled(Object killer)
196 {
197 super.EEKilled(killer);
198 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", GetPosition(), DamageType.EXPLOSION);
199 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, 1000, false);
200 }
201
202 override void OnDamageDestroyed(int oldLevel)
203 {
204 super.OnDamageDestroyed(oldLevel);
205#ifndef SERVER
206 ClearFlags(EntityFlags.VISIBLE, false);
207#endif
208 }
209}
210//class Ammo_40mm_Grenade_Gas: Ammo_40mm_Base {};
212{
215 if (GetGame().IsServer())
216 GetGame().CreateObject("ContaminatedArea_Local", item.GetPosition());
217 }
218
219 override void EEKilled(Object killer)
220 {
221 super.EEKilled(killer);
222 GetGame().CreateObject("ContaminatedArea_Local", GetPosition());
223 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, 1000, false);
224 }
226 override void OnDamageDestroyed(int oldLevel)
227 {
228 super.OnDamageDestroyed(oldLevel);
229
230#ifndef SERVER
231 ClearFlags(EntityFlags.VISIBLE, false);
233#endif
234 }
235
236
237}
238
240{
242 protected float m_ParticleLifetime;
243 protected int m_ParticleId;
244 protected bool m_Activated;
245
247 {
248 RegisterNetSyncVariableBool("m_Activated");
249 }
250
252 {
253 super.OnVariablesSynchronized();
254
255 if (m_Activated)
256 {
257#ifndef SERVER
258 string particleStrIdentifier = GetGame().ConfigGetTextOut(string.Format("CfgMagazines %1 particleStrIdentifier", GetType()));
260 if (m_ParticleId > 0)
261 {
262 m_ParticleSmoke = ParticleManager.GetInstance().PlayOnObject(m_ParticleId, this);
264 }
265#endif
266 }
267 }
268
269 protected void Activate()
270 {
271 m_ParticleLifetime = GetGame().ConfigGetFloat(string.Format("CfgMagazines %1 particleLifeTime", GetType()));
272 m_Activated = true;
273 SetSynchDirty();
274
275 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, m_ParticleLifetime * 1000);
276 }
277
279 override void EEKilled(Object killer)
280 {
281 //analytics (behaviour from EntityAI)
282 GetGame().GetAnalyticsServer().OnEntityKilled(killer, this);
283 }
284
285 override void EEDelete(EntityAI parent)
286 {
287#ifndef SERVER
288 if (m_ParticleSmoke)
290#endif
291
292 super.EEDelete(parent);
293 }
294
295 override bool CanPutInCargo(EntityAI parent)
296 {
297 return !m_Activated;
298 }
299
301 {
302 SetHealth("", "", 0.0);
303 Activate();
304 }
305}
306
eBleedingSourceType GetType()
void AddAction(typename actionName)
void SetActions()
static void PlayOnHitParticle(vector position)
override void EEParentedFrom(EntityAI parent)
Ammo_40mm_Base EEParentedTo
override void OnDamageDestroyed(int oldLevel)
Definition AnimalBase.c:128
DamageType
exposed from C++ (do not change)
override void EEKilled(Object killer)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
class JsonUndergroundAreaTriggerData GetPosition
override bool IsTakeable()
override bool IsInventoryVisible()
override bool ShootsExplosiveAmmo()
override void EEKilled(Object killer)
override void OnActivatedByItem(notnull ItemBase item)
override void OnDamageDestroyed(int oldLevel)
override void OnActivatedByItem(notnull ItemBase item)
override void EEKilled(Object killer)
special behaviour - do not call super
override bool CanPutInCargo(EntityAI parent)
override void OnVariablesSynchronized()
override void EEDelete(EntityAI parent)
ammo pile base
override void SetFromProjectile(ProjectileStoppedInfo info)
override void SetActions()
static float GetAmmoWeightByBulletType(string bulletType)
float GetWeightSpecialized(bool forceRecalc=false)
override bool IsAmmoPile()
static ref map< string, float > m_AmmoWeightByBulletType
override void SetQuantityToMinimum()
override void EEParentedTo(EntityAI parent)
override bool IsInventoryVisible()
override bool CanBeActionTarget()
override void EEParentedFrom(EntityAI parent)
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
Definition Particle.c:742
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:262
static const int BOLT_CUPID_HIT
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
static const int GRENADE_CHEM_BREAK
proto native CGame GetGame()
enum ShapeType ErrorEx
EntityFlags
Entity flags.
Definition EnEntity.c:114
static proto float Max(float x, float y)
Returns bigger of two given values.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389
proto native int ClearFlags(int flags, bool immedUpdate=true)