HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why this spell leaks? (SetUnitPosition)

02-27-2008, 07:32 PM#1
GALLED
Hello everybody:

I have a spell based in the spell Blade Massacre --> http://www.hiveworkshop.com/resources_new/spells/446/

But my spell is very laggy:

Collapse JASS:
constant function limite_map takes nothing returns real
    return 6500.0 //limite del mapa.
endfunction

function PolarProjectionX takes real punto, real distancia, real angulo returns real
   return punto+distancia*Cos(angulo*bj_DEGTORAD)
endfunction

function PolarProjectionY takes real punto, real distancia, real angulo returns real
   return punto+distancia*Sin(angulo*bj_DEGTORAD)
endfunction

function GetAngleBetweenPoints takes real x1, real y1, real x2, real y2 returns real
    return bj_RADTODEG * Atan2(y2-y1,x2-x1)
endfunction

function GetDistanceBetweenPoints takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
endfunction

function mataarbol takes nothing returns nothing
 local destructable d=GetEnumDestructable()
    if (GetWidgetLife(d)> 0 ) then
        call KillDestructable(d)
    endif
   set d = null  
endfunction

function ShadowMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit shadow = GetHandleUnit(t,"shadow")
local real x = GetUnitX(shadow)
local real y = GetUnitY(shadow)
local real ang = GetUnitFacing(shadow)
local location loc
local real x_2 = PolarProjectionX(x,50,ang)
local real y_2 = PolarProjectionY(y,50,ang)

    if(x_2>limite_map())then
    set x_2 = limite_map()
    endif

    if(y_2>limite_map())then
    set y_2 = limite_map()
    endif

    if(x_2<-limite_map())then
    set x_2 = -limite_map()
    endif

    if(y_2<-limite_map())then
    set y_2 = -limite_map()
    endif
    
        set loc = Location(x,y)
        call EnumDestructablesInCircleBJ(120,loc, function mataarbol)        
        call RemoveLocation(loc)
        
call SetUnitPosition(shadow,x_2,y_2)
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",shadow,"origin"))
set loc = null
set t = null
set shadow= null
endfunction

function Trig_Dragon_Slash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A070' 
endfunction

constant function DS_ID takes nothing returns integer
    return 'A070'  //RawId for the spell
endfunction

constant function DSBuff_ID takes nothing returns integer
    return 'B00G'  //RawId for the spell's buff
endfunction

constant function DSUnit_ID takes nothing returns integer
    return 'oshm'  //RawId for the Slashing Unit.
endfunction

function Trig_Dragon_Slash_Actions takes nothing returns nothing
local timer array t
local unit u = GetTriggerUnit()
local unit v = GetSpellTargetUnit()
local unit array shadow
local effect e2
local fogmodifier BMV
local location loc
local integer l = GetUnitAbilityLevel(u,DS_ID())
local integer i
local integer i2
local real x
local real y
local real xv
local real yv 
local real xs
local real ys
local real tiempo=0
local texttag tt
local real dmg
local timer s = CreateTimer()
local real ang
local real dist
local sound snd 
local sound snd1
local player p

call TimerStart(s,5,false,null)
loop
call TriggerSleepAction(0.1)
exitwhen(TimerGetRemaining(s)<=0.0) or (GetUnitAbilityLevel(v,DSBuff_ID()) > 0)
endloop
call DestroyTimer(s)

    if (GetUnitAbilityLevel(v,DSBuff_ID()) > 0) and (GetWidgetLife(u)>0.405) and (GetWidgetLife(v)>0.405) then
        set dmg = (3.5+(l*0.5))*GetHeroStr(u,true)
        set x = GetUnitX(u)
        set y = GetUnitY(u)    
        set xv = GetUnitX(v)
        set yv = GetUnitY(v)
        set loc = Location(xv,yv)
        set p = GetOwningPlayer(u)
        set BMV = CreateFogModifierRadiusLocBJ( true, p, FOG_OF_WAR_VISIBLE,loc, 1000)
        call RemoveLocation(loc)
        call SetCameraTargetControllerNoZForPlayer(p,v, 0, 0, true )        
        call PauseUnit(v, true)
        set ang = GetAngleBetweenPoints(x,y,xv,yv)
        set dist = GetDistanceBetweenPoints(x,y,xv,yv)
        set e2= AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl",v,"overhead")        

        set i = 1
        loop
            exitwhen i > 5
            set shadow[i]=CreateUnit(p,DSUnit_ID(),x,y,ang)
            call SetUnitPosition(shadow[i],PolarProjectionX(x,i*10,ang),PolarProjectionY(y,i*10,ang))                
            call SetUnitFacing(shadow[i],ang)        
            call SetUnitVertexColor(shadow[i],255,255,255,PercentToInt(100.0-(20*I2R( i - 1 )),255))            
            call SetUnitTimeScale(shadow[i],0.7)
            call SetUnitAnimation(shadow[i], "stand")           
            set i = i + 1
        endloop
        call ShowUnit(u, false)
        call SetUnitAnimation(v, "stand")

        call TriggerSleepAction(0.1)
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "ready" )
            set i = i + 1
        endloop
        call TriggerSleepAction(0.2)
        set snd = CreateSound("Units\\Orc\\HeroBladeMaster\\HeroBladeMasterYesAttack3.wav", false, true, false, 12700, 12700, "")
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "slam" )
            set t[i]=CreateTimer()
            call SetHandleHandle(t[i], "shadow",shadow[i])
            call TimerStart(t[i],0.07,true,function ShadowMove)              
            set i = i + 1
        endloop
        call TriggerSleepAction( dist*0.07/50)

        call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodKnight.mdl",v,"chest"))
        call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 1.00, "ReplaceableTextures\\CameraMasks\\DiagonalSlash_mask.blp", 100.00, 0, 0, 50.00 )
        
        call PauseUnit(v, false)
        call StopSound(snd,true,false)
        call DestroyEffect(e2)
        call UnitDamageTarget(u,v,dmg,true,false, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL,null)
        set xv = GetUnitX(v)
        set yv = GetUnitY(v)
                
        set tt = CreateTextTag()
        call SetTextTagText(tt,I2S(R2I(dmg)),0.023)
        call SetTextTagPos(tt,xv,yv,0)
        call SetTextTagColorBJ(tt,100,0,0,0)
        call SetTextTagPermanent(tt, false )
        call SetTextTagVelocityBJ(tt, 64, 90 )
        call SetTextTagLifespan(tt, 2.5 )

        set snd1 = CreateSound("Sound\\Units\\Combat\\MetalHeavyBashFlesh1.wav", false, true, false, 12700, 12700, "")
        
        call TriggerSleepAction( 0.18 )
        call StopSound(snd1,true,false)
                
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "ready" )
            call FlushHandleLocals(t[i])                
            call DestroyTimer(t[i])
            set t[i] = null            
            set i = i + 1
        endloop
            
//------------------------------------------------------------------        
        set xs = GetUnitX(shadow[1])
        set ys = GetUnitY(shadow[1])
        call SetUnitPosition(u,xs,ys)
        call SetUnitFacing(u,GetUnitFacing(shadow[1]))
                        
        set i = 1
        loop
            exitwhen i > 5
            call RemoveUnit(shadow[i])
            set shadow[i]=null
            set i = i + 1
        endloop
        
        call DestroyFogModifier(BMV)
        call ShowUnitShow(u)
        call SelectUnitForPlayerSingle(u,p) 
        call ResetToGameCameraForPlayer(p, 0 )
    endif
    set p = null
    set snd = null
    set tt = null
    set loc = null
    set tt = null
    set BMV = null
    set e2 = null    
    set u = null
    set v = null
    set s = null    
endfunction

//===========================================================================
function InitTrig_Dragon_Slash takes nothing returns nothing
local trigger gg_trg_Dragon_Slash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Dragon_Slash, Condition( function Trig_Dragon_Slash_Conditions ) )
    call TriggerAddAction( gg_trg_Dragon_Slash, function Trig_Dragon_Slash_Actions )
endfunction

That I am making bad?
02-27-2008, 10:13 PM#2
Captain Griffen
Learn to indent, seriously, makes code much easier to read.

You use a lot of pointless wrapper/BJ functions, which slow it down.

call EnumDestructablesInCircleBJ(120,loc, function mataarbol) is probably the main problem.

And lagginess is rarely caused by leaks. Leaks only cause lagginess when they build up over time.
02-27-2008, 10:18 PM#3
GALLED
Quote:
Originally Posted by Captain Griffen
Learn to indent, seriously, makes code much easier to read.
How I can learn to do this?

Quote:
Originally Posted by Captain Griffen
You use a lot of pointless wrapper/BJ functions, which slow it down.

call EnumDestructablesInCircleBJ(120,loc, function mataarbol) is probably the main problem.

And lagginess is rarely caused by leaks. Leaks only cause lagginess when they build up over time.
What is a wrapper function?
02-27-2008, 11:13 PM#4
uberfoop
Quote:
Originally Posted by GALLED
How I can learn to do this?
Tab button.

Quote:
What is a wrapper function?
A thingy that just holds another function.
For example:

Collapse JASS:
native UnitAddAbility takes unit whichUnit, integer abilityId returns boolean

This is the unit add ability BJ wrapper function:
Collapse JASS:
function UnitAddAbilityBJ takes integer abilityId, unit whichUnit returns boolean
    return UnitAddAbility(whichUnit, abilityId)
endfunction


As you can see, all the BJ does is return the native, making you get 1 pointless function call. Well, it also swaps the order of parameters, but that's irrelevant.
02-28-2008, 01:35 PM#5
GALLED
Ah ok thanks, I'm rewrite the spell:

Collapse JASS:
constant function limite_map takes nothing returns real
    return 6500.0 //limite del mapa.
endfunction

function PolarProjectionX takes real punto, real distancia, real angulo returns real
   return punto+distancia*Cos(angulo*bj_DEGTORAD)
endfunction

function PolarProjectionY takes real punto, real distancia, real angulo returns real
   return punto+distancia*Sin(angulo*bj_DEGTORAD)
endfunction

function GetAngleBetweenPoints takes real x1, real y1, real x2, real y2 returns real
    return bj_RADTODEG * Atan2(y2-y1,x2-x1)
endfunction

function GetDistanceBetweenPoints takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
endfunction

function mataarbol takes nothing returns nothing
 local destructable d=GetEnumDestructable()
    if (GetWidgetLife(d)> 0 ) then
        call KillDestructable(d)
    endif
   set d = null  
endfunction

function ShadowMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit v = GetHandleUnit(t,"shadow")
local real dist_lit = GetHandleReal(t,"shadow_dist")
local string fx = GetHandleString(t,"shadow_fx")
local real ang = GetHandleReal(t,"shadow_angle")   
local real x2 = GetUnitX(v)
local real y2 = GetUnitY(v)
local real x_2 = PolarProjectionX(x2,dist_lit,ang)
local real y_2 = PolarProjectionY(y2,dist_lit,ang)
local rect r

    if(x_2>limite_map())then
    set x_2 = limite_map()
    endif

    if(y_2>limite_map())then
    set y_2 = limite_map()
    endif

    if(x_2<-limite_map())then
    set x_2 = -limite_map()
    endif

    if(y_2<-limite_map())then
    set y_2 = -limite_map()
    endif


    set r = Rect(x_2 - 120, y_2 - 120, x_2 + 120, y_2 + 120)
    call EnumDestructablesInRect(r, null, function mataarbol)
    call RemoveRect(r)
        
    call SetUnitPosition(v,x_2,y_2)
    if(fx!=null)then
        call DestroyEffect(AddSpecialEffectTarget(fx,v,"origin"))    
    endif

set fx = null
set r = null
set t = null
set v = null
endfunction

function Trig_Dragon_Slash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A070' 
endfunction

constant function DS_ID takes nothing returns integer
    return 'A070'  //RawId for the spell
endfunction

constant function DSBuff_ID takes nothing returns integer
    return 'B00G'  //RawId for the spell's buff
endfunction

constant function DSUnit_ID takes nothing returns integer
    return 'oshm'  //RawId for the Slashing Unit.
endfunction

function Trig_Dragon_Slash_Actions takes nothing returns nothing
local timer array t
local unit u = GetTriggerUnit()
local unit v = GetSpellTargetUnit()
local unit array shadow
local effect e2
local fogmodifier BMV
local integer l = GetUnitAbilityLevel(u,DS_ID())
local integer i
local integer i2
local real x
local real y
local real xv
local real yv 
local real xs
local real ys
local texttag tt
local real dmg
local timer s = CreateTimer()
local real ang
local real dist
local sound snd 
local sound snd1
local player p

    call TimerStart(s,5,false,null)
loop
    call TriggerSleepAction(0.1)
    exitwhen(TimerGetRemaining(s)<=0.0) or (GetUnitAbilityLevel(v,DSBuff_ID()) > 0)
endloop
    call DestroyTimer(s)

    if (GetUnitAbilityLevel(v,DSBuff_ID()) > 0) and (GetWidgetLife(u)>0.405) and (GetWidgetLife(v)>0.405) then
        set dmg = (3.5+(l*0.5))*GetHeroStr(u,true)
        set x = GetUnitX(u)
        set y = GetUnitY(u)    
        set xv = GetUnitX(v)
        set yv = GetUnitY(v)
        set p = GetOwningPlayer(u)
        set BMV = CreateFogModifierRadius(p,FOG_OF_WAR_VISIBLE,xv,yv,1000,true, false)                
        call FogModifierStart(BMV)
        call SetCameraTargetControllerNoZForPlayer(p,v, 0, 0, true )        
        call PauseUnit(v, true)
        set ang = GetAngleBetweenPoints(x,y,xv,yv)
        set dist = GetDistanceBetweenPoints(x,y,xv,yv)
        set e2= AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl",v,"overhead")        

        set i = 1
        loop
            exitwhen i > 5
            set shadow[i]=CreateUnit(p,DSUnit_ID(),x,y,ang)
            call SetUnitPosition(shadow[i],PolarProjectionX(x,i*10,ang),PolarProjectionY(y,i*10,ang))                
            call SetUnitFacing(shadow[i],ang)        
            call SetUnitVertexColor(shadow[i],255,255,255,PercentToInt(100.0-(20*I2R( i - 1 )),255))            
            call SetUnitTimeScale(shadow[i],0.7)
            call SetUnitAnimation(shadow[i], "stand")           
            set i = i + 1
        endloop
        call ShowUnit(u, false)
        call SetUnitAnimation(v, "stand")

        call TriggerSleepAction(0.1)
        
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "ready" )
            set i = i + 1
        endloop
        set snd = CreateSound("Units\\Orc\\HeroBladeMaster\\HeroBladeMasterYesAttack3.wav", false, true, false, 12700, 12700, "")
        call StartSound(snd)
        call SetSoundPosition(snd,x,y,0.00)
        call SetSoundVolume(snd,64)
        call TriggerSleepAction(0.2)
        
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "slam" )
            set t[i]=CreateTimer()
            call SetHandleReal(t[i], "shadow_dist",50.0)
            call SetHandleHandle(t[i], "shadow",shadow[i])
            call SetHandleReal(t[i], "shadow_angle",GetUnitFacing(shadow[i]))
            call SetHandleString(t[i],"shadow_fx","Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl")                               
            call TimerStart(t[i],0.07,true,function ShadowMove)              
            set i = i + 1
        endloop
        
        call TriggerSleepAction( dist*0.07/50)

        call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodKnight.mdl",v,"chest"))
        call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 1.00, "ReplaceableTextures\\CameraMasks\\DiagonalSlash_mask.blp", 100.00, 0, 0, 50.00 )
        
        call PauseUnit(v, false)
        call DestroyEffect(e2)
        call UnitDamageTarget(u,v,dmg,true,false, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL,null)
        set xv = GetUnitX(v)
        set yv = GetUnitY(v)
                
        set tt = CreateTextTag()
        call SetTextTagText(tt,I2S(R2I(dmg)),0.023)
        call SetTextTagPos(tt,xv,yv,0)
        call SetTextTagColorBJ(tt,100,0,0,0)
        call SetTextTagPermanent(tt, false )
        call SetTextTagVelocityBJ(tt, 64, 90 )
        call SetTextTagLifespan(tt, 2.5 )

        set snd1 = CreateSound("Sound\\Units\\Combat\\MetalHeavyBashFlesh1.wav", false, true, false, 12700, 12700, "")
        call StartSound(snd1)
        call SetSoundPosition(snd1,xv,yv,0.00)
        call SetSoundVolume(snd1,64)       
        call TriggerSleepAction( 0.18 )

                
        set i = 1
        loop
            exitwhen i > 5
            call SetUnitAnimation(shadow[i], "ready" )
            call FlushHandleLocals(t[i])                
            call DestroyTimer(t[i])
            set t[i] = null            
            set i = i + 1
        endloop
            
//------------------------------------------------------------------        
        set xs = GetUnitX(shadow[1])
        set ys = GetUnitY(shadow[1])
        call SetUnitPosition(u,xs,ys)
        call SetUnitFacing(u,GetUnitFacing(shadow[1]))
                        
        set i = 1
        loop
            exitwhen i > 5
            call RemoveUnit(shadow[i])
            set shadow[i]=null
            set i = i + 1
        endloop
        
        call DestroyFogModifier(BMV)
        call ShowUnitShow(u)
        call SelectUnitForPlayerSingle(u,p) 
        call ResetToGameCameraForPlayer(p, 0 )
        call TriggerSleepAction( 1.5)        
        call StopSound(snd,true,false)        
        call StopSound(snd1,true,false)        
    endif
    
    set p = null
    set snd = null
    set tt = null
    set BMV = null
    set e2 = null    
    set u = null
    set v = null
    set s = null    
endfunction

//===========================================================================
function InitTrig_Dragon_Slash takes nothing returns nothing
local trigger gg_trg_Dragon_Slash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Dragon_Slash, Condition( function Trig_Dragon_Slash_Conditions ) )
    call TriggerAddAction( gg_trg_Dragon_Slash, function Trig_Dragon_Slash_Actions )
endfunction
And now it's leak free.

But I have a new problem: The sounds are not listened. Why?
02-28-2008, 03:44 PM#6
Captain Griffen
You leak sounds. snd1 is also not nulled.

As for having them play, try preloading the sound at map init.
02-28-2008, 04:08 PM#7
GALLED
Ah ok, thanks, but:

Collapse JASS:
        call StartSound(snd)
        call SetSoundPosition(snd,x,y,0.00)
        call SetSoundVolume(snd,64)
It is not sufficient so that they sound? It thought that it had mistaken in path of the wav file, because I have another spell (based in another spell Eye of the Time by l33torizor) with sounds and I did not have problems:
Collapse JASS:

constant function eot_GetAbilityID takes nothing returns integer
        return 'AHfs' //                                                                 
endfunction

constant function eot_Area takes nothing returns real
        return 600.00  //                                                               
endfunction

constant function eot_Tornado takes nothing returns integer
        return 'hmil'  //                                                                 
endfunction

function eot_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == eot_GetAbilityID())
endfunction

function eot_AgrupaUnits takes real x, real y, real area, unit origen returns nothing
local group g
local group h = GetHandleGroup(origen,"eot_grupo")
local unit j

if(h==null)then
    set h = CreateGroup()
endif

    set g = CreateGroup()    
    call GroupEnumUnitsInRange(g,x,y,area,null)
    loop
        set j = FirstOfGroup(g)
        exitwhen j==null
        call GroupRemoveUnit(g,j)
        if(IsUnitInGroup(j,h)==false)then
            if(GetUnitAbilityLevel(j,'A08V')!=5)then
                if( (IsUnitAlly(j,GetOwningPlayer(origen))==false) and (IsUnitType(j,UNIT_TYPE_STRUCTURE)==false) and (IsUnitType(j,UNIT_TYPE_MECHANICAL)==false) and  (IsUnidInvulnerable(j)==false) and (GetUnitTypeId(j)!=eot_Tornado()) ) then

                    call GroupAddUnit(h,j)
                    call UnitAddAbility(j,'A08V') 
                    call SetUnitAbilityLevel(j,'A08V',5)
                endif
            endif
        endif            
    endloop
    
    call DestroyGroup(g)
    call SetHandleHandle(origen,"eot_grupo",h)
    set g = null
    set j = null
endfunction


//=========================================================================================
function eot_GetUnits takes nothing returns nothing
local real x1
local real y1
local group g
local real angle
local real dist
local unit j
local real x
local real y
local timer t = GetExpiredTimer()
local unit o = GetHandleUnit(t,"eot_origen")
local real d

    if(GetWidgetLife(o)>0.405)then
        set x = GetHandleReal(t,"eot_x")
        set y = GetHandleReal(t,"eot_y")
        set g = CreateGroup()
        call GroupEnumUnitsInRange(g,x,y,eot_Area(),null)

        loop
            set j = FirstOfGroup(g)
            exitwhen j == null
            call GroupRemoveUnit(g,j)  
            if(IsUnitAlly(j,GetOwningPlayer(o))==false)then
                if((IsUnitType(j,UNIT_TYPE_STRUCTURE)==false) and (IsUnitType(j,UNIT_TYPE_MECHANICAL)==false) and  (IsUnidInvulnerable(j)==false)) then                   
                    set x1 = GetUnitX(j) 
                    set y1 = GetUnitY(j)
                    set d = GetDistanceBetweenPoints(x1,y1,x,y)
                    if(d>150)then 
                        set angle = GetAngleBetweenPoints(x1,y1,x,y)
                        call SetUnitPathing(j,false)
                        call SetUnitPosition(j,PolarProjectionX(x1,10,angle),PolarProjectionY(y1,10,angle))
                        call SetUnitPathing(j,true)
                    else
                        call IssueImmediateOrder(j,"stop")
                    endif
                endif
            endif
        endloop
        call DestroyGroup(g)
    else
        call FlushHandleLocals(t)
        if(t!=null)then
            call DestroyTimer(t)
        endif
    endif

set t = null
set g = null
set j = null
set o = null
endfunction

//=========================================================================================
function eot_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local sound snd = CreateSound("Abilities\\Spells\\Orc\\LightningBolt\\LightningBolt.wav", true, true, false, 12700, 12700, "")
local integer ni = GetUnitAbilityLevel(caster,eot_GetAbilityID())
local real scle = 0.35
local real x
local real y
local rect r
local group g
local unit j
local location l
local effect se
local unit se2
local timer t
local timer s

    set l = GetSpellTargetLoc()
    set x = GetLocationX(l)
    set y = GetLocationY(l)
    call RemoveLocation(l)

    set se = AddSpecialEffect( "Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",x,y)
    set se2 = CreateUnit(GetOwningPlayer(caster),eot_Tornado(),x,y,0)
    call UnitApplyTimedLife(se2,'BTLF',4+(2*ni))

    set s = CreateTimer()
    call TimerStart(s,2,false,null)
    loop
        set scle = scle + 0.09
        call SetUnitScale(se2,scle,scle,scle)
        call TriggerSleepAction(0.15) 
        exitwhen(TimerGetRemaining(s)<=0.0) or (GetWidgetLife(se2)<=0.405)
    endloop
    call DestroyTimer(s)

    set r = Rect(x - eot_Area(), y - eot_Area(), x + eot_Area(),y + eot_Area())
    call EnumDestructablesInRect(r, null, function mataarbol)
    call RemoveRect(r)

    set t = CreateTimer()
    call SetHandleReal(t,"eot_x",x)
    call SetHandleReal(t,"eot_y",y)
    call SetHandleHandle(t,"eot_origen",se2)
    call StartSound(snd)
    call SetSoundPosition(snd,x,y,0.00)
    call SetSoundVolume(snd,64)

    call TimerStart(t, 0.04, true, function eot_GetUnits)

    set s = CreateTimer()
    call TimerStart(s,1+(2*ni),false,null)
    loop
        call eot_AgrupaUnits(x,y,eot_Area(),se2) 
        call TriggerSleepAction(0.15)
        if(scle<=3)then  
            set scle = scle + 0.09
            call SetUnitScale(se2,scle,scle,scle)
        endif    
        exitwhen(TimerGetRemaining(s)<=0.0) or (GetWidgetLife(se2)<=0.405)
    endloop
    call DestroyTimer(s)

    call FlushHandleLocals(t)

    if(t!=null)then
        call DestroyTimer(t)
    endif
    call DestroyEffect(se)

    set g = GetHandleGroup(se2,"eot_grupo")
    call FlushHandleLocals(se2)
    call RemoveUnit(se2)
    call StopSound(snd,true,false)

           
    loop
        set j = FirstOfGroup(g)
        exitwhen j==null
        call GroupRemoveUnit(g,j)
        if(GetUnitAbilityLevel(j,'A08V')==5)then
            call UnitRemoveAbility(j,'A08V')
        endif            
    endloop
    call DestroyGroup(g)
        
    set g = null
    set j = null
    set r = null
    set t = null
    set l = null
    set caster = null
    set se = null
    set se2 = null
    set snd = null
    set s = null
endfunction

//===========================================================================
function InitTrig_OjodelTiempo takes nothing returns nothing
    set gg_trg_OjodelTiempo = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_OjodelTiempo, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_OjodelTiempo, Condition( function eot_Conditions ) )
    call TriggerAddAction( gg_trg_OjodelTiempo, function eot_Actions  )
endfunction
02-28-2008, 05:45 PM#8
Captain Griffen
Sounds can be a bit buggy for the first few uses in JASS unless you preload them.
02-28-2008, 05:54 PM#9
GALLED
Ah ok! And how i can preload the sounds???
02-28-2008, 05:59 PM#10
Captain Griffen
Extract the common.j file from your war3xpatch.mpq (a version of it also comes with the newgen pack, which you should get if you're going to be JASSing). That contains all the natives (convert to .txt or just open it with notepad).

Alternatively, just use the function list in the NewGen pack.
02-28-2008, 06:57 PM#11
GALLED
Ok, I am going to review it. Thanks