Is there an equivalent of IsA() for structs?

I’m building my quest system with a base struct FQuestBase, and a bunch of subclasses of type struct FQuestWhatever : public FQuestBase. I process quests and check if they’re complete with a function that takes an FQuestBase as its argument, but I’d like to be able to tell exactly which subclass of FQuestBase I’m dealing with, like this:

FClueBase testQuest;
if (testQuest.IsA(FFetchQuest)){
	//do stuff

Obviously this doesn’t work, and the compiler tells me that FClueBase doesn’t have a member IsA, which is expected. Is there an alternative way to go about what I’m describing?

you shouldn’t need to know the type of quest in order to check if its complete. the status of a quest should be separate from its content. quest content can be stored in a separate datatable for each type of quest if you want, but quest status should be stored in the player’s inventory. all quests should use the same format for keeping track of the completion of a quest, and all you really need is a unique ID and a progress amount to know if a quest is complete, so storing the full text of the quest alongside that would just waste space in the player’s save file.

i recommend making a struct called stackedItem, which just has variables for “Pocket” (name), “ID” (name) and “Amount” (integer).

you can have an array of these StackedItems called QuestInventory, which you can use to populate a menu checklist. the highlighted Item in the menu can use its Pocket to choose the right datatable to read from, and use its ID to look up the quest title, descriptions, rewards, etc… then you only have to load all of that text data for the currently highlighted item.

the reason i use the Pocket variable to decide which datatable to use, is so i can keep slightly different item types in the same inventory array. for example, helmets and boots can both go in the ArmorInventory array, and show up on the same page in the inventory, but when you try to equip a helmet, it can check if the item belongs in the helmet pocket, to prevent the player from equipping boots on their head.

StackedItem is such a generic structure, you could use it to keep track of most collectibles/progress in the game. so if you want to keep track of how many Red Potions you collected, or how many dragons you killed, you just add an item to the HealingItems pocket, or the Enemies pocket. if the item ID already exists in the array, you just increment its amount, instead of adding a new entry.

Hmm okay, thank you for the feedback! The specific reason I was trying to identify struct by subclass was because my system allows the player to sort quests by category, so I’m trying to iterate through my master list of quests and extract any of a specific type. The alternative, which is just as easy to implement but a little inelegant, is to simply give each quest some EQuestType enum, and use that with my iterator instead of a direct reference to the class type. :slight_smile: