3 static private const float SOUND_CONTACT_SKIP = 0.33;
10 private float m_SoundContactTickTime;
11 private bool m_IsMeleeWeapon =
false;
16 proto native
void SwitchOn(
bool onOff);
18 proto native
bool IsOn();
21 proto native
void EnableCollisionsWithCharacter(
bool state);
22 proto native
bool HasCollisionsWithCharacter();
26 proto native
void ThrowPhysically(
DayZPlayer player,
vector force,
bool collideWithCharacters =
true);
31 proto native
void ForceFarBubble(
bool state);
35 InitImpactSoundData();
37 if (ConfigIsExisting(
"isMeleeWeapon"))
38 m_IsMeleeWeapon = ConfigGetBool(
"isMeleeWeapon");
47 event bool OnUseFromInventory(Man owner)
56 if (!DescriptionOverride(temp))
57 temp = ConfigGetString(
"descriptionShort");
61 override bool IsInventoryItem()
71 int GetMeleeHeavyMode()
76 int GetMeleeSprintMode()
81 override bool IsMeleeWeapon()
83 return m_IsMeleeWeapon;
86 bool IsMeleeFinisher()
92 void PlayImpactSound(
float weight,
float velocity,
int surfaceHash)
94 if (!m_SoundImpactTable)
98 if (soundBuilder !=
null)
100 soundBuilder.AddVariable(
"weight", weight);
101 soundBuilder.AddVariable(
"speed", velocity);
104 SoundObject soundObject = soundBuilder.BuildSoundObject();
105 if (soundObject !=
null)
107 soundObject.SetKind(
WaveKind.WAVEEFFECTEX);
114 protected void InitImpactSoundData()
117 string soundImpactType =
"default";
118 if ( ConfigIsExisting(
"soundImpactType") )
119 soundImpactType = ConfigGetString(
"soundImpactType");
121 m_SoundImpactTable =
AnimSoundLookupTableBank.GetInstance().GetImpactTable(soundImpactType +
"_Impact_LookupTable");
140 AnimSoundEvent soundEvent = GetInventoryItemType().GetSoundEvent(
id);
144 SoundObject soundObject = builder.BuildSoundObject();
156 return GetImpactSurfaceTypeEx(other, impact, liquid);
160 string GetImpactSurfaceTypeEx(
IEntity other,
Contact impact, out
int liquid)
163 GetWorldBounds(mins, maxs);
164 vector size = maxs - mins;
166 vector add = impact.RelativeVelocityBefore.Normalized() * size.Length();
167 string surfaceImpact;
170 impact.Position + add,
171 impact.Position - add,
175 return surfaceImpact;
178 GetGame().SurfaceUnderObjectEx(
this, surface, surfaceImpact, liquid);
180 return surfaceImpact;
184 string GetRuinedMeleeAmmoType()
190 float ProcessImpactSound(
IEntity other,
Contact extra,
float weight, out
int surfaceHash)
193 return ProcessImpactSoundEx(other, extra, weight, surfaceHash,liquidType);
198 float ProcessImpactSoundEx(
IEntity other,
Contact extra,
float weight, out
int surfaceHash, out
int liquidType)
200 float impactVelocity = extra.RelativeVelocityBefore.Length();
201 if ( impactVelocity < 0.3 )
204 float tickTime =
GetGame().GetTickTime();
205 if ( m_SoundContactTickTime + SOUND_CONTACT_SKIP > tickTime )
208 string surfaceName = GetImpactSurfaceTypeEx(other, extra, liquidType);
209 if ( surfaceName ==
"" )
212 #ifdef DIAG_DEVELOPER
213 string infoText =
"Surface: " + surfaceName +
", Weight: " + weight +
", Speed: " + impactVelocity;
215 if ( s_ImpactSoundsInfo.Count() == 10 )
216 s_ImpactSoundsInfo.Remove(9);
218 s_ImpactSoundsInfo.InsertAt(infoText, 0);
221 m_SoundContactTickTime = tickTime;
223 surfaceHash = surfaceName.Hash();
224 return impactVelocity;
227 #ifdef DIAG_DEVELOPER
228 static void DrawImpacts()
230 DbgUI.Begin(
"Item impact sounds", 10, 200);
232 for (
int i = 0; i < s_ImpactSoundsInfo.Count(); ++i )
234 string line = (i + 1).
ToString() +
". " + s_ImpactSoundsInfo.Get(i);