Xander9009 Posted July 17, 2014 Posted July 17, 2014 Is there a way to check if a player knows a specific enchantment? The only one I know of is the function to check if a player knows an ingredient's Nth effect. unfortunately, the thing i'm trying to do will only work if I can see if the player knows an enchantment. If I can't check, I'll have to go about it completely differently. I don't think there's a way, but it'd be fantastic for someone to prove me wrong.
IsharaMeradin Posted July 17, 2014 Posted July 17, 2014 PlayerKnows might be what you are looking for.
Xander9009 Posted July 17, 2014 Author Posted July 17, 2014 (edited) Thank you Ishara. It's been awhile since I modded, that's my excuse. I'm just so used to knowing the vanilla functions, and since I didn't remember that function (I've never used it for an enchantment that I recall), I assumed it didn't exist. Edited July 17, 2014 by Xander9009
Xander9009 Posted July 17, 2014 Author Posted July 17, 2014 Alright, I've got another issue that I can't remember how to fix (honestly, I don't even remember if I knew how to fix it. I'm trying to grab info about which item a player crafts. There's the event for exactly that, but unfortunately, the only way it appears to get information about the item instead of just waiting for a specific item to be crafted (like the blacksmith tutorial does) is to use the event StoryCraftItem(), but the wiki says it crashes the game. I was trying an alias-supported OnItemAdded() event, but it doesn't fire while the crafting menu is open. The only way I can think of that should definitely work is to index the player's entire inventory and then see what's changed. The problem with this is two-fold.It'll be way too slow. Since I'm trying to figure out which item was enchanted, it would require indexing the inventory before, then after, and for each enchantable item, check if its enchantment has changed.The way it's looking, the only way I'll be able to properly make this work (have Farengar and other Court Wizards enchant stuff for you) will be to find a way to do it that's more similar to how I made Adrianne temper stuff for me. That works well for tempering. It's just a gift menu, a few buttons, and a clever script to put them together. But for enchanting, the only real way to manage it is to use the enchanting menu. I've got everything working (for the most part) except that I can't figure out a way to pick out the new item and remove it from the player's inventory. Thoughts?
IsharaMeradin Posted July 17, 2014 Posted July 17, 2014 How do you know that OnItemAdded does not work while the menu is open? If you are relying on screen notifications, those won't show until you are out of the menu (if at all). Try using some Trace statements instead. Register for the menu with the SKSE functions, use the OnMenuOpen event and send a trace line to the log, send a trace line to the log when an item is added, send a trace line to the log in the OnMenuClose event. See what happens. I'd expect that OnItemAdded still works behind the scenes, the game is not paused when the enchanting menu is open.
Xander9009 Posted July 17, 2014 Author Posted July 17, 2014 I was relying on notifications. I'll test again, this time with dropping the item and see if that works. I was thinking it should have been working, but other notifications (coming from and OnActivate of the enchanting table) worked fine. I'm still getting back into the flow of things. I'll try testing more before posting in the future. I remember once upon a time, you and I were fairly equal. It seems I've lost a step while I was off modding MTG: DotP lol. Thanks, though. I'll see about that when I wake up (i'm heading to bed, now). I'll try dropping the item before going for the trace method, though. I need it removed from the inventory anyway.
Xander9009 Posted July 18, 2014 Author Posted July 18, 2014 Unfortunately, it doesn't seem to work.Scriptname ES_PlayerMonitorScript extends ReferenceAlias Event OnInit() Debug.Trace("ES_Initialized") RegisterForMenu("Crafting Menu") EndEvent Event OnMenuOpen(String MenuName) Debug.Trace("ES_Enchanting") EndEvent Event OnMenuClose(String MenuName) Debug.Trace("ES_Done") EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Debug.Trace("Item: " + akBaseItem.GetName() + " | Value: " + akBaseItem.GetGoldValue()) If GetOwningQuest().GetStage() == 11 Input.TapKey(15) While Game.GetPlayer().GetFurnitureReference() != None Utility.Wait(0.1) EndWhile ObjectReference Item = Game.GetPlayer().DropObject(akBaseItem, 1) Debug.Notification("Item: " + Item.GetName() + " | Value: " + Item.GetGoldValue()) EndIf EndEventHere's an excerpt from my log when I enchanted an item. Quote [07/18/2014 - 01:07:50PM] ES_Initialized...[07/18/2014 - 01:07:50PM] Item: Iron Helmet | Value: 60[07/18/2014 - 01:07:50PM] Item: Iron Boots | Value: 25[07/18/2014 - 01:07:50PM] Item: Iron Gauntlets | Value: 25[07/18/2014 - 01:07:50PM] Item: Iron Armor | Value: 125...[07/18/2014 - 01:08:33PM] ES_Enchanting[07/18/2014 - 01:08:47PM] ES_Done...[07/18/2014 - 01:09:03PM] Item: gold | Value: 1[07/18/2014 - 01:09:06PM] Item: Lesser Soul Gem | Value: 80[07/18/2014 - 01:09:16PM] ES_Enchanting[07/18/2014 - 01:09:57PM] ES_DoneIt never called the trace in the OnItemAdded event. The game tells me the item was added with the normal notification, but the event doesn't pick it up. It picks up other items added to my inventory, just not while the menu is open. For the record, I'm calling "coc whiterundragonsreach" from the main menu, so it's not a save-game issue or anything like that. I've also only got SkyUI and this mod loading (I don't even have the DLC active, though that's only because they spam the log). Any ideas?
IsharaMeradin Posted July 21, 2014 Posted July 21, 2014 No idea then. Perhaps the item does not actually change? Use the console to check inventory before hand and jot down the ID# of the object in question.Add an enchantment, then check the ID# to see if it changes. If it does not then it is the same reference of the item being affected without actually changing inventory. If that is the case then you'll have to grep the inventory before and then after, unfortunately.
Xander9009 Posted July 21, 2014 Author Posted July 21, 2014 Well, until I can figure out how to make it work properly, I've reworked it completely so it's done without using the enchanting dialogue at all. It's working now, just completely differently. Kryptopyr pointed out a way that might make it easier to index the proper things without having to index EVERYTHING. If I find anything that makes this easier, I'll post a solution (even though it'll only be a bad workaround, at best).
Recommended Posts