Sooda
Diversity enchants
- Reaction score
- 318
JASS:
function Trig_Lightning_Effect_Conditions takes nothing returns boolean
return ( ( GetUnitTypeId(GetAttacker()) == 039;h000039; ) )
endfunction
function Trig_Lightning_Effect_Actions takes nothing returns nothing
local unit attacker = GetAttacker()
local unit target = GetTriggerUnit()
local lightning LightningEffect
local integer volume = 90
local integer LoopStart = 1
local integer LoopEnd = 2
local real x = GetUnitX(attacker)
local real y = GetUnitY(attacker)
local real x2 = GetUnitX(target)
local real y2 = GetUnitX(target)
local real z = 0
loop
exitwhen LoopStart > LoopEnd
set LightningEffect = AddLightning( "FORK", true, x, y, x2, y2)
call TriggerSleepAction( 0.50 )
call DestroyLightning(LightningEffect)
set LoopStart = LoopStart + 1
endloop
call SetSoundPosition(gg_snd_LightningBolt, x, y, z)
call SetSoundVolume(gg_snd_LightningBolt, volume)
call StartSound(gg_snd_LightningBolt)
// Cleaning is important.
set attacker = null
set target = null
set LightningEffect = null
endfunction
//===========================================================================
function InitTrig_Lightning_Effect takes nothing returns nothing
set gg_trg_Lightning_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Effect, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Lightning_Effect, Condition( function Trig_Lightning_Effect_Conditions ) )
call TriggerAddAction( gg_trg_Lightning_Effect, function Trig_Lightning_Effect_Actions )
endfunction
Your x, x and x2,y2 coordinates where wrongly set up. All local handles needs to be nulled. It means local sounds need to be nulled. But your sound is constant and isn' t changing so you could directly use that instead. Then you don' t have to null it. Though when you want to use different sound it is better to use local sound and after null local sound. So you don' t have to change in all places sound when you want to fastly change function.
> local real z = 0
It' s height from ground where sound is played. Default game camera z height is 1600. If you would change your z to 1600 it would play your sound louder because it is closer to player view. Thats why sound becomes louder when you scroll your game screen view to lower where are units.