Jump to content

Creating a dual trigger


entropiachrome

Recommended Posts

OK, I am using the NMCoffin01 (Night Mother's Coffin) in a mod I'm working on. This item will open and close it's doors when activated by the player (toggle E).

 

What I would like to do is:

 

1) Have a trigger (maybe TGDoorCloserTrigger?) that will shut the coffin automatically when stepping inside the upright coffin, and then...

 

2) The doors closing will prompt the "sleep" menu to pop up, as if you had chosen to sleep on a bed.

 

 

 

Anyone willing to spend a few moments to instruct me on the simpliest way to achieve this? If closing the doors will be difficult, I'd be willing to simply have the sleep menu pop up when stepping inside if that makes this easier...

Link to comment
Share on other sites

You will pretty much need a script to do this with a bed. Here I wrote you one

 

Scriptname zzznmcoffinscript extends ObjectReference  
ObjectReference Property zzznmcoffinbed auto

bool closed = true

EVENT onActivate(ObjectReference triggerRef)
closed = !closed
if(triggerRef == game.getPlayer() && closed == true)
Utility.wait(2)
if(self.getDistance(game.getPlayer()) < 75)
zzznmcoffinbed.Activate(game.getPlayer())
endif
endif
endEVENT

 

1.You will need to add this to the coffin reference's scripts and call it zzznmcoffinscript.

2.You will also need to make a bed of any type, put it in the wall so no one can see it and call it zzznmcoffinbed.

3.Finally go to the reference of the nmcoffin you are using, double click the zzznmcoffinscript you added. On the menu that should pop up hit auto fill for zzznmcoffinbed.

 

It should now work pretty well. Don't forget to save. Hope this helps!

Link to comment
Share on other sites

You will pretty much need a script to do this with a bed. Here I wrote you one

 

Scriptname zzznmcoffinscript extends ObjectReference  
ObjectReference Property zzznmcoffinbed auto

bool closed = true

EVENT onActivate(ObjectReference triggerRef)
closed = !closed
if(triggerRef == game.getPlayer() && closed == true)
Utility.wait(2)
if(self.getDistance(game.getPlayer()) < 75)
zzznmcoffinbed.Activate(game.getPlayer())
endif
endif
endEVENT

 

1.You will need to add this to the coffin reference's scripts and call it zzznmcoffinscript.

2.You will also need to make a bed of any type, put it in the wall so no one can see it and call it zzznmcoffinbed.

3.Finally go to the reference of the nmcoffin you are using, double click the zzznmcoffinscript you added. On the menu that should pop up hit auto fill for zzznmcoffinbed.

 

It should now work pretty well. Don't forget to save. Hope this helps!

 

 

Awesome, thanks for the information!!! I'm fallin asleep here at the keyboard, so I'll give this a whirl tomorrow morning over a cup of coffee and see how it works!

 

:biggrin:

Link to comment
Share on other sites

1) Use the "defaultActivateSelfTRIG", change the doOnce property in its script to false, have the trigger be the activate parent of the coffin.

 

2) This is more complicated. You'd have to script it so that the player activates a bed when the doors close. Instead of doing #1, you need to create a trigger with this script:

 

Scriptname ExampleTriggerScript extends ObjectReference

ObjectReference Property Coffin Auto
{The coffin...}
ObjectReference Property Bed Auto
{Some bed somewhere}
Furniture Property BedFurniture Auto
{If you didn't set the Bed property, what kind of bed to use}

Event OnCellLoad()
if !Coffin
	if (GetLinkedRef())
		Coffin = GetLinkedRef()
	else
		Debug.Notification("Failure!  You didn't set the coffin to the 'Coffin' property, nor did you set it as the linked ref to this trigger.")
		Disable()
	endif
elseif !Bed
	if (NobleBedSingle01)
		Bed = PlaceAtMe(NobleBedSingle01)
		Bed.Disable()
	else
		Debug.Notification("Failure!  You didn't set a bed to the 'Bed' property, nor did you set a bed to the 'BedFurniture' property.")
		Disable()
	endif
endif
EndEvent

Event OnTriggerEnter(ObjectReference TriggerRef)
if !(TriggerRef == Game.GetPlayer())
	Return
endif
Coffin.Activate(TriggerRef)
Utility.Wait(1)
Bed.Activate(TriggerRef)
EndEvent

 

EDIT: Looks like I took too long. :rolleyes:

Edited by fg109
Link to comment
Share on other sites

OK folks, bear with me here... this is my first time ever attempting to implement scripts, and it's kind of like reading Spanish. I can understand bits and pieces of it, but I don't really comprehend all of it.

 

Good news is, I got the coffin (resized to 1.80) to close automatically when stepping inside (it still can be opened and closed manually from both inside and outside the coffin). Details in case something needs to be changed, the defaultActivateSelfTRIG (named zzznmcoffinbedtrigger) is the parent of the coffin has the following script:

 

ScriptName defaultActivateSelf extends objectReference

{Default script that simply activates itself when player enters trigger}

 

import game

import debug

 

bool property doOnce = FALSE auto

{Fire only once? Default: TRUE}

bool property disableWhenDone = FALSE auto

{Disable after activating? Default: FALSE}

bool property playerOnly = TRUE auto

{Only Player Triggers? Default: TRUE}

bool property playerAndAlliesOnly = False Auto

{Only player or Allies/Followers/Summons trigger? Overrides playerOnly if that's true as well. Default: TRUE}

int property minLevel auto

{Optional: If set, player must be >= minLevel to activate this}

 

Faction property PlayerFaction Auto

Faction property CurrentFollowerFaction Auto

Package property Follow Auto

Package property FollowerPackageTemplate Auto

 

 

;************************************

 

auto State waiting

Event onTriggerEnter(objectReference triggerRef)

Actor actorRef = triggerRef as Actor

; check whether we care if the player is activating

if(actorRef == game.getPlayer() || (playerAndAlliesOnly && IsPlayerAlly(triggerRef)) || (playerOnly == False && playerAndAlliesOnly == False))

; also check level (if we even care about that)

if(minLevel == 0 || game.getPlayer().getLevel() >= minLevel)

if doOnce == TRUE

gotoState("allDone")

endif

if disableWhenDone

Self.Disable()

EndIf

; per the description of this script, pass self as the activating ref

activate(self)

endif

endif

endEvent

endState

 

bool Function IsPlayerAlly(ObjectReference triggerObj)

Actor triggerAct = (triggerObj as Actor)

 

;Short-circuit this if this isn't an Actor at all, or if it's hostile to the player.

if (triggerAct == None || triggerAct.GetFactionReaction(GetPlayer()) == 1)

return False

EndIf

 

 

 

<continued on next post>

Edited by entropiachrome
Link to comment
Share on other sites

Bad news is, the bed won't activate the sleep menu. I have a DweFurnitureBedSingle01R (named zzznmcoffinbed) outside the wall, with the blue marker thingie sticking into the coffin. Here is the script I have for the COFFIN (I did not use the script from fg109 because it was twice as much text and I didn't understand it, but I can change if needed):

 

 

Scriptname zzznmcoffinscript extends ObjectReference

ObjectReference Property zzznmcoffinbed auto

 

{bool closed = true

 

EVENT onActivate(ObjectReference triggerRef)

closed = !closed

if(triggerRef == game.getPlayer() && closed == true)

Utility.wait(2)

if(self.getDistance(game.getPlayer()) < 75)

zzznmcoffinbed.Activate(game.getPlayer())

endif

endif

endEVENT}

 

1) Do I need to remove the { and } around the script info? It seems it was added automatically.

2) I did not make the coffin the parent of the bed, should I have?

3) Does the bed marker need to be in the coffin, or can I move it further out into the void?

4) When I did auto fill for zzznmcoffinbed, it didn't replace anything.

Edited by entropiachrome
Link to comment
Share on other sites

1) Yes. Stuff between the curly braces are considered comments.

2) No, you don't have to.

3) You can put the bed anywhere, even in another cell.

4) Auto-fill will not work unless the property is named the same as the object's Editor ID.

 

Also, I didn't mean for you to change and recompile the defaultActivateSelf script. I meant that you're supposed to assign False to the DoOnce property. If you don't know how to change the values of properties, read the tutorial.

Link to comment
Share on other sites

1) Yes. Stuff between the curly braces are considered comments.

2) No, you don't have to.

3) You can put the bed anywhere, even in another cell.

4) Auto-fill will not work unless the property is named the same as the object's Editor ID.

 

Also, I didn't mean for you to change and recompile the defaultActivateSelf script. I meant that you're supposed to assign False to the DoOnce property. If you don't know how to change the values of properties, read the tutorial.

 

 

I fixed everything in bold above, and the subtanker script (referenced in the coffin itself) still didn't work. I tried cpoy/pasting the fg109 script, changed the names as instructed, saved, deleted the subtanker script from the coffin, added the fg109 script to the trigger, and it didn't work (and there were no failure warnings). The door doesn't close anymore, either.

 

Is the one trigger with the fg109 script supposed to be the parent of the coffin, the bed, or both? Also, should I have the defaultActivateself script going in addition to the added script?

Link to comment
Share on other sites

OK, actually tried out the script I gave you. I'd messed up one of the property names, but that's not the real problem. I thought that you could still activate a bed if it's not in the same cell and/or disabled. I was wrong, so this is the modified script (I tested it and it works):

 

 

Scriptname ExampleTriggerScript extends ObjectReference

ObjectReference Property Coffin Auto
{The coffin...}
ObjectReference Property Bed Auto
{Non-disabled bed in the same cell as the coffin}
Furniture Property BedFurniture Auto
{If you didn't set the Bed property, what kind of bed to use}

Event OnCellLoad()
if !Coffin
	if (GetLinkedRef())
		Coffin = GetLinkedRef()
	else
		Debug.Notification("Failure!  You didn't set the coffin to the 'Coffin' property, nor did you set it as the linked ref to this trigger.")
		Disable()
	endif
elseif !Bed
	if (BedFurniture)
		Bed = PlaceAtMe(BedFurniture)
		Bed.SetScale(0.01)
		Bed.MoveTo(Self, 0, 0, -30000)
	else
		Debug.Notification("Failure!  You didn't set a bed to the 'Bed' property, nor did you set a bed to the 'BedFurniture' property.")
		Disable()
	endif
endif
EndEvent

Event OnTriggerEnter(ObjectReference TriggerRef)
if !(TriggerRef == Game.GetPlayer())
	Return
endif
Coffin.Activate(TriggerRef)
Utility.Wait(1)
Bed.Activate(TriggerRef)
EndEvent

 

 

I'm not sure why the door wasn't closing for you, it did for me. Also, I needed to set the coffin to 1.3 times its size, or else there's not enough space for the player to fit inside.

Link to comment
Share on other sites

OK... Here is where I'm at:

 

Scriptname zzznmcoffinscript extends ObjectReference

 

ObjectReference Property zzznmcoffin Auto

{The coffin...}

ObjectReference Property CommonBed01 Auto

{Non-disabled bed in the same cell as the coffin}

Furniture Property CommonBed01 Auto

{If you didn't set the Bed property, what kind of bed to use}

 

Event OnCellLoad()

if !zzznmcoffin

if (GetLinkedRef())

zzznmcoffin = GetLinkedRef()

else

Debug.Notification("Failure! You didn't set the coffin to the 'Coffin' property, nor did you set it as the linked ref to this trigger.")

Disable()

endif

elseif !CommonBed01

if (CommonBed01)

CommonBed01 = PlaceAtMe(CommonBed01)

CommonBed01.SetScale(0.01)

CommonBed01.MoveTo(Self, 0, 0, -30000)

else

Debug.Notification("Failure! You didn't set a bed to the 'Bed' property, nor did you set a bed to the 'BedFurniture' property.")

Disable()

endif

endif

EndEvent

 

Event OnTriggerEnter(ObjectReference TriggerRef)

if !(TriggerRef == Game.GetPlayer())

Return

endif

zzznmcoffin.Activate(TriggerRef)

Utility.Wait(1)

CommonBed01.Activate(TriggerRef)

EndEvent

 

 

It won't save correctly:

 

Starting 1 compile threads for 1 files...

Compiling "zzznmcoffinscript"...

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zzznmcoffinscript.psc(7,19): script property CommonBed01 already defined

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zzznmcoffinscript.psc(7,19): script variable ::CommonBed01_var already defined

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zzznmcoffinscript.psc(7,19): script property CommonBed01 already has a get function defined

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zzznmcoffinscript.psc(7,19): script property CommonBed01 already has a set function defined

No output generated for zzznmcoffinscript, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on zzznmcoffinscript

 

 

 

I have no idea why this isn't working. Am I supposed to use a defaultActivateSelfTRIG as the parent to the coffin and ADD this script to the default script? Or should this replace the default trigger script?

 

Unless I have stuff laid out for me step by step I'm never gonna get this, as I'm obviously clueless. :facepalm:

 

Thanks for your help so far, I hope this is something I can get to work!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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