lofgren Posted February 23, 2017 Share Posted February 23, 2017 Cdcooley makes good points about taking the items from containers. Honestly I don't know where my head was at. Link to comment Share on other sites More sharing options...
NexusComa Posted February 24, 2017 Share Posted February 24, 2017 Comment removed. I suggest you read the terms of service, attacks on other members will not be tolerated. -Jim_UK Link to comment Share on other sites More sharing options...
NexusComa Posted February 24, 2017 Share Posted February 24, 2017 (edited) sure wish that went both ways Edited February 24, 2017 by NexusComa Link to comment Share on other sites More sharing options...
candlepin Posted February 24, 2017 Author Share Posted February 24, 2017 Thank you for your feedback, cdcooley. I have so much to learn... I don't really know where to start here. By an AddInventoryFilter, do you mean this: http://www.creationkit.com/fallout4/index.php?title=AddInventoryEventFilter_-_ScriptObject? I know that's from the Fallout 4 CK site, but I'm having trouble finding AddInventoryFilter for Skyrim. What is the syntax for this, and how would this be implemented in an OnInit() Event? Sorry for the simplistic questions, but I'm a bit lost and most of the tutorials I'm looking at are either simplistic "Hello world" type help or stuff that is still Greek to me. You're suggesting not to use an OnItemAdded Event because it would tax the system too much, which makes sense. But how would this work in the context of what I want to do with this mod? If the script is only fired OnInit (when the script first launches) and ignores OnItemAdded events, then the only things changed would be in the player's inventory and any new items picked up would still be the vanilla version. Or are you saying that the OnInit event should replace all vanilla versions of the items I'd like to exchange (everywhere, inventory + world)? Sorry, I have so many questions.... I think I'll just start with those. Inventory events are extremely taxing on the system. You really should use an OnInit() event to apply an AddInventoryFilter for the items you will be replacing. If the player uses Take All on a container you can end up with hundreds of events firing at the same time which can temporarily overload the system. The filters help solve that problem by blocking most of the events. This is also the case where using a PlayerRef property is the best option because you want to avoid even the small amount of time it takes to do a GetReference call. (I also like to avoid the PlayerRef property but sometimes a space-for-speed trade-off is required and this is one of those times.) I don't think keeping the original items as invisible tokens will actually work. You would be forcing all such items in the world to have a weight of zero and it would also mean the player couldn't see or take items of that type out of containers. Personally I would just implement the basic version of the mod, alter the conditions on those farmer's dialogue lines to see your new versions of things, and fix any quests that break when and if you find out about them. I suspect there are so few quests that involve these items that it be easier to patch individual quests than create some generic system to avoid problems. Link to comment Share on other sites More sharing options...
lofgren Posted February 24, 2017 Share Posted February 24, 2017 CdCooley is referring to this (it's the same basic concept as the Fallout 4 version): http://www.creationkit.com/index.php?title=AddInventoryEventFilter_-_ObjectReference All of the previous script examples included an event filter in their oninit block. I had simply been leaving that out for the sake of simplicity since it had already been covered by other posters (and because I avoid OnInit blocks as a general rule, so I would add the event filter through a quest stage instead). By adding an InventoryEventFilter to your alias, the OnItemAdded event will only fire if the item that was added is included in the formlist that you are filtering for. That will reduce your use of Papyrus resources by a massive proportion. I rather disagree with cdcooley that using PlayerREF as a property is valuable for saving time in this case. This is not a script that is likely to be time-sensitive because it will probably rarely fire in combat when every frame matters. In fact it will most likely fire most often while the game is in menu mode, when resources are at their least taxed. But again, we're quibbling about the most minuscule of differences here – totally imperceptible to a human user and unlikely to cause an issue except when your PC is under the greatest of stress (usually in the middle of combat while running multiple combat-related mods). Link to comment Share on other sites More sharing options...
cdcooley Posted February 25, 2017 Share Posted February 25, 2017 I rather disagree with cdcooley that using PlayerREF as a property is valuable for saving time in this case. This is not a script that is likely to be time-sensitive because it will probably rarely fire in combat when every frame matters. In fact it will most likely fire most often while the game is in menu mode, when resources are at their least taxed. But again, we're quibbling about the most minuscule of differences here – totally imperceptible to a human user and unlikely to cause an issue except when your PC is under the greatest of stress (usually in the middle of combat while running multiple combat-related mods).With inventory filters in place there shouldn't be too much of a difference, but it's not the behavior of that single event that matters. It's when the player does a Take All from some container that matters. In that case all of the events process in game mode just after you close the container. With proper inventory filters no one container should hold very many of those items that are going to trigger an event so that should eliminate any problems. But it's still safer in general to assume that speed matters if you're doing filtering that monitors multiple items entering the player's inventory. Link to comment Share on other sites More sharing options...
lofgren Posted February 25, 2017 Share Posted February 25, 2017 Meh even without filters we're talking about 0.5 seconds vs. 1.0 seconds. Maybe 1.5 seconds if there are thousands of items, and the GetReference()/PlayerREF portion of the script isn't going to represent the bulk of that time. I'm not saying you're wrong, just that the benefits are negligible. Link to comment Share on other sites More sharing options...
candlepin Posted February 25, 2017 Author Share Posted February 25, 2017 (edited) I've read that to add a script referencing the player, you should do it by adding a new quest, adding a new Reference Alias (referencing the player, and attaching the script. Am I on the right track here? Helpful tips and other suggestions would be much appreciated. Hope everyone is having a good weekend! Edited February 25, 2017 by candlepin Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 25, 2017 Share Posted February 25, 2017 I've read that to add a script referencing the player, you should do it by adding a new quest, adding a new Reference Alias (referencing the player, and attaching the script. Am I on the right track here? Helpful tips and other suggestions would be much appreciated. Hope everyone is having a good weekend!Yes, that is the correct approach. Link to comment Share on other sites More sharing options...
candlepin Posted February 26, 2017 Author Share Posted February 26, 2017 (edited) In an attempt to attach a script via a new quest, I wrote a few basic scripts including the one below. I seem to have a bit of an issue with adding items to the player inventory. I been successful at linking a script to the player, and debug.notification works, but I can't seem to get PlayerRef.AddItem() to work. For example, with the following script: Scriptname CP_MI_test extends ReferenceAlias ;to test attachment of script to player ObjectReference Property PlayerRef Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) int NewNum = aiItemCount * 3 PlayerRef.AddItem(akBaseItem, NewNum, true) Debug.Notification("Is this working?") Debug.Notification(NewNum) EndEvent My output for this script are the correct notifications, but I don't get the additional items added to the inventory; i.e. if I pick up a carrot, I only get one carrot added, not 4. Any ideas of what I'm missing? Edited February 26, 2017 by candlepin Link to comment Share on other sites More sharing options...
Recommended Posts