DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Bot_TestSpawnAndOpenCan.c
См. документацию.
1#ifdef ROBOCLIENT
2class BotEventEntityInHands : BotEventBase { };
3
4class BotSpawnEntityInHands extends BotStateBase
5{
6 string m_Type;
7
8 void BotSpawnEntityInHands (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
9 {
10 if (new_type == string.Empty)
11 m_Type = "TunaCan";
12 else
13 m_Type = new_type;
14 }
15
16 override void OnEntry (BotEventBase e)
17 {
18 super.OnEntry(e);
19
20 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
21 {
22 m_Owner.GetHumanInventory().CreateInHands(m_Type);
23 }
24 }
25
26 override void OnExit (BotEventBase e) { super.OnExit(e); }
27
28 override void OnUpdate (float dt)
29 {
30 super.OnUpdate(dt);
31
32 EntityAI inHands = m_Owner.GetEntityInHands();
33 if (inHands)
34 {
35 botDebugPrint("[bot] + " + m_Owner + " hand item=" + inHands + " bot=" + m_Owner);
36 m_Bot.ProcessEvent(new BotEventEntityInHands(m_Owner, inHands));
37 }
38 }
39};
40
41class BotEventEntityInHandsOpened : BotEventBase { };
42
43class BotOpenEntityInHands extends BotStateBase
44{
46
47 override void OnEntry (BotEventBase e)
48 {
49 super.OnEntry(e);
50
51 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
52 {
53 BotEventEntityInHands ev_ih = BotEventEntityInHands.Cast(e);
54 if (ev_ih)
55 {
56 m_Entity = ev_ih.m_Entity;
58 if (b)
59 {
60 botDebugPrint("[bot] + " + m_Owner + " will open edible item=" + b + " bot=" + m_Owner);
61 b.Open();
62 }
63 }
64 }
65 }
66
67 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
68
69 override void OnExit (BotEventBase e)
70 {
71 super.OnExit(e);
72 }
73
74 override void OnUpdate (float dt)
75 {
76 super.OnUpdate(dt);
77
79 botDebugSpam("[bot] + " + m_Owner + " wait for opened item inHands=" + inHands + " bot=" + m_Owner);
80 if (inHands)
81 {
82 string t_str = inHands.GetType();
83 //string t_str = t.ToString();
84 if (t_str.IndexOf("_Opened") != -1)
85 {
86 botDebugPrint("[bot] + " + m_Owner + " opened item=" + inHands + " bot=" + m_Owner);
87 m_Bot.ProcessEvent(new BotEventEntityInHandsOpened(m_Owner, inHands));
88 }
89 }
90 }
91};
92
93
94class Bot_TestSpawnOpen extends BotStateBase
95{
96 string m_Type;
97 ref BotSpawnEntityInHands m_Spawning;
98 ref BotOpenEntityInHands m_Opening;
99
100 void Bot_TestSpawnOpen (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
101 {
102 m_Type = new_type;
103
104 // setup nested state machine
105 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
106
107 m_Spawning = new BotSpawnEntityInHands(m_Bot, this);
108 m_Opening = new BotOpenEntityInHands(m_Bot, this);
109
110 // events
111 BotEventBase __EntInH__ = new BotEventEntityInHands;
112
113 // transitions
114 m_FSM.AddTransition(new BotTransition( m_Spawning, __EntInH__, m_Opening));
115 //m_FSM.AddTransition(new BotTransition( m_Opening, __EntAtt__, m_Eating));
116 //m_FSM.AddTransition(new BotTransition( m_Eating, __EntAtt__, m_Eating));
117
118 m_FSM.SetInitialState(m_Spawning);
119 }
120
121 override void OnEntry (BotEventBase e) { super.OnEntry(e); }
122 override void OnExit (BotEventBase e) { super.OnExit(e); }
123 override void OnUpdate (float dt) { super.OnUpdate(dt); }
124};
125
126
127class BotEventHandsEmpty : BotEventBase { };
128
129class BotWaitForEmptyHands extends BotStateBase
130{
131 override void OnEntry (BotEventBase e) { super.OnEntry(e); }
132 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
133 override void OnExit (BotEventBase e) { super.OnExit(e); }
134
135 override void OnUpdate (float dt)
136 {
137 super.OnUpdate(dt);
138
140 botDebugSpam("[bot] + " + m_Owner + " waiting for empty hands, inHands=" + inHands + " bot=" + m_Owner);
141 if (!inHands)
142 {
143 botDebugPrint("[bot] + " + m_Owner + " hand slot empty. bot=" + m_Owner);
144 m_Bot.ProcessEvent(new BotEventHandsEmpty(m_Owner, inHands));
145 }
146 }
147};
148
149class BotWaitForChangeInHands extends BotStateBase
150{
151 /*override void OnExit (BotEventBase e)
152 {
153 super.OnExit(e);
154 m_Bot.ProcessEvent(new BotEventEndOK(m_Owner));
155 }*/
156};
157
158
159class BotDropEntityInHands extends BotWaitForChangeInHands
160{
162
163 override void OnEntry (BotEventBase e)
164 {
165 super.OnEntry(e);
166
167
169 if (inHands)
170 {
171 botDebugPrint("[bot] + " + m_Owner + " dropping item=" + inHands + " bot=" + m_Owner);
172 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
173 m_Owner.PredictiveDropEntity(inHands);
174 //m_Owner.LocalDropEntity(inHands);
175 }
176 }
177
178 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
179 override void OnExit (BotEventBase e) { super.OnExit(e); }
180 override void OnUpdate (float dt) { super.OnUpdate(dt); }
181};
182
183class BotEatEntityInHands extends BotWaitForChangeInHands
184{
186
187 override void OnEntry (BotEventBase e)
188 {
189 super.OnEntry(e);
190
192 if (inHands)
193 {
194 botDebugPrint("[bot] + " + m_Owner + " eating item=" + inHands + " bot=" + m_Owner);
195 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
196 {
197#ifdef BOT
198 ActionManagerBase mgr = m_Owner.GetActionManager();
199 ActionManagerClient cli_mgr = ActionManagerClient.Cast(mgr);
200 if (cli_mgr)
201 {
202 ActionTarget target;
203 target = new ActionTarget(inHands, null, -1, vector.Zero, -1);
204 cli_mgr.PerformAction(AT_EAT, target, inHands);
205 }
206#endif
207 }
208 }
209 }
210
211 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
212 override void OnExit (BotEventBase e) { super.OnExit(e); }
213 override void OnUpdate (float dt) { super.OnUpdate(dt); }
214};
215
216
217
218class BotDestroyEntityInHands extends BotWaitForChangeInHands
219{
221
222 override void OnEntry (BotEventBase e)
223 {
224 super.OnEntry(e);
225
227 if (inHands)
228 {
229 botDebugPrint("[bot] + " + m_Owner + " deleting item=" + inHands + " bot=" + m_Owner);
230 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
231 inHands.Delete();
232 }
233 }
234
235 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
236 override void OnExit (BotEventBase e) { super.OnExit(e); }
237 override void OnUpdate (float dt) { super.OnUpdate(dt); }
238};
239
240
241class Bot_TestSpawnOpenDrop extends Bot_TestSpawnOpen
242{
243 ref BotDropEntityInHands m_Dropping;
244
245 void Bot_TestSpawnOpenDrop (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
246 {
247 m_Dropping = new BotDropEntityInHands(m_Bot, this);
248
249 // events
250 BotEventBase __EntOpn__ = new BotEventEntityInHandsOpened;
251 BotEventBase __HndChg__ = new BotEventOnItemInHandsChanged;
252
253 // transitions
254 m_FSM.AddTransition(new BotTransition( m_Opening, __EntOpn__, m_Dropping));
255 m_FSM.AddTransition(new BotTransition( m_Dropping, __HndChg__, NULL));
256 }
257
258 override void OnEntry (BotEventBase e) { super.OnEntry(e); }
259 override void OnExit (BotEventBase e) { super.OnExit(e); }
260 override void OnUpdate (float dt) { super.OnUpdate(dt); }
261};
262
263class Bot_TestSpawnOpenDestroy extends Bot_TestSpawnOpen
264{
265 ref BotDestroyEntityInHands m_Destroying;
266
267 void Bot_TestSpawnOpenDestroy (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
268 {
269 m_Destroying = new BotDestroyEntityInHands(m_Bot, this);
270
271 // events
272 BotEventBase __EntOpn__ = new BotEventEntityInHandsOpened;
273 BotEventBase __HndChg__ = new BotEventOnItemInHandsChanged;
274
275 // transitions
276 m_FSM.AddTransition(new BotTransition( m_Opening, __EntOpn__, m_Destroying));
277 m_FSM.AddTransition(new BotTransition( m_Destroying, __HndChg__, NULL));
278 }
279
280 override void OnEntry (BotEventBase e) { super.OnEntry(e); }
281 override void OnExit (BotEventBase e) { super.OnExit(e); }
282 override void OnUpdate (float dt) { super.OnUpdate(dt); }
283};
284
285class Bot_TestSpawnOpenEat extends Bot_TestSpawnOpen
286{
287 ref BotEatEntityInHands m_Eating;
288
289 void Bot_TestSpawnOpenEat (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
290 {
291 m_Eating = new BotEatEntityInHands(m_Bot, this);
292
293 // events
294 BotEventBase __EntOpn__ = new BotEventEntityInHandsOpened;
295 BotEventBase __HndChg__ = new BotEventOnItemInHandsChanged;
296
297 // transitions
298 m_FSM.AddTransition(new BotTransition( m_Opening, __EntOpn__, m_Eating));
299 m_FSM.AddTransition(new BotTransition( m_Eating, __HndChg__, NULL));
300 }
301
302 override void OnEntry (BotEventBase e)
303 {
304 super.OnEntry(e);
305 }
306
307 override void OnExit (BotEventBase e)
308 {
309 super.OnExit(e);
310 }
311
312 override void OnUpdate (float dt)
313 {
314 super.OnUpdate(dt);
315 }
316};
317#endif
class LogManager EntityAI
eBleedingSourceType m_Type
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
Entity m_Entity
Определения CachedEquipmentStorageBase.c:16
void Edible_Base()
Определения Edible_Base.c:1137
HandStateEquipped OnEntry
Определения WeaponChambering.c:292
Empty
Определения Hand_States.c:14
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
Определения RemoteDetonator.c:300
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
Определения WeaponChambering.c:352
proto native EntityAI GetEntityInHands()
Returns the current entity in hands.
override void OnEntry(HandEventBase e)
Определения Hand_States.c:34
override void OnExit(WeaponEventBase e)
Определения WeaponChambering.c:439
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1084
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
proto native void OnUpdate()
Определения 3_Game/DayZ/tools/tools.c:349