Zorkaz Posted Sunday at 11:28 AM Share Posted Sunday at 11:28 AM I have a script like this: Function RemoveMisc() Actor PlayerRef = Game.GetPlayer() Int iWaponCount = PlayerRef.GetItemCount(ObjectTypeWeapon) EndFunction I want to remove all misc items. The issue is that I don't find a keyword for misc items. Any ideas? Link to comment Share on other sites More sharing options...
dizietemblesssma Posted Sunday at 01:10 PM Share Posted Sunday at 01:10 PM I'm wondering if these might help: https://ck.uesp.net/wiki/GetType_-_Form https://ck.uesp.net/wiki/GetIsFormType I am assuming that the list in the first link would be the one to use in the second, and that kMisc = 32 from that list is in fact a misc item:) diziet edit: except that's Skyrim and this is the F4 forum, both tabs next to each other in my browser:) Arrrgh! 1 Link to comment Share on other sites More sharing options...
dizietemblesssma Posted Sunday at 05:13 PM Share Posted Sunday at 05:13 PM Would checking to see if casting to MiscObject succeeds be useful? diziet edit: Garden Of Eden papyrus extender has this function: ; # returns the FormType of this form; like "ACHR", "FURN", "STAT", "NPC_" String Function GetFormTypeAsString(Form akForm) native global Link to comment Share on other sites More sharing options...
DieFeM Posted Sunday at 05:45 PM Share Posted Sunday at 05:45 PM If you don't find any other solution you can pass a formlist with all existing components to removecomponents with icount to -1 1 Link to comment Share on other sites More sharing options...
LarannKiar Posted yesterday at 09:13 AM Share Posted yesterday at 09:13 AM I haven't tested this code but something like this should work in vanilla: Container Property TempContainerBase Auto Const Function RemoveAllMiscItems(ObjectReference theRef) If !theRef Return None EndIf ; create a temporary container ObjectReference tempContainerRef = theRef.PlaceAtMe(TempContainerBase) If !tempContainerRef Return None EndIf ; transfer all items from theRef to the temp container theRef.RemoveAllItems(tempContainerRef) If tempContainerRef.GetItemCount() == 0 Return None EndIf Int iMaxRunCount = 1000 Int Index = 0 ; drop and check each object reference of the items While Index < iMaxRunCount && Index < tempContainerRef.GetItemCount() ObjectReference DroppedRef = tempContainerRef.DropFirstObject() ; presumably, tempContainerRef is now empty If !DroppedRef Index = iMaxRunCount Else Form ItemBase = DroppedRef.GetBaseObject() If ItemBase ; add the items which are not Misc Items back to the inventory of theRef If !(ItemBase as MiscObject) theRef.AddItem(DroppedRef) ; otherwise, remove DroppedRef.Delete() EndIf EndIf EndIf Index = Index + 1 EndWhile ; optional, move everything back to theRef's inventory that happens to be in the temp container, just in case tempContainerRef.RemoveAllItems(theRef) ; delete the temp container tempContainerRef.Delete() EndFunction Link to comment Share on other sites More sharing options...
peacefulhomecare Posted yesterday at 09:21 AM Share Posted yesterday at 09:21 AM 21 hours ago, Zorkaz said: I have a script like this: Function RemoveMisc() Actor PlayerRef = Game.GetPlayer() Int iWaponCount = PlayerRef.GetItemCount(ObjectTypeWeapon) EndFunction I want to remove all misc items. The issue is that I don't find a keyword for misc items. Any ideas? There's no specific keyword for misc items, but you can loop through the player's inventory and check item types. Try using FormList or filtering by exclusion (i.e., not weapons, armor, etc.). Another option is checking for specific EditorIDs if you have a known list. Link to comment Share on other sites More sharing options...
Recommended Posts