DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 {
33 }
34 if (m_PPersistent)
35 {
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 (GetGame().IsServer())
61 {
62 entity.SetTakeable(m_EntityIsTakeable);
63
64 if (oldLevel != -1 || entity.m_Initialized)
65 {
67 {
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 {
105 }
106 }
107 #endif
108 }
109
110 private void ReplaceEntityServer()
111 {
112 EntityAI dead_entity = EntityAI.Cast(GetGame().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
DamageType
exposed from C++ (do not change)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
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)
void OnEntityDestroyedPersistentClient(EntityAI entity, string zone)
void OnEntityDestroyedPersistentServer(EntityAI entity, string zone)
private ParticleSource PlayParticle(int particleType, bool attach=false)
void OnEntityDestroyedOneTimeClient(EntityAI entity, int oldLevel, string zone)
void OnHealthLevelChanged(notnull EntityAI entity, int oldLevel, int newLevel, string zone)
private void Init()
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:266
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. If null value is provided then the particle will be detached...
proto native void SetOwner(Class owner)
Set the owner of this ParticleSource.
Manager class for managing Effect (EffectParticle, EffectSound)
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native CGame GetGame()
enum ShapeType ErrorEx
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8