• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Sound Volume + No. of Units in Camera Bounds

Status
Not open for further replies.
Level 5
Joined
Oct 7, 2005
Messages
102
Hey guys.

I'm making a zombie simulation map.

Basically what I'm trying to tackle at the moment is a trigger that adjusts the volume of an ambient zombie crowd sound I have to the appropriate level based on how many zombies there are in the players camera bounds.

So for example, there are only 5 zombies in the players camera view, so the volume of the sound is set to 10%.

Then the player scrolls across the map to an area with 50 zombies, so the sound volume goes up to 80%.

Is this possible? And is it also possible to make it relative to each player? I don't want players who can't see any zombies hearing a horde if you see what I mean.

I would rather this trigger were written in GUI form if possible, I have no idea how to use JASS.

Thanks guys.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
It's very possible yep. Using 3D sound simulation. Every player has his own Camera-bounds-rect. And the volume would be automatically set according to distance since the sound is 3D. Yet, there is one problem which is if the sounds you have are 3D or not.
That's how far I think for now, worth to try :
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Set CameraTarget = (Target of Camera[(Player number of (Picked player))])
        • Set ZombiesInArea = (Units within (Distance to target of Camera[(Player number of (Picked player))]) of CameraTarget matching ((Unit-type of (Matching unit)) Equal to Zombie))
        • Unit Group - Pick every unit in ZombiesInArea and do (Actions)
          • Loop - Actions
            • Set Num_Zombies = (Num_Zombies + 1)
        • Sound - Play No sound at (5.00 x (Real(Num_Zombies)))% volume, located at CameraTarget with Z offset 0.00
        • Sound - Set (Last played sound) distances to 0.00 minimum and (Distance to target of Camera[(Player number of (Picked player))]) maximum
        • Custom script: call RemoveLocation(udg_CameraTarget)
        • Custom script: call DestroyGroup(udg_ZombiesInArea)
        • Set Num_Zombies = 0
 
Level 5
Joined
Oct 7, 2005
Messages
102
Thanks mate, I will try this out and get back to you if I can or can't get it to work.

Edit: I'm guessing the event for this trigger is going to be a periodic event?
 
Level 5
Joined
Oct 7, 2005
Messages
102
It will be constantly updated depending on where the players camera is looking. So I'm guessing periodic is the best way?
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hmmm, periodic event would work, it's good to fix the camera and prevent getting rid of it also. I forgot to tell that every player should have a camera object for him and store it as a variable with a player number array thus my trigger works.
The reason I said periodic event works because I null every value so it wouldn't effect but I won't guarantee a lagless game. Use 0.05 or higher periodics.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Be aware that player camera locations are not automatically synchronized in WC3. As such there may be considerable latency in multiplayer between the camera moving and such movement being reflected inside triggers. It will also generate considerably more net traffic which could raise lag.

What you should much rather do is attach 3D zombie sounds to random zombies inside the crowd. The more zombies that are nearby, the louder you make these 3D sounds. You can stagger the computation over several ticks to avoid poor performance as chances are you will be counting units around a single unit to compute the correct loudness which becomes O(n^2) based in dense crowds.
 
Level 5
Joined
Oct 7, 2005
Messages
102
The trigger you gave me isn't working I'm afraid.

After considering Super Good's comment, I'll try that method.

Could I get a GUI trigger of that please? I can't figure out how to create the 'crowd' that won't cause lag.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
What sort of lag you experience? Lag usually corresponds to input to output delay such as issuing an order takes 1+ seconds before the order is actually issued inside the game and the unit starts to execute the order. If you experience high frame drop (or low frame rate if you look at it that way) then that is poor performance and a result of the game trying to do something computationally expensive (eg rendering the entire map at once, WC3 is not as optimized as games like TES Skyrim) or something critical that has a long block time (I/O related like preloading assets or saving a screenshot).
 
Level 5
Joined
Oct 7, 2005
Messages
102
Are you sure the sound you included is 3D ? Also is it causing lag ? Or just not working?

If by 3D, the 3D box was ticked. Or is it not that simple?

What sort of lag you experience? Lag usually corresponds to input to output delay such as issuing an order takes 1+ seconds before the order is actually issued inside the game and the unit starts to execute the order. If you experience high frame drop (or low frame rate if you look at it that way) then that is poor performance and a result of the game trying to do something computationally expensive (eg rendering the entire map at once, WC3 is not as optimized as games like TES Skyrim) or something critical that has a long block time (I/O related like preloading assets or saving a screenshot).

I haven't experienced any lag yet, but I'm anticipating what you're saying and I can't think of a way that I know would not cause lag.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I haven't experienced any lag yet, but I'm anticipating what you're saying and I can't think of a way that I know would not cause lag.
Ops I think that was intended for another thread (been dealing a lot with performance recently).

Anyway how you do it is to have an a list of structures (parallel arrays). Obviously one is the sound object itself (so you can stop playing it) and the other is the unit itself. You then iterate through sections of the list periodically (say 10-20 units) and destroy their sounds (if any) and add new sounds to random members with loudness based on how many zombies are nearby. When new zombies are created add them to end of list, when zombies die remove them and swap them with the list end. For efficient removal consider using a hashtable to map zombies to their index in the list.
 
Status
Not open for further replies.
Top