Theweasels Posted June 2 Share Posted June 2 SKSE has a number of functions to mess with enchantments. GetEnchantment, SetEnchantment, and even CreateEnchantment. However, they all seem to only work with Weapon and Armor enchantments, but not Staff Enchantments. Edit: I was wrong, it's only the CreateEnchantment that does not work with StaffEnchantments. Is there any way to create a Staff Enchantment? I'm trying to create a mod that allows you to change the spell (aka staff enchantment) on a staff in your right hand by taking it from the spell or staff in your left hand. Mostly because there are some really cool staff models you can download but I want to be able to use all my mod-added spells on those staffs without needing to create a hundred custom items in a patch. I found a similar thread from years ago, but nobody ever answered his question: Link to comment Share on other sites More sharing options...
Theweasels Posted June 2 Author Share Posted June 2 Weapon sourceStaff = Caster.GetEquippedWeapon(true) Weapon targetStaff = Caster.GetEquippedWeapon(false) targetStaff.SetEnchantment(sourceStaff.GetEnchantment()) This basic sample seems to work, taking the enchantment from the staff in your left hand and copying it onto the staff on your right hand. The new enchantment does not take effect until the staff is unequipped. However, this modifies the enchantment on the base object, which means all other copies of the staff will have the enchantment updated as well. Not a huge problem if you are changing the enchantment on a modded staff that you have the only copy of, but it a huge problem if you change the enchantment on something like a Falmer staff, as all future staff-wielding falmer will have your modified version. I don't suppose there is a way to make a new base object in skse? Or a way to copy the model of one staff to another, so I could make a single base object that copies the appearance of one staff and the enchantments of another? Link to comment Share on other sites More sharing options...
Theweasels Posted June 2 Author Share Posted June 2 I now have this snippet, which is attached to a spell. The spell copies the appearance of the left staff to the right staff if you are sneaking, and copies the enchantment if you are standing. Then unequips and equips the staff so that the changes take effect. Weapon sourceStaff = Caster.GetEquippedWeapon(true) Weapon targetStaff = Caster.GetEquippedWeapon(false) If Caster.IsSneaking() targetStaff.SetModelPath(sourceStaff.GetModelPath()) targetStaff.SetIconPath(sourceStaff.GetIconPath()) targetStaff.SetMessageIconPath(sourceStaff.GetMessageIconPath()) targetStaff.SetEquippedModel(sourceStaff.GetEquippedModel()) targetStaff.SetWorldModelPath(sourceStaff.GetWorldModelPath()) Else targetStaff.SetEnchantment(sourceStaff.GetEnchantment()) EndIf Game.GetPlayer().UnequipItem(targetStaff) Game.GetPlayer().EquipItem(targetStaff) This is progress, but I still have two issues: These SKSE functions do not persist after the game closes. I have done some searching and found I can create a Quest script to re-apply them on game load, so I should be able so solve this with other resources. The Max item charge is not transferred. I tried using the SetItemMaxCharge and GetItemMaxCharge functions on the item ObjectReferences, but for some reason neither function seems to be working on the staves. The Get function returns 0 and the Set function does nothing. If I can't find a solution for this, I will probably just make a new base object with the charge manually set to the highest vanilla charge. Link to comment Share on other sites More sharing options...
PeterMartyr Posted June 2 Share Posted June 2 A lot of SKSE functions have no persistence unless they are directed at the player.. FYI player has persistence NPC do not for example, and shock horror also has no persistence on unload then loading again, in between the player loading the game, you have not done enough testing have you? There, I save you some heartache, you require two maintenance scripts The persistence problems is an OFF LOADING problem, and reload, whether in game or at player load games (matters NOT) back in it original state, where it manifest it self is a hint at where to apply the fix EDIT the reason for above is, if you need to save the current state, you do it at offLoad event, then apply it onLoad or playLoadGame, for proper persistence sake, but if rough enough is good enough, ignore offloading and use the default state on load Link to comment Share on other sites More sharing options...
Recommended Posts