What's the most efficient way to assign a reference variable to == ANY NPC in the game? That includes friendly's creatures, and races.
The best I can come up with, in my noobness, is to assign a string to any ObjectID, if that ID has a minimum amount of characters, do something. But that will also apply to items and such, not just NPC's.
No, it's still a little finicky, because you have to include a reference in GetObjectType. I could check the distance of something to the player, set that as the reference, then determine what it is.
But how do I determine anything that is a set distance from the player? Gotta go function hunting again.
Keep in mind, walking thru all references in a cell, on a regular basis, WILL be CPU intensive, and could cause slow-downs.
another alternative might be to check thru references on cell change, add a token to the folks you are concerned with, and have a script on the token checking distance to the player. If that distance closes to some tiny amount...... do whatever it is you had in mind. Might be a bit less intensive. Maybe. Perhaps........
What I'm doing is adding a perk to the athletics skill that allows you to stagger enemies when you are sprinting and run into them. The sprinting perk is added on level 125. Level 150 reduces fatigue consumption from sprinting, and level 175 gives you the ability to stagger enemies.
I have the ref walking functions running only when you hit level 175, they won't run an other time. That's how I've minimized it. But I may add it to a while loop so that it only happens when sprinting. That should reduce it further...Yeah, I think that's what I'll do.
Got a question for you, HeyYou. One small problem I have with my sprinting script is when you're done sprinting, you reduced fatigue does not regenerate like it does for everything else. I am using "ModActorValue" to reduce fatigue while sprinting. I suspect that this is why the fatigue does not regenerate. The nature of ModActorValue. How can I restore the vanilla setting if fatigue regenerating like it's supposed (using the built-in formula)?
I'm always using GetFirst/NextRef "outside" of loops per say. I noticed it causes slowdown in just about "every" situation when done in a while or foreach loop. There's just too much stuff in my game world I guess. What I'm doing is let the script do the looping for me. Scripts run every frame (unless specified differently), so each frame I obtain the NextRef, the first time I obtain the FirstRef, and when it's done and GetNextRef returns 0, or something else invalid, I'll make it so next frame it will start with FirstRef again. This makes only 1 of these function calls per frame (or less, if I also use a timer prior to advancing into the loop each frame). It's still done scanning quite quickly, but it never causes a noticable slowdown to me.
Interesting. I noticed that when I experienced the slide show, there were a lot of NPC's around. I tried it again, with only one NPC, and the slowdown didn't happen. Both times were in a "While" loop.