Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
botstates.c
Go to the documentation of this file.
1
10class 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};
void botDebugPrint(string s)
Definition bot.c:122
represents event that triggers transition from state to state
Definition botevents.c:5
Bot Finite State Machine (Hierarchical)
Definition bot.c:19
represent weapon state base
Definition bot_hunt.c:16
represents transition src -— event[guard]/action -—|> dst
proto string ToString()
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
HandStateEquipped OnEntry
string Type
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit