Jump to content

After some Scripting help


LittleMikey

Recommended Posts

Hi guys!

 

I'm trying to set up a simple mod that allows you to craft the Skeleton Key from the Thieves' Guild quest line.

 

I can get the item in game fine, but it breaks. I have looked through the quest logs and it seems that the game gives you a hidden Perk when you pick up the key in game, then removes that perk when you hand the key back in. So I'm trying to figure out how to add that perk without having to use console commands.

 

I've created a simple script, and attached it to the Skeleton Key item. I'm guessing this is where I'm going wrong, since I assumed that attaching a script to an item means it will be called whenever the item is created/used, but this does not seem to be the case.

 

My script is:

Scriptname MKYAddKeyPerk extends Quest

Perk Property TGSkeletonKeyPerk Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

Actor player = Game.GetPlayer()
	if akNewContainer == player
		if !(player.HasPerk(TGSkeletonKeyPerk))
			player.AddPerk(TGSkeletonKeyPerk)
			Debug.notification("The Skeleton Key fits perfectly into any lock")
		endif
	endif
EndEvent

 

Any help anyone can provide would be great!

 

*EDIT*

 

Managed to figure out the problem, I was calling Quest instead of Object Reference. Also for some reason the "Actor player" wasn't functioning correctly, so I just set them all to be Game.GetPlayer() and now it works!

 

Not sure how to delete the topic, so I'll just leave it here incase anyone else gets the same problem!

Edited by littlemikey
Link to comment
Share on other sites

Must compare an ObjectReference (new container) with the player cast as an ObjectReference:

 

Scriptname MKYAddKeyPerk extends ObjectReference

Perk Property TGSkeletonKeyPerk Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
       
       Actor player = Game.GetPlayer()
               if akNewContainer == player as ObjectReference
                       if !player.HasPerk(TGSkeletonKeyPerk)
                               player.AddPerk(TGSkeletonKeyPerk)
                               Debug.notification("The Skeleton Key fits perfectly into any lock")
                       endif
               endif
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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