• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] 3D Sound Attachment

Status
Not open for further replies.
Level 3
Joined
Oct 8, 2017
Messages
20
I have a trigger that it attaches 3D sound to unit that loops itself as default sound for the unit as it stands moves or whatever it does, but whenever it attaches the same sound on another unit the previous sound stops.
 
Level 21
Joined
Dec 4, 2007
Messages
1,478
That's a sound engine limitation, can't have too many sounds playing via the same channel (like animations).
You can try to split your sounds more evenly between all channels.
 
Level 3
Joined
Feb 24, 2016
Messages
38
sounds like youll want to add the sound to the model with like War3 Model Editor
some units like peasants and such have their sounds in the model instead of an option in the unit editor. there are a few tutorials on youtube and stuff which make it pretty easy to figure out. ive used it to add the repair sound to a custom worker model and it works with playing the sound when theres multiple units doing that action.

EDIT - ill see if i can find the youtube video i used to help me with the worker
 
Level 3
Joined
Feb 24, 2016
Messages
38
sounds like youll want to add the sound to the model with like War3 Model Editor
some units like peasants and such have their sounds in the model instead of an option in the unit editor. there are a few tutorials on youtube and stuff which make it pretty easy to figure out. ive used it to add the repair sound to a custom worker model and it works with playing the sound when theres multiple units doing that action.

EDIT - ill see if i can find the youtube video i used to help me with the worker
as i did some research i dont think it was a video i used, im pretty sure it was this tutorial.
Adding sounds and attachments
lots of pictures, step by step, should help out a bunch with giving units their own sounds
 
Level 3
Joined
Feb 24, 2016
Messages
38
maybe there is a different program for modeling that you can import that to and then export it as an mdx file so that all the files are in one, theres gotta be a way to make it all in one file...
 
Level 13
Joined
May 10, 2009
Messages
868
I have a trigger that it attaches 3D sound to unit that loops itself as default sound for the unit as it stands moves or whatever it does, but whenever it attaches the same sound on another unit the previous sound stops.

Could you post your trigger, please? Judging from that description, sounds like you are trying to create and attach the same sound handle onto both units. Also, you should be able to, at least, play a few instances of sounds in the same sound channel, so two instances should be audible.
 
Level 3
Joined
Oct 8, 2017
Messages
20
The trigger is not the probelm i even loop 2 times created unit and attached the sound to it
  • StartSound
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Havoc (Helicopter)
          • (Unit-type of (Triggering unit)) Equal to Transport Helicopter
    • Actions
      • Set HeliCount = (HeliCount + 1)
      • Set HeliCount2 = (HeliCount2 + 1)
      • Unit - Set the custom value of (Triggering unit) to HeliCount
      • Set HeliSound[HeliCount] = helirotor2 <gen>
      • Sound - Play helirotor2 <gen> at 100.00% volume, attached to (Triggering unit)
 
Level 13
Joined
May 10, 2009
Messages
868
oh, as I thought. There is only one sound handle (instance) created, and you're trying to share it with all existing helicopters.

  • Set HeliSound[HeliCount] = helirotor2 <gen>
Unfortunately, that doesn't really create a new sound. Instead the variable is being told to just point to that existing sound, which was created in the Sound Editor.

Here is the "behind the scenes":
Untitled-2.png


The sound editor creates a sound (Sherlock strikes again), and also generates a variable for it. You can't see it in the trigger editor, but it is there - in the "war3map.j" file:
JASS:
//***************************************************************************
//*
//*  Sounds
//*
//***************************************************************************

function InitSounds takes nothing returns nothing
    set gg_snd_EnchantedCellLoop=CreateSound("Sound\\Ambient\\DoodadEffects\\EnchantedCellLoop.wav", false, true, true, 10, 10, "DefaultEAXON")
    call SetSoundParamsFromLabel(gg_snd_EnchantedCellLoop, "EnchantedCellLoop")
    call SetSoundDuration(gg_snd_EnchantedCellLoop, 4999)
endfunction
You just have to use that CreateSound() function in order to create a new sound instance. I don't think there is one in GUI.

I'll try to help you out with the following:
JASS:
function AttachSoundUnit takes unit u, string s, integer volume, integer channel, integer duration, boolean doesLoop,boolean stopoutofrange, integer FadeIn, integer FadeOut returns nothing
    set udg_lastCreatedSound = CreateSound (s, doesLoop, true, stopoutofrange, FadeIn, FadeOut, "DefaultEAXON")
    call SetSoundDuration(udg_lastCreatedSound, duration)
    call SetSoundChannel(udg_lastCreatedSound, channel)
    call SetSoundVolume(udg_lastCreatedSound, volume)
    call SetSoundPitch(udg_lastCreatedSound, 1.0)
    call SetSoundDistances(udg_lastCreatedSound, FadeIn, FadeOut)
    call SetSoundDistanceCutoff(udg_lastCreatedSound, FadeOut * .75)
    call SetSoundConeAngles(udg_lastCreatedSound, 0.0, 0.0, volume)
    call SetSoundConeOrientation(udg_lastCreatedSound, 0.0 , 0.0 , 0.0)
    call AttachSoundToUnit(udg_lastCreatedSound, u)
    call StartSound(udg_lastCreatedSound)
endfunction
That snippet contains everything you need to create a new source of sound. It also plays the sound as soon as you call it. Before using it, you need to create a GUI variable:
Untitled-3.png


Then, copy and paste the code in your map header:
Click on it to zoom in
Untitled-4.png

At last, you remove that Attach Sound action
  • Sound - Play helirotor2 <gen> at 100.00% volume, attached to (Triggering unit)
replacing it with

  • Custom script: call AttachSoundUnit(GetTriggerUnit(), "PathToYourSound\\helirotor2.wav", 127, 9, 2000, true, false, 0, 3000)
  • Set HeliSound[HeliCount] = lastCreatedSound
Now, compare this
JASS:
call AttachSoundUnit(GetTriggerUnit(), "PathToYourSound\\helirotor2.wav", 127, 9, 2000, true, false, 0, 3000)
with
JASS:
function AttachSoundUnit takes unit u, string s, integer volume, integer channel, integer duration, boolean doesLoop,boolean stopoutofrange, integer FadeIn, integer FadeOut returns nothing
I hope comparison mentioned above helps you to understand what each argument from "AttachSoundUnit" function does.

//======

Something tells me that there is an easier way to achieve that, but you'd have to be careful with leaks. Oh, and don't forget to destroy the sound when a unit dies or gets removed from the game.
 
Last edited:
Level 3
Joined
Oct 8, 2017
Messages
20
btw how do i refer to that sound your variable is not array, i guess ill make it, tell me if im wrong

Edit - Nevermind just noticed its local variable
 
Status
Not open for further replies.
Top