fixed cone and added Utils_CalcAim

This commit is contained in:
krystalgamer 2024-05-15 19:30:43 +02:00
parent fcfa46d2b2
commit 8749a1bdfa
3 changed files with 61 additions and 6 deletions

View File

@ -590,11 +590,11 @@ int CBaddy::CheckSightCone(int a2, int a3, int a4, int a5, CBody *a6)
int v13; int v13;
if (a6 == globalSuper) if (a6 == globalSuper)
{ {
this->DistanceToPlayer(2); v13 = this->DistanceToPlayer(2);
} }
else else
{ {
Utils_CrapXZDist(this->mPos, a6->mPos); v13 = Utils_CrapXZDist(this->mPos, a6->mPos);
} }
if (v13 < a5) if (v13 < a5)

View File

@ -163,6 +163,61 @@ int Utils_LineOfSight(CVector*, CVector*, CVector*, int)
return 0x15052024; return 0x15052024;
} }
// @TODO int catan(int a1)
void Utils_CalcAim(CSVector*, CVector*, CVector*) {
{} return (atan((double)a1 / 4096.0) * 651.0006103515625);
}
// @Ok
int Utils_CalcAim(CSVector* a1, CVector* a2, CVector* a3)
{
int x,y,z;
x = (a3->vx - a2->vx) >> 12;
y = (a3->vy - a2->vy) >> 12;
z = (a3->vz - a2->vz) >> 12;
if (z)
{
if (z > 0)
{
a1->vy = catan(-((x << 12) / z));
}
else
{
a1->vy = catan((x << 12) / z);
}
}
else
{
if (x > 0)
{
a1->vy = -1024;
}
else
{
a1->vy = 1024;
}
}
int v7 = M3dMaths_SquareRoot0(x*x + z*z);
if (v7)
{
if (y > 0)
{
a1->vx = catan((y<<12) / v7);
}
else
{
a1->vx = -catan(-4096 * y / v7);
}
}
else
{
a1->vx = y > 0 ? 1024 : -1024;
}
a1->vx &= 0xFFF;
a1->vy &= 0xFFF;
a1->vz = 0;
return v7;
}

View File

@ -17,6 +17,6 @@ EXPORT int Rnd(int);
EXPORT CBody* Utils_CheckObjectCollision(CVector*, CVector*, CBody*, CBody*); EXPORT CBody* Utils_CheckObjectCollision(CVector*, CVector*, CBody*, CBody*);
EXPORT int Utils_GetGroundHeight(CVector*, int, int, CBody**); EXPORT int Utils_GetGroundHeight(CVector*, int, int, CBody**);
EXPORT int Utils_LineOfSight(CVector*, CVector*, CVector*, int); EXPORT int Utils_LineOfSight(CVector*, CVector*, CVector*, int);
EXPORT void Utils_CalcAim(CSVector*, CVector*, CVector*); EXPORT int Utils_CalcAim(CSVector*, CVector*, CVector*);
#endif #endif