Jump to content

Modding Question - amulet that provides a spell


Recommended Posts

Posted

I have a creation kit question. Does anyone know if there is a way to create an item in Creation Kit such that it allows the wearer to cast a particular spell while it is worn? Basically I want to create an amulet, when equipped, will allow the player to cast a custom spell.

Posted

You can do it with a small trick.

 

Create your Amulet.

Create your spell.

Add a ReferenceAlias to your Quest, and assign it to the player.

Add a script to the RefAlias and add something like this inside:

Armor Property myAmulet Auto
Spell Property mySpell Auto
Actor Property PlayerRef Auto

Event OnInit()
  PlayerRef.AddInventoryEventFilter(myAmulet)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  if !PlayerRef.HasSpell(mySpell)
    PlayerRef.addSpell(mySpell, false)
  endIf
  PlayerRef.equipSpell(mySpell, 1) ; Right hand
EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
  if PlayerRef.getItemCount(myAmulet)==0
    PlayerRef.unEquipSpell(mySpell, 0) ; Both hands, just in case
    PlayerRef.unEquipSpell(mySpell, 1)    PlayerRef.removeSpell(mySpell, false)
EndEvent

And you are done.

 

The previous script enables the spell as soon as you get the amulet in your inventory.

 

If you want it to happen when you actually wear the amulet, just replace the events with:

 

 

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

 

and

 

 

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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