| 08-23-2006, 12:31 AM | #1 |
Hello everybody: I have a pasive ability called Forest's Friend, so when the unit is near to a forest (some trees) have some chance that an Ent will help him (create a dummy and cast Force of Nature), but i have a mayor leak when the Ent is summoned. Well this is the script: JASS:function Trig_Amigo_Func001001001002 takes nothing returns boolean return ( UnitHasBuffBJ(GetFilterUnit(), 'B00B') == true ) endfunction function CountDestructablesInRect_Enum takes nothing returns nothing set bj_randomSubGroupWant = bj_randomSubGroupWant + 1 endfunction function CountDestructablesInCircle takes location where, real radius returns integer local integer old = bj_randomSubGroupWant local integer new set bj_randomSubGroupWant = 0 call EnumDestructablesInCircleBJ(radius, where, function CountDestructablesInRect_Enum) set new = bj_randomSubGroupWant set bj_randomSubGroupWant = old return new endfunction function Trig_Amigo_Conditions takes nothing returns boolean if ( CountUnitsInGroup(GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Amigo_Func001001001002))) > 0 ) then return true endif return false endfunction function Trig_Amigo_Actions takes nothing returns nothing local group g = CreateGroup() local real xu local real yu local unit u = null local group a = CreateGroup() local real r local integer l local unit dummyCaster set g = GetUnitsInRectAll(GetPlayableMapRect()) set u = FirstOfGroup(g) loop exitwhen u==null set u = FirstOfGroup(g) set xu = GetUnitX(u) set yu = GetUnitY(u) call GroupRemoveUnit(g,u) //Revisa si tiene la habilidad if UnitHasBuffBJ(u, 'B00B')==true then set l = GetUnitAbilityLevelSwapped('A08E', u) //Si hay destructibles alrededor de la unidad... if (CountDestructablesInCircle(Location(xu,yu),300)>0) then set r = GetRandomReal(1,100) if r<=20+(20*(l-1)) then set dummyCaster = CreateUnit(GetOwningPlayer(u),'h00C',xu,yu, bj_UNIT_FACING ) call UnitApplyTimedLife( dummyCaster,'BTLF', 1) call UnitAddAbility( dummyCaster , 'A08D') call SetUnitAbilityLevelSwapped( 'A08D', dummyCaster, GetUnitAbilityLevelSwapped('A08E', u) ) call IssuePointOrder( dummyCaster, "forceofnature", xu,yu ) endif endif endif endloop call RemoveLocation(Location(xu,yu)) set dummyCaster = null call DestroyGroup(g) call DestroyGroup(a) set g = null set u = null set a = null endfunction //=========================================================================== function InitTrig_Amigo takes nothing returns nothing set gg_trg_Amigo = CreateTrigger( ) call TriggerRegisterTimerEventPeriodic( gg_trg_Amigo, 6 ) call TriggerAddCondition( gg_trg_Amigo, Condition( function Trig_Amigo_Conditions ) ) call TriggerAddAction( gg_trg_Amigo, function Trig_Amigo_Actions ) endfunction Why is leaking?? Can anybody help me? ![]() |
| 08-23-2006, 01:01 AM | #2 |
This leaks a group JASS:if ( CountUnitsInGroup(GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Amigo_Func001001001002))) > 0 ) then return true endif Also, this is unnecessary JASS:call RemoveLocation(Location(xu,yu)) Also: JASS:if (CountDestructablesInCircle(Location(xu,yu),300)>0) then JASS:set tempLoc = Location(xu,yu) if (CountDestructablesInCircle(tempLoc,300)>0) then set r = GetRandomReal(1,100) if r<=20+(20*(l-1)) then set dummyCaster = CreateUnit(GetOwningPlayer(u),'h00C',xu,yu, bj_UNIT_FACING ) call UnitApplyTimedLife( dummyCaster,'BTLF', 1) call UnitAddAbility( dummyCaster , 'A08D') call SetUnitAbilityLevelSwapped( 'A08D', dummyCaster, GetUnitAbilityLevelSwapped('A08E', u) ) call IssuePointOrder( dummyCaster, "forceofnature", xu,yu ) endif endif call RemoveLocation(tempLoc) I believe that EnumDestructablesInCircleBJ clears the leaks already, but I'm not positive. |
| 08-23-2006, 01:18 AM | #3 |
my guess is that some of the BJ-functions you use leak. in addition, Location(xu,yu) leaks. you need to store it in a var etc, or use remove it inside the function it is used in.. also remove the call to RemoveLocation(Location(xu,yu)), it doesn't work that way. it'll just remove that specific location and not all that match the x/y values, each location is unique GetUnitsInRectMatching(..) leaks a group JASS:local group g = CreateGroup() set g = GetUnitsInRectAll(GetPlayableMapRect()) leaks as the bj-function GetUnitsInRectAll creates a group, replace it with JASS:call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null) might be something else but then I'd have to look further into things edit: maybe I should start updating the thread before I post :P |
| 08-23-2006, 02:33 AM | #4 |
Thanks men. Well now i see the leaks, thanks!!! |
