Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
destructioneffectbase.c
Go to the documentation of this file.
2{
4
6
9
12
15
18
22
25 string m_AmmoType;
26
27
29 {
30 if (m_POneTime)
31 {
32 m_POneTime.Stop();
33 }
34 if (m_PPersistent)
35 {
36 m_PPersistent.Stop();
37 }
38
41 }
42
43 private void Init();
44
46 {
48 }
49
50 private void DealExplosionDamage()
51 {
52 DamageSystem.ExplosionDamage(m_Entity, null, m_AmmoType, m_Entity.GetPosition(), m_DamageType);
53 }
54
55 void OnHealthLevelChanged(notnull EntityAI entity, int oldLevel, int newLevel, string zone)
56 {
57 m_Entity = entity;
58 Init();
59
60 if (g_Game.IsServer())
61 {
62 entity.SetTakeable(m_EntityIsTakeable);
63
64 if (oldLevel != -1 || entity.m_Initialized)
65 {
67 {
68 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ReplaceEntityServer, m_ReplaceDelay, false);
69 }
71 {
73 }
74 OnEntityDestroyedOneTimeServer(entity, oldLevel, zone);
75 }
77 }
78 #ifndef SERVER//client OR single
79 {
80 if (oldLevel != -1 || entity.m_Initialized)//one time
81 {
83
84 if (m_POneTime)
85 {
86 m_POneTime.SetOwner(this);
87 }
88
89 OnEntityDestroyedOneTimeClient(entity, oldLevel, zone);
90
91 m_Entity.PlaySoundSet(m_SOneTime, m_SoundSetOneTime, 0, 0 );
92 m_Entity.PlaySoundSetLoop(m_SPersistent, m_SoundSetPersistent, 0, 0 );
93 }
94 else//Persistent
95 {
97 m_Entity.PlaySoundSetLoop(m_SPersistent, m_SoundSetPersistent, 0, 0 );
98 }
99
101
102 if (m_PPersistent)
103 {
104 m_PPersistent.SetOwner(this);
105 }
106 }
107 #endif
108 }
109
110 private void ReplaceEntityServer()
111 {
112 EntityAI dead_entity = EntityAI.Cast(g_Game.CreateObjectEx(m_ReplaceWithEntity, m_Entity.GetPosition(), ECE_OBJECT_SWAP, RF_ORIGINAL));
113 dead_entity.SetOrientation(m_Entity.GetOrientation());
115 {
116 dead_entity.SetHealth(m_Entity.GetHealth());
117 }
118 m_Entity.Delete();
119 }
120
121 private ParticleSource PlayParticle(int particleType, bool attach = false)
122 {
123 if (!m_Entity)
124 {
125 ErrorEx("Missing entity - something went wrong");
126 return null;
127 }
128 if (particleType)
129 {
130 ParticleSource p = ParticleManager.GetInstance().PlayInWorld(particleType, m_Entity.GetPosition());
131 if (attach && p)
132 {
133 p.AddAsChild(m_Entity);//Note: it's also possible to directly play on object: Particle.PlayOnObject
134 }
135 return p;
136 }
137 return null;
138 }
139
140 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
141 // !!!!!!!!!! Override methods bellow !!!!!!!!!!!!!
142 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
143
144 // ! Client Event called the moment the entity is destroyed, best for explosion and other one-time effects
145 void OnEntityDestroyedOneTimeClient(EntityAI entity, int oldLevel,string zone);
146
147 // ! Server Event called the moment the entity is destroyed
148 void OnEntityDestroyedOneTimeServer(EntityAI entity, int oldLevel, string zone);
149
150 // ! Client Event called at the same moment as the one-time event, but also when the entity is loaded/spawned on client, typically as the player connects to the server or moves close enough so that previously non-existent client entity is now spawned in
152
153 // ! Server Event called at the same moment as the one time event, but also when the entity is loaded/spawned on Server, typically as the server is starting up
155
156 // !Relayed from entity when explosion happens
157 void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType);
158
159}
160
const int ECE_OBJECT_SWAP
const int RF_ORIGINAL
void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
void OnEntityDestroyedOneTimeServer(EntityAI entity, int oldLevel, string zone)
ParticleSource PlayParticle(int particleType, bool attach=false)
void OnEntityDestroyedPersistentClient(EntityAI entity, string zone)
void OnEntityDestroyedPersistentServer(EntityAI entity, string zone)
void OnEntityDestroyedOneTimeClient(EntityAI entity, int oldLevel, string zone)
void OnHealthLevelChanged(notnull EntityAI entity, int oldLevel, int newLevel, string zone)
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
Entity which has the particle instance as an ObjectComponent.
override void AddAsChild(Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
Attaches this particle onto some object.
Manager class for managing Effect (EffectParticle, EffectSound).
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
DamageType
exposed from C++ (do not change)
DayZGame g_Game
Definition dayzgame.c:3942
enum ShapeType ErrorEx
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).