ObjectReference script OnOpen not firing when script activat

Post » Tue Jun 19, 2012 8:16 pm

Okay, this is probably just something stupid on my part again, but I figured I'd ask anyway :smile:

First off, I'm overriding the PlayerHorse script. When the player is sneaking (heh, got that figured out), instead of activating the horse and allowing the player to climb aboard, it instead activates a chest reference.

The chest reference has a custom ObjectReference script attached. I've overridden the OnOpen and OnClose events and if you enter the cell with the chests and open/close them, the events will fire off properly.

The problem comes when I'm firing off the Activate function on the object, the chest opens, the OnActivate Event fires off, but neither the OnOpen nor OnClose events will trigger.

Here's the overridden horse script. I've attached the ChestReference to the HorseChest ObjectReference Property:
Spoiler
Scriptname PlayerHorseScript extends ReferenceAlias  bool bDelayActivationEvent OnDeath(Actor akKiller)	MySelf = GetActorReference()	HorseChest.RemoveAllItems(akTransferTo = MySelf, abKeepOwnership = true)EndEventEvent OnUnload()	If MySelf.IsDead() == 1		; disable the dead horse if it is unloaded		MySelf.Disable()		MySelf.Delete()		; added a new horse that can be bought at the stables		Myself = StablesPosition.PlaceActorAtMe(LvlHorseSaddled)		Alias_HorseRef.ForceRefTo(MySelf)		Alias_HorseRef.GetRef().SetFactionOwner(StablesFaction)	EndIfEndEventEvent OnActivate(ObjectReference akActionRef)		If bDelayActivation		bDelayActivation = false		GetActorReference().BlockActivation(True)	Else		If (akActionRef == Game.GetPlayer() && Game.GetPlayer().IsSneaking())			;Debug.MessageBox("Sneak Activate Horse!!")			HorseChest.Activate(Game.GetPlayer(), False)		Else			;Debug.MessageBox("Normal Activate Horse!! " + HorseChest)						;Set Speed of horse based on weight in chest						Debug.MessageBox("SaddleBags Weight = " + (HorseChest as _MDHorseChestScript).GetWeight())						;Enable activations and have player mount horse			bDelayActivation = true			GetActorReference().BlockActivation(False)			GetActorReference().Activate(Game.GetPlayer())		EndIf	EndIf	EndEventActor Property MySelf  Auto  ObjectReference Property StablesPosition  Auto  ActorBase Property LvlHorseSaddled  Auto  ReferenceAlias Property Alias_HorseRef  Auto  Faction Property StablesFaction  Auto  ObjectReference Property HorseChest Auto

And here's the script attached directly to the chest object reference in the Cell:
Spoiler
Scriptname _MDHorseChestScript extends ObjectReference  Event OnInit()	Weight = 1.0EndEventFloat Function GetWeight()	Return WeightEndFunctionEvent OnActivate(ObjectReference akActionRef)	Debug.MessageBox("OnActivate Weight = " + Weight)EndEventEvent OnOpen(ObjectReference akActionRef)	PCWeightBefore = Game.GetPlayer().GetAV("InventoryWeight")	Debug.MessageBox("OnOpen Weight = " + Weight)EndEventEvent OnClose(ObjectReference akActionRef)	PCWeightAfter = Game.GetPlayer().GetAV("InventoryWeight")	Weight = Weight +(PCWeightBefore - PCWeightAfter)	Debug.MessageBox("OnClose Weight = " + Weight)EndEventFloat Property Weight AutoFloat Property PCWeightBefore AutoFloat Property PCWeightAfter Auto
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Tue Jun 19, 2012 9:35 pm

This is probably happening because the containers' 3D data is not loaded due to them being located in a remote cell, so the open and closing animations are never triggered.

Cipscis
User avatar
lucy chadwick
 
Posts: 3412
Joined: Mon Jul 10, 2006 2:43 am

Post » Tue Jun 19, 2012 6:19 pm

OnOpen() and OnClose fire when the animation finished, if the chest is not rendered, there is no animation.

You can try with



Function SetOpen(bool abOpen = true) native

User avatar
Hazel Sian ogden
 
Posts: 3425
Joined: Tue Jul 04, 2006 7:10 am

Post » Wed Jun 20, 2012 2:57 am

I was afraid it was going to be something like that. Looks like I'll have to approach it from a different direction, then.

-EDIT-

Well, it's always the simple answers that solve things nicely :) Keying off of the idea that it's the animation sequences that fire off the events, before running the Activate() function, I just move the chest to the player's position first. It still doesn't fire off the OnOpen event, but I still get the OnActivate one. Once the chest closes, the OnClose event does fire off and I can use that to move the chest back to it's original location.

Thanks for the help!
User avatar
Stu Clarke
 
Posts: 3326
Joined: Fri Jun 22, 2007 1:45 pm


Return to V - Skyrim