Optimized dish tracking in Cuthbert's Legacy

This commit is contained in:
Eddoursul 2021-12-20 00:54:45 +01:00
parent ccdd1b20a4
commit 2edfd9c09c
7 changed files with 94 additions and 31 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,43 +1,89 @@
Scriptname _00E_FS_NQ07_DinnerControlSC extends ReferenceAlias
Event OnInit()
AddInventoryEventFilter(_00E_EmptyFormlist)
If FS_NQ07.GetStage() == 370 ; version update
AddInventoryEventFilter(_00E_DalSarkerHoneywine)
AddInventoryEventFilter(FoodChickenCooked)
AddInventoryEventFilter(FoodCabbagePotatoSoup)
endif
FS_NQ07_HoneyWineBought.Value = PlayerREF.GetItemCount(_00E_DalSarkerHoneywine)
FS_NQ07_ChickenCooked.Value = PlayerREF.GetItemCount(FoodChickenCooked)
FS_NQ07_SoupBrewed.Value = PlayerREF.GetItemCount(FoodCabbagePotatoSoup)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_HoneyWineBought)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_ChickenCooked)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_SoupBrewed)
EndEvent
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if FS_NQ07.GetStage() == 370
if akBaseItem == _00E_DalSarkerHoneywine
FS_NQ07_HoneyWineBought.SetValue(PlayerREF.GetItemCount(_00E_DalSarkerHoneywine))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_HoneyWineBought)
FS_NQ07.SetObjectiveDisplayed(110, true, true)
elseif akBaseItem == FoodChickenCooked
FS_NQ07_ChickenCooked.SetValue(PlayerREF.GetItemCount(FoodChickenCooked))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_ChickenCooked)
FS_NQ07.SetObjectiveDisplayed(120, true, true)
elseif akBaseItem == FoodCabbagePotatoSoup
FS_NQ07_SoupBrewed.SetValue(PlayerREF.GetItemCount(FoodCabbagePotatoSoup))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_SoupBrewed)
FS_NQ07.SetObjectiveDisplayed(130, true, true)
endif
If FS_NQ07.GetStage() != 370
AddInventoryEventFilter(_00E_EmptyFormlist) ; in case clearing fails
RemoveInventoryEventFilter(_00E_DalSarkerHoneywine)
RemoveInventoryEventFilter(FoodChickenCooked)
RemoveInventoryEventFilter(FoodCabbagePotatoSoup)
Self.Clear()
return
endif
if akBaseItem == _00E_DalSarkerHoneywine
FS_NQ07.ModObjectiveGlobal(aiItemCount, FS_NQ07_HoneyWineBought, 110, 2, true, true, true)
elseif akBaseItem == FoodChickenCooked
FS_NQ07.ModObjectiveGlobal(aiItemCount, FS_NQ07_ChickenCooked, 120, 2, true, true, true)
elseif akBaseItem == FoodCabbagePotatoSoup
FS_NQ07.ModObjectiveGlobal(aiItemCount, FS_NQ07_SoupBrewed, 130, 2, true, true, true)
endif
EndEvent
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
if FS_NQ07.GetStage() == 370
if akBaseItem == _00E_DalSarkerHoneywine
FS_NQ07_HoneyWineBought.SetValue(PlayerREF.GetItemCount(_00E_DalSarkerHoneywine))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_HoneyWineBought)
If FS_NQ07.GetStage() != 370
AddInventoryEventFilter(_00E_EmptyFormlist) ; in case clearing fails
RemoveInventoryEventFilter(_00E_DalSarkerHoneywine)
RemoveInventoryEventFilter(FoodChickenCooked)
RemoveInventoryEventFilter(FoodCabbagePotatoSoup)
Self.Clear()
return
endif
if akBaseItem == _00E_DalSarkerHoneywine
FS_NQ07_HoneyWineBought.Value = PlayerREF.GetItemCount(_00E_DalSarkerHoneywine)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_HoneyWineBought)
if FS_NQ07_HoneyWineBought.Value < 2
FS_NQ07.SetObjectiveCompleted(110, false)
FS_NQ07.SetObjectiveDisplayed(110, true, true)
elseif akBaseItem == FoodChickenCooked
FS_NQ07_ChickenCooked.SetValue(PlayerREF.GetItemCount(FoodChickenCooked))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_ChickenCooked)
FS_NQ07.SetObjectiveDisplayed(120, true, true)
elseif akBaseItem == FoodCabbagePotatoSoup
FS_NQ07_SoupBrewed.SetValue(PlayerREF.GetItemCount(FoodCabbagePotatoSoup))
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_SoupBrewed)
FS_NQ07.SetObjectiveDisplayed(130, true, true)
elseif ! FS_NQ07.IsObjectiveCompleted(110)
FS_NQ07.SetObjectiveCompleted(110, true)
endif
return
endif
if akBaseItem == FoodChickenCooked
FS_NQ07_ChickenCooked.Value = PlayerREF.GetItemCount(FoodChickenCooked)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_ChickenCooked)
if FS_NQ07_ChickenCooked.Value < 2
FS_NQ07.SetObjectiveCompleted(120, false)
FS_NQ07.SetObjectiveDisplayed(120, true, true)
elseif ! FS_NQ07.IsObjectiveCompleted(120)
FS_NQ07.SetObjectiveCompleted(120, true)
endif
return
endif
if akBaseItem == FoodCabbagePotatoSoup
FS_NQ07_SoupBrewed.Value = PlayerREF.GetItemCount(FoodCabbagePotatoSoup)
FS_NQ07.UpdateCurrentInstanceGlobal(FS_NQ07_SoupBrewed)
if FS_NQ07_SoupBrewed.Value < 2
FS_NQ07.SetObjectiveCompleted(130, false)
FS_NQ07.SetObjectiveDisplayed(130, true, true)
elseif ! FS_NQ07.IsObjectiveCompleted(130)
FS_NQ07.SetObjectiveCompleted(130, true)
endif
return
endif
EndEvent
@ -53,3 +99,5 @@ Potion Property FoodCabbagePotatoSoup Auto
GlobalVariable Property FS_NQ07_HoneyWineBought Auto
GlobalVariable Property FS_NQ07_ChickenCooked Auto
GlobalVariable Property FS_NQ07_SoupBrewed Auto
FormList Property _00E_EmptyFormlist Auto

View File

@ -514,9 +514,26 @@ Function UpdateGlobals()
FS_NQ07_ChickenCooked.SetValue(PlayerREF.GetItemCount(FoodChickenCooked))
FS_NQ07_SoupBrewed.SetValue(PlayerREF.GetItemCount(FoodCabbagePotatoSoup))
wait(0.1)
UpdateCurrentInstanceGlobal(FS_NQ07_HoneyWineBought)
UpdateCurrentInstanceGlobal(FS_NQ07_ChickenCooked)
UpdateCurrentInstanceGlobal(FS_NQ07_SoupBrewed)
wait(0.5)
SetObjectiveDisplayed(110)
SetObjectiveDisplayed(120)
SetObjectiveDisplayed(130)
wait(1.5)
ModObjectiveGlobal(0, FS_NQ07_HoneyWineBought, 110, 2, true, true, false)
ModObjectiveGlobal(0, FS_NQ07_ChickenCooked, 120, 2, true, true, false)
ModObjectiveGlobal(0, FS_NQ07_SoupBrewed, 130, 2, true, true, false)
ReferenceAlias PlayerAlias = Self.GetAlias(14) as ReferenceAlias
PlayerAlias.ForceRefTo(PlayerREF)
PlayerAlias.AddInventoryEventFilter(_00E_DalSarkerHoneywine)
PlayerAlias.AddInventoryEventFilter(FoodChickenCooked)
PlayerAlias.AddInventoryEventFilter(FoodCabbagePotatoSoup)
EndFunction

View File

@ -168,9 +168,6 @@ kmyQuest.UpdateGlobals()
Utility.Wait(4)
SetObjectiveDisplayed(95)
kmyQuest.EnableActivatorForDinner()
SetObjectiveDisplayed(110)
SetObjectiveDisplayed(120)
SetObjectiveDisplayed(130)
SetObjectiveDisplayed(140)
SetObjectiveDisplayed(150)
;END CODE
@ -538,6 +535,7 @@ Quest __temp = self as Quest
_00E_FS_NQ07_Functions kmyQuest = __temp as _00E_FS_NQ07_Functions
;END AUTOCAST
;BEGIN CODE
(kmyQuest.GetAlias(14) as ReferenceAlias).Clear() ; PlayerREF
SetObjectiveDisplayed(160)
kmyQuest.StartDinnerScene()
SetObjectiveCompleted(110)