What's the easiest way to...

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
play a 3D sound when I cast an ability?

I've checked the natives and BJs in JassCraft, but they weren't as self-explanatory as most other Natives/BJs.

Could anyone point me in the right direction please?
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
Err... I dunno. Usually, I don't check JassCraft for native and BJs. I do it in GUI, convert it, and see what it does, takes, blah blah. Then, if it's a BJ (it usually is), search JassCraft for the BJ, and look at the natives it calls. Then go from there.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
JASS:
function PlaySoundOnUnitBJ takes sound soundHandle, real volumePercent, unit whichUnit returns nothing
    call AttachSoundToUnitBJ(soundHandle, whichUnit)
    call SetSoundVolumeBJ(soundHandle, volumePercent)
    call PlaySoundBJ(soundHandle)
endfunction


JASS:
function PlaySoundAtPointBJ takes sound soundHandle, real volumePercent, location loc, real z returns nothing
    call SetSoundPositionLocBJ(soundHandle, loc, z)
    call SetSoundVolumeBJ(soundHandle, volumePercent)
    call PlaySoundBJ(soundHandle)
endfunction


spell cast - play sound on trigger unit
 

0zaru

Learning vJASS ;)
Reaction score
60
JASS:
 takes sound soundHandle


That's the soundHandle that is a sound
call Whatever(<YourSound>, bla bla bla)
 

illidan92

New Member
Reaction score
6
Only kill it if you play it once, methinks.

Heres a quick custom function i'll write for you:

Code:
function SoundAtLoc takes sound s location l returns nothing
  call SetSoundPosition(s,GetLocationX(l),GetLocationY(l),0)
  call StartSound(s)
endfunction

There you go!

If you want me to create a local sound variable that is in itself distinguishable just ask. I'm pretty sure that one will run the fastest, though, unless it leaks.

To fill in the parameters for a unit casting a spell you would use SoundAtLoc(gg_snd_WhatSoundYouWant, GetUnitLoc(GetSpellAbilityUnit()) That would leak though so if you want to fix the leaks you would do:

Code:
local unit u = GetSpellAbilityUnit()
local location l = GetUnitLoc(u)
call SoundAtLoc(gg_snd_WhatSoundYouWant, l)
set u = null
call RemoveLocation(l)
set l = null
Yup, just put that in your functions in the trigger and my custom func in the custom script section (click your map name at the top in the trigger editor).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top