Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bot_testitemmovebackandforth.c
Go to the documentation of this file.
1 class BotTestItemMoveBackAndForth extends BotStateBase
2 {
4  ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move;
5 
6  void BotTestItemMoveBackAndForth (Bot bot = NULL, BotStateBase parent = NULL)
7  {
8  // setup nested state machine
9  m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
10 
11  m_Move = new BotTestItemMoveBackAndForth_MoveFromSlotToSlot(m_Bot, this);
12 
13  // events
14  BotEventBase __EntAtt__ = new BotEventEntityAttached;
15 
16  // transitions
17  m_FSM.AddTransition(new BotTransition( m_Move, __EntAtt__, m_Move));
18 
19  m_FSM.SetInitialState(m_Move);
20  }
21 
22  override void OnEntry (BotEventBase e)
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)
30  m_Entity = hgear;
31  if (mask)
32  m_Entity = mask;
33 
34 
36  if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
37  {
38  m_Move.m_WaitingForSlot = loc.GetSlot();
39  }
40  else
41  Error("EE");
42  m_Move.m_Entity = m_Entity;
43 
44  super.OnEntry(e);
45  }
46 
47  override void OnExit (BotEventBase e)
48  {
49  m_Entity = null;
50 
51  super.OnExit(e);
52  }
53 
54  override void OnUpdate (float dt)
55  {
56  super.OnUpdate(dt);
57  }
58 };
59 
60 class BotTestItemMoveBackAndForth_MoveFromSlotToSlot extends BotStateBase
61 {
63  int m_WaitingForSlot = InventorySlots.INVALID;
64  int m_hgSlot = InventorySlots.GetSlotIdFromString("Headgear");
65  int m_mskSlot = InventorySlots.GetSlotIdFromString("Mask");
66 
67  override void OnEntry (BotEventBase e)
68  {
69  super.OnEntry(e);
70  }
71 
72  override void OnAbort (BotEventBase e) { super.OnAbort(e); }
73 
74  override void OnExit (BotEventBase e)
75  {
76  super.OnExit(e);
77  }
78 
79  int GetNextSlot (int curr)
80  {
81  if (curr == m_hgSlot)
82  return m_mskSlot;
83  if (curr == m_mskSlot)
84  return m_hgSlot;
85  Error("EE2");
86  return InventorySlots.INVALID;
87  }
88 
89  override void OnUpdate (float dt)
90  {
91  if (m_Entity)
92  {
93  botDebugPrint("[bot] + " + m_Owner + " move item=" + m_Entity);
94 
96  if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
97  {
98  if (loc.GetType() == InventoryLocationType.ATTACHMENT)
99  {
100  if (loc.GetSlot() == m_WaitingForSlot)
101  {
102  int nextSlot = GetNextSlot(m_WaitingForSlot);
103  botDebugPrint("[bot] + " + m_Owner + " will switch slot=" + nextSlot + " for item=" + m_Entity);
104 
105  m_WaitingForSlot = nextSlot;
106 
107  m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, nextSlot);
108  //m_Bot.ProcessEvent(new BotEventEntityDet(m_Owner, m_Entity));
109  }
110  }
111  }
112  }
113  }
114 };
115 
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
OnAbort
override void OnAbort()
Definition: remotedetonator.c:300
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
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