Trigger Once?

Post » Wed Jun 20, 2012 3:49 pm

I have a trigger that is nearly complete but I can't figure out how to make the trigger a one-time event.

Are there one or so lines of code to make the trigger trigger one time only?

Thanks!
User avatar
Angela Woods
 
Posts: 3336
Joined: Fri Feb 09, 2007 2:15 pm

Post » Wed Jun 20, 2012 12:05 pm

Declare an Int variable called DoOnce, then put this line in with the rest of the code that you want done only once time:
If DoOnce == 0;do your stuffDoOnce = 1EndIf

Work it in with your other If conditions. So if you already have like 'If GetIsId(MyNPC) == 1' then just add '&& DoOnce == 0' to that line.
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Wed Jun 20, 2012 9:00 pm

http://www.creationkit.com/BlockActivation_-_ObjectReference if it's an ObJectReference, perhaps?
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Wed Jun 20, 2012 5:56 pm

Thanks Alexander

Does "If DoOnce == 0" declare the variable, or is declared somewhere else?
User avatar
Naomi Ward
 
Posts: 3450
Joined: Fri Jul 14, 2006 8:37 pm

Post » Wed Jun 20, 2012 10:31 am

Justin

I don't think BlockActivation will work in my case.

My trigger "enables" several things, one of which is an actor. Once his routine is played out and the player goes through another trigger it turns everything back to normal.

I just don't want the trigger going off again as the player leaves the house.
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Wed Jun 20, 2012 4:43 pm

Actually I get an error that DoOnce isn't registered and it won't compile.

How do I register variables in Papyrus?

Thanks again!
User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Wed Jun 20, 2012 5:36 pm

Int DoOnce = 0

Though you'll probably want

Int Property DoOnce = 0 Auto

Since you'll want it to "remember" that value until you change it again.
User avatar
X(S.a.R.a.H)X
 
Posts: 3413
Joined: Tue Feb 20, 2007 2:38 pm

Post » Wed Jun 20, 2012 7:35 pm

Thanks Redwood

That did exactly what I needed.

It's been since the 70' since I've coded. I'll catch up :)
User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Wed Jun 20, 2012 1:42 pm

DoOnce var: You'd declare it elsweyr
BlockActivation(): Could be used just like the DoOnce sans the variable.
Event OnActivate()	If !IsActivationBlocked()		; Do Stuff once...		BlockActivation(True) ; ...and block activation until...	EndIfEndEventEvent OnLoad() ; ...ObjectReference reloads (player has left and returned)	BlockActivation(False)EndEvent
More than one way to skin this cat...
User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Thu Jun 21, 2012 1:16 am

Old habits die hard. We have states now so we don't need to fake the states with a DoOnce variable anymore.

So another way to skin this cat...
Event OnActivate()  GotoState("DoneOnce")  ; Do stuffEndEventState DoneOnce  Event OnActivate()   ; Do nothing  EndEventEndState

Whatever method is used, I think it will need the never resets flag on the object.
User avatar
Brandon Bernardi
 
Posts: 3481
Joined: Tue Sep 25, 2007 9:06 am

Post » Thu Jun 21, 2012 12:04 am

Actually "DoOnce" isn't working. I mean it's working but there are two triggers I have to create.

One trigger turns on certain objects and actors and turns off objects and actors if they are on.

I then have to have another trigger a little farther away that resets everything to before the first trigger.

It's sorta like a cut-scene in that it should play one time and if you go back through the triggers the objects remain as they were when you first entered.

I've tried several things. Like setting the second trigger to if DoOnce == 1 etc but that doesn't work. I'm thinking because I had to redeclare the variable. So I created a new trigger with a new name, a new script that has a new name and a new variable "DoOnceOff" and I haven't had any luck with that.

I'll try some of the other methods you guys mention tomorrow and see if I can get this to work.

Thanks!
User avatar
Multi Multi
 
Posts: 3382
Joined: Mon Sep 18, 2006 4:07 pm

Post » Wed Jun 20, 2012 10:24 am

So you mean you actually want it to trigger more than once, just not until the second trigger resets everything?

I guess you can have the first trigger be the enable parent of the second trigger and all your actors and objects, with them set to have the opposite enable state of their parent. Then you put these scripts on your triggers:

ScriptName Trigger01Script extends ObjectReferenceEvent OnTriggerEnter(ObjectReference akActionRef)    if (akActionRef == Game.GetPlayer())        Disable()    endifEndEvent

ScriptName Trigger02Script extends ObjectReferenceObjectReference property ParentTrigger autoEvent OnTriggerEnter(ObjectReference akActionRef)    if (akActionRef == Game.GetPlayer())        ParentTrigger.Enable()    endifEndEvent
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Wed Jun 20, 2012 12:08 pm

I am wondering if a one time only timed trigger would be a better idea.

Either an event, as when the enabled NPC leaves the scene or timed.

That would allow me to have only one trigger box and leaves me more room to do other things as well.
User avatar
Hayley O'Gara
 
Posts: 3465
Joined: Wed Nov 22, 2006 2:53 am

Post » Wed Jun 20, 2012 2:10 pm

i usually use a self.disable() at the end of the OnTriggerEnter

then if i need to reuse the trigger later on, i will call it from an objectreference property elsewhere and TriggerRef.Enable()
(triggerRef being a declared ObjectReference property in the other trigger's script
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Wed Jun 20, 2012 3:59 pm

Amethyst, thanks for your reply :smile:

Actually I'm thinking the best solution that I am looking for is either a timed trigger, where a timer is set and when it runs out of time the trigger resets everything to what it was before.

Either that, and this would be the best solution, would be having the trigger set and set a collision box to block the player pretty much forcing him to watch what is happening and when the NPC goes through the door it triggers the first trigger to reset everything. This would allow me to tweak what the NPC is doing without have to reset a timer every time I make a change.

I've made a short clip that should give a better idea what I am trying to accomplish (345MB)

[video]http://youtu.be/lDo9VAi8Zxo[/video]

The above video shows how it is not doing what I need it to do with two triggers. I even called a new variable DoOnceOFF and it still doesn't reset the scene.

What I need is basically the player enters the house and a vision appears with blood on the walls, furniture thrown about and a ghost appears and motions you to follow him into a room.

One of the things that are needed as well is a collision plane to keep the player in the first room and this can be easily added by setting it to initially disabled and the trigger would enable it.

Once the ghost goes through the door everything should reset as it was at the beginning (no blood on the walls, future sound effect and voices etc).
User avatar
Kat Lehmann
 
Posts: 3409
Joined: Tue Jun 27, 2006 6:24 am

Post » Wed Jun 20, 2012 10:37 am

randomnoob

I am using the example script from the wiki that uses FormLists for disabling things. I don't know how I would use your idea for that.
User avatar
Mel E
 
Posts: 3354
Joined: Mon Apr 09, 2007 11:23 pm

Post » Wed Jun 20, 2012 7:04 pm

Well my idea involves using an enable parent. You know how when you buy a player home it starts out empty and you have to buy upgrades for it? That's basically the same thing. The furniture in each room all have the same enable parent. When the 'parent' is enabled, the 'children' get enabled. When the 'parent' is disabled, the 'children' get disabled.

Choosing the option for them to have the opposite enable state of their 'parent' would mean that when the 'parent' gets enabled, the 'children' get disabled, and when the 'parent' gets disabled, the 'children' are enabled.

The example script in the wiki could do the same thing of course, but probably not as easily as just using an enable parent. It's obviously meant to do things that are more complicated than enabling/disabling, and that just happened to be a convenient example.
User avatar
Lalla Vu
 
Posts: 3411
Joined: Wed Jul 19, 2006 9:40 am

Post » Wed Jun 20, 2012 7:35 pm

Whatever method is used, I think it will need the never resets flag on the object.

What do you mean?
User avatar
.X chantelle .x Smith
 
Posts: 3399
Joined: Thu Jun 15, 2006 6:25 pm

Post » Wed Jun 20, 2012 9:22 pm

Well my idea involves using an enable parent. You know how when you buy a player home it starts out empty and you have to buy upgrades for it? That's basically the same thing. The furniture in each room all have the same enable parent. When the 'parent' is enabled, the 'children' get enabled. When the 'parent' is disabled, the 'children' get disabled. Choosing the option for them to have the opposite enable state of their 'parent' would mean that when the 'parent' gets enabled, the 'children' get disabled, and when the 'parent' gets disabled, the 'children' are enabled. The example script in the wiki could do the same thing of course, but probably not as easily as just using an enable parent. It's obviously meant to do things that are more complicated than enabling/disabling, and that just happened to be a convenient example.

So, using an enabled parent allow me to set up a situation where when the NPC goes through the door (see video above at youtube) it would unset the parent?
User avatar
D LOpez
 
Posts: 3434
Joined: Sat Aug 25, 2007 12:30 pm

Post » Wed Jun 20, 2012 6:51 pm

OK, watching the video, I think I misunderstood what you wanted. You only want the blood and the ghost to show up the first time you enter the house, and only the first time, right?

This ties into what tunaisafish is saying. You want to set the trigger to never respawn, because otherwise the trigger would get reset when the cell does and you'd play the scene over again.

So, you have the actor and all these blood splatters, and that first trigger. Create a second trigger behind the door (so the ghost will trigger it when he passes through) using the 'defaultenabledisablelinkedref' trigger. Then put an X marker somewhere, and set it to be initially disabled. Now, for the actor, the second trigger, and each of the blood splatters and effects, edit them and go to the 'Enable Parent' tab.

Select the X marker as the enable parent. Now for the first trigger, if it isn't already, change it to the 'defaultenabledisablelinkedref' trigger. Edit it and add the X marker as a linked ref.

Now edit the second trigger. Again, add the X marker as a linked ref. Now edit the trigger's script so that the 'PlayerOnly' property is false and 'TriggerType' is 1.

Save your mod and test.
User avatar
Stephanie I
 
Posts: 3357
Joined: Thu Apr 05, 2007 3:28 pm

Post » Wed Jun 20, 2012 11:03 pm

Where would that xmarker be placed?

I am currently using xmarkers for the NPC to get to the door etc.

Would this new xmarker be placed somewhere the player steps on?

I'm trying to understand its purpose
User avatar
Jordan Fletcher
 
Posts: 3355
Joined: Tue Oct 16, 2007 5:27 am

Post » Wed Jun 20, 2012 11:18 pm

Random,

Nevermind about the xmarker, I see what you're doing. It's more like a place holder for the enabler/disabler and can be anywhere.

What line do I include for setting 'PlayerOnly' as false and setting the 'TriggerType' to 1.
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Wed Jun 20, 2012 12:37 pm

You only want the blood and the ghost to show up the first time you enter the house, and only the first time, right?


Yes but....I want everything to return to "normal" after the ghost goes through the door. I don't want the blood splatter and all the other things I'll be adding later to stick around.

It's kinda like having a vision and it goes away when the ghost leaves.
User avatar
DarkGypsy
 
Posts: 3309
Joined: Tue Jan 23, 2007 11:32 am

Post » Wed Jun 20, 2012 6:05 pm

Randomnoob

I found where that is located.

I was looking at the properties of the trigger, not its script.

Hang with me guys! I'll keep working at it till I get the Papyrus language and CK!
User avatar
Mr. Allen
 
Posts: 3327
Joined: Fri Oct 05, 2007 8:36 am

Post » Wed Jun 20, 2012 7:24 pm

RandomNoob,

I think it's working pretty good now !

I still have a lot of fixing up to do and work on the ambiance and all but the cut scene seems to be working perfectly now:

https://www.youtube.com/watch?v=KFwZodRk2KQ&feature=youtu.be

Thanks!
User avatar
Philip Lyon
 
Posts: 3297
Joined: Tue Aug 14, 2007 6:08 am

Next

Return to V - Skyrim