diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 49c30be5a..147a4c192 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -152,6 +152,67 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state) return !!result; } +//========================================================================== +// +// CheckClass +// +// NON-ACTION function to check a pointer's class. +// +//========================================================================== + +DEFINE_ACTION_FUNCTION(AActor, CheckClass) +{ + if (numret > 0) + { + assert(ret != NULL); + PARAM_PROLOGUE; + PARAM_OBJECT (self, AActor); + PARAM_CLASS (checktype, AActor); + PARAM_INT_OPT (pick_pointer) { pick_pointer = AAPTR_DEFAULT; } + PARAM_BOOL_OPT (match_superclass) { match_superclass = false; } + + self = COPY_AAPTR(self, pick_pointer); + if (self == NULL) + { + ret->SetInt(false); + } + else if (match_superclass) + { + ret->SetInt(self->IsKindOf(checktype)); + } + else + { + ret->SetInt(self->GetClass() == checktype); + } + return 1; + } + return 0; +} + +//========================================================================== +// +// IsPointerEqual +// +// NON-ACTION function to check if two pointers are equal. +// +//========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, IsPointerEqual) +{ + if (numret > 0) + { + assert(ret != NULL); + PARAM_PROLOGUE; + PARAM_OBJECT (self, AActor); + PARAM_INT (ptr_select1); + PARAM_INT (ptr_select2); + + ret->SetInt(COPY_AAPTR(self, ptr_select1) == COPY_AAPTR(self, ptr_select2)); + return 1; + } + return 0; +} + //========================================================================== // // A_RearrangePointers diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index d4910df91..d20a7d0ed 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -66,6 +66,9 @@ ACTOR Actor native //: Thinker native fixed_t meleerange; native fixed_t speed; + native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); + native bool IsPointerEqual(int ptr_select1, int ptr_select2); + // Meh, MBF redundant functions. Only for DeHackEd support. action native A_Turn(float angle = 0); action native A_LineEffect(int boomspecial = 0, int tag = 0);