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

Go to the source code of this file.

Classes

class  TripwireTrapDeployed
 

Enumerations

enum  eWireMaterial { WIRE = 0 , BARBED_WIRE = 1 , ROPE = 2 }
 

Functions

void TripwireTrap ()
 
override void OnVariablesSynchronized ()
 
override void OnStoreSave (ParamsWriteContext ctx)
 
override bool OnStoreLoad (ParamsReadContext ctx, int version)
 
override void CreateTrigger ()
 
override void OnSteppedOn (EntityAI victim)
 
override void OnItemLocationChanged (EntityAI old_owner, EntityAI new_owner)
 
override void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
 
override void EEHealthLevelChanged (int oldLevel, int newLevel, string zone)
 
override void SetInactive (bool stop_timer=true)
 
void SetState (int state_ID)
 
int GetState ()
 returns one of STATE_...
 
void SetWireType (int wireType)
 
int GetWireType ()
 
override void RefreshState ()
 
override void SetupTrapPlayer (PlayerBase player, bool set_position=true)
 
override void StartDeactivate (PlayerBase player)
 
override bool CanReceiveAttachment (EntityAI attachment, int slotId)
 
override bool CanDisplayAttachmentSlot (int slot_id)
 
override void EEItemAttached (EntityAI item, string slot_name)
 
override void EEItemDetached (EntityAI item, string slot_name)
 
override void EEKilled (Object killer)
 
void FoldTripWire ()
 
override void OnInventoryEnter (Man player)
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override void OnPlacementCancelled (Man player)
 
override bool IsDeployable ()
 
override bool IsTakeable ()
 
override string GetDeploySoundset ()
 
override string GetLoopDeploySoundset ()
 
override void SetActions ()
 
void UpdateProxySelections ()
 

Variables

enum eWireMaterial FOLDED = 3
 
static const int DEPLOYED = 2
 
static const int TRIGGERED = 1
 
int m_State = FOLDED
 
int m_WireMaterial
 
bool m_ResultOfAdvancedPlacing
 
vector m_TriggerPosition
 
vector m_TriggerOrientation
 

Enumeration Type Documentation

◆ eWireMaterial

Enumerator
WIRE 
BARBED_WIRE 
ROPE 

Definition at line 2 of file Trap_TripWire.c.

3{
4 WIRE = 0,
5 BARBED_WIRE = 1,
6 ROPE = 2
7}
@ WIRE
@ ROPE
@ BARBED_WIRE

Function Documentation

◆ CanDisplayAttachmentSlot()

override bool CanDisplayAttachmentSlot ( int slot_id)
protected

Definition at line 226 of file Trap_TripWire.c.

227 {
228 if (GetState() != DEPLOYED)
229 return false;
230
231 return super.CanDisplayAttachmentSlot(slot_id);
232 }
int GetState()
returns one of STATE_...
static const int DEPLOYED

References DEPLOYED, and GetState().

Referenced by Entity::CanDisplayAnyAttachmentSlot().

◆ CanReceiveAttachment()

override bool CanReceiveAttachment ( EntityAI attachment,
int slotId )
protected

Definition at line 217 of file Trap_TripWire.c.

218 {
219 if (GetState() != DEPLOYED)
220 return false;
221
222 return super.CanReceiveAttachment(attachment, slotId);
223 }

References DEPLOYED, and GetState().

◆ CreateTrigger()

override void CreateTrigger ( )
protected

Definition at line 68 of file Trap_TripWire.c.

69 {
70 m_TrapTrigger = TripWireTrigger.Cast(GetGame().CreateObjectEx("TripWireTrigger", GetPosition(), SPAWN_FLAGS));
71 vector mins = "-0.75 0.3 -0.01";
72 vector maxs = "0.75 0.32 0.01";
73 m_TrapTrigger.SetOrientation(GetOrientation());
76
78 }
vector GetOrientation()
void DeferredEnableTrigger()
Definition TrapBase.c:490
enum SoundTypeTrap SPAWN_FLAGS
TrapTrigger m_TrapTrigger
Definition TrapBase.c:44
class JsonUndergroundAreaTriggerData GetPosition
void SetParentObject(TrapBase obj)
Definition TrapTrigger.c:18
void SetExtents(vector mins, vector maxs)
Set the size of the Trigger, avoid using SetCollisionBox directly.
Definition Trigger.c:116
proto native CGame GetGame()
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, DeferredEnableTrigger(), GetGame(), GetOrientation(), GetPosition, m_TrapTrigger, Trigger::SetExtents(), TrapTrigger::SetParentObject(), and SPAWN_FLAGS.

◆ EEHealthLevelChanged()

override void EEHealthLevelChanged ( int oldLevel,
int newLevel,
string zone )
protected

Definition at line 140 of file Trap_TripWire.c.

141 {
142 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
143
144 if (GetGame().IsServer())
145 {
147 {
149 RefreshState();
150 }
151 }
152 }
static const int TRIGGERED
override void RefreshState()
void SetState(int state_ID)
const int STATE_RUINED
Definition constants.c:757

References GetGame(), RefreshState(), SetState(), GameConstants::STATE_RUINED, and TRIGGERED.

◆ EEItemAttached()

override void EEItemAttached ( EntityAI item,
string slot_name )
protected

Definition at line 234 of file Trap_TripWire.c.

235 {
236 super.EEItemAttached(item, slot_name);
237
238 SetTakeable(false);
239 }
override void SetTakeable(bool pState)
Definition ItemBase.c:8905

References SetTakeable().

◆ EEItemDetached()

override void EEItemDetached ( EntityAI item,
string slot_name )
protected

Definition at line 241 of file Trap_TripWire.c.

242 {
243 super.EEItemDetached(item, slot_name);
244
245 SetTakeable(false);
246 }

References SetTakeable().

◆ EEItemLocationChanged()

override void EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
protected

Definition at line 115 of file Trap_TripWire.c.

116 {
117 super.EEItemLocationChanged(oldLoc, newLoc);
118
120 {
121 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.GROUND)
122 {
123 SetActive();
124 m_TrapTrigger.SetPosition(m_TriggerPosition);
125 m_TrapTrigger.SetOrientation(m_TriggerOrientation);
126 }
127
129 }
130
131 if (oldLoc.GetType() == InventoryLocationType.GROUND && newLoc.GetType() == InventoryLocationType.CARGO)
132 {
133 SetInactive();
136 RefreshState();
137 }
138 }
InventoryLocationType
types of Inventory Location
bool m_ResultOfAdvancedPlacing
enum eWireMaterial FOLDED
override void SetInactive(bool stop_timer=true)
vector m_TriggerOrientation
vector m_TriggerPosition
void SetActive()
Definition TrapBase.c:409
void DeleteTrigger()
Definition TrapBase.c:481

References DeleteTrigger(), FOLDED, m_ResultOfAdvancedPlacing, m_TrapTrigger, m_TriggerOrientation, m_TriggerPosition, RefreshState(), SetActive(), SetInactive(), and SetState().

◆ EEKilled()

override void EEKilled ( Object killer)
protected

Definition at line 248 of file Trap_TripWire.c.

249 {
250 if (m_TrapTrigger)
252
253 super.EEKilled(killer);
254 }
override void StartDeactivate(PlayerBase player)

References m_TrapTrigger, and StartDeactivate().

◆ FoldTripWire()

void FoldTripWire ( )
protected

Definition at line 257 of file Trap_TripWire.c.

258 {
259 if (m_AnimationPhaseGrounded != "")
260 {
261 SetAnimationPhase(m_AnimationPhaseSet, 1);
262
264 SetAnimationPhase(m_AnimationPhaseTriggered, 1);
265
266 SetAnimationPhase(m_AnimationPhaseGrounded, 0);
267 }
268 }
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
string m_AnimationPhaseGrounded
Definition TrapBase.c:32
string m_AnimationPhaseSet
Definition TrapBase.c:33

References m_AnimationPhaseGrounded, m_AnimationPhaseSet, and m_AnimationPhaseTriggered.

Referenced by RefreshState().

◆ GetDeploySoundset()

override string GetDeploySoundset ( )
protected

Definition at line 367 of file Trap_TripWire.c.

368 {
369 return "tripwire_deploy_SoundSet";
370 }

◆ GetLoopDeploySoundset()

override string GetLoopDeploySoundset ( )
protected

Definition at line 372 of file Trap_TripWire.c.

373 {
374 return "tripwiretrap_deploy_SoundSet";
375 }

◆ GetState()

◆ GetWireType()

int GetWireType ( )
protected

Definition at line 188 of file Trap_TripWire.c.

189 {
190 return m_WireMaterial;
191 }
int m_WireMaterial

References m_WireMaterial.

◆ IsDeployable()

override bool IsDeployable ( )
protected

Definition at line 356 of file Trap_TripWire.c.

357 {
358 return true;
359 }

◆ IsTakeable()

override bool IsTakeable ( )
protected

Definition at line 362 of file Trap_TripWire.c.

363 {
364 return GetState() != DEPLOYED || (GetInventory().AttachmentCount() == 0 && GetState() == DEPLOYED);
365 }

References DEPLOYED, and GetState().

◆ OnInventoryEnter()

override void OnInventoryEnter ( Man player)
protected

Definition at line 270 of file Trap_TripWire.c.

271 {
273 }

References FOLDED, and SetState().

◆ OnItemLocationChanged()

override void OnItemLocationChanged ( EntityAI old_owner,
EntityAI new_owner )
protected

Definition at line 103 of file Trap_TripWire.c.

104 {
105 super.OnItemLocationChanged(old_owner, new_owner);
106
108 if (player)
109 {
111 return;
112 }
113 }

References StartDeactivate().

◆ OnPlacementCancelled()

override void OnPlacementCancelled ( Man player)
protected

Definition at line 347 of file Trap_TripWire.c.

348 {
349 super.OnPlacementCancelled(player);
350
352
354 }

References FOLDED, m_ResultOfAdvancedPlacing, and SetState().

◆ OnPlacementComplete()

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

Definition at line 334 of file Trap_TripWire.c.

335 {
336 SetIsPlaceSound(true);
337 if (GetGame().IsServer())
338 {
340
344 }
345 }
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8962

References DEPLOYED, GetGame(), m_ResultOfAdvancedPlacing, m_TriggerOrientation, m_TriggerPosition, SetIsPlaceSound(), and SetState().

◆ OnSteppedOn()

override void OnSteppedOn ( EntityAI victim)
protected

Definition at line 80 of file Trap_TripWire.c.

81 {
82 if (!victim)
83 return;
84
85 if (!victim.GetAllowDamage())
86 return;
87
88 // We must deal some damage, here 5 shock as melee damage in order to trigger hit animation
89 if (GetGame().IsServer())
90 {
91 victim.ProcessDirectDamage(DT_CLOSE_COMBAT, this, "", "TripWireHit", "0 0 0", 1);
93 SetInactive(false);
94 }
95
96 // We play the trap trigger sound
97#ifndef SERVER
98 EffectSound sound = SEffectManager.PlaySound("TripwireTrap_Trigger_SoundSet", GetPosition());
99 sound.SetAutodestroy(true);
100#endif
101 }
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
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 GetGame(), GetPosition, SEffectManager::PlaySound(), SetInactive(), SetState(), and TRIGGERED.

◆ OnStoreLoad()

override bool OnStoreLoad ( ParamsReadContext ctx,
int version )
protected

Definition at line 53 of file Trap_TripWire.c.

54 {
55 if (!super.OnStoreLoad(ctx, version))
56 return false;
57
58 int state = FOLDED;
59 if (!ctx.Read(state))
60 state = FOLDED;
61
64
65 return true;
66 }

References FOLDED, RefreshState(), and SetState().

◆ OnStoreSave()

override void OnStoreSave ( ParamsWriteContext ctx)
protected

Definition at line 45 of file Trap_TripWire.c.

46 {
47 super.OnStoreSave(ctx);
48
49 ctx.Write(m_State);
50 }

References m_State.

◆ OnVariablesSynchronized()

override void OnVariablesSynchronized ( )
protected

Definition at line 37 of file Trap_TripWire.c.

38 {
39 super.OnVariablesSynchronized();
40
41 if (IsPlaceSound())
43 }
void PlayPlaceSound()
Definition ItemBase.c:9027
bool IsPlaceSound()
Definition ItemBase.c:8967

References IsPlaceSound(), and PlayPlaceSound().

◆ RefreshState()

override void RefreshState ( )
protected

Definition at line 194 of file Trap_TripWire.c.

195 {
196 super.RefreshState();
197
198 if (GetState() == FOLDED)
199 FoldTripWire();
200 }
void FoldTripWire()

References FOLDED, FoldTripWire(), and GetState().

◆ SetActions()

override void SetActions ( )
protected

Definition at line 377 of file Trap_TripWire.c.

378 {
379 super.SetActions();
380
382 AddAction(ActionDeployObject);
383 }
void AddAction(typename actionName)

References AddAction().

◆ SetInactive()

override void SetInactive ( bool stop_timer = true)
protected

Definition at line 154 of file Trap_TripWire.c.

155 {
156 super.SetInactive(stop_timer);
157
158 // de-attach attachments after "activating them"
159 for (int att = 0; att < GetInventory().AttachmentCount(); att++)
160 {
161 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(att));
162 if (attachment)
163 {
164 if (attachment.IsLockedInSlot())
165 attachment.UnlockFromParent();
166
167 attachment.OnActivatedByItem(this);
168 GetInventory().DropEntity(InventoryMode.SERVER, this, attachment);
169 }
170 }
171 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22

◆ SetState()

void SetState ( int state_ID)
protected

Definition at line 173 of file Trap_TripWire.c.

174 {
176 }

References m_State.

◆ SetupTrapPlayer()

override void SetupTrapPlayer ( PlayerBase player,
bool set_position = true )
protected

Definition at line 202 of file Trap_TripWire.c.

203 {
204 super.SetupTrapPlayer(player, set_position);
206 }

References DEPLOYED, and SetState().

◆ SetWireType()

void SetWireType ( int wireType)
protected

Definition at line 183 of file Trap_TripWire.c.

184 {
186 }

References m_WireMaterial.

◆ StartDeactivate()

override void StartDeactivate ( PlayerBase player)
protected

Definition at line 208 of file Trap_TripWire.c.

209 {
210 super.StartDeactivate(player);
211
214 }

References DeleteTrigger(), FOLDED, and SetState().

Referenced by EEKilled(), and OnItemLocationChanged().

◆ TripwireTrap()

void TripwireTrap ( )
protected

Definition at line 23 of file Trap_TripWire.c.

24 {
25 m_DamagePlayers = 0; //How much damage player gets when caught
26 m_InitWaitTime = 0.0; //After this time after deployment, the trap is activated
27 m_DefectRate = 15;
28 m_NeedActivation = false;
29 m_AnimationPhaseGrounded = "inventory";
30 m_AnimationPhaseSet = "placing";
31 m_AnimationPhaseTriggered = "triggered";
32 m_InfoActivationTime = string.Format("#STR_TripwireTrap0%1#STR_TripwireTrap1", m_InitWaitTime.ToString()); // nefunguje dynamicke vyrazy mimo funkcii
33
34 RegisterNetSyncVariableInt("m_State");
35 }
float m_DefectRate
Definition TrapBase.c:19
bool m_NeedActivation
Definition TrapBase.c:18
string m_InfoActivationTime
Definition TrapBase.c:40
float m_InitWaitTime
Definition TrapBase.c:17
float m_DamagePlayers
Definition TrapBase.c:20
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_AnimationPhaseGrounded, m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DamagePlayers, m_DefectRate, m_InfoActivationTime, m_InitWaitTime, m_NeedActivation, and float::ToString().

◆ UpdateProxySelections()

void UpdateProxySelections ( )
protected

Definition at line 389 of file Trap_TripWire.c.

390 {
391 if (GetInventory().AttachmentCount() > 0)
392 {
393 ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(0));
394
395 if (attachment)
396 {
397 // Hide all proxies
398 for (int i = 1; i <= 3; i++)
399 HideSelection("s" + i + "_charge");
400
401 // Now show the one we need to see
402 string proxy_to_show = string.Format("s%1_charge", GetState());
403 //Print(proxy_to_show);
404 ShowSelection(proxy_to_show);
405 }
406 }
407 }

References GetState().

Variable Documentation

◆ DEPLOYED

◆ FOLDED

◆ m_ResultOfAdvancedPlacing

bool m_ResultOfAdvancedPlacing
protected

◆ m_State

int m_State = FOLDED

Definition at line 16 of file Trap_TripWire.c.

◆ m_TriggerOrientation

vector m_TriggerOrientation
protected

Definition at line 21 of file Trap_TripWire.c.

Referenced by EEItemLocationChanged(), and OnPlacementComplete().

◆ m_TriggerPosition

vector m_TriggerPosition
protected

Definition at line 20 of file Trap_TripWire.c.

Referenced by EEItemLocationChanged(), and OnPlacementComplete().

◆ m_WireMaterial

int m_WireMaterial
private

Definition at line 17 of file Trap_TripWire.c.

Referenced by GetWireType(), and SetWireType().

◆ TRIGGERED

const int TRIGGERED = 1
static

Definition at line 14 of file Trap_TripWire.c.

Referenced by EEHealthLevelChanged(), and OnSteppedOn().