Decorate function CheckClass

Moderator: GZDoom Developers

Post Reply
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Decorate function CheckClass

Post by FDARI »

bool CheckClass(string classname, int ptr_select = aaptr_default, bool match_superclass = false)

Checks the class of the selected pointer.

Returns false if the specified class does not exist.
Returns false if the selected actor (default = caller) does not exist.
Returns true if the selected actor's class is the one specified in the first parameter.
Returns true if match_superclass is true and the selected actor's class is a descendant of the one specified in the first parameter.
Returns false otherwise.

Expression usable in A_JumpIf, as well as in other (less obviously useful) places.
If it is somehow preferable, A_JumpIf[Not]Class(...) could be submitted instead, but I generally prefer to use A_JumpIf for jumping and let an expression determine the outcome.

Programmer notes:

The global decorate functions now appear to have a standard implementation. I was not entirely comfortable with the parameter list, but my function does accept 1-3 parameters where the first has to be a string (name) (or class, which I don't think can actually happen), and the last two have to be numeric. A stronger general way to build the parameter list might be worth implementing.

CheckClass isn't very "global" in its behaviour. It will almost always be making use of the AActor * self value that is passed to it for evaluation. However, it does function if self == NULL; it will only find actors for static pointers (AAPTR_PLAYER1 and such) and returns false if no actor is found. I'm not aware of a more appropriate way to implement this expression.

I'd make an ACS counterpart. I might. Just not today. I'd like feedback on this. From potential users and from people who have an opinion on how this should be done (I hope there are not far too many of you).

I have only run the simplest of testcases:
Spoiler:
Attachments
CheckClass_Decorate.patch.txt
(2.69 KiB) Downloaded 43 times
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Decorate function CheckClass

Post by NeuralStunner »

This would be extremely useful. I can already see value for replacing messy inventory-based flag items, especially when morphing is involved.
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Decorate function CheckClass

Post by Major Cooke »

Working on importing it to a pull now.
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Decorate function CheckClass

Post by Major Cooke »

Post Reply

Return to “Closed Feature Suggestions [GZDoom]”