Leaking???

INCINERATE

New Member
Reaction score
12
when i checked Slammer with leak checker it said this , where is the leak and how to fix?

Total lines: 18

Location Leak Detection ON
Unit Group Leak Detection ON
Special Effect Leak Detection ON
Variable Removal Detection ON

Location variable has not been removed:

Completed

Trigger:
  • Reverse Polarity
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Slammer
    • Actions
      • -------- Area of effect --------
      • Set RPPRealAoE = 410.00
      • -------- ----------------------------------------------- --------
      • Set TempPoint = (Position of (Triggering unit))
      • Set TempOffset = (TempPoint offset by (Random real number between 120.00 and 170.00) towards (Facing of (Triggering unit)) degrees)
      • Set TempUnitGroup = (Units within (RPPRealAoE + 32.00) of TempPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is A flying unit) Equal to False) and ((((Matching unit) is alive) Equal t
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to TempOffset
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempOffset)


-----------------------------------------------------------------------------------------------------------------------------------------

okay for the next trigger, i do not think it leaks, but for some damn reason the average frame rate is lower when i enable this trigger, compared to when i disable it which results in the average frame rate like 15 frames higher , is this trigger possibly leaking? or is it checking for conditions every .03 seconds of gametime which means it checks on average 33 times EAch second for the entire game which is wasted efficiency? just curious


JASS:
scope Webshot initializer Init

    globals
        private constant integer    SPELL_ID            = 'yuty'
        
        //The caster moves MAX_DISTANCE in MAX_DURATION. So, if the distance
        //to the target point is half MAX_DISTANCE, the duration will be half
        //too.
        private constant real       MAX_DISTANCE        = 1200.00
        private constant real       MAX_DURATION        = 1.20
        
        //String path for lightning effect, and some colour configuration.
        private constant string     LIGHTNING_PATH      = "LEAS"
        private constant real       LIGHTNING_A         = 0.82
        private constant real       LIGHTNING_R         = 0.15
        private constant real       LIGHTNING_G         = 1.00
        private constant real       LIGHTNING_B         = 0.10
        //Distance from the center of the caster to the angle direction.
        //The root of the webs are placed on those positions. If you don't
        //get it, test it.
        private constant real       LIGHTNING_DISTANCE  = 75.00
        private constant real       LIGHTNING_ANGLE     = bj_PI / 4

        private constant real       DAMAGE_RADIUS       = 112.00
        private constant attacktype DAMAGE_ATTACK_TYPE  = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_DAMAGE_TYPE  = DAMAGE_TYPE_UNIVERSAL
        private constant weapontype DAMAGE_WEAPON_TYPE  = WEAPON_TYPE_WHOKNOWS
        private constant string     DAMAGE_EFFECT       = "Abilities\\Weapons\\PoisonArrow\\PoisonArrowMissile.mdl"
        private constant string     DAMAGE_EFFECT_POINT = "chest"

        private constant real       INTERVAL            = 0.03
    endglobals

    private constant function DamageFilter takes unit caster, unit target returns boolean
        return IsUnitEnemy(target, GetOwningPlayer(caster)) and IsUnitType(target, UNIT_TYPE_GROUND) == true
    endfunction

    private constant function DamageAmount takes integer level returns real
        return 00.00 + level * 75.00
    endfunction

    private struct Data
        private static timer Timer = CreateTimer()
        private static Data array Array
        private static integer Counter = 0

        private unit caster
        private real angle
        private real xInc
        private real yInc
        private real damage

        private lightning web1
        private lightning web2
        private real targetX
        private real targetY

        private integer ticks

        private group currentGroup = CreateGroup()
        private group damagedGroup = CreateGroup()

        private static method ReturnTrue takes nothing returns boolean
            return true
        endmethod

        private method actions takes nothing returns nothing
            local real casterX = GetUnitX(.caster)
            local real casterY = GetUnitY(.caster)
            local unit f

            call SetUnitPathing(.caster, false)
            call SetUnitPosition(.caster, casterX + .xInc, casterY + .yInc)
            call SetUnitFacing(.caster, .angle * bj_RADTODEG)
            call MoveLightning(.web1, true, casterX + LIGHTNING_DISTANCE * Cos(.angle + LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle + LIGHTNING_ANGLE), .targetX, .targetY)
            call MoveLightning(.web2, true, casterX + LIGHTNING_DISTANCE * Cos(.angle - LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle - LIGHTNING_ANGLE), .targetX, .targetY)

            call GroupEnumUnitsInRange(.currentGroup, GetUnitX(.caster), GetUnitY(.caster), DAMAGE_RADIUS, Condition(function Data.ReturnTrue))
            loop
                set f = FirstOfGroup(.currentGroup)
                exitwhen f == null
                call GroupRemoveUnit(.currentGroup, f)
                if not IsUnitInGroup(f, .damagedGroup) and DamageFilter(.caster, f) then
                    call GroupAddUnit(.damagedGroup, f)
                    call UnitDamageTarget(.caster, f, .damage, true, false, DAMAGE_ATTACK_TYPE, DAMAGE_DAMAGE_TYPE, DAMAGE_WEAPON_TYPE)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, DAMAGE_EFFECT_POINT))
                endif
            endloop
        endmethod

        private static method Handler takes nothing returns nothing
            local integer i = 0

            loop
                exitwhen i == .Counter
                if .Array<i>.ticks == 0 or GetUnitState(.Array<i>.caster, UNIT_STATE_LIFE) &lt; 0.405 then
                    call .Array<i>.destroy()
                    set .Array<i> = .Array[.Counter - 1]
                    set .Counter = .Counter - 1
                    set i = i - 1
                else
                    call .Array<i>.actions()
                    set .Array<i>.ticks = .Array<i>.ticks - 1
                endif
                set i = i + 1
            endloop

            if .Counter == 0 then
                call PauseTimer(.Timer)
            endif
        endmethod

        static method create takes unit caster, real targetX, real targetY returns Data
            local Data dat = .allocate()

            local real casterX = GetUnitX(caster)
            local real casterY = GetUnitY(caster)
            local real dx = targetX - casterX
            local real dy = targetY - casterY
            local real distance = SquareRoot(dx * dx + dy * dy)
            local real angle = Atan2(dy, dx)

            local real web1x = casterX + LIGHTNING_DISTANCE * Cos(angle + LIGHTNING_ANGLE)
            local real web1y = casterY + LIGHTNING_DISTANCE * Sin(angle + LIGHTNING_ANGLE)
            local real web2x = casterX + LIGHTNING_DISTANCE * Cos(angle - LIGHTNING_ANGLE)
            local real web2y = casterY + LIGHTNING_DISTANCE * Sin(angle - LIGHTNING_ANGLE)

            local real duration = distance / MAX_DISTANCE * MAX_DURATION

            set dat.caster = caster
            set dat.xInc = (distance / duration * INTERVAL) * Cos(angle)
            set dat.yInc = (distance / duration * INTERVAL) * Sin(angle)
            set dat.angle = angle
            set dat.damage = DamageAmount(GetUnitAbilityLevel(caster, SPELL_ID))

            set dat.web1 = AddLightning(LIGHTNING_PATH, true, web1x, web1y, targetX, targetY)
            call SetLightningColor(dat.web1, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.web2 = AddLightning(LIGHTNING_PATH, true, web2x, web2y, targetX, targetY)
            call SetLightningColor(dat.web2, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.targetX = targetX
            set dat.targetY = targetY

            set dat.ticks = R2I(duration / INTERVAL)

            set .Array[.Counter] = dat
            set .Counter = .Counter + 1
            if .Counter == 1 then
                call TimerStart(.Timer, INTERVAL, true, function Data.Handler)
            endif

            return dat
        endmethod

        private method onDestroy takes nothing returns nothing
            call SetUnitPathing(.caster, true)
            call DestroyLightning(.web1)
            call DestroyLightning(.web2)
            call DestroyGroup(.damagedGroup)
            call DestroyGroup(.currentGroup)
        endmethod
    endstruct

    private function Actions takes nothing returns nothing
        local location targetLoc = GetSpellTargetLoc()

        call Data.create(GetTriggerUnit(), GetLocationX(targetLoc), GetLocationY(targetLoc))

        call RemoveLocation(targetLoc)
        set targetLoc = null
    endfunction

    //==========================================================

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function Actions)
    endfunction

endscope</i></i></i></i></i></i></i>
 

Komaqtion

You can change this now in User CP.
Reaction score
469
There is no leak in that first trigger ;)

Second trigger looks fine to me...
But better wait for some more comments on that one :p

Though, I'd suggest you change it so that it uses at least one global group, of those two used...

Like this:
JASS:
scope Webshot initializer Init

    globals
        private constant integer    SPELL_ID            = &#039;yuty&#039;
        
        //The caster moves MAX_DISTANCE in MAX_DURATION. So, if the distance
        //to the target point is half MAX_DISTANCE, the duration will be half
        //too.
        private constant real       MAX_DISTANCE        = 1200.00
        private constant real       MAX_DURATION        = 1.20
        
        //String path for lightning effect, and some colour configuration.
        private constant string     LIGHTNING_PATH      = &quot;LEAS&quot;
        private constant real       LIGHTNING_A         = 0.82
        private constant real       LIGHTNING_R         = 0.15
        private constant real       LIGHTNING_G         = 1.00
        private constant real       LIGHTNING_B         = 0.10
        //Distance from the center of the caster to the angle direction.
        //The root of the webs are placed on those positions. If you don&#039;t
        //get it, test it.
        private constant real       LIGHTNING_DISTANCE  = 75.00
        private constant real       LIGHTNING_ANGLE     = bj_PI / 4

        private constant real       DAMAGE_RADIUS       = 112.00
        private constant attacktype DAMAGE_ATTACK_TYPE  = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_DAMAGE_TYPE  = DAMAGE_TYPE_UNIVERSAL
        private constant weapontype DAMAGE_WEAPON_TYPE  = WEAPON_TYPE_WHOKNOWS
        private constant string     DAMAGE_EFFECT       = &quot;Abilities\\Weapons\\PoisonArrow\\PoisonArrowMissile.mdl&quot;
        private constant string     DAMAGE_EFFECT_POINT = &quot;chest&quot;

        private constant real       INTERVAL            = 0.03
        
        // ==========================================================================================================
        
        private group currentGroup = CreateGroup()
    endglobals

    private constant function DamageFilter takes unit caster, unit target returns boolean
        return IsUnitEnemy(target, GetOwningPlayer(caster)) and IsUnitType(target, UNIT_TYPE_GROUND) == true
    endfunction

    private constant function DamageAmount takes integer level returns real
        return 00.00 + level * 75.00
    endfunction

    private struct Data
        private static timer Timer = CreateTimer()
        private static Data array Array
        private static integer Counter = 0

        private unit caster
        private real angle
        private real xInc
        private real yInc
        private real damage

        private lightning web1
        private lightning web2
        private real targetX
        private real targetY

        private integer ticks

        private group damagedGroup

        private static method ReturnTrue takes nothing returns boolean
            return true
        endmethod

        private method actions takes nothing returns nothing
            local real casterX = GetUnitX(.caster)
            local real casterY = GetUnitY(.caster)
            local unit f

            call SetUnitPathing(.caster, false)
            call SetUnitPosition(.caster, casterX + .xInc, casterY + .yInc)
            call SetUnitFacing(.caster, .angle * bj_RADTODEG)
            call MoveLightning(.web1, true, casterX + LIGHTNING_DISTANCE * Cos(.angle + LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle + LIGHTNING_ANGLE), .targetX, .targetY)
            call MoveLightning(.web2, true, casterX + LIGHTNING_DISTANCE * Cos(.angle - LIGHTNING_ANGLE), casterY + LIGHTNING_DISTANCE * Sin(.angle - LIGHTNING_ANGLE), .targetX, .targetY)

            call GroupEnumUnitsInRange(currentGroup, GetUnitX(.caster), GetUnitY(.caster), DAMAGE_RADIUS, Condition(function Data.ReturnTrue))
            loop
                set f = FirstOfGroup(currentGroup)
                exitwhen f == null
                call GroupRemoveUnit(currentGroup, f)
                if not IsUnitInGroup(f, .damagedGroup) and DamageFilter(.caster, f) then
                    call GroupAddUnit(.damagedGroup, f)
                    call UnitDamageTarget(.caster, f, .damage, true, false, DAMAGE_ATTACK_TYPE, DAMAGE_DAMAGE_TYPE, DAMAGE_WEAPON_TYPE)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, DAMAGE_EFFECT_POINT))
                endif
            endloop
        endmethod

        private static method Handler takes nothing returns nothing
            local integer i = 0

            loop
                exitwhen i == .Counter
                if .Array<i>.ticks == 0 or GetUnitState(.Array<i>.caster, UNIT_STATE_LIFE) &lt; 0.405 then
                    call .Array<i>.destroy()
                    set .Array<i> = .Array[.Counter - 1]
                    set .Counter = .Counter - 1
                    set i = i - 1
                else
                    call .Array<i>.actions()
                    set .Array<i>.ticks = .Array<i>.ticks - 1
                endif
                set i = i + 1
            endloop

            if .Counter == 0 then
                call PauseTimer(.Timer)
            endif
        endmethod

        static method create takes unit caster, real targetX, real targetY returns Data
            local Data dat = .allocate()

            local real casterX = GetUnitX(caster)
            local real casterY = GetUnitY(caster)
            local real dx = targetX - casterX
            local real dy = targetY - casterY
            local real distance = SquareRoot(dx * dx + dy * dy)
            local real angle = Atan2(dy, dx)

            local real web1x = casterX + LIGHTNING_DISTANCE * Cos(angle + LIGHTNING_ANGLE)
            local real web1y = casterY + LIGHTNING_DISTANCE * Sin(angle + LIGHTNING_ANGLE)
            local real web2x = casterX + LIGHTNING_DISTANCE * Cos(angle - LIGHTNING_ANGLE)
            local real web2y = casterY + LIGHTNING_DISTANCE * Sin(angle - LIGHTNING_ANGLE)

            local real duration = distance / MAX_DISTANCE * MAX_DURATION
            
            set dat.damagedGroup = CreateGroup()
            set dat.caster = caster
            set dat.xInc = (distance / duration * INTERVAL) * Cos(angle)
            set dat.yInc = (distance / duration * INTERVAL) * Sin(angle)
            set dat.angle = angle
            set dat.damage = DamageAmount(GetUnitAbilityLevel(caster, SPELL_ID))

            set dat.web1 = AddLightning(LIGHTNING_PATH, true, web1x, web1y, targetX, targetY)
            call SetLightningColor(dat.web1, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.web2 = AddLightning(LIGHTNING_PATH, true, web2x, web2y, targetX, targetY)
            call SetLightningColor(dat.web2, LIGHTNING_R, LIGHTNING_G, LIGHTNING_B, LIGHTNING_A)
            set dat.targetX = targetX
            set dat.targetY = targetY

            set dat.ticks = R2I(duration / INTERVAL)

            set .Array[.Counter] = dat
            set .Counter = .Counter + 1
            if .Counter == 1 then
                call TimerStart(.Timer, INTERVAL, true, function Data.Handler)
            endif

            return dat
        endmethod

        private method onDestroy takes nothing returns nothing
            call SetUnitPathing(.caster, true)
            call DestroyLightning(.web1)
            call DestroyLightning(.web2)
            call DestroyGroup(.damagedGroup)
        endmethod
    endstruct

    private function Actions takes nothing returns nothing
        local location targetLoc = GetSpellTargetLoc()

        call Data.create(GetTriggerUnit(), GetLocationX(targetLoc), GetLocationY(targetLoc))

        call RemoveLocation(targetLoc)
        set targetLoc = null
    endfunction

    //==========================================================

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function Actions)
    endfunction

endscope</i></i></i></i></i></i></i>
 

INCINERATE

New Member
Reaction score
12
okay ill switch it out for your posted code, what exactly does that do?

also question, is this running a periodic the entire game ? or is it turned on only for the duration of the spell then turned off?


cause i find even without using the spell the map is slower. so i have disabled the hero and the trigger using this spell for now, till this code is more effient, if you are wondering if its maybe the other spells this hero has, it cant be cause the other 3 are blizzard spells with no triggers .
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top