Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bot_testspawndeadbury.c
Go to the documentation of this file.
1 #ifdef BOT
2 class BotEventEntitySpawned : BotEventBase { };
3 
4 class 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
13  m_Type = new_type;
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 
30 class Bot_TestSpawnDeadSelectBury extends BotStateBase
31 {
32  string m_Type;
33  ref BotSpawnDead m_SpawnDead;
34  ref BotSpawnEntityInHands m_SpawnShovel;
35  ref BotSelectZombieTarget m_Selecting;
36  ref BotPerformAction m_Burying;
37 
38  void Bot_TestSpawnDeadSelectBury (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "ZmbM_HermitSkinny_Beige")
39  {
40  m_Type = new_type;
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
51  BotEventBase __SpwnZ__ = new BotEventEntitySpawned;
52  BotEventBase __EntInH__ = new BotEventEntityInHands;
53  BotEventBase __Select__ = new BotEventSelectedTarget;
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 
70 class BotEventSelectedTarget : BotEventBase { };
71 
72 class BotSelectZombieTarget extends BotStateBase
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 
102  m_dtAccumulator += dt;
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 
127 class BotPerformAction extends BotStateBase
128 {
130  int m_ActionID;
131 
132  void BotPerformAction (Bot bot = NULL, BotStateBase parent = NULL, int action = AT_EAT)
133  {
134  m_ActionID = action;
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 
163 /*class BotHunt extends BotStateBase
164 {
165  float m_dtAccumulator = 0.0;
166 
167  override void OnEntry (BotEventBase e)
168  {
169  super.OnEntry(e);
170  m_dtAccumulator = 0.0;
171  }
172 
173  override void OnExit (BotEventBase e)
174  {
175  m_dtAccumulator = 0.0;
176  super.OnExit(e);
177  }
178 
179  override void OnUpdate (float dt)
180  {
181  super.OnUpdate(dt);
182 
183  m_dtAccumulator += dt;
184 
185  float rescanTime = 3.0;
186  if (m_dtAccumulator >= rescanTime)
187  if (m_weapon.CanProcessWeaponEvents())
188  m_Bot.ProcessEvent(new WeaponEventReloadTimeout(p));
189  }
190 };
191 */
192 
193 
194 #endif
GetGame
proto native CGame GetGame()
m_Target
ref ActionTarget m_Target
Definition: actionbase.c:17
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
ZombieMaleBase
Base class for eatch Infected type.
Definition: zombiemalebase.c:16
OnAbort
override void OnAbort()
Definition: remotedetonator.c:300
m_Type
eBleedingSourceType m_Type
Definition: bleedingsource.c:25
OnExit
override void OnExit(HandEventBase e)
Definition: hand_states.c:28
Bot
Definition: bot.c:18
BotStateBase
represent weapon state base
Definition: bot_hunt.c:15
m_ActionID
protected int m_ActionID
Definition: actionbase.c:58
m_dtAccumulator
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
botDebugPrint
void botDebugPrint(string s)
Definition: bot.c:182
BotEventBase
represents event that triggers transition from state to state
Definition: botevents.c:4
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
BotTransition
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition: botfsm.c:7
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
ActionManagerClient
Definition: actionmanagerclient.c:4
m_Owner
enum ProcessDirectDamageFlags m_Owner
Empty
Empty
Definition: hand_states.c:3
BotEventEntityInHands
Definition: bot_testspawnandopencan.c:1
BotFSM
Bot Finite State Machine (Hierarchical)
EntityAI
Definition: building.c:5
m_Entity
EntityAI m_Entity
Definition: actiondebug.c:11
OnEntry
HandStateEquipped OnEntry
Definition: weaponchambering.c:208
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058