Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
botstates.c
Go to the documentation of this file.
1 
10 class BotStateBase
11 {
12  PlayerBase m_Owner;
13  Bot m_Bot;
14  BotStateBase m_ParentState;
15  ref BotFSM m_FSM;
16 
17  void BotStateBase (Bot bot = NULL, BotStateBase parent = NULL) { m_Bot = bot; m_Owner = bot.m_Owner; m_ParentState = parent; }
18 
19  PlayerBase GetPlayerOwner() { return m_Owner; }
20 
24  void SetParentState (BotStateBase parent) { m_ParentState = parent; }
28  BotStateBase GetParentState () { return m_ParentState; }
29 
30  bool HasFSM () { return m_FSM != NULL; }
31  BotFSM GetFSM () { return m_FSM; }
32 
33  bool ProcessEvent (BotEventBase e)
34  {
35  if (HasFSM())
36  return m_FSM.ProcessEvent(e);
37  return false;
38  }
39 
44  {
45  if (HasFSM())
46  m_FSM.AddTransition(t);
47  else
48  Error("[botfsm] adding transition to state without FSM. Configure FSM first.");
49  }
50 
51 
57  void OnEntry (BotEventBase e)
58  {
59  if (HasFSM() && !m_FSM.IsRunning())
60  {
61  botDebugPrint("[botfsm] { " + this.Type().ToString() + " Has Sub-FSM! Starting submachine...");
62  m_FSM.Start(e);
63  }
64  else
65  botDebugPrint("[botfsm] { " + this.Type().ToString());
66  }
67 
73  void OnUpdate (float dt)
74  {
75  if (HasFSM() && m_FSM.IsRunning())
76  m_FSM.GetCurrentState().OnUpdate(dt);
77  }
78 
83  void OnAbort (BotEventBase e)
84  {
85  if (HasFSM() && m_FSM.IsRunning())
86  {
87  botDebugPrint("[botfsm] OnAbort " + this.Type().ToString() + " Has Sub-FSM! Aborting submachine...");
88  m_FSM.Abort(e);
89  }
90  botDebugPrint("[botfsm] } ABORTED " + this.Type().ToString());
91  }
92 
97  void OnExit (BotEventBase e)
98  {
99  botDebugPrint("[botfsm] } " + this.Type().ToString());
100  }
101 
106  bool IsWaitingForActionFinish () { return HasFSM() && m_FSM.IsRunning() && m_FSM.GetCurrentState().IsWaitingForActionFinish(); }
107 
112  bool IsIdle () { return false; }
113 
119  void OnSubMachineChanged (BotStateBase src, BotStateBase dst) { }
120 
126  void OnStateChanged (BotStateBase src, BotStateBase dst) { }
127 };
128 
130 {
131  void BotStateIdle (Bot bot = NULL, BotStateBase parent = NULL) { m_Bot = bot; m_Owner = m_Bot.m_Owner; m_ParentState = parent; }
132 
133  override bool IsIdle () { return true; }
134 };
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
Bot
Definition: bot.c:18
BotStateBase
represent weapon state base
Definition: bot_hunt.c:15
ToString
proto string ToString()
botDebugPrint
void botDebugPrint(string s)
Definition: bot.c:182
BotEventBase
represents event that triggers transition from state to state
Definition: botevents.c:4
PlayerBase
Definition: playerbaseclient.c:1
FSMTransition
represents transition src -— event[guard]/action -—|> dst
m_Owner
enum ProcessDirectDamageFlags m_Owner
Type
string Type
Definition: jsondatacontaminatedarea.c:11
BotFSM
Bot Finite State Machine (Hierarchical)
BotStateIdle
Definition: botstates.c:129