darthbdaman Posted July 10, 2016 Share Posted July 10, 2016 This script gets all of the dumpsters, garbage cans, and trash bins in the game, and then removes the ownership from them whenever the player is in their cell. This is the most efficient way I can think of doing this, but it can cause a slowdown when switching cells, which I am sure would be more pronounced on slower systems. Can anyone think of a better way to do this? scn YGTTrashScript array_var Containers array_var Bins string_var sTrash string_var sBin string_var sDumpster string_var sGarbage ref rTrash ref rTrashRef ref currentcell ref oldcell begin GameMode if GetGameRestarted foreach Containers <- (GetLoadedTypeArray 27) let rTrash := *Containers let sTrash := LNGetName rTrash let sBin := LNGetName MS04CaHDumpster let sDumpster := LNGetName Dumpster02 let sGarbage := LNGetName GarbageCanUrban01 if eval ((sBin == sTrash) || (sDumpster == sTrash) || (sGarbage == sTrash)) ListAddForm YGTTrashList rTrash endif loop sv_Destruct sTrash sv_Destruct sBin sv_Destruct sDumpster sv_Destruct sGarbage endif set currentcell to player.getparentcell if(currentcell != oldcell) foreach Containers <- (GetListForms YGTTrashList ) let rTrash := *Containers foreach Bins <- (GetFormRefs rTrash) let rTrashRef := *Bins if IsReference rTrashRef rTrashRef.SetOwnership endif loop loop set oldcell to currentcell endif end Link to comment Share on other sites More sharing options...
Ladez Posted July 10, 2016 Share Posted July 10, 2016 Yukichigai's original mod does this by giving the containers an OnLoad script. Why not follow suit but use NVSE event handling instead? scriptName OwnershipSetupQST begin menumode if getGameRestarted setEventHandler "OnLoad", OwnershipHandler, "first"::YGTTrashList endif end scriptName OwnershipHandler reference loaded_ref reference dummy_ref begin function{loaded_ref, dummy_ref} loaded_ref.setOwnerShip end Note: For some reason the OnLoad handler only seems to work with two paramenters, when it should only have one. That's why the dummy_ref variable is there. Link to comment Share on other sites More sharing options...
darthbdaman Posted July 10, 2016 Author Share Posted July 10, 2016 The YGTTrashList is going to be filled with Base Objects. Will this still work? I can't get refs unless they are persistent, or in the current cell is the basic problem with what I was trying to do before, and I wonder if this get around that. Link to comment Share on other sites More sharing options...
Ladez Posted July 10, 2016 Share Posted July 10, 2016 I tested it by pre-filling it with base forms in the GECK, so yeah it should work. Oh and by the way, sv_Destruct can handle more than one string in one go: sv_Destruct sTrash, sBin, sDumpster, sGarbageJust for the sake of tidiness. :P Link to comment Share on other sites More sharing options...
darthbdaman Posted July 10, 2016 Author Share Posted July 10, 2016 Doesn't seem to be working. I used your exact scripts, and added my list add script to my main quest script. I added a quest for the ownership setup and made it quest type. I left the handler as object type. Link to comment Share on other sites More sharing options...
Ladez Posted July 10, 2016 Share Posted July 10, 2016 You're going to want to register the event after you've filled the list, I bet it doesn't work retroactively. Probably best just to stick the SetEventHandler line in right after the loop finishes. My demo was in a menumode block for it to register in the main menu, so I could coc into a cell to test without the OnLoad event firing before the handler was registered. Link to comment Share on other sites More sharing options...
RoyBatterian Posted July 10, 2016 Share Posted July 10, 2016 OnLoad only triggers when the cell is loaded, if it's already loaded or in the cell buffer then it won't trigger again which will just cause you headaches. Try using an OnActivate event handler instead. Link to comment Share on other sites More sharing options...
Ladez Posted July 10, 2016 Share Posted July 10, 2016 (edited) But then it's owned until the moment you activate it, which means that it shows up red in the HUD. Not exactly optimal, in my opinion. You could use both events though, with OnActivate as a backup. Edited July 10, 2016 by Ladez Link to comment Share on other sites More sharing options...
darthbdaman Posted July 11, 2016 Author Share Posted July 11, 2016 Thanks guys, finally got it working. It also exposed some errors in my other scripts, which was really nice. Thanks! Link to comment Share on other sites More sharing options...
RoyBatterian Posted July 11, 2016 Share Posted July 11, 2016 Hrm maybe you can use the crosshair target function and then set it when that is over a container in your list... but then again it won't update until you move the crosshair off and back on the container. This is just a crappy problem with the New Vegas ownership system. They changed it from Fallout 3, and that's also why the doors and stuff were red in TTW. Maybe a GetCellRefs script running every 5 seconds would be better. Link to comment Share on other sites More sharing options...
Recommended Posts