DayZ 1.24
Loading...
Searching...
No Matches
ImpactEffects.c
Go to the documentation of this file.
9
11{
17 string m_Surface;
18 string m_AmmoType;
24
25
26}
27
29{
32
36
42 static int PLASTIC = RegisterSurface("Hit_Plastic");
43 static int SAND = RegisterSurface("Hit_Sand");
44 static int TEXTILE = RegisterSurface("Hit_Textile");
45 static int CONCRETE = RegisterSurface("Hit_Concrete");
46 static int GRAVEL = RegisterSurface("Hit_Gravel");
47 static int DIRT = RegisterSurface("Hit_Dirt");
48 static int FOLIAGE = RegisterSurface("Hit_Foliage");
49 static int GRASS = RegisterSurface("Hit_Grass");
50 static int WOOD = RegisterSurface("Hit_Wood");
51 static int METAL = RegisterSurface("Hit_Metal");
52 static int GLASS = RegisterSurface("Hit_Glass");
53 static int GLASS_THIN = RegisterSurface("Hit_Glass_Thin");
54 static int WATER = RegisterSurface("Hit_Water");
55 static int RUBBER = RegisterSurface("Hit_Rubber");
56 static int PLASTER = RegisterSurface("Hit_Plaster");
57 static int MEATBONES = RegisterSurface("Hit_MeatBones");
58 static int MEATBONES_SHOVEL = RegisterSurface("Hit_MeatBones_MeleeShovel");
59 static int MEATBONES_PIPEWRENCH = RegisterSurface("Hit_MeatBones_MeleePipeWrench");
60 static int MEATBONES_WRENCH = RegisterSurface("Hit_MeatBones_MeleeWrench");
61 static int MEATBONES_FIST = RegisterSurface("Hit_MeatBones_MeleeFist");
62 static int UNDEFINED = RegisterSurface("Hit_Undefined");
63 static int ERROR_NO_MATERIAL = RegisterSurface("Hit_ErrorNoMaterial");
65
71 static int FIST = RegisterIgnoredAmmo("MeleeFist");
72 static int FIST_HEAVY = RegisterIgnoredAmmo("MeleeFist_Heavy");
73 static int SOFT = RegisterIgnoredAmmo("MeleeSoft");
74 static int SOFT_HEAVY = RegisterIgnoredAmmo("MeleeSoft_Heavy");
75 static int DUMMY = RegisterIgnoredAmmo("Dummy_Light");
76 static int DUMMY_HEAVY = RegisterIgnoredAmmo("Dummy_Heavy");
78
79 static int RegisterSurface(string surface)
80 {
81 if (!m_ImpactEffect)
83
84 m_ImpactEffect.Insert(surface, surface.ToType());
85
87 }
88
89 static bool UnregisterSurface(string surface)
90 {
92 {
93 m_ImpactEffect.Remove(surface);
94 return !m_ImpactEffect.Contains(surface);
95 }
96
97 return false;
98 }
99
111
112 static bool UnregisterIgnoredAmmo(string ammo)
113 {
114 if (m_IgnoredAmmo)
115 {
116 m_IgnoredAmmo.Remove(ammo);
117 return !m_IgnoredAmmo.Contains(ammo);
118 }
119
120 return false;
121 }
122
123 static typename GetImpactEffect(string surface, string ammoType)
124 {
125 string key = string.Format("%1_%2", surface, ammoType);
126
127 typename eff_type = m_ImpactEffect[key];
128
129 if (eff_type)
130 return eff_type;
131 else
132 return m_ImpactEffect[surface];
133 }
134
136 {
137 EvaluateImpactEffect(pData.m_DirectHit, pData.m_ComponentIndex, pData.m_Surface, pData.m_Position, pData.m_ImpactType, pData.m_SurfaceNormal, pData.m_ExitPosition, pData.m_InSpeed, pData.m_OutSpeed, pData.m_IsDeflected, pData.m_AmmoType, pData.m_IsWater);
138 }
139
141 {
142 // No impact effects wanted for this ammo
143 if (m_IgnoredAmmo.Contains(ammoType))
144 return;
145
146 if (impact_type == ImpactTypes.UNKNOWN)
148
149 if (deflected)
150 impact_type = ImpactTypes.RICOCHET;
151 else if (outSpeed)
152 impact_type = ImpactTypes.PENETRATE;
153
154 if (isWater)
155 surface = "Hit_Water";
156
158
159 if (!eff && surface == "") // handle undefined surface
160 {
161 eff = EffBulletImpactBase.Cast(surface.ToType().Spawn());
162
163 if (eff)
164 {
165 RegisterSurface(surface);
166 ErrorEx(string.Format("Unregistered surface for bullet impact effect (%1). Register this surface in ImpactMaterials (Script) for better performance.", surface), ErrorExSeverity.WARNING);
167 }
168 else
169 {
170 if (directHit)
171 {
172 string object_type = directHit.GetType();
173
174 if (object_type == "")
175 object_type = "OBJECT_WITHOUT_CONFIG_CLASS";
176
177 ErrorEx(string.Format("Object '%1' with model file: %2 has undefined 'Hit_...' material! Cannot play impact effect.", object_type, directHit.GetShapeName()));
178 eff = EffBulletImpactBase.Cast(GetImpactEffect("Hit_ErrorNoMaterial", ammoType).Spawn());
179 }
180 }
181 }
182
183 if (!eff && surface != "")
184 {
185 ErrorEx(string.Format("Unregistered surface impact material <%1>! Register this surface in ImpactMaterials (Script).", surface));
186 eff = EffBulletImpactBase.Cast(GetImpactEffect("Hit_Undefined", ammoType).Spawn());
187 }
188
189 if (eff)
190 {
192 eff.SetAutodestroy(true);
194 }
195 }
196}
void Spawn()
spawn damage trigger
@ UNKNOWN
24 - Any other error. Can be returned from any call.
vector m_Position
Cached world position.
Definition Effect.c:41
int m_ImpactType
enum ImpactTypes m_DirectHit
vector m_InSpeed
bool m_IsDeflected
vector m_SurfaceNormal
bool m_IsWater
vector m_OutSpeed
string m_AmmoType
int m_ComponentIndex
vector m_ExitPosition
string m_Surface
ImpactTypes
@ MELEE
static int ERROR_NO_MATERIAL
static int CONCRETE
static int RegisterSurface(string surface)
static int MEATBONES_FIST
static int SOFT_HEAVY
static bool UnregisterSurface(string surface)
static int RegisterIgnoredAmmo(string ammo)
static int TEXTILE
static int GLASS_THIN
static int FIST_HEAVY
static int WATER
static void EvaluateImpactEffect(Object directHit, int componentIndex, string surface, vector pos, int impact_type, vector surfNormal, vector exitPos, vector inSpeed, vector outSpeed, bool deflected, string ammoType, bool isWater)
static GetImpactEffect(string surface, string ammoType)
static int PLASTIC
static int MEATBONES_SHOVEL
static int FIST
static ref map< string, typename > m_ImpactEffect
static int SOFT
static bool UnregisterIgnoredAmmo(string ammo)
static int GRAVEL
static int MEATBONES_PIPEWRENCH
static int RUBBER
static int WOOD
static int PLASTER
static int GLASS
static int SAND
static int FOLIAGE
static int m_LastRegisteredIgnoredAmmo
static int DUMMY
static void EvaluateImpactEffectEx(ImpactEffectsData pData)
static int GRASS
static int METAL
static int DUMMY_HEAVY
static int DIRT
static int UNDEFINED
static int MEATBONES_WRENCH
static int MEATBONES
static int m_LastRegisteredMaterial
static ref map< string, int > m_IgnoredAmmo
Map of ammo which will not spawn any impact effect.
Manager class for managing Effect (EffectParticle, EffectSound)
static int PlayInWorld(notnull Effect eff, vector pos)
Play an Effect.
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...
@ STOP
Definition EnWidgets.c:508