What is the best way to check if the unit left the rect? I want to check whether the unit is still inside the rect or not. In this case, checking the distance does not work because it is rect.
Edit: here is my solution, but it does not look efficient
Edit: here is my solution, but it does not look efficient
JASS:
call LineSegment.EnumUnitsEx(temp_group, rect1X, rect1Y, rect2X, rect2Y, RECT_LENGTH , true)
loop
set u = FirstOfGroup(temp_group)
exitwhen u == null
if (BaseBool(u) and not IsUnitEnemy(u, this.owner)) then
call GroupAddUnit(check, u)
if not IsUnitInGroup(u, this.barrierDef) then
//Turn on Immunities
call GroupAddUnit(this.barrierDef, u)
endif
endif
call GroupRemoveUnit(temp_group, u)
endloop
set copy = CopyGroup(this.barrierDef)
loop
set u = FirstOfGroup(copy)
exitwhen u == null
if not IsUnitInGroup(u, check) then
//Turn off immunities
call GroupRemoveUnit(this.barrierDef, u)
endif
call GroupRemoveUnit(copy, u)
endloop
call GroupClear(check)
Last edited: