Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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
5 class AreaDamageTrigger extends AreaDamageTriggerBase
6 {
7  protected ref AreaDamageBase m_AreaDamageType;
8 
9  protected vector m_ExtentMin;
10  protected vector m_ExtentMax;
11  protected float m_InnerDistance;
12 
13  protected int m_TriggerUpdateMs;
14 
15  void AreaDamageTrigger()
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 
23  m_ExtentMin = vector.Zero;
24  m_ExtentMax = vector.Zero;
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 
38  override void SetExtents( vector mins, vector maxs )
39  {
40  m_ExtentMax = maxs;
41  m_ExtentMin = mins;
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 
55  void SetAreaDamageType( AreaDamageBase adType )
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
115  DebugSendDmgTrigger();
116  #endif
117  }
118  }
119 }
GetGame
proto native CGame GetGame()
UpdateInsiders
override protected void UpdateInsiders(int timeout)
Update the current TriggerInsider inside the Trigger.
Definition: areadamagetriggerbase.c:242
m_ExtentMin
protected vector m_ExtentMin
Definition: areadamagemanager.c:15
TriggerInsider
The object which is in a trigger and its metadata.
Definition: trigger.c:2
SetExtents
void SetExtents(vector mins, vector maxs)
Definition: areadamagemanager.c:233
AreaDamageTriggerBase
Definition: areadamagetriggerdirect.c:1
AddInsider
override protected void AddInsider(Object obj)
Adding of new TriggerInsider.
Definition: areadamagetriggerbase.c:224
IEntity
Definition: enentity.c:164
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
vector
Definition: enconvert.c:105
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
m_ExtentMax
protected vector m_ExtentMax
Definition: areadamagemanager.c:16
GetRadius
protected float GetRadius()
Definition: radialmenu.c:372
EOnTouch
override void EOnTouch(IEntity other, int extra)
Definition: easteregg.c:106
AreaDamageManager
void AreaDamageManager(EntityAI parent)
Definition: areadamagemanager.c:22
AreaDamageBase
Definition: areadamage.c:3
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
SetAreaDamageManager
void SetAreaDamageManager(AreaDamageManager adType)
AreaDamageTriggerBase configuration.
Definition: areadamagetriggerbase.c:40