Jump to content

[LE] Need help advancing quest stage upon item pick up


Recommended Posts

I'm creating a quest mod, and I need to advance the quest when an item is picked up (it is not an essential item, you can sell it or drop it after).

I've looked online for some scripts to make this happen but nothing really works. Here's what I've tried already:

Scriptname HoDKhajiitiAmuletScript extends ObjectReference  

Actor Property PlayerREF Auto
Quest Property HoDBloodEx  Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF
		HoDBloodEx.SetStage(30)
		GoToState("Taken")
	EndIf
EndEvent
 
State Taken
	; Do nothing
EndState

The item ID is HoDKhajiitiAmulet. HoDKhajiitiAmuletScript is a script placed on the item.

Using the above script, there are no compiler errors but nothing happens when I pick up the amulet in-game.

Scriptname HoDKhajiitiAmuletScript extends ObjectReference  

Actor Property PlayerREF Auto
Quest Property HoDBloodEx  Auto

Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer) if (newContainer == Game.GetPlayer()) HoDBloodEx.SetStage(30) EndIf EndEvent

I looked up my question online and this is a script I found some others had said worked for them. But I get the following compiler errors when I use it:

Starting 1 compile threads for 1 files...
Compiling "HoDKhajiitiAmuletScript"...
D:\SteamF\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\HoDKhajiitiAmuletScript.psc(6,85): no viable alternative at input 'if'
D:\SteamF\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\HoDKhajiitiAmuletScript.psc(0,0): error while attempting to read script HoDKhajiitiAmuletScript: Object reference not set to an instance of an object.
No output generated for HoDKhajiitiAmuletScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on HoDKhajiitiAmuletScript

Can anyone help me fix either of the scripts, or provide an alternative? It would be much appreciated.

Link to comment
Share on other sites

What you have should definitely work, ie:

 

Scriptname HoDKhajiitiAmuletScript extends ObjectReference

Quest Property HoDBloodEx Auto

Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer)
If (newContainer == Game.GetPlayer())
HoDBloodEx.SetStage(30)
Endif
EndEvent

 

Check your syntax (or copy the above) and that you have filled the quest property correctly

Link to comment
Share on other sites

Is the amulet in a quest alias?

 

Personally I prefer to manage things like this via a player alias in the relevant quest, using OnItemAdded with an inventory filter to screen out everything but the particular item I'm after. That way you don't have to deal with how containers and objectreferences that move into them interact.

Link to comment
Share on other sites

The amulet doesn't have to be a quest alias unless you need the quest to use it for something else (eg set as a quest item).

 

Its a pretty standard script in Skyrim because many quests require the player to find something and move the quest along when its found.

Link to comment
Share on other sites

What you have should definitely work, ie:

 

Scriptname HoDKhajiitiAmuletScript extends ObjectReference

 

Quest Property HoDBloodEx Auto

 

Event OnContainerChanged(ObjectReference newContainer, ObjectReference oldContainer)

If (newContainer == Game.GetPlayer())

HoDBloodEx.SetStage(30)

Endif

EndEvent

 

Check your syntax (or copy the above) and that you have filled the quest property correctly

Thanks. I put it in and it worked. Must have been spacing or a syntax error.

Link to comment
Share on other sites

  • 1 year later...

I'm creating a quest mod, and I need to advance the quest when an item is picked up (it is not an essential item, you can sell it or drop it after).

I've looked online for some scripts to make this happen but nothing really works. Here's what I've tried already:

Scriptname HoDKhajiitiAmuletScript extends ObjectReference  

Actor Property PlayerREF Auto
Quest Property HoDBloodEx  Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF
		HoDBloodEx.SetStage(30)
		GoToState("Taken")
	EndIf
EndEvent
 
State Taken
	; Do nothing
EndState

 

I'm surprised nobody mentioned your "Taken" state is broken. Since you declare the OnContainerChanged in the empty state, it will always run, unless the state you're in has an override. When you change state to taken, since the event does not exist there, it will re-run in the empty state. You need to either make an auto state that holds the event (my personal preference), or put a blank event in the Taken state like this:

State Taken
    Event OnContainerChanged (ObjectReference akNewContainer, ObjectReference akOldContainer)
        ; Do nothing
    EndEvent
EndState

Also, did you assign the properties in CK to point to the proper targets? And are you testing with a save that has never seen the mod before?

 

If you're using a save which previously had the item created (even if you never saw it or interacted with it) from before the script was attached, it will be broken. It will not get the script until the item is respawned from a new save that never saw it before. Similar issues if the script was missing assignment of properties and you load a save that had bad assignments. They don't update unless a new object is created.

 

So for testing you should always use a dummy save that has never seen the mod so it's clean. Depending on the circumstances of the mod, you might be able to get away with just COCing into the area with the object you're testing and interact with it without doing any other prerequisite stuff.

Edited by BigAndFlabby
Link to comment
Share on other sites

  • Recently Browsing   0 members

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