How does one advance a quest on item pickup?

Post » Tue Jun 19, 2012 11:23 am

I'm trying to make an item that when picked up, advances the stage. They way I've tried so far was to put a script on it. This is the script (it also enables a triggerbox for later in the quest).

Scriptname TBJSchivver extends ObjectReference Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    TBJ01.SetStage(40)    AltarBox.enable()endEventQuest Property TBJ01  Auto ObjectReference Property AltarBox  Auto Alias Property AltarBoxAlias  Auto 

It compiles just fine, but doesn't seem to do anything. Anyone know whats wrong?
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Tue Jun 19, 2012 11:56 pm

Using OnItemAdded works but it's not ideal as there are a couple of conditions which it won't catch.
You should do as below instead:

Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer)  if (newContainer == Game.GetPlayer())    TBJ01.SetStage(30)    AltarBox.enable()  endifEndEvent

Also make sure that you have something like the following on stage 40 of your quest:
SetObjectiveCompleted(30)SetObjectiveDisplayed(40)

Without this it will seem like nothing happens because your quest would move to stage 40 silently.

Line #2 makes sure that it's only triggered if the item is moved into the players inventory (as opposed to a chest or NPC).
User avatar
Tyler F
 
Posts: 3420
Joined: Mon Aug 27, 2007 8:07 pm

Post » Tue Jun 19, 2012 4:18 pm

if you attached this to the item you want to pick up to trigger, it wont work.



here's an example:

i want to pick up a cabbage, and have it start CabbageQuest.

attaching the OnItemAdded to the cabbage is just letting the game know, that when the cabbage gets any item added to it, the quest will start.


what you could do instead is create a player alias in your quest, and attach this script to the player alias. that way when the game is listening for OnItemAdded, it will look for the item added to the player. you should also specify which item you are looking for and consider using a filter or else the script will trigger every single time any item is added to your inventory.
User avatar
Rik Douglas
 
Posts: 3385
Joined: Sat Jul 07, 2007 1:40 pm

Post » Wed Jun 20, 2012 1:29 am

Thanks guys.
Using OnItemAdded works but it's not ideal as there are a couple of conditions which it won't catch. You should do as below instead:
 Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer) if (newContainer == Game.GetPlayer()) TBJ01.SetStage(30) AltarBox.enable() endif EndEvent 
Also make sure that you have something like the following on stage 40 of your quest:
 SetObjectiveCompleted(30) SetObjectiveDisplayed(40) 
Without this it will seem like nothing happens because your quest would move to stage 40 silently. Line #2 makes sure that it's only triggered if the item is moved into the players inventory (as opposed to a chest or NPC).

Thank you, that worked wonderfully.
User avatar
Sharra Llenos
 
Posts: 3399
Joined: Wed Jan 17, 2007 1:09 pm


Return to V - Skyrim