Scripting problem with CopyAllEffectItems

Post » Sat Feb 19, 2011 6:01 am

What i am trying to do is create a way to add enchantments to already enchanted items. The basic premise is to put the item to enchant with a soul gem and a varla stone (nothing is free after all) and add a new enchantment to the item using the Enchantment station. To this end I remove all player items and add the items in the chest to the player and call ShowEnchantment. After testing for actual creation of the enchantment, I run the following code:


; get the created item
set CreatedItem to GetLastEnchantedItem
PrintToConsole "New Item is %n" CreatedItem

let TempEnchnew := GetEnchantment CreatedItem
let numEffectsnew := GetMagicItemEffectCount TempEnchnew
let TempEnchorig := GetEnchantment itemObj
let numEffectsorig := GetMagicItemEffectCount TempEnchorig
printToConsole "num enchantments %n %f" CreatedItem numEffectsnew
printToConsole "num enchantments %n %f" ItemObj numEffectsorig

CopyAllEffectItems TempEnchorig CreatedItem ; <===========================

let TempEnchnew := GetEnchantment CreatedItem
let numEffectsTest := GetMagicItemEffectCount TempEnchnew
printToConsole "num enchantments %n %f" CreatedItem numEffectsTest



This code is similar to CandleMaster's Unenchanting chest. The problem is the original effects are not copied to the new item. For testing, the original item has 2 enchantments and the new item has the 1 from the Enchantment station. After the call to Copy All EffectItems, the new item still only has one effect. I have also tried the following code to no avail:


While ( numEffectsOrig > 0)
set numEffectsOrig to (numEffectsOrig -1)
CopyNthEffectItem TempEnchorig CreatedItem numEffectsOrig
set CurrentEffect to GetNthEffectItemCode TempEnchorig numEffectsOrig
PrintToConsole "new effect no %.0f should be %f" numEffectsOrig CurrentEffect
Loop

using this, my debug comments show the expected 2 lines with the effect codes, but here CopyNthEffectItem also is not putting the enchantment onto the item. This is the final itemI need for my current mod. Any help or thoughts are appreciated.
User avatar
Anthony Rand
 
Posts: 3439
Joined: Wed May 09, 2007 5:02 am

Post » Sat Feb 19, 2011 1:21 am

Hi

I don't have the detail at the moment (not at home) but I believe there is a fairly simple mod you might want to take a look at called TransferEnchant. I was having a tinker with the script used in it a while ago, and it seemed fairly straightforward.
User avatar
Laura Shipley
 
Posts: 3564
Joined: Thu Oct 26, 2006 4:47 am

Post » Sat Feb 19, 2011 1:35 am

Thanks for the response.

I looked at TransferEnchant and another that does the same thing. In both cases, they use get/set enchantment which replaces the enchantment on the receiving item. I am looking to add to the enchantment already on the receiving item and it looks like CopyAllEffectItems and CopyNthEffectItem are not doing that. I am going to try setNthEffectItemxxx functions in a loop next to see if that will work.

In all of these functions, the enchantment looks to go onto the item (objectID:ref). Should I perhaps be cloning the enchantment and modifying that, then setting the new enchantment onto the original object?
User avatar
Mélida Brunet
 
Posts: 3440
Joined: Thu Mar 29, 2007 2:45 am

Post » Sat Feb 19, 2011 10:23 am

ok, I figured out where I was going wrong. I had based my script on Candlemaster's Unenchant tutorial in the CS Wiki.

See - http://cs.elderscrolls.com/constwiki/index.php/User:Candlemaster/Unenchanter

What I had failed to take into consideration was Candlemaster's use of a cloned sigil stone as the receiving object. Now a sigil stone can be considered an enchantment object since you place enchantments on to it directly. What I had to do above is replace the CreatedItem with it's base enchantment object and modify that. Since the base enchantment came from an enchantment station, it was a new enchantment object, so I could modify it without worrying about other items with the same base enchantment. so the script changed to:


let TempEnchnew := GetEnchantment CreatedItem
let numEffectsnew := GetMagicItemEffectCount TempEnchnew
let TempEnchorig := GetEnchantment itemObj
let numEffectsorig := GetMagicItemEffectCount TempEnchorig
;printToConsole "num enchantments %n %f" CreatedItem numEffectsnew
;printToConsole "num enchantments %n %f" ItemObj numEffectsorig

CopyAllEffectItems TempEnchorig TempEnchnew ; now uses the new enchantment object

set OldCharge to GetObjectCharge itemObj ; adding the charge of the original object to the charge from the soul gem
ModObjectCharge OldCharge CreatedItem

Thanks moogatron for your input. That helped lead me to figuring out where I went wrong. Also thanks to Candlmaster for the tutorial
User avatar
Cesar Gomez
 
Posts: 3344
Joined: Thu Aug 02, 2007 11:06 am


Return to IV - Oblivion