DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Bot_TestSpawnDeadBury.c
См. документацию.
1#ifdef BOT
2class BotEventEntitySpawned : BotEventBase { };
3
4class BotSpawnDead extends BotStateBase
5{
6 string m_Type;
7
8 void BotSpawnDead (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "")
9 {
10 if (new_type == string.Empty)
11 m_Type = "ZmbM_HermitSkinny_Beige";
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 EntityAI Z = EntityAI.Cast(GetGame().CreateObject(m_Type, m_Owner.GetPosition()));
23 Z.SetHealth( "", "", 0 );
24 Error("TODO");
25 //m_Bot.PostEvent(new BotEventEntitySpawned(m_Owner, Z));
26 }
27 }
28};
29
30class Bot_TestSpawnDeadSelectBury extends BotStateBase
31{
32 string m_Type;
33 ref BotSpawnDead m_SpawnDead;
34 ref BotSpawnEntityInHands m_SpawnShovel;
35 ref BotSelectZombieTarget m_Selecting;
36 ref BotPerformAction m_Burying;
37
38 void Bot_TestSpawnDeadSelectBury (Bot bot = NULL, BotStateBase parent = NULL, string new_type = "ZmbM_HermitSkinny_Beige")
39 {
40 m_Type = new_type;
41
42 // setup nested state machine
43 m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
44
45 m_SpawnDead = new BotSpawnDead(m_Bot, this, m_Type);
46 m_SpawnShovel = new BotSpawnEntityInHands(m_Bot, this, "Shovel");
47 m_Selecting = new BotSelectZombieTarget(m_Bot, this);
48 m_Burying = new BotPerformAction(m_Bot, this, AT_BURY_BODY);
49
50 // events
51 BotEventBase __SpwnZ__ = new BotEventEntitySpawned;
52 BotEventBase __EntInH__ = new BotEventEntityInHands;
53 BotEventBase __Select__ = new BotEventSelectedTarget;
54
55 // transitions
56 m_FSM.AddTransition(new BotTransition( m_SpawnDead, NULL, m_SpawnShovel));
57 m_FSM.AddTransition(new BotTransition( m_SpawnShovel, __EntInH__, m_Selecting));
58 m_FSM.AddTransition(new BotTransition( m_Selecting, __Select__, m_Burying));
59 m_FSM.AddTransition(new BotTransition( m_Burying, NULL, NULL));
60
61 m_FSM.SetInitialState(m_SpawnDead);
62 }
63
64 override void OnEntry (BotEventBase e) { super.OnEntry(e); }
65 override void OnExit (BotEventBase e) { super.OnExit(e); }
66 override void OnUpdate (float dt) { super.OnUpdate(dt); }
67};
68
69
70class BotEventSelectedTarget : BotEventBase { };
71
72class BotSelectZombieTarget extends BotStateBase
73{
74 ZombieMaleBase m_Target;
75 float m_dtAccumulator = 0.0;
76
77 void SelectTarget ()
78 {
79 //m_Target = NearestTargetSelector<ZombieMaleBase>.Find(GetPlayerOwner(), NULL);
80 botDebugPrint("[bot] + " + m_Owner + " hunt SelectTarget target=" + m_Target);
81 }
82
83 override void OnEntry (BotEventBase e)
84 {
85 super.OnEntry(e);
86 m_dtAccumulator = 0.0;
88 }
89
90 override void OnExit (BotEventBase e)
91 {
92 m_dtAccumulator = 0.0;
93 m_Target = null;
94
95 super.OnExit(e);
96 }
97
98 override void OnUpdate (float dt)
99 {
100 super.OnUpdate(dt);
101
102 m_dtAccumulator += dt;
103
104 if (m_Target == null)
105 {
106 if (m_dtAccumulator > 2.0)
107 {
108 botDebugPrint("[bot] + " + m_Owner + " searching...");
109 SelectTarget();
110 if (m_Target)
111 {
112 Error("TODO");
113 //m_Bot.PostEvent(new BotEventSelectedTarget(m_Owner, m_Target));
114 }
115
116 m_dtAccumulator = 0.0;
117 }
118 }
119 else
120 {
121 Error("TODO");
122 //m_Bot.PostEvent(new BotEventSelectedTarget(m_Owner, m_Target));
123 }
124 }
125};
126
127class BotPerformAction extends BotStateBase
128{
130 int m_ActionID;
131
132 void BotPerformAction (Bot bot = NULL, BotStateBase parent = NULL, int action = AT_EAT)
133 {
134 m_ActionID = action;
135 }
136
137 override void OnEntry (BotEventBase e)
138 {
139 super.OnEntry(e);
140
141 if (e.m_Entity)
142 {
143 botDebugPrint("[bot] + " + m_Owner + " performing action on item=" + e.m_Entity);
144
145 if (m_Owner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
146 {
147#ifdef BOT
148 ActionManagerClient cli_mgr = ActionManagerClient.Cast(m_Owner.GetActionManager());
149 if (cli_mgr)
150 cli_mgr.PerformAction(m_ActionID, new ActionTarget(e.m_Entity, null, -1, vector.Zero, -1), e.m_Entity);
151#endif
152 }
153 }
154 }
155
156 override void OnAbort (BotEventBase e) { super.OnAbort(e); }
157 override void OnExit (BotEventBase e) { super.OnExit(e); }
158 override void OnUpdate (float dt) { super.OnUpdate(dt); }
159};
160
161
162
163/*class BotHunt extends BotStateBase
164{
165 float m_dtAccumulator = 0.0;
166
167 override void OnEntry (BotEventBase e)
168 {
169 super.OnEntry(e);
170 m_dtAccumulator = 0.0;
171 }
172
173 override void OnExit (BotEventBase e)
174 {
175 m_dtAccumulator = 0.0;
176 super.OnExit(e);
177 }
178
179 override void OnUpdate (float dt)
180 {
181 super.OnUpdate(dt);
182
183 m_dtAccumulator += dt;
184
185 float rescanTime = 3.0;
186 if (m_dtAccumulator >= rescanTime)
187 if (m_weapon.CanProcessWeaponEvents())
188 m_Bot.ProcessEvent(new WeaponEventReloadTimeout(p));
189 }
190};
191*/
192
193
194#endif
class LogManager EntityAI
eBleedingSourceType m_Type
Определения BleedingSource.c:25
ref ActionTarget m_Target
Определения ActionBase.c:18
EntityAI m_Entity
Определения ActionDebug.c:11
class ActionTargets ActionTarget
void botDebugPrint(string s)
Определения Bot.c:122
FSMTransition< BotStateBase, BotEventBase, BotActionBase, BotGuardBase > BotTransition
Определения BotFSM.c:7
HandStateEquipped OnEntry
Определения WeaponChambering.c:291
Empty
Определения Hand_States.c:14
enum ProcessDirectDamageFlags m_Owner
override void OnAbort()
Определения RemoteDetonator.c:300
class WeaponFireWithEject extends WeaponFire m_dtAccumulator
EntityAI m_Entity
Определения BotEvents.c:7
represents event that triggers transition from state to state
Определения BotEvents.c:5
void BotSpawnEntityInHands(Bot bot=NULL, BotStateBase parent=NULL, string new_type="")
Определения Bot_TestSpawnAndOpenCan.c:7
override void OnExit(BotEventBase e)
Определения Bot_Hunt.c:58
void SelectTarget()
Определения Bot_Hunt.c:42
represent weapon state base
Определения Bot_Hunt.c:16
override void OnEntry(HandEventBase e)
Определения Hand_States.c:34
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1068
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
proto native void OnUpdate()
Определения tools.c:349