DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
InventoryItem.c
См. документацию.
1class InventoryItem extends EntityAI
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 = GetGame().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 GetGame().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 = GetGame().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};
class AnimSoundObjectBuilderBank AnimSoundLookupTableBank()
Определения DayZAnimEventMaps.c:179
EAnimSoundEventID
Определения EAnimSoundEventID.c:2
proto string ToString()
void PlaySound()
Определения HungerSoundHandler.c:38
WaveKind
Определения Sound.c:2
proto native float GetTickTime()
Returns current time from start of the game.
proto native AbstractSoundScene GetSoundScene()
void SurfaceUnderObjectExCorrectedLiquid(notnull Object object, out string type, out string impact, out int liquidType)
Определения Game.c:1188
Определения EnPhysics.c:305
static proto bool GetHitSurfaceAndLiquid(Object other, vector begPos, vector endPos, string surface, out int liquidType)
Определения DayZPhysics.c:124
Определения DbgUI.c:60
string GetImpactSurfaceTypeEx(IEntity other, Contact impact, out int liquid)
Определения InventoryItem.c:160
proto native bool IsOn()
Some inventoryItem devices can be switched on/off (radios, transmitters)
string GetRuinedMeleeAmmoType()
returns ammo (projectile) used in melee if the item is destroyed. Override higher for specific use
Определения InventoryItem.c:184
void InitImpactSoundData()
Определения InventoryItem.c:114
int GetMeleeHeavyMode()
Определения InventoryItem.c:71
void Man()
Определения Man.c:39
SoundLookupTable m_SoundImpactTable
Определения InventoryItem.c:9
void InventoryItem()
Определения InventoryItem.c:33
proto native void ThrowPhysically(DayZPlayer player, vector force, bool collideWithCharacters=true)
float ProcessImpactSound(IEntity other, Contact extra, float weight, out int surfaceHash)
Определения InventoryItem.c:190
bool m_IsMeleeWeapon
Определения InventoryItem.c:11
void OnRightClick()
Определения InventoryItem.c:42
string GetTooltip()
Get tooltip text.
Определения InventoryItem.c:53
override bool IsMeleeWeapon()
Определения InventoryItem.c:81
proto native bool HasCollisionsWithCharacter()
AbstractWave PlaySound(SoundObject so, SoundObjectBuilder sob)
Определения InventoryItem.c:126
proto native void SwitchOn(bool onOff)
Some inventoryItem devices can be switched on/off (radios, transmitters)
void PlaySoundByAnimEvent(EAnimSoundEventID id)
Определения InventoryItem.c:138
proto native void EnableCollisionsWithCharacter(bool state)
collisions with character
proto native MeleeCombatData GetMeleeCombatData()
bool IsMeleeFinisher()
Определения InventoryItem.c:86
const float SOUND_CONTACT_SKIP
Определения InventoryItem.c:3
event bool OnUseFromInventory(Man owner)
Определения InventoryItem.c:47
int GetMeleeSprintMode()
Определения InventoryItem.c:76
proto native InventoryItemType GetInventoryItemType()
int GetMeleeMode()
Определения InventoryItem.c:66
void PlayImpactSound(float weight, float velocity, int surfaceHash)
Определения InventoryItem.c:92
override bool IsInventoryItem()
Определения InventoryItem.c:61
proto native void ForceFarBubble(bool state)
Sets the item to use the server configured 'networkRangeFar' instead of 'networkRangeNear'.
float ProcessImpactSoundEx(IEntity other, Contact extra, float weight, out int surfaceHash, out int liquidType)
Определения InventoryItem.c:198
float m_SoundContactTickTime
Определения InventoryItem.c:10
string GetImpactSurfaceType(IEntity other, Contact impact)
Определения InventoryItem.c:152
Определения Building.c:6
Определения EnEntity.c:165
Определения ItemBase.c:15
Определения gameplay.c:161
Определения ObjectTyped.c:2
Определения Sound.c:112
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)
Определения EnConvert.c:106
proto native CGame GetGame()
vector RelativeVelocityBefore
Определения EnPhysics.c:324
vector Position
Определения EnPhysics.c:323
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
proto native AbstractWave Play3D(SoundObject soundObject, SoundObjectBuilder soundBuilder)
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
void AbstractWave()
Определения Sound.c:167
proto native void SetPosition(vector position)
Note: Sets the position locally if parented, retrieves globally with the sound offset.
proto native void SetKind(WaveKind kind)
proto string Get(int index)
Gets n-th character from string.
proto native int Hash()
Returns hash of string.