Jump to content

Weapons give player spells


FallenTormentor

Recommended Posts

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

  • 2 weeks later...

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
EndEvent

So 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

  • 4 years later...

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())
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)
EndIf
EndEvent

Event 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)

EndIf
EndEvent

 

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 by jtull1127
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...