I can't seem to reliably receive OnTriggerLeave events. OnTriggerEnter always seems to get sent. I have no idea why this isn't working reliably.
For example, staves always seem to send an OnTriggerLeave event, but every other weapon I've tested won't. I've made the trigger large enough that the player can jump into the display case and prompt reliable trigger events but this is not an acceptable solution for me
http://i.imgbox.com/ux77GCm7.png. No editor objects or markers intersect it.
The trigger has this script on it:
Scriptname MDHDisplayCaseTriggerScript extends ObjectReference{Controls the enable state of the display case activator to allow for item retrieval}ObjectReference Property ActivatorRef Auto {The activator we must disable if there is already something in this trigger}auto STATE Waiting EVENT onTriggerEnter(ObjectReference aktriggerRef) ActivatorRef.Disable() debug.notification("An object has entered this trigger") endEVENT EVENT OnTriggerLeave(ObjectReference aktriggerRef) ActivatorRef.Enable() debug.notification("An object has left this trigger") endEVENTendSTATE
Items get placed into the trigger from my container object which has this script on it:
Scriptname MDHDisplayScriptCONTAINERstaff extends ObjectReference {Script for display cases specifically};Amethyst DeceiverBool Property Blocked = False Auto HiddenObjectReference Property TriggerMarker Auto HiddenKeyword Property WRackTrigger AutoMessage Property MessageWarning AutoMessage Property MessageCount AutoKeyword Property ArmorShield AutoKeyword Property WeapTypeDagger AutoKeyword Property WeapTypeSword AutoKeyword Property WeapTypeGreatSword AutoKeyword Property WeapTypeStaff AutoKeyword Property WeapTypeWarAxe AutoKeyword Property WeapTypeMace AutoKeyword Property WeapTypeBattleAxe AutoKeyword Property WeapTypeWarhammer AutoKeyword Property WeapTypeBow AutoKeyword Property ClothingRing AutoKeyword Property VendorItemPotion AutoKeyword Property VendorItemPoison AutoKeyword Property VendorItemGem AutoKeyword Property ClothingNecklace AutoFormList Property ClawList AutoFormList Property WhitePhial AutoFormList Property PoisonList AutoFormList Property UniqueJarList AutoInt Property PlacedItem = 0 Auto HiddenInt Property DisplayType = 1 Auto{1 = Weapon rack2 = Dagger case3 = Jewel display4 = Shield plaque5 = Potion/Poison6 = Dragon claw7 = COA weapon8 = Unique Jar9 = Necklace}ObjectReference ItemRefForm ItemBaseEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)Actor PlayerRef = Game.GetPlayer()If (akSourceContainer == PlayerRef) If (AllowedItems(akBaseItem)) If (aiItemCount == 1) && (PlacedItem == 0) PlacedItem += aiItemCount ItemBase = akBaseItem ItemRef = akItemReference RegisterForSingleUpdate(0.1) Else MessageCount.Show() PlacedItem += aiItemCount RemoveItem(akBaseItem, aiItemCount, False, PlayerRef) ;if I register for a single update in the OnItemRemoved Event it should force a recheck of the now singular item EndIf Else MessageWarning.Show() PlacedItem += aiItemCount RemoveItem(akBaseItem, aiItemCount, False, PlayerRef) EndIfElse RemoveItem(akBaseItem, aiItemCount, False, akSourceContainer)EndIfEndEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)If (akDestContainer == Game.GetPlayer()) UnregisterForUpdate()EndIfPlacedItem -= aiItemCountRegisterForSingleUpdate(0.1) ;This event only fires when the player attempts to add more than one item to the container, and when the player physically removes a displayed item. ;The latter won't have any object to "drop" but the MountCurrentItem function will still fire, is this bad?EndEventEvent OnUpdate() MountCurrentItem(ItemBase, ItemRef)EndEventFunction MountCurrentItem(Form akBaseItem, ObjectReference akItemReference) ObjectReference MountedItem TriggerMarker = GetLinkedRef(WRackTrigger) Int i = 0 If (akItemReference) DropObject(akBaseItem) MountedItem = akItemReference Else MountedItem = DropObject(akBaseItem) EndIf If (MountedItem != None) Blocked = True While(!MountedItem.Is3DLoaded()) && (i < 10) Utility.Wait(0.1) i += 1 EndWhile;Use MoveToNode MountedItem.SetMotionType(Motion_Keyframed, False) If MountedItem.HasKeyword(WeapTypeSword) MountedItem.MoveToNode(TriggerMarker, "SwordPivot01") endif If MountedItem.HasKeyword(WeapTypeWarAxe) MountedItem.MoveToNode(TriggerMarker, "WarAxePivot01") endif If MountedItem.HasKeyword(WeapTypeMace) MountedItem.MoveToNode(TriggerMarker, "MacePivot01") endif If MountedItem.HasKeyword(WeapTypeGreatSword) MountedItem.MoveToNode(TriggerMarker, "GreatSwordPivot01") endif If MountedItem.HasKeyword(WeapTypeBattleAxe) MountedItem.MoveToNode(TriggerMarker, "BattleAxePivot01") endif If MountedItem.HasKeyword(WeapTypeWarhammer) MountedItem.MoveToNode(TriggerMarker, "WarhammerPivot01") endif If MountedItem.HasKeyword(WeapTypeBow) MountedItem.MoveToNode(TriggerMarker, "BowPivot01") endif If MountedItem.HasKeyword(WeapTypeStaff) MountedItem.MoveToNode(TriggerMarker, "StaffPivot01") endif If MountedItem.HasKeyword(WeapTypeDagger) MountedItem.MoveToNode(TriggerMarker, "DaggerPivot01") endif Utility.Wait(1) Blocked = False ItemRef = None EndifEndFunctionBool Function AllowedItems(Form akBaseItem)If (DisplayType == 1) Return (akBaseItem as Weapon)ElseIf (DisplayType == 2) Return (akBaseItem.HasKeyword(WeapTypeDagger))ElseIf (DisplayType == 3) Return ((akBaseItem.HasKeyword(ClothingRing)) || (akBaseItem.HasKeyword(VendorItemGem)))ElseIf (DisplayType == 4) Return (akBaseItem.HasKeyword(ArmorShield))ElseIf (DisplayType == 5) Return ((akBaseItem.HasKeyword(VendorItemPotion)) || (akBaseItem.HasKeyword(VendorItemPoison)) || (WhitePhial.HasForm(akBaseItem)) || (PoisonList.HasForm(akBaseItem)))ElseIf (DisplayType == 6) Return (ClawList.HasForm(akBaseItem))ElseIf (DisplayType == 7) Return ((akBaseItem.HasKeyword(WeapTypeSword)) || (akBaseItem.HasKeyword(WeapTypeGreatSword)))ElseIf (DisplayType == 8) Return (UniqueJarList .HasForm(akBaseItem))ElseIf (DisplayType == 9) Return (akBaseItem.HasKeyword(ClothingNecklace))EndIfEndFunction
No idea where things are going wrong. Any suggestions/solutions/workarounds would be extremely welcome.
Halp!