Jump to content

Functioning Gear Door


daisy8

Recommended Posts

 

Bethesda one trick pony'd that door - you gotta make a reverse animation.

I'm currently trying to make a working vault door too and I made the console animations, but still cant make the door open/close.

but what I want to say - if you have vault 88 dlc, I think it have door with both open and close animations. atm I'm trying to reverse engineer that that door to have all animations running, like for the door itself, for both in and out consoles, for emergency lights, sound and etc. not sure if I'll be able to do it in next week or two (but really hope so) but I can post some updates on the theme here later.

 

also I know Ryanc229 solved that problem already in his vault 98

Edited by w31
Link to comment
Share on other sites

  • 2 weeks later...

So it is almost two weeks passed since my post here.. and I keep my promises. But I'm not really good in tutorials and englsih isn't my primary language so read on your own risk.
Also it took a day to get all this running, all this time I spent on other things. If you care :laugh:

And here it is

Gear Door Script:

 

;=======Original script made by Bethesda========
;===========Modified by Comdriver W31===========

;=======DONT FORGET TO INSERT YOUR SCRIPT NAME!!!

ObjectReference Property Collision Auto Const
{Collision Plane}

Sound Property OBJKlaxon2DLPM Auto const mandatory
Int KlaxonSoundID

Keyword Property LinkVaultDoorConsoleFurniture Auto const mandatory
{Console 1}
Keyword Property DLC06LinkVaultDoorConsoleFurniture02 Auto const mandatory
{Console 2}

Keyword Property LinkCustom01 Auto const mandatory

bool busy = false

bool gearDoorOpen = false conditional

bool gearDoorOpenVar = false ; this gets set to true immediately at start of opening; false at start of closing

Function OpenGearDoor(bool bOpen = true)
	if busy == false
		busy = true

		if bOpen
			if gearDoorOpen == false
				StartKlaxonSound()
				self.PlayAnimation("Stage2")
				gearDoorOpenVar = true
			endif
		else
			if gearDoorOpen
				StartKlaxonSound()
				self.PlayAnimation("Stage4")
				gearDoorOpenVar = false
			endif
		endif

	;enable the Klaxon lights. Animations play in the RefAlias scripts for each KlaxonLight
		RegisterForAnimationEvent(Self, "KlaxonStop")
		; also run timer as failsafe
		StartTimerGameTime(0.5)

	endif
EndFunction

function DoorAnimationFinished()
	StartKlaxonSound(false)
	UnregisterForAnimationEvent(GetLinkedRef(), "KlaxonStop")
	; set conditional variable to match hidden variable
	gearDoorOpen = gearDoorOpenVar

	; ready to open/close
	busy = false
	; unblock activation on console
	ResetVaultConsole()
	;Debug.Notification("READY")						;<====
EndFunction

Function StartKlaxonSound(bool bStart = true)
	if bStart
		KlaxonSoundID = OBJKlaxon2DLPM.Play(Self)
	else
		Sound.StopInstance(KlaxonSoundID)
	endif
	; turn lights on/off
	ObjectReference[] Klaxons = GetLinkedRefChildren(LinkCustom01)
	int i = 0
	while i < Klaxons.Length
		Default2StateActivator theKlaxon = Klaxons[i] as Default2StateActivator
		theKlaxon.SetOpen(bStart)
		ObjectReference[] KlaxonLights = theKlaxon.GetLinkedRefChildren(NONE)
		int j = 0
		while j < KlaxonLights.Length 
			ObjectReference theLight = KlaxonLights[j]
			if bStart 
				theLight.Enable()
				theLight.PlayAnimation("Stage2")
			else 
				theLight.Disable()
				theLight.PlayAnimation("Reset")
			endif
			j += 1
		endWhile
;		Klaxons[i].Activate(self)
		i += 1
	endWhile

EndFunction

function ResetVaultConsole()
	ObjectReference console = GetLinkedRef(LinkVaultDoorConsoleFurniture)
	if console 
		; unblock and reset
		console.BlockActivation(False, False)
		console.PlayAnimation("reset")
	endif 

	ObjectReference console02 = GetLinkedRef(DLC06LinkVaultDoorConsoleFurniture02)
	if console02 
		; unblock and reset
		console02.BlockActivation(False, False)
		console02.PlayAnimation("reset")
	endif 
endFunction 

Event OnTimerGameTime(int aiTimerID)
	if busy
    	DoorAnimationFinished()
    endif
EndEvent

Event OnLoad()
	RegisterForAnimationEvent(self, "Stage3")
	RegisterForAnimationEvent(self, "Stage5")
	; make sure console can be used
	ResetVaultConsole()
EndEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	 If asEventName == "Stage3"
		Collision.Disable()
	ElseIf asEventName == "Stage5"
		Collision.EnableNoWait()
	EndIf

	;wait for the gear door to finish animating, then stop Klaxon
	If (asEventName == "KlaxonStop")
		DoorAnimationFinished()
	EndIf
EndEvent

Event OnActivate(ObjectReference akActionRef)
	OpenGearDoor(gearDoorOpen == false)
EndEvent

 

 

To use it just attach this script to your copy gear door from vault 88 (DLC06VltGearDoor88 in Object Window) and that's all for the door actually. Just use <gear door object reference>activate(self) or <gear door object reference>activate(game.getplayer()) in your button's script and that should work. Use same line again to close the door if you use default gear door nif (not from the vault DLC). Or you can use any default game button with activate scripts.

 

For more complex use you should do auto fill properties of the script and manually select collision box for Collision property (I'm not sure what is the reason to have one, but there is one in vault 88 right between the door circle and it's hanging motor, I think is somehow blocks the way for AI when door is closed). You can later use this collision box for items to enable/disable with your door, just select that collision box as Enable Parent for your object and if you want enable state to be oppsite mark "Set enable state to opposite to parent" check box.

For klaxons. Place KlaxonLight01 from Movable Static category, open it's properties and add your gear door with keyword "LinkCustom01" to it's linked ref list. In scripts tab double click on "Default2StateActivator" script and mark "AllowInterrupt" as TRUE or you'll stuck on klaxon's animation. Then put KlaxonLightGlowNS (if you don't want shadows from klaxon) or KlaxonLightGlow (if you want shadows) from the Light category next to your KlaxonLight01. Add KlaxonLight01 as linked ref without any keyword to your KlaxonLightGlow linked ref list. That should do the work for klaxons and objects enabled/disabled with activating the door.

 

As for gear door consoles.. I had some difficulties with them. Skip this spoiler if you don't care and just want to make them work.

 

 

 

I tried to make them work without use of any quests but got problems on my way. I cleared and modified console script from any quests and made it use gear door activate instead. It's logic is pretty clear and compilation was successful. But.. when I added that script to a console it only worked in power armor and combat mode without any pip-boy animations. Also I made a duplicate of vanilla console with vanilla script without any modifications and got same result. Copy of vanilla console with my own script failed the animations too. I see no reasons for this behavior and it is some kind of magic for me.

 

Here is my script in case you want to try it, not much difference from default one.

 

Scriptname zvltConsoleScript extends ObjectReference

Keyword Property LinkVaultDoorConsoleFurniture Auto Hidden

Keyword Property LinkVaultDoor Auto
{Gear Door Trigger to activate}


InputEnableLayer Property VaultDoorConsoleLayer Auto Hidden

Function UseTheDoor()
	Debug.Notification("Activate door")
	Self.GetLinkedRef(LinkVaultDoor).Activate(self)
EndFunction

Event OnActivate(ObjectReference akActionRef)
	Actor PlayerREF = Game.GetPlayer()
	ObjectReference PlayerFurnitureREF = Self.GetLinkedRef(LinkVaultDoorConsoleFurniture)

	If akActionRef == PlayerREF

		if PlayerREF.IsInCombat()
			; skip the animation and go directly to opening everything
			Self.BlockActivation(True, True)
			Self.PlayAnimation("Stage2")
			Utility.Wait(2.0)
			Self.PlayAnimation("Stage3")
			Debug.Notification("Activate door in combat")
			UseTheDoor()
		ElseIf PlayerREF.IsInPowerArmor()
			; skip the animation and go directly to opening everything
			Self.BlockActivation(True, True)
			Self.PlayAnimation("Stage2")
			Utility.Wait(2.0)
			Self.PlayAnimation("Stage3")
			Debug.Notification("Activate door in PA")
			UseTheDoor()
		ElseIf PlayerREF.GetSitState() != 0
			; Don't do a thing
		else
			;disable VATS controls 
			VaultDoorConsoleLayer = InputEnableLayer.Create()
			VaultDoorConsoleLayer.EnableVATS(False)
			Self.BlockActivation(True, True)
			;put player in the furniture 
			Debug.Notification("UI disabled, activate furn")
			PlayerFurnitureREF.Activate(PlayerREF)

			;wait for the pipboy animation to finish
			RegisterForAnimationEvent(PlayerREF, "On")
			;wait for the player button press anim
			RegisterForAnimationEvent(PlayerREF, "Play01")
			;wait for the button press to finish
			RegisterForAnimationEvent(Self, "stage4")

			;patch 1.3 - 89054 - if the player ever gets up from the furniture (such as being hit) we need to know
			RegisterForRemoteEvent(PlayerREF, "OnGetUp")
		EndIf
	EndIf
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
	Actor PlayerREF = Game.GetPlayer()

	;player plugs in the pipboy
	If (akSource == PlayerREF) && (asEventNAme == "On")
		Debug.Notification("player plugs in the pipboy")
		UnregisterForAnimationEvent(PlayerREF, "On")
		;flip open the glass
		Self.PlayAnimation("Stage2")
		;play the SWF files on the pipboy
		Game.ShowPipboyPlugin()
	EndIf

	;player presses the button
	If (akSource == PlayerREF) && (asEventName == "Play01")
		Debug.Notification("button pressed")
		UnRegisterForAnimationEvent(PlayerREF, "Play01")
		;depress button animation
		Self.PlayAnimation("Stage3")
	EndIf

	;if the vault control panel sequence is complete, set stage in quest
	If (akSource == Self) && (asEventName == "stage4")
		Debug.Notification("all done")
		UnRegisterForAnimationEvent(Self, "stage4")
		;allow VATS again and delete layer
		VaultDoorConsoleLayer.EnableVATS(True)
		VaultDoorConsoleLayer = None
		UseTheDoor()

		;patch 1.3 - 89054 - no need to catch the getup event anymore
		UnRegisterForRemoteEvent(PlayerREF, "OnGetUp")
	EndIf
EndEvent

;patch 1.3 - 89054 - if the player ever leaves the linked furniture, we need to clear the control lock and re-enable the console

;need to create a function so I can call this remotely to fix savegames already in this state
Function ResetVaultConsole()
	Actor PlayerREF = Game.GetPlayer()
	VaultDoorConsoleLayer.EnableVATS()
	VaultDoorConsoleLayer = None
	Self.BlockActivation(False, False)

	;unregister for previously registered events
	UnregisterForAllEvents()
EndFunction

Event Actor.OnGetUp(Actor akSender, ObjectReference akFurniture)
	Actor PlayerREF = Game.GetPlayer()
	If (akSender == PlayerREF) && (akFurniture == Self.GetLinkedRef(LinkVaultDoorConsoleFurniture))
		ResetVaultConsole()
	EndIf
EndEvent

;Event OnReset()
;	Self.PlayAnimation("reset")
;	Self.BlockActivation(False, False)
;EndEvent

 

 

 

 

So to make working console animations you have to make a quest. Name it something like "myGearDoorHandler" or anything, anyway the quest should be standalone. You'll have to check "Allow repeated stages" in quest options and make just one stage in your quest. Don't fill anything in that quest stage but use papyrus fragment window. Press on "Select properties" button there (even if you dont have any script fragments cretion kit will add one automatically) and add an Object Reference const property. Select your gear door as the vaule and click OK. Now press "Edit" button and write a single coomand there: <your property name>.Activate(Game.GetPlayer()). That's all for quest, now back to consoles. Open your console's scripts tab and as properties for "VaultDoorConsoleScript" use you quest you just made and your stage number for papyrus fragment in that quest. This will allow to use console to open and close the door, but consoles will be locked after first activation and you'll have to resset their state. For this press "Edit" on your gear door and opne it's "Linked Ref" tab. Add your console as linked ref with keyword "LinkVaultDoorConsoleFurniture". If you have second console and vault 88 DLC add that console with keyword "DLC06LinkVaultDoorConsoleFurniture02". So you should have two consoles linked to gear door with two different keywords.

 

- here you can get test mod with all that things connected, just "coc zTestCell" in game.

 

EDIT: There is a typo in scripts path of the attached demo.

Data\Scripts\Fragments\Qests\

path should be

Data\Scripts\Fragments\Quests\

 

I'm not sure if I'm explaining that right way so later I can make a video tutorial and hope it will be more understandable.

Edited by w31
Link to comment
Share on other sites

And I also should mention what when I was looking for ideas how to solve my problem with console animations (and I solved it.. in some way) I found this guy who made a video tutorial about gear doors two weeks ago. Unlike me instead of a script on the door itself he decided to put all scripts to a quest and manage everything from there. As for me that's a bit overcomplicated but you guys may find that more useful than my way:

Open youtube video description to see the links to his scripts and time stamps.

 

Link to comment
Share on other sites

  • 1 year later...
  • Recently Browsing   0 members

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