DayZ 1.24
Loading...
Searching...
No Matches
Bot_TestItemMoveBackAndForth.c
Go to the documentation of this file.
1class BotTestItemMoveBackAndForth extends BotStateBase
2{
5
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
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)
31 if (mask)
32 m_Entity = mask;
33
34
36 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
37 m_Move.m_WaitingForSlot = loc.GetSlot();
38 else
39 Error("EE");
40 m_Move.m_Entity = m_Entity;
41
42 super.OnEntry(e);
43 }
44
45 override void OnExit(BotEventBase e)
46 {
47 m_Entity = null;
48
49 super.OnExit(e);
50 }
51
52 override void OnUpdate(float dt)
53 {
54 super.OnUpdate(dt);
55 }
56};
57
59{
61 int m_WaitingForSlot = InventorySlots.INVALID;
62 int m_hgSlot = InventorySlots.GetSlotIdFromString("Headgear");
63 int m_mskSlot = InventorySlots.GetSlotIdFromString("Mask");
64
65 override void OnEntry(BotEventBase e)
66 {
67 super.OnEntry(e);
68 }
69
70 override void OnAbort(BotEventBase e) { super.OnAbort(e); }
71
72 override void OnExit(BotEventBase e)
73 {
74 super.OnExit(e);
75 }
76
78 {
79 if (curr == m_hgSlot)
80 return m_mskSlot;
81 if (curr == m_mskSlot)
82 return m_hgSlot;
83 Error("EE2");
85 }
86
87 override void OnUpdate(float dt)
88 {
89 if (m_Entity)
90 {
91 botDebugPrint("[bot] + " + m_Owner + " move item=" + m_Entity);
92
94 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
95 {
96 if (loc.GetType() == InventoryLocationType.ATTACHMENT)
97 {
98 if (loc.GetSlot() == m_WaitingForSlot)
99 {
100 int nextSlot = GetNextSlot(m_WaitingForSlot);
101 botDebugPrint("[bot] + " + m_Owner + " will switch slot=" + nextSlot + " for item=" + m_Entity);
102
103 m_WaitingForSlot = nextSlot;
104
105 m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, nextSlot);
106 //m_Bot.ProcessEvent(new BotEventEntityDet(m_Owner, m_Entity));
107 }
108 }
109 }
110 }
111 }
112};
113
EntityAI m_Entity
Definition ActionDebug.c:11
void botDebugPrint(string s)
Definition Bot.c:182
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition BotFSM.c:7
InventoryLocationType
types of Inventory Location
enum ProcessDirectDamageFlags m_Owner
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
ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move
override void OnUpdate(float dt)
void BotTestItemMoveBackAndForth(Bot bot=NULL, BotStateBase parent=NULL)
override void OnEntry(BotEventBase e)
override void OnAbort(BotEventBase e)
override void OnExit(BotEventBase e)
InventoryLocation.
provides access to slot configuration
const int INVALID
Invalid slot (-1)
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90