DayZ 1.24
Loading...
Searching...
No Matches
AreaDamageTrigger.c
Go to the documentation of this file.
1// DEPRECATED: Left for backwards compatibility with mods
2// This file is NOT AN EXAMPLE of how to use triggers
3// As overriding UpdateInsiders should ideally no longer be done
4// Look at "AreaDamageTriggerBase.c" instead and use that as base
5class AreaDamageTrigger extends AreaDamageTriggerBase
6{
8
9 protected vector m_ExtentMin;
11 protected float m_InnerDistance;
12
13 protected int m_TriggerUpdateMs;
14
16 {
17 // Backwards compat, revert the flags back to what they used to be
18 ClearEventMask(EntityEvent.ENTER | EntityEvent.LEAVE);
19 SetEventMask(EntityEvent.TOUCH);
20
21 m_AreaDamageType = null;
22
25 m_InnerDistance = 0;
26
27 m_TriggerUpdateMs = 100;
28 }
29
30 // Backwards compat
31 override void EOnTouch(IEntity other, int extra)
32 {
33 Object obj;
34 if (Class.CastTo(obj, other))
35 AddInsider(obj);
36 }
37
39 {
42
43 m_InnerDistance = (GetRadius(m_ExtentMin, m_ExtentMax) * 0.5) + 0.2;
44
45 super.SetExtents(mins, maxs);
46 }
47
48 override void SetAreaDamageManager(AreaDamageManager adType)
49 {
50 super.SetAreaDamageManager(adType);
51
52 m_AreaDamageType = AreaDamageBase.Cast(adType);
53 }
54
56 {
57 super.SetAreaDamageManager(adType);
58
59 m_AreaDamageType = adType;
60 }
61
62 override void OnEnter(Object obj)
63 {
64 super.OnEnter(obj);
65
66 if (GetGame().IsServer() && m_AreaDamageType)
67 m_AreaDamageType.OnEnter(obj);
68 }
69
70 override void OnLeave(Object obj)
71 {
72 super.OnLeave(obj);
73
74 if (GetGame().IsServer() && m_AreaDamageType)
75 m_AreaDamageType.OnLeave(obj);
76 }
77
78 override protected void UpdateInsiders(int timeout)
79 {
80 if (GetGame().IsServer())
81 {
82 for (int n = 0; n < m_insiders.Count();)
83 {
84 TriggerInsider ins = m_insiders.Get(n);
85 if (ins.GetObject() == null)
86 {
87 //object has been deleted. Remove it
88 m_insiders.Remove(n);
89 continue;
90 }
91
92 Object insObj = ins.GetObject();
93 if (insObj && (!insObj.IsAlive() || vector.DistanceSq(insObj.GetPosition(), GetPosition()) > (m_InnerDistance * m_InnerDistance)))
94 {
95 int timeDiff = g_Game.GetTime() - ins.timeStamp;
96 if (timeDiff > 500)
97 {
98 //object left. Remove it
99 OnLeave(ins.GetObject());
100 m_insiders.Remove(n);
101
102 continue;
103 }
104 else
105 {
106 //Print("" + this + " :: " + insObj + " :: " + timeDiff);
107 }
108 }
109
110 ++n;
111 }
112
114#ifdef DEVELOPER
116#endif
117 }
118 }
119}
vector m_ExtentMin
vector m_ExtentMax
void AddInsider(Object obj)
Adding of new TriggerInsider.
DayZGame g_Game
Definition DayZGame.c:3528
float GetRadius()
Definition RadialMenu.c:358
class JsonUndergroundAreaTriggerData GetPosition
override void SetAreaDamageManager(AreaDamageManager adType)
void UpdateInsiders(int timeout)
override void OnEnter(Object obj)
override void SetExtents(vector mins, vector maxs)
override void EOnTouch(IEntity other, int extra)
void SetAreaDamageType(AreaDamageBase adType)
ref AreaDamageBase m_AreaDamageType
override void OnLeave(Object obj)
Super root of all classes in Enforce script.
Definition EnScript.c:11
The object which is in a trigger and its metadata.
Definition Trigger.c:3
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44