Jump to content

[LE] How to trigger a sound file when a certain area/location is reached with a specific weapon equiped?


Recommended Posts

Pretty much what the title says.

 

To detail my use case a bit more in steps;

 

1. I've created a custom weapon.

2. When entering specific areas or entering a 'trigger box', it would play a sound file, in this case someone speaking to you, without there being an actual NPC (Imagine Meridia's Beacon when you pick up the item for the first time). The requirement for the sound file to play, would be that you must have the weapon either in your inventory or your hand.

 

My main question is if someone could provide me a general idea or tutorial that I could look at to try and do something like this.

 

Thank you for any and all answers :)

Link to comment
Share on other sites

You can put a script on a triggerbox with conditions. Something like this:

 

Scriptname TM_ObjectReferenceScript extends ObjectReference 

Weapon Property MyWeapon Auto 
Sound Property MySound Auto 
Actor Property PlayerRef Auto

Event OnTriggerEnter(ObjectReference akActionRef)
    If akActionRef == PlayerRef ;did the player enter this trigger box?
        If PlayerRef.GetItemCount(MyWeapon) > 0 ;does the player have at least one of MyWeapon in inventory
            MySound.Play(PlayerRef) ;Play MySound from PlayerRef
        Endif 
    endif 
EndEvent

If you're new to scripting, I recommend doing a beginner scripting tutorial. There's a lot of em out there.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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