DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
AmmoEffects.c
Go to the documentation of this file.
1
6{
9
12
13
14
19
21 static int GetAmmoParticleID(string ammoType)
22 {
23 int particleID;
24
25 // Search for it in the static map
26 if ( !m_AmmoParticles.Find(ammoType, particleID) )
27 {
28 // Load it in when we can't find it
29 string particleFileName;
30 GetGame().ConfigGetText(string.Format("cfgAmmo %1 particle", ammoType), particleFileName);
31
32 // If we found a valid entry, try looking for it in ParticleList
33 if ( particleFileName != "" )
34 {
35 particleID = ParticleList.GetParticleIDByName(particleFileName);
36 }
37
38 // Store it for next search
39 m_AmmoParticles.Insert(ammoType, particleID);
40 }
41
42 return particleID;
43 }
44
46 static bool PlayAmmoParticle(string ammoType, vector pos)
47 {
48 int particleID = GetAmmoParticleID(ammoType);
49
50 if (ParticleList.IsValidId(particleID))
51 {
52 return ParticleManager.GetInstance().PlayInWorld(particleID, pos) != null;
53 }
54
55 return false;
56 }
57
59
60
61
66
68 static typename GetAmmoEffectTypename(string ammoType)
69 {
70 typename typeName;
71
72 // Search for it in the static map
73 if ( !m_AmmoEffects.Find(ammoType, typeName) )
74 {
75 // Load it in when we can't find it
76 string effectName;
77 GetGame().ConfigGetText(string.Format("cfgAmmo %1 effect", ammoType), effectName);
78
79 // If we found a valid entry, try looking for it in ParticleList
80 if ( effectName != "" )
81 {
82 typeName = effectName.ToType();
83 }
84
85 // Store it for next search
86 m_AmmoEffects.Insert(ammoType, typeName);
87 }
88
89 return typeName;
90 }
91
93 static bool PlayAmmoEffect(string ammoType, vector pos)
94 {
95 typename typeName = GetAmmoEffectTypename(ammoType);
96
97 if ( typeName )
98 {
99 Effect eff = Effect.Cast(typeName.Spawn());
100
101 if ( eff )
102 {
103 eff.SetAutodestroy(true);
104 return SEffectManager.PlayInWorld( eff, pos );
105 }
106 }
107
108 return false;
109 }
110
112
113
114
119
121 static void Init()
122 {
125 }
126
128 static void Cleanup()
129 {
130 /* These ain't containing no refs, so whatever
131 m_AmmoParticles.Clear();
132 m_AmmoEffects.Clear();
133 */
134 }
135
137}
void Effect()
ctor
Definition Effect.c:70
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Static data holder for certain ammo config values.
Definition AmmoEffects.c:6
static bool PlayAmmoEffect(string ammoType, vector pos)
Attempt to play the ammo effect at pos if found, returns true on success.
Definition AmmoEffects.c:93
static void Init()
Initialize the containers: this is done this way, to have these not exist on server.
static GetAmmoEffectTypename(string ammoType)
Get the typename for the effect for this ammoType.
Definition AmmoEffects.c:68
static void Cleanup()
Clean up the data.
static ref map< string, typename > m_AmmoEffects
Key: Ammo class name; Data: ParticleList ID.
Definition AmmoEffects.c:11
static bool PlayAmmoParticle(string ammoType, vector pos)
Attempt to play the ammo particle at pos if found, returns true on success.
Definition AmmoEffects.c:46
static ref map< string, int > m_AmmoParticles
Key: Ammo class name; Data: ParticleList ID.
Definition AmmoEffects.c:8
static int GetAmmoParticleID(string ammoType)
Get the ParticleList ID for the particle for this ammoType.
Definition AmmoEffects.c:21
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
static bool IsValidId(int id)
Purely checks for an invalid number, does NOT mean it is actually registered.
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
Manager class for managing Effect (EffectParticle, EffectSound)
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
proto native CGame GetGame()
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...