Iterating through all NPC's *once* per cell

Post » Sun Jun 19, 2011 1:34 pm

Hi all!
I am working with several small, likely private mods to enhance my game. However, I've been stopped in my tracks because I am unable to iterate only once through a cell.

Ex: I tried to create a mod that replaces any creatures in a cell with a fiend. It worked great, except it kept running, so I was inundated by a steady stream of fiends.
I would post the code but it'd probably be much easier if someone could post the loop framework. I am of course using label-goto.

Also, how does the quest script delay effect NVSE loops? For instance if the quest script runs while the loop is still active.

And also II, is there a way to make sure it only runs once per cell for each playthrough?

Thanks in advance!
User avatar
k a t e
 
Posts: 3378
Joined: Fri Jan 19, 2007 9:00 am

Post » Sun Jun 19, 2011 11:27 am

The loop happens in one pass, assuming you mean a label/goto pair. I don't think you can even get another frame of animation until a script has finished a pass, so it's impossible for a script to start a new pass while the previous pass is still underway. In other words, a loop isn't ''still active''; it occurs all at once. Execution doesn't continue until a loop finishes.

Queue
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Sun Jun 19, 2011 3:11 am

In this specific case, you could just check to see if an NPC is in the Fiend faction before you replace them, or if GetDisabled is 0 so you don't place new NPCs on the site of the old disabled ones. Checking things once per cell is easy in interior (track player.GetParentCell, if it changes they've changed cell) but in exteriors it's not as useful as NPCs regularly run across cell boundaries, and you can be standing 50cm away from someone and be in a different cell.
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am

Post » Sun Jun 19, 2011 12:17 pm

Very helpful, thank you! I'd forgotten all about getDisabled, that'll solve my Agent Smith problem :D
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am


Return to Fallout: New Vegas