DayZ 1.24
Loading...
Searching...
No Matches
EasterEgg.c File Reference

Go to the source code of this file.

Enumerations

enum  eCaptureState {
  CAPTURE = 0 , RELEASE = 1 , STASIS = 2 , CAPTUREFX = 3 ,
  RELEASEFX = 4 , END
}
 

Functions

void EasterEgg ()
 
void ~EasterEgg ()
 
void ContactEvent (IEntity other, vector pos)
 
override void EOnTouch (IEntity other, int extra)
 
override void EOnContact (IEntity other, Contact extra)
 
override void OnInventoryExit (Man player)
 
override void OnInventoryEnter (Man player)
 
override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
 
void Capture (DayZCreatureAI capAnimal)
 
void Release (vector pos)
 
void PlayVFX ()
 
void ResizeParticle (DayZCreatureAI capAnimal)
 
void PlaySFX (int releaseCase=eCaptureState.CAPTURE)
 
override void OnVariablesSynchronized ()
 
void RegisterSoundSetMap ()
 
override void OnStoreSave (ParamsWriteContext ctx)
 
override bool OnStoreLoad (ParamsReadContext ctx, int version)
 
void DestroyEg ()
 

Variables

enum eCaptureState m_StoredCreature = null
 
string m_CreatureType
 
int m_CreatureHash = 0
 
int m_CaptureState = eCaptureState.STASIS
 
const vector CAPTURE_VELOCITY = { 0, 0, 0 }
 
Particle m_ParCapture
 
float m_ParScale = 1
 
const float PARTICLE_SCALE_MULT = 0.1
 
EffectSound m_CaptureSound
 
EffectSound m_CreatureSound
 
bool m_DangerSound = false
 
ref map< int, stringm_CreatureSoundMap
 
int m_CaptureSoundHash
 
int m_ReleaseSoundHash
 

Enumeration Type Documentation

◆ eCaptureState

Enumerator
CAPTURE 
RELEASE 
STASIS 
CAPTUREFX 
RELEASEFX 
END 

Definition at line 1 of file EasterEgg.c.

2{
3 CAPTURE = 0,
4 RELEASE = 1,
5 STASIS = 2,
6 CAPTUREFX = 3,
7 RELEASEFX = 4,
8
9 //Keep this last value at the end, add any new states before
10 END
11}
@ CAPTURE
Definition EasterEgg.c:3
@ RELEASEFX
Definition EasterEgg.c:7
@ STASIS
Definition EasterEgg.c:5
@ RELEASE
Definition EasterEgg.c:4
@ END
Definition EasterEgg.c:10
@ CAPTUREFX
Definition EasterEgg.c:6

Function Documentation

◆ Capture()

void Capture ( DayZCreatureAI capAnimal)
private

Definition at line 155 of file EasterEgg.c.

156 {
157 if (!IsAlive())
158 {
159 if (m_ParCapture)
160 m_ParCapture.Delete();
161 Delete();
162 return;
163 }
164
168 m_CaptureState = eCaptureState.CAPTUREFX;
169 m_DangerSound = m_StoredCreature.IsDanger();
170 m_CaptureSoundHash = m_StoredCreature.CaptureSound().Hash();
171 m_ReleaseSoundHash = m_StoredCreature.ReleaseSound().Hash();
172
173 //Resize particle upon capture as there is enough delay to be sure value is synced
175
176 SetSynchDirty();
177
178 capAnimal.Delete();
181 }
eCaptureState
Definition EasterEgg.c:2
string m_CreatureType
Definition EasterEgg.c:17
void ResizeParticle(DayZCreatureAI capAnimal)
Definition EasterEgg.c:226
int m_CaptureState
Definition EasterEgg.c:19
int m_ReleaseSoundHash
Definition EasterEgg.c:34
const vector CAPTURE_VELOCITY
Definition EasterEgg.c:20
bool m_DangerSound
Definition EasterEgg.c:30
Particle m_ParCapture
Definition EasterEgg.c:23
enum eCaptureState m_StoredCreature
int m_CaptureSoundHash
Definition EasterEgg.c:33
int m_CreatureHash
Definition EasterEgg.c:18
bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition ItemBase.c:7838
override int GetQuantityMax()
Definition ItemBase.c:7941
proto native void SetVelocity(notnull IEntity ent, vector vel)
Sets linear velocity (for Rigid bodies)
proto native int Hash()
Returns hash of string.

References CAPTURE_VELOCITY, GetQuantityMax(), string::Hash(), m_CaptureSoundHash, m_CaptureState, m_CreatureHash, m_CreatureType, m_DangerSound, m_ParCapture, m_ReleaseSoundHash, m_StoredCreature, ResizeParticle(), SetQuantity(), and SetVelocity().

Referenced by ContactEvent().

◆ ContactEvent()

void ContactEvent ( IEntity other,
vector pos )
protected

Definition at line 61 of file EasterEgg.c.

62 {
63 switch (m_CaptureState)
64 {
65 case eCaptureState.CAPTURE:
67 if (capAnimal && capAnimal.IsAlive())
68 {
69 if (GetGame().IsServer())
71 }
72 else
73 m_CaptureState = eCaptureState.STASIS; //We did not capture anything, go back to stasis
74 break;
75
76 case eCaptureState.RELEASE:
77 Release(pos);
78 PlayVFX();
79 PlaySFX(eCaptureState.RELEASE);
80 break;
81
82 case eCaptureState.CAPTUREFX:
83 case eCaptureState.RELEASEFX:
84 //Intermediate state to play FX on next client side contact event
85 //Creates slight delay but saves network traffic
86 if (m_CreatureHash != 0)
87 {
88 //Make sure to go back in stasis
90 SetSynchDirty();
91 }
92 break;
93
94 case eCaptureState.STASIS:
95 //Do nothing here, feel free to add logic for fun fumble effects when nothing happens :)
96
97 break;
98
99 default: //default in case state is somehow not initialized
100
101 break;
102 }
103 }
void PlayVFX()
Definition EasterEgg.c:210
void Release(vector pos)
Definition EasterEgg.c:183
void Capture(DayZCreatureAI capAnimal)
Definition EasterEgg.c:155
void PlaySFX(int releaseCase=eCaptureState.CAPTURE)
Definition EasterEgg.c:237
do not process rotations !
Definition DayZAnimal.c:573
proto native CGame GetGame()

References Capture(), GetGame(), m_CaptureState, m_CreatureHash, PlaySFX(), PlayVFX(), and Release().

Referenced by EOnContact(), and EOnTouch().

◆ DestroyEg()

void DestroyEg ( )
private

Definition at line 403 of file EasterEgg.c.

404 {
405 Delete();
406 }

◆ EasterEgg()

void EasterEgg ( )
protected

Definition at line 37 of file EasterEgg.c.

38 {
39 m_CreatureType = "";
40 SetEventMask(EntityEvent.CONTACT | EntityEvent.TOUCH);
41 SetFlags(EntityFlags.TRIGGER, false);
42 RegisterNetSyncVariableInt("m_CaptureState", 0, eCaptureState.END);
43 RegisterNetSyncVariableInt("m_CreatureHash", 0, 0);
44 RegisterNetSyncVariableFloat("m_ParScale", 0, 0, 0.1);
45 RegisterNetSyncVariableBool("m_DangerSound");
46 RegisterNetSyncVariableInt("m_CaptureSoundHash", 0, 0);
47 RegisterNetSyncVariableInt("m_ReleaseSoundHash", 0, 0);
48
50 }
void RegisterSoundSetMap()
Definition EasterEgg.c:287
proto native void SetFlags(ShapeFlags flags)
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
EntityFlags
Entity flags.
Definition EnEntity.c:114

References m_CreatureType, RegisterSoundSetMap(), and SetFlags().

◆ EEItemLocationChanged()

override void EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
protected

Definition at line 145 of file EasterEgg.c.

146 {
147 super.EEItemLocationChanged(oldLoc, newLoc);
148
149 //DestroyEg();
150 }

◆ EOnContact()

override void EOnContact ( IEntity other,
Contact extra )
protected

Definition at line 112 of file EasterEgg.c.

113 {
114 ContactEvent(other, extra.Position);
115 }
void ContactEvent(IEntity other, vector pos)
Definition EasterEgg.c:61

References ContactEvent().

◆ EOnTouch()

override void EOnTouch ( IEntity other,
int extra )
protected

Definition at line 106 of file EasterEgg.c.

107 {
109 }
class JsonUndergroundAreaTriggerData GetPosition

References ContactEvent(), and GetPosition.

◆ OnInventoryEnter()

override void OnInventoryEnter ( Man player)
protected

Definition at line 135 of file EasterEgg.c.

136 {
137 //Make sure to stop particles once in inventory
138 if (GetGame().IsClient() && m_ParCapture)
139 {
141 m_ParCapture.Delete();
142 }
143 }
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:262

References GetGame(), m_ParCapture, and Particle::Stop().

◆ OnInventoryExit()

override void OnInventoryExit ( Man player)
protected

Definition at line 117 of file EasterEgg.c.

118 {
119 //Do not execute on simple drop as it may cause issues
121 if (player_PB && player_PB.GetThrowing().IsThrowingAnimationPlaying())
122 {
123 if (m_CreatureType != "")
125 else
127 }
128 else
130
131 //Make sure state is properly synchronized or VFX might bug out
132 SetSynchDirty();
133 }

References m_CaptureState, and m_CreatureType.

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext ctx,
int version )
private

Definition at line 376 of file EasterEgg.c.

377 {
378 if (!super.OnStoreLoad(ctx, version))
379 return false;
380
381 if (!ctx.Read(m_CaptureState))
382 return false;
383
384 if (!ctx.Read(m_CreatureType))
385 return false;
386
387 if (!ctx.Read(m_ParScale))
388 return false;
389
390 if (!ctx.Read(m_DangerSound))
391 return false;
392
393 if (!ctx.Read(m_CaptureSoundHash))
394 return false;
395
396 if (!ctx.Read(m_ReleaseSoundHash))
397 return false;
398
399 return true;
400 }
float m_ParScale
Definition EasterEgg.c:24

References m_CaptureSoundHash, m_CaptureState, m_CreatureType, m_DangerSound, m_ParScale, and m_ReleaseSoundHash.

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext ctx)
private

Definition at line 364 of file EasterEgg.c.

365 {
366 super.OnStoreSave(ctx);
367
368 ctx.Write(m_CaptureState);
369 ctx.Write(m_CreatureType);
370 ctx.Write(m_ParScale);
371 ctx.Write(m_DangerSound);
372 ctx.Write(m_CaptureSoundHash);
373 ctx.Write(m_ReleaseSoundHash);
374 }

References m_CaptureSoundHash, m_CaptureState, m_CreatureType, m_DangerSound, m_ParScale, and m_ReleaseSoundHash.

◆ OnVariablesSynchronized()

override void OnVariablesSynchronized ( )
private

Definition at line 270 of file EasterEgg.c.

271 {
272 if (m_CaptureState == eCaptureState.CAPTUREFX)
273 {
274 PlayVFX();
275 PlaySFX();
276 }
277 else if (m_CaptureState == eCaptureState.RELEASEFX)
278 {
279 PlayVFX();
280 PlaySFX(eCaptureState.RELEASE);
281 }
282 }

References m_CaptureState, PlaySFX(), and PlayVFX().

◆ PlaySFX()

void PlaySFX ( int releaseCase = eCaptureState.CAPTURE)
private

Definition at line 237 of file EasterEgg.c.

238 {
239 if (!GetGame().IsDedicatedServer())
240 {
241 string soundSet = "";
242 if (releaseCase == eCaptureState.CAPTURE)
243 {
244 PlaySoundSet(m_CaptureSound, "EasterEgg_Catch_SoundSet", 0, 0);
245
247 PlaySoundSet(m_CreatureSound, soundSet, 0, 0);
248 }
249 else
250 {
251 if (!m_DangerSound)
252 {
253 PlaySoundSet(m_CaptureSound, "EasterEgg_Spawn_SoundSet", 0, 0);
254
256 PlaySoundSet(m_CreatureSound, soundSet, 0, 0);
257 }
258 else
259 {
260 PlaySoundSet(m_CaptureSound, "EasterEgg_Spawn_Danger_SoundSet", 0, 0);
261
263 PlaySoundSet(m_CreatureSound, soundSet, 0, 0);
264 }
265 }
266 }
267 }
EffectSound m_CreatureSound
Definition EasterEgg.c:29
ref map< int, string > m_CreatureSoundMap
Definition EasterEgg.c:32
EffectSound m_CaptureSound
Definition EasterEgg.c:28

References GetGame(), m_CaptureSound, m_CaptureSoundHash, m_CreatureSound, m_CreatureSoundMap, m_DangerSound, and m_ReleaseSoundHash.

Referenced by ContactEvent(), and OnVariablesSynchronized().

◆ PlayVFX()

void PlayVFX ( )
private

Definition at line 210 of file EasterEgg.c.

211 {
212 if (!GetGame().IsDedicatedServer())
213 {
214 if (!m_ParCapture && m_CaptureState != eCaptureState.STASIS)
215 {
216 //Ideally play a one time effect such as an explosion
218
219 //Resize, -1 signifies ALL emitors
221 m_ParCapture.SetWiggle(7, 0.3);
222 }
223 }
224 }
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
Definition Particle.c:742
void SetParameter(int emitter, int parameter, float value)
Set the value of a parameter of an emitor in the particle.
Definition Particle.c:603
static const int EASTER_EGG_ACTIVATE
EmitorParam
Definition EnVisual.c:114

References ParticleList::EASTER_EGG_ACTIVATE, GetGame(), GetPosition, m_CaptureState, m_ParCapture, m_ParScale, ParticleManager(), Particle::SetParameter(), and Particle::SetWiggle().

Referenced by ContactEvent(), and OnVariablesSynchronized().

◆ RegisterSoundSetMap()

void RegisterSoundSetMap ( )
private

Definition at line 287 of file EasterEgg.c.

288 {
289 //Register all possible creature sounds in map with their respective hash
290 string soundSet;
292
293 //Cow sounds
294 soundSet = "CattleMooA_SoundSet";
295 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
296 soundSet = "CattleBellow_SoundSet";
297 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
298
299 //Deer sounds
300 soundSet = "DeerRoar_SoundSet";
301 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
302 soundSet = "DeerBleat_SoundSet";
303 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
304
305 //Goat sounds
306 soundSet = "GoatBleat_A_SoundSet";
307 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
308 soundSet = "GoatBleat_B_SoundSet";
309 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
310
311 //Hare sounds
312 soundSet = "HareChirp_SoundSet";
313 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
314 soundSet = "HareSquawk_SoundSet";
315 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
316
317 //Hen sounds
318 soundSet = "HenCluck_X_SoundSet";
319 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
320 soundSet = "HenScream_SoundSet";
321 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
322
323 //Hog sounds
324 soundSet = "HogGrunt_G_SoundSet";
325 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
326 soundSet = "HogSqueal_SoundSet";
327 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
328
329 //Sheep sounds
330 soundSet = "SheepBleat_G_SoundSet";
331 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
332 soundSet = "SheepBleat_E_SoundSet";
333 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
334
335 //Wolf sounds
336 soundSet = "WolfBark_SoundSet";
337 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
338 soundSet = "WolfWhimper_SoundSet";
339 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
340
341 //Zmb F sounds
342 soundSet = "ZmbF_Normal_CallToArmsShort_Soundset";
343 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
344 soundSet = "ZmbF_Normal_HeavyHit_Soundset";
345 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
346
347 //Zmb M sounds
348 soundSet = "ZmbM_Normal_CallToArmsShort_Soundset";
349 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
350 soundSet = "ZmbM_Normal_HeavyHit_Soundset";
351 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
352
353 //Bear sounds
354 soundSet = "BearRoarShort_SoundSet";
355 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
356 soundSet = "BearSnarl_SoundSet";
357 m_CreatureSoundMap.Insert(soundSet.Hash(), soundSet);
358 }

References m_CreatureSoundMap.

Referenced by EasterEgg().

◆ Release()

void Release ( vector pos)
private

Definition at line 183 of file EasterEgg.c.

184 {
185 if (GetGame().IsServer())
186 {
187 m_CaptureState = eCaptureState.RELEASEFX;
188 m_CreatureHash = 0;
189 SetSynchDirty();
190
191 GetGame().CreateObject(m_CreatureType, pos, false, true);
192 m_CreatureType = "";
193
194 DecreaseHealth("", "", GetMaxHealth() * 0.4);
195 SetQuantity(GetQuantityMin(), false);
197
198 if (!IsAlive())
199 {
200 if (m_ParCapture)
201 m_ParCapture.Delete();
202 Delete();
203 }
204 }
205 }
int GetQuantityMin()
Definition ItemBase.c:7979

References CAPTURE_VELOCITY, GetGame(), GetQuantityMin(), m_CaptureState, m_CreatureHash, m_CreatureType, m_ParCapture, SetQuantity(), and SetVelocity().

Referenced by ContactEvent().

◆ ResizeParticle()

void ResizeParticle ( DayZCreatureAI capAnimal)
private

Definition at line 226 of file EasterEgg.c.

227 {
228 //Determine particle scale depending on captured animal scale
230 capAnimal.GetWorldBounds(mins, maxs);
232
233 //Multiply to rescale down as fed values can be really large
235 }
const float PARTICLE_SCALE_MULT
Definition EasterEgg.c:25
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.

References vector::DistanceSq(), m_ParScale, and PARTICLE_SCALE_MULT.

Referenced by Capture().

◆ ~EasterEgg()

void ~EasterEgg ( )
protected

Definition at line 52 of file EasterEgg.c.

53 {
54 if (m_ParCapture)
56 }

References m_ParCapture, and Particle::Stop().

Variable Documentation

◆ CAPTURE_VELOCITY

const vector CAPTURE_VELOCITY = { 0, 0, 0 }
private

Definition at line 20 of file EasterEgg.c.

20{ 0, 0, 0 };

Referenced by Capture(), and Release().

◆ m_CaptureSound

EffectSound m_CaptureSound
protected

Definition at line 28 of file EasterEgg.c.

Referenced by PlaySFX().

◆ m_CaptureSoundHash

int m_CaptureSoundHash
protected

Definition at line 33 of file EasterEgg.c.

Referenced by Capture(), OnStoreLoad(), OnStoreSave(), and PlaySFX().

◆ m_CaptureState

◆ m_CreatureHash

int m_CreatureHash = 0
private

Definition at line 18 of file EasterEgg.c.

Referenced by Capture(), ContactEvent(), and Release().

◆ m_CreatureSound

EffectSound m_CreatureSound
protected

Definition at line 29 of file EasterEgg.c.

Referenced by PlaySFX().

◆ m_CreatureSoundMap

ref map<int, string> m_CreatureSoundMap
protected

Definition at line 32 of file EasterEgg.c.

Referenced by PlaySFX(), and RegisterSoundSetMap().

◆ m_CreatureType

string m_CreatureType
private

Definition at line 17 of file EasterEgg.c.

Referenced by Capture(), EasterEgg(), OnInventoryExit(), OnStoreLoad(), OnStoreSave(), and Release().

◆ m_DangerSound

bool m_DangerSound = false
protected

Definition at line 30 of file EasterEgg.c.

Referenced by Capture(), OnStoreLoad(), OnStoreSave(), and PlaySFX().

◆ m_ParCapture

Particle m_ParCapture
protected

Definition at line 23 of file EasterEgg.c.

Referenced by Capture(), OnInventoryEnter(), PlayVFX(), Release(), and ~EasterEgg().

◆ m_ParScale

float m_ParScale = 1
private

Definition at line 24 of file EasterEgg.c.

Referenced by OnStoreLoad(), OnStoreSave(), PlayVFX(), and ResizeParticle().

◆ m_ReleaseSoundHash

int m_ReleaseSoundHash
protected

Definition at line 34 of file EasterEgg.c.

Referenced by Capture(), OnStoreLoad(), OnStoreSave(), and PlaySFX().

◆ m_StoredCreature

enum eCaptureState m_StoredCreature = null

Referenced by Capture().

◆ PARTICLE_SCALE_MULT

const float PARTICLE_SCALE_MULT = 0.1
private

Definition at line 25 of file EasterEgg.c.

Referenced by ResizeParticle().