FrankFamily Posted November 27, 2018 Share Posted November 27, 2018 (edited) The first function is in the armor script, the other in the wornobject script. You'll need to either import WornObject and call normally or WornObject.SetEnchantment(etc) In the same manner that you do Game.GetPlayer() and not just GetPlayer() Event won't give you a compiler error since you'd be declaring it, but it would never be received because it's not an event. So: Scriptname _AceTestingScript extends ActiveMagicEffect Enchantment Property MyEnchantment Auto Event OnEffectStart(Actor akCaster, Actor akTarget) WornObject.SetEnchantment(Game.GetPlayer(), 0, 0x00000200, MyEnchantment) EndEvent Edited November 27, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
Elias555 Posted November 27, 2018 Author Share Posted November 27, 2018 (edited) Perfect, thank you! I went with the second one and it applies the enchantment only to the particular shield. Same visual problem, but I'm glad that part's finally done. Edit: I now have to manually unequip and re-equip for the enchantment to take place. This doesn't work for some reason. fml. Scriptname _AceTestingScript extends ActiveMagicEffect Enchantment Property MyEnchantment Auto Event OnEffectStart(Actor akCaster, Actor akTarget) WornObject.SetEnchantment(Game.GetPlayer(), 0, 0x00000200, MyEnchantment, 1000) Armor EquippedShield = Game.GetPlayer().GetEquippedShield() Utility.Wait(0.1) Game.GetPlayer().UnequipItem(EquippedShield, False, False) Game.GetPlayer().EquipItem(EquippedShield, False, False) EndEvent Edited November 27, 2018 by Elias555 Link to comment Share on other sites More sharing options...
Elias555 Posted November 28, 2018 Author Share Posted November 28, 2018 (edited) When using EquipItem to equip a custom player-enchanted item to any actor, a bug will prevent the magic effects of that enchantment from taking effect.WHY! Is there a workaround?There's no RemoveEnchantment function either. What have I got myself into? Scriptname _AceTestingScript extends ActiveMagicEffect Enchantment Property MyEnchantment Auto Event OnEffectStart(Actor akCaster, Actor akTarget) WornObject.SetEnchantment(Game.GetPlayer(), 0, 0x00000200, MyEnchantment, 1000) Armor EquippedShield = Game.GetPlayer().GetEquippedShield() Game.GetPlayer().UnequipItemEX(EquippedShield, 2, False) EndEvent Just found UnEquipItemEx. Not sure how it works because it's not unequiping the shield but it is 'refreshing' the enchantment so now it functions again! Still no visual or method to remove the enchantment. For disenchanting I tried attaching this script to the enchantment but nothing fires. Scriptname _AceTestScript2 extends ObjectReference Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) Armor SelfShield = Self.GetBaseObject() as Armor if akNewContainer && !akOldContainer akNewContainer.Additem(SelfShield, 1) akNewContainer.RemoveItem(Self, 1) EndIf EndEvent Event OnEquipped(Actor akActor) Debug.Notification("We were equipped by the player!") EndEvent Edited November 28, 2018 by Elias555 Link to comment Share on other sites More sharing options...
FrankFamily Posted November 28, 2018 Share Posted November 28, 2018 (edited) Check the log, Self.GetBaseObject() is most likely failing if that object is in inventory, self will be an invalid reference then, unless the item is persistent which I'm not sure you'd want it to be. In any case you said this was in the enchantment's magic effect? Those events won't be received there. They would have to be in the armor form which is the item that changes container and is equipped. The enchantment runs on the player so you get events from the player actor not the item it belongs to. Edited November 28, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
Elias555 Posted November 28, 2018 Author Share Posted November 28, 2018 The enchantment runs on the player so you get events from the player actor not the item it belongs to.What, how? A quest alias?Any ideas on how to get rid of the enchantment when the spell ends? I was hoping that I could make a switch but If you or anyone know a better method I'd like to know. Link to comment Share on other sites More sharing options...
FrankFamily Posted November 28, 2018 Share Posted November 28, 2018 (edited) What I meant is that in the script of a magic effect within an armor enchantment (which should extend activemagiceffect) you receive events from the activemagiceffect like oneffectstart and you also receive events from the player this magic effect is affecting (in armor the one wearing it) like OnHit, OnObjectEquipped, etc. So it's a bit weird that you said you have attached to the enchantment an script extending object reference, an enchantment is not an obect reference, with OnContainerChanged and OnEquipped events that wouldn't be received in the enchantment. No idea how you could remove it, this is an area I haven't experimented with. Perhaps make a blank enchantment and set that at the end? Maybe you can pass none as the enchantment and that removes it, can't tell. Edited November 28, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
Elias555 Posted November 28, 2018 Author Share Posted November 28, 2018 (edited) I tried both and that was the last thing I tried so I posted that but neither worked.Passing none compiles but causes CTD. You can't enchant an already enchanted item, so a blank enchantment won't work. Edit: I think I'm getting somewhere with this. It gets removed but not replaced at all. I did make sure to have the AddItem first. Scriptname _AceTestingScript2 extends ActiveMagicEffect Armor EquippedShield Event OnEffectStart(Actor akCaster, Actor akTarget) EquippedShield = Game.GetPlayer().GetEquippedShield() Armor BaseShield = Game.GetPlayer().GetBaseObject() as Armor ;ObjectReference BaseShield = Game.GetPlayer().GetBaseObject() as ObjectReference While Game.GetPlayer().GetEquippedShield() == EquippedShield Debug.Notification("shield is equipped") If Game.GetPlayer().GetEquippedShield() != EquippedShield Game.GetPlayer().Additem(BaseShield, 1) Game.GetPlayer().RemoveItem(EquippedShield, 1) EndIf EndWhile EndEvent BaseShield returns with None. Damn, I really thought that was going to work. Edited November 28, 2018 by Elias555 Link to comment Share on other sites More sharing options...
FrankFamily Posted November 28, 2018 Share Posted November 28, 2018 (edited) This line is wrong: Game.GetPlayer().GetBaseObject() as Armor the player is not armor so it results in none. Equippedshield.GetBaseObject() as Armor is what I think you wanted to do.Definitely not objref as you have in the comment. why the while instead of running that oneffectfinish? Edited November 28, 2018 by FrankFamily Link to comment Share on other sites More sharing options...
FrankFamily Posted November 28, 2018 Share Posted November 28, 2018 Wait, no, GetEquippedShield gives you armor (the form, not the particular instance) you don't need getbaseobject's at all.Going off your last version, what about this: Scriptname _AceTestingScript extends ActiveMagicEffect Enchantment Property MyEnchantment Auto Armor BaseShield Event OnEffectStart(Actor akCaster, Actor akTarget) BaseShield = Game.GetPlayer().GetEquippedShield() WornObject.SetEnchantment(Game.GetPlayer(), 0, 0x00000200, MyEnchantment, 1000) Game.GetPlayer().UnequipItemEX(EquippedShield, 2, False) ;you said this refreshed the enchantment EndEvent Event OnEffectFinish(Actor akCaster, Actor akTarget) Game.GetPlayer().RemoveItem(BaseShield, 1) Game.GetPlayer().Additem(BaseShield, 1) ;this is wrong is the player has multiple instances of this shield, it might not remove the enchanted one. EndEvent Link to comment Share on other sites More sharing options...
Elias555 Posted November 29, 2018 Author Share Posted November 29, 2018 (edited) why the while instead of running that oneffectfinish?This is in the enchantment effect script, the effect will never finish.I need to make a few changes to your script to get it to compile. Give me a sec. Okay, I see what was wrong now. I shouldn't have combined your script with mine like that. This works to 'remove' the enchantment if unquipped but not if player equips something else. I also don't like that there's a while loop. Scriptname _AceTestingScript2 extends ActiveMagicEffect Armor BaseShield Event OnEffectStart(Actor akCaster, Actor akTarget) BaseShield = Game.GetPlayer().GetEquippedShield() Armor EquippedShield = Game.GetPlayer().GetEquippedShield() While Game.GetPlayer().GetEquippedShield() == EquippedShield Debug.Notification("shield is equipped") If Game.GetPlayer().GetEquippedShield() != EquippedShield Game.GetPlayer().RemoveItem(EquippedShield, 1) Game.GetPlayer().Additem(BaseShield, 1) EndIf EndWhile EndEvent Now here's the first script, the applier. When the spell is finished the swap is made but I can't get the shield to re-quip. Scriptname _AceTestingScript extends ActiveMagicEffect Enchantment Property MyEnchantment Auto Armor EquippedShield Armor BaseShield Event OnEffectStart(Actor akCaster, Actor akTarget) WornObject.SetEnchantment(Game.GetPlayer(), 0, 0x00000200, MyEnchantment, 1000) BaseShield = Game.GetPlayer().GetEquippedShield() EquippedShield = Game.GetPlayer().GetEquippedShield() Game.GetPlayer().UnequipItemEX(EquippedShield, 2, False) EndEvent Event OnEffectFinish(Actor akCaster, Actor akTarget) Game.GetPlayer().RemoveItem(EquippedShield, 1, True) Armor ReplacementShield = Game.GetPlayer().Additem(BaseShield, 1, True) Game.GetPlayer().EquipItemEX(ReplacementShield, 2, False) ;NOT WORKING EndEvent STILL NO VISUALS! Edited November 29, 2018 by Elias555 Link to comment Share on other sites More sharing options...
Recommended Posts