DayZ 1.24
Loading...
Searching...
No Matches
Bot_TestSpawnDeadBury.c
Go to the documentation of this file.
1#ifdef BOT
3
4class BotSpawnDead extends BotStateBase
5{
6 string m_Type;
7
8 void BotSpawnDead(Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
9 {
10 if (new_type == string.Empty)
11 m_Type = "ZmbM_HermitSkinny_Beige";
12 else
14 }
15
16 override void OnEntry(BotEventBase e)
17 {
18 super.OnEntry(e);
19
20 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
21 {
22 EntityAI Z = EntityAI.Cast(GetGame().CreateObject(m_Type, m_Owner.GetPosition()));
23 Z.SetHealth("", "", 0);
24 Error("TODO");
25 //m_Bot.PostEvent(new BotEventEntitySpawned(m_Owner, Z));
26 }
27 }
28};
29
31{
32 string m_Type;
34 ref BotSpawnEntityInHands m_SpawnShovel;
37
38 void Bot_TestSpawnDeadSelectBury(Bot bot = NULL, BotStateBase parent = NULL, string new_type = "ZmbM_HermitSkinny_Beige")
39 {
41
42 // setup nested state machine
43 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
44
45 m_SpawnDead = new BotSpawnDead(m_Bot, this, m_Type);
46 m_SpawnShovel = new BotSpawnEntityInHands(m_Bot, this, "Shovel");
47 m_Selecting = new BotSelectZombieTarget(m_Bot, this);
48 m_Burying = new BotPerformAction(m_Bot, this, AT_BURY_BODY);
49
50 // events
54
55 // transitions
56 m_FSM.AddTransition(new BotTransition(m_SpawnDead, NULL, m_SpawnShovel));
57 m_FSM.AddTransition(new BotTransition(m_SpawnShovel, __EntInH__, m_Selecting));
58 m_FSM.AddTransition(new BotTransition(m_Selecting, __Select__, m_Burying));
59 m_FSM.AddTransition(new BotTransition(m_Burying, NULL, NULL));
60
61 m_FSM.SetInitialState(m_SpawnDead);
62 }
63
64 override void OnEntry(BotEventBase e) { super.OnEntry(e); }
65 override void OnExit(BotEventBase e) { super.OnExit(e); }
66 override void OnUpdate(float dt) { super.OnUpdate(dt); }
67};
68
69
71
73{
75 float m_dtAccumulator = 0.0;
76
77 void SelectTarget()
78 {
79 //m_Target = NearestTargetSelector<ZombieMaleBase>.Find(GetPlayerOwner(), NULL);
80 botDebugPrint("[bot] + " + m_Owner + " hunt SelectTarget target=" + m_Target);
81 }
82
83 override void OnEntry(BotEventBase e)
84 {
85 super.OnEntry(e);
86 m_dtAccumulator = 0.0;
87 SelectTarget();
88 }
89
90 override void OnExit(BotEventBase e)
91 {
92 m_dtAccumulator = 0.0;
93 m_Target = null;
94
95 super.OnExit(e);
96 }
97
98 override void OnUpdate(float dt)
99 {
100 super.OnUpdate(dt);
101
103
104 if (m_Target == null)
105 {
106 if (m_dtAccumulator > 2.0)
107 {
108 botDebugPrint("[bot] + " + m_Owner + " searching...");
109 SelectTarget();
110 if (m_Target)
111 {
112 Error("TODO");
113 //m_Bot.PostEvent(new BotEventSelectedTarget(m_Owner, m_Target));
114 }
115
116 m_dtAccumulator = 0.0;
117 }
118 }
119 else
120 {
121 Error("TODO");
122 //m_Bot.PostEvent(new BotEventSelectedTarget(m_Owner, m_Target));
123 }
124 }
125};
126
127class BotPerformAction extends BotStateBase
128{
130 int m_ActionID;
131
132 void BotPerformAction(Bot bot = NULL, BotStateBase parent = NULL, int action = AT_EAT)
133 {
135 }
136
137 override void OnEntry(BotEventBase e)
138 {
139 super.OnEntry(e);
140
141 if (e.m_Entity)
142 {
143 botDebugPrint("[bot] + " + m_Owner + " performing action on item=" + e.m_Entity);
144
145 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
146 {
147#ifdef BOT
148 ActionManagerClient cli_mgr = ActionManagerClient.Cast(m_Owner.GetActionManager());
149 if (cli_mgr)
150 cli_mgr.PerformAction(m_ActionID, new ActionTarget(e.m_Entity, null, -1, vector.Zero, -1), e.m_Entity);
151#endif
152 }
153 }
154 }
155
156 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
157 override void OnExit(BotEventBase e) { super.OnExit(e); }
158 override void OnUpdate(float dt) { super.OnUpdate(dt); }
159};
160
161
162/*class BotHunt extends BotStateBase
163 {
164 float m_dtAccumulator = 0.0;
165
166 override void OnEntry (BotEventBase e)
167 {
168 super.OnEntry(e);
169 m_dtAccumulator = 0.0;
170 }
171
172 override void OnExit (BotEventBase e)
173 {
174 m_dtAccumulator = 0.0;
175 super.OnExit(e);
176 }
177
178 override void OnUpdate (float dt)
179 {
180 super.OnUpdate(dt);
181
182 m_dtAccumulator += dt;
183
184 float rescanTime = 3.0;
185 if (m_dtAccumulator >= rescanTime)
186 if (m_weapon.CanProcessWeaponEvents())
187 m_Bot.ProcessEvent(new WeaponEventReloadTimeout(p));
188 }
189 };
190*/
191
192
193#endif
eBleedingSourceType m_Type
int m_ActionID
Definition ActionBase.c:58
ref ActionTarget m_Target
Definition ActionBase.c:17
EntityAI m_Entity
Definition ActionDebug.c:11
class ActionTargets ActionTarget
void botDebugPrint(string s)
Definition Bot.c:182
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition BotFSM.c:7
override void OnExit(HandEventBase e)
Definition Hand_States.c:28
HandStateEquipped OnEntry
Empty
Definition Hand_States.c:14
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
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
Base class for eatch Infected type.
static const vector Zero
Definition EnConvert.c:110
DayZPlayerInstanceType
defined in C++
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto native void OnUpdate()
Definition tools.c:333