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
parent 09175a6a7a
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;

View File

@ -41,7 +41,7 @@ ACTOR Actor native //: Thinker
native bool IsPointerEqual(int ptr_select1, int ptr_select2);
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT);
native float GetAngle(bool relative, int ptr = AAPTR_DEFAULT);
native float GetAngle(int flags, int ptr = AAPTR_DEFAULT);
native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
native int GetSpawnHealth();
native int GetGibHealth();

View File

@ -652,3 +652,9 @@ enum
BT_USER3 = 1<<23,
BT_USER4 = 1<<24,
};
// Flags for GetAngle
enum
{
GAF_RELATIVE = 1,
GAF_SWITCH = 1 << 1,
};