Added GAF_SWITCH to GetAngle, inverting the function to get the caller's angle on the pointer instead.
This commit is contained in:
parent
09175a6a7a
commit
b121284fc0
3 changed files with 17 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue