DayZ 1.24
Loading...
Searching...
No Matches
TrapBase Class Reference
Collaboration diagram for TrapBase:
[legend]

Protected Member Functions

void OnServerSteppedOn (Object obj, string damageZone)
 
void CauseVictimToStartLimping (Object obj, string damagedZone)
 
void PlaySoundBiteLeg ()
 
void PlaySoundBiteEmpty ()
 
void PlaySoundOpen ()
 
override void OnActivate ()
 
override void OnDisarm ()
 
override void OnPlacementComplete (Man player, vector position="0 0 0", vector orientation="0 0 0")
 
override bool IsDeployable ()
 
override string GetLoopDeploySoundset ()
 
override void SetActions ()
 

Private Member Functions

void BearTrap ()
 
override bool CanBeDisarmed ()
 
override void EEHealthLevelChanged (int oldLevel, int newLevel, string zone)
 
override void CreateTrigger ()
 
override void OnUpdate (EntityAI victim)
 
override void OnSteppedOn (EntityAI victim)
 
override void OnSteppedOut (EntityAI victim)
 

Static Private Attributes

static const int RAYCAST_SOURCES_COUNT = 5
 
static const vector m_RaycastSources [RAYCAST_SOURCES_COUNT]
 

Detailed Description

Definition at line 1 of file Trap_Bear.c.

Member Function Documentation

◆ BearTrap()

void TrapBase::BearTrap ( )
inlineprivate

Definition at line 14 of file Trap_Bear.c.

15 {
16 m_DamagePlayers = 5; // How much damage player gets when caught
17 m_DamageOthers = 5; // How much damage other entities(CreatureAI) gets when caught
18 m_DefectRate = 0;
19 m_InitWaitTime = 0.0; // After this time after deployment, the trap is activated
20 m_AnimationPhaseGrounded = "placing";
21 m_AnimationPhaseSet = "BearTrap_Set";
22 m_AnimationPhaseTriggered = "placing";
23 }
string m_AnimationPhaseTriggered
Definition TrapBase.c:34
float m_DefectRate
Definition TrapBase.c:19
string m_AnimationPhaseGrounded
Definition TrapBase.c:32
string m_AnimationPhaseSet
Definition TrapBase.c:33
float m_InitWaitTime
Definition TrapBase.c:17
float m_DamagePlayers
Definition TrapBase.c:20
float m_DamageOthers
Definition TrapBase.c:21

References m_AnimationPhaseGrounded, m_AnimationPhaseSet, m_AnimationPhaseTriggered, m_DamageOthers, m_DamagePlayers, m_DefectRate, and m_InitWaitTime.

◆ CanBeDisarmed()

override bool TrapBase::CanBeDisarmed ( )
inlineprivate

Definition at line 25 of file Trap_Bear.c.

26 {
27 return true;
28 }

◆ CauseVictimToStartLimping()

void TrapBase::CauseVictimToStartLimping ( Object obj,
string damagedZone )
inlineprotected

Definition at line 165 of file Trap_Bear.c.

166 {
169 if (Class.CastTo(player, obj))
170 {
171 player.DamageAllLegs(player.GetMaxHealth() * 2); //reduce legs health (not regular DamageSystem damage, does not transfer!)
172 }
173 else if (Class.CastTo(zombie, obj))
174 {
175 zombie.SetHealth("LeftLeg", "Health", 0.0);
176 zombie.SetHealth("RightLeg", "Health", 0.0);
177 }
178 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo().

Referenced by OnServerSteppedOn().

◆ CreateTrigger()

override void TrapBase::CreateTrigger ( )
inlineprivate

Definition at line 41 of file Trap_Bear.c.

42 {
43 super.CreateTrigger();
44
45 vector mins = "-0.1 -0.05 -0.1";
46 vector maxs = "0.1 0.4 0.1";
47
48 m_TrapTrigger.SetOrientation(GetOrientation());
51 }
vector GetOrientation()
TrapTrigger m_TrapTrigger
Definition TrapBase.c:44
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

References GetOrientation(), m_TrapTrigger, Trigger::SetExtents(), and TrapTrigger::SetParentObject().

Referenced by SetActive().

◆ EEHealthLevelChanged()

override void TrapBase::EEHealthLevelChanged ( int oldLevel,
int newLevel,
string zone )
inlineprivate

Definition at line 30 of file Trap_Bear.c.

31 {
32 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
33
34 if (GetGame().IsServer())
35 {
38 }
39 }
void SetInactive(bool stop_timer=true)
Definition TrapBase.c:452
proto native CGame GetGame()
const int STATE_RUINED
Definition constants.c:757

References GetGame(), SetInactive(), and GameConstants::STATE_RUINED.

◆ GetLoopDeploySoundset()

override string TrapBase::GetLoopDeploySoundset ( )
inlineprotected

Definition at line 232 of file Trap_Bear.c.

233 {
234 return "beartrap_deploy_SoundSet";
235 }

◆ IsDeployable()

override bool TrapBase::IsDeployable ( )
inlineprotected

Definition at line 227 of file Trap_Bear.c.

228 {
229 return true;
230 }

◆ OnActivate()

override void TrapBase::OnActivate ( )
inlineprotected

Definition at line 198 of file Trap_Bear.c.

199 {
200#ifndef SERVER
202#endif
203 }
void PlaySoundOpen()
Definition Trap_Bear.c:192

References PlaySoundOpen().

Referenced by SetActive().

◆ OnDisarm()

override void TrapBase::OnDisarm ( )
inlineprotected

Definition at line 205 of file Trap_Bear.c.

206 {
207#ifndef SERVER
209#endif
210 }
void PlaySoundBiteEmpty()
Definition Trap_Bear.c:186

References PlaySoundBiteEmpty().

Referenced by Disarm(), and OnRPC().

◆ OnPlacementComplete()

override void TrapBase::OnPlacementComplete ( Man player,
vector position = "0 0 0",
vector orientation = "0 0 0" )
inlineprotected

Definition at line 216 of file Trap_Bear.c.

217 {
218 super.OnPlacementComplete(player, position, orientation);
219
220 if (GetGame().IsServer())
221 {
224 }
225 }
void StartActivate(PlayerBase player)
Definition TrapBase.c:431

References GetGame(), and StartActivate().

◆ OnServerSteppedOn()

void TrapBase::OnServerSteppedOn ( Object obj,
string damageZone )
inlineprotected

Generic limp handling

Definition at line 128 of file Trap_Bear.c.

129 {
130 if (obj.IsInherited(CarWheel))
131 {
132 obj.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, damageZone, "BearTrapHit_CarWheel", "0 0 0", 1);
133 if (m_UpdateTimer.IsRunning())
134 m_UpdateTimer.Stop();
135
136 SetInactive(false);
137 Synch(EntityAI.Cast(obj));
138
139 return;
140 }
141
142 if (obj.IsDamageDestroyed())
143 return;
144
145 string zoneUsed = damageZone;
146 if (damageZone == "zone_leg_random")
147 {
148 zoneUsed = "LeftLeg";
149 if (Math.RandomIntInclusive(0, 1) == 1)
150 zoneUsed = "RightLeg";
151 }
152
155 if (obj.IsInherited(PlayerBase) || (Class.CastTo(zombie, obj) && !zombie.IsCrawling() && Math.RandomIntInclusive(0, 1) == 1))
157
158 obj.ProcessDirectDamage(DamageType.CLOSE_COMBAT, this, zoneUsed, "BearTrapHit", "0 0 0", 1);
159
160 SetInactive(false);
161 Synch(EntityAI.Cast(obj));
162 }
DamageType
exposed from C++ (do not change)
ref Timer m_UpdateTimer
Definition RadialMenu.c:20
void Synch(EntityAI victim)
keeping "step" here for consistency only
Definition TrapBase.c:280
Definition EnMath.c:7
void CauseVictimToStartLimping(Object obj, string damagedZone)
Definition Trap_Bear.c:165
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Definition EnMath.c:54

References Class::CastTo(), CauseVictimToStartLimping(), m_UpdateTimer, Math::RandomIntInclusive(), SetInactive(), and Synch().

Referenced by OnSteppedOn(), OnUpdate(), and OnUpdate().

◆ OnSteppedOn()

override void TrapBase::OnSteppedOn ( EntityAI victim)
inlineprivate

CarScript specific reaction on BearTrap

this is also called on client (OnRPC->SnapOn->OnSteppedOn chain)

Definition at line 63 of file Trap_Bear.c.

64 {
65 if (GetGame().IsServer() && victim)
66 {
67 if (!victim.GetAllowDamage())
68 return;
69
70 if (victim.IsInherited(CarScript))
71 {
74 m_UpdateTimer.Run(UPDATE_TIMER_INTERVAL, this, "OnUpdate", params, true);
75
76 return;
77 }
78 else
79 {
81 {
83 vector raycastEnd = "0 0.5 0" + raycastStart;
84
86 rayInput.flags = CollisionFlags.ALLOBJECTS;
88 rayInput.radius = 0.05;
90
92 {
94 {
95 if (result.obj && !result.obj.IsDamageDestroyed() && !result.obj.IsAnyInherited({ItemBase, Plant}))
96 {
97 OnServerSteppedOn(result.obj, result.obj.GetDamageZoneNameByComponentIndex(result.component));
98 return;
99 }
100 }
101 }
102 }
103
104 OnServerSteppedOn(victim, "zone_leg_random");
105 }
106 }
107 else if (!GetGame().IsDedicatedServer())
108 {
109 if (victim)
110 {
111 if (victim.IsInherited(PlayerBase))
112 victim.SpawnDamageDealtEffect();
113
115 }
116 }
117 }
const float UPDATE_TIMER_INTERVAL
Definition TrapBase.c:15
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
void OnServerSteppedOn(Object obj, string damageZone)
Definition Trap_Bear.c:128
static const vector m_RaycastSources[RAYCAST_SOURCES_COUNT]
Definition Trap_Bear.c:6
void PlaySoundBiteLeg()
Definition Trap_Bear.c:180
CollisionFlags
Definition EnDebug.c:141

References GetGame(), ItemBase, m_RaycastSources, m_UpdateTimer, OnServerSteppedOn(), PlaySoundBiteLeg(), DayZPhysics::RaycastRVProxy(), and UPDATE_TIMER_INTERVAL.

Referenced by SnapOnObject().

◆ OnSteppedOut()

override void TrapBase::OnSteppedOut ( EntityAI victim)
inlineprivate

Definition at line 119 of file Trap_Bear.c.

120 {
121 if (victim.IsInherited(CarScript))
122 {
123 if (m_UpdateTimer && m_UpdateTimer.IsRunning())
124 m_UpdateTimer.Stop();
125 }
126 }

References m_UpdateTimer.

Referenced by RemoveFromObject().

◆ OnUpdate()

override void TrapBase::OnUpdate ( EntityAI victim)
inlineprivate

Definition at line 53 of file Trap_Bear.c.

54 {
55 if (victim && victim.IsInherited(CarScript))
56 {
58 if (wheel)
60 }
61 }
EntityAI GetClosestCarWheel(EntityAI victim)
Definition TrapBase.c:612

References GetClosestCarWheel(), and OnServerSteppedOn().

◆ PlaySoundBiteEmpty()

void TrapBase::PlaySoundBiteEmpty ( )
inlineprotected

Definition at line 186 of file Trap_Bear.c.

187 {
188 EffectSound sound = SEffectManager.PlaySound("beartrapClose_SoundSet", GetPosition(), 0, 0, false);
189 sound.SetAutodestroy(true);
190 }
class JsonUndergroundAreaTriggerData GetPosition
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 GetPosition, and SEffectManager::PlaySound().

Referenced by OnDisarm().

◆ PlaySoundBiteLeg()

void TrapBase::PlaySoundBiteLeg ( )
inlineprotected

Definition at line 180 of file Trap_Bear.c.

181 {
182 EffectSound sound = SEffectManager.PlaySound("beartrapCloseDamage_SoundSet", GetPosition(), 0, 0, false);
183 sound.SetAutodestroy(true);
184 }

References GetPosition, and SEffectManager::PlaySound().

Referenced by OnSteppedOn().

◆ PlaySoundOpen()

void TrapBase::PlaySoundOpen ( )
inlineprotected

Definition at line 192 of file Trap_Bear.c.

193 {
194 EffectSound sound = SEffectManager.PlaySound("beartrapOpen_SoundSet", GetPosition(), 0, 0, false);
195 sound.SetAutodestroy(true);
196 }

References GetPosition, and SEffectManager::PlaySound().

Referenced by OnActivate().

◆ SetActions()

override void TrapBase::SetActions ( )
inlineprotected

Definition at line 237 of file Trap_Bear.c.

References AddAction().

Member Data Documentation

◆ m_RaycastSources

const vector TrapBase::m_RaycastSources[RAYCAST_SOURCES_COUNT]
staticprivate
Initial value:
= {
"0.0 0.1 0.0",
"0.2 0.1 0.2",
"-.2 0.1 0.2",
"0.2 0.1 -0.2",
"-0.2 0.1 -0.2"
}

Definition at line 6 of file Trap_Bear.c.

6 {
7 "0.0 0.1 0.0", // center
8 "0.2 0.1 0.2", // north east
9 "-.2 0.1 0.2", // north west
10 "0.2 0.1 -0.2", // south east
11 "-0.2 0.1 -0.2" // south west
12 };

Referenced by OnSteppedOn().

◆ RAYCAST_SOURCES_COUNT

const int TrapBase::RAYCAST_SOURCES_COUNT = 5
staticprivate

Definition at line 3 of file Trap_Bear.c.


The documentation for this class was generated from the following file: