DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Bottle_Base.c
Go to the documentation of this file.
2{
3 POURING = 1,
4 EMPTYING = 0,
5}
6
7class Bottle_Base extends Edible_Base
8{
9 //Particles
12 //Boiling
13 //waiting for proper particle effects
17 //Baking
20 //Drying
23 //Burning
25
26 //Sounds
29
30 //cooking data
32 protected bool m_CookingIsDone;
33 protected bool m_CookingIsEmpty;
34 protected bool m_CookingIsBurned;
35
36 //Boiling
37 const string SOUND_BOILING_EMPTY = "Boiling_SoundSet";
38 const string SOUND_BOILING_START = "Boiling_SoundSet";
39 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
40 const string SOUND_DRYING_START = "Drying_SoundSet";
41 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
42
44 private const float QUANTITY_EMPTIED_PER_SEC_DEFAULT = 200; //default
45
47 {
48 RegisterNetSyncVariableInt("m_CookingMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
49 RegisterNetSyncVariableBool("m_CookingIsDone");
50 RegisterNetSyncVariableBool("m_CookingIsEmpty");
51 RegisterNetSyncVariableBool("m_CookingIsBurned");
52
54 }
55
57 {
60 }
61
62 override void EEDelete( EntityAI parent )
63 {
64 super.EEDelete( parent );
65
66 //remove audio visuals
68 }
69
70 //================================================================
71 // PARTICLES & SOUNDS
72 //================================================================
73 //Refreshes the audio and partcile effects on cooking pot
74 //is_done - is the food baked, boiled, dried?
75 //is_empty - is cooking quipment (cargo) empty?
76 //is_burned - is any of the food items in the cargo in burned food stage?
77 override void Synchronize()
78 {
79 SetSynchDirty();
80 }
81
82 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
83 {
84 super.OnRPC(sender, rpc_type, ctx);
85
86 Param1<bool> p = new Param1<bool>(false);
87
88 if (!ctx.Read(p))
89 return;
90
91 bool play = p.param1;
92 switch (rpc_type)
93 {
94 case SoundTypeBottle.POURING:
95 if (play)
97 else
99
100 break;
101
102 case SoundTypeBottle.EMPTYING:
103 if (play)
105 else
107
108 break;
109 }
110 }
111
113 {
114 super.OnVariablesSynchronized();
115
117 {
119 }
120 else
121 {
123 }
124 }
125
127 {
129
130 Synchronize();
131 }
132
133 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned )
134 {
135 m_CookingMethod = cooking_method;
136 m_CookingIsDone = is_done;
137 m_CookingIsEmpty = is_empty;
138 m_CookingIsBurned = is_burned;
139
140 Synchronize();
141 }
142
143 void RefreshAudioVisuals( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned )
144 {
145 string soundName;
146 int particleId;
147
148 //if at least one of the food items is burned
149 if (is_burned)
150 {
151 soundName = SOUND_BURNING_DONE;
152 particleId = PARTICLE_BURNING_DONE;
153 }
154 //proper cooking methods
155 else
156 {
157 if (cooking_method == CookingMethodType.BOILING)
158 {
159 if (is_empty) //EMPTY
160 {
161 soundName = SOUND_BOILING_EMPTY;
162 particleId = PARTICLE_BOILING_EMPTY;
163 }
164 else
165 {
166 if (is_done) //DONE
167 {
168 soundName = SOUND_BOILING_DONE;
169 particleId = PARTICLE_BOILING_DONE;
170 }
171 else //START
172 {
173 soundName = SOUND_BOILING_START;
174 particleId = PARTICLE_BOILING_START;
175 }
176 }
177 }
178 else if (cooking_method == CookingMethodType.BAKING)
179 {
180 if (is_done) //DONE
181 {
182 soundName = SOUND_BAKING_DONE;
183 particleId = PARTICLE_BAKING_DONE;
184 }
185 else //START
186 {
187 soundName = SOUND_BAKING_START;
188 particleId = PARTICLE_BAKING_START;
189 }
190 }
191 else if (cooking_method == CookingMethodType.DRYING)
192 {
193 if (is_done) //DONE
194 {
195 soundName = SOUND_DRYING_DONE;
196 particleId = PARTICLE_DRYING_DONE;
197 }
198 else //START
199 {
200 soundName = SOUND_DRYING_START;
201 particleId = PARTICLE_DRYING_START;
202 }
203 }
204 }
205
206 //play effects
207 ParticleCookingStart(particleId);
208 SoundCookingStart(soundName);
209 }
210
212 {
215 }
216
217 //particles
219 {
220 #ifndef SERVER
222 {
223 //stop previous particles
225
226 //create new
227 vector localPos = MiscGameplayFunctions.GetSteamPosition(GetHierarchyParent());
228 m_ParticleCooking = ParticleManager.GetInstance().PlayInWorld(particle_id, localPos);
230
231 }
232 #endif
233 }
234
236 {
237 if (m_ParticleCooking && GetGame() && !GetGame().IsDedicatedServer())
238 {
239 m_ParticleCooking.Stop();
240 m_ParticleCooking = null;
242 }
243 }
244
246 {
248 {
250 }
251 }
252
254 {
257 }
258
260 {
262 {
264 }
265 }
266
268 {
271
273 sound.SetAutodestroy(true);
274 }
275
277 {
278 vector pos = GetPosition();
279 string surfaceType = GetGame().GetPlayer().GetSurfaceType();
280 string soundSet = "";
281
282 bool diggable = GetGame().IsSurfaceDigable(surfaceType);
283
284 if (!diggable)
285 {
286 soundSet = GetEmptyingLoopSoundsetHard();
287 }
288 else if (diggable)
289 {
290 soundSet = GetEmptyingLoopSoundsetSoft();
291 }
292 else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
293 {
294 soundSet = GetEmptyingLoopSoundsetWater();
295 }
296
297 return soundSet;
298 }
299
301 {
302 vector pos = GetPosition();
303 string surfaceType = GetGame().GetPlayer().GetSurfaceType();
304 string soundSet = "";
305
306 bool diggable = GetGame().IsSurfaceDigable(surfaceType);
307
308 if (!diggable)
309 {
310 soundSet = GetEmptyingEndSoundsetHard();
311 }
312 else if (diggable)
313 {
314 soundSet = GetEmptyingEndSoundsetSoft();
315 }
316 else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
317 {
318 soundSet = GetEmptyingEndSoundsetWater();
319 }
320
321 return soundSet;
322 }
323
331
334 {
335 return m_LiquidEmptyRate;
336 }
337
338 override void SetActions()
339 {
340 super.SetActions();
341
355 }
356
357 override void OnDebugSpawn()
358 {
360 }
361}
void AddAction(typename actionName)
SoundTypeBottle
Definition Bottle_Base.c:2
@ POURING
Definition Bottle_Base.c:3
@ EMPTYING
Definition Bottle_Base.c:4
void StopEmptyingLoopSound()
void StopPouringLoopSound()
float m_LiquidEmptyRate
Definition Bottle_Base.c:43
protected bool m_CookingIsBurned
Definition Bottle_Base.c:34
protected int PARTICLE_BAKING_DONE
Definition Bottle_Base.c:19
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
protected bool m_CookingIsEmpty
Definition Bottle_Base.c:33
protected EffectSound m_EmptyingLoopSound
Definition Bottle_Base.c:28
private const float QUANTITY_EMPTIED_PER_SEC_DEFAULT
Definition Bottle_Base.c:44
string GetEmptyingEndSoundset()
protected int PARTICLE_BURNING_DONE
Definition Bottle_Base.c:24
void RemoveAudioVisuals()
protected int PARTICLE_BAKING_START
Definition Bottle_Base.c:18
protected int PARTICLE_DRYING_START
Definition Bottle_Base.c:21
void ParticleCookingStart(int particle_id)
void PlayEmptyingLoopSound()
protected int PARTICLE_BOILING_START
Definition Bottle_Base.c:15
void RefreshAudioVisuals(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
void RemoveAudioVisualsOnClient()
string GetEmptyingLoopSoundset()
const string SOUND_DRYING_START
Definition Bottle_Base.c:40
protected int PARTICLE_DRYING_DONE
Definition Bottle_Base.c:22
void ~Bottle_Base()
Definition Bottle_Base.c:56
float GetLiquidEmptyRate()
Returns base liquid empty rate (absolute)..preferrably use the 'GetLiquidThroughputCoef' instead.
protected int PARTICLE_BOILING_EMPTY
Definition Bottle_Base.c:14
const string SOUND_DRYING_DONE
Definition Bottle_Base.c:41
protected bool m_CookingIsDone
Definition Bottle_Base.c:32
protected CookingMethodType m_CookingMethod
Definition Bottle_Base.c:31
protected int PARTICLE_BOILING_DONE
Definition Bottle_Base.c:16
const string SOUND_BOILING_DONE
Definition Bottle_Base.c:39
const string SOUND_BOILING_START
Definition Bottle_Base.c:38
enum SoundTypeBottle m_ParticleCooking
protected EffectSound m_PouringLoopSound
Definition Bottle_Base.c:27
void ParticleCookingStop()
void PlayPouringLoopSound()
protected int m_ParticlePlaying
Definition Bottle_Base.c:11
const string SOUND_BOILING_EMPTY
Definition Bottle_Base.c:37
void Synchronize()
CookingMethodType
Definition Cooking.c:2
protected void SoundCookingStop()
const string SOUND_BURNING_DONE
const string SOUND_BAKING_DONE
const string SOUND_BAKING_START
protected void SoundCookingStart(string sound_name)
override void EEDelete(EntityAI parent)
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
void SetQuantityMax()
Definition ItemBase.c:7871
override void OnVariablesSynchronized()
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
int particle_id
void OnRPC(float stamina, float stamina_cap, bool cooldown)
deprecated use, StaminaHandler uses SyncJunctures now
class JsonUndergroundAreaTriggerData GetPosition
override string GetEmptyingEndSoundsetSoft()
override string GetEmptyingEndSoundsetHard()
override string GetPouringSoundset()
override string GetEmptyingLoopSoundsetWater()
override string GetEmptyingEndSoundsetWater()
override string GetEmptyingLoopSoundsetSoft()
override string GetEmptyingLoopSoundsetHard()
override void SetActions()
Definition Cauldron.c:96
bool IsSurfaceDigable(string surface)
Checks if the surface is digable.
Definition Game.c:1087
proto native DayZPlayer GetPlayer()
string GetSurfaceType(SurfaceAnimationBone limbType)
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
void SoundStop()
Stops sound.
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Legacy way of using particles in the game.
Definition Particle.c:7
static const int COOKING_BOILING_DONE
static const int COOKING_BAKING_DONE
static const int COOKING_DRYING_START
static const int COOKING_BOILING_EMPTY
static const int INVALID
static const int COOKING_BURNING_DONE
static const int COOKING_DRYING_DONE
static const int COOKING_BAKING_START
static const int COOKING_BOILING_START
The class that will be instanced (moddable)
Definition gameplay.c:378
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySoundOnObject(string sound_set, Object parent_object, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Read(void value_in)
proto native CGame GetGame()