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

Go to the source code of this file.

Enumerations

enum  SoundTypeMine { DISARMING = 0 }
 

Functions

void LandMineTrap ()
 
void ~LandMineTrap ()
 
override void StartActivate (PlayerBase player)
 
override void OnActivatedByItem (notnull ItemBase item)
 Called when this item is activated by other.
 
override void OnActivate ()
 HumanCommandScript fully scriptable command.
 
override bool CanExplodeInFire ()
 
override void OnUpdate (EntityAI victim)
 
override void OnSteppedOn (EntityAI victim)
 
override void OnSteppedOut (EntityAI victim)
 
void OnServerSteppedOn (Object obj, string damageZone)
 
void DeleteThis ()
 
override void OnItemLocationChanged (EntityAI old_owner, EntityAI new_owner)
 
override void EEKilled (Object killer)
 
void PlaySoundActivate ()
 
override void Explode (int damageType, string ammoType="")
 
override bool CanBeDisarmed ()
 
override void OnRPC (PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
 
void PlayDisarmingLoopSound ()
 
void StopDisarmingLoopSound ()
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override bool IsDeployable ()
 
override string GetLoopDeploySoundset ()
 
override void SetActions ()
 

Variables

enum SoundTypeMine m_TimerLoopSound
 
ref EffectSound m_SafetyPinSound
 
ref EffectSound m_DisarmingLoopSound
 
ref Timer m_DeleteTimer
 
const int BROKEN_LEG_PROB = 90
 
const int BLEED_SOURCE_PROB = 50
 
const int MAX_BLEED_SOURCE = 1
 

Enumeration Type Documentation

◆ SoundTypeMine

Enumerator
DISARMING 

Definition at line 1 of file Trap_LandMine.c.

2{
3 DISARMING = 0
4}
@ DISARMING

Function Documentation

◆ CanBeDisarmed()

override bool CanBeDisarmed ( )
protected

Definition at line 227 of file Trap_LandMine.c.

228 {
229 return true;
230 }

◆ CanExplodeInFire()

override bool CanExplodeInFire ( )
private

Definition at line 82 of file Trap_LandMine.c.

83 {
84 return true;
85 }

◆ DeleteThis()

void DeleteThis ( )
protected

Definition at line 183 of file Trap_LandMine.c.

184 {
186 m_DeleteTimer.Run(1, this, "DeleteSafe");
187 }
ref Timer m_DeleteTimer
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, and m_DeleteTimer.

Referenced by Explode(), OnActivatedByItem(), and OnSteppedOn().

◆ EEKilled()

override void EEKilled ( Object killer)
protected

Definition at line 194 of file Trap_LandMine.c.

195 {
196 super.EEKilled(killer);
197
198 Explode(DamageType.EXPLOSION);
199 }
DamageType
exposed from C++ (do not change)
override void Explode(int damageType, string ammoType="")

References Explode().

◆ Explode()

override void Explode ( int damageType,
string ammoType = "" )
protected

Definition at line 210 of file Trap_LandMine.c.

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 }
void DeleteThis()
class JsonUndergroundAreaTriggerData GetPosition
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References DeleteThis(), GetGame(), GetPosition, and Vector().

Referenced by FuelStation::EEKilled(), InventoryItem::EEKilled(), EEKilled(), ExplodeNow(), InitiateExplosion(), Grenade_Base::InitiateExplosion(), OnServerSteppedOn(), and OnSteppedOn().

◆ GetLoopDeploySoundset()

override string GetLoopDeploySoundset ( )
protected

Definition at line 285 of file Trap_LandMine.c.

286 {
287 return "landmine_deploy_SoundSet";
288 }

◆ IsDeployable()

override bool IsDeployable ( )
protected

Definition at line 280 of file Trap_LandMine.c.

281 {
282 return true;
283 }

◆ LandMineTrap()

void LandMineTrap ( )
private

Definition at line 17 of file Trap_LandMine.c.

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 }
float m_DefectRate
Definition TrapBase.c:19
ref array< int > m_ClothingDmg
Definition TrapBase.c:46
string m_InfoActivationTime
Definition TrapBase.c:40
float m_InitWaitTime
Definition TrapBase.c:17
float m_DamagePlayers
Definition TrapBase.c:20
bool m_AddDeactivationDefect
Definition TrapBase.c:24
proto string ToString()
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.

References string::Format(), m_AddDeactivationDefect, m_ClothingDmg, m_DamagePlayers, m_DefectRate, m_InfoActivationTime, m_InitWaitTime, and float::ToString().

Referenced by ActionCondition(), OnAnimationEvent(), OnEndAnimationLoop(), OnFinishProgressServer(), and OnStartAnimationLoop().

◆ OnActivate()

override void OnActivate ( )
private

HumanCommandScript fully scriptable command.

Warning
NON-MANAGED, will be managed by C++ once it is sent to the CommandHandler through Human.StartCommand_Script
Note
So ideally, it is best to set up the HumanCommandScript, not create any instances and start it through Human.StartCommand_ScriptInst In case an instance needs to be created, it needs manual deletion if not sent to the CommandHandler But deleting it while it is in the CommandHandler will cause crashes constructor must have 1st parameter to be Human virtual to be overridden called when command starts

Definition at line 67 of file Trap_LandMine.c.

68 {
69 if (!GetGame().IsDedicatedServer())
70 {
72 {
73 m_TimerLoopSound.SetAutodestroy(true);
74 m_TimerLoopSound.SoundStop();
75 }
76
77 if (GetGame().GetPlayer())
79 }
80 }
PlayerBase GetPlayer()
void PlaySoundActivate()
enum SoundTypeMine m_TimerLoopSound

References GetGame(), GetPlayer(), m_TimerLoopSound, and PlaySoundActivate().

◆ OnActivatedByItem()

override void OnActivatedByItem ( notnull ItemBase item)
private

Called when this item is activated by other.

Definition at line 61 of file Trap_LandMine.c.

62 {
63 SetHealth("", "", 0.0);
64 DeleteThis();
65 }

References DeleteThis().

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
protected

Definition at line 189 of file Trap_LandMine.c.

190 {
191 super.OnItemLocationChanged(old_owner, new_owner);
192 }

◆ OnPlacementComplete()

override void OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
protected

Definition at line 269 of file Trap_LandMine.c.

270 {
271 super.OnPlacementComplete(player, position, orientation);
272
273 if (GetGame().IsServer())
274 {
277 }
278 }
override void StartActivate(PlayerBase player)

References GetGame(), and StartActivate().

◆ OnRPC()

override void OnRPC ( PlayerIdentity sender,
int rpc_type,
ParamsReadContext ctx )
protected

Definition at line 232 of file Trap_LandMine.c.

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 }
void PlayDisarmingLoopSound()
SoundTypeMine
void StopDisarmingLoopSound()

References PlayDisarmingLoopSound(), and StopDisarmingLoopSound().

◆ OnServerSteppedOn()

void OnServerSteppedOn ( Object obj,
string damageZone )
protected

Definition at line 167 of file Trap_LandMine.c.

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 }
ref Timer m_UpdateTimer
Definition RadialMenu.c:20
void Synch(EntityAI victim)
keeping "step" here for consistency only
Definition TrapBase.c:280
void SetInactive(bool stop_timer=true)
Definition TrapBase.c:452

References Explode(), m_UpdateTimer, SetInactive(), and Synch().

◆ OnSteppedOn()

override void OnSteppedOn ( EntityAI victim)
private

CarScript specific reaction on LandMineTrap

Definition at line 97 of file Trap_LandMine.c.

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 }
const int BROKEN_LEG_PROB
const int MAX_BLEED_SOURCE
const int BLEED_SOURCE_PROB
const float UPDATE_TIMER_INTERVAL
Definition TrapBase.c:15
const int DAMAGE_TRIGGER_MINE
Definition TrapBase.c:14
void DamageClothing(PlayerBase player)
Definition TrapBase.c:649
Definition EnMath.c:7
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

References BLEED_SOURCE_PROB, BROKEN_LEG_PROB, DAMAGE_TRIGGER_MINE, DamageClothing(), DeleteThis(), Explode(), GetGame(), m_UpdateTimer, MAX_BLEED_SOURCE, Math::RandomInt(), Math::RandomIntInclusive(), and UPDATE_TIMER_INTERVAL.

◆ OnSteppedOut()

override void OnSteppedOut ( EntityAI victim)
private

Definition at line 158 of file Trap_LandMine.c.

159 {
160 if (victim.IsInherited(CarScript))
161 {
162 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
163 m_UpdateTimer.Stop();
164 }
165 }

References m_UpdateTimer.

◆ OnUpdate()

override void OnUpdate ( EntityAI victim)
private

Definition at line 87 of file Trap_LandMine.c.

88 {
89 if (victim && victim.IsInherited(CarScript))
90 {
92 if (wheel)
94 }
95 }
void OnServerSteppedOn(Object obj, string damageZone)
EntityAI GetClosestCarWheel(EntityAI victim)
Definition TrapBase.c:612

References GetClosestCarWheel(), and TrapBase::OnServerSteppedOn().

◆ PlayDisarmingLoopSound()

void PlayDisarmingLoopSound ( )
protected

Definition at line 254 of file Trap_LandMine.c.

255 {
256 if (!m_DisarmingLoopSound || !m_DisarmingLoopSound.IsSoundPlaying())
257 m_DisarmingLoopSound = SEffectManager.PlaySound("landmine_deploy_SoundSet", GetPosition());
258 }
ref EffectSound m_DisarmingLoopSound
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.

References GetPosition, m_DisarmingLoopSound, and SEffectManager::PlaySound().

Referenced by OnRPC().

◆ PlaySoundActivate()

void PlaySoundActivate ( )
protected

Definition at line 201 of file Trap_LandMine.c.

202 {
203 if (!GetGame().IsDedicatedServer())
204 {
205 EffectSound sound = SEffectManager.PlaySound("landmineActivate_SoundSet", GetPosition(), 0, 0, false);
206 sound.SetAutodestroy(true);
207 }
208 }
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5

References GetGame(), GetPosition, and SEffectManager::PlaySound().

Referenced by OnActivate().

◆ SetActions()

override void SetActions ( )
protected

Definition at line 290 of file Trap_LandMine.c.

291 {
292 super.SetActions();
293
294 AddAction(ActionAttach);
297 AddAction(ActionDeployObject);
298 }
void ActionDetach()
void AddAction(typename actionName)

References ActionDetach(), and AddAction().

◆ StartActivate()

override void StartActivate ( PlayerBase player)
private

Definition at line 44 of file Trap_LandMine.c.

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 }
ref EffectSound m_SafetyPinSound

References GetGame(), GetPosition, m_SafetyPinSound, m_TimerLoopSound, and SEffectManager::PlaySound().

◆ StopDisarmingLoopSound()

void StopDisarmingLoopSound ( )
protected

Definition at line 260 of file Trap_LandMine.c.

261 {
262 m_DisarmingLoopSound.SoundStop();
263 }

References m_DisarmingLoopSound.

Referenced by OnRPC().

◆ ~LandMineTrap()

void ~LandMineTrap ( )
private

Definition at line 38 of file Trap_LandMine.c.

39 {
42 }
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.

References SEffectManager::DestroyEffect(), m_DisarmingLoopSound, and m_TimerLoopSound.

Variable Documentation

◆ BLEED_SOURCE_PROB

const int BLEED_SOURCE_PROB = 50
private

Definition at line 14 of file Trap_LandMine.c.

Referenced by OnSteppedOn().

◆ BROKEN_LEG_PROB

const int BROKEN_LEG_PROB = 90
private

Definition at line 13 of file Trap_LandMine.c.

Referenced by OnSteppedOn().

◆ m_DeleteTimer

ref Timer m_DeleteTimer
protected

Definition at line 11 of file Trap_LandMine.c.

◆ m_DisarmingLoopSound

ref EffectSound m_DisarmingLoopSound
protected

Definition at line 10 of file Trap_LandMine.c.

Referenced by PlayDisarmingLoopSound(), StopDisarmingLoopSound(), and ~LandMineTrap().

◆ m_SafetyPinSound

ref EffectSound m_SafetyPinSound
protected

Definition at line 9 of file Trap_LandMine.c.

Referenced by StartActivate().

◆ m_TimerLoopSound

enum SoundTypeMine m_TimerLoopSound

◆ MAX_BLEED_SOURCE

const int MAX_BLEED_SOURCE = 1
private

Definition at line 15 of file Trap_LandMine.c.

Referenced by OnSteppedOn().