DayZ 1.24
Loading...
Searching...
No Matches
Trap_LandMine.c
Go to the documentation of this file.
5
6class LandMineTrap extends TrapBase
7{
12
13 private const int BROKEN_LEG_PROB = 90;
14 private const int BLEED_SOURCE_PROB = 50;
15 private const int MAX_BLEED_SOURCE = 1;
16
18 {
19 m_DefectRate = 15;
20 m_DamagePlayers = 0; //How much damage player gets when caught
21 m_InitWaitTime = 10; //After this time after deployment, the trap is activated
22 m_InfoActivationTime = string.Format("#STR_LandMineTrap0%1#STR_LandMineTrap1", m_InitWaitTime.ToString());
23
25
26 //Order is important and must match clothing array in DamageClothing method
28 m_ClothingDmg.Insert(60); //Trousers
29 m_ClothingDmg.Insert(100); //BackPack
30 m_ClothingDmg.Insert(40); //Vest
31 m_ClothingDmg.Insert(10); //HeadGear
32 m_ClothingDmg.Insert(10); //Mask
33 m_ClothingDmg.Insert(40); //Body
34 m_ClothingDmg.Insert(50); //Feet
35 m_ClothingDmg.Insert(5); //Gloves
36 }
37
43
45 {
46 super.StartActivate(player);
47
48 if (!GetGame().IsDedicatedServer())
49 {
51 {
52 m_SafetyPinSound = SEffectManager.PlaySound("landmine_safetyPin_SoundSet", GetPosition(), 0, 0, false);
53 m_SafetyPinSound.SetAutodestroy(true);
54 }
55
57 m_TimerLoopSound = SEffectManager.PlaySound("landmine_timer2_SoundSet", GetPosition(), 0, 0, true);
58 }
59 }
60
62 {
63 SetHealth("", "", 0.0);
64 DeleteThis();
65 }
66
67 override void OnActivate()
68 {
69 if (!GetGame().IsDedicatedServer())
70 {
72 {
73 m_TimerLoopSound.SetAutodestroy(true);
74 m_TimerLoopSound.SoundStop();
75 }
76
77 if (GetGame().GetPlayer())
79 }
80 }
81
82 override bool CanExplodeInFire()
83 {
84 return true;
85 }
86
87 override void OnUpdate(EntityAI victim)
88 {
89 if (victim && victim.IsInherited(CarScript))
90 {
92 if (wheel)
94 }
95 }
96
98 {
99 int i;
100
101 if (GetGame().IsServer() && victim)
102 {
103 if (!victim.GetAllowDamage())
104 return;
105
106 if (victim.IsInherited(CarScript))
107 {
110 m_UpdateTimer.Run(UPDATE_TIMER_INTERVAL, this, "OnUpdate", params, true);
111
112 return;
113 }
114 else
115 {
116 //Check if we have a player
118 if (victim_PB && victim_PB.IsAlive())
119 {
120 int randNum; //value used for probability evaluation
121 randNum = Math.RandomInt(0, 100);
123 {
124 float damage = victim_PB.GetMaxHealth("RightLeg", ""); //deal 100% damage to break legs
125 victim_PB.DamageAllLegs(damage);
126 }
127
128 randNum = Math.RandomInt(0, 100);
130 {
131 for (i = 0; i < MAX_BLEED_SOURCE; i++)
132 {
133 //We add two bleeding sources max to lower half
134 randNum = Math.RandomIntInclusive(0, PlayerBase.m_BleedingSourcesLow.Count() - 1);
135
136 victim_PB.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesLow[randNum]);
137 }
138 }
139
141 }
142 else
143 {
145 if (victim_IB)
147 }
148
149 Explode(DamageType.EXPLOSION);
150 }
151
152 DeleteThis();
153 }
154
155 super.OnSteppedOn(victim);
156 }
157
159 {
160 if (victim.IsInherited(CarScript))
161 {
162 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
163 m_UpdateTimer.Stop();
164 }
165 }
166
167 protected void OnServerSteppedOn(Object obj, string damageZone)
168 {
169 if (obj.IsInherited(CarWheel))
170 {
171 obj.ProcessDirectDamage(DT_CLOSE_COMBAT, this, "", "LandMineExplosion_CarWheel", "0 0 0", 1);
172 Explode(DamageType.EXPLOSION);
173
174 if (m_UpdateTimer.IsRunning())
175 m_UpdateTimer.Stop();
176
177 }
178
179 SetInactive(false);
180 Synch(EntityAI.Cast(obj));
181 }
182
184 {
186 m_DeleteTimer.Run(1, this, "DeleteSafe");
187 }
188
190 {
191 super.OnItemLocationChanged(old_owner, new_owner);
192 }
193
194 override void EEKilled(Object killer)
195 {
196 super.EEKilled(killer);
197
198 Explode(DamageType.EXPLOSION);
199 }
200
202 {
203 if (!GetGame().IsDedicatedServer())
204 {
205 EffectSound sound = SEffectManager.PlaySound("landmineActivate_SoundSet", GetPosition(), 0, 0, false);
206 sound.SetAutodestroy(true);
207 }
208 }
209
210 override void Explode(int damageType, string ammoType = "")
211 {
212 if (ammoType == "")
213 ammoType = ConfigGetString("ammoType");
214
215 if (ammoType == "")
216 ammoType = "Dummy_Heavy";
217
218 if (GetGame().IsServer())
219 {
220 SynchExplosion();
221 vector offset = Vector(0, 0.1, 0); //Vertical offset applied to landmine explosion (in meters)
222 DamageSystem.ExplosionDamage(this, NULL, ammoType, GetPosition() + offset, damageType); //Offset explosion on Y axis
223 DeleteThis();
224 }
225 }
226
227 override bool CanBeDisarmed()
228 {
229 return true;
230 }
231
233 {
234 super.OnRPC(sender, rpc_type, ctx);
235
236 Param1<bool> p = new Param1<bool>(false);
237
238 if (!ctx.Read(p))
239 return;
240
241 bool play = p.param1;
242 switch (rpc_type)
243 {
244 case SoundTypeMine.DISARMING:
245 if (play)
247 else
249
250 break;
251 }
252 }
253
255 {
256 if (!m_DisarmingLoopSound || !m_DisarmingLoopSound.IsSoundPlaying())
257 m_DisarmingLoopSound = SEffectManager.PlaySound("landmine_deploy_SoundSet", GetPosition());
258 }
259
261 {
262 m_DisarmingLoopSound.SoundStop();
263 }
264
265 //================================================================
266 // ADVANCED PLACEMENT
267 //================================================================
268
269 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
270 {
271 super.OnPlacementComplete(player, position, orientation);
272
273 if (GetGame().IsServer())
274 {
277 }
278 }
279
280 override bool IsDeployable()
281 {
282 return true;
283 }
284
285 override string GetLoopDeploySoundset()
286 {
287 return "landmine_deploy_SoundSet";
288 }
289
290 override void SetActions()
291 {
292 super.SetActions();
293
294 AddAction(ActionAttach);
297 AddAction(ActionDeployObject);
298 }
299
300#ifdef DEVELOPER
301 //================================================================
302 // DEBUG
303 //================================================================
304
305 //Debug menu Spawn Ground Special
306 override void OnDebugSpawn()
307 {
309 }
310
312 {
313 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Activate", FadeColors.LIGHT_GREY));
314 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Deactivate", FadeColors.LIGHT_GREY));
315 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
316
317 super.GetDebugActions(outputList);
318 }
319
320 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
321 {
322 if (super.OnAction(action_id, player, ctx))
323 return true;
324 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
325 {
326 if (action_id == EActions.ACTIVATE_ENTITY)
328 else if (action_id == EActions.DEACTIVATE_ENTITY)
329 SetInactive();
330 }
331 return false;
332 }
333#endif
334}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition EntityAI.c:97
void ActionDetach()
void AddAction(typename actionName)
DamageType
exposed from C++ (do not change)
void OnRPC(ParamsReadContext ctx)
EActions
Definition EActions.c:2
override void EEKilled(Object killer)
ref Timer m_DeleteTimer
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition ItemBase.c:6834
bool CanExplodeInFire()
Definition ItemBase.c:7019
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Definition ItemBase.c:5867
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition ItemBase.c:6792
PlayerBase GetPlayer()
ref Timer m_UpdateTimer
Definition RadialMenu.c:20
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
void LandMineTrap()
ref EffectSound m_DisarmingLoopSound
override void Explode(int damageType, string ammoType="")
void PlayDisarmingLoopSound()
ref EffectSound m_SafetyPinSound
void ~LandMineTrap()
void DeleteThis()
void PlaySoundActivate()
SoundTypeMine
@ DISARMING
const int BROKEN_LEG_PROB
const int MAX_BLEED_SOURCE
const int BLEED_SOURCE_PROB
void StopDisarmingLoopSound()
enum SoundTypeMine m_TimerLoopSound
float m_DefectRate
Definition TrapBase.c:19
ref array< int > m_ClothingDmg
Definition TrapBase.c:46
void Synch(EntityAI victim)
keeping "step" here for consistency only
Definition TrapBase.c:280
const float UPDATE_TIMER_INTERVAL
Definition TrapBase.c:15
const int DAMAGE_TRIGGER_MINE
Definition TrapBase.c:14
EntityAI GetClosestCarWheel(EntityAI victim)
Definition TrapBase.c:612
string m_InfoActivationTime
Definition TrapBase.c:40
void SetInactive(bool stop_timer=true)
Definition TrapBase.c:452
float m_InitWaitTime
Definition TrapBase.c:17
void DamageClothing(PlayerBase player)
Definition TrapBase.c:649
float m_DamagePlayers
Definition TrapBase.c:20
void StartActivate(PlayerBase player)
Definition TrapBase.c:431
bool m_AddDeactivationDefect
Definition TrapBase.c:24
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
Definition EnMath.c:7
The class that will be instanced (moddable)
Definition gameplay.c:376
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySound(string sound_set, vector position, 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
void OnServerSteppedOn(Object obj, string damageZone)
Definition Trap_Bear.c:128
override void OnSteppedOn(EntityAI victim)
Definition Trap_Bear.c:63
override string GetLoopDeploySoundset()
Definition Trap_Bear.c:232
override void OnActivate()
Definition Trap_Bear.c:198
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition Trap_Bear.c:216
override bool CanBeDisarmed()
Definition Trap_Bear.c:25
override bool IsDeployable()
Definition Trap_Bear.c:227
override void SetActions()
Definition Trap_Bear.c:237
override void OnSteppedOut(EntityAI victim)
Definition Trap_Bear.c:119
proto string ToString()
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54
const int SAT_DEBUG_ACTION
Definition constants.c:424
static proto string Format(string fmt, 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)
Gets n-th character from string.
proto native void OnUpdate()
Definition tools.c:333
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8