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.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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