I want a certain sound to play.

Post » Sat May 28, 2011 8:22 am

Well, the topic title and the topic description tells everything. I need a sound to play every time I hit something with my lute. Is there an easy way to do this, with just one short script? I assume I can't use "Begin OnHit" -beginning block, as it applies only to the predetermined reference, IIRC. I could do it by placing a script like "Begin OnHit TheLuteIUse;playsound TheSoundIUse;end", but I would have to place that row into every actor's and creature's script... And the code wouldn't work with mod-added NPCs :D

So, once again I ask, is there an easy way to do it?

EDIT: http://www.tesnexus.com/downloads/file.php?id=33331
User avatar
Trent Theriot
 
Posts: 3395
Joined: Sat Oct 13, 2007 3:37 am

Post » Sat May 28, 2011 11:34 am

Aye lads, me bumps this! Does anyone know how to do this?
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Sat May 28, 2011 1:55 pm

No script on the other actor?
No there is not an easy way to do this. But it can be done with 99% accuracy with OBSE.
Grab and check the Ref in the player's crosshair with a quest script like so:


Ref Targetfloat fquestdelaytimebegin gamemodeset fquestdelaytime to .01;(may work with 0.1) if player.isattacking == 1 && player.iscasting == 0  set Target to GetCrosshairRef      if Taget != 0        if Target.isactor == 1                if ( Target.IsAnimPlaying + Target.IsIdlePlaying ) > 0; checks for a BUNCH of issues such as if the actor is unconscious and many other potential problems. Not perfect but  works most of the time.                    if target.getsoundplaying "*hit* > 0 && ( player.GetHeadingAngle target > -20 ) && ( player.GetHeadingAngle target < 20 )                         target.playsound3d MySound                     endif                endif        endif     endif     endifend


So as I said this will work 99% of the time as expected. But once in a while you may hear the sound right before the hit actually lands if another NPC is also hitting the one you are aiming for.

If you are willing to put a temporary token on your target (it is given to the target in a fraction of a second before you land your blow)
that runs a health check to detect when their health drops you can increase the accuracy to 99.9 percent. But if you do no damage to them this will not work.

OBSE 19 has a possible solution as well to runing onhit blocks on a crosshair ref. But that is a little out of my realm of knowledge to explain it.


Well, the topic title and the topic description tells everything. I need a sound to play every time I hit something with my lute. Is there an easy way to do this, with just one short script? I assume I can't use "Begin OnHit" -beginning block, as it applies only to the predetermined reference, IIRC. I could do it by placing a script like "Begin OnHit TheLuteIUse;playsound TheSoundIUse;end", but I would have to place that row into every actor's and creature's script... And the code wouldn't work with mod-added NPCs :D

So, once again I ask, is there an easy way to do it?

EDIT: http://www.tesnexus.com/downloads/file.php?id=33331

User avatar
Thema
 
Posts: 3461
Joined: Thu Sep 21, 2006 2:36 am

Post » Sat May 28, 2011 5:00 am

No script on the other actor?
No there is not an easy way to do this. But it can be done with 99% accuracy with OBSE.
Grab and check the Ref in the player's crosshair with a quest script like so:


Ref Targetfloat fquestdelaytimebegin gamemodeset fquestdelaytime to .01;(may work with 0.1) if player.isattacking == 1 && player.iscasting == 0  set Target to GetCrosshairRef      if Taget != 0        if Target.isactor == 1                if ( Target.IsAnimPlaying + Target.IsIdlePlaying ) > 0; checks for a BUNCH of issues such as if the actor is unconscious and many other potential problems. Not perfect but  works most of the time.                    if target.getsoundplaying "*hit* > 0 && ( player.GetHeadingAngle target > -20 ) && ( player.GetHeadingAngle target < 20 )                         target.playsound3d MySound                     endif                endif        endif     endif     endifend


So as I said this will work 99% of the time as expected. But once in a while you may hear the sound right before the hit actually lands if another NPC is also hitting the one you are aiming for.

If you are willing to put a temporary token on your target (it is given to the target in a fraction of a second before you land your blow)
that runs a health check to detect when their health drops you can increase the accuracy to 99.9 percent. But if you do no damage to them this will not work.

OBSE 19 has a possible solution as well to runing onhit blocks on a crosshair ref. But that is a little out of my realm of knowledge to explain it.

Yes, that could very well work with NPC's, but I'd also need the sound to play when hitting objects etc.... I think I'll just script it so, that when the LMB is pressed when the Lute is equipped, it will play the sound... It might have synch problems etc., but... Well...
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm


Return to IV - Oblivion