• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Change unit attack sound?

Status
Not open for further replies.

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
Heya!

I'm wondering if it is possible to change a unit's attack sound (Slash, Bash etc.) with triggers? For an example if my unit picks up a sword he will have a Slash sound but if he picks up a hammer he will have a Bash sound.
Thanks! :)

+ rep to all helpers ;)
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Kaijyuu That is actually a rather good idea. I have a damage detection system that I am using, so setting the attack sound to an empty sound file and then adding it manually might actually be a very good idea :) Thanks!
However, is there any way of doing this with triggers? I'm imagining "Change unit's attack sound to XXX" ?

Thanks ;)
 
@Kaijyuu That is actually a rather good idea. I have a damage detection system that I am using, so setting the attack sound to an empty sound file and then adding it manually might actually be a very good idea :) Thanks!
Yeah the damage system gives you the moment to play the sound. I would recomment using an 0 damage action with the jass damageunit function, this will reduce your part to do to:
save current combatsound onto your hero
use saved one in the damage event trigger.​
JASS:
native UnitDamageTarget  takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

With values
JASS:
  call UnitDamageTarget(udg_Target, udg_Target, 0 , true, true, null, null, udg_WeaponSound)

Damage Engine
  • Hit Play Sound
    • Events
      • Game - AfterDamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource is A Hero) Equal to True
      • IsDamageSpell Equal to False
    • Actions
      • Trigger - Turn off (This trigger)
      • Set Index = (Custom value of DamageEventSource)
      • Custom script: call UnitDamageTarget(udg_DamageEventTarget, udg_DamageEventTarget, 0 , true, true, null, null, udg_CombatSound[udg_Index])
      • Trigger - Turn on (This trigger)
 
Last edited:

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Tasyen Thank you again Tasyen! You are a real friend!
Very good information, I'm impressed that you knew with such precision exactly what I was asking for :)

Unfortunately the problem is a bit more complex than that. I've further explained my problem here if you'd be interested in having a look. It comes down to GetLastAnimation, atleast the way I'm seeing myself solving this for now.

Get Last Played Animation
 
Status
Not open for further replies.
Top