Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
bot_testitemmovebackandforth.c
Go to the documentation of this file.
1
class
BotTestItemMoveBackAndForth
extends
BotStateBase
2
{
3
EntityAI
m_Entity
;
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
;
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
61
class
BotTestItemMoveBackAndForth_MoveFromSlotToSlot
extends
BotStateBase
62
{
63
EntityAI
m_Entity
;
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
;
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
EntityAI
class LogManager EntityAI
botDebugPrint
void botDebugPrint(string s)
Definition
bot.c:122
BotTransition
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Definition
botfsm.c:7
m_Entity
Entity m_Entity
Definition
cachedequipmentstoragebase.c:14
BotEventBase
represents event that triggers transition from state to state
Definition
botevents.c:5
BotEventEntityAttached
Definition
bot_testattachanddropcycle.c:1
BotFSM
Bot Finite State Machine (Hierarchical).
Bot
Definition
bot.c:19
BotStateBase
represent weapon state base
Definition
bot_hunt.c:16
BotStateBase::BotTestItemMoveBackAndForth
void BotTestItemMoveBackAndForth(Bot bot=NULL, BotStateBase parent=NULL)
Definition
bot_testitemmovebackandforth.c:6
BotStateBase::m_FSM
ref BotFSM m_FSM
hierarchical parent state of this state (or null)
Definition
botstates.c:15
BotStateBase::m_WaitingForSlot
int m_WaitingForSlot
Definition
bot_testitemmovebackandforth.c:64
BotStateBase::OnAbort
override void OnAbort(BotEventBase e)
Definition
bot_testitemmovebackandforth.c:73
BotStateBase::BotStateBase
void BotStateBase(Bot bot=NULL, BotStateBase parent=NULL)
nested state machine (or null)
Definition
botstates.c:17
BotStateBase::m_mskSlot
int m_mskSlot
Definition
bot_testitemmovebackandforth.c:66
BotStateBase::OnExit
override void OnExit(BotEventBase e)
Definition
bot_testitemmovebackandforth.c:48
BotStateBase::m_Owner
PlayerBase m_Owner
Definition
botstates.c:12
BotStateBase::m_Move
ref BotTestItemMoveBackAndForth_MoveFromSlotToSlot m_Move
Definition
bot_testitemmovebackandforth.c:4
BotStateBase::OnEntry
override void OnEntry(BotEventBase e)
Definition
bot_testitemmovebackandforth.c:22
BotStateBase::m_hgSlot
int m_hgSlot
Definition
bot_testitemmovebackandforth.c:65
BotStateBase::OnUpdate
override void OnUpdate(float dt)
Definition
bot_testitemmovebackandforth.c:55
BotStateBase::GetNextSlot
int GetNextSlot(int curr)
Definition
bot_testitemmovebackandforth.c:80
BotStateBase::m_Entity
EntityAI m_Entity
Definition
bot_testattachanddropcycle.c:7
BotStateBase::m_Bot
Bot m_Bot
man that this state belongs to
Definition
botstates.c:13
EntityAI
Definition
inventoryitem.c:2
GameInventory
script counterpart to engine's class Inventory
Definition
inventory.c:81
GameInventory::FindAttachment
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)...
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::GetSlot
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation::GetType
proto native int GetType()
returns type of InventoryLocation
InventorySlots
provides access to slot configuration
Definition
inventoryslots.c:6
InventorySlots::GetSlotIdFromString
static proto native int GetSlotIdFromString(string slot_name)
InventorySlots::INVALID
const int INVALID
Invalid slot (-1).
Definition
inventoryslots.c:17
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition
inventorylocation.c:4
Games
Dayz
scripts
4_world
systems
bot
bot_testitemmovebackandforth.c
Generated by
1.17.0