DayZ 1.24
Loading...
Searching...
No Matches
BotStateBase Class Reference

represent weapon state base More...

Inheritance diagram for BotStateBase:
[legend]
Collaboration diagram for BotStateBase:
[legend]

Protected Member Functions

void BotTimedWait (Bot bot=NULL, BotStateBase parent=NULL, float timeout=3.0)
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
void OnTimeout ()
 

Protected Attributes

float m_Timeout = 3.0
 
bool m_Periodic = true
 

Private Member Functions

void BotHunt (Bot bot=NULL, BotStateBase parent=NULL)
 
void SelectTarget ()
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
void BotTestAttachAndDropCycle (Bot bot=NULL, BotStateBase parent=NULL)
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
void BotTestItemMoveBackAndForth (Bot bot=NULL, BotStateBase parent=NULL)
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
int GetNextSlot (int curr)
 
override void OnUpdate (float dt)
 
void BotSpawnEntityInHands (Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
void Bot_TestSpawnOpen (Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
 
override void OnEntry (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
override void OnEntry (BotEventBase e)
 
override void OnAbort (BotEventBase e)
 
override void OnExit (BotEventBase e)
 
override void OnUpdate (float dt)
 
void BotStateBase (Bot bot=NULL, BotStateBase parent=NULL)
 nested state machine (or null)
 
PlayerBase GetPlayerOwner ()
 
void SetParentState (BotStateBase parent)
 allows construction of hierarchical state machine
 
BotStateBase GetParentState ()
 
bool HasFSM ()
 
BotFSM GetFSM ()
 
bool ProcessEvent (BotEventBase e)
 
void AddTransition (FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > t)
 adds transition into m_FSM transition table
 
void OnEntry (BotEventBase e)
 
void OnUpdate (float dt)
 
void OnAbort (BotEventBase e)
 
void OnExit (BotEventBase e)
 
bool IsWaitingForActionFinish ()
 waiting for active animation action/actionType finish
 
bool IsIdle ()
 idle state does not expect any animation events
 
void OnSubMachineChanged (BotStateBase src, BotStateBase dst)
 called when sub-machine has changed its state
 
void OnStateChanged (BotStateBase src, BotStateBase dst)
 called on current state when state machine has changed its state
 

Private Attributes

Man m_Target
 
float m_dtAccumulator = 0.0
 
ref BotHunt_Tracking m_Tracking
 
ref BotHunt_Hunting m_Hunting
 
EntityAI m_Target
 
bool m_TargetInSight = false
 
bool m_TargetLost = false
 
bool m_Tracking = true
 
EntityAI m_Entity
 
ref BotTestAttachAndDropCycle_Detaching m_Detaching
 
ref BotTestAttachAndDropCycle_Attaching m_Attaching
 
ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move
 
int m_WaitingForSlot = InventorySlots.INVALID
 
int m_hgSlot = InventorySlots.GetSlotIdFromString("Headgear")
 
int m_mskSlot = InventorySlots.GetSlotIdFromString("Mask")
 
string m_Type
 
ref BotSpawnEntityInHands m_Spawning
 
ref BotOpenEntityInHands m_Opening
 
PlayerBase m_Owner
 
Bot m_Bot
 man that this state belongs to
 
BotStateBase m_ParentState
 bot that this state belongs to
 
ref BotFSM m_FSM
 hierarchical parent state of this state (or null)
 

Detailed Description

represent weapon state base

Class comes with entry/update/exit hooks that can be overriden in custom states

Class is ready for hierarchic composition, i.e. this state having a sub-machine running under hood. If no m_FSM member is configured, class acts as ordinary plain finite machine state.

Definition at line 15 of file Bot_Hunt.c.

Constructor & Destructor Documentation

◆ BotStateBase()

void BotStateBase::BotStateBase ( Bot bot = NULL,
BotStateBase parent = NULL )
inlineprivate

nested state machine (or null)

Definition at line 17 of file BotStates.c.

17{ m_Bot = bot; m_Owner = bot.m_Owner; m_ParentState = parent; }
BotStateBase m_ParentState
bot that this state belongs to
Definition BotStates.c:14
PlayerBase m_Owner
Definition BotStates.c:12
Bot m_Bot
man that this state belongs to
Definition BotStates.c:13

References m_Bot, m_Owner, and m_ParentState.

Member Function Documentation

◆ AddTransition()

BotStateBase::AddTransition ( FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > t)
inlineprivate

adds transition into m_FSM transition table

Definition at line 43 of file BotStates.c.

44 {
45 if (HasFSM())
46 m_FSM.AddTransition(t);
47 else
48 Error("[botfsm] adding transition to state without FSM. Configure FSM first.");
49 }
ref BotFSM m_FSM
hierarchical parent state of this state (or null)
Definition BotStates.c:15
bool HasFSM()
Definition BotStates.c:30
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Error(), HasFSM(), and m_FSM.

◆ Bot_TestSpawnOpen()

void BotStateBase::Bot_TestSpawnOpen ( Bot bot = NULL,
BotStateBase parent = NULL,
string new_type = "" )
inlineprivate

Definition at line 97 of file Bot_TestSpawnAndOpenCan.c.

98 {
100
101 // setup nested state machine
102 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
103
106
107 // events
109
110 // transitions
111 m_FSM.AddTransition(new BotTransition(m_Spawning, __EntInH__, m_Opening));
112 //m_FSM.AddTransition(new BotTransition( m_Opening, __EntAtt__, m_Eating));
113 //m_FSM.AddTransition(new BotTransition( m_Eating, __EntAtt__, m_Eating));
114
115 m_FSM.SetInitialState(m_Spawning);
116 }
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition BotFSM.c:7
represents event that triggers transition from state to state
Definition BotEvents.c:5
Bot Finite State Machine (Hierarchical)
void BotSpawnEntityInHands(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
ref BotSpawnEntityInHands m_Spawning
ref BotOpenEntityInHands m_Opening

References m_Type.

◆ BotHunt()

void BotStateBase::BotHunt ( Bot bot = NULL,
BotStateBase parent = NULL )
inlineprivate

Definition at line 23 of file Bot_Hunt.c.

24 {
25 // setup nested state machine
26 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
27
29 m_Hunting = new BotHunt_Hunting(m_Bot, this);
30
31 // events
34
35 // transitions
37 m_FSM.AddTransition(new BotTransition(m_Hunting, __Lost__, m_Tracking));
38
39 m_FSM.SetInitialState(m_Tracking);
40 }
ref BotHunt_Tracking m_Tracking
Definition Bot_Hunt.c:20
ref BotHunt_Hunting m_Hunting
Definition Bot_Hunt.c:21

◆ BotSpawnEntityInHands()

void BotStateBase::BotSpawnEntityInHands ( Bot bot = NULL,
BotStateBase parent = NULL,
string new_type = "" )
inlineprivate

Definition at line 7 of file Bot_TestSpawnAndOpenCan.c.

8 {
9 if (new_type == string.Empty)
10 m_Type = "TunaCan";
11 else
13 }
Empty
Definition Hand_States.c:14

References Empty, and m_Type.

◆ BotTestAttachAndDropCycle()

void BotStateBase::BotTestAttachAndDropCycle ( Bot bot = NULL,
BotStateBase parent = NULL )
inlineprivate

Definition at line 11 of file Bot_TestAttachAndDropCycle.c.

12 {
13 // setup nested state machine
14 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
15
18
19 // events
22
23 // transitions
26
27 m_FSM.SetInitialState(m_Detaching);
28 }
ref BotTestAttachAndDropCycle_Attaching m_Attaching
ref BotTestAttachAndDropCycle_Detaching m_Detaching

◆ BotTestItemMoveBackAndForth()

void BotStateBase::BotTestItemMoveBackAndForth ( Bot bot = NULL,
BotStateBase parent = NULL )
inlineprivate

Definition at line 6 of file Bot_TestItemMoveBackAndForth.c.

7 {
8 // setup nested state machine
9 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
10
12
13 // events
15
16 // transitions
17 m_FSM.AddTransition(new BotTransition(m_Move, __EntAtt__, m_Move));
18
19 m_FSM.SetInitialState(m_Move);
20 }
ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move

◆ BotTimedWait()

void BotStateBase::BotTimedWait ( Bot bot = NULL,
BotStateBase parent = NULL,
float timeout = 3.0 )
inlineprotected

Definition at line 10 of file Bot_TimedWait.c.

11 {
13 }

◆ GetFSM()

BotFSM BotStateBase::GetFSM ( )
inlineprivate

Definition at line 31 of file BotStates.c.

31{ return m_FSM; }

References m_FSM.

◆ GetNextSlot()

int BotStateBase::GetNextSlot ( int curr)
inlineprivate

Definition at line 77 of file Bot_TestItemMoveBackAndForth.c.

78 {
79 if (curr == m_hgSlot)
80 return m_mskSlot;
81 if (curr == m_mskSlot)
82 return m_hgSlot;
83 Error("EE2");
85 }
provides access to slot configuration
const int INVALID
Invalid slot (-1)

References Error(), and InventorySlots::INVALID.

◆ GetParentState()

BotStateBase::GetParentState ( )
inlineprivate
Returns
state that owns this sub-state (or null if plain state)

Definition at line 28 of file BotStates.c.

28{ return m_ParentState; }

References m_ParentState.

◆ GetPlayerOwner()

PlayerBase BotStateBase::GetPlayerOwner ( )
inlineprivate

Definition at line 19 of file BotStates.c.

19{ return m_Owner; }

References m_Owner.

Referenced by SelectTarget().

◆ HasFSM()

bool BotStateBase::HasFSM ( )
inlineprivate

Definition at line 30 of file BotStates.c.

30{ return m_FSM != NULL; }

References m_FSM.

Referenced by AddTransition(), IsWaitingForActionFinish(), OnAbort(), OnEntry(), OnUpdate(), and ProcessEvent().

◆ IsIdle()

BotStateBase::IsIdle ( )
inlineprivate

idle state does not expect any animation events

Returns
true if this state is idle

Definition at line 112 of file BotStates.c.

112{ return false; }

◆ IsWaitingForActionFinish()

BotStateBase::IsWaitingForActionFinish ( )
inlineprivate

waiting for active animation action/actionType finish

Returns
true if this state or active substate is waiting for finish signal

Definition at line 106 of file BotStates.c.

106{ return HasFSM() && m_FSM.IsRunning() && m_FSM.GetCurrentState().IsWaitingForActionFinish(); }

References HasFSM(), and m_FSM.

◆ OnAbort() [1/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 105 of file Bot_Hunt.c.

106 {
107 m_TargetLost = false;
108 m_TargetInSight = false;
109 m_Tracking = false;
110
111 super.OnAbort(e);
112 }
bool m_TargetInSight
Definition Bot_Hunt.c:92
bool m_TargetLost
Definition Bot_Hunt.c:93

◆ OnAbort() [2/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 179 of file Bot_Hunt.c.

179{ super.OnAbort(e); }

◆ OnAbort() [3/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 61 of file Bot_TestAttachAndDropCycle.c.

61{ super.OnAbort(e); }

◆ OnAbort() [4/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 95 of file Bot_TestAttachAndDropCycle.c.

95{ super.OnAbort(e); }

◆ OnAbort() [5/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 70 of file Bot_TestItemMoveBackAndForth.c.

70{ super.OnAbort(e); }

◆ OnAbort() [6/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 64 of file Bot_TestSpawnAndOpenCan.c.

64{ super.OnAbort(e); }

◆ OnAbort() [7/8]

override void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 129 of file Bot_TestSpawnAndOpenCan.c.

129{ super.OnAbort(e); }

◆ OnAbort() [8/8]

void BotStateBase::OnAbort ( BotEventBase e)
inlineprivate

Definition at line 83 of file BotStates.c.

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 }
void botDebugPrint(string s)
Definition Bot.c:182
proto string ToString()
string Type

References botDebugPrint(), HasFSM(), m_FSM, ToString(), and Type.

◆ OnEntry() [1/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 50 of file Bot_Hunt.c.

51 {
52 m_dtAccumulator = 0.0;
54
55 super.OnEntry(e);
56 }
float m_dtAccumulator
Definition Bot_Hunt.c:18
void SelectTarget()
Definition Bot_Hunt.c:42

References m_dtAccumulator, and SelectTarget().

◆ OnEntry() [2/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 96 of file Bot_Hunt.c.

97 {
98 super.OnEntry(e);
99
100 m_TargetLost = false;
101 m_TargetInSight = false;
102 m_Tracking = false;
103 }

◆ OnEntry() [3/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 174 of file Bot_Hunt.c.

175 {
176 super.OnEntry(e);
177 }

◆ OnEntry() [4/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 30 of file Bot_TestAttachAndDropCycle.c.

31 {
32 m_Entity = m_Owner.GetInventory().CreateAttachment("TaloonBag_Orange");
33 m_Detaching.m_Entity = m_Entity;
34 m_Attaching.m_Entity = m_Entity;
35
36 super.OnEntry(e);
37 }

References m_Entity, m_Entity, and m_Owner.

◆ OnEntry() [5/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 56 of file Bot_TestAttachAndDropCycle.c.

57 {
58 super.OnEntry(e);
59 }

◆ OnEntry() [6/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 90 of file Bot_TestAttachAndDropCycle.c.

91 {
92 super.OnEntry(e);
93 }

◆ OnEntry() [7/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 22 of file Bot_TestItemMoveBackAndForth.c.

23 {
24 //m_Entity = m_Owner.GetInventory().CreateAttachment("TaloonBag_Orange");
25 //m_Entity = m_Owner.GetInventory().FindAttachment();
26 EntityAI hgear = m_Owner.GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("Headgear"));
27 EntityAI mask = m_Owner.GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("Mask"));
28
29 if (hgear)
31 if (mask)
32 m_Entity = mask;
33
34
36 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
37 m_Move.m_WaitingForSlot = loc.GetSlot();
38 else
39 Error("EE");
40 m_Move.m_Entity = m_Entity;
41
42 super.OnEntry(e);
43 }
InventoryLocation.
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id

References Error(), InventorySlots::GetSlotIdFromString(), m_Entity, m_Entity, and m_Owner.

◆ OnEntry() [8/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 65 of file Bot_TestItemMoveBackAndForth.c.

66 {
67 super.OnEntry(e);
68 }

◆ OnEntry() [9/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 15 of file Bot_TestSpawnAndOpenCan.c.

16 {
17 super.OnEntry(e);
18
19 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
20 m_Owner.GetHumanInventory().CreateInHands(m_Type);
21 }
DayZPlayerInstanceType
defined in C++

References m_Owner, and m_Type.

◆ OnEntry() [10/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 44 of file Bot_TestSpawnAndOpenCan.c.

45 {
46 super.OnEntry(e);
47
48 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
49 {
51 if (ev_ih)
52 {
53 m_Entity = ev_ih.m_Entity;
55 if (b)
56 {
57 botDebugPrint("[bot] + " + m_Owner + " will open edible item=" + b + " bot=" + m_Owner);
58 b.Open();
59 }
60 }
61 }
62 }

References botDebugPrint(), m_Entity, and m_Owner.

◆ OnEntry() [11/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 118 of file Bot_TestSpawnAndOpenCan.c.

118{ super.OnEntry(e); }

◆ OnEntry() [12/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 128 of file Bot_TestSpawnAndOpenCan.c.

128{ super.OnEntry(e); }

◆ OnEntry() [13/14]

override void BotStateBase::OnEntry ( BotEventBase e)
inlineprotected

Definition at line 15 of file Bot_TimedWait.c.

16 {
17 m_dtAccumulator = 0.0;
18
19 super.OnEntry(e);
20 }

References m_dtAccumulator.

◆ OnEntry() [14/14]

void BotStateBase::OnEntry ( BotEventBase e)
inlineprivate

Definition at line 57 of file BotStates.c.

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 }

References botDebugPrint(), HasFSM(), m_FSM, ToString(), and Type.

◆ OnExit() [1/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 58 of file Bot_Hunt.c.

59 {
60 m_dtAccumulator = 0.0;
61 m_Target = null;
62
63 super.OnExit(e);
64 }

References m_dtAccumulator, and m_Target.

◆ OnExit() [2/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 114 of file Bot_Hunt.c.

115 {
116 m_TargetLost = false;
117 m_TargetInSight = false;
118 m_Tracking = false;
119
120 super.OnExit(e);
121 }

◆ OnExit() [3/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 181 of file Bot_Hunt.c.

182 {
183 super.OnExit(e);
184 }

◆ OnExit() [4/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 39 of file Bot_TestAttachAndDropCycle.c.

40 {
41 m_Entity = null;
42
43 super.OnExit(e);
44 }

References m_Entity.

◆ OnExit() [5/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 63 of file Bot_TestAttachAndDropCycle.c.

64 {
65 super.OnExit(e);
66 }

◆ OnExit() [6/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 97 of file Bot_TestAttachAndDropCycle.c.

98 {
99 super.OnExit(e);
100 }

◆ OnExit() [7/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 45 of file Bot_TestItemMoveBackAndForth.c.

46 {
47 m_Entity = null;
48
49 super.OnExit(e);
50 }

References m_Entity.

◆ OnExit() [8/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 72 of file Bot_TestItemMoveBackAndForth.c.

73 {
74 super.OnExit(e);
75 }

◆ OnExit() [9/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 23 of file Bot_TestSpawnAndOpenCan.c.

23{ super.OnExit(e); }

◆ OnExit() [10/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 66 of file Bot_TestSpawnAndOpenCan.c.

67 {
68 super.OnExit(e);
69 }

◆ OnExit() [11/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 119 of file Bot_TestSpawnAndOpenCan.c.

119{ super.OnExit(e); }

◆ OnExit() [12/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 130 of file Bot_TestSpawnAndOpenCan.c.

130{ super.OnExit(e); }

◆ OnExit() [13/14]

override void BotStateBase::OnExit ( BotEventBase e)
inlineprotected

Definition at line 22 of file Bot_TimedWait.c.

23 {
24 m_dtAccumulator = 0.0;
25
26 super.OnExit(e);
27 }

References m_dtAccumulator.

◆ OnExit() [14/14]

void BotStateBase::OnExit ( BotEventBase e)
inlineprivate

Definition at line 97 of file BotStates.c.

98 {
99 botDebugPrint("[botfsm] } " + this.Type().ToString());
100 }

References botDebugPrint(), ToString(), and Type.

◆ OnStateChanged()

BotStateBase::OnStateChanged ( BotStateBase src,
BotStateBase dst )
inlineprivate

called on current state when state machine has changed its state

Parameters
[in]srcfrom state (previous)
[in]dstto state (current)

Definition at line 126 of file BotStates.c.

126{ }

◆ OnSubMachineChanged()

BotStateBase::OnSubMachineChanged ( BotStateBase src,
BotStateBase dst )
inlineprivate

called when sub-machine has changed its state

Parameters
[in]srcfrom state (previous)
[in]dstto state (current)

Definition at line 119 of file BotStates.c.

119{ }

◆ OnTimeout()

void BotStateBase::OnTimeout ( )
inlineprotected

Definition at line 47 of file Bot_TimedWait.c.

48 {
49 botDebugSpam("[bot] + " + m_Owner + " BotTimedWait::OnTimeout");
51 }
void botDebugSpam(string s)
Definition Bot.c:191
bool ProcessEvent(BotEventBase e)
Definition Bot.c:167

References botDebugSpam(), and m_Owner.

◆ OnUpdate() [1/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 66 of file Bot_Hunt.c.

67 {
68 super.OnUpdate(dt);
69
71
72 /*float rescanTime = 3.0;
73 if (m_dtAccumulator >= rescanTime)
74 if (m_weapon.CanProcessWeaponEvents())
75 m_Bot.ProcessEvent(new WeaponEventReloadTimeout(p));*/
76
77 if (m_Target == null)
78 {
79 int acc = m_dtAccumulator;
80 if (acc % 5 == 0)
81 {
82 Print("Searching...");
84 }
85 }
86 }
proto void Print(void var)
Prints content of variable to console/log.

References m_dtAccumulator, m_dtAccumulator, m_Target, Print(), and SelectTarget().

◆ OnUpdate() [2/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 123 of file Bot_Hunt.c.

124 {
125 if (m_Target)
126 {
127 m_Tracking = true;
128 vector targetPos = m_Target.GetPosition();
129 botDebugPrint("[bot] + " + m_Owner + " hunt Tracking target=" + m_Target + " pos=" + targetPos);
130
131 // tmp dist check
132 float d = vector.Distance(m_Target.GetPosition(), GetPlayerOwner().GetPosition());
133 if (d < 2.0)
134 m_TargetInSight = true;
135 else
136 m_TargetInSight = false;
137
138 if (!m_TargetInSight)
139 {
140 GetPlayerOwner().GetInputController().OverrideMovementSpeed(true, 1);
141 GetPlayerOwner().GetInputController().OverrideMovementAngle(true, 1);
142 }
143 else
144 {
145 GetPlayerOwner().GetInputController().OverrideMovementSpeed(false, 0);
146 GetPlayerOwner().GetInputController().OverrideMovementAngle(false, 0);
147 }
148
149 /*if ((.GetInputController().LimitsIsSprintDisabled()))
150 .GetInputController().OverrideMovementSpeed( true, 2 );
151 else
152 .GetInputController().OverrideMovementSpeed( true, 3 );*/
153
154 }
155 else
156 {
157 if (m_Tracking)
158 {
159 m_TargetLost = true;
160 m_TargetInSight = false;
161 m_Tracking = false;
162
163 GetPlayerOwner().GetInputController().OverrideMovementSpeed(false, 0);
164 GetPlayerOwner().GetInputController().OverrideMovementAngle(false, 0);
165 }
166 }
167 }
class JsonUndergroundAreaTriggerData GetPosition
PlayerBase GetPlayerOwner()
Definition BotStates.c:19
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References botDebugPrint(), vector::Distance(), GetPosition, m_Owner, and m_Target.

◆ OnUpdate() [3/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 186 of file Bot_Hunt.c.

187 {
188 }

◆ OnUpdate() [4/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 46 of file Bot_TestAttachAndDropCycle.c.

47 {
48 super.OnUpdate(dt);
49 }

◆ OnUpdate() [5/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 68 of file Bot_TestAttachAndDropCycle.c.

69 {
70 if (m_Entity)
71 {
72 botDebugPrint("[bot] + " + m_Owner + " drop item=" + m_Entity + " bot=" + m_Owner);
73
74 m_Owner.PredictiveDropEntity(m_Entity);
75
77 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
78 {
79 if (loc.GetType() == InventoryLocationType.GROUND)
81 }
82 }
83 }
InventoryLocationType
types of Inventory Location

References botDebugPrint(), m_Entity, and m_Owner.

◆ OnUpdate() [6/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 102 of file Bot_TestAttachAndDropCycle.c.

103 {
104 if (m_Entity)
105 {
106 botDebugPrint("[bot] + " + m_Owner + " att item=" + m_Entity + " bot=" + m_Owner);
107
108 if (m_Owner.GetInventory().CanAddAttachment(m_Entity))
109 {
110 m_Owner.PredictiveTakeEntityAsAttachment(m_Entity);
111
113 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
114 {
115 if (loc.GetType() == InventoryLocationType.ATTACHMENT)
117 }
118 }
119 }
120 }

References botDebugPrint(), m_Entity, and m_Owner.

◆ OnUpdate() [7/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 52 of file Bot_TestItemMoveBackAndForth.c.

53 {
54 super.OnUpdate(dt);
55 }

◆ OnUpdate() [8/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 87 of file Bot_TestItemMoveBackAndForth.c.

88 {
89 if (m_Entity)
90 {
91 botDebugPrint("[bot] + " + m_Owner + " move item=" + m_Entity);
92
94 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
95 {
96 if (loc.GetType() == InventoryLocationType.ATTACHMENT)
97 {
98 if (loc.GetSlot() == m_WaitingForSlot)
99 {
101 botDebugPrint("[bot] + " + m_Owner + " will switch slot=" + nextSlot + " for item=" + m_Entity);
102
104
105 m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, nextSlot);
106 //m_Bot.ProcessEvent(new BotEventEntityDet(m_Owner, m_Entity));
107 }
108 }
109 }
110 }
111 }

References botDebugPrint(), m_Entity, and m_Owner.

◆ OnUpdate() [9/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 25 of file Bot_TestSpawnAndOpenCan.c.

26 {
27 super.OnUpdate(dt);
28
29 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
30 if (inHands)
31 {
32 botDebugPrint("[bot] + " + m_Owner + " hand item=" + inHands + " bot=" + m_Owner);
34 }
35 }

References botDebugPrint(), and m_Owner.

◆ OnUpdate() [10/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 71 of file Bot_TestSpawnAndOpenCan.c.

72 {
73 super.OnUpdate(dt);
74
75 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
76 botDebugSpam("[bot] + " + m_Owner + " wait for opened item inHands=" + inHands + " bot=" + m_Owner);
77 if (inHands)
78 {
79 string t_str = inHands.GetType();
80 //string t_str = t.ToString();
81 if (t_str.IndexOf("_Opened") != -1)
82 {
83 botDebugPrint("[bot] + " + m_Owner + " opened item=" + inHands + " bot=" + m_Owner);
85 }
86 }
87 }

References botDebugPrint(), botDebugSpam(), and m_Owner.

◆ OnUpdate() [11/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 120 of file Bot_TestSpawnAndOpenCan.c.

120{ super.OnUpdate(dt); }

◆ OnUpdate() [12/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 132 of file Bot_TestSpawnAndOpenCan.c.

133 {
134 super.OnUpdate(dt);
135
136 EntityAI inHands = m_Owner.GetHumanInventory().GetEntityInHands();
137 botDebugSpam("[bot] + " + m_Owner + " waiting for empty hands, inHands=" + inHands + " bot=" + m_Owner);
138 if (!inHands)
139 {
140 botDebugPrint("[bot] + " + m_Owner + " hand slot empty. bot=" + m_Owner);
142 }
143 }

References botDebugPrint(), botDebugSpam(), and m_Owner.

◆ OnUpdate() [13/14]

override void BotStateBase::OnUpdate ( float dt)
inlineprotected

Definition at line 29 of file Bot_TimedWait.c.

30 {
31 super.OnUpdate(dt);
32
34
35 float rescanTime = m_Timeout;
37 {
38 OnTimeout();
39
40 if (m_Periodic)
41 m_dtAccumulator = 0.0;
42 else
43 m_dtAccumulator = -1.0;
44 }
45 }

References m_dtAccumulator, and OnTimeout().

◆ OnUpdate() [14/14]

void BotStateBase::OnUpdate ( float dt)
inlineprivate

Definition at line 73 of file BotStates.c.

74 {
75 if (HasFSM() && m_FSM.IsRunning())
76 m_FSM.GetCurrentState().OnUpdate(dt);
77 }

References HasFSM(), and m_FSM.

◆ ProcessEvent()

bool BotStateBase::ProcessEvent ( BotEventBase e)
inlineprivate

Definition at line 33 of file BotStates.c.

34 {
35 if (HasFSM())
36 return m_FSM.ProcessEvent(e);
37 return false;
38 }

References HasFSM(), and m_FSM.

◆ SelectTarget()

void BotStateBase::SelectTarget ( )
inlineprivate

Definition at line 42 of file Bot_Hunt.c.

43 {
45 m_Tracking.m_Target = m_Target;
46 m_Hunting.m_Target = m_Target;
47 botDebugPrint("[bot] + " + m_Owner + " hunt SelectTarget target=" + m_Target);
48 }
Man BotSelectNearestTarget(EntityAI bot)
Definition Bot_Hunt.c:191

References botDebugPrint(), BotSelectNearestTarget(), GetPlayerOwner(), m_Owner, m_Target, and m_Target.

Referenced by OnEntry(), and OnUpdate().

◆ SetParentState()

BotStateBase::SetParentState ( BotStateBase parent)
inlineprivate

allows construction of hierarchical state machine

Definition at line 24 of file BotStates.c.

24{ m_ParentState = parent; }

References m_ParentState.

Member Data Documentation

◆ m_Attaching

ref BotTestAttachAndDropCycle_Attaching BotStateBase::m_Attaching
private

Definition at line 9 of file Bot_TestAttachAndDropCycle.c.

◆ m_Bot

Bot BotStateBase::m_Bot
private

man that this state belongs to

Definition at line 13 of file BotStates.c.

Referenced by BotStateBase(), BotStateIdle::BotStateIdle(), and BotTestSpamUserActions::BotTestSpamUserActions().

◆ m_Detaching

ref BotTestAttachAndDropCycle_Detaching BotStateBase::m_Detaching
private

Definition at line 8 of file Bot_TestAttachAndDropCycle.c.

◆ m_dtAccumulator

float BotStateBase::m_dtAccumulator = 0.0
private

Definition at line 18 of file Bot_Hunt.c.

Referenced by OnUpdate().

◆ m_Entity

EntityAI BotStateBase::m_Entity
private

Definition at line 7 of file Bot_TestAttachAndDropCycle.c.

Referenced by OnEntry().

◆ m_FSM

ref BotFSM BotStateBase::m_FSM
private

hierarchical parent state of this state (or null)

Definition at line 15 of file BotStates.c.

Referenced by AddTransition(), BotTestSpamUserActions::BotTestSpamUserActions(), GetFSM(), HasFSM(), IsWaitingForActionFinish(), OnAbort(), OnEntry(), OnUpdate(), and ProcessEvent().

◆ m_hgSlot

int BotStateBase::m_hgSlot = InventorySlots.GetSlotIdFromString("Headgear")
private

Definition at line 62 of file Bot_TestItemMoveBackAndForth.c.

◆ m_Hunting

ref BotHunt_Hunting BotStateBase::m_Hunting
private

Definition at line 21 of file Bot_Hunt.c.

◆ m_Move

Definition at line 4 of file Bot_TestItemMoveBackAndForth.c.

◆ m_mskSlot

int BotStateBase::m_mskSlot = InventorySlots.GetSlotIdFromString("Mask")
private

Definition at line 63 of file Bot_TestItemMoveBackAndForth.c.

◆ m_Opening

ref BotOpenEntityInHands BotStateBase::m_Opening
private

Definition at line 95 of file Bot_TestSpawnAndOpenCan.c.

◆ m_Owner

◆ m_ParentState

BotStateBase BotStateBase::m_ParentState
private

bot that this state belongs to

Definition at line 14 of file BotStates.c.

Referenced by BotStateBase(), BotStateIdle::BotStateIdle(), GetParentState(), and SetParentState().

◆ m_Periodic

bool BotStateBase::m_Periodic = true
protected

Definition at line 8 of file Bot_TimedWait.c.

◆ m_Spawning

ref BotSpawnEntityInHands BotStateBase::m_Spawning
private

Definition at line 94 of file Bot_TestSpawnAndOpenCan.c.

◆ m_Target [1/2]

EntityAI BotStateBase::m_Target
private

Definition at line 17 of file Bot_Hunt.c.

Referenced by SelectTarget().

◆ m_Target [2/2]

EntityAI BotStateBase::m_Target
private

Definition at line 91 of file Bot_Hunt.c.

◆ m_TargetInSight

bool BotStateBase::m_TargetInSight = false
private

Definition at line 92 of file Bot_Hunt.c.

◆ m_TargetLost

bool BotStateBase::m_TargetLost = false
private

Definition at line 93 of file Bot_Hunt.c.

◆ m_Timeout

float BotStateBase::m_Timeout = 3.0
protected

Definition at line 7 of file Bot_TimedWait.c.

◆ m_Tracking [1/2]

ref BotHunt_Tracking BotStateBase::m_Tracking
private

Definition at line 20 of file Bot_Hunt.c.

◆ m_Tracking [2/2]

bool BotStateBase::m_Tracking = true
private

Definition at line 94 of file Bot_Hunt.c.

◆ m_Type

string BotStateBase::m_Type
private

Definition at line 5 of file Bot_TestSpawnAndOpenCan.c.

◆ m_WaitingForSlot

int BotStateBase::m_WaitingForSlot = InventorySlots.INVALID
private

Definition at line 61 of file Bot_TestItemMoveBackAndForth.c.


The documentation for this class was generated from the following files: