Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bot_timedwait.c
Go to the documentation of this file.
1 
3 
4 class BotTimedWait extends BotStateBase
5 {
6  protected float m_dtAccumulator = 0.0;
7  protected float m_Timeout = 3.0;
8  protected bool m_Periodic = true;
9 
10  void BotTimedWait (Bot bot = NULL, BotStateBase parent = NULL, float timeout = 3.0)
11  {
12  m_Timeout = timeout;
13  }
14 
15  override void OnEntry (BotEventBase e)
16  {
17  m_dtAccumulator = 0.0;
18 
19  super.OnEntry(e);
20  }
21 
22  override void OnExit (BotEventBase e)
23  {
24  m_dtAccumulator = 0.0;
25 
26  super.OnExit(e);
27  }
28 
29  override void OnUpdate (float dt)
30  {
31  super.OnUpdate(dt);
32 
33  m_dtAccumulator += dt;
34 
35  float rescanTime = m_Timeout;
36  if (m_dtAccumulator >= rescanTime)
37  {
38  OnTimeout();
39 
40  if (m_Periodic)
41  m_dtAccumulator = 0.0;
42  else
43  m_dtAccumulator = -1.0;
44  }
45  }
46 
47  void OnTimeout ()
48  {
49  botDebugSpam("[bot] + " + m_Owner + " BotTimedWait::OnTimeout");
50  m_Bot.ProcessEvent(new BotEventWaitTimeout(m_Owner));
51  }
52 };
53 
OnExit
override void OnExit(HandEventBase e)
Definition: hand_states.c:28
Bot
Definition: bot.c:18
BotStateBase
represent weapon state base
Definition: bot_hunt.c:15
m_dtAccumulator
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
botDebugSpam
void botDebugSpam(string s)
Definition: bot.c:191
BotEventBase
represents event that triggers transition from state to state
Definition: botevents.c:4
BotEventWaitTimeout
Definition: bot_timedwait.c:2
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
m_Owner
enum ProcessDirectDamageFlags m_Owner
OnTimeout
override void OnTimeout()
Definition: bot_testspamuseractions.c:132
OnEntry
HandStateEquipped OnEntry
Definition: weaponchambering.c:208