mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
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)
|
// 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)
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
|
||||||
{
|
{
|
||||||
if (numret > 0)
|
if (numret > 0)
|
||||||
{
|
{
|
||||||
assert(ret != NULL);
|
assert(ret != NULL);
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
PARAM_BOOL(relative);
|
PARAM_INT(flags);
|
||||||
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
|
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
|
||||||
|
|
||||||
AActor *target = COPY_AAPTR(self, ptr);
|
AActor *target = COPY_AAPTR(self, ptr);
|
||||||
|
@ -346,9 +352,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DVector3 diff = self->Vec3To(target);
|
DVector3 diff = (flags & GAF_SWITCH) ? target->Vec3To(self) : self->Vec3To(target);
|
||||||
DAngle angto = diff.Angle();
|
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);
|
ret->SetFloat(angto.Degrees);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -41,7 +41,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 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 float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
|
||||||
native int GetSpawnHealth();
|
native int GetSpawnHealth();
|
||||||
native int GetGibHealth();
|
native int GetGibHealth();
|
||||||
|
|
|
@ -652,3 +652,9 @@ enum
|
||||||
BT_USER3 = 1<<23,
|
BT_USER3 = 1<<23,
|
||||||
BT_USER4 = 1<<24,
|
BT_USER4 = 1<<24,
|
||||||
};
|
};
|
||||||
|
// Flags for GetAngle
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GAF_RELATIVE = 1,
|
||||||
|
GAF_SWITCH = 1 << 1,
|
||||||
|
};
|
Loading…
Reference in a new issue