SameOldBard Posted April 21 Share Posted April 21 (edited) Hello, Is there a way to have a custom script per item in a RefCollectionAlias? I know I can have one for the collection itself and that it gets events from its members, but I would like to set a Script for the items themselves, so they can control themselves. That is, while using objects already spawned. I don't want to create my own objects. Example: I have a RefCollectionAlias called Weapons which has a WeaponsRefCollectionScript. And then a script called WeaponSomethingScript which extends ObjectReference. So far I found no way of doing it. Thanks, OldBard Edited April 21 by SameOldBard Link to comment Share on other sites More sharing options...
SameOldBard Posted April 21 Author Share Posted April 21 I think I found 2 possible solutions to this: 1. To use the AttachPapyrusScript method. Which seems intrusive and dangerous to me. Save game wise, am I correct? 2.To use a Magic Effect. Is there a third more straightforward way of doing it? OldBard. Link to comment Share on other sites More sharing options...
LarannKiar Posted April 24 Share Posted April 24 (edited) On 4/21/2024 at 2:07 AM, SameOldBard said: I think I found 2 possible solutions to this: 1. To use the AttachPapyrusScript method. Which seems intrusive and dangerous to me. Save game wise, am I correct? 2.To use a Magic Effect. Is there a third more straightforward way of doing it? OldBard. None that I know of. Why do you need one script for each reference by the way? Processing speed or timers? As far as I remember, AttachPapyrusScript doesn't set const properties to the variables defined in the editor which makes it unusable for many vanilla scripts as one cannot "fill" the const property later. How the VM clears the Papyrus object if it was attached with AttachPapyrusScript I don't know.. I personally wouldn't use it without extensive testing (even though it doesn't seem dangerous). The best tool to see certain data stored in saves is Fallrim Tools. If you'd like to examine the effects of AttachPapyrusScript, you can call it on a reference, create a save, open it with Fallrim Tools then locate the reference, (keep Fallrim Tools open), reopen the game, then call MarkForDelete for example to remove the reference. Verify it's removed with "Prid RefID" (console posts an error if no ref caould be found with the given ID). Create another save, then compare the saves in Fallrim Tools. Alternatively, you can request the VM to attach a script normally (e.g. by filling it to a script variable) then compare the script objects in the saves. Edited April 24 by LarannKiar Link to comment Share on other sites More sharing options...
SameOldBard Posted April 25 Author Share Posted April 25 7 hours ago, LarannKiar said: None that I know of. Why do you need one script for each reference by the way? Processing speed or timers? As far as I remember, AttachPapyrusScript doesn't set const properties to the variables defined in the editor which makes it unusable for many vanilla scripts as one cannot "fill" the const property later. How the VM clears the Papyrus object if it was attached with AttachPapyrusScript I don't know.. I personally wouldn't use it without extensive testing (even though it doesn't seem dangerous). The best tool to see certain data stored in saves is Fallrim Tools. If you'd like to examine the effects of AttachPapyrusScript, you can call it on a reference, create a save, open it with Fallrim Tools then locate the reference, (keep Fallrim Tools open), reopen the game, then call MarkForDelete for example to remove the reference. Verify it's removed with "Prid RefID" (console posts an error if no ref caould be found with the given ID). Create another save, then compare the saves in Fallrim Tools. Alternatively, you can request the VM to attach a script normally (e.g. by filling it to a script variable) then compare the script objects in the saves. Thanks for replying LarannKiar, This is for a mod for Starfield that I am currently working at. I asked it here since there's a higher chance of getting some help than in there and solutions to both games are a bit similar. I need individual controllers per Actor as I will having them using specific Packages and I want them to control their own states. If I do that from the collection script I will have to do plenty of workarounds to deal with different actors situations. Not to mention that it would be difficult to make the decision making not be serialized as I go through the collection members. I knew about Fallrim but never used it. I will keep the test you mention in mind for the future. I decided to follow the Spell/Magic effect path to having the individual controllers and it is working quite nicely at the moment. I will make sure to post snippets of the solution (which is actually from a Skyrim guide) after I have things properly done and tested. Cheers, OldBard Link to comment Share on other sites More sharing options...
LarannKiar Posted April 25 Share Posted April 25 5 hours ago, SameOldBard said: Thanks for replying LarannKiar, This is for a mod for Starfield that I am currently working at. I asked it here since there's a higher chance of getting some help than in there and solutions to both games are a bit similar. Conceptually and structurally they are quite similar. I only have actual modding experience from Fallout regarding MagicEffects (especially Cloak Effects) but I decoded the Starfield's ActiveEffect structure for my "Get Detailed Reference Info" mod and it seems BGS made improvements to MagicEffects regarding performance. But something to keep in mind is that they're more resource hungry than RefColls, like they've always been. 5 hours ago, SameOldBard said: I need individual controllers per Actor as I will having them using specific Packages and I want them to control their own states. If I do that from the collection script I will have to do plenty of workarounds to deal with different actors situations. Not to mention that it would be difficult to make the decision making not be serialized as I go through the collection members. I understand, and yes.. that can be quite inconvenient unfortunately. On the bright side, these functions, that became available in vanilla Starfield Papyrus, may prove useful: RefCollectionAlias.psc: Actor[] Function GetActorArray() Native ObjectReference[] Function GetArray() Native Link to comment Share on other sites More sharing options...
SameOldBard Posted April 28 Author Share Posted April 28 Your Get Detailed Reference Info helped me a lot on the couple of mods I am working at right now. Thanks for that one btw! Another downside of using magic effects is that the TimerGameTime does not work there. But it is not an issue for my current needs. True, those methods are quite handy. It is indeed an improvement. And thanks for the help here LarannKiar. OldBard Link to comment Share on other sites More sharing options...
Recommended Posts