Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
wreck_santassleigh.c
Go to the documentation of this file.
1 //Christmas Event: Santa's Sleigh
2 class Wreck_SantasSleigh extends CrashBase
3 {
4  XmasSleighLight m_SleighLight;
5 
6  int m_MaxDeersAmount = 4;
7  int m_MinDeersAmount = 2;
8  int m_MaxDeersSpawnRange = 25;
9  int m_MinDeersSpawnRange = 5;
10 
11  void Wreck_SantasSleigh()
12  {
13  if ( !GetGame().IsDedicatedServer() )
14  {
15  //particles - Aurora trail
16  m_ParticleEfx = ParticleManager.GetInstance().PlayOnObject(ParticleList.AURORA_SANTA_WRECK, this, Vector(0, 0, 0));
17 
18  //lights - green light
19  m_SleighLight = XmasSleighLight.Cast( ScriptedLightBase.CreateLight( XmasSleighLight, Vector(0, 0, 0) ) );
20  m_SleighLight.AttachOnMemoryPoint( this, "light" );
21  }
22  }
23 
24  // needs to have the soundset registered in CrashBase.Init()
25  override string GetSoundSet()
26  {
27  return "SledgeCrash_Distant_SoundSet";
28  }
29 
30  override void EEOnCECreate()
31  {
32  super.EEOnCECreate();
33  SpawnRandomDeerLater();
34  }
35 
36  override void EEDelete(EntityAI parent)
37  {
38  super.EEDelete(parent);
39 
40  if ( !GetGame().IsDedicatedServer() )
41  {
42  if ( m_SleighLight )
43  m_SleighLight.Destroy();
44  }
45  }
46 
47  void SpawnRandomDeerLater()
48  {
49  //SpawnRandomDeers();
50  GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( SpawnRandomDeers, 0);
51  }
52 
53  //Spawn a random amount of (dead) deers around the sleigh
54  void SpawnRandomDeers()
55  {
56  EntityAI deer;
57  vector crash_pos = GetPosition();
58 
59  int deersAmount = Math.RandomIntInclusive(m_MinDeersAmount,m_MaxDeersAmount);
60 
61  for (int i = 0; i < m_MaxDeersAmount; i++)
62  {
63  vector deer_pos = RandomizePosition(crash_pos);
64  deer = EntityAI.Cast(GetGame().CreateObject("Animal_CervusElaphus", deer_pos,false, true));
65  deer.SetHealth01("","", 0);
66  vector orientation = deer.GetOrientation();
67  deer.SetOrientation(Vector(Math.RandomIntInclusive(0,360),orientation[1],orientation[2]));
68  }
69  }
70 
71  //Return a new vector scattered around origin.
73  {
74  int randX;
75  int randZ;
76 
77  randX = Math.RandomIntInclusive(m_MinDeersSpawnRange, m_MaxDeersSpawnRange);
78  if (Math.RandomIntInclusive(0,1) < 1)
79  randX = -randX;
80 
81  randZ = Math.RandomIntInclusive(m_MinDeersSpawnRange, m_MaxDeersSpawnRange);
82  if (Math.RandomIntInclusive(0,1) < 1)
83  randZ = -randZ;
84 
85  origin[0] = origin[0] + randX;
86  origin[2] = origin[2] + randZ;
87 
88  return origin;
89 
90  }
91 }
GetGame
proto native CGame GetGame()
RandomizePosition
void RandomizePosition()
Definition: mapnavigationbehaviour.c:93
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
EEOnCECreate
override void EEOnCECreate()
Definition: fireworksbase.c:23
EEDelete
override void EEDelete(EntityAI parent)
Definition: contaminatedarea.c:69
CrashBase
Definition: wreck_mi8.c:2
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
ParticleList
Definition: particlelist.c:11
vector
Definition: enconvert.c:105
ScriptedLightBase
Definition: pointlightbase.c:1
Math
Definition: enmath.c:6
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EntityAI
Definition: building.c:5