Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bot_testattachanddropcycle.c
Go to the documentation of this file.
2 
4 
5 class BotTestAttachAndDropCycle extends BotStateBase
6 {
8  ref BotTestAttachAndDropCycle_Detaching m_Detaching;
9  ref BotTestAttachAndDropCycle_Attaching m_Attaching;
10 
11  void BotTestAttachAndDropCycle (Bot bot = NULL, BotStateBase parent = NULL)
12  {
13  // setup nested state machine
14  m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
15 
16  m_Detaching = new BotTestAttachAndDropCycle_Detaching(m_Bot, this);
17  m_Attaching = new BotTestAttachAndDropCycle_Attaching(m_Bot, this);
18 
19  // events
20  BotEventBase __EntAtt__ = new BotEventEntityAttached;
21  BotEventBase __EntDet__ = new BotEventEntityDetached;
22 
23  // transitions
24  m_FSM.AddTransition(new BotTransition( m_Detaching, __EntDet__, m_Attaching));
25  m_FSM.AddTransition(new BotTransition( m_Attaching, __EntAtt__, m_Detaching));
26 
27  m_FSM.SetInitialState(m_Detaching);
28  }
29 
30  override void OnEntry (BotEventBase e)
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  }
38 
39  override void OnExit (BotEventBase e)
40  {
41  m_Entity = null;
42 
43  super.OnExit(e);
44  }
45 
46  override void OnUpdate (float dt)
47  {
48  super.OnUpdate(dt);
49  }
50 };
51 
52 class BotTestAttachAndDropCycle_Detaching extends BotStateBase
53 {
55 
56  override void OnEntry (BotEventBase e)
57  {
58  super.OnEntry(e);
59  }
60 
61  override void OnAbort (BotEventBase e) { super.OnAbort(e); }
62 
63  override void OnExit (BotEventBase e)
64  {
65  super.OnExit(e);
66  }
67 
68  override void OnUpdate (float dt)
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)
80  {
81  m_Bot.ProcessEvent(new BotEventEntityDetached(m_Owner, m_Entity));
82  }
83  }
84  }
85  }
86 };
87 
88 class BotTestAttachAndDropCycle_Attaching extends BotStateBase
89 {
91 
92  override void OnEntry (BotEventBase e)
93  {
94  super.OnEntry(e);
95  }
96 
97  override void OnAbort (BotEventBase e) { super.OnAbort(e); }
98 
99  override void OnExit (BotEventBase e)
100  {
101  super.OnExit(e);
102  }
103 
104  override void OnUpdate (float dt)
105  {
106  if (m_Entity)
107  {
108  botDebugPrint("[bot] + " + m_Owner + " att item=" + m_Entity + " bot=" + m_Owner);
109 
110  if (m_Owner.GetInventory().CanAddAttachment(m_Entity))
111  {
112  m_Owner.PredictiveTakeEntityAsAttachment(m_Entity);
113 
115  if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
116  {
117  if (loc.GetType() == InventoryLocationType.ATTACHMENT)
118  {
119  m_Bot.ProcessEvent(new BotEventEntityAttached(m_Owner, m_Entity));
120  }
121  }
122  }
123  }
124  }
125 };
126 
BotEventEntityDetached
Definition: bot_testattachanddropcycle.c:3
OnAbort
override void OnAbort()
Definition: remotedetonator.c:300
OnExit
override void OnExit(HandEventBase e)
Definition: hand_states.c:28
Bot
Definition: bot.c:18
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
BotStateBase
represent weapon state base
Definition: bot_hunt.c:15
botDebugPrint
void botDebugPrint(string s)
Definition: bot.c:182
BotEventBase
represents event that triggers transition from state to state
Definition: botevents.c:4
BotTransition
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition: botfsm.c:7
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
m_Owner
enum ProcessDirectDamageFlags m_Owner
BotFSM
Bot Finite State Machine (Hierarchical)
BotEventEntityAttached
Definition: bot_testattachanddropcycle.c:1
EntityAI
Definition: building.c:5
m_Entity
EntityAI m_Entity
Definition: actiondebug.c:11
OnEntry
HandStateEquipped OnEntry
Definition: weaponchambering.c:208