GetDistance Non-Action (Double version)
- Added GetDistance(bool checkz, ptr = aaptr_target). - Returns the distance of an actor. Must be target, master or tracer.
This commit is contained in:
parent
646f7a1f90
commit
e04fe06226
2 changed files with 36 additions and 0 deletions
|
|
@ -250,6 +250,41 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, CountInv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// GetDistance
|
||||
//
|
||||
// NON-ACTION function to get the distance in double.
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance)
|
||||
{
|
||||
if (numret > 0)
|
||||
{
|
||||
assert(ret != NULL);
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_OBJECT(self, AActor);
|
||||
PARAM_BOOL(checkz);
|
||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
|
||||
|
||||
AActor *target = COPY_AAPTR(self, ptr);
|
||||
|
||||
if (!target || target == self)
|
||||
{
|
||||
ret->SetFloat(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
fixedvec3 diff = self->Vec3To(target);
|
||||
diff.z += (target->height - self->height) / 2;
|
||||
const double lengthsquared = TVector3<double>(diff.x, diff.y, diff.z).LengthSquared();
|
||||
ret->SetFloat(lengthsquared);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A_RearrangePointers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue