Jump to content

Intermediate/Advanced papyrus questions


TruePooshmeu

Recommended Posts

Posted

So, after realizing how easy and similar to C papyrus is, I've decided to dive in scripting this game...

 

Not claiming an expert at C language but I did study it for quite some time, I got to the point of using intermediate stuff like saving/retrieving data from archives, using a bunch of "struct" and using pointers. But some things (mainly stuff related to optimization) aren't clear yet. So here we go:

_______________________________________________________________________________________________________________________________________________

 

 

1 Threading

 

-About thread capacity... everyone knows that if I spawn too many actors in combat, many won't attack and will just stand around,  is this so because there are no more "threads" available for the other actors?

-Is there a limit to the number of threads at all?

-Or is a thread created the moment a script is fired and the limit is my CPU/memory?Or the threads stay "idle" waiting for a script to call them?

 

_______________________________________________________________________________________________________________________________________________

2 Quest scripts

 

-I've read around here, that every dialogue is a hidden quest that is waiting to be activated, so I guess the game has a shitload of quests in "idle" mode?

-Which makes me believe that creating quests for scripts is indeed very effective, and "idle quests" consume very little resource?

-After a quest is completed, does it consume less performance resources?

-What should I know about how quests and scripts interact with each other "behind the scenes"? And how quests by themselves work behind the scenes?

 

_______________________________________________________________________________________________________________________________________________

3 Objects and references

 

-A base object is whatever there is in the object window, a reference is ONLY a base object that is placed in a specific location of world and has a X, Y, Z coordinate, am I right?

-Are random spawns also references of their base objects?

-So let's say I create a book, and place it in 2 dungeons, one book in each dungeon, my book is a base object, and has 2 references.
A script (that extends book) attached to my book will work in both books, but if I want a script to only affect one of the books I must extend ObjectReference script and attach this script to the book? Is that right?

-What's the difference between a reference and an ObjectReference? (I know that object reference is a script)

 

 

 

_______________________________________________________________________________________________________________________________________________

4 Optimization and understanding the language barries and limitations.

 

Is there any other optimization/performance stuff I need to know besides:

 

-How scripting can make objects persistent

 

-How Threading works..... how threads can make scripts conflict... How threads can make a script get stuck forever, or in a non-stop loop... How threads can make a script having to wait for too long before another thread frees the script... and finally, the techinques used to avoid all of this.

 

-How multi-threading can work in my favor.

 

-How save games can be affect by scripts and how they interact with scripts.

(specifically, I find the information in the wiki about save games pretty limited and briefly explained, so I'd be glad if anyone points me toward a better reading).

 

-Is there anything else I should know about optimization and potential problems about papyrus?

 

-Will the link below(about fallout) be of any help for skyrim?

https://www.creation...mance_(Papyrus)

 

 

_______________________________________________________________________________________________________________________________________________

 

5- Hidden perk trees

-What mechanisms the game uses to hide/show the vampire perk tree?

-Can I hide/show specific perks inside the trees?  (I know about flagging a perk as "hidden" in the creation kit, but I want to do it after the game has started, if the player chooses one perk, I want another perk to get hidden)

  • 2 months later...
Posted

I do not have any better insight into how the game works than anybody else. Most of what i know is just stuff i read somewhere, and some of what i know is based on experience and some experiments i did myself.
So, as always, take everything with a grain of salt.



1. Threading
Regarding Papyrus threads, the Threading Notes is a good source of info.
I wish every modder would read that and apply what they have learned, especially the info related to thread locking and context switching, which is often what many bigger mods suffer from (specifically, creating race conditions and negatively impacting VM's performance by constantly switching+locking/unlocking threads due to excesive and unneccessary use of external properties).
New threads are started as needed.
I think regardless of what the number of threads limit is, you will surely reach a practical limit way sooner (the VM gets saturated and it will significantly affect user experience), so the actual limit is rather unimportant.

The thing you mentioned about some NPCs not fighting if too many NPCs are spawned, is a different matter, and has very little if nothing to do with Papyrus VM threads (unless those spawned NPCs would have scripts attached to them).
I remember, in Oldrim, there was a limit for how many NPCs can be in combat at the same time, but i dont remember what the limit was. I assume this limit still exists in SSE, but it has been significantly raised (again, no idea what the actual number is).
No idea how this relates to any threads otside of the Papyrus VM.



2. Quest scripts


- "I've read around here, that every dialogue is a hidden quest that is waiting to be activated, so I guess the game has a shitload of quests in "idle" mode?"

Essentially correct, but not EVERY dialogue has its own quest, they are usually grouped by some context, and sometimes are on a quest that is an actual quest.
So the "shitload" is roughly something like few dozens of pure dialogue "quests", maybe about a hundred (super rough estimate, i didn't actually count them).

- "Which makes me believe that creating quests for scripts is indeed very effective, and "idle quests" consume very little resource?"

It depends on what is the "quest" doing if anything - when the "quest" starts (some quests are set to start when the game starts) and what scripts does it starts (if any) and at which point (it can start scripts when it starts, or it can start some script fragments when certain quest stage is reached, etc.).
But yes, quests that are not running, consume very little resources (from observation, i'd say they impact is negligible at best, but i have no statistics to support this claim).
 

- "After a quest is completed, does it consume less performance resources?"

Usually yes. When an actual in-game quest completes, it usually goes hand in hand with stopping the related "quest" which means all scripts attached to that "quest" are also stopped, at which point it will consume the same as before the "quest" was started.


3. Objects and references

- "A base object is whatever there is in the object window, a reference is ONLY a base object that is placed in a specific location of world and has a X, Y, Z coordinate, am I right?"
Yes, the "reference" is something that currently exists somewhere in the game world, but it depends on the context you use this word in (see below).


- "Are random spawns also references of their base objects?"
I never actually even looked at random spawns, so i do not know what they are and how they work. I could only guess.


- "So let's say I create a book, and place it in 2 dungeons, one book in each dungeon, my book is a base object, and has 2 references.
A script (that extends book) attached to my book will work in both books, but if I want a script to only affect one of the books I must extend ObjectReference script and attach this script to the book? Is that right?"

Not quite.
If you'd extend the base "Book" script, you would create a new type of base which is not used by anything, so it wouldn't affect existing books (which are all derived from the base object "Book").
A script attached to a new book you createed in CK, must extend objectReference.
Then, you place two of these books somewhere in the game world, and if you want one of those references to use an additional script, you attach that script to that reference placed in the editor.
(i dont see what were you attempting to ascertain by that example - i dont think you were specifically interested in how to add books to the game, so if my explanation doesnt answer the question, maybe rephrase it)


- "What's the difference between a reference and an ObjectReference? (I know that object reference is a script)"
ObjectReference is a type, and it refers to something that exists in the game world.
A "reference" is just a word people use to refer to different things, based on context. Most of the time, they mean an objectReference, but it can refer to other things of different types, like scripts (you can say "hey, i have this reference to an alias script ..., what do i do with it?" - there the word is used to refer to a script object derived from "ReferenceAlias").



4. Optimization and understanding the language barries and limitations.

- "Will the link below(about fallout) be of any help for skyrim?"
https://www.creationkit.com/fallout4/index.php?title=Performance_(Papyrus)
Yes, 99% of the points written there are relevant to Skyrim too.
That link is bascially a summary of "dos and don'ts", like general, common sense things, which mostly apply to just about any language.

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...