Added GAF_SWITCH to GetAngle, inverting the function to get the caller's angle on the pointer instead.

This commit is contained in:
MajorCooke 2016-06-24 13:19:49 -05:00 committed by Christoph Oelckers
commit b121284fc0
3 changed files with 17 additions and 4 deletions

View file

@ -329,13 +329,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance)
// NON-ACTION function to get the angle in degrees (normalized to -180..180)
//
//==========================================================================
enum GAFlags
{
GAF_RELATIVE = 1,
GAF_SWITCH = 1 << 1,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(relative);
PARAM_INT(flags);
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
AActor *target = COPY_AAPTR(self, ptr);
@ -346,9 +352,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
}
else
{
DVector3 diff = self->Vec3To(target);
DVector3 diff = (flags & GAF_SWITCH) ? target->Vec3To(self) : self->Vec3To(target);
DAngle angto = diff.Angle();
if (relative) angto = deltaangle(self->Angles.Yaw, angto);
DAngle yaw = (flags & GAF_SWITCH) ? target->Angles.Yaw : self->Angles.Yaw;
if (flags & GAF_RELATIVE) angto = deltaangle(yaw, angto);
ret->SetFloat(angto.Degrees);
}
return 1;