Jump to content

Enchantment to open a container


Rimtuuk

Recommended Posts

Hello all,

 

I am working on a mod that links a piece of jewelry to a container. You equip the item and it opens the container. I have gotten the container in a cell and created the enchantment and placed it on a ring but nothing happens. I have the enchantment set to be a script and script to activate the container but that is not working. Here is what I have for my script:

objectreference property Dimestorage (name of the container) auto    function OnEffectStart(Actor akTarget, Actor akCaster)        DimeStorage.Activate(akTarget as objectreference, true)            akTarget.PlaceAtMe(Dimestorage)endFunction

I am assuming that this can even be done. If it can't please let me know.

 

Thanks

Edited by Rimtuuk
Link to comment
Share on other sites

I would skip the enchantment. Enchantments are meant for effects that last for the duration that the item is equipped. Just script an OnEquipped event. Here is a working example:

 

 

Scriptname abim_IMS_SatchelEquipScript extends ObjectReference  

ObjectReference 	Property 	TheContainer 	= None	Auto
Actor 				Property 	PlayerRef 		= None	Auto
FormList 			Property 	abim_IMS_RepItemList 	Auto
Int 				Property 	RepItemIndex 			Auto

Event OnEquipped(Actor akActor)
	If akActor == PlayerRef
		Game.DisablePlayerControls(False, False, False, False, False, True)	; Exit menu
		Utility.Wait(0.01)
		TheContainer.Activate(PlayerRef)									; activate container interface
		Utility.Wait(0.01) 
		Game.EnablePlayerControls(False, False, False, False, False, True)	; Reenable menu		
		If abim_IMS_RepItemList.GetAt(RepItemIndex) as Armor 				; un-equip only if an armor item
			PlayerRef.UnequipItem(abim_IMS_RepItemList.GetAt(RepItemIndex), False, True)
		EndIf
	EndIf
EndEvent 

With the mod that this is from, I have multiple objects which can be equipped to open different containers. Thus I use a formlist for those items which fall in the armor category to make them unequip. For your use you can get away with just referencing the individual item.

 

 

 

If you really want to go the enchantment route, perhaps this working example might shed some light.

 

 

Scriptname abim_IMS_SatchelEatEffectScript extends activemagiceffect  

ObjectReference 	Property 	TheContainer 	= None	Auto
Actor 				Property 	PlayerRef 		= None	Auto
FormList 			Property 	abim_IMS_RepItemList 	Auto
Int 				Property 	RepItemIndex 			Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Game.DisablePlayerControls(False, False, False, False, False, True)
	Utility.Wait(0.01)
	TheContainer.Activate(PlayerRef)
	Utility.Wait(0.01) 
	Game.EnablePlayerControls(False, False, False, False, False, True)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	If 	PlayerRef.GetItemCount(abim_IMS_RepItemList.GetAt(RepItemIndex)) <= 0
		PlayerRef.AddItem(abim_IMS_RepItemList.GetAt(RepItemIndex), 1, true)
	EndIf
EndEvent 

Now the items which run this are technically potions/poisons and they needed a short duration. The objects were also 'consumed' and have to be given back to the player. But on a piece of jewelry as an enchantment you shouldn't need to do that.

 

 

 

Hope that helps shed some light...

Link to comment
Share on other sites

Thanks so much for your help Isharameradin. I applied the OnEquipped event script to the ring I was using and changed the "The container" to the correct ID of the container that I am using. The script compiled without any errors but when I equip the ring nothing happens.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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