Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
inventoryitem.c
Go to the documentation of this file.
2{
3 static private const float SOUND_CONTACT_SKIP = 0.33;//second
4
5#ifdef DIAG_DEVELOPER
6 static private ref array<ref string> s_ImpactSoundsInfo = new array<ref string>();
7#endif
8
11 private bool m_IsMeleeWeapon = false;
12
14
16 proto native void SwitchOn(bool onOff);
18 proto native bool IsOn();
19
21 proto native void EnableCollisionsWithCharacter(bool state);
22 proto native bool HasCollisionsWithCharacter();
23
25
26 proto native void ThrowPhysically(DayZPlayer player, vector force, bool collideWithCharacters = true);
27
29 // This method performs an OR operation with the config 'forceFarBubble'. If set in the config
30 // this method has no effect.
31 proto native void ForceFarBubble(bool state);
32
34 {
36
37 if (ConfigIsExisting("isMeleeWeapon"))
38 m_IsMeleeWeapon = ConfigGetBool("isMeleeWeapon");
39 }
40
41
43 {
44
45 }
46
47 event bool OnUseFromInventory(Man owner)
48 {
49 return false;
50 }
51
53 string GetTooltip()
54 {
55 string temp;
56 if (!DescriptionOverride(temp))
57 temp = ConfigGetString("descriptionShort");
58 return temp;
59 }
60
61 override bool IsInventoryItem()
62 {
63 return true;
64 }
65
67 {
68 return 0;
69 }
70
72 {
73 return 1;
74 }
75
77 {
78 return 2;
79 }
80
81 override bool IsMeleeWeapon()
82 {
83 return m_IsMeleeWeapon;
84 }
85
87 {
88 return false;
89 }
90
91 // -------------------------------------------------------------------------------
92 void PlayImpactSound(float weight, float velocity, int surfaceHash)
93 {
95 return;
96
97 SoundObjectBuilder soundBuilder = m_SoundImpactTable.GetSoundBuilder(surfaceHash);
98 if (soundBuilder != null)
99 {
100 soundBuilder.AddVariable("weight", weight);
101 soundBuilder.AddVariable("speed", velocity);
102 soundBuilder.AddEnvSoundVariables(GetPosition());
103
104 SoundObject soundObject = soundBuilder.BuildSoundObject();
105 if (soundObject != null)
106 {
107 soundObject.SetKind(WaveKind.WAVEEFFECTEX);
108 PlaySound(soundObject, soundBuilder);
109 }
110 }
111 }
112
113 // -------------------------------------------------------------------------------
114 protected void InitImpactSoundData()
115 {
116 #ifndef SERVER
117 string soundImpactType = "default";
118 if ( ConfigIsExisting("soundImpactType") )
119 soundImpactType = ConfigGetString("soundImpactType");
120
121 m_SoundImpactTable = AnimSoundLookupTableBank.GetInstance().GetImpactTable(soundImpactType + "_Impact_LookupTable");
122 #endif
123 }
124
125 // -------------------------------------------------------------------------------
127 {
128 if (so == null)
129 return null;
130
132 AbstractWave wave = g_Game.GetSoundScene().Play3D(so, sob);
133
134 return wave;
135 }
136
137 // -------------------------------------------------------------------------------
139 {
140 AnimSoundEvent soundEvent = GetInventoryItemType().GetSoundEvent(id);
141 if (soundEvent)
142 {
143 SoundObjectBuilder builder = soundEvent.GetSoundBuilder();
144 SoundObject soundObject = builder.BuildSoundObject();
145 if (soundObject)
146 PlaySound(soundObject, builder);
147 }
148 }
149
150
151 // -------------------------------------------------------------------------------
153 {
154 string surface;
155 int liquid = -1;
156 return GetImpactSurfaceTypeEx(other, impact, liquid);
157 }
158
159 // -------------------------------------------------------------------------------
160 string GetImpactSurfaceTypeEx(IEntity other, Contact impact, out int liquid)
161 {
162 vector mins, maxs;
163 GetWorldBounds(mins, maxs);
164 vector size = maxs - mins;
165
166 vector add = impact.RelativeVelocityBefore.Normalized() * size.Length();
167 string surfaceImpact;
169 Object.Cast(other),
170 impact.Position + add,
171 impact.Position - add,
172 surfaceImpact,
173 liquid))
174 {
175 return surfaceImpact;
176 }
177 string surface;
178 g_Game.SurfaceUnderObjectExCorrectedLiquid(this, surface, surfaceImpact, liquid);
179
180 return surfaceImpact;
181 }
182
185 {
186 return "MeleeSoft";
187 }
188
189 // -------------------------------------------------------------------------------
190 float ProcessImpactSound(IEntity other, Contact extra, float weight, out int surfaceHash)
191 {
192 int liquidType = -1;
193 return ProcessImpactSoundEx(other, extra, weight, surfaceHash,liquidType);
194 }
195
196
197 // -------------------------------------------------------------------------------
198 float ProcessImpactSoundEx(IEntity other, Contact extra, float weight, out int surfaceHash, out int liquidType)
199 {
200 float impactVelocity = extra.RelativeVelocityBefore.Length();
201 if ( impactVelocity < 0.3 )
202 return 0.0;
203
204 float tickTime = g_Game.GetTickTime();
206 return 0.0;
207
208 string surfaceName = GetImpactSurfaceTypeEx(other, extra, liquidType);
209 if ( surfaceName == "" )
210 return 0.0;
211
212#ifdef DIAG_DEVELOPER
213 string infoText = "Surface: " + surfaceName + ", Weight: " + weight + ", Speed: " + impactVelocity;
214
215 if ( s_ImpactSoundsInfo.Count() == 10 )
216 s_ImpactSoundsInfo.Remove(9);
217
218 s_ImpactSoundsInfo.InsertAt(infoText, 0);
219#endif
220
221 m_SoundContactTickTime = tickTime;
222
223 surfaceHash = surfaceName.Hash();
224 return impactVelocity;
225 }
226
227#ifdef DIAG_DEVELOPER
228 static void DrawImpacts()
229 {
230 DbgUI.Begin("Item impact sounds", 10, 200);
231
232 for ( int i = 0; i < s_ImpactSoundsInfo.Count(); ++i )
233 {
234 string line = (i + 1).ToString() + ". " + s_ImpactSoundsInfo.Get(i);
235 DbgUI.Text(line);
236 }
237
238 DbgUI.End();
239 }
240#endif
241};
void InventoryItemType()
Output structure for reporting collisions.
Definition contact.c:10
vector Position
Position of the contact point (world space).
Definition contact.c:29
vector RelativeVelocityBefore
Definition contact.c:35
static proto bool GetHitSurfaceAndLiquid(Object other, vector begPos, vector endPos, string surface, out int liquidType)
Definition dbgui.c:60
void InitImpactSoundData()
int GetMeleeMode()
const float SOUND_CONTACT_SKIP
bool IsMeleeFinisher()
AbstractWave PlaySound(SoundObject so, SoundObjectBuilder sob)
float m_SoundContactTickTime
proto native bool HasCollisionsWithCharacter()
override bool IsMeleeWeapon()
float ProcessImpactSoundEx(IEntity other, Contact extra, float weight, out int surfaceHash, out int liquidType)
proto native void EnableCollisionsWithCharacter(bool state)
collisions with character
int GetMeleeHeavyMode()
proto native void ForceFarBubble(bool state)
Sets the item to use the server configured 'networkRangeFar' instead of 'networkRangeNear'.
proto native void ThrowPhysically(DayZPlayer player, vector force, bool collideWithCharacters=true)
event bool OnUseFromInventory(Man owner)
override bool IsInventoryItem()
string GetImpactSurfaceTypeEx(IEntity other, Contact impact, out int liquid)
void Man()
Definition man.c:43
void PlayImpactSound(float weight, float velocity, int surfaceHash)
int GetMeleeSprintMode()
void OnRightClick()
string GetImpactSurfaceType(IEntity other, Contact impact)
SoundLookupTable m_SoundImpactTable
float ProcessImpactSound(IEntity other, Contact extra, float weight, out int surfaceHash)
bool m_IsMeleeWeapon
void InventoryItem()
string GetTooltip()
Get tooltip text.
proto native bool IsOn()
Some inventoryItem devices can be switched on/off (radios, transmitters).
void PlaySoundByAnimEvent(EAnimSoundEventID id)
proto native MeleeCombatData GetMeleeCombatData()
string GetRuinedMeleeAmmoType()
returns ammo (projectile) used in melee if the item is destroyed. Override higher for specific use
proto native InventoryItemType GetInventoryItemType()
proto native void SwitchOn(bool onOff)
Some inventoryItem devices can be switched on/off (radios, transmitters).
Internal ancestor of all Entity implementations.
Definition enentity.c:165
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
proto native float Length()
Returns length of vector (magnitude).
class AnimSoundObjectBuilderBank AnimSoundLookupTableBank()
DayZGame g_Game
Definition dayzgame.c:3942
EAnimSoundEventID
proto string ToString()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
proto native void SetPosition(vector position)
Note: Sets the position locally if parented, retrieves globally with the sound offset.
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
proto native void SetKind(WaveKind kind)
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
void AbstractWave()
Definition sound.c:167
proto string Get(int index)
Gets n-th character from string.
proto native int Hash()
Returns hash of string.
void PlaySound()
WaveKind
Definition sound.c:2