CharmicsMods Posted March 11, 2018 Share Posted March 11, 2018 Hello, I'm currently trying to make a papyrus script that will process items based on what type of items they are. I'm extending ObjectReference and I'm using OnItemAdded, so I have akBaseItem and akItemReference both available. I'm modifying akBaseItem. Here's what I have so far: if akBaseItem as Ammo elseif akBaseItem as Armor elseif akBaseItem as Book elseif akBaseItem as Ingredient elseif akBaseItem as Key elseif akBaseItem as MiscObject elseif akBaseItem as Soulgem elseif akBaseItem as Weapon ;unlisted elseif akBaseItem as Scroll elseif akBaseItem as Potion elseif akBaseItem as ;elseif akBaseItem as Outfit ;elseif akBaseItem as LeveledItem endif Outfit and LeveledItem's are technically items, but they are obviously not things the player can hold. I don't know if there is anything else I'm missing. Apparently food is potions. I'd also like to be able to tell things like dwemer struts apart from gems and light armor from heavy armor, but I don't know how i'd do that. Is there a list of these types of forms somewhere? Is there a way to get a little deeper and find armor weight and miscobject type etc?Sorry for the noob question, I'm a novice at papyrus. Thanks! Link to comment Share on other sites More sharing options...
cdcooley Posted March 11, 2018 Share Posted March 11, 2018 The core types a character can hold in inventory are Ammo, Weapon, Armor, Ingredient, Potion, Book, Scroll, MiscObject, and Light. Most Light objects can't be carried, but a few like the torch can. Soulgem and Key objects are all also of the MiscObject type, so for efficiency check against MiscObject and then if you have one you can check to see if it's a key or soulgem if you like. Once the item is classified as a particular type like armor you can use the more specific functions of that class to get some details. But your biggest problem is going to be that inventory items don't actually exist. They are just entries in a list and Papyrus has very little it can do with them except through their base type. MiscObject has almost no functions, so there's very little you can learn about misc objects in general. At least you can identify and separate out the keys and soulgems though. Link to comment Share on other sites More sharing options...
CharmicsMods Posted March 11, 2018 Author Share Posted March 11, 2018 Thanks for the info! For my purposes, modifying the base item is fine. It seems like this list of member functions on the form list is very incomplete. I find more functions for weapons and armor which extend from it here and here. On a side note, I also just found this list of papyrus functions, which seems much closer to comprehensive, but it has been flagged. On it I found this get type function, which looks like it might be useful, but provides no better functionality than I previously had. So I'll be able to separate armor and weapon types, but unfortunately it looks like there's no way to get miscobject type. I'm going to look into SkyUI to see if I can find anything on how they might have done it - though that mod is far more advanced than anything I'm doing. Thanks! Link to comment Share on other sites More sharing options...
CharmicsMods Posted March 11, 2018 Author Share Posted March 11, 2018 I unpacked and decompiled SkyUI but it all looks like general interface management (shocking, I know), nothing about what symbols to match up with what items, functionality why afaik doesn't exist in vanilla. I also looked at a few other mods and saw no indication of non-manual misc-type sorting. I'm trying to create a solution which is compatible with with modded items. Given people's load orders today, it would be pointless to make a mod that can only process vanilla items, which is why I don't want to edit misc object manually. However, relatively few modded items are miscobjects, and even fewer will be relevant to my mod, so perhaps I should just do it manually.If anyone has tips on sorting misc objects, would be appreciated. Link to comment Share on other sites More sharing options...
DavidJCobb Posted March 11, 2018 Share Posted March 11, 2018 I've got a copy of the SKSE source code on hand (and therefore, most of the engine-level stuff that the community has decoded). I can tell you that the only MiscObjects that are fundamentally different are apparatuses (an Oblivion leftover), keys, and soul gems. Technical explanation: First of all, every form in memory has a single value representing its base type (and these map roughly to the kind of data structure used for the form). SKSE Form.GetType just returns that value verbatim. It's about as "pure" as it gets. Second of all, while the SKSE devs didn't identify every data structure in the game, they did identify a lot of them, including pretty much all of the ones used for items. The internal class for misc items is called TESObjectMISC, and three other classes "inherit" from it: BGSApparatus, TESKey, and TESSoulGel. All other misc objects are just TESObjectMISC under the hood. They are distinguished only by the usual item data -- name, model, value, weight, and keywords. If "apparati, keys, soul gems, and other" isn't specific enough for you, then you'll want to check keywords in the Creation Kit and see if there are any useful ones that your script can check for (here's a function that might be better for looping). Link to comment Share on other sites More sharing options...
CharmicsMods Posted March 15, 2018 Author Share Posted March 15, 2018 Thanks! I've begun to work towards using keywords for filtering, and it's working better than expected. Link to comment Share on other sites More sharing options...
Recommended Posts