- added GetAngle(bool relative, int target) DECORATE function.

This commit is contained in:
Christoph Oelckers 2016-04-27 11:52:52 +02:00
parent 61b165ccc4
commit f5afa30ee6
2 changed files with 35 additions and 0 deletions

View file

@ -320,6 +320,40 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance)
return 0; return 0;
} }
//==========================================================================
//
// GetAngle
//
// NON-ACTION function to get the angle in degrees (normalized to -180..180)
//
//==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(relative);
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
AActor *target = COPY_AAPTR(self, ptr);
if (!target || target == self)
{
ret->SetFloat(0);
}
else
{
DVector3 diff = self->Vec3To(target);
DAngle angto = diff.Angle();
if (relative) angto = deltaangle(self->Angles.Yaw, angto);
ret->SetFloat(angto.Degrees);
}
return 1;
}
return 0;
}
//========================================================================== //==========================================================================
// //
// GetSpawnHealth // GetSpawnHealth

View file

@ -42,6 +42,7 @@ ACTOR Actor native //: Thinker
native bool IsPointerEqual(int ptr_select1, int ptr_select2); native bool IsPointerEqual(int ptr_select1, int ptr_select2);
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT); native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT);
native float GetAngle(bool relative, int ptr = AAPTR_DEFAULT);
native int GetSpawnHealth(); native int GetSpawnHealth();
native int GetGibHealth(); native int GetGibHealth();