Jump to content

Script Misbehaving


Shadeybladey

Recommended Posts

Hi,

 

This is not a request for a mod, but for help with a script for a mod.

 

I have a very simple mini-Quest mod which I want to work from either end without disabling the target NPC.

 

Player finds and reads this letter

Stage 10

Add Journal Entry, Update Map, Add Floating Quest Markers, SetStage(10), SetObjectiveDisplayed(10), Start Quest

Journal Entry I have read a private letter to some guy…

Objective 10 Search the ruins for the book that interests some guy…

 

 

This is the script for the letter:

 

Scriptname _shb_SWSQ_QuestStartSCRIPT extends ObjectReference

Quest Property Quest Auto  
ObjectReference Property MapQuestMRKR  Auto
ObjectReference Property NoteQuest Auto

; read the letter
Event onRead()
	Quest.SetStage(10)
	Quest.SetObjectiveDisplayed(10)
	MapQuestMRKR.addtomap()
EndEvent

 

This works fine.

 

 

 

Search ruins, find and kill the revenant, take the book from his inventory

Stage 20

Update Journal Entry, Remove Floating Quest Markers, SetStage(20), SetObjectiveCompleted(10), SetObjectiveDisplayed(20)

Journal Entry I have found the ancient tome that interests Some Guy.

Objective 20 I must Study the ancient tome Some Guy is interested in.

 

Player Studies the Book

Stage 30

Study the Book, Update Journal, acquire the hidden perk added to player, SetObjectiveCompleted(20), SetStage(30), End Quest

Journal Entry I have studied the book and now I have the special quest perk

Quest Ended

 

These all work fine.

 

 

In case the player just explores and finds the book on his own, I added Stage 40

 

 

Kill the Revenant while exploring, take book from his inventory

Stage 40

Start Quest, Update journal, disable letter, Set Stage(40), SetObjectiveDisplayed(40)

Journal Entry I have found an ancient tome…

Objective 40 I must Read this ancient book

 

 

Player Reads the book

Stage 50

Read the Book, Update Journal, acquire the secret knowledge as a hidden perk added to player, SetObjectiveCompleted(40), SetStage(50), End Quest

Journal entry I have read this book I found and learned the secrets

 

 

I've tweaked it as best I can and it works perfectly forwards.

 

BUT, if I find the book before reading the letter, it goes to Stage 40 on taking the book from the Revenant's inventory, as it should, but when I read the book instead of going to stage 50 and completing, it goes to Stage 20 and completes.

 

Each journal entry has different text so I can tell which Stage it belongs to.

 

 

 

This is the acript for finding and reading the book:

 

Scriptname QuestStopSCRIPT extends ObjectReference

Quest property Quest auto
ObjectReference property NoteQuest auto
Perk Property QuestPerk auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

; Letter is read first
If	Quest.GetStage() == 10
	Quest.SetObjectiveCompleted(10) ; "I have found THE book"
	Quest.SetStage(20)
	Quest.SetObjectiveDisplayed(20) ; "STUDY the book"

; Book is discovered first
ElseIf	Quest.GetStage() <10
	Quest.SetStage(40) ; "I have found A Book"
	Quest.SetObjectiveDisplayed(40) ; "READ the book"
	NoteQuest.Disable()
EndIf
EndEvent


Event onRead()	
; Letter is read first
If	Quest.GetStage() == 20
	Quest.SetObjectiveCompleted(20) ; "I have STUDIED the book"
	Quest.SetStage(30)
	Game.GetPlayer().AddPerk(QuestPerk)

; Book is discovered first
ElseIf	Quest.GetStage() == 40
	Quest.SetObjectiveCompleted(40) ; "I have READ the Book"
	Quest.SetStage(50)
	Game.GetPlayer().AddPerk(QuestPerk)
EndIf
EndEvent

 

 

 

Is there anything you can see that might cause this?

 

If it IS at Stage 20, it goes to Stage 30 and completes as intended.

 

But, if it is at Stage 40, it goes to Stage 20, updates the Journal and completes when it should go to Stage 50.

 

 

The QF_ quest fragment has this:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 12
Scriptname QF_Quest_02000D7C Extends Quest Hidden

;BEGIN ALIAS PROPERTY NPC_MRKR
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_QuestNPC_MRKR Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY MapQuestMRKR
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MapQuestMRKR Auto
;END ALIAS PROPERTY

 

 

I read somewhere that you cannot call functions on something that has changed containers, but then why does anything happen at all when I read the book?

 

 

Cheers!

 

~

Edited by Shadeybladey
Link to comment
Share on other sites

I have also tried taking the objectives etc out and putting them in the QF_ fragnent, but the script works exactly the same way:

 

if I read the letter first,

0

10

20

30

 

but if I kill the Revenant and take the book without reading the letter first, then read the book, it goes from:

 

0

40

20

 

Any ideas?

 

 

 

Many Thanks

 

~

Link to comment
Share on other sites

I dont think you can call disable() on a quest and thats the only thing I see fishy about your scripts. The quest fragment is just showing the aliases you have attach to your quest. Its pre declaring them for you so you can use them right away. Nothing wrong there.

 

Im curious about your papyrus log. Add this to skyrim.ini so I can see what papyrus is up to.

 

[Papyrus]
fPostLoadUpdateTimeMS=500.0
bEnableLogging=1
bEnableTrace=1
bLoadDebugInformation=1

 

Then add this to each stage on your quest and each function in your script.

 

debug.trace(self +"")

Like this

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
debug.trace(self +" Container has changed")
       If      Quest.GetStage() == 10
         debug.trace(self +"Letter is discovered first")
               Quest.SetObjectiveCompleted(10) ; "I have found THE book"
               Quest.SetStage(20)
               Quest.SetObjectiveDisplayed(20) ; "STUDY the book"


       ElseIf  Quest.GetStage() <10
         debug.trace(self +" Book is discovered first")
               Quest.SetStage(40) ; "I have found A Book"
               Quest.SetObjectiveDisplayed(40) ; "READ the book"
               NoteQuest.Disable()
       EndIf
EndEvent


Event onRead()  
debug.trace(self +" Something just got read")
       If      Quest.GetStage() == 20
         debug.trace(self +" Letter is read first")
               Quest.SetObjectiveCompleted(20) ; "I have STUDIED the book"
               Quest.SetStage(30)
               Game.GetPlayer().AddPerk(QuestPerk)

; 
       ElseIf  Quest.GetStage() == 40
         debug.trace(self +" Book is read first")
               Quest.SetObjectiveCompleted(40) ; "I have READ the Book"
               Quest.SetStage(50)
               Game.GetPlayer().AddPerk(QuestPerk)
       EndIf
EndEvent

 

Then after a play test go to where your saves are stored and post the papyrus log in [spoiler.]d[/spoiler.] tags, without the dot :biggrin:

Link to comment
Share on other sites

It doesn't disable the quest, it disables the note, or letter, so that if you find the book first, when you later find the letter and read it the quest does not start again.

 

I'll try your suggestions anyway and see what happens.

 

 

Cheers

 

~

Link to comment
Share on other sites

  • Recently Browsing   0 members

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