Jump to content

Enabling an initially disabled static object via trigger


Recommended Posts

I'm rather new to modding, to please forgive me if this is a "stupid question."

Without further ado.

I have a mod with three interior zones; A, B, and C. They are chain linked such that A<--> B <--> C through regular doors.
But there is also a shortcut between A<-->C. However, to avoid players skipping zone B, that shortcut should only be enabled when the Player has reached zone C 'naturally'

Basically, there's a ladder in zone C which links to an Initially Disabled trapdoor in zone A. I would like either

  • the trapdoor is enabled when the Player passes a threshold (trigger box?) in zone C
  • the trapdoor is enabled when the Player first uses the ladder from zone C

Either way is fine by me, so if one is easier to explain/do than the other that's okay.

Thanks for reading!

Link to comment
Share on other sites

 Personally, I think having a trapdoor appear where there was previously none is weird.   Why not just have it there, but lock it with "requires a key" lock.

Put the key in an obvious location in C close to ladder.

But otherwise, yeah, you can put a trigger area someplace in C, and attach a script to it that will have that trapdoor reference as property.  The script, oh trigger activation, would: 

Enable door

Disable the trigger area.

Link to comment
Share on other sites

Hi you two,

 

What your think about is using a volume tigger that detect the character when enter in it and then enable some object.
Am i right ?

 

You should look at this solution so :

Spoiler
ScriptName ExampleTrigger Extends ObjectReference

Actor Property PlayerREF Auto ; Least 'costly' way to refer to the player

Event OnTriggerEnter(ObjectReference akActionRef)
	If akActionRef == PlayerREF ; This condition ensures that only the player will trigger this code
		Debug.MessageBox("Yippee!")
	EndIf
EndEvent

 

To Make This Script Work

Select an existing object in your cell

Click on the Trigger Volume button, the box with a T inside of it.

  • A orange box should appear around the object you selected.
  • Now edit the new orange box you created and add the script above.
  • Then go in-game and walk into the space where this invisible box is.

Uses:

  • Create events that depend on player positioning
  • You could eliminate the player if statement above and have other actors like draugr or companions activate things as well
  • Non-player triggers can be used by changing the == to a != in the script above, to do things to other actors like restoring their health or moving them around (but not affecting player if player walks through the trigger)

 

Its comes from here : Complete Example Scripts

 

I hope it will help you.

 

 

 

Link to comment
Share on other sites

8 hours ago, scorrp10 said:

 Personally, I think having a trapdoor appear where there was previously none is weird.   Why not just have it there, but lock it with "requires a key" lock.

Put the key in an obvious location in C close to ladder.

But otherwise, yeah, you can put a trigger area someplace in C, and attach a script to it that will have that trapdoor reference as property.  The script, oh trigger activation, would: 

Enable door

Disable the trigger area.

Having it appear out of nowhere is odd, I realize. But it's sooort of supposed to be a secret, which is why.

5 hours ago, Chronepsys said:

Hi you two,

 

What your think about is using a volume tigger that detect the character when enter in it and then enable some object.
Am i right ?

 

You should look at this solution so :

  Reveal hidden contents
ScriptName ExampleTrigger Extends ObjectReference

Actor Property PlayerREF Auto ; Least 'costly' way to refer to the player

Event OnTriggerEnter(ObjectReference akActionRef)
	If akActionRef == PlayerREF ; This condition ensures that only the player will trigger this code
		Debug.MessageBox("Yippee!")
	EndIf
EndEvent

 

To Make This Script Work

Select an existing object in your cell

Click on the Trigger Volume button, the box with a T inside of it.

  • A orange box should appear around the object you selected.
  • Now edit the new orange box you created and add the script above.
  • Then go in-game and walk into the space where this invisible box is.

Uses:

  • Create events that depend on player positioning
  • You could eliminate the player if statement above and have other actors like draugr or companions activate things as well
  • Non-player triggers can be used by changing the == to a != in the script above, to do things to other actors like restoring their health or moving them around (but not affecting player if player walks through the trigger)

 

Its comes from here : Complete Example Scripts

 

I hope it will help you.

 

 

 

Thanks!

Though which part of that script actually enables something? I feel like there should be some sort of
getLinkedRef().enable
in that if statement (I don't know the actual syntax, sorry. New to Papyrus, but familiar with prog. languages in general though)

Link to comment
Share on other sites

ScriptName TrapDoorEnablerTrigger Extends ObjectReference

Actor Property PlayerREF Auto ; Least 'costly' way to refer to the player
ObjectReference Property TrapDoor Auto

Event OnTriggerEnter(ObjectReference akActionRef)
	If akActionRef == PlayerREF ; This condition ensures that only the player will trigger this code
		TrapDoor.Enable()
		Self.Disable()
	EndIf
EndEvent

The script given by above poster is just an example that does nothing except display a message popup.    The script above actually does what you need.

In the properties of that trigger area, there should be a scripts tab, where you can attach a script.   You can attach one of existing scripts, or you can create a new one, in which case CK will ask you to enter its name.   

Once a script is attached, you click the Properties button next to it.   In there, Add Property.   You want to put in its type as Actor, and its name as PlayerRef.    Once you click OK, it should auto-populate it.

Again, Add Property.   Type is ObjectReference, and name 'TrapDoor', OK.   The property will get added, but it will be unfilled.   You click this property, click Edit.    It should give you an option to select a  cell, and in that cell, the reference to that trapdoor.

After this, you should be able to go into your Data\Source\Scripts, and the new .psc file should be there with the two properties defined, and you just add the OnTriggerEnter function.    As you can see, logic is simple.    If the triggerer is the player, the script will enable the trapdoor, and then it will disable itself.

One more thing - you still need to compile the script after this.   Generally, if you go Gameplay - papyrus script manager,  the script should be there if you look for it, but often, a new script will not appear until you restart Creation Kit. So you want to save, exit, restart CK, and the open script manager and compile.

Link to comment
Share on other sites

16 hours ago, scorrp10 said:
ScriptName TrapDoorEnablerTrigger Extends ObjectReference

Actor Property PlayerREF Auto ; Least 'costly' way to refer to the player
ObjectReference Property TrapDoor Auto

Event OnTriggerEnter(ObjectReference akActionRef)
	If akActionRef == PlayerREF ; This condition ensures that only the player will trigger this code
		TrapDoor.Enable()
		Self.Disable()
	EndIf
EndEvent

The script given by above poster is just an example that does nothing except display a message popup.    The script above actually does what you need.

In the properties of that trigger area, there should be a scripts tab, where you can attach a script.   You can attach one of existing scripts, or you can create a new one, in which case CK will ask you to enter its name.   

Once a script is attached, you click the Properties button next to it.   In there, Add Property.   You want to put in its type as Actor, and its name as PlayerRef.    Once you click OK, it should auto-populate it.

Again, Add Property.   Type is ObjectReference, and name 'TrapDoor', OK.   The property will get added, but it will be unfilled.   You click this property, click Edit.    It should give you an option to select a  cell, and in that cell, the reference to that trapdoor.

After this, you should be able to go into your Data\Source\Scripts, and the new .psc file should be there with the two properties defined, and you just add the OnTriggerEnter function.    As you can see, logic is simple.    If the triggerer is the player, the script will enable the trapdoor, and then it will disable itself.

One more thing - you still need to compile the script after this.   Generally, if you go Gameplay - papyrus script manager,  the script should be there if you look for it, but often, a new script will not appear until you restart Creation Kit. So you want to save, exit, restart CK, and the open script manager and compile.

I'm still a little uncertain of how the script is put into Skyrim/Creation kit?

When I attempt to edit my trigger box, I get the following (Creation kit screen caps)

Spoiler

screencap01.png.3c6eb38c5b56efd56af5b59c113ca06c.png

screencap02.png.114d4c10fa60f6b22265bd00dd1b2035.png

screencap03.png.0883521f3134e14ff97a80ddabfd01b4.png

But when I attempt this, I just get a compilation error message.
At which point do I actually input papyrus script language? Should I pop into my data folder and make a new .psc file myself, and then (re)start the Creation Kit before I can select it?

 

-thanks for all the help!

Link to comment
Share on other sites

Ah, indeed, the initial setup.   In order to compile even the initial empty script, the compiler needs to know what "ObjectReference" is.  In your games Data folder, there should be a file "Scripts.zip".  You need to unzip it, which will put a ton of .psc files into your your Data/Source/Scripts.  This should be enough for now.

Next, you need an editor application associated with .psc files.  It could be just Notepad, but you really should get something designed for coding.   I personally use Apache Netbeans.  You could also try Eclipse, Visual Studio or even Notepad++.

After you done that, load your mod in CK and edit the trigger box again.  If it already shows with script attached, go and edit its properties as I mentioned. Otherwise, try adding the script again.  (And then creating its properties)  You should not be getting a compile error now.

At this point, if you select "Papyrus Script manager" (PSM) from gameplay menu, your new script should be listed there.  Might need to use the filter box to locate it.  If not there, save your mod and restart CK.

Right click your script in PSM and choose "Open in External Editor", which should open your script in the editor you chose.  This is where you get to add actual script code.   Edit, save, then in PSM, right click your script and choose Compile.

Link to comment
Share on other sites

I'm having trouble getting the script to work/register in game.
I think it might be an issue of me using Creation Kit through Mod Organizer (long story, but launching it the "vanilla" way caused errors).

But I think that's a problem on my end only, w.r.t. folder and game structure.

Thanks for all the help! I'll edit in when/if I get it working, but you've helped me a tonne, and the rest is up to me!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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