3D sounds

elmstfreddie

The Finglonger
Reaction score
203
In the sound editor, you can convert any mp3 to/from being a 3d sound...

the only difference from a 3d sound and a normal sound is that the intensity of 3d sounds changes depending on how close you are to the source of the sound. Whereas non-3d sounds will play at the same volume no matter where your camera is.

Btw. What relevance to JASS does this have..?
 

wraithseeker

Tired.
Reaction score
122
Because I am going to do it in vJASS and not touching the Sound editor at all, there's a native that allows me to do that.

Yeah thats why I needed 3D sounds.
 

elmstfreddie

The Finglonger
Reaction score
203
Ah, I see. Well could you post your code that doesn't work so we could maybe just fix it?
Could you also specify precisely what is wrong?
 

wraithseeker

Tired.
Reaction score
122
JASS:
scope deathpact initializer Init

globals
    private constant integer SPELL = 'A00P'
    private constant string EFFECT = "MDX\\NewDarkPillar.mdx"
    private sound SLEEP
    private constant string UDEATH = "Objects\\Spawnmodels\\Undead\\UDeathMedium\\UDeath.mdl"
endglobals

private struct data
//! runtextmacro PUI()
    unit caster
    unit target
    unit dummy
    timer t
    integer ticks
    
static method create takes nothing returns data
    local data d = data.allocate()
    set d.caster = GetTriggerUnit()
    set d.target = GetSpellTargetUnit()
    set d.t = NewTimer()
    set d.dummy = CreateUnit(GetOwningPlayer(d.caster),DUMMY,GetUnitX(d.target),GetUnitY(d.target),GetUnitFacing(d.target))
    set d.ticks = 0
    call UnitApplyTimedLife(d.dummy,'BTLF',3)
    call StunUnit(d.target,3)
    call AddTimedEffectTarget(EFFECT,d.dummy,"origin",1)
    return d
endmethod

endstruct

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELL
endfunction

private function Loop takes nothing returns nothing
    local data d = data(GetTimerData(GetExpiredTimer()))
    local real TLife = GetWidgetLife(d.target) * 0.10
    local real TMana =  GetUnitState(d.target,UNIT_STATE_MANA) *0.10
    local real x = GetUnitX(d.target)
    local real y = GetUnitY(d.target)
    call SetWidgetLife(d.caster,GetWidgetLife(d.caster)+ TLife)
    call SetUnitState(d.caster,UNIT_STATE_MANA,GetUnitState(d.caster,UNIT_STATE_MANA) + TMana)
    call SetWidgetLife(d.target,GetWidgetLife(d.target)-TLife)
    call SetUnitState(d.target,UNIT_STATE_MANA,GetUnitState(d.target,UNIT_STATE_MANA) - TMana)
    set d.ticks = d.ticks + 1
    if d.ticks == 3 then
        call ReleaseTimer(d.t)
        call DestroyEffect(AddSpecialEffect(UDEATH,x,y))
        call SetUnitExploded(d.target,true)
        call KillUnit(d.target)
    endif
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local data d
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        call StartSound(SLEEP)
        set d = data.create()
        set data<u> = d
        call SetTimerData(d.t,d)
        call TimerStart(d.t,1,true,function Loop)
        set u = null
        set t = null
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
        set d = data<u>
        call ShowUnit(d.dummy,false)
        call StopEffect(1)
        call RemoveUnit(d.dummy)
        call d.destroy()
        set u = null
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
    call TriggerAddAction( t, function Actions )
    call TriggerAddCondition(t,Condition(function Conditions))
    //set SLEEP = CreateSoundFromLabel(&quot;SleepBirth1&quot;,false,true,true,10,10)
    set SLEEP = CreateSound(&quot;Internal\\Abilities\\Spells\\Undead\\SleepBirth1&quot;,false,true,true,10,10,&quot;&quot;)
    call StartSound(SLEEP)
    call Preload(&quot;Internal\\Abilities\\Spells\\Undead\\SleepBirth1&quot;)
    call SetSoundVolume(SLEEP,2000)
endfunction
endscope</u></u>


Sound doesn't play.
 

wraithseeker

Tired.
Reaction score
122
Attached it but still I can't hear it.

JASS:
scope deathpact initializer Init

globals
    private constant integer SPELL = &#039;A00P&#039;
    private constant string EFFECT = &quot;MDX\\NewDarkPillar.mdx&quot;
    private sound SLEEP
    private constant string UDEATH = &quot;Objects\\Spawnmodels\\Undead\\UDeathMedium\\UDeath.mdl&quot;
endglobals

private struct data
    unit caster
    unit target
    unit dummy
    timer t
    integer ticks
    
    implement AutoData
    
static method create takes nothing returns data
    local data d = data.allocate()
    set d.caster = GetTriggerUnit()
    set d.target = GetSpellTargetUnit()
    set d.t = NewTimer()
    set d.dummy = CreateUnit(GetOwningPlayer(d.caster),DUMMY,GetUnitX(d.target),GetUnitY(d.target),GetUnitFacing(d.target))
    set d.ticks = 0
    call UnitApplyTimedLife(d.dummy,&#039;BTLF&#039;,3)
    call StunUnit(d.target,3)
    call AddTimedEffectTarget(EFFECT,d.dummy,&quot;origin&quot;,1)
    return d
endmethod


endstruct

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELL
endfunction

private function Loop takes nothing returns nothing
    local data d = data(GetTimerData(GetExpiredTimer()))
    local real TLife = GetWidgetLife(d.target) * 0.10
    local real TMana =  GetUnitState(d.target,UNIT_STATE_MANA) *0.10
    local real x = GetUnitX(d.target)
    local real y = GetUnitY(d.target)
    call AttachSoundToUnit(SLEEP,d.target)
    call StartSound(SLEEP)
    call SetWidgetLife(d.caster,GetWidgetLife(d.caster)+ TLife)
    call SetUnitState(d.caster,UNIT_STATE_MANA,GetUnitState(d.caster,UNIT_STATE_MANA) + TMana)
    call SetWidgetLife(d.target,GetWidgetLife(d.target)-TLife)
    call SetUnitState(d.target,UNIT_STATE_MANA,GetUnitState(d.target,UNIT_STATE_MANA) - TMana)
    set d.ticks = d.ticks + 1
    if d.ticks == 3 then
        call ReleaseTimer(d.t)
        call DestroyEffect(AddSpecialEffect(UDEATH,x,y))
        call SetUnitExploded(d.target,true)
        call KillUnit(d.target)
    endif
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local data d
    local integer id = GetUnitId(u)
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        call StartSound(SLEEP)
        set d = data.create()
        set data<u> = d
        call SetTimerData(d.t,d)
        call TimerStart(d.t,1,true,function Loop)
        set u = null
        set t = null
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
        set d = data<u>
        call ShowUnit(d.dummy,false)
        call StopEffect(1)
        call RemoveUnit(d.dummy)
        call d.destroy()
        set u = null
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
    call TriggerAddAction( t, function Actions )
    call TriggerAddCondition(t,Condition(function Conditions))
    //set SLEEP = CreateSoundFromLabel(&quot;SleepBirth1&quot;,false,true,true,10,10)
    set SLEEP = CreateSound(&quot;Internal\\Abilities\\Spells\\Undead\\SleepBirth1&quot;,false,true,true,10,10,&quot;&quot;)
    call StartSound(SLEEP)
    call Preload(&quot;Internal\\Abilities\\Spells\\Undead\\SleepBirth1&quot;)
    call SetSoundVolume(SLEEP,2000)
endfunction
endscope
</u></u>
 

Faust

You can change this now in User CP.
Reaction score
123
I had a 3d sounds problem not long ago, but then I heard the sound, the problem was that I heard it everywhere. But it may help you:

JASS:
function Force3dSound takes string SPath, unit onWho, real MaxDistance, real FadeDistance, integer MaxVolume returns nothing
    local sound s = CreateSound(SPath,false,false,true,1,1,&quot;DefaultEAXON&quot;) //path / boolean if looping / boolean if 3D / boolean if stop when out of range / integer fade in rate / integer fade out rate
    local real dx = GetUnitX(onWho) - GetCameraTargetPositionX()
    local real dy = GetUnitY(onWho) - GetCameraTargetPositionY()
    local real dist = SquareRoot(dx*dx+dy*dy)
    local integer volume = 0

    if dist &lt; FadeDistance then
        set volume = MaxVolume
    elseif dist &lt; MaxDistance then
        set volume = R2I(MaxVolume * (MaxDistance - dist) / (MaxDistance - FadeDistance))
    endif
    
    call SetSoundDuration(s,100) //in ms
    call SetSoundChannel(s,0) //not needed
    call SetSoundPitch(s,1.) //pitch in real, 1. = 100%
    //The following commands do the exact same as PlaySoundOnUnitBJ
    call AttachSoundToUnit(s, GetTriggerUnit())
    call SetSoundVolume(s,volume) //volume
    call StartSound(s)
endfunction


A helper from here gave me this, sorry for not remembering his name right now. x)
 

Chocobo

White-Flower
Reaction score
409
me =D

"Internal\\Abilities\\Spells\\Undead\\SleepBirth1" needs a file extension


and this is how to create (normally) a sound :

(from fsn2)
JASS:
    local sound snd = CreateSound(&quot;war3mapImported\\Rin NP.mp3&quot;, false, false, false, 10, 10,&quot;DefaultEAXON&quot;) //create default sound
    call SetSoundDuration(snd, 6740) //duration 6,740ms
    call SetSoundChannel(snd, 0) //channel normal
    call SetSoundVolume(snd, 127) //volume max
    call SetSoundPitch(snd, 1.0) //pitch rate 1.0x

3rd argument false must be set to true (to be a 3d sound), to play on a unit use AttachSoundToUnit(sound, unit) before or SetSoundPosition(x,y,z) before.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top