Dayz Explorer 1.29.162510
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 GameInventory ownerInventory = m_Owner.GetInventory();
27 EntityAI hgear = ownerInventory.FindAttachment( InventorySlots.GetSlotIdFromString("Headgear") );
28 EntityAI mask = ownerInventory.FindAttachment( InventorySlots.GetSlotIdFromString("Mask") );
29
30 if (hgear)
31 m_Entity = hgear;
32 if (mask)
33 m_Entity = mask;
34
35
36 InventoryLocation loc = new InventoryLocation;
38 {
39 m_Move.m_WaitingForSlot = loc.GetSlot();
40 }
41 else
42 Error("EE");
43 m_Move.m_Entity = m_Entity;
44
45 super.OnEntry(e);
46 }
47
48 override void OnExit (BotEventBase e)
49 {
50 m_Entity = null;
51
52 super.OnExit(e);
53 }
54
55 override void OnUpdate (float dt)
56 {
57 super.OnUpdate(dt);
58 }
59};
60
61class BotTestItemMoveBackAndForth_MoveFromSlotToSlot extends BotStateBase
62{
64 int m_WaitingForSlot = InventorySlots.INVALID;
65 int m_hgSlot = InventorySlots.GetSlotIdFromString("Headgear");
66 int m_mskSlot = InventorySlots.GetSlotIdFromString("Mask");
67
68 override void OnEntry (BotEventBase e)
69 {
70 super.OnEntry(e);
71 }
72
73 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
74
75 override void OnExit (BotEventBase e)
76 {
77 super.OnExit(e);
78 }
79
80 int GetNextSlot (int curr)
81 {
82 if (curr == m_hgSlot)
83 return m_mskSlot;
84 if (curr == m_mskSlot)
85 return m_hgSlot;
86 Error("EE2");
87 return InventorySlots.INVALID;
88 }
89
90 override void OnUpdate (float dt)
91 {
92 if (m_Entity)
93 {
94 botDebugPrint("[bot] + " + m_Owner + " move item=" + m_Entity);
95
96 InventoryLocation loc = new InventoryLocation;
98 {
99 if (loc.GetType() == InventoryLocationType.ATTACHMENT)
100 {
101 if (loc.GetSlot() == m_WaitingForSlot)
102 {
103 int nextSlot = GetNextSlot(m_WaitingForSlot);
104 botDebugPrint("[bot] + " + m_Owner + " will switch slot=" + nextSlot + " for item=" + m_Entity);
105
106 m_WaitingForSlot = nextSlot;
107
108 m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, nextSlot);
109 //m_Bot.ProcessEvent(new BotEventEntityDet(m_Owner, m_Entity));
110 }
111 }
112 }
113 }
114 }
115};
116
class LogManager EntityAI
void botDebugPrint(string s)
Definition bot.c:122
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition botfsm.c:7
Entity m_Entity
represent weapon state base
Definition bot_hunt.c:16
proto native GameInventory GetInventory()
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)...
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
void OnUpdate()
Definition tools.c:349
HandStateEquipped OnEntry
InventoryLocationType
types of Inventory Location
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit