DayZ 1.24
Loading...
Searching...
No Matches
Bot_Hunt.c File Reference

Go to the source code of this file.

Classes

class  BotEventHuntedTargetInSight
 
class  BotEventHuntedTargetLost
 
class  BotStateBase
 represent weapon state base More...
 

Functions

Man BotSelectNearestTarget (EntityAI bot)
 

Function Documentation

◆ BotSelectNearestTarget()

Man BotSelectNearestTarget ( EntityAI bot)

Definition at line 191 of file Bot_Hunt.c.

192{
193 /*ref array<Man> players = new array<Man>;
194 g_Game.GetWorld().GetPlayerList( players );
195
196 bool minimal_distance_ok = true;
197
198 float min_dist = 1234567.0;
199 int min_index = -1;
200 for ( int i = 0; i < players.Count(); i++ )
201 {
202 float d = vector.Distance(players.Get(i).GetPosition(), bot.GetPosition());
203 if ( d < min_dist )
204 {
205 min_dist = d;
206 min_index = i;
207 }
208 }
209
210 if (min_index != -1)
211 return players.Get(min_index);
212
213 return null;*/
214 vector pos = bot.GetPosition();
215 //vector dir = player.GetDirection();
216
219 GetGame().GetObjectsAtPosition(pos, 100.0, objects, proxyCargos);
220
221 float min_dist = 1234567.0;
222 int min_index = -1;
223 int c = objects.Count();
224 for (int i = 0; i < c; i++)
225 {
226 Object o = objects[i];
227 if (o == bot)
228 continue;
229
230 float d = vector.Distance(o.GetPosition(), bot.GetPosition());
231 if (d < min_dist)
232 {
233 min_dist = d;
234 min_index = i;
235 }
236 }
237
238 if (min_index != -1)
239 {
240 botDebugPrint("[bot] + " + bot + " BotSelectNearestTarget idx=" + min_index + " dist=" + min_dist + " obj=" + o);
241 return Man.Cast(objects.Get(min_index));
242 }
243 return null;
244}
void botDebugPrint(string s)
Definition Bot.c:182
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()

References botDebugPrint(), vector::Distance(), and GetGame().

Referenced by BotStateBase::SelectTarget().