Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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;
10 protected vector m_ExtentMax;
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
26
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
38 override void SetExtents( vector mins, vector maxs )
39 {
40 m_ExtentMax = maxs;
41 m_ExtentMin = mins;
42
44
45 super.SetExtents(mins, maxs);
46 }
47
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 ( g_Game.IsServer() && m_AreaDamageType )
67 m_AreaDamageType.OnEnter( obj );
68 }
69
70 override void OnLeave( Object obj )
71 {
72 super.OnLeave( obj );
73
74 if ( g_Game.IsServer() && m_AreaDamageType )
75 m_AreaDamageType.OnLeave( obj );
76 }
77
78 override protected void UpdateInsiders(int timeout)
79 {
80 if ( g_Game.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
115 DebugSendDmgTrigger();
116 #endif
117 }
118 }
119}
void AreaDamageManager(EntityAI parent)
void AddInsider(Object obj)
Adding of new TriggerInsider.
override void SetAreaDamageManager(AreaDamageManager adType)
void UpdateInsiders(int timeout)
override void EOnTouch(IEntity other, int extra)
override void SetExtents(vector mins, vector maxs)
ref AreaDamageBase m_AreaDamageType
void SetAreaDamageType(AreaDamageBase adType)
override void OnEnter(Object obj)
override void OnLeave(Object obj)
Super root of all classes in Enforce script.
Definition enscript.c:11
Internal ancestor of all Entity implementations.
Definition enentity.c:165
The object which is in a trigger and its metadata.
Definition trigger.c:3
int timeStamp
Last time the object was seen in ms.
Definition trigger.c:10
Object GetObject()
Definition trigger.c:28
static const vector Zero
Definition enconvert.c:123
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
DayZGame g_Game
Definition dayzgame.c:3942
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:45
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
float GetRadius()
Definition radialmenu.c:372