ThoraldGM Posted October 2, 2017 Share Posted October 2, 2017 I'm working on an overhaul of Diamond City SWAT. The plan is to let players specify what weapons and armors the guards get, by putting the gear in a locker. So I wrote a massive sorting algorithm for OnItemAdded. It checks formlists of vanilla armors and keywords. If player has AWKCR installed, it also checks those keywords (formIDs from Gambit77 tutorial) via inter-mod communication. Every item added to locker gets sorted into a formlist. Each armor slot has its own formlist (headgear, eyewear, etc). Then, when guards spawn they will choose one hat randomly from the headgear list, one glasses randomly from the eyewear list, etc. The actual items stay in the locker (vanilla, DmndSecurity01 office) until the locker respawns. I plan to save the gear by storing as an array OnItemAdded, then refilling the locker from array OnReset. But that's not my Big Problem. The issue I am stuck on is that my robust, gee whiz sorting method is saving akBaseItem as a FORM. So the list is filled with base items that have been stripped of their omods. Meanwhile, the gear (OBJ REFS) in the locker still has omods. So... Is it possible to have each guard choose a FORM, use that form to locate the OBJ REF in the locker, then duplicate the ref to every guard that spawns? (Since guards are leveled, my plan for that is FindAllReferences within 20k radius OnLocationChange if GetParentCell is on a list of Diamond City locations.) If a player puts an upgraded armor or weapon in the locker, the guards should get gear with those upgrades. Any ideas? Am I close to a solution or is there a better approach? Scripts: Recent version of sorting method: https://pastebin.com/QkfHYZRC Newer version of OnInit that changes container if player scrapped locker, with planned option for player to choose container in MCM: https://pastebin.com/92iaBenh I can usually write code without getting stuck, but this one is like stumbling through a brain fog, and I've been stuck for about a week. I'm hoping there is a simple solution that I'm overthinking. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 2, 2017 Share Posted October 2, 2017 It's late here so this is going to be brief. To do what you want is extremely difficult if not impossible. Papyrus has limitations that will prevent it from working exactly how you've described unless very specific circumstances are met. Is it possible to have each guard choose a FORM, use that form to locate the OBJ REF in the locker, then duplicate the ref to every guard that spawns?Yes, not really, and no. When you transfer from a container to another container unless the object is persistent the object ref isn't available so it can't be used to identify a particular instance of an object in the container. There is no function to duplicate an object including all omods either. F4SE has a function to get an array of omods on an object reference but you need the reference. A really bad hack way to partially get where you want to go might be to use a spell to activate a listening event on the player for picking up an item, then add that item to a reference alias or ref collection on a quest thus making it persistent. Now you have an object ref that sticks around and can be tracked when placed into your locker container. If using F4SE you can now call the function to get the attached mods and then spawn a new item and attach said mods. Link to comment Share on other sites More sharing options...
ThoraldGM Posted October 3, 2017 Author Share Posted October 3, 2017 Thanks for looking. It amazes me that there's no easy way to intercept and process an object reference before it is transmuted into a form. Link to comment Share on other sites More sharing options...
Recommended Posts