wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 10-30-2006, 01:51 PM   #1
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Question Leaking group or what?

Hello i'm making a spell with a casting time has need a chaneling, when the time is reached, the spell is casting in an area in front the caster, killing trees and units in front. But when the caster launch the bolt, leak the game, so here my code:

Collapse JASS:
function Trig_slave_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A0AE' ) 
endfunction


function mataarbol takes nothing returns nothing
    if ( GetDestructableLife(GetEnumDestructable())> 0 ) then
        call KillDestructable(GetEnumDestructable() )
    else
    endif
endfunction

function Trig_slave_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d1
local unit d2
local unit array d3
local group g1
local group g2
local unit j
local real x1 = GetUnitX(u)
local real y1 = GetUnitY(u)
local integer l = GetUnitAbilityLevel(u,'A0AE')
local real dmg1 = -100
local real dmgprogre = 500
local real x2 = GetHandleReal(u,"x2")
local real y2 = GetHandleReal(u,"y2")
local real ang = GetAngleBetweenPoints(x1,y1,x2,y2)
local real x3 = PolarProjectionX(x1,150,ang)
local real y3 = PolarProjectionY(y1,150,ang)
local location loc3
local player p = GetOwningPlayer(u)

local effect e
local integer i
local terraindeformation terra
local real dirX
local real dirY

    set e = AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl",x3,y3)
    call DestroyEffect(e)
    set e = AddSpecialEffect("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl",x3,y3)
    call DestroyEffect(e)
    //Unit bolt effect
    set d1 = CreateUnit(p,'h00L',x3,y3,ang)
    call SetUnitScalePercent(d1,250+(l*10),250+(l*10),250+(l*10))
    //Unit explotion effect.
    set d2 = CreateUnit(p,'h00M',x3,y3,ang)
    call SetUnitScalePercent(d2,350+(l*10),350+(l*10),350+(l*10))
    call SetUnitTimeScale(d2,0.15)
    call KillUnit(d2)

    set g2 = CreateGroup()
    set i = 0
    loop
        exitwhen i > 5
        set x3 = PolarProjectionX(x1,200*i,ang)
        set y3 = PolarProjectionY(y1,200*i,ang)        
        set loc3 = Location(x3,y3)
        call SetTerrainType(x3,y3, 'Kdtr', -1, 2, 0 )
        call SetTerrainType(x3,y3, 'Jdtr', -1, 1, 0 )
    //Some effect too
        set d3[i] = CreateUnit(p,'h004',x3,y3,0 )
        set g1 = GetUnitsInRangeOfLocMatching(200,loc3,null)
        set j = FirstOfGroup(g1)
        loop
            exitwhen j == null
            set j = FirstOfGroup(g1)    
            call GroupRemoveUnit(g1,j)
            call GroupAddUnit(g2,j)
        endloop                  
        call EnumDestructablesInCircleBJ(200,loc3, function mataarbol)
        set i = i+1
        call RemoveLocation(loc3)
        call DestroyGroup(g1)
    endloop
    
        set j = FirstOfGroup(g2)
        loop
            exitwhen j == null
            set j = FirstOfGroup(g2)    
            call GroupRemoveUnit(g2,j)
            if(IsUnitEnemy(j,p)==true)then
            call UnitDamageTarget(u,j,dmg1+dmgprogre*l,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,null)
            endif        
         endloop


        set x3 = PolarProjectionX(x1,900*4,ang)
        set y3 = PolarProjectionY(y1,900*4,ang) 
    set dirX = (x3 - x1) / GetDistanceBetweenPoints(x1,y1,x3,y3)
    set dirY = (y3 - y1) / GetDistanceBetweenPoints(x1,y1,x3,y3)
    set terra = TerrainDeformWave(x1,y1,dirX, dirY,GetDistanceBetweenPoints(x1,y1,x3,y3),GetDistanceBetweenPoints(x1,y1,x3,y3)/3,400,128,1000, 1)

call TriggerSleepAction(3)
            set i = 0
    loop
        exitwhen i > 5
        call RemoveUnit(d3[i])
        set d3[i] = null
        set i = i+1        
    endloop

        call RemoveLocation(loc3)
        call DestroyGroup(g2)
        call DestroyGroup(g1)
set loc3=null
set u = null
set p = null
call RemoveUnit(d1)
call RemoveUnit(d2)
set d1 = null
set d2 = null
set g1 = null
set g2 = null
set j = null
call DestroyEffect(e)
set e = null
set terra = null
endfunction

function Trig_slave1_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A0AE' ) 
endfunction

function Trig_slave1_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local location loc = GetSpellTargetLoc()
local real x2 = GetLocationX(loc)
local real y2 = GetLocationY(loc)
local real xaux
local real yaux
local lightning array rayo
local real ang = 30
local integer i = 0
local trigger t =CreateTrigger()
local event evento1

if(x2==0)then
set x2=1
endif
if(y2==0)then
set y2=1
endif

call SetHandleReal(u,"x2",x2)
call SetHandleReal(u,"y2",y2)
set evento1 = TriggerRegisterUnitEvent(t,u,EVENT_UNIT_SPELL_FINISH )
call TriggerAddCondition(t, Condition( function Trig_slave1_Conditions ) )
call TriggerAddAction(t, function Trig_slave_Actions)

loop
exitwhen ang > 300
    set xaux = PolarProjectionX(x,100,ang)
    set yaux = PolarProjectionY(y,100,ang)
    set d = CreateUnit(GetOwningPlayer(u),'hfoo',xaux,yaux,0)
    call UnitApplyTimedLife(d,'BTLF', 4)
    set rayo[i] = AddLightning("AFOD",true,x,y,xaux,yaux)
    set ang = ang + 90
    set i = i+1
endloop

call TriggerSleepAction(4.1)
set  i=0
loop
    exitwhen i>4
    call DestroyLightning(rayo[i])
    set rayo[i]=null
    set i = i+1
endloop

call FlushHandleLocals(u)
call DestroyTrigger(t)
call RemoveLocation(loc)
set loc = null
set t = null
set d = null
set u = null
set evento1 = null
endfunction

//===========================================================================
function InitTrig_slave1 takes nothing returns nothing
local trigger gg_trg_slave1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_slave1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_slave1, Condition( function Trig_slave1_Conditions ) )
    call TriggerAddAction( gg_trg_slave1, function Trig_slave1_Actions )
endfunction

what's wrong? why is leaking?
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 10-30-2006, 02:07 PM   #2
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

You are not leaking a group, you are leaking plenty of things

Collapse JASS:
function Trig_slave_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A0AE' ) 
endfunction


function mataarbol takes nothing returns nothing
    if ( GetDestructableLife(GetEnumDestructable())> 0 ) then
        call KillDestructable(GetEnumDestructable() )
    else
    endif
endfunction

function Trig_slave_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d1
local unit d2
local unit array d3
local group g1
local group g2
local unit j
local real x1 = GetUnitX(u)
local real y1 = GetUnitY(u)
local integer l = GetUnitAbilityLevel(u,'A0AE')
local real dmg1 = -100
local real dmgprogre = 500
local real x2 = GetHandleReal(u,"x2")
local real y2 = GetHandleReal(u,"y2")
local real ang = GetAngleBetweenPoints(x1,y1,x2,y2)
local real x3 = PolarProjectionX(x1,150,ang)
local real y3 = PolarProjectionY(y1,150,ang)
local location loc3
local player p = GetOwningPlayer(u)

local effect e
local integer i
local terraindeformation terra
local real dirX
local real dirY

    set e = AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl",x3,y3)
    call DestroyEffect(e)
    set e = AddSpecialEffect("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl",x3,y3)
    call DestroyEffect(e)
    //Unit bolt effect
    set d1 = CreateUnit(p,'h00L',x3,y3,ang)
    call SetUnitScalePercent(d1,250+(l*10),250+(l*10),250+(l*10))
    //Unit explotion effect.
    set d2 = CreateUnit(p,'h00M',x3,y3,ang)
    call SetUnitScalePercent(d2,350+(l*10),350+(l*10),350+(l*10))
    call SetUnitTimeScale(d2,0.15)
    call KillUnit(d2)

    set g2 = CreateGroup()
    set i = 0
    loop
        exitwhen i > 5
        set x3 = PolarProjectionX(x1,200*i,ang)
        set y3 = PolarProjectionY(y1,200*i,ang)        
        set loc3 = Location(x3,y3)
        call SetTerrainType(x3,y3, 'Kdtr', -1, 2, 0 )
        call SetTerrainType(x3,y3, 'Jdtr', -1, 1, 0 )
    //Some effect too
        set d3[i] = CreateUnit(p,'h004',x3,y3,0 )
        set g1 = GetUnitsInRangeOfLocMatching(200,loc3,null) //this bj function causes a leak since it is a local not set to null, Use GroupEnumUnitsInRangeOfLoc instead
        set j = FirstOfGroup(g1)
        loop
            exitwhen j == null
            set j = FirstOfGroup(g1)    
            call GroupRemoveUnit(g1,j)
            call GroupAddUnit(g2,j)
        endloop                  
        call EnumDestructablesInCircleBJ(200,loc3, function mataarbol)
        set i = i+1
        call RemoveLocation(loc3)
        call DestroyGroup(g1)
    endloop
    
        set j = FirstOfGroup(g2)
        loop
            exitwhen j == null
            set j = FirstOfGroup(g2)    
            call GroupRemoveUnit(g2,j)
            if(IsUnitEnemy(j,p)==true)then
            call UnitDamageTarget(u,j,dmg1+dmgprogre*l,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,null)
            endif        
         endloop


        set x3 = PolarProjectionX(x1,900*4,ang)
        set y3 = PolarProjectionY(y1,900*4,ang) 
    set dirX = (x3 - x1) / GetDistanceBetweenPoints(x1,y1,x3,y3)
    set dirY = (y3 - y1) / GetDistanceBetweenPoints(x1,y1,x3,y3)
    set terra = TerrainDeformWave(x1,y1,dirX, dirY,GetDistanceBetweenPoints(x1,y1,x3,y3),GetDistanceBetweenPoints(x1,y1,x3,y3)/3,400,128,1000, 1)

call TriggerSleepAction(3)
            set i = 0
    loop
        exitwhen i > 5
        call RemoveUnit(d3[i])
        set d3[i] = null
        set i = i+1        
    endloop

        call RemoveLocation(loc3)
        call DestroyGroup(g2)
        call DestroyGroup(g1)
set loc3=null
set u = null
set p = null
call RemoveUnit(d1)
call RemoveUnit(d2)
set d1 = null
set d2 = null
set g1 = null
set g2 = null
set j = null
call DestroyEffect(e) //This effect has already been destroyed.
set e = null
set terra = null
endfunction

function Trig_slave1_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A0AE' ) 
endfunction

function Trig_slave1_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local location loc = GetSpellTargetLoc()
local real x2 = GetLocationX(loc)
local real y2 = GetLocationY(loc)
local real xaux
local real yaux
local lightning array rayo
local real ang = 30
local integer i = 0
local trigger t =CreateTrigger()
local event evento1

if(x2==0)then
set x2=1
endif
if(y2==0)then
set y2=1
endif

call SetHandleReal(u,"x2",x2)
call SetHandleReal(u,"y2",y2)
set evento1 = TriggerRegisterUnitEvent(t,u,EVENT_UNIT_SPELL_FINISH )
call TriggerAddCondition(t, Condition( function Trig_slave1_Conditions ) )
call TriggerAddAction(t, function Trig_slave_Actions)

loop
exitwhen ang > 300
    set xaux = PolarProjectionX(x,100,ang)
    set yaux = PolarProjectionY(y,100,ang)
    set d = CreateUnit(GetOwningPlayer(u),'hfoo',xaux,yaux,0)
    call UnitApplyTimedLife(d,'BTLF', 4)
    set rayo[i] = AddLightning("AFOD",true,x,y,xaux,yaux)
    set ang = ang + 90
    set i = i+1
endloop

call TriggerSleepAction(4.1)
set  i=0
loop
    exitwhen i>4
    call DestroyLightning(rayo[i])
    set rayo[i]=null
    set i = i+1
endloop

call FlushHandleLocals(u)
call DestroyTrigger(t)
call RemoveLocation(loc)
set loc = null
set t = null
set d = null
set u = null
set evento1 = null
endfunction

//===========================================================================
function InitTrig_slave1 takes nothing returns nothing
local trigger gg_trg_slave1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_slave1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_slave1, Condition( function Trig_slave1_Conditions ) )
    call TriggerAddAction( gg_trg_slave1, function Trig_slave1_Actions )
endfunction

__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 10-30-2006, 02:14 PM   #3
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Thanks!!!

Well.... how avoid the leak in

TerrainDeformWave
call TriggerAddCondition(t, Condition( function Trig_slave1_Conditions ) )
call TriggerAddAction(t, function Trig_slave_Actions)

???

Thanks in advance
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 10-30-2006, 02:17 PM   #4
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

TerrainDeformStop,

I would say don't use a condition, just add an if then else to the actions then:

Collapse JASS:
 local triggeraction ac
// ...
     set ac=TriggerAddAction(t, function Trig_slave_Actions)
// ...
     call TriggerRemoveAction(t, ac)
     call DestroyTrigger(t)
// ...
  set t=null
  set ac=null
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 10-30-2006, 02:22 PM   #5
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default


like this?

Collapse JASS:
if( GetSpellAbilityId() == 'A0AE' )then
     set ac=TriggerAddAction(t, function Trig_slave_Actions)
endif
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 10-30-2006, 02:41 PM   #6
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

hell no.
Collapse JASS:
function Trig_slave_Actions takes nothing returns nothing
// ... stuff like locals
      if (GetSpellAbilityId() != 'A0AE') then
            return
      endif
 //better assign the locals now instead of in declarations, you can also split the function in 2 parts, the condition check and the actions
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 10-30-2006, 03:34 PM   #7
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

OK

But this still leaking:

Collapse JASS:
    set terra = TerrainDeformWave(x1,y1,dirX, dirY,GetDistanceBetweenPoints(x1,y1,x3,y3),GetDistanceBetweenPoints(x1,y1,x3,y3)/3,400,128,1000, 1)
call TriggerSleepAction(3)
    call TerrainDeformStop(terra,1)

why?
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Old 10-30-2006, 03:56 PM   #8
oNdizZ
User
 
oNdizZ's Avatar
 
Join Date: Jul 2004
Posts: 526

Submissions (2)

oNdizZ will become famous soon enough (33)oNdizZ will become famous soon enough (33)

Default

GetDistanceBetweenPoints() im guessing its a version of DistanceBetweenPoints() but with coordinations instead of locations in the parameter?
__________________

In need of a Macromedia Flash script tutor.

RIP - L2Extreme
oNdizZ is offline   Reply With Quote
Old 10-30-2006, 03:58 PM   #9
GALLED
User
 
GALLED's Avatar
 
Join Date: May 2006
Posts: 95

Submissions (1)

GALLED has little to show at this moment (1)

Default

Yep, is a Daelin's function
__________________
Actual Project:

War of Gods
GALLED is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:02 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2017, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services