Script not behaving properly

Post » Tue Dec 04, 2012 8:02 pm

Hi,

with some help from here and there i have managed to get this far with my very simple mini-Quest mod, but it's not quite working right.

I want it to work from either end without disabling the target NPC, who is Undead.

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 ObjectReferenceQuest Property Quest AutoObjectReference Property MapQuestMRKR  AutoObjectReference Property NoteQuest Auto ; read the letterEvent onRead()	  Quest.SetStage(10)	  Quest.SetObjectiveDisplayed(10) ; "I have read a private letter to Some Guy, I must search Some Ruin and find the book"	  MapQuestMRKR.addtomap()EndEvent

This works fine.


Then,

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 script for finding and reading the book:

Scriptname QuestStopSCRIPT extends ObjectReferenceQuest Property Quest AutoObjectReference Property NoteQuest AutoPerk Property QuestPerk autoEvent 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() &--#60;10			 Quest.SetStage(40) ; "I have found A Book"			 Quest.SetObjectiveDisplayed(40) ; "READ the book"			 NoteQuest.Disable()	 EndIfEndEventEvent 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)	 EndIfEndEvent


Is there anything you can see that might cause this?

If it IS at Stage 20, it goes to Stage 30 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 12Scriptname QF_Quest_02000D7C Extends Quest Hidden;BEGIN ALIAS PROPERTY NPC_MRKR;ALIAS PROPERTY TYPE ReferenceAliasReferenceAlias Property Alias_QuestNPC_MRKR Auto;END ALIAS PROPERTY;BEGIN ALIAS PROPERTY MapQuestMRKR;ALIAS PROPERTY TYPE ReferenceAliasReferenceAlias 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!

~
User avatar
Lucky Boy
 
Posts: 3378
Joined: Wed Jun 06, 2007 6:26 pm

Return to V - Skyrim