Skip to content

Commit 4e7de98

Browse files
committed
Fix crows AI fly target position
1 parent 88941ac commit 4e7de98

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/xrGame/ai/crow/ai_crow.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ void CAI_Crow::renderable_Render ()
314314
inherited::renderable_Render ();
315315
o_workload_rframe = Device.dwFrame ;
316316
}
317+
318+
collide::rq_result GetPickResult(Fvector pos, Fvector dir, float range, CObject* ignore);
317319
void CAI_Crow::shedule_Update (u32 DT)
318320
{
319321
float fDT = float(DT)/1000.F;
@@ -340,7 +342,23 @@ void CAI_Crow::shedule_Update (u32 DT)
340342
// At random times, change the direction (goal) of the plane
341343
if(fGoalChangeTime<=0) {
342344
fGoalChangeTime += fGoalChangeDelta+fGoalChangeDelta*Random.randF(-0.5f,0.5f);
343-
Fvector vP = Actor()->Position();
345+
346+
Fvector vP = Actor()->Position();
347+
348+
Fvector dest_dir;
349+
dest_dir.sub(Actor()->Position(), Position());
350+
float range = dest_dir.magnitude();
351+
dest_dir.normalize();
352+
353+
collide::rq_result RQ = GetPickResult(Position(), dest_dir, range, this);
354+
if(RQ.element >= 0)
355+
vP = Fvector(Position()).mad(dest_dir, RQ.range);
356+
357+
collide::rq_result RQ2 = GetPickResult(Position(), Direction(), range, this);
358+
if(RQ2.element >= 0)
359+
vP = Fvector(Position()).mad(Direction(), RQ2.range);
360+
361+
344362
vP.y += +fMinHeight;
345363
vGoalDir.x = vP.x+vVarGoal.x*Random.randF(-0.5f,0.5f);
346364
vGoalDir.y = vP.y+vVarGoal.y*Random.randF(-0.5f,0.5f);

0 commit comments

Comments
 (0)