Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
bot_testitemmovebackandforth.c
Go to the documentation of this file.
1class 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
60class 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
EntityAI m_Entity
Definition actiondebug.c:11
void botDebugPrint(string s)
Definition bot.c:122
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition botfsm.c:7
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
InventoryLocation.
provides access to slot configuration
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
HandStateEquipped OnEntry
InventoryLocationType
types of Inventory Location
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit