SKSE Member Functions Enchantment Script

Post » Mon Jun 08, 2015 9:39 am

Hi everyone. I've been working on an update to Immersive Jewelry that will allow users to switch their rings from right to left hands, and I think I have a pretty effective script to handle this using dual form lists. However, when it comes to allowing users to swap items with player enchantments as well, I had a couple of questions that I wondered if you could help me with.

First, is the limitation still in place that if an item with a player-made enchantment is equipped by means of a script, that the enchantment won't take effect until the player equips the item by hand? I wondered if there might have been a recent SKSE update that resolved this or anything.

Second, is it possible by means of the SKSE functions GetBaseEnchantment(), MagicEffect GetNthEffectMagicEffect(Int index), Float GetNthEffectMagnitude(int index), and SetNthEffectMagnitude(int index) to copy an enchantment exactly from one item (ie, a right handed ring) and apply it with the exact same parameters to another (ie, a called up left handed ring) ? If it is possible, can someone give an example of how this might be accomplished?

User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Mon Jun 08, 2015 8:20 am

Try both of these script. But it seems like SetEchantment can crash your game.

http://www.creationkit.com/SetEnchantment_-_Armor

http://www.creationkit.com/GetEnchantment_-_Armor

User avatar
Star Dunkels Macmillan
 
Posts: 3421
Joined: Thu Aug 31, 2006 4:00 pm

Post » Mon Jun 08, 2015 9:51 am

Oh, those look helpful. How do I apply the values I fetched from GetEnchantment immediately into SetEnchantment?

User avatar
Lauren Denman
 
Posts: 3382
Joined: Fri Jun 16, 2006 10:29 am

Post » Mon Jun 08, 2015 1:00 pm

Something like :

Armor1.SetEnchantment(Armor2.GetEnchantment())

User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Mon Jun 08, 2015 1:52 pm

Would that only set the type of enchantment or would it set the magnitude as well?

User avatar
Hannah Whitlock
 
Posts: 3485
Joined: Sat Oct 07, 2006 12:21 am

Post » Mon Jun 08, 2015 7:19 am

I have no idea since I never used these functions. You should test it before.

User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Mon Jun 08, 2015 7:22 pm

That Armor.SetEnchantment function sets the enchantment for the base object, not the specific ring. There are a few SKSE objectreference ones though that you can try. Haven't used them myself.

; Returns the player-made enchantment if there is oneEnchantment Function GetEnchantment() native; Changes an item's player-made enchantment to something else; None enchantment will remove the existing enchantment; does not delete the custom enchantment, only removes it'Function SetEnchantment(Enchantment source, float maxCharge) native; Creates a new enchantment on the item given the specified parameters; all arrays must be the same size; created enchantments are not purged from the save when removed or overwritten; exact same enchantments are re-used by the gameFunction CreateEnchantment(float maxCharge, MagicEffect[] effects, float[] magnitudes, int[] areas, int[] durations) native
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Mon Jun 08, 2015 6:35 am

Thanks Mojo, that looks even better. How do I have it apply the returned parameters to a new item without setting them manually myself?

User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Mon Jun 08, 2015 9:17 am

Looking for something like this? Haven't used any of these functions before so no idea how they will actually behave in game. There also doesn't seem to be a way to create a MagicEffect array of a size that is not predetermined.

Scriptname _test_testscript extends QuestFunction TransferEnchant(ObjectReference akTemplate, ObjectReference akNew)    float fCharge = akTemplate.GetItemMaxCharge()    Enchantment kEnchant = akTemplate.GetEnchantment() ;returns None if not a player enchantment    if !kEnchant ;not player made, use CreateEnchantment        kEnchant = (akTemplate.GetBaseObject() as Armor).GetEnchantment()        int iNumEffects = kEnchant.GetNumEffects()        MagicEffect[] kEffects = new MagicEffect[128]        float[] fMags = new float[128]        int[] iAreas = new int[128] ;area and duration are problably not needed for armor pieces        int[] iDurs = new int[128] ;could probably set to 0        int iCount        while iCount < iNumEffects            kEffects[iCount] = kEnchant.GetNthEffectMagicEffect(iCount)            fMags[iCount] = kEnchant.GetNthEffectMagnitude(iCount)            iAreas[iCount] = kEnchant.GetNthEffectArea(iCount)            iDurs[iCount] = kEnchant.GetNthEffectDuration(iCount)            iCount += 1        endWhile        akNew.CreateEnchantment(fCharge, kEffects, fMags, iAreas, iDurs) ;no idea what will happen with using all the empty slots in the 128 sized arrays            else        akNew.SetEnchantment(kEnchant, fCharge) ;source code comments say this only works for player made enchantments    endIfendFunction

Also, try http://www.creationkit.com/EquipItemEx_-_Actor for the enchantment bug. I thought that this was supposed to get around it.

User avatar
james kite
 
Posts: 3460
Joined: Sun Jul 22, 2007 8:52 am

Post » Mon Jun 08, 2015 8:33 pm

That looks great. Definitely something I can work with, thank you. Is there a consideration for if the item has two player made enchants?

User avatar
Averielle Garcia
 
Posts: 3491
Joined: Fri Aug 24, 2007 3:41 pm

Post » Mon Jun 08, 2015 7:40 am

I would assume that the two player made enchants would get merged into 1 enchantment, but I'm not sure.

User avatar
mimi_lys
 
Posts: 3514
Joined: Mon Apr 09, 2007 11:17 am


Return to V - Skyrim

cron