Skip to content

Commit 0392ea1

Browse files
St4lker0k765ForserX
authored andcommitted
Add crows flying to corpses from B.O.R.S.C.H.T
by @redpython
1 parent 1383d0b commit 0392ea1

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/xrGame/ai/crow/ai_crow.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,31 @@ void CAI_Crow::shedule_Update (u32 DT)
356356
if(fGoalChangeTime<=0) {
357357
fGoalChangeTime += fGoalChangeDelta+fGoalChangeDelta*Random.randF(-0.5f,0.5f);
358358

359-
Fvector vP = Actor()->Position();
359+
Level().ObjectSpace.GetNearest(nearbyObjects, Position(), 300.0f, NULL);
360+
for (CObject* obj : nearbyObjects)
361+
{
362+
if (CEntityAlive* entity = smart_cast<CEntityAlive*>(obj); entity && !entity->g_Alive())
363+
{
364+
deadNPCs.push_back(entity);
365+
}
366+
}
367+
368+
Fvector vP;
369+
if (!deadNPCs.empty())
370+
{
371+
CEntityAlive* targetNPC = deadNPCs[Random.randI(0, deadNPCs.size())];
372+
vP = targetNPC->Position();
373+
//Msg("Flying to dead NPC at [%f, %f, %f]", vP.x, vP.y, vP.z);
374+
}
375+
else
376+
{
377+
vP = Actor()->Position();
378+
float distanceToActor = Position().distance_to(vP);
379+
if (distanceToActor > 500.0f)
380+
{
381+
fGoalChangeTime = 30.0f;
382+
}
383+
}
360384

361385
Fvector dest_dir;
362386
dest_dir.sub(Actor()->Position(), Position());

src/xrGame/ai/crow/ai_crow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class CAI_Crow final : public CEntity
100100

101101
void UpdateWorkload (float DT);
102102

103+
xr_vector<CObject*> nearbyObjects;
104+
xr_vector<CEntityAlive*> deadNPCs;
105+
103106
public:
104107
u32 o_workload_frame ;
105108
u32 o_workload_rframe ;

0 commit comments

Comments
 (0)