diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 441ba4899..1b1c7b2cf 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -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; diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 901d7a553..cb6ff4d93 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -41,7 +41,7 @@ ACTOR Actor native //: Thinker native bool IsPointerEqual(int ptr_select1, int ptr_select2); native int CountInv(class 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(); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 7b75b481d..46e810a7f 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -652,3 +652,9 @@ enum BT_USER3 = 1<<23, BT_USER4 = 1<<24, }; +// Flags for GetAngle +enum +{ + GAF_RELATIVE = 1, + GAF_SWITCH = 1 << 1, +}; \ No newline at end of file