DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 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
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
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
136class Ammo_DartSyringe: Ammunition_Base {};
142
143//bolts
145
146class Ammo_ImprovisedBolt_1 : Bolt_Base
147{
148 override void SetActions()
149 {
150 super.SetActions();
151
153 }
154}
155
157// 40mm
158
159class Ammo_40mm_Base: Ammunition_Base
160{
161 override bool IsTakeable()
162 {
163 return GetAnimationPhase("Visibility") == 0;
164 }
165
166 override bool IsInventoryVisible()
167 {
168 if (!super.IsInventoryVisible())
169 {
170 return false;
171 }
172
173 return IsTakeable();
174 }
175};
176
177class Ammo_40mm_Explosive: Ammo_40mm_Base
178{
179 override bool ShootsExplosiveAmmo()
180 {
181 return true;
182 }
183
184 override void OnActivatedByItem(notnull ItemBase item)
185 {
186 if (GetGame().IsServer())
187 {
188 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", item.GetPosition(), DamageType.EXPLOSION);
189 }
190 }
191
192 override void EEKilled(Object killer)
193 {
194 super.EEKilled(killer);
195 DamageSystem.ExplosionDamage(this, null, "Explosion_40mm_Ammo", GetPosition(), DamageType.EXPLOSION);
196 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
197 }
198
199 override void OnDamageDestroyed(int oldLevel)
200 {
201 super.OnDamageDestroyed(oldLevel);
202 #ifndef SERVER
203 ClearFlags(EntityFlags.VISIBLE, false);
204 #endif
205 }
206}
207//class Ammo_40mm_Grenade_Gas: Ammo_40mm_Base {};
208class Ammo_40mm_ChemGas: Ammo_40mm_Base
209{
210 override void OnActivatedByItem(notnull ItemBase item)
212 if (GetGame().IsServer())
213 {
214 GetGame().CreateObject("ContaminatedArea_Local", item.GetPosition());
215 }
216 }
217
218 override void EEKilled(Object killer)
219 {
220 super.EEKilled(killer);
221 GetGame().CreateObject("ContaminatedArea_Local", GetPosition());
222 GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeleteSafe, 1000, false);
223 }
225 override void OnDamageDestroyed(int oldLevel)
226 {
227 super.OnDamageDestroyed(oldLevel);
228
229 #ifndef SERVER
230 ClearFlags(EntityFlags.VISIBLE, false);
232 #endif
233 }
234
235
236}
237
238class Ammo_40mm_Smoke_ColorBase: Ammo_40mm_Base
239{
241 protected float m_ParticleLifetime;
242 protected int m_ParticleId;
243 protected bool m_Activated;
244
246 {
247 RegisterNetSyncVariableBool("m_Activated");
248 }
249
251 {
252 super.OnVariablesSynchronized();
253
254 if (m_Activated)
255 {
256 #ifndef SERVER
257 string particleStrIdentifier = GetGame().ConfigGetTextOut(string.Format("CfgMagazines %1 particleStrIdentifier", GetType()));
258 m_ParticleId = ParticleList.GetParticleIDByName(particleStrIdentifier);
259 if (m_ParticleId > 0)
260 {
261 m_ParticleSmoke = ParticleManager.GetInstance().PlayOnObject(m_ParticleId, this);
263 }
264 #endif
265 }
266 }
267
268 protected void Activate()
269 {
270 m_ParticleLifetime = GetGame().ConfigGetFloat(string.Format("CfgMagazines %1 particleLifeTime", GetType()));
271 m_Activated = true;
272 SetSynchDirty();
273
275 }
276
278 override void EEKilled(Object killer)
279 {
280 //analytics (behaviour from EntityAI)
281 GetGame().GetAnalyticsServer().OnEntityKilled(killer, this);
282 }
283
284 override void EEDelete(EntityAI parent)
285 {
286 #ifndef SERVER
287 if (m_ParticleSmoke)
288 {
290 }
291 #endif
292
293 super.EEDelete(parent);
294 }
295
296 override bool CanPutInCargo( EntityAI parent )
297 {
298 return !m_Activated;
299 }
300
301 override void OnActivatedByItem(notnull ItemBase item)
302 {
303 SetHealth("", "", 0.0);
304 Activate();
305 }
306}
307
308class Ammo_40mm_Smoke_Red: Ammo_40mm_Smoke_ColorBase {};
eBleedingSourceType GetType()
void AddAction(typename actionName)
override bool IsInventoryVisible()
Ammo_ImprovisedBolt_2 Bolt_Base IsTakeable()
override void OnDamageDestroyed(int oldLevel)
Definition ClockBase.c:134
DamageType
exposed from C++ (do not change)
override void EEKilled(Object killer)
Magazine Magazine_Base
Definition Magazine.c:1
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 ShootsExplosiveAmmo()
override void EEKilled(Object killer)
override void OnActivatedByItem(notnull ItemBase item)
override void OnDamageDestroyed(int oldLevel)
protected float m_ParticleLifetime
override void EEKilled(Object killer)
special behaviour - do not call super
override bool CanPutInCargo(EntityAI parent)
override void EEDelete(EntityAI parent)
protected Particle m_ParticleSmoke
override void OnActivatedByItem(notnull ItemBase item)
override void OnVariablesSynchronized()
ammo pile base
override protected float GetWeightSpecialized(bool forceRecalc=false)
override bool IsAmmoPile()
override void SetFromProjectile(ProjectileStoppedInfo info)
override void SetQuantityToMinimum()
static float GetAmmoWeightByBulletType(string bulletType)
static ref map< string, float > m_AmmoWeightByBulletType
override void SetActions()
void OnEntityKilled(Object killer, EntityAI target)
void RemoveArrow(EntityAI arrow)
void AddArrow(EntityAI arrow)
override bool IsInventoryVisible()
override void EEParentedFrom(EntityAI parent)
override void EEParentedTo(EntityAI parent)
override bool CanBeActionTarget()
AnalyticsManagerServer GetAnalyticsServer()
Definition Game.c:1407
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native Object CreateObject(string type, vector pos, bool create_local=false, bool init_ai=false, bool create_physics=true)
Creates object of certain type.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
string ConfigGetTextOut(string path)
Get string value from config on path.
Definition Game.c:440
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:266
void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
Definition Particle.c:765
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
static const int GRENADE_CHEM_BREAK
proto native float GetProjectileDamage()
proto native string GetAmmoType()
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
void SetCalcDetails(string details)
Definition Debug.c:728
proto native CGame GetGame()
enum ShapeType ErrorEx
EntityFlags
Entity flags.
Definition EnEntity.c:115
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:396
proto native int ClearFlags(int flags, bool immedUpdate=true)