Script on Quest starts without 'Start Game Enabled' Flag

Post » Wed Jun 20, 2012 1:45 pm

Good evening,

in short, I have the problem you can read in the topic title. Basically I've created a quest with a script on it. I've tried the whole evening to get my script started shortly after the character creation process, but somehow the 'OnTrigger' Event was messing up things. I then decided to use a 'OnInit', so that my Questscript runs on game start up. While I was fiddeling around with other events I suddenly figured out that my script gets activated, no matter if I have activated the 'start game enabled' flag on my quest or not. Isn't the script supposed not to be working when I turn off start game enabled? However. I still wish I could fire my script after the character creation process. Any help apreciated. Here's the script:

Spoiler
Scriptname SI_StartSkyrimImprovedScript extends Quest  {Mega script to initiaze features of Skyrim Improved.}Perk Property SI_DummyPerkChooser AutoPerk Property SI_LowerCarryWeightPerk AutoSpell Property SI_AccessInventorySpell AutoSpell Property SI_UndressNPCSpell AutoSpell Property SI_MakeEssentialSpell AutoMessage Property SI_ChooseLowerCarryWeigth AutoMessage Property SI_ChoosePowerMessage1 AutoMessage Property SI_ChoosePowerMessage2 AutoMessage Property SI_ChooseAbilityMessage1 AutoMessage Property SI_ChooseAbilityMessage2 AutoMessage Property SI_ChooseSpellsMessage AutoMessage Property SI_ChooseSchoolOfMagicMessage AutoMessage Property SI_ChoosePASMessage AutoMessage Property SI_ChooseAutoHealthRegenMessage AutoMessage Property SI_ChooseResetStatsTo0 AutoSpell Property PowerArgonianHistskin AutoSpell Property PowerBretonAbsorbSpell AutoSpell Property PowerDarkElfFlameCloak AutoSpell Property PowerHighElfMagickaRegen AutoSpell Property PowerImperialPacify AutoSpell Property PowerKhajiitNightEye AutoSpell Property PowerNordBattleCry AutoSpell Property RaceOrcBerserk AutoSpell Property PowerRedguardStaminaRegen AutoSpell Property PowerWoodElfCommandAnimal AutoSpell Property RaceArgonianResistDisease AutoSpell Property RaceArgonianWaterbreathing AutoSpell Property RaceBreton AutoSpell Property RaceDarkElf AutoSpell Property AbHighElfMagicka AutoSpell Property RaceImperial AutoSpell Property RaceKhajiitClaws AutoSpell Property RaceNord AutoSpell Property RaceRedguard AutoSpell Property RaceWoodElf AutoSpell Property Candlelight AutoSpell Property Oakflesh AutoSpell Property BoundSword AutoSpell Property ConjureFamiliar AutoSpell Property Flames AutoSpell Property Frostbite AutoSpell Property Clairvoyance AutoSpell Property Courage AutoSpell Property Healing AutoSpell Property WardLesser AutoSpell Property PCHealRateCombat AutoActor playerEvent OnInit()		RegisterForSingleUpdate(1)EndEventEvent OnUpdate()	...
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Wed Jun 20, 2012 12:07 pm

I just want to say I've noticed the same thing happening to me. The OnInit in my quest script runs even when the quest is not start game enabled.

Drove me crazy when I was trying to figure out text replacement. Thought I was doing everything right, but turned out my quest wasn't actually running.
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Post » Wed Jun 20, 2012 11:42 am

Yeah the OnInit will fire at game start the first time it's installed, and again when the quest starts.
For quests that you don't want as start game enabled, then it might make better sense putting the oninit code into the start stage fragment.
User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Wed Jun 20, 2012 4:07 pm

Yeah the OnInit will fire at game start the first time it's installed, and again when the quest starts.
For quests that you don't want as start game enabled, then it might make better sense putting the oninit code into the start stage fragment.

Thanks for the answer. If I put the OnInit into the start stage, don't I need a trigger to activate it then? Wouldn't it be easier to just use another event?

I'm specifically searching for something like a 'Event OnGetQuestStageDone' Event. Does something like that excists? And how would I set it up to be fired only once. The problem I had when using a Trigger, was, the script got fired again every time I got close to the Trigger. How do you make 'Event OnTrigger' fire only once?

Edit: Would it be possible to tie the script to MQ101 at stage 97 (when you're in front of the choping block)?
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Wed Jun 20, 2012 10:33 pm

You can put IsRunning condition within OnInit block to prevent firing it up after game loads and when the quest is not yet running.

here's a sample code from one of my mods:

Quest Property axBowOfShadowsQuest  Auto  WEAPON Property axBowOfShadows  Auto  Event OnInit()    Actor Player    Player = Game.GetPlayer()    If axBowOfShadowsQuest.IsRunning()        If Player.GetItemCount(axBowOfShadows) < 1            Player.AddItem (axBowOfShadows, 1)        EndIf        axBowOfShadowsQuest.stop()    EndIfEndEvent
User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Wed Jun 20, 2012 11:09 am

The property is not needed because the script is the script already, so a simple [self.]IsRunning() does the job.
User avatar
Markie Mark
 
Posts: 3420
Joined: Tue Dec 04, 2007 7:24 am

Post » Wed Jun 20, 2012 12:07 pm

Quest fragments are already 'Events' The event being when the stage is entered.
So if you tick the box on the stage that says 'startup stage', then you've got yourself an OnStartQuest event.

So you could put your registerForSingleUpdate there, or do as Artisanix suggests.

There's another thread from today that will answer you 'Trigger Once?' question.

If you have this quest running from startup, (and not use an external trigger) then you.could check for MQ101.IsStageDone(97) in the OnUpdate event. Just have it check every 30 secs or so, and re-register until that stage is done.

If you wanted it to happen as an 'event' then you'd have to edit the MQ101 quest itself, which is not good practice if you can easily avoid it.
User avatar
TRIsha FEnnesse
 
Posts: 3369
Joined: Sun Feb 04, 2007 5:59 am

Post » Wed Jun 20, 2012 12:33 pm

Thanks guys for trying to help me. I finally figured out what was wrong. The problem was I did 'RegisterForSingleUpdate(1)' which says the script got checked only once after 1 second into the game. So basically what happened was:

1. I tell it to fire the script with 'OnInit' - which tells the game to start the script, no matter if the 'Start Game Enabled" flag is tacked or not
2. then I tell it to 'RegisterForSingleUpdate(1)' - which says it's waiting for an update 1 second after it got initialized by 'OnInit' and only to do this once(SingleUpdate)
3. then it checks for 'If (MQ101.IsStageDone(80))' - since the quest stage isn't reached it simply quits with 'SI_SkyrimImprovedStarterQuest.stop()'

So here's the code like it looks now. Note the different directions I've tried to get this thing working...:D

Spoiler
Actor playerEvent OnInit();    RegisterForSingleUpdate(1)    RegisterForUpdate(5) <--- this did the trickEndEventEvent OnUpdate();    Actor Player;bool mainQuestStage80Done = mq101.IsStageDone(80);if mainQuestStage80Done == true    Player = Game.GetPlayer()    If MQ101.IsStageDone(80);    If (MQ101.IsStageDone(80))    Debug.MessageBox......endif    Debug.MessageBox("Have Fun with Skyrim Improved. If you like the mod, don't forget to endorse.")    SI_SkyrimImprovedStarterQuest.stop();    endifendifendevent

Thanks for your help again guys. Without your tips I would have never get this fixed. You shall be mentioned in the credits of my mod...:D
User avatar
Kitana Lucas
 
Posts: 3421
Joined: Sat Aug 12, 2006 1:24 pm

Post » Wed Jun 20, 2012 7:43 pm

[self.]IsRunning() does the job.
Functions can/should be called implicitly in such instances. 'Self' is rarely needed unless as an argument, like FXShader.Play(Self).
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am


Return to V - Skyrim