[C++] IsKindOf with ZScript actors [solved]

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

[C++] IsKindOf with ZScript actors [solved]

Post by Nash »

I'm trying to remove some old C++ changes out of the engine and my question is if it's possible to do IsKindOf with actors that aren't defined in C++ side, for example

Code: Select all

if (thing && thing->IsKindOf(RUNTIME_CLASS(ALADBodyPartBase)) && thing->tracer == vp.ViewActor)
I'd like to move LADBodyPartBase out of C++ and into mod-side ZScript.
Last edited by Nash on Wed Dec 12, 2018 6:23 am, edited 1 time in total.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [C++] IsKindOf with ZScript actors

Post by _mental_ »

Code: Select all

FName testClass("TestClass");

if (target->IsKindOf(testClass))
{
	Printf("It's TestClass");
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [C++] IsKindOf with ZScript actors

Post by Graf Zahl »

You can also to (target->IsKindOf(NAME_blah)) which saves the class type lookup entirely if you have a name constant.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [C++] IsKindOf with ZScript actors [solved]

Post by Nash »

Perfect, thanks!
Post Reply

Return to “Scripting”