Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
37 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
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{
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");
88 }
89
90 override void OnUpdate (float dt)
91 {
92 if (m_Entity)
93 {
94 botDebugPrint("[bot] + " + m_Owner + " move item=" + m_Entity);
95
97 if (m_Entity.GetInventory().GetCurrentInventoryLocation(loc))
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
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
void BotTestItemMoveBackAndForth(Bot bot=NULL, BotStateBase parent=NULL)
ref BotFSM m_FSM
hierarchical parent state of this state (or null)
Definition botstates.c:15
override void OnAbort(BotEventBase e)
void BotStateBase(Bot bot=NULL, BotStateBase parent=NULL)
nested state machine (or null)
Definition botstates.c:17
override void OnExit(BotEventBase e)
PlayerBase m_Owner
Definition botstates.c:12
ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move
override void OnEntry(BotEventBase e)
override void OnUpdate(float dt)
Bot m_Bot
man that this state belongs to
Definition botstates.c:13
script counterpart to engine's class Inventory
Definition inventory.c:81
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)...
InventoryLocation.
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetType()
returns type of InventoryLocation
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
const int INVALID
Invalid slot (-1).
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
InventoryLocationType
types of Inventory Location