NexBeth Posted August 12, 2019 Posted August 12, 2019 Well, long story short, I've been trying to get a sound marker to go on then off at certain times. I initially attempted to apply conditions within AI packages to make it go off. That should have worked, but could never get it to work. https://forums.nexusmods.com/index.php?/topic/7788313-set-a-condition/ Now, and I think it is actually a better option, I am trying to get this to be triggered when an NPC enters the trigger (on sound) and leaves trigger (off sound). I've got the triggerbox set with the following script attached: Reveal hidden contents Scriptname EP_NameScript extends ObjectReference Int iCount = 0 ;Event OnTriggerEnter(ObjectReference akActionRef) If (akActionRef as Actor) && akActionRef != Game.GetPlayer() iCount += 1 ObjectReference kTemporary = GetLinkedRef() ; If iCount == 1 && kTemporary && kTemporary.IsDisabled() ; kTemporary.Enable() EndIf EndIfEndEventEvent OnTriggerLeave(ObjectReference akActionRef) If (akActionRef as Actor) && akActionRef != Game.GetPlayer() iCount -= 1 ObjectReference kTemporary = GetLinkedRef() ; s If iCount == 0 && kTemporary && !kTemporary.IsDisabled() ; kTemporary.Disable() EndIf EndIfEndEvent No properties on script.This triggerbox is link-ref to an activator (below).Z is set to number other than zero. Have activator (initially disabled) with defaulttoggleselfonactivate script attached, no propertiesHas player activation tickedZ is set to number other than zero Sounder maker has the above activator set as Enable Parent. Won't work. I'm not a script-er. The script above was gifted to me for another very similar situation, but for some reason won't work. Any help is appreciated. Thanks
agerweb Posted August 12, 2019 Posted August 12, 2019 Not sure what the iCount is for, can't you keep it simple: EVENT onTriggerEnter(objectReference akActionRef) if akActionRef == Game.GetPlayer() ;Do something endifendEventEVENT OnTriggerLeave(objectReference akActionRef) if akActionRef == Game.GetPlayer() ;Do something else endifendEvent Also kTemporary is a property and needs to be defined.
Evangela Posted August 12, 2019 Posted August 12, 2019 iCount is used to keep track of how many/when objects enter and leave the trigger. It's an old way to ensure that the events do not fire out of sequence(i.e OnTriggerLeave firing before OnTriggerEnter). The creator of papyrus though has stated in the past the GetTriggerObjectCount() is better.
NexBeth Posted August 12, 2019 Author Posted August 12, 2019 But is the iCount the reason this isn't working? Because it is working on a similar set up in the mod using a moveable static instead of the sound marker. Thanks for responding.
maxarturo Posted August 12, 2019 Posted August 12, 2019 " Now, and I think it is actually a better option, I am trying to get this to be triggered when an NPC enters the trigger (on sound) and leaves trigger (off sound). " Why don't you use a default vanilla script ? : defaultDisableExitEnableEnter This script will disable the triggerbox's linked references when the player exits the triggerbox, then enables them when the player enters the triggerbox. This script will only work on triggerboxes. Only 5 linked references can be recognized.
NexBeth Posted August 12, 2019 Author Posted August 12, 2019 On 8/12/2019 at 2:35 PM, maxarturo said: " Now, and I think it is actually a better option, I am trying to get this to be triggered when an NPC enters the trigger (on sound) and leaves trigger (off sound). " Why don't you use a default vanilla script ? :defaultDisableExitEnableEnter This script will disable the triggerbox's linked references when the player exits the triggerbox, then enables them when the player enters the triggerbox. This script will only work on triggerboxes. Only 5 linked references can be recognized. I would gladly but as I said I'm not a scripter so I don't know which one might work. Right now the activator which is linked to the trigger as defaulttoggleselfonactivate script attached, which is a vanilla script. Also, this needs to work with NPCs not the player.
maxarturo Posted August 12, 2019 Posted August 12, 2019 I don't know why you need an " Activator ", but you can Link Ref the " Sounder maker " directly to the script's properties ( MyREF ). * " Sound Marker " should be in a initialy disable state. Script should look something like this so that all actors can trigger it : Reveal hidden contents ObjectReference Property MyREF Auto {Enable and Disable Link Ref on Trigger Enter - Leave} ObjectReference Property MyActivator auto {Activates Activator} EVENT onTriggerEnter(objectReference triggerRef) if triggerRef as Actor == TRUE MyREF.Enable() MyActivator.Activate(self) EndIf ENDEVENT EVENT onTriggerLeave(objectReference triggerRef) if triggerRef as Actor == TRUE MyREF.Disable() MyActivator.Activate(self) EndIf ENDEVENT
agerweb Posted August 12, 2019 Posted August 12, 2019 As I pointed out above this may be your problem "Also kTemporary is a property and needs to be defined".
NexBeth Posted August 12, 2019 Author Posted August 12, 2019 (edited) @maxarturo: Thanks for writing that up for me. You said I don't need an activator but you included a property for an activator? Not sure what to do. I've created the script and it compiled. Linked the myRef property to the sound marker. Just need to understand the activator part? Edited August 12, 2019 by NexBeth
Recommended Posts