Jump to content

[Papyrus] Get ESP name of an equipped item via script?


Nymra

Recommended Posts

Posted

I am curious if there is a way to obtain the ESP name of an item (like for example weapon or piece of armor) via script?

 

I wanted to create a "Load Order Proof" way of transfering items between profiles and if I could get the ESP name this should be possible?!

All mods I found "forget" items if the load order changes and the owning ESP has another prefix.

 

thx alot

Posted
19 minutes ago, Tlam99 said:

Bool weapon Getformfromfile(id, string) 

Returns true if there

Id 0x00000nnn, string xxxx.esp

 

but when I do not know the ESP name?

Say I have weapon X from mod abc.esp

 

I want to save that weapons ID and ESP file name to a json to then be able to recover it via Getformfromfile

Posted

A better way might be to use xEDIT Pascal script. That allows you to check through all weapon forms from all mods you select. And then you can just save the ID to the file. Problem would be that saved file will most likely be just  text, not JSON.

Posted
1 hour ago, Nymra said:

 

but when I do not know the ESP name?

Say I have weapon X from mod abc.esp

 

I want to save that weapons ID and ESP file name to a json to then be able to recover it via Getformfromfile



I think this will work since the first 2 hexadecimal digits in the Form ID are the mod index.

0x1B0012B7

 

Int iFormId      = myWhatever.GetFormID()
Int iModIndex    = Math.RightShift(iFormId, 24) ; e.g. 0x1B0012B7 becomes 0x1B or the decimal value of 27
String sFileName = Game.GetModName(iModIndex) ;Gets Name of Mod eg. Skyrim.esm, Update.esm, Hearthfire.esm, etc.


https://www.creationkit.com/index.php?title=GetFormID_-_Form

https://www.creationkit.com/index.php?title=RightShift_-_Math

https://www.creationkit.com/index.php?title=GetModName_-_Game

 

 

Posted

The following bitwise logical AND will mask off the index of a form id. Not really necessary with GetFormFromFile since the function does it internally.

 

Int iItemMask    = Math.LogicalAnd(iFormId, 0x00FFFFFF)

 

So 0x1B0012B7 becomes 0x000012B7 and you can save "String sFileName" and "Int iItemMask" to the JSON file.

https://www.creationkit.com/index.php?title=LogicalAnd_-_Math


https://miniwebtool.com/bitwise-calculator/?data_type=16&number1=1B0012B7&number2=00FFFFFF&operator=AND

https://miniwebtool.com/bitwise-calculator/bit-shift/?data_type=16&number=1B0012B7&place=24&operator=Shift+Right

Posted
22 minutes ago, jbezorg said:



I think this will work since the first 2 hexadecimal digits in the Form ID are the mod index.

0x1B0012B7

 

Int iFormId      = myWhatever.GetFormID()
Int iModIndex    = Math.RightShift(iFormId, 24) ; e.g. 0x1B0012B7 becomes 0x1B or the decimal value of 27
String sFileName = Game.GetModName(iModIndex) ;Gets Name of Mod eg. Skyrim.esm, Update.esm, Hearthfire.esm, etc.


https://www.creationkit.com/index.php?title=GetFormID_-_Form

https://www.creationkit.com/index.php?title=RightShift_-_Math

https://www.creationkit.com/index.php?title=GetModName_-_Game

 

 

 

aaaah, thx alot, this explains it for me.

damnit, I searched the CK wiki and did not stumble over the GetModname o_O 

 

Posted

This will just save base IDs though. You'll have to take additional steps for player enchanted items if you're planning a "Save My Stuff" mod for Skyrim. This is a problem I ran into in Fallout 4 with player modded armor and weapons.

Posted
14 minutes ago, Nymra said:

damnit, I searched the CK wiki and did not stumble over the GetModname o_O 


The CK wiki search sucks. It's exact match and that's it. Not a substring match. I usually go to the scripting reference pages and use CTRL+F and try to find a function that way.

Posted
8 minutes ago, jbezorg said:

This will just save base IDs though. You'll have to take additional steps for player enchanted items if you're planning a "Save My Stuff" mod for Skyrim. This is a problem I ran into in Fallout 4 with player modded armor and weapons.

at least for me the enchantments are not an issue right now. base IDs are totally sufficient.

 

I plan a "feature" that allows the player to summon a "mystic trader" that reequips a previously saved equipment sex in exchange for sex and money (and a random chance of some... scamming :D) 

basically I want to built a kinky based economy in skyrim that offers an alternative to classic looting/crafting mechanics.

I personally also dont like looted armor. I spend alot of time to design my outfits and always want them back :D

Posted

That and the one-size-fits-all-unisex outfits in Skyrim and Fallout 4.

Conan the Nord looting a suit of bikini armor from a female woof elf and wearing it.

Posted
7 minutes ago, jbezorg said:

That and the one-size-fits-all-unisex outfits in Skyrim and Fallout 4.

Conan the Nord looting a suit of bikini armor from a female woof elf and wearing it.

 

yeah, that too :(
I fiddled around with almost any loot mod out there by now I think but they are either overintrusive or useless in a way. For my purpose ofc, kinky skyrim is some very special place, haha.

 

But actually there was a mod somewhere that randomized the sizes of looted armor so you had to find suitable ones or suffer drawbacks or could not fit it at all. 

I dont remember the name tho. 

Archived

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

  • Recently Browsing   0 members

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