Jump to content

A bunch of intermediate to advanced questions about papyr


TruePooshmeu

Recommended Posts

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- Global variables vs properties

 

What's the difference between using a global variable or a property?

 

More specifically:

-Why mod authors use Global variables if I'll need my MCM_quest as a property anyway?

 

lets say I have a quest that wants acess to a "MCMmenu" variable.

scriptname Quest_That_Will_Get_MCMmenu_values extends quest

;;;;  1ST alternative       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 

GlobalVariable property Variable auto
Quest Property My_MCM_Quest auto
;;;random code
"FUNCION_INVOLVING_GlobalVariable_HERE"    ;;;;;;seems worse, 2 datas will always be stored, the global variable AND the quest as a property




;;;; 2ND alternative that seems better;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Quest Property My_MCM_Quest auto
;;;random code
int Variable = My_MCM_Quest.(Functions_involving_the_variable_here)
;;;random code
VariableIwantToGet = none ;;;;;seems better because less data will be stored, a globalvariable will always be consuming space

_______________________________________________________________________________________________________________________________________

2 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?

 

_______________________________________________________________________________________________________________________________________________

3 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?

 

_______________________________________________________________________________________________________________________________________________

4 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)

 

 

_______________________________________________________________________________________________________________________________________________

5 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.creationkit.com/fallout4/index.php?title=Performance_(Papyrus)

 

 

_______________________________________________________________________________________________________________________________________________

 

6- 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)

Edited by TruePooshmeu
Link to comment
Share on other sites

about "Global variables vs. properties"

read this: https://www.creationkit.com/index.php?title=Talk:UpdateCurrentInstanceGlobal_-_Quest

for more look at creation kit wiki: https://www.creationkit.com/index.php?search=globalVariable&title=Special%3ASearch&fulltext=Search

 

If you have read the content you should understand its not "Global vs. property", it is "script variable (like bool, int, float) vs. script GlobalVariable"

Edited by ReDragon2013
Link to comment
Share on other sites

Thanks! now I can see how a global variable would be useful in a context that properties wouldn't cut it.

 

now what I fail to see is why mod authors use it in a context that properties would be enough, Globalvariable script has 5 functions, all of them either for reading a value or changing a value, which honestly still looks like a property, I can get a property value, or change it just like a global variable as long as that property is either a full or auto property.

 

still, I've seen a few mods using global variables in such cases where properties would be fine, am I still missing something? Are global variables better for whatever reason?

Link to comment
Share on other sites

1 - Global vs. prop.

Covered by others, but the biggest is globald are available in other mods and scripts, and even accessible in the console.

 

2 Threads

No idea, sorry. :(

 

3 - Dialog in quests

Not exactly. Start here.

https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Dialogue

 

4 - Objects and references

The base object is like the master copy of something with all of its properties.

A reference id of an object is that specific instance of that object.

 

For example, let us say there is a single iron dagger base object. It has weight, damage, etc. It has a base ID of 01234.

Then lets say NPC A has an iron dagger. He has his own copy of the master, and that specific copy is ref ID 00a1b2x (whatever).

Then the player makes an iron dagger at a forge. The game creates a new copy of the base object, and assigns a ref id of 0100132 (what ever, but it is unique). There are now two 100% independent iron daggers in this world - the one on NPC A, and the one on the player.

They both share all the same properties of the base iron dagger, but each one is unique, in its location, ownership, etc.

 

This is different from "object references" in scripting (similar words...I know).

Someone may be able to to explain this better, but think about as the script has to act on something, or be related to something - to add more info than the base info for that object - hence, it extends that object.

 

5 Optimization and understanding the language barries and limitations.

Can't help you too much there. I can say for the most part the fallout papyrus is useful for ideas, but there are some minor differences between the two, so I would stick with skyrim stuff where you can.

 

 

6- Hidden perk trees

I have messed with perk trees (not very user friendly) but don't know about the vampire ones.

Sorry.

 

 

Finally, there are tons of great tutorials on youtube, here is a really good series;

https://www.youtube.com/channel/UCtYB2iX9_52X_DNtSIJXyWg

Link to comment
Share on other sites

GlobalVariable holds the same value in every script instance that is running.. (exception quest script, first link I posted)

 

for example: you have a lot of bookshelves and weaponracks in the skyrim world

 

a bookshelf object has the script PlayerBookSelfContainerScript attached with

  GlobalVariable Property BookShelfGlobal Auto
    {Global showing whether or not the player has ever activated a bookshelf}

a weaponRack has the script WeaponRackActivateSCRIPT attached with

  GlobalVariable Property WRackGlobal Auto
    {Global that determines if you have seen the help message yet or not}

both scripts use a special globalVariable like a Bool to find out players first activation of them

 

would you use a Bool as follow

     Int Property bFirstActivation auto

then only the property in this single activated object will be updated, the same property in other script instances of other objects keeps the same value

Link to comment
Share on other sites

Thanks guys! Now I can see some uses for global variables.

 

If you guys could help me about the other questions, they are even more important than the global variable one.

 

I mean, my scripts that I've been testing have been running the way they are supposed to run, my concern now is about optimization and nuances about papyrus, and how the language works behind de scenes.

Link to comment
Share on other sites

 

2 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?

I don't think the actors not fighting has anything to do with thread capacity. There are some settings that govern max combat actors and max actors with active AI. I cannot point to them specifically, I just remember Wrye Bash exposed them as viable settings to tweak with the bashed batch.

 

The way I understand it and I could be wrong... A thread is started when an event on a script is triggered. It goes through line by line. When it reaches something that is on another script, it pauses while a separate thread goes and gets that information or does whatever it needs to on that script. When that second thread returns, the first continues. When it runs out of things to do or reasons to pause, it stops.

 

Processing of all this is limited by your FPS as I understand it. So hardware does play a factor.

 

Regarding the FO4 link about Papyrus performance. All of that is good advice and for the most part should be considered when scripting for any version of Skyrim.

Link to comment
Share on other sites

 

I don't think the actors not fighting has anything to do with thread capacity. There are some settings that govern max combat actors and max actors with active AI. I cannot point to them specifically, I just remember Wrye Bash exposed them as viable settings to tweak with the bashed batch.

 

And sadly they are not used in any capacity in the actual game executable. Just dead weight.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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