FiftyTifty Posted July 6, 2018 Share Posted July 6, 2018 One of the issues that I've encountered with New Vegas, is that placed items will sometimes move about when you enter a cell that's being loaded for the first time. If you visit a cell with placed items, then reload and re-enter the cell, the items will not move and will be exactly where they should be. It's a very annoying issue, so I've set out to make a workaround; replace all the items in a given cell with static versions. The good news, is that I was able to make static versions of every item in the game through FNVEdit scripting. The next roadblock is scripting a way to search through 14 source form lists that contain item base objects, find the index of each placed item, and then replace them with the static equivalent in the 14 destination form list pairs that contain all the statics. I've created the form lists in such a way that they are 1:1 in terms of indexes. If, say, there's an item's base object present in FormlistSource03, I can get the static version from FormlistDest03 by using the same index returned by IsRefInList. But iterating through these form lists is unintuitive. How would I go about doing that? Here's the script in it's current incarnation: https://pastebin.com/iA21hnzZ It does the following, in order: - Uses the GetRefs function to create several arrays containing the item references in the current cell - Takes each reference from each array, and puts them into a bigger array - Takes the X, Y, and Z positions for each item, giving each one their own respective array What it needs to do, is: - Check for each reference in the assimilated array against 14 different form lists - If there is a match, stop iterating through every form list - Move the item to another cell - Place the static version - Set the static's XYZ position to the original item's. It's the first step that's aggravating me. How do I iterate through 14 different arrays, and stopping processing when an item's base object is found? Link to comment Share on other sites More sharing options...
EPDGaffney Posted July 6, 2018 Share Posted July 6, 2018 I'm not against trying to work through it this way if I'm wrong, but I've generally had good luck with MoveToEditorPosition to alleviate these problems when I found it important enough to do so.https://geckwiki.com/index.php/MoveToEditorPosition Could be paired with Lutana's OnCellEnter event in an event handler.https://geckwiki.com/index.php/OnCellEnter But I'm actually a little confused about the precise thing you're finding to be a problem. There are quite a few functions to use to look at lists. And if you wanted to loop through them, there's always this one:https://geckwiki.com/index.php/GetListForms You can use this to grab an item based on the index:https://geckwiki.com/index.php/ListGetNthForm Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 6, 2018 Author Share Posted July 6, 2018 (edited) Having the script tied to an OnCellEnter event is a horrible idea, as it would automatically convert objects in every cell the player enters. What I've done, is used a hotkey event instead. The problem is iterating through each list, and stopping the search when an item's base object is found. I tried making two large arrays, the first containing all the base objects from the source form lists, and the second containing base objects from the destination form lists. But I don't know how to actually do that; there's no way to have a base object as a variable. Edit: Alright, I think I'm managing to wrap my head around this. But there is a big problem; I can't manage to get an entry from an array by using an index. How do I do that? 2nd Edit: Managed to figure it out; you can get the entry from an array by using an integer. E.g: arrayOfItems[iIndexVar]. Now that's sorted, I've found a show-stopping bug. For some reason, New Vegas has sorted my form lists differently. They look fine in FNVEdit, but when loaded in the game and GECK, they are no longer sorted into pairs. Edited July 6, 2018 by FiftyTifty Link to comment Share on other sites More sharing options...
EPDGaffney Posted July 6, 2018 Share Posted July 6, 2018 I thought you wanted it to occur whenever you went into a cell, something to do with preserving where you'd put the items when making your mod. You can still specify the cell if you want. In fact, your hotkey can set a variable that must be true for the UDF to switch out the items for statics when the player enters the cell. Is this supposed to be for maintaining the position of items you've arranged neatly whilst in-game? When you said placed items will sometimes move about when you enter a cell that's being loaded for the first time that made me think otherwise. Base objects can be stored as ref variables. If you want, you can use GetListForms with one of the array-sorting functions to sort everything 1:1 again and compare arrays instead of a form list and an array. Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 6, 2018 Author Share Posted July 6, 2018 I thought you wanted it to occur whenever you went into a cell, something to do with preserving where you'd put the items when making your mod. You can still specify the cell if you want. In fact, your hotkey can set a variable that must be true for the UDF to switch out the items for statics when the player enters the cell. Is this supposed to be for maintaining the position of items you've arranged neatly whilst in-game? When you said placed items will sometimes move about when you enter a cell that's being loaded for the first time that made me think otherwise. Base objects can be stored as ref variables. If you want, you can use GetListForms with one of the array-sorting functions to sort everything 1:1 again and compare arrays instead of a form list and an array. Aye, it's to keep placed items from moving about. Having it tied to a hotkey is better for performance, as that event only fires when the key is pressed, rather than whenever the player enters a new cell. Unfortunately, I hit a snag with the form lists. For some reason, they're sorted differently by the GECK and in-game, than how they are sorted in FNVEdit. So the lists, while they look fine in FNVEdit, are not sorted 1:1. Ugh. Unless I can figure out a way to fix the form lists, the mod's dead in the water. Link to comment Share on other sites More sharing options...
Mktavish Posted July 6, 2018 Share Posted July 6, 2018 What about just using this function on them temporarily , instead of swapping them out with a static ? https://geckwiki.com/index.php/SetRigidBodyMass But I guess you would want to do this first on them , and store those for later recall ... https://geckwiki.com/index.php/GetRigidBodyMass Link to comment Share on other sites More sharing options...
EPDGaffney Posted July 6, 2018 Share Posted July 6, 2018 Well, see what you find with that, as it sounds more like a FNVEdit issue than anything I would have experience doing. But if you don't find anything, why can't you just re-sort everything at run-time as I've suggested? Link to comment Share on other sites More sharing options...
EPDGaffney Posted July 6, 2018 Share Posted July 6, 2018 Oh? Never used that one, Mktavish. Kind of never knew it existed. That's quite a find. Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 6, 2018 Author Share Posted July 6, 2018 (edited) What about just using this function on them temporarily , instead of swapping them out with a static ? https://geckwiki.com/index.php/SetRigidBodyMass But I guess you would want to do this first on them , and store those for later recall ... https://geckwiki.com/index.php/GetRigidBodyMass SetRigidBodyMass only works on weapons and certain light objects. It does not work on the vast majority of items. You can try this yourself, as it's also a console command. Well, see what you find with that, as it sounds more like a FNVEdit issue than anything I would have experience doing. But if you don't find anything, why can't you just re-sort everything at run-time as I've suggested? Ar_SortAlpha and Ar_Sort only sort records alphabetically if they have a NAME element (not the editor ID). Statics don't, so there's no way to sort the arrays into pairs. Edited July 6, 2018 by FiftyTifty Link to comment Share on other sites More sharing options...
EPDGaffney Posted July 6, 2018 Share Posted July 6, 2018 Ar_SortAlpha can sort via FormID, but I still don't think it would work quite right. Ar_CustomSort could probably give you something if you thought about what to use as your sorting criteria. But working out why the form list is out of order is probably easier. I don't see why it would be different in FNVEdit with no way to fix it ever implemented. Link to comment Share on other sites More sharing options...
Recommended Posts