Jump to content

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


Recommended Posts

  • 1 year later...

UPDATED!!!! Fully functioning item collection quest

 

I know it's been a long while since this thread was even active but It only seemed right to share my final solution to this quest to help anyone out there that might need it. :happy: A huge thanks to wormple for getting the majority of this up and running a while back. Here was my final solution for a fully working "item collection" style quest. A great quest to look at in the Creation Kit is "FreeFormRiften04." I referenced this often to see how it handled everything.

 

 

1.) Here's the final script attached to my player reference, in the quest aliases tab:

Scriptname ItemCountGlobalScript extends ReferenceAlias

TM_HuntforHagravensQuestScript property pHFHQS auto

globalvariable property myGlobalCurrent auto

globalvariable property myGlobalTotal auto

ingredient property HagravenClaw auto

Quest Property TM_Quest_HuntforHagravens  Auto

Event OnInit()
	
		AddInventoryEventFilter(HagravenClaw)

EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	
	if GetOwningQuest().GetStage() == 10;
		
		if akBaseItem == HagravenClaw
			pHFHQS.Clawcount()

			endif

		endif

EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)

	if GetOwningQuest().GetStage() == 10;

			if akBaseItem == HagravenClaw
				pHFHQS.Clawcount()

		endif

	endif

EndEvent

If the Quest is at Stage 10 (where my quest giver gives you the quest) then It checks to see if a Hagraven claw is added to or removed from my inventory. Without that line of code, the first time the player picked up a hagraven claw the quest would activate. The OnItemRemoved was added because otherwise you could start the quest, find one hagraven claw and then drop it from your inventory over and over to keep adding to the "myGlobalCurrent" count. You'll notice the "pHFHQS.Clawcount()". That code is really what made this come together and here's how that works....

 

 

 

2.) Under the scripts tab I added a new script:

Scriptname TM_HuntforHagravensQuestScript extends Quest  

Quest Property TM_Quest_HuntforHagravens  Auto  

GlobalVariable Property myGlobalCurrent  Auto  

GlobalVariable Property myGlobalTotal  Auto  

Ingredient Property HagravenClaw  Auto  

Function Clawcount()

	float CurrentCount = Game.GetPlayer().GetItemCount(HagravenClaw)

	myGlobalCurrent.Value = CurrentCount
	UpdateCurrentInstanceGlobal(myGlobalCurrent)
		if CurrentCount >= 10
		TM_Quest_HuntforHagravens.SetObjectiveCompleted(10)
		TM_Quest_HuntforHagravens.SetStage(20)
		TM_Quest_HuntforHagravens.SetObjectiveDisplayed(20)
	elseif CurrentCount < 10
		TM_Quest_HuntforHagravens.SetStage(10)
		TM_Quest_HuntforHagravens.SetObjectiveDisplayed(10, true, true)
	endif

endFunction

I basically ripped this function right out of the FreeFormRiften04 quest and formatted it to fit mine. The issue I was having before this function was added was that if the player had any Hagraven claws on him before the quest started, then once the quest did start at Stage 10, my quest objective would still say, Find Hagraven Claws (0/10). It wouldn't account for what was already in my inventory. So regardless if I had 2 or 20 my global variable needed to be updated so this handled that and advanced the quest depending on the amount I had collected.

3.) Now, for the part that took me longer than I'd like to admit... Going back to the first script attached to the player reference alias. The second line "TM_HuntforHagravensQuestScript property pHFHQS auto" is vital.

Without that property there the pHFHQS.Clawcount() couldn't be called. To add this property I had to type it in to the source code, once compiled I was able to edit the property value and add my quest script. Check out "Getting Properties of a Quest Script" here for more info https://www.creationkit.com/index.php?title=Variables_and_Properties.

 

4.) Almost there! Back into my scripts tab once again I added the TM_HuntforHagravensQuestScript property pHFHQS auto property to the Quest Fragment Script (the script the CK auto-generates for your quest). Once again I had to type this in in source, once compiled, then I could edit via the properties tab and fill the value with my quest script (it was the only thing in the drop down to select for me). Step 5 explains why I did this.

 

 

 

5.) Last but not least. Under my quest stages tab on stage 10 I added this into my papyrus fragment.

SetObjectiveDisplayed(10)
pHFHQS.Clawcount()

If I hadn't done step 4 and added that property to the main quest script, the pHFHQS.Clawcount() wouldn't have worked. For my scenario, stage 10 is where the quest is given to the player and more importantly where the objective display (Find Hagraven Claws <0/10>) is triggered. That's why I added that code here. With this in place, if you have say, 6 hagraven claws in your inventory already and then you start the quest via the quest giver. Immediately after the objective (find Hagraven Claws <0/10>) displays it will update with the new correct "current" amount of (Find Hagraven Claws <6/10>).

 

 

 

6. Also, final note, I created a special dialogue option for if the player already had 10 claws in their inventory. I Just added a simple condition to check the amount of claws the player had, if it was >= 10 then the dialogue option would display to them after saying "Yes" to the quest.


I hope this helps someone out there. I'm sure there are other ways to do this type quest but this is fully functioning for me so I felt I should share it! Happy Modding Everyone!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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