Jump to content

[LE] Quest Help! Keeping track of collected items.


Recommended Posts

SOLVED!

 

Hey everyone!

 

I am working on a new quest in the CK where the player has to collect 10 Hagraven claws and return them to the quest giver. The only part of this quest build I am unfamiliar about is how to keep track of what I have collected and display that in the journal. Check out this link here for a vanilla Skyrim quest as an example. At the 1:00 mark you'll see Gather 10 bear pelts for Temba Wide-Arms (3/10). How do I keep track of the claws I've collected so that when I pick up another one it updates the (3/10) part?

Thanks in advance for any help/direction here! :happy:

Edited by wesk1288
Link to comment
Share on other sites

As far as I remember:

 

1. Create two globals, myGlobalCurrent and myGlobalTotal, both of variable type 'short'. myGlobalTotal should have 'Constant' checked. myGlobalCurrent should be equal 0, while myGlobalTotal should be equal 10 (or whatever the amount of claws you want to collect).

 

2. Write (<Global=myGlobalCurrent>/<Global=myGlobalTotal>) in your objective field.

 

3. Add the two globals on your quest's data tab under 'Text Display Globals'.

 

4. Create an alias and fill it with the player reference. Add a script with the following;

quest property myQuest auto
globalvariable property myGlobalCurrent auto
globalvariable property myGlobalTotal auto
ingredient property HagravenClaw auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

   if akBaseItem == HagravenClaw

      if MyQuest.ModObjectiveGlobal(aiItemCount, myGlobalCurrent, ObjectiveNumber, myGlobalTotal.value) ; replace "ObjectiveNumber" with whatever number your objective has

           SetStage(CompleteStage) ; replace "CompleteStage" with whatever stage you want to set when you've collected all the hagraven claws 

      endif
   endif
EndEvent

Remember to fill the properties.

 

That should be it. Hope it works for you :)

Link to comment
Share on other sites

Hey Wormple, thanks for the help! I've followed all of your instructions, compiled my script successfully and tested this out in game. Everything looks correct with my global variables. The issue I am getting in the game is that my number is not increasing when I pick up the item. The objective text still reads (0/10) no matter how many claws I pick up. I believe my issue is with how I am referencing my player in the Quest Alias tab. I am selecting the unique actor fill type and then finding "player" in the drop-down list. Is that correct? I am attaching my script to this reference alias page as well. I even tried referencing the player inventory instead of the player but that didn't work. It actually caused the quest not to trigger at all. I feel I am close to getting this. Thanks for all the help!

Link to comment
Share on other sites

About referencing the player through the quest alias tab - I did some digging and found this on the bottom of the wiki page...

 

  • To add the Player as a Reference, select Specific Reference, click Select Forced Reference, pick (any) for cell and find the Player reference

 

Oddly enough, even with my script attached to this specific reference of the player I still don't have the item count going up.

Link to comment
Share on other sites

Well, I'm not sure what's wrong - it's been a while since I worked with this. You're sure that myGlobalCurrent hasn't "Constant" checked? Because that would mean, it can't change from 0.

 

Otherwise, try adding a debugging line to your script, inside the 'if' statement:

int CurrentNumber = myGlobalCurrent.value
debug.notification("You have gained " + aiItemCount + " hagraven claws, and myGlobalCurrent has updated to " + CurrentNumber)

See if this in-game notification shows up at all, and if it shows you the expected values of aiItemCount and myGlobalCurrent.

Link to comment
Share on other sites

No problem, I appreciate the help. I double checked my Globals and they are set correctly. I'll do some more debugging when I get home today. I did a little last night and I am worried that I may have added my script in the wrong place. I added a debug.notification message after the if statement and didn't see anything in game. I added my script under the quest alias tab on the same page I set up my specific reference to the player.

Link to comment
Share on other sites

It is correct that the script should be added to the player alias, so the problem isn't that.

 

Oh, yeah, actually, the debug message shouldn't be inside the if statement as I said. Mistake on me. Then the message will only show if you actually reach the objective of 10 hagraven claws.

 

Add the debug line after the endIf line instead.

 

Oh, yeah, and make sure you don't pick up too many items at once - this might cause some issues. I forgot about this too, but to avoid problems with overloading Skyrim's script engine, you should add an event filter to your script, something like this:

Event OnInit()

  AddInventoryEventFilter(HagravenClaw)

EndEvent
Edited by wormple12
Link to comment
Share on other sites

Well, no luck with my debugging sadly! I decided to look at a quest in the CK with similar scripting using global variables to see if it revealed anything. If you search through the Quests category in the CK for "FreeformRiften04" this quest is set up to achieve what I am wanting to do basically, just with a lot more ingredients to find. As I compared things I noticed this bit of code under its "quests stages" tab at stage 20....

;Ingun assigned herb quest to Player
SetObjectiveDisplayed(10,1)
SetObjectiveDisplayed(20,1)
SetObjectiveDisplayed(30,1)
pFFR04QS.Nirncount()
pFFR04QS.Deathbellcount()
pFFR04QS.Nightshadecount()

If you go all the way to the right to the Scripts Tab of the quest I noticed a "FFR04QuestScript". In that script, it looks like it's declaring what Nirncount(), Deathbellcoutnt(), and Nightshadecount() contain. Just wondering if this is a component I am missing?

 

I am noticing one other possible error/variation in my scripting that differs from your original script given. Here's what I currently have... (This script compiles successfully and all properties have been added)

Scriptname ItemCountGlobalScript   

quest property myQuest auto
globalvariable property myGlobalCurrent auto
globalvariable property myGlobalTotal auto
ingredient property HagravenClaw auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

   if akBaseItem == HagravenClaw

	 if MyQuest.ModObjectiveGlobal(aiItemCount, myGlobalCurrent, 10, myGlobalTotal.value) ;
           	
		myQuest.SetStage(20) ;

      endif
   endif
EndEvent

The SetStage line at the end is what differs. Whenever I try to compile my script with SetStage(20) instead of what is there currently I get an error message that says, "SetStage is not a function or does not exist.

Edited by wesk1288
Link to comment
Share on other sites

Yep, I missed the myQuest in front of SetStage, my bad. But actually, now that I think of it, you don't need to have a quest property at all, you can just use GetOwningQuest().

 

Also, your script should extend ReferenceAlias, like this:

Scriptname ItemCountGlobalScript extends ReferenceAlias

And remember to add that inventory event filter I mentioned.

 

So your script should look like this:

Scriptname ItemCountGlobalScript extends ReferenceAlias

globalvariable property myGlobalCurrent auto

globalvariable property myGlobalTotal auto

ingredient property HagravenClaw auto

Event OnInit()

  AddInventoryEventFilter(HagravenClaw)

EndEvent


Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

   if akBaseItem == HagravenClaw

      if GetOwningQuest().ModObjectiveGlobal(aiItemCount, myGlobalCurrent, 10, myGlobalTotal.value) ;

           GetOwningQuest.SetStage(20) ;

      endif

      int CurrentNumber = myGlobalCurrent.value
      debug.notification("You have gained " + aiItemCount + " hagraven claws, and myGlobalCurrent has updated to " + CurrentNumber)

   endif

EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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