User:PROXiCiDE/CreateAdvancedQuestBook

From the CreationKit Wiki
Jump to navigation Jump to search

Creating a Advanced Quest Book[edit | edit source]

This script allows you to advance to the next quest stage only if the player has the book in the inventory while it is being read by the player

;=================================================================================
; Properties
;=================================================================================
Quest Property pQuest Auto
{The quest}
Int Property nStagePrequisite Auto
{Quest stage requirement}
Int Property nStageToSet Auto
{Advances the quest to this stage}

;=================================================================================
; Events
;=================================================================================
Bool bInPlayerInventory = False
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	bInPlayerInventory = False
	If akNewContainer && akNewContainer == Game.GetPlayer()
		bInPlayerInventory = True
	EndIf
EndEvent

Event OnRead()
	If pQuest.GetStage() == nStagePrequisite
		If bInPlayerInventory 
			pQuest.SetStage(nStageToSet)
		Else
			; Player did not read the book in inventory
			; Do stuff here
		EndIf
	EndIf
EndEvent