Starting a script that always runs from a quest

Post » Mon Jun 18, 2012 9:27 pm

I'm trying to make a script that runs on the player at all times using a quest, but I'm having trouble getting the quest to start, even though "Start game enabled" is ticked. Am I missing a step? I created a new quest, attached my script to it, and made sure "Start game enabled" was ticked. When that didn't work, I tried adding a name, a start up stage with a log entry and an objective to see if it would show up in the journal, but it didn't.

The script is as follows:
Scriptname LorkTestScript extends ObjectReference{Prevents the player from moving while attacking}Event OnInit()	Debug.MessageBox("I live!")	RegisterForAnimationEvent(Game.GetPlayer(), "AttackStart")endEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)	Debug.MessageBox("I'm attacking")endEvent
Never mind the event handler for now; if the script is running at all I should at least see the first messagebox, shouldn't I?
User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Mon Jun 18, 2012 11:49 pm

I'm trying to make a script that runs on the player at all times using a quest, but I'm having trouble getting the quest to start, even though "Start game enabled" is ticked. Am I missing a step? I created a new quest, attached my script to it, and made sure "Start game enabled" was ticked. When that didn't work, I tried adding a name, a start up stage with a log entry and an objective to see if it would show up in the journal, but it didn't.

The script is as follows:
Scriptname LorkTestScript extends ObjectReference{Prevents the player from moving while attacking}Event OnInit()	Debug.MessageBox("I live!")	RegisterForAnimationEvent(Game.GetPlayer(), "AttackStart")endEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)	Debug.MessageBox("I'm attacking")endEvent
Never mind the event handler for now; if the script is running at all I should at least see the first messagebox, shouldn't I?
If you attached it to a quest, your script has to extend Quest.
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Mon Jun 18, 2012 4:39 pm

That's interesting (and not mentioned anywhere in the wiki that I can see), although if that's the case, the problem then becomes how to use the functions I want. Simply changing the script to extend the quest prevents it from compiling because it can't find RegisterForAnimationEvent.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm

Post » Mon Jun 18, 2012 4:07 pm

RegisterForAnimationEvent belongs to the Form script. Almost all script extends Form and therefore inherit this function.
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am

Post » Mon Jun 18, 2012 12:38 pm

Oh, whoops. I misread trira's post as saying scripts attached to a quest should extend the quest itself, rather than what he was actually saying, which is that they should extend "Quest".
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am

Post » Mon Jun 18, 2012 11:40 pm

Oh, whoops. I misread trira's post as saying scripts attached to a quest should extend the quest itself, rather than what he was actually saying, which is that they should extend "Quest".
Edit: Lol, I misread your post there too. What a coincidence...
User avatar
Lucky Boy
 
Posts: 3378
Joined: Wed Jun 06, 2007 6:26 pm

Post » Tue Jun 19, 2012 4:29 am

Success! Well, the first messagebox triggers anyway. It looks like I might be running into http://www.gamesas.com/topic/1348473-onanimationevent-doesnt-trigger-even-after-successful-registerforanimationevent/ with OnAnimationEvent, though. There are other, significantly less elegant ways to do what I want, but it seems silly to use them when this other, much better way supposedly exists.

Edit: Disregard that. Apparently "attackStart" isn't an animation event according to RegisterForAnimationEvent. Is there any way to get a list of all of the animation events accepted by this function?
User avatar
Charles Weber
 
Posts: 3447
Joined: Wed Aug 08, 2007 5:14 pm

Post » Tue Jun 19, 2012 2:01 am

Success! Well, the first messagebox triggers anyway. It looks like I might be running into http://www.gamesas.com/topic/1348473-onanimationevent-doesnt-trigger-even-after-successful-registerforanimationevent/ with OnAnimationEvent, though. There are other, significantly less elegant ways to do what I want, but it seems silly to use them when this other, much better way supposedly exists.


Oh yes you will, mark my words, Muahahahaha :devil:

To be honest, I'm start thinking that OnAnimationEvent is not functioning as it should. It didn't catch any Registered Animation at all
User avatar
Emmie Cate
 
Posts: 3372
Joined: Sun Mar 11, 2007 12:01 am

Post » Mon Jun 18, 2012 10:07 pm

Have you checked whether or not that's used anywhere in vanilla scripts?

Cipscis
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Mon Jun 18, 2012 2:46 pm

And never mind my edit to my last post, because apparently RegisterForAnimationEvent will fail if you start it from a new game, probably because the player doesn't exist yet or something dumb like that. If I do it with an existing character it does register "attackStart" successfully, and then proceeds to not trigger any OnAnimationEvents.
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am

Post » Mon Jun 18, 2012 3:15 pm

Have you checked whether or not that's used anywhere in vanilla scripts?

Cipscis
It seems to work just fine here:

ScriptName AltarofMolagBalScript extends ReferenceAliasReferenceAlias Property MaceofMolagBal AutoQuest Property DA10 AutoReferenceAlias Property TalkingMaceTriggerREF AutoReferenceAlias Property TalkingMace AutoReferenceAlias Property RustyMaceIntRef AutoInt Property DisableOnce AutoEvent OnAnimationEvent(ObjectReference akSource, string asEventName);	 debug.trace(self + "Receiving animation event from player")	If akSource == Game.GetPlayer() && asEventName == "IdleChairSitting"		;Utility.Wait(1)		Game.DisablePlayerControls()		GetRef().PlayAnimation("Up")		TalkingMace.GetRef().Activate(Game.GetPlayer())		TalkingMaceTriggerREF.GetRef().Disable()		UnRegisterForAnimationEvent(Game.GetPlayer(), "IdleChairSitting")	EndIfEndEventEvent OnActivate(ObjectReference akActionRef)	If (akActionRef == (Game.GetPlayer())) && (GetOwningQuest().GetStageDone(76) == 0)		RegisterForAnimationEvent(Game.GetPlayer(), "IdleChairSitting")		;Game.ForceThirdPerson()				;failsafe		Utility.Wait(5)		UnRegisterForAnimationEvent(Game.GetPlayer(), "IdleChairSitting")	EndIf		EndEvent

Anyway, we should probably continue this discussion in rongphale's thread, since it seems to be the same issue.
User avatar
JaNnatul Naimah
 
Posts: 3455
Joined: Fri Jun 23, 2006 8:33 am


Return to V - Skyrim