HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can Boolexpr's get 'overloaded'?

08-04-2008, 04:40 PM#1
Fulla
I'm experiencing a strange bug, in a shooter type map (ET2).
Basically at any given time there are generally tonnes of projectiles & particle flying all over the place with periodic movement & grouping.

For a projectile to 'impact' onto a unit I simply check for 3 things.
Is it alive, not invulnerable & not have a specific buff (An item can give this buff temporarily).
Entire Code

Collapse JASS:
function ParticleCollisionCond takes nothing returns boolean
    local unit u = GetEnumUnit()
    local unit f = null
    local location l = null
    local integer p = udg_clsParticlePlace[GetUnitUserData(u)]
    local integer tv
    local real area = 80
    local group g = CreateGroup()
    local boolexpr  b = Filter(function DeadUnit)
  //Was projectile enhanced by a User with Imbued Shells? (Increases area)
    if GetUnitAbilityLevel(u,'AIx1')>0 then
        set area=120
    endif
    call GroupEnumUnitsInRange(g, udg_vectorX[p], udg_vectorY[p], area, b)
    loop
        set f=FirstOfGroup(g)
        exitwhen f==null
      //Is unit enemy of projectile else a C4, an Explosive Barrel or a Tree?
        if IsUnitEnemy(f, GetOwningPlayer(u)) or GetUnitTypeId(f)=='hdhw' or GetUnitTypeId(f)=='opeo' or GetUnitTypeId(f)=='uaco' then
            set l = GetUnitLoc(f)
            set tv = VectorCreate(GetLocationX(l), GetLocationY(l), GetLocationZ(l)+GetUnitFlyHeight(f))
            call RemoveLocation(l)
          //Check for 3d Height as well
            if IsPointInSphere(tv, p, area) then
                call VectorDestroy(tv)
                set udg_elimTUnit = f //This is a temp global to be used in the conditionfuncs
                set u = null
                set f = null
                call DestroyGroup(g)
                call DestroyBoolExpr(b)
                return true
            endif
        
            call VectorDestroy(tv)
        endif
        call GroupRemoveUnit(g,f)
    endloop
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set u = null
    set f = null
    return false
endfunction



thx
08-04-2008, 04:43 PM#2
Captain Griffen
You don't destroy boolexprs (unless created from AND or OR, but blargh).

Condition(function DeadUnit) == Condition(function DeadUnit)

Thus, destroy one, you destroy all.
08-04-2008, 04:45 PM#3
Fulla
Added code to main thread.
So use conditions instead your saying?
08-04-2008, 04:45 PM#4
Troll-Brain
The unit can be dead and have more than 0.405 hp.
With a trigger action or a buggy ability.

http://www.wc3campaigns.net/showthread.php?t=101654
08-04-2008, 04:48 PM#5
Captain Griffen
Quote:
Originally Posted by Fulla
Added code to main thread.
So use conditions instead your saying?

I meant Filter.

Anyway, don't use DestroyBoolExpr(b); boolexprs created from functions don't leak, but get cached, and if you destroy it, then all instances of boolexprs created from that function will be destroyed.

Alternatively, if you ever set a dead unit to have HP > 0.405, then, as troll-brain said, it can bug.
08-04-2008, 04:52 PM#6
Fulla
Ok I'll try this then:
Collapse JASS:
IsUnitType(unit, UNIT_TYPE_DEAD)
08-04-2008, 11:52 PM#7
DioD
what problem?

projectiles collide with nothing or ignore units?
08-05-2008, 01:20 AM#8
d07.RiV
Yes you didn't mention what problem you were experiencing.

Also why do you use GetUnitLoc/GetLocationXY/RemoveLocation when you can just use GetUnitXY.
08-05-2008, 04:42 AM#9
DioD
He also check unit's height by location, this function looks incomplete.
08-05-2008, 07:28 AM#10
Fulla
Quote:
Originally Posted by DioD
what problem?

projectiles collide with nothing or ignore units?

The problem is/was that often projectiles would collide with dead units/corpses.
I'll have to see how it goes with the new boolean thou & report back.
08-05-2008, 10:03 AM#11
DioD
There is one unit per player and some barrels\barricades, you can mark them by youself, if UNIT_DEATH triggers set costom value to 0 and check it. This is much more better then unit state and widget life both, since 0 CS unit is already removed or dead and this surely known.