Permalink
Browse files

- deprecated a few functions that depend on AAPTR_* to be useful.

  • Loading branch information...
coelckers committed Dec 5, 2018
1 parent b8c4a50 commit de5ab0b4b69032316f24a4e47d58310ea994a551
@@ -98,7 +98,7 @@ FRandom pr_cajump("CustomJump");
extern TArray<VMValue> actionParams; // this can use the same storage as CallAction
static bool CallStateChain (AActor *self, AActor *actor, FState *state)
static int CallStateChain (AActor *self, AActor *actor, FState *state)
{
INTBOOL result = false;
int counter = 0;
@@ -235,234 +235,14 @@ static bool CallStateChain (AActor *self, AActor *actor, FState *state)
return !!result;
}
DEFINE_ACTION_FUNCTION(ACustomInventory, CallStateChain)
DEFINE_ACTION_FUNCTION_NATIVE(ACustomInventory, CallStateChain, CallStateChain)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(affectee, AActor);
PARAM_POINTER(state, FState);
ACTION_RETURN_BOOL(CallStateChain(self, affectee, state));
}
//==========================================================================
//
// CheckClass
//
// NON-ACTION function to check a pointer's class.
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, CheckClass)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS (checktype, AActor);
PARAM_INT (pick_pointer);
PARAM_BOOL (match_superclass);
self = COPY_AAPTR(self, pick_pointer);
if (self == nullptr || checktype == nullptr)
{
ret->SetInt(false);
}
else if (match_superclass)
{
ret->SetInt(self->IsKindOf(checktype));
}
else
{
ret->SetInt(self->GetClass() == checktype);
}
return 1;
}
return 0;
}
//==========================================================================
//
// CheckClass
//
// NON-ACTION function to calculate missile damage for the given actor
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetMissileDamage)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(mask);
PARAM_INT(add);
PARAM_INT(pick_pointer);
self = COPY_AAPTR(self, pick_pointer);
if (self == NULL)
{
ret->SetInt(0);
}
else
{
ret->SetInt(self->GetMissileDamage(mask, add));
}
return 1;
}
return 0;
}
//==========================================================================
//
// GetDistance
//
// NON-ACTION function to get the distance in double.
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetDistance)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(checkz);
PARAM_INT(ptr);
AActor *target = COPY_AAPTR(self, ptr);
if (!target || target == self)
{
ret->SetFloat(0);
}
else
{
DVector3 diff = self->Vec3To(target);
if (checkz)
diff.Z += (target->Height - self->Height) / 2;
else
diff.Z = 0.;
ret->SetFloat(diff.Length());
}
return 1;
}
return 0;
}
//==========================================================================
//
// GetAngle
//
// 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(AActor, GetAngle)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(flags);
PARAM_INT(ptr)
AActor *target = COPY_AAPTR(self, ptr);
if (!target || target == self)
{
ret->SetFloat(0);
}
else
{
DVector3 diff = (flags & GAF_SWITCH) ? target->Vec3To(self) : self->Vec3To(target);
DAngle angto = diff.Angle();
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;
}
return 0;
}
//==========================================================================
//
// GetSpawnHealth
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetSpawnHealth)
{
if (numret > 0)
{
PARAM_SELF_PROLOGUE(AActor);
ret->SetInt(self->SpawnHealth());
return 1;
}
return 0;
}
//==========================================================================
//
// GetSpriteAngle
//
// NON-ACTION function returns the sprite angle of a pointer.
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetSpriteAngle)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(ptr);
AActor *target = COPY_AAPTR(self, ptr);
if (target == nullptr)
{
ret->SetFloat(0.0);
}
else
{
const double ang = target->SpriteAngle.Degrees;
ret->SetFloat(ang);
}
return 1;
}
return 0;
}
//==========================================================================
//
// GetSpriteRotation
//
// NON-ACTION function returns the sprite rotation of a pointer.
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetSpriteRotation)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(ptr);
AActor *target = COPY_AAPTR(self, ptr);
if (target == nullptr)
{
ret->SetFloat(0.0);
}
else
{
const double ang = target->SpriteRotation.Degrees;
ret->SetFloat(ang);
}
return 1;
}
return 0;
}
//==========================================================================
//
// GetZAt
@@ -267,7 +267,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SetZ, SetZ)
return 0;
}
static void SetDamage(AActor *self, double dmg)
static void SetDamage(AActor *self, int dmg)
{
self->SetDamage(dmg);
}
@@ -698,6 +698,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, SpawnHealth, SpawnHealth)
ACTION_RETURN_INT(self->SpawnHealth());
}
// Why does this exist twice?
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpawnHealth, SpawnHealth)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_INT(self->SpawnHealth());
}
void Revive(AActor *self)
{
self->Revive();
@@ -1061,7 +1070,7 @@ static AActor *ZS_LineAttack(AActor *self, double angle, double distance, double
return P_LineAttack(self, angle, distance, pitch, damage, ENamedName(damageType), puffType, flags, victim, actualdamage, offsetz, offsetforward, offsetside);
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LineAttac, ZS_LineAttack)
DEFINE_ACTION_FUNCTION_NATIVE(AActor, LineAttack, ZS_LineAttack)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_FLOAT(angle);
@@ -1321,8 +1330,21 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, GiveSecret, GiveSecret)
return 0;
}
static int ZS_GetMissileDamage(AActor *self, int mask, int add, int pick_pointer)
{
self = COPY_AAPTR(self, pick_pointer);
return self ? self->GetMissileDamage(mask, add) : 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetMissileDamage, ZS_GetMissileDamage)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(mask);
PARAM_INT(add);
PARAM_INT(pick_pointer);
ACTION_RETURN_INT(ZS_GetMissileDamage(self, mask, add, pick_pointer));
}
//=====================================================================================
//
// Inventory exports
@@ -771,7 +771,6 @@ class Actor : Thinker native
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
protected native void DestroyAllInventory(); // This is not supposed to be called by user code!
native clearscope Inventory FindInventory(class<Inventory> itemtype, bool subclass = false) const;
native Inventory GiveInventoryType(class<Inventory> itemtype);
@@ -782,17 +781,13 @@ class Actor : Thinker native
native bool Warp(Actor dest, double xofs = 0, double yofs = 0, double zofs = 0, double angle = 0, int flags = 0, double heightoffset = 0, double radiusoffset = 0, double pitch = 0);
// DECORATE compatible functions
native double GetDistance(bool checkz, int ptr = AAPTR_TARGET) const;
native double GetAngle(int flags, int ptr = AAPTR_TARGET) const;
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
native clearscope int GetSpawnHealth() const;
native double GetCrouchFactor(int ptr = AAPTR_PLAYER1);
native double GetCVar(string cvar);
native double GetCVarString(string cvar);
native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT);
native int CountProximity(class<Actor> classname, double distance, int flags = 0, int ptr = AAPTR_DEFAULT);
native double GetSpriteAngle(int ptr = AAPTR_DEFAULT);
native double GetSpriteRotation(int ptr = AAPTR_DEFAULT);
native int GetMissileDamage(int mask, int add, int ptr = AAPTR_DEFAULT);
action native int OverlayID();
action native double OverlayX(int layer = 0);
Oops, something went wrong.

0 comments on commit de5ab0b

Please sign in to comment.