DayZ 1.24
Loading...
Searching...
No Matches
Bot Class Reference
Collaboration diagram for Bot:
[legend]

Protected Member Functions

void Bot (PlayerBase ow)
 
void SetInstanceType (DayZPlayerInstanceType t)
 
void Start (bool use_trigger, BotTrigger trigger=null)
 
void DelayedStart (float ms)
 
void OnDelayedStart ()
 
void Stop ()
 
void OnTrigger ()
 
void OnUpdate (float dt)
 
void OnTimer ()
 
bool ProcessEvent (BotEventBase e)
 
void InitFSM ()
 

Protected Attributes

ref Timer m_Timer = new Timer
 
const float c_TriggerTimeoutMS = 1000.0
 
const float c_UpdateMS = 16.0
 
ref BotFSM m_FSM = null
 
bool m_UseTrigger = false
 
bool m_Triggered = false
 
DayZPlayerInstanceType m_InstanceType = DayZPlayerInstanceType.INSTANCETYPE_CLIENT
 
ref BotTrigger m_BotTrigger = null
 
ref BotStateBase m_BotTest = null
 

Private Attributes

PlayerBase m_Owner = null
 

Detailed Description

Definition at line 18 of file Bot.c.

Constructor & Destructor Documentation

◆ Bot()

void Bot::Bot ( PlayerBase ow)
inlineprotected

Definition at line 32 of file Bot.c.

33 {
34 m_Owner = ow;
35 }
PlayerBase m_Owner
Definition Bot.c:20

References m_Owner.

Member Function Documentation

◆ DelayedStart()

void Bot::DelayedStart ( float ms)
inlineprotected

Definition at line 62 of file Bot.c.

63 {
64 m_Timer.Run(ms / 1000.0, this, "OnDelayedStart", null, false);
65 }
ref Timer m_Timer
Definition Bot.c:21

References m_Timer.

◆ InitFSM()

void Bot::InitFSM ( )
inlineprotected

transition table

Definition at line 126 of file Bot.c.

References m_BotTest, and m_FSM.

Referenced by Start().

◆ OnDelayedStart()

void Bot::OnDelayedStart ( )
inlineprotected

Definition at line 67 of file Bot.c.

68 {
69 Start(false, null);
70
72 m_UseTrigger = false;
73 }
void Start()
Plays all elements this effects consists of.
Definition Effect.c:149
bool m_UseTrigger
Definition Bot.c:26
bool ProcessEvent(BotEventBase e)
Definition Bot.c:167

References m_Owner, m_UseTrigger, ProcessEvent(), and Start().

◆ OnTimer()

void Bot::OnTimer ( )
inlineprotected

Definition at line 119 of file Bot.c.

120 {
121 //m_FSM.GetCurrentState().OnUpdate(c_UpdateMS / 1000.0);
122
123 //OnTrigger(); // to detect trigger stop
124 }

◆ OnTrigger()

void Bot::OnTrigger ( )
inlineprotected

Definition at line 82 of file Bot.c.

83 {
84 bool triggered = m_BotTrigger.CheckTrigger();
85
86 if (!m_Triggered)
87 {
88 if (triggered)
89 {
90 m_Timer.Stop(); // stop trigger timer
91 m_Triggered = true;
93 m_Timer.Run(c_UpdateMS / 1000.0, this, "OnUpdate", null, true);
94
95 botDebugPrint("[bot] + " + m_Owner + " Started test!");
96 }
97 }
98 else
99 {
100 if (!triggered)
101 {
102 m_Timer.Stop(); // stop update timer
103 m_Triggered = false;
105 m_Timer.Run(c_TriggerTimeoutMS / 1000.0, this, "OnTrigger", null, true);
106
107 botDebugPrint("[bot] + " + m_Owner + " Stopped test!");
108 }
109 }
110 }
void botDebugPrint(string s)
Definition Bot.c:182
const float c_TriggerTimeoutMS
Definition Bot.c:22
const float c_UpdateMS
Definition Bot.c:24
ref BotTrigger m_BotTrigger
Definition Bot.c:29
bool m_Triggered
Definition Bot.c:27

References botDebugPrint(), c_TriggerTimeoutMS, c_UpdateMS, m_BotTrigger, m_Owner, m_Timer, m_Triggered, and ProcessEvent().

Referenced by OnUpdate().

◆ OnUpdate()

void Bot::OnUpdate ( float dt)
inlineprotected

Definition at line 112 of file Bot.c.

113 {
114 m_FSM.GetCurrentState().OnUpdate(dt);
115
116 OnTrigger(); // to detect trigger stop
117 }
void OnTrigger()
Definition Bot.c:82
ref BotFSM m_FSM
Definition Bot.c:25

References m_FSM, and OnTrigger().

◆ ProcessEvent()

bool Bot::ProcessEvent ( BotEventBase e)
inlineprotected

Definition at line 167 of file Bot.c.

168 {
169 if (m_FSM.ProcessEvent(e) == ProcessEventResult.FSM_OK)
170 {
171 botDebugSpam("[botfsm] Processed event e=" + e.ToString());
172 return true;
173 }
174 else
175 {
176 botDebugSpam("[botfsm] FSM refused to process event (no transition): src=" + m_FSM.GetCurrentState().ToString() + " event=" + e.ToString());
177 return false;
178 }
179 }
void botDebugSpam(string s)
Definition Bot.c:191
ProcessEventResult
Definition FSMBase.c:41

References botDebugSpam(), and m_FSM.

Referenced by OnDelayedStart(), and OnTrigger().

◆ SetInstanceType()

void Bot::SetInstanceType ( DayZPlayerInstanceType t)
inlineprotected

Definition at line 37 of file Bot.c.

37{ m_InstanceType = t; }
DayZPlayerInstanceType m_InstanceType
Definition Bot.c:28

References m_InstanceType.

◆ Start()

void Bot::Start ( bool use_trigger,
BotTrigger trigger = null )
inlineprotected

Definition at line 39 of file Bot.c.

40 {
42
43 InitFSM();
44
45 if (m_UseTrigger)
46 {
47 if (m_UseTrigger && trigger == null)
48 Error("use trigger, but trigger null");
49
50 m_Triggered = false;
52 botDebugPrint("[bot] + " + m_Owner + " Bot waiting for trigger...");
53 m_Timer.Run(c_TriggerTimeoutMS / 1000.0, this, "OnTrigger", null, true);
54 }
55 else
56 {
57 botDebugPrint("[bot] + " + m_Owner + " Bot Started.");
58 m_Timer.Run(c_UpdateMS / 1000.0, this, "OnTimer", null, true);
59 }
60 }
void InitFSM()
Definition Bot.c:126
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References botDebugPrint(), c_TriggerTimeoutMS, c_UpdateMS, Error(), InitFSM(), m_BotTrigger, m_Owner, m_Timer, m_Triggered, and m_UseTrigger.

◆ Stop()

void Bot::Stop ( )
inlineprotected

Definition at line 75 of file Bot.c.

76 {
77 m_Triggered = false;
78 m_Timer.Stop();
79 m_FSM.Terminate();
80 }

References m_FSM, m_Timer, and m_Triggered.

Member Data Documentation

◆ c_TriggerTimeoutMS

const float Bot::c_TriggerTimeoutMS = 1000.0
protected

Definition at line 22 of file Bot.c.

Referenced by OnTrigger(), and Start().

◆ c_UpdateMS

const float Bot::c_UpdateMS = 16.0
protected

Definition at line 24 of file Bot.c.

Referenced by OnTrigger(), and Start().

◆ m_BotTest

ref BotStateBase Bot::m_BotTest = null
protected

Definition at line 30 of file Bot.c.

Referenced by InitFSM().

◆ m_BotTrigger

ref BotTrigger Bot::m_BotTrigger = null
protected

Definition at line 29 of file Bot.c.

Referenced by OnTrigger(), and Start().

◆ m_FSM

ref BotFSM Bot::m_FSM = null
protected

Definition at line 25 of file Bot.c.

Referenced by InitFSM(), OnUpdate(), ProcessEvent(), and Stop().

◆ m_InstanceType

Definition at line 28 of file Bot.c.

Referenced by SetInstanceType().

◆ m_Owner

PlayerBase Bot::m_Owner = null
private

Definition at line 20 of file Bot.c.

Referenced by Bot(), BotStateIdle::BotStateIdle(), OnDelayedStart(), OnTrigger(), and Start().

◆ m_Timer

ref Timer Bot::m_Timer = new Timer
protected

Definition at line 21 of file Bot.c.

Referenced by DelayedStart(), OnTrigger(), Start(), and Stop().

◆ m_Triggered

bool Bot::m_Triggered = false
protected

Definition at line 27 of file Bot.c.

Referenced by OnTrigger(), Start(), and Stop().

◆ m_UseTrigger

bool Bot::m_UseTrigger = false
protected

Definition at line 26 of file Bot.c.

Referenced by OnDelayedStart(), and Start().


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