Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
bot_testattachanddropcycle.c
Go to the documentation of this file.
1class BotEventEntityAttached : BotEventBase { };
2
3class BotEventEntityDetached : BotEventBase { };
4
5class 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
52class 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
76 InventoryLocation loc = new InventoryLocation;
78 {
79 if (loc.GetType() == InventoryLocationType.GROUND)
80 {
81 m_Bot.ProcessEvent(new BotEventEntityDetached(m_Owner, m_Entity));
82 }
83 }
84 }
85 }
86};
87
88class 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
114 InventoryLocation loc = new InventoryLocation;
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
class LogManager EntityAI
void botDebugPrint(string s)
Definition bot.c:122
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition botfsm.c:7
Entity m_Entity
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
proto native GameInventory GetInventory()
proto native EntityAI CreateAttachment(string typeName)
Create Entity of specified type as attachment of entity.
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
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