pufthemajicdragon Posted November 28, 2014 Share Posted November 28, 2014 (edited) I've been digging and so far it seems that the function GetGoldValue() only returns the base item's value. For example, if I put an "Elven Sword of Blizzards" into a chest with a script that returns GetGoldValue() for the item placed in the chest, it returns 95, the base value of a standard Elven Sword.I've searched the forums and the web and can't find any information on updates to this function. I did find one forum thread where someone suggested making sure that GetGoldValue() was called on the object reference and not the base item - GetNthForm returns a form type, not an objectReference type, which makes me wonder if GetNthForm is where my problem is - is there a way to return the Nth item in a container as an objectReference type? Is anyone here aware of updates or alternatives to this function? Or has anyone found an updated work around? Script: Scriptname pppBreezeHomeStoreQuestScript extends Quest ; Aliases ObjectReference Property pppBHStoreSafeRef Auto ObjectReference Property pppBHStoreChestRef Auto MiscObject Property Gold Auto ; Variables ; Imports import Utility ; Functions and events ; Sets the update interval in game time for the next update Function SetUpdate() float fRand = Utility.RandomFloat(1.0, 4.0) RegisterForSingleUpdateGameTime(fRand) endFunction ; Selects a random item in the items chest, gets its value, ; removes the item from the chest and adds the value to the ; store's safe. Event OnUpdateGameTime() int iTotalValue = 0 int iTotalItems = 0 int iItemValue = 0 while (iTotalValue < 100) int iItemIndex = enumItems() if iItemIndex < 0 iTotalValue = 101 else form oItem = pppBHStoreChestRef.GetNthForm(iItemIndex) iItemValue = oItem.GetGoldValue() iTotalValue = iTotalValue + iItemValue pppBHStoreChestRef.RemoveItem(oItem, 1) pppBHStoreSafeRef.AddItem(Gold, iItemValue, true) endIf endWhile iTotalValue = 0 SetUpdate() endEvent ; Enumerates the items in the items chest. ; Returns an index for an item in the chest, or -1 if the chest is empty. int Function enumItems() int iTotalItems = pppBHStoreChestRef.GetNumItems() if iTotalItems > 0 int iRand = Utility.RandomInt(0,iTotalItems - 1) return iRand else return -1 endIf endFunction int Function getPrice(ObjectRference oItem) float gsfBarterMax = Game.getGameSettingFloat("fBarterMax") float gsfBarterMin = Game.getGameSettingFloat("fBarterMin") float avfSpeech = Game.GetPlayer().getAv("Speechcraft") float factor = (gsfBarterMax - (gsfBarterMin * (avfSpeech/100))) if (oItem.getBaseObject().getType() == kWeapon) e = (oItem.getBaseObject() as Weapon).getEnchantment() elseIf (oItem.getBaseObject().getType() == kArmor) e = (oItem.getBaseObject() as Armor).getEnchantment() endIf if (e) eValue = e.getGoldValue() eValue = else endIf endFunction Edited November 28, 2014 by pufthemajicdragon Link to comment Share on other sites More sharing options...
ArronDominion Posted November 28, 2014 Share Posted November 28, 2014 Forgive me if you have already tried this, but have you tried casting the form as an objectreference, in a similar way that you casted it as a Weapon/Armor? Link to comment Share on other sites More sharing options...
pufthemajicdragon Posted November 28, 2014 Author Share Posted November 28, 2014 (edited) Forgive me if you have already tried this, but have you tried casting the form as an objectreference, in a similar way that you casted it as a Weapon/Armor?I did try the following (on line 33) and it compiled but GetGoldValue() returned 0 when I ran it.ObjectReference oItem = pppBHStoreChestRef.GetNthForm(iItemIndex) as ObjectReference iItemValue = oItem.GetGoldValue() debug.Notification("iItemValue: "+iItemValue)I also tried running GetGoldValue() on a base reference, and it also returned 0.WEAPON Property testSword Auto ;linked to EnchElvenSwordFrost05 iValue = testSword.GetGoldValue() debug.Notification("iValue: "+iValue) Edited November 28, 2014 by pufthemajicdragon Link to comment Share on other sites More sharing options...
ArronDominion Posted November 29, 2014 Share Posted November 29, 2014 Definitely a step in the wrong direction (sorry about that). Looking in the creation kit, it looks like the value of the enchanted items are listed with the same price as the regular versions of the item, regardless of item type (so an object reference will not help get around that issue). I would experiment in game with the items with their various enchantments and work backwards to come up with a formula on enchanted items where the price would be (yay algebra?): base (+ or *) enchOffset = actual price Link to comment Share on other sites More sharing options...
pufthemajicdragon Posted November 29, 2014 Author Share Posted November 29, 2014 Definitely a step in the wrong direction (sorry about that). Looking in the creation kit, it looks like the value of the enchanted items are listed with the same price as the regular versions of the item, regardless of item type (so an object reference will not help get around that issue). I would experiment in game with the items with their various enchantments and work backwards to come up with a formula on enchanted items where the price would be (yay algebra?): base (+ or *) enchOffset = actual priceIt took way too long (don't ask how late I've been staying up) but I managed to sort out an equation that fairly closely approximates enchanted item value. It's just under by between 0 and 7 gold, which isn't too bad. It's silly how simple the equation was for how long it took me to figure it out. GOLD = (Item.GetGoldValue() + (Enchantment.GetGoldValue * 8) + (Item.GetCharge() * .12)) I did find that the UESP talk page on "Generic Magic Weapons" has a formula that is supposedly 100% accurate, but I just have too much trouble wrapping my head around it, much less converting it into a SKSE function. The equation above is a frankensteined version of the information I found there. I hope it can prove useful to someone else! Oh, and FYI, GetEnchantment() returns null for player-enchanted items. Gir. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 30, 2014 Share Posted November 30, 2014 Wrapped my brain around that formula for you. Came up with a function that should produce the same results (knock on wood). Feel free to test it out and use it if it does indeed work. I haven't even tested to see if it compiles.... Int Function GetEnchantedGoldValue(Form TheItem) Int GoldValue = 0 Enchantment E = TheItem.GetEnchantment() Index = 0 While Index < E.GetNumEffects() MagicEffect ME = E.GetNthEffectMagicEffect(Index) Float MEBaseCost = ME.GetBaseCost() Float Mag = E.GetNthEffectMagnitude(Index) Int Dur = E.GetNthEffectDuration(Index) GoldValue = GoldValue + ( (MEBaseCost*8) * (pow(Mag,1.1)) * (pow(Dur/10,1.1) ) Index += 1 EndWhile Return GoldValue EndFunction It is a shame that GetEnchantment() does not work with player enchanted gear.... Link to comment Share on other sites More sharing options...
pufthemajicdragon Posted December 3, 2014 Author Share Posted December 3, 2014 Wrapped my brain around that formula for you. Came up with a function that should produce the same results (knock on wood). Feel free to test it out and use it if it does indeed work. I haven't even tested to see if it compiles.... Int Function GetEnchantedGoldValue(Form TheItem) Int GoldValue = 0 Enchantment E = TheItem.GetEnchantment() Index = 0 While Index < E.GetNumEffects() MagicEffect ME = E.GetNthEffectMagicEffect(Index) Float MEBaseCost = ME.GetBaseCost() Float Mag = E.GetNthEffectMagnitude(Index) Int Dur = E.GetNthEffectDuration(Index) GoldValue = GoldValue + ( (MEBaseCost*8) * (pow(Mag,1.1)) * (pow(Dur/10,1.1) ) Index += 1 EndWhile Return GoldValue EndFunction It is a shame that GetEnchantment() does not work with player enchanted gear....You are a genius. Or at least way more motivated than I am. I want to have a SKSE love child with you.I haven't implemented this yet, or tested it, but the code looks good and I'll see about putting it in an update for the mod I just launched tonight.http://www.nexusmods.com/skyrim/mods/60466/? Link to comment Share on other sites More sharing options...
icecreamassassin Posted September 13, 2015 Share Posted September 13, 2015 I know I am necro-ing this thread but I've been trying to find out of this indeed is functional and if anyone has ever found a way to isolate the enchantment gold value for player created items Link to comment Share on other sites More sharing options...
MotoSxorpio Posted September 13, 2015 Share Posted September 13, 2015 I know I am necro-ing this thread but I've been trying to find out of this indeed is functional and if anyone has ever found a way to isolate the enchantment gold value for player created itemsThe source is available in that mod... :) Link to comment Share on other sites More sharing options...
Recommended Posts