Anyone else notice that recently (as of dawnguard?) the play

Post » Mon Nov 19, 2012 6:28 am

I was seeing some behavior from my mod that could only be explained by the player running scripts much faster than the NPC.
Some quick testing shows that the damage (from my scripts) is being calculated and or applied to the player almost twice as fast as to the NPC I am fighting.

We are both using the same scripts!

Could Bethesda have given the player some kind of priority to run scripts? I have tweaked the INI to runs scripts with more memory but that was when Skyrim first came out and I am just noticing this script priority? situation now.
User avatar
Kieren Thomson
 
Posts: 3454
Joined: Sat Jul 21, 2007 3:28 am

Post » Mon Nov 19, 2012 12:33 pm

That doesn't sound too implausible. The player object has always been special, so it's possible that scripts attached to the player are given higher priority than other scripts.

I wonder how we could test this to confirm or deny it. I'd imagine the player object is generally busier than your average NPC with regard to scripts, so calling a bunch of functions on it probably isn't a fair test as they'd have to wait longer. A function like this might be a good way to test it though:
Spoiler
ScriptName PlayerSpeedTest extends ReferenceAliasFloat Function Test(Int iIterations = 100000)	Int iIndex	Float fStart	Float fEnd	Float fTimeTaken	fStart = Utility.GetCurrentRealTime()	While iIndex < iIterations		iIndex += 1	EndWhile	fEnd = Utility.GetCurrentRealTime()	fTimeTaken = fEnd - fStart	Debug.Trace("Test results: " + GetReference().GetBaseObject().GetName() + \		"\nStart time:\t" + fStart + \		"\nEnd time:\t" + fEnd + \		"\nTime taken:\t" + fTimeTaken)	Return fTimeTakenEndFunction

In order to make it a fair test, the script would have to extend http://www.creationkit.com/ReferenceAlias_-_Script, which I assume is how you have things set up as well.

I'd test it myself right now, but I don't have access to either Skyrim or the Creation Kit at the moment. If anyone wants to try testing this out themselves, JustinOther's and my http://skyrim.nexusmods.com/mods/23782 utility might be helpful.

Cipscis
User avatar
flora
 
Posts: 3479
Joined: Fri Jun 23, 2006 1:48 am

Post » Mon Nov 19, 2012 12:21 pm

lol... that link gets me this:

ReferenceAlias - Script
There is currently no text in this page. You can search for this page title in other pages, or search the related logs.



I run 95% of my scripts thru magic effect abilities. Is that the same thing? I am guessing not, you mean the script that runs on the tab for quest Alias right?

see here: http://www.creationkit.com/Quest_Alias_Tab


In order to make it a fair test, the script would have to extend http://www.creationkit.com/ReferenceAlias_-_Script, which I assume is how you have things set up as well.

Cipscis
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Mon Nov 19, 2012 3:04 pm

Ah, sorry, I guess I'm too used to the format of the wiki's function page headings. This is what I meant - http://www.creationkit.com/ReferenceAlias_Script.

Running them via http://www.creationkit.com/ActiveMagicEffect_Script could work too, so long as it's done the same for the player and any NPCs that are being tested.

Cipscis
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Mon Nov 19, 2012 6:05 pm

Papyrus has no priority system, for the player or anything else. Scripts run as fast as they run, almost always limited by resource contension (multiple scripts accessing the same object/script at the same time) or syncing up native calls with the framerate. If you're seeing something run faster or slower then you expect, I suggest digging into the various profiling functions available :)
User avatar
Yama Pi
 
Posts: 3384
Joined: Wed Apr 18, 2007 3:51 am

Post » Mon Nov 19, 2012 10:56 am

Papyrus has no priority system, for the player or anything else. Scripts run as fast as they run, almost always limited by resource contension (multiple scripts accessing the same object/script at the same time) or syncing up native calls with the framerate. If you're seeing something run faster or slower then you expect, I suggest digging into the various profiling functions available :smile:
A dev speaks! :D *Cough, dialogue bug thread, Cough, Cough*
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Mon Nov 19, 2012 5:49 am

Papyrus has no priority system, for the player or anything else. Scripts run as fast as they run, almost always limited by resource contension (multiple scripts accessing the same object/script at the same time) or syncing up native calls with the framerate. If you're seeing something run faster or slower then you expect, I suggest digging into the various profiling functions available :smile:
I'm glad to hear that. It wouldn't be a good thing if most modders start adding scripts to the player as manichs in order to speed up things.
User avatar
Lil'.KiiDD
 
Posts: 3566
Joined: Mon Nov 26, 2007 11:41 am

Post » Mon Nov 19, 2012 1:39 am

"multiple scripts accessing the same object/script at the same time"

This could be the issue, The player use the same scripts as the NPC however the NPC also have 2 scripts that they all share. So this can slow down ALL their scripting huh? (to be clear they only run them when the player can see them while in combat, but that can be more than several).

So I could speed it up by making more scripts that "types" of NPC would use.

er....profiling functions?





Papyrus has no priority system, for the player or anything else. Scripts run as fast as they run, almost always limited by resource contension (multiple scripts accessing the same object/script at the same time) or syncing up native calls with the framerate. If you're seeing something run faster or slower then you expect, I suggest digging into the various profiling functions available :smile:
User avatar
Skivs
 
Posts: 3550
Joined: Sat Dec 01, 2007 10:06 pm

Post » Mon Nov 19, 2012 12:43 pm

Thanks for the clarification SmkViper :)

@spookyfx.com:
The profiling functions are all located in the http://www.creationkit.com/Debug_Script:
  • http://www.creationkit.com/StartScriptProfiling_-_Debug
  • http://www.creationkit.com/StartStackProfiling_-_Debug
  • http://www.creationkit.com/StopScriptProfiling_-_Debug
  • http://www.creationkit.com/StopStackProfiling_-_Debug
Here's the advice SmkViper gave JustinOther and me when we were developing our http://skyrim.nexusmods.com/mods/23782 utility:
The profiling log format is as follows:
:::::
With being the standard