FallenTormentor Posted March 27, 2012 Share Posted March 27, 2012 I'm wondering if there is any way to script a weapon to give the player an enchantment/spell/power/shout/etc.? For example, I would like to add a script to a bow that gives me power to turn invisible for a few seconds (a la bow of shadows). Is this feasible? Has it already been done and I'm blind? Or am I trying for the impossible? Any input would be great, I would really like to learn how to do this kind of stuff myself but I find the scripting tutorials frustrating to understand. I kind of hope a talented programmer will have pity on me and give me a walkthrough because I really have no idea what in Oblivion I'm doing :confused: Link to comment Share on other sites More sharing options...
KingsGambit Posted April 8, 2012 Share Posted April 8, 2012 I'm wondering if there is any way to script a weapon to give the player an enchantment/spell/power/shout/etc.? For example, I would like to add a script to a bow that gives me power to turn invisible for a few seconds (a la bow of shadows). Is this feasible? Has it already been done and I'm blind? Or am I trying for the impossible? Any input would be great, I would really like to learn how to do this kind of stuff myself but I find the scripting tutorials frustrating to understand. I kind of hope a talented programmer will have pity on me and give me a walkthrough because I really have no idea what in Oblivion I'm doing :confused:Funny you ask this, though I realise it was asked a time ago. I've just finished (almost) my mod that utilises just this. This page on the Creation Kit wiki will be very useful. In my case, I utilised a modified version of the script on that page. To make it more suitable for you: Scriptname AddYOURSPELL extends ObjectReference {OnEquip Adds YOURSPELL} Spell Property YOURSPELL auto Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().AddSpell(YOURSPELL, abVerbose = false) EndIf EndEvent Event OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) Game.GetPlayer().RemoveSpell(YOURSPELL) EndIf EndEventSo you create your weapon (or modify an existing one) then attach this script to it. You can then set the property for the variable "YOURSPELL" (feel free to rename all instances as appropriate) from any available spell or ability. You can use an existing spell, or create your own. Either way, when in-game on equipping your "Weapon of AddSpell" the player will gain the spell/ability specified. On unequipping, the spell will be removed. If you already had the weapon in inventory/equipped on the save you loaded, you may need to drop and pick it up again for it to start working. One last thing...if you make a custom script, you will need to include it in an archive along with your mod. In the Creation Kit it's under File -> Create Archive. It will create a .bsa file which you should rar up with your .esp Link to comment Share on other sites More sharing options...
awesomeal360 Posted December 4, 2016 Share Posted December 4, 2016 Thanks for this. I know this is an old topic, but is there a way to add multiple spells to a weapon in Properties? Link to comment Share on other sites More sharing options...
jtull1127 Posted December 4, 2016 Share Posted December 4, 2016 (edited) Scriptname AddYOURSPELL extends ObjectReference {OnEquip Adds YOURSPELL}Spell Property YOURSPELL autoSpell Property YOURSPELL2 autoSpell Property YOURSPELL3 autoSpell Property YOURSPELL4 autoSpell Property YOURSPELL5 auto Event OnEquipped(Actor akActor)If (akActor == Game.GetPlayer())Game.GetPlayer().AddSpell(YOURSPELL, abVerbose = false)Game.GetPlayer().AddSpell(YOURSPELL2, abVerbose = false)Game.GetPlayer().AddSpell(YOURSPELL3, abVerbose = false)Game.GetPlayer().AddSpell(YOURSPELL4, abVerbose = false)Game.GetPlayer().AddSpell(YOURSPELL5, abVerbose = false)EndIfEndEventEvent OnUnequipped(Actor akActor)If (akActor == Game.GetPlayer())Game.GetPlayer().RemoveSpell(YOURSPELL)Game.GetPlayer().RemoveSpell(YOURSPELL2)Game.GetPlayer().RemoveSpell(YOURSPELL3)Game.GetPlayer().RemoveSpell(YOURSPELL4)Game.GetPlayer().RemoveSpell(YOURSPELL5)EndIfEndEvent there now it can give up to 5 and if you just keep copying the lines you can go on for as many spells as you want Edited December 4, 2016 by jtull1127 Link to comment Share on other sites More sharing options...
awesomeal360 Posted December 4, 2016 Share Posted December 4, 2016 Thank you! Link to comment Share on other sites More sharing options...
lofgren Posted December 4, 2016 Share Posted December 4, 2016 It's preferable to avoid using game.GetPlayer() more than once in a script. Scriptname AddYOURSPELL extends ObjectReference {OnEquip Adds YOURSPELL} Spell Property YOURSPELL auto Spell Property YOURSPELL2 auto Spell Property YOURSPELL3 auto Spell Property YOURSPELL4 auto Spell Property YOURSPELL5 auto Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) akActor.AddSpell(YOURSPELL, abVerbose = false) akActor.AddSpell(YOURSPELL2, abVerbose = false) akActor.AddSpell(YOURSPELL3, abVerbose = false) akActor.AddSpell(YOURSPELL4, abVerbose = false) akActor.AddSpell(YOURSPELL5, abVerbose = false) EndIf EndEvent Event OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) akActor.RemoveSpell(YOURSPELL) akActor.RemoveSpell(YOURSPELL2) akActor.RemoveSpell(YOURSPELL3) akActor.RemoveSpell(YOURSPELL4) akActor.RemoveSpell(YOURSPELL5) EndIf EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts