Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
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
43
void
AddTransition
(
FSMTransition<BotStateBase, BotEventBase, BotActionBase, BotGuardBase>
t)
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
129
class
BotStateIdle
:
BotStateBase
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
};
botDebugPrint
void botDebugPrint(string s)
Definition
bot.c:122
BotEventBase
represents event that triggers transition from state to state
Definition
botevents.c:5
BotFSM
Bot Finite State Machine (Hierarchical).
Bot
Definition
bot.c:19
BotStateBase
represent weapon state base
Definition
bot_hunt.c:16
BotStateBase::HasFSM
bool HasFSM()
Definition
botstates.c:30
BotStateBase::OnStateChanged
void OnStateChanged(BotStateBase src, BotStateBase dst)
Definition
botstates.c:126
BotStateBase::m_FSM
ref BotFSM m_FSM
hierarchical parent state of this state (or null)
Definition
botstates.c:15
BotStateBase::IsIdle
bool IsIdle()
idle state does not expect any animation events
Definition
botstates.c:112
BotStateBase::AddTransition
void AddTransition(FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > t)
Definition
botstates.c:43
BotStateBase::ProcessEvent
bool ProcessEvent(BotEventBase e)
Definition
botstates.c:33
BotStateBase::BotStateBase
void BotStateBase(Bot bot=NULL, BotStateBase parent=NULL)
nested state machine (or null)
Definition
botstates.c:17
BotStateBase::OnExit
void OnExit(BotEventBase e)
Definition
botstates.c:97
BotStateBase::GetPlayerOwner
PlayerBase GetPlayerOwner()
Definition
botstates.c:19
BotStateBase::OnEntry
void OnEntry(BotEventBase e)
Definition
botstates.c:57
BotStateBase::GetFSM
BotFSM GetFSM()
Definition
botstates.c:31
BotStateBase::m_Owner
PlayerBase m_Owner
Definition
botstates.c:12
BotStateBase::OnSubMachineChanged
void OnSubMachineChanged(BotStateBase src, BotStateBase dst)
Definition
botstates.c:119
BotStateBase::IsWaitingForActionFinish
bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
Definition
botstates.c:106
BotStateBase::OnUpdate
void OnUpdate(float dt)
Definition
botstates.c:73
BotStateBase::GetParentState
BotStateBase GetParentState()
Definition
botstates.c:28
BotStateBase::m_Bot
Bot m_Bot
man that this state belongs to
Definition
botstates.c:13
BotStateBase::OnAbort
void OnAbort(BotEventBase e)
Definition
botstates.c:83
BotStateBase::m_ParentState
BotStateBase m_ParentState
bot that this state belongs to
Definition
botstates.c:14
BotStateBase::SetParentState
void SetParentState(BotStateBase parent)
Definition
botstates.c:24
BotStateIdle::BotStateIdle
void BotStateIdle(Bot bot=NULL, BotStateBase parent=NULL)
Definition
botstates.c:131
BotStateIdle::IsIdle
override bool IsIdle()
Definition
botstates.c:133
FSMTransition
represents transition src -— event[guard]/action -—|> dst
PlayerBase
Definition
playerbaseclient.c:2
ToString
proto string ToString()
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
Type
string Type
Definition
jsondatacontaminatedarea.c:11
Games
Dayz
scripts
4_world
systems
bot
botstates.c
Generated by
1.17.0