• 🏆 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!

How do I play a sound file when casting a certain spell?

Status
Not open for further replies.
  • Ereignisse
    • Unit - A unit starts the effect of an ability
  • Bedingungen
    • (Ability being cast) Gleich YourAbility
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Triggering unit)


  • Ereignisse
    • Unit - A unit gets attacked
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Attacked unit)


Just import your sounds in SoundEditor. :wink:
 
Level 11
Joined
Oct 11, 2012
Messages
711
  • Ereignisse
    • Unit - A unit starts the effect of an ability
  • Bedingungen
    • (Ability being cast) Gleich YourAbility
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Triggering unit)


  • Ereignisse
    • Unit - A unit gets attacked
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Attacked unit)


Just import your sounds in SoundEditor. :wink:

Thanks, +Rep.
 

nGy

nGy

Level 11
Joined
Apr 15, 2011
Messages
123
If the sound should always be played if a specific spell is cast, you can add it in the object editor as well (you may have 'View sounds' disabled in the object editor, so if you don't see it right away, look there).
For the "getting hit" I recommend using a damage detection system, rather than the "Unit is attacked" event, because that's more accurate and takes into account spell damage. Though, for that second case, you may need someone to adapt the system, so that the sound isn't spammed like crazy.
 
Level 6
Joined
Oct 1, 2012
Messages
166
  • Ereignisse
    • Unit - A unit starts the effect of an ability
  • Bedingungen
    • (Ability being cast) Gleich YourAbility
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Triggering unit)


  • Ereignisse
    • Unit - A unit gets attacked
  • Aktionen
    • Sound - Play YourSound at 100.00% volume, attached to (Attacked unit)


Just import your sounds in SoundEditor. :wink:


I believe that sounds leak. Everything leaks but for the integers, reals and booleans, damn the WE.

If you want it not to leak, you'd have to destroy the sound. What is bad about it is, if you use the sounds from Sound Editor, the KillSound function will remove it permanently.

I had this problem, couldn't find an answer, so I made a function with CreateSound and setting all the sound stats there, but it's jass-dependable.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Sounds only leak in the sense that it is still in the memory, in GUI I believe each sound is a global and it has only effectively "leaked" when after you're finished using it you do not destroy it.

Long story short if the supposed spell that needs a sound as the OP mentioned is removed from the unit, (with a assumption it will never be used again) at that time it would a good idea to destroy the sound.
 
Level 6
Joined
Oct 1, 2012
Messages
166
Ah, yes, globals. Sorry for that interruption, I didn't use GUI for so long, that I don't remember much about it :D
 
Level 6
Joined
Oct 1, 2012
Messages
166
It is, but it never happened to me with GUI, only in making sound via CreateSound by Jass. I guess it's some deeper problem.
 
Status
Not open for further replies.
Top