• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Leak check

Status
Not open for further replies.
Level 4
Joined
Nov 27, 2012
Messages
85
mostly concerned about the groups created

JASS:
function Trig_Doom_Mantle_Conditions takes nothing returns boolean
    local integer index=0
    local item indexItem

    loop
        set indexItem=UnitItemInSlot(GetFilterUnit(),index)
        if indexItem!=null and (GetItemTypeId(indexItem)=='IC71' or GetItemTypeId(indexItem)=='I00A') and IsUnitIllusion(GetFilterUnit())==false then
            return true
        elseif GetUnitTypeId(GetFilterUnit())=='ninf' then
            return true
        endif
        set index=index+1
        exitwhen index>=bj_MAX_INVENTORY
    endloop
    return false
endfunction

function DoomMantle_Damage takes nothing returns nothing
    local group g=CreateGroup()
    local unit u=GetEnumUnit()
    local unit p
    local integer i=0
    local integer index=0
        
    call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),250.00,null)
    
    loop
        exitwhen index>5
        if GetItemTypeId(UnitItemInSlot(u,index))=='IC71' or GetItemTypeId(UnitItemInSlot(u,index))=='I00A' then
            set i=i+1
        endif
        set index=index+1
    endloop
    
    loop
        set p=FirstOfGroup(g)

        exitwhen p==null
                                                                                       
        if IsUnitEnemy(p,GetOwningPlayer(u)) and IsUnitType(p,UNIT_TYPE_STRUCTURE)==false and IsUnitType(p,UNIT_TYPE_MECHANICAL)==false and IsUnitType(p,UNIT_TYPE_MAGIC_IMMUNE)==false and IsUnitType(p,UNIT_TYPE_SLEEPING)==false and IsUnitInvisible(u,GetOwningPlayer(p))==false and GetUnitTypeId(p)!='ohwd' and GetUnitTypeId(p)!='o00A' then
            if GetUnitTypeId(u)=='ninf' then
                call UnitDamageTarget(u,p,(10.00),true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null)
            else        
                call UnitDamageTarget(u,p,(10.00*i),true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null)          
            endif 
            
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Immolation\\ImmolationDamage.mdl",p,"head"))
        endif
       
        call GroupRemoveUnit(g,p)
    endloop
    
    call DestroyGroup(g)
    set g=null
    set u=null
    set p=null   
endfunction

function Trig_Doom_Mantle_Actions takes nothing returns nothing
    local group g=CreateGroup()
        
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,Condition(function Trig_Doom_Mantle_Conditions))   
    call ForGroup(g,function DoomMantle_Damage)

    call DestroyGroup(g) 
    set g=null
endfunction
//===========================================================================
function InitTrig_Doom_Mantle takes nothing returns nothing
    set gg_trg_Doom_Mantle=CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_Doom_Mantle,1.00,true)
    call TriggerAddAction(gg_trg_Doom_Mantle,function Trig_Doom_Mantle_Actions)
endfunction
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
bj_lastCreatedGroup is a group which you can use which is never destroyed in order to do these instant-enunerations.

Instead of making a trigger, event and actionfunc, just use TimerStart(CreateTimer(), 0, true, function Actions).

So instead of "normal" init functions, like blizzard created, it is more efficient to just create a timer for periodic game time events?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
That's not anything I've ever heard. You can have thousands of things happening at once. It depends on the PC and what is happening trigger-wise when the timers expire.

Where did you read this wrong information?

sry I cant remember anymore, I read it a long time ago, or thought so.
Well I guess, I rather choose to believe what you just replied. Thanks alot for clarifying this! Let me give you some rep for this! :thumbs_up:
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
sry, I thought you could just have 100 timers max at one timepoint?
It's wrong information. A maximum timer count would be only limited
by the capabilities of Warcraft and your computer.

If you wish you could run tousands of timers during the same time, which is however not recommended. :)

Afaik the only capped handle is the texttag handle. This one has a upper limit of 100 during the same time.
The cap can be exceeded by creating texttags for a local player. Then it's 100 per client.
 
Status
Not open for further replies.
Top