Jump to content

How to setstage when book is closed instead of opened


chambcra

Recommended Posts

I have it working when the book is opened but to get it to happen when the book is closed instead is starting to look like it might be tricky. I'm pretty sure I've seen it work both ways and wondered what is the difference and now I sort of need to know.

Thanks

Edited by chambcra
Link to comment
Share on other sites

Setstage is used to get a quest to proceed to the next stage. I am not sure what it is you are asking really? Is it a quest that starts or get to the next stage when you open a book and which book and which mod? Every quest stage in every quest can be set forward, no matter if books are involved or not as it doesn't have anything with the quests or rather quest stages to do in any way really.

Link to comment
Share on other sites

Thanks for the replies. I'm just trying to make something happen when the book closes instead of when it opens. Setting a stage just happens to be the thing I want to happen. It could be anything.

 

This works fine except it happens immediately when the book is opened. I want the quest window to pop up right after the book is closed instead of popping up on top of the book. Sorry if I'm not being clear.

 

scn a1ccBookScript

short doOnce

begin MenuMode 1026
if doOnce == 0
setStage a1ccZepplinQuest 20
set doOnce to 1
endif

end

 

I don't know anything about setting a flag. Still a noob after all these years. I was wondering if while in the menu mode you can detect the button press (exit button). Maybe I can assume it's button index 1. I could just start trying stuff but I thought this might be something that is so commonly done someone would know off the top of their head the exact script. I think I've seen it work this way all the time in lots of mods but maybe I'm mistaken. I'm the kind of noob that tries to find an example and I can't find one on this.

 

Thanks

Link to comment
Share on other sites

I wonder how the game really react when you open a book? When you click anything, even a misc item, it sets the equip flag and I do wonder if a book does the same? The equip flag will make it possible to use a block like:

begin OnEquip 
<code>
end

and when you close the book, it could also set the unequip flag so try to add your setstage at a block like this:

begin OnUnequip player
setstage quest stage
end

and we see what happens. Otherwise, try to find the right or proper begin onxxxxx here but I couldn't find any really. Many mods use the OnEquip for misc items for sure, like MOO as one example and Retros Fletching another. It must work for books as well really... Report back when you tried it.

Edited by Pellape
Link to comment
Share on other sites

There's a mod that sets a book to read, after you read it the first time, so maybe there is something in that script you could use? Just a wilde hunch but that's the only mod I know of that tracks books in any way.

 

Another way is to set a variable in a quest script when you read the book and check that variable with another quest script... Or rather add a script direct to the book:

Scn BookScript

Begin Onactivate
Set TheQuest.FlagVariable to 1 
activate
end

And to change the stage is then best to do in game mode, not in menu mode as then it might pop up when you are reading the book and that is what you wanna avoid right? No one have ever succeeded doing this as far as I have seen by the way but you need to close the menu in this example to be able to get to the next stage:

Scn TheQuestSCR

Short FlagVariable

Beging OnGameMode

If ( FlagVariable == 1 )
Setstage TheQuest Stage
endif

end

Edited by Pellape
Link to comment
Share on other sites

Why didn't I think of that. Thanks a lot Pellape that does the trick. Goes to show you how much of a noob I am. This must be what KatsAwful was talking about with a flag. Thanks to you too KatsAwful. I just changed my book script in the menu block to set the variable instead of the stage.

 

Just one more question. In this case the quest completes so I'm assuming the quest script will never run again so I don't have to worry about the setstage line running repeatedly everytime the script runs? Right?

 

If the quest didn't complete I would want to add another condition like:

 

If ( FlagVariable == 1 && anotherDoOnce == 0 )
Setstage TheQuest Stage

set anotherDoOnce to 1
endif

 

Right?

 

Thanks

Edited by chambcra
Link to comment
Share on other sites

Well almost right really but you do not need another DoOnce, as it is enough to:

Scn TheQuestSCR

Short FlagVariable

Beging OnGameMode

If ( FlagVariable == 1 )
Setstage TheQuest Stage
Set FlagVariable to 0
endif

end

This is the most common and optimal way to use am IF block only ones. The Variable name never needs to be named DoOnce, in case their is no other way but in this case there is as you already have the FlagVariable which you can change back to 0.

 

DoOnce is so common and I more use VariablesInitiated as that is what I usually do in the beginning of a script and when I speak it loud: -If not the Variables are inititiaded, should be:

 

If ( VariablesInitiated != 1 )

 

Well the point is to name the variable to what it is used for, more then just the common DoOnce, which will make the script easier to read if needed... :wink:

 

The best thing with quest scripts is that they run ones every 5s by default and not every frame like object scripts do and the speed of a quest script can be changed with an environment variable or to be more clear, a premade variable called fQuestDelayTime and it must be declared in the quest script as a float and can be set to any number really. I use 1s for many quest scripts as I use quests for much more then just quests.

 

Here is an example how to optimize a quest script to save some micro seconds

scn ExampleQuestSCR

float fQuestDelayTime

begin Gamemode

set fQuestDelayTime to 0.7

Is ( QuestComplete == 1 )
set fQuestDelayTime to 10
endif

And then the script will only run ones every 10s or just stop the quest but I do guess quest stops when it is set to be completed at the last stage

If ( QuestComplete == 1 )
StopQuest ExampleQuest
Endif
Edited by Pellape
Link to comment
Share on other sites

  • Recently Browsing   0 members

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