Jump to content

Photo

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

weapon script skyrim sound trigger

  • Please log in to reply
3 replies to this topic

#1
Raccoonmancer

Raccoonmancer

    Stranger

  • Members
  • Pip
  • 4 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 :)



#2
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,845 posts

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.



#3
Raccoonmancer

Raccoonmancer

    Stranger

  • Members
  • Pip
  • 4 posts

Thanks a lot! Managed to do it. :)



#4
dylbill

dylbill

    Resident poster

  • Premium Member
  • 2,845 posts

No problem, happy modding :)







Also tagged with one or more of these keywords: weapon, script, skyrim, sound, trigger

IPB skins by Skinbox
Page loaded in: 1.032 seconds