Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
ammunitionpiles.c
Go to the documentation of this file.
3{
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 g_Game.ConfigGetText( string.Format("CfgAmmo %1 spawnPileType", bulletType) , ammoTypeName);
17 if (ammoTypeName)
18 ammoWeight = g_Game.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 bool IsAmmoPile()
28 {
29 return true;
30 }
31
32 override protected float GetWeightSpecialized(bool forceRecalc = false)
33 {
34 #ifdef DEVELOPER
35 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
36 {
37 WeightDebugData data = WeightDebug.GetWeightDebug(this);
38 data.SetCalcDetails("TAmmo: ("+GetAmmoCount()+"(Ammo count) * "+ GetConfigWeightModifiedDebugText());
39 }
40 #endif
41
42 return GetAmmoCount() * GetConfigWeightModified();
43 }
44
45 override void SetQuantityToMinimum()
46 {
47 ServerSetAmmoCount(1);
48 }
49
51 {
52 float dmgPerUse = g_Game.ConfigGetFloat("cfgAmmo " + info.GetAmmoType() + " dmgPerUse");
53 float totalDmg = info.GetProjectileDamage() + dmgPerUse;
54 float health = Math.Max(1 - totalDmg, 0);
55
57 SetHealth01("","", health);
58
59 // SetCartridgeDamageAtIndex() MUST be called AFTER SetHealth01()!!
60 // otherwise, decreasing health by less than an entire health level get ignored
61 SetCartridgeDamageAtIndex(0, totalDmg);
62 }
63};
64
84{
85 override bool IsInventoryVisible()
86 {
88 return CanBeActionTarget();
89 }
90
91 override bool CanBeActionTarget()
92 {
93 if (super.CanBeActionTarget())
94 {
95 EntityAI parent = EntityAI.Cast(GetParent());
96 if (parent)
97 {
98 return !parent.IsManagingArrows();
99 }
100 }
101 return true;
102 }
103
104 override void EEParentedTo(EntityAI parent)
105 {
106 if (!parent)
107 return;
108
109 ArrowManagerBase arrowManager = parent.GetArrowManager();
110 if (arrowManager)
111 {
112 arrowManager.AddArrow(this);
113 }
114 }
115
116 override void EEParentedFrom(EntityAI parent)
117 {
118 if (!parent)
119 return;
120
121 ArrowManagerBase arrowManager = parent.GetArrowManager();
122 if (arrowManager)
123 {
124 arrowManager.RemoveArrow(this);
125 }
126 }
127}
128
129class Ammo_DartSyringe: Ammunition_Base {};
135
136//bolts
138
139class Ammo_ImprovisedBolt_1 : Bolt_Base
140{
141 override void SetActions()
142 {
143 super.SetActions();
144
146 }
147}
148
150class Ammo_CupidsBolt : Bolt_Base
151{
152 override void EEParentedTo(EntityAI parent)
153 {
154 Delete();
155 }
156
157 override void EEParentedFrom(EntityAI parent);
158
159 static void PlayOnHitParticle(vector position)
160 {
161 ParticleManager.GetInstance().PlayInWorld(ParticleList.BOLT_CUPID_HIT, position);
162 }
163}
164
165// 40mm
166
168{
169 override bool IsTakeable()
170 {
171 return GetAnimationPhase("Visibility") == 0;
172 }
173
174 override bool IsInventoryVisible()
175 {
176 if (!super.IsInventoryVisible())
177 {
178 return false;
179 }
180
181 return IsTakeable();
182 }
184
186{
187 override bool ShootsExplosiveAmmo()
188 {
189 return true;
190 }
191
192 override void OnActivatedByItem(notnull ItemBase item)
193 {
194 if (g_Game.IsServer())
195 {
196 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", item.GetPosition(), DamageType.EXPLOSION);
197 }
198 }
199
200 override void EEKilled(Object killer)
201 {
202 super.EEKilled(killer);
203 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", GetPosition(), DamageType.EXPLOSION);
204 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
205 }
206
207 override void OnDamageDestroyed(int oldLevel)
208 {
209 super.OnDamageDestroyed(oldLevel);
210 #ifndef SERVER
211 ClearFlags(EntityFlags.VISIBLE, false);
212 #endif
213 }
214}
215//class Ammo_40mm_Grenade_Gas: Ammo_40mm_Base {};
216class Ammo_40mm_ChemGas: Ammo_40mm_Base
217{
218 override void OnActivatedByItem(notnull ItemBase item)
220 if (g_Game.IsServer())
221 {
222 g_Game.CreateObject("ContaminatedArea_Local", item.GetPosition());
223 }
224 }
225
226 override void EEKilled(Object killer)
227 {
228 super.EEKilled(killer);
229 g_Game.CreateObject("ContaminatedArea_Local", GetPosition());
230 g_Game.GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
231 }
233 override void OnDamageDestroyed(int oldLevel)
234 {
235 super.OnDamageDestroyed(oldLevel);
236
237 #ifndef SERVER
238 ClearFlags(EntityFlags.VISIBLE, false);
240 #endif
241 }
242
243
244}
245
247{
249 protected float m_ParticleLifetime;
250 protected int m_ParticleId;
251 protected bool m_Activated;
252
254 {
255 RegisterNetSyncVariableBool("m_Activated");
256 }
257
259 {
260 super.OnVariablesSynchronized();
261
262 if (m_Activated)
263 {
264 #ifndef SERVER
265 string particleStrIdentifier = g_Game.ConfigGetTextOut(string.Format("CfgMagazines %1 particleStrIdentifier", GetType()));
266 m_ParticleId = ParticleList.GetParticleIDByName(particleStrIdentifier);
267 if (m_ParticleId > 0)
268 {
269 m_ParticleSmoke = ParticleManager.GetInstance().PlayOnObject(m_ParticleId, this);
270 m_ParticleSmoke.SetWiggle(7, 0.3);
271 }
272 #endif
273 }
274 }
275
276 protected void Activate()
277 {
278 m_ParticleLifetime = g_Game.ConfigGetFloat(string.Format("CfgMagazines %1 particleLifeTime", GetType()));
279 m_Activated = true;
280 SetSynchDirty();
281
282 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeleteSafe, m_ParticleLifetime * 1000);
283 }
284
286 override void EEKilled(Object killer)
287 {
288 //analytics (behaviour from EntityAI)
289 g_Game.GetAnalyticsServer().OnEntityKilled(killer, this);
290 }
291
292 override void EEDelete(EntityAI parent)
293 {
294 #ifndef SERVER
295 if (m_ParticleSmoke)
296 {
297 m_ParticleSmoke.Stop();
298 }
299 #endif
300
301 super.EEDelete(parent);
302 }
303
304 override bool CanPutInCargo( EntityAI parent )
305 {
306 return !m_Activated;
307 }
308
309 override void OnActivatedByItem(notnull ItemBase item)
310 {
311 SetHealth("", "", 0.0);
312 Activate();
313 }
314}
315
316class Ammo_40mm_Smoke_Red: Ammo_40mm_Smoke_ColorBase {};
eBleedingSourceType GetType()
void AddAction(typename actionName)
static void PlayOnHitParticle(vector position)
Ammo_HuntingBolt Bolt_Base SetActions()
override void EEKilled(Object killer)
Ammo_40mm_Explosive Ammo_40mm_Base OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Ammo_40mm_Base EEParentedTo
override void OnDamageDestroyed(int oldLevel)
override bool IsInventoryVisible()
override bool IsTakeable()
override bool ShootsExplosiveAmmo()
override void EEKilled(Object killer)
override void OnActivatedByItem(notnull ItemBase item)
override void OnDamageDestroyed(int oldLevel)
override void EEKilled(Object killer)
special behaviour - do not call super
override bool CanPutInCargo(EntityAI parent)
override void EEDelete(EntityAI parent)
override void OnActivatedByItem(notnull ItemBase item)
override void OnVariablesSynchronized()
ammo pile base
override bool IsAmmoPile()
override void SetFromProjectile(ProjectileStoppedInfo info)
override void SetQuantityToMinimum()
float GetWeightSpecialized(bool forceRecalc=false)
static float GetAmmoWeightByBulletType(string bulletType)
static ref map< string, float > m_AmmoWeightByBulletType
void RemoveArrow(EntityAI arrow)
void AddArrow(EntityAI arrow)
override bool IsInventoryVisible()
override void EEParentedFrom(EntityAI parent)
override void EEParentedTo(EntityAI parent)
override bool CanBeActionTarget()
Definition enmath.c:7
Legacy way of using particles in the game.
Definition particle.c:7
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix).
static const int BOLT_CUPID_HIT
static const int GRENADE_CHEM_BREAK
proto native float GetProjectileDamage()
proto native string GetAmmoType()
void SetCalcDetails(string details)
Definition debug.c:916
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition dayzgame.c:3942
class LOD Object
class GP5GasMask extends MaskBase ItemBase
enum ShapeType ErrorEx
EntityFlags
Entity flags.
Definition enentity.c:115
static proto float Max(float x, float y)
Returns bigger of two given values.
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native Widget GetParent()
Get parent of the Effect.
Definition effect.c:422
proto native int ClearFlags(int flags, bool immedUpdate=true)
Magazine Magazine_Base
Definition magazine.c:1
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).