senterpat Posted January 16, 2019 Share Posted January 16, 2019 Here is the script, I'll edit it later to make it easier to understand, I'm exhausted and hoping someone can tell me where I went wrong by the time I wake up. Scriptname patTGRQuestScript extends Quest GlobalVariable Property patTGTotalPoints Auto Conditional GlobalVariable Property patLocksPickedGlobal Auto Conditional GlobalVariable Property patItemsPickedGlobal Auto Conditional GlobalVariable Property patItemsStolenGlobal Auto Conditional GlobalVariable Property patRadiantJobsGlobal Auto Conditional GlobalVariable Property TGRMasterTotal Auto Conditional GlobalVariable Property TGStatusCount Auto Conditional GlobalVariable Property patRewardGlobal00 Auto Conditional GlobalVariable Property patRewardGlobal01 Auto Conditional GlobalVariable Property patRewardGlobal02 Auto Conditional GlobalVariable Property patRewardGlobal03 Auto Conditional GlobalVariable Property patRewardGlobal04 Auto Conditional GlobalVariable Property patRewardGlobal05 Auto Conditional GlobalVariable Property patRewardGlobal06 Auto Conditional GlobalVariable Property patRewardGlobal07 Auto Conditional GlobalVariable Property patRewardGlobal08A Auto Conditional GlobalVariable Property patRewardGlobal08B Auto Conditional GlobalVariable Property patRewardGlobal09 Auto Conditional Quest Property TG00 Auto Conditional Quest Property TG01 Auto Conditional Quest Property TG02 Auto Conditional Quest Property TG03 Auto Conditional Quest Property TG04 Auto Conditional Quest Property TG05 Auto Conditional Quest Property TG06 Auto Conditional Quest Property TG07 Auto Conditional Quest Property TG08A Auto Conditional Quest Property TG08B Auto Conditional Quest Property TG09 Auto Conditional ObjectReference Property patStatusStage001 Auto Conditional ObjectReference Property patStatusStage002 Auto Conditional ObjectReference Property patStatusStage003 Auto Conditional ObjectReference Property patStatusStage004 Auto Conditional ObjectReference Property patStatusStage005 Auto Conditional ObjectReference Property patStatusStage006 Auto Conditional ObjectReference Property patStatusStage007 Auto Conditional ObjectReference Property patStatusStage008 Auto Conditional ObjectReference Property patStatusStage009 Auto Conditional ObjectReference Property patStatusStage010 Auto Conditional ObjectReference Property patStatusStageHoneyside Auto Conditional Cell Property RiftenHoneyside Auto Faction Property PlayerFaction Auto Location Property RiftenRaggedFlagonLocation Auto Location Property RiftenThievesGuildHeadquartersLocation Auto Event OnPlayerLoadGame() RegisterForUpdateGameTime(1.0) EndEvent Event OnUpdateGameTime() if (RiftenHoneyside.GetFactionOwner() == PlayerFaction) && (patTGTotalPoints.GetValueInt() >= 1500) patStatusStageHoneyside.Enable() endif Float LocksPicked = (Game.QueryStat("Locks Picked")) if LocksPicked > (patLocksPickedGlobal.GetValueInt()) int LocksPickedGlobal = (patLocksPickedGlobal.GetValueInt()) ;assign the new value for the global patLocksPickedGlobal.SetValueInt(LocksPickedGlobal + 1) ;apply the new global value if TG08B.IsCompleted() int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 6) else int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 3) endif endif Float ItemsPicked = (Game.QueryStat("Items Pickpocketed")) if ItemsPicked > (patItemsPickedGlobal.GetValueInt()) int ItemsPickedGlobal = (patItemsPickedGlobal.GetValueInt()) ;assign the new value for the global patItemsPickedGlobal.SetValueInt(ItemsPickedGlobal + 1) ;apply the new global value if TG08B.IsCompleted() int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 12) else int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 6) endif endif Float ItemsStolen = (Game.QueryStat("Items Stolen")) if ItemsStolen > (patItemsStolenGlobal.GetValueInt()) int ItemsStolenGlobal = (patItemsStolenGlobal.GetValueInt()) ;assign the new value for the global patItemsStolenGlobal.SetValueInt(ItemsStolenGlobal + 1) ;apply the new global value if TG08B.IsCompleted() int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 2) else int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 1) endif endif float RadiantJobs = TGRMasterTotal.GetValue() if RadiantJobs > (patRadiantJobsGlobal.GetValueInt()) int RadiantJobsGlobal = (patRadiantJobsGlobal.GetValueInt()) ;assign the new value for the global patRadiantJobsGlobal.SetValueInt(RadiantJobsGlobal + 1) ;apply the new global value if TG08B.IsCompleted() int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 24) else int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 12) endif endif if (TG00.IsCompleted()) && (patRewardGlobal00.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal00.SetValueInt(1) endIf if (TG01.IsCompleted()) && (patRewardGlobal01.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal01.SetValueInt(1) endIf if (TG02.IsCompleted()) && (patRewardGlobal02.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal02.SetValueInt(1) endIf if (TG03.IsCompleted()) && (patRewardGlobal03.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal03.SetValueInt(1) endIf if (TG04.IsCompleted()) && (patRewardGlobal04.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal04.SetValueInt(1) endIf if (TG05.IsCompleted()) && (patRewardGlobal05.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal05.SetValueInt(1) endIf if (TG06.IsCompleted()) && (patRewardGlobal06.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal06.SetValueInt(1) endIf if (TG07.IsCompleted()) && (patRewardGlobal07.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal07.SetValueInt(1) endIf if (TG08A.IsCompleted()) && (patRewardGlobal08A.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 65) patRewardGlobal08A.SetValueInt(1) endIf if (TG08B.IsCompleted()) && (patRewardGlobal08B.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 130) patRewardGlobal08B.SetValueInt(1) endIf if (TG09.IsCompleted()) && (patRewardGlobal09.GetValueInt() == 0) int patTGCurrent = (patTGTotalPoints.GetValueInt()) patTGTotalPoints.SetValueInt(patTGCurrent + 130) patRewardGlobal09.SetValueInt(1) endIf if Game.Getplayer().IsInLocation(RiftenRaggedFlagonLocation) != 1 && Game.Getplayer().IsInLocation(RiftenThievesGuildHeadquartersLocation) != 1 IF patTGTotalPoints.GetValueInt() >= 300 patStatusStage001.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 600 patStatusStage002.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 900 patStatusStage003.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 1200 patStatusStage004.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 1500 patStatusStage005.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 1800 patStatusStage006.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 2100 patStatusStage007.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 2400 patStatusStage008.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 2700 patStatusStage009.Enable() Endif IF patTGTotalPoints.GetValueInt() >= 3000 patStatusStage010.Enable() Endif endif endEvent Link to comment Share on other sites More sharing options...
foamyesque Posted January 16, 2019 Share Posted January 16, 2019 (edited) OnPlayerLoadGame() only fires on scripts attached to the player (which should be done through a player alias). This script is listed as extends Quest. It will compile because Papyrus reads your addition of OnPlayerLoadGame() as a declaration of a new function (with the same name as the one you're trying to use, but because they're in separate scopes it doesn't matter), but because nothing calls that function, the first update is never registered for, and so the whole script chokes. The simplest fix is to add the player to an alias in this quest and add a very short script to it: Scriptname patTGRPlayerAliasScript extends ReferenceAlias Event OnPlayerLoadGame() (GetOwningQuest() as patTGRQuestScript).OnPlayerLoadGame() EndEvent This will pass along the load-game trigger from the thing that receives it to the quest that's trying to listen for it. Note: This will not fire the first time a game is loaded with the mod, because, at that time, the quest (and alias) didn't exist and so can't receive the event. To catch the very first load after installation, you want to use OnInit(). Edited January 16, 2019 by foamyesque Link to comment Share on other sites More sharing options...
ReDragon2013 Posted January 22, 2019 Share Posted January 22, 2019 As foamyesque already wrote, OnInit() is the clue.By using arrays the script will be more comfortable. patTGRQuestScript Scriptname patTGRQuestScript extends Quest ; https://forums.nexusmods.com/index.php?/topic/7318796-script-compiling-but-not-triggering-in-game/ ; senterpat wrote: "not triggering in game, I'm exhausted and hoping someone can tell me where I went wrong" Cell PROPERTY RiftenHoneyside auto Faction PROPERTY PlayerFaction auto Location PROPERTY RiftenRaggedFlagonLocation auto Location PROPERTY RiftenThievesGuildHeadquartersLocation auto GlobalVariable PROPERTY TGRMasterTotal auto GlobalVariable PROPERTY TGStatusCount auto ; UnUSED !? GlobalVariable PROPERTY patTGTotalPoints auto Conditional GlobalVariable PROPERTY patLocksPickedGlobal auto Conditional GlobalVariable PROPERTY patItemsPickedGlobal auto Conditional GlobalVariable PROPERTY patItemsStolenGlobal auto Conditional GlobalVariable PROPERTY patRadiantJobsGlobal auto Conditional Quest[] PROPERTY myQuests auto ; fill in order as follow ; TG00, TG01, TG02, TG03, TG04, ; TG05, TG06, TG07, TG08A, TG08B, TG09 GlobalVariable[] PROPERTY myRewards auto ; fill in order as follow ;GlobalVariable Property patRewardGlobal00 auto ;GlobalVariable Property patRewardGlobal01 auto ;GlobalVariable Property patRewardGlobal02 auto ;GlobalVariable Property patRewardGlobal03 auto ;GlobalVariable Property patRewardGlobal04 auto ;GlobalVariable Property patRewardGlobal05 auto ;GlobalVariable Property patRewardGlobal06 auto ;GlobalVariable Property patRewardGlobal07 auto ;GlobalVariable Property patRewardGlobal08A auto ;GlobalVariable Property patRewardGlobal08B auto ;GlobalVariable Property patRewardGlobal09 auto ObjectReference[] PROPERTY myObjs auto ; fill in order as follow ;ObjectReference Property patStatusStageHoneyside auto ;ObjectReference Property patStatusStage001 auto ;ObjectReference Property patStatusStage002 auto ;ObjectReference Property patStatusStage003 auto ;ObjectReference Property patStatusStage004 auto ;ObjectReference Property patStatusStage005 auto ;ObjectReference Property patStatusStage006 auto ;ObjectReference Property patStatusStage007 auto ;ObjectReference Property patStatusStage008 auto ;ObjectReference Property patStatusStage009 auto ;ObjectReference Property patStatusStage010 auto ; -- EVENTs -- 2 ;EVENT OnPlayerLoadGame() EVENT OnInit() RegisterForSingleUpdateGameTime(1.0) ; use single update here ENDEVENT EVENT OnUpdateGameTime() myF_Action() ENDEVENT ; -- FUNCTIONs -- 4 ;--------------------------------------------------- FUNCTION myF_Stats(GlobalVariable g, Float f, Int i) ;--------------------------------------------------- IF (i <= g.GetValueInt()) RETURN ; - STOP - query stats is not big enough ENDIF ;--------------------- g.Mod(1.0) ; apply new global value threadsafe IF myQuests[9].IsCompleted() ; TG08B f = f + f ; double it ENDIF patTGTotalPoints.Mod(f) ; apply new value threadsafe ENDFUNCTION ;--------------------- FUNCTION myF_Rewards() ;--------------------- int i = 0 WHILE (i < myQuests.Length) ; i < 11 IF myQuests[i].IsCompleted() && (myRewards[i].GetValue() == 0.0) myRewards[i].SetValue(1.0) patTGTotalPoints.Mod(65.0) ; apply new value threadsafe ENDIF i = i + 1 ENDWHILE ENDFUNCTION ;-------------------- FUNCTION myF_Action() ; internal helper ;-------------------- IF ( !RiftenHoneyside ) Debug.Trace(" OnUpdateGameTime() - missing cell property 'RiftenHoneyside' " +self) RETURN ; - STOP - bail out, missing property ENDIF ;--------------------- ;;; myF_LocksPicked( Game.QueryStat("Locks Picked") ) ;;; myF_ItemsPicked( Game.QueryStat("Items Pickpocketed") ) ;;; myF_ItemsStolen( Game.QueryStat("Items Stolen") ) ;;; myF_RadiantJobs( TGRMasterTotal.GetValueInt() ) myF_Stats(patLocksPickedGlobal, 3.0, Game.QueryStat("Locks Picked") ) myF_Stats(patItemsPickedGlobal, 6.0, Game.QueryStat("Items Pickpocketed") ) ; better name here: "paItemsPocketGlobal" myF_Stats(patItemsStolenGlobal, 1.0, Game.QueryStat("Items Stolen") ) myF_Stats(patRadiantJobsGlobal,12.0, TGRMasterTotal.GetValueInt() ) ; ------------- myF_Rewards() myF_EnableObjects() RegisterForSingleUpdateGameTime(1.0) ; try again 1 ingame hour later ENDFUNCTION ;--------------------------- FUNCTION myF_EnableObjects() ;--------------------------- IF Game.GetPlayer().IsInLocation(RiftenRaggedFlagonLocation) RETURN ; - STOP - player is in this location ENDIF ;--------------------- IF Game.GetPlayer().IsInLocation(RiftenThievesGuildHeadquartersLocation) RETURN ; - STOP - player is in this location ENDIF ;--------------------- int T = patTGTotalPoints.GetValueInt() int X = 0 objectReference oRef = myObjs[0] ; myObjs[0] = patStatusStageHoneyside IF oRef.IsDisabled() IF (RiftenHoneyside.GetFactionOwner() == PlayerFaction) && (T >= 1500) oRef.Enable() ; enable object "patStatusStageHoneyside" ENDIF ELSE IF (RiftenHoneyside.GetFactionOwner() == PlayerFaction) ELSE Debug.Trace(" OnUpdateGameTime() - disable 'patStatusStageHoneyside' object, because 'RiftenHoneyside' is not player owned!") oRef.Disable() ; disable object "patStatusStageHoneyside" ENDIF ENDIF int i = 1 ; myObjs[1] = patStatusStage001 WHILE (i < myObjs.Length) X = X + 300 ; 300, 600, 900, .. 3000 IF (T >= X) oRef = myObjs[i] IF (oRef) && oRef.IsDisabled() oRef.Enable() ENDIF ENDIF i = i + 1 ENDWHILE ENDFUNCTION ;/ *** multi line comment starts here ;------------------------------ FUNCTION myF_LocksPicked(Int i) ; i = LocksPicked ;------------------------------ IF (i <= patLocksPickedGlobal.GetValueInt()) RETURN ; - STOP - ENDIF ;--------------------- patLocksPickedGlobal.Mod(1.0) ; apply new global value threadsafe float f = 3.0 IF myQuests[9].IsCompleted() ; TG08B f = f + f ; 6.0 ENDIF patTGTotalPoints.Mod(f) ; apply new global value threadsafe ENDFUNCTION ;------------------------------ FUNCTION myF_ItemsPicked(Int i) ; i = ItemsPicked ;------------------------------ IF (i <= patItemsPickedGlobal.GetValueInt()) RETURN ; - STOP - ENDIF ;--------------------- patItemsPickedGlobal.Mod(1.0) ; apply new global value threadsafe float f = 6.0 IF myQuests[9].IsCompleted() ; TG08B f = f + f ; 12.0 ENDIF patTGTotalPoints.Mod(f) ; apply new global value threadsafe ENDFUNCTION ;------------------------------ FUNCTION myF_ItemsStolen(Int i) ; i = ItemsStolen ;------------------------------ IF (i <= patItemsStolenGlobal.GetValueInt()) RETURN ; - STOP - ENDIF ;--------------------- patItemsStolenGlobal.Mod(1.0) ; apply new global value threadsafe float f = 1.0 IF myQuests[9].IsCompleted() ; TG08B f = f + f ; 2.0 ENDIF patTGTotalPoints.Mod(f) ; apply new global value threadsafe ENDFUNCTION ;------------------------------ FUNCTION myF_RadiantJobs(Int i) ; i = RadiantJobs ;------------------------------ IF (i <= patRadiantJobsGlobal.GetValueInt()) RETURN ; - STOP - ENDIF ;--------------------- patRadiantJobsGlobal.Mod(1.0) ; apply new global value threadsafe float f = 12.0 IF myQuests[9].IsCompleted() ; TG08B f = f + f ; 24.0 ENDIF patTGTotalPoints.Mod(f) ; apply new global value threadsafe ENDFUNCTION *** /; Link to comment Share on other sites More sharing options...
Recommended Posts