cleeezzz
The Undead Ranger.
- Reaction score
- 268
think GroupEnumUnitsInRange, it takes group, range, and boolexpr, whats interesting is the boolexpr does not take anything so how does this function run the unit through this filter?
scope Stupidity initializer Init
globals
private unit Caster
endglobals
public function Filt takes nothing returns nothing
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster))
endfunction
private function Init takes nothing returns nothing
set Caster = //....Some Unit Stuff
//...Some Group Stuff
endfunction
endscope
scope Random initializer Init
function PrivateFilter takes nothing returns boolean
return GetWidgetState(GetFilterUnit()) > .405
endfunction
function Actions takes nothing returns nothing
local group g2 = CreateGroup()
call GroupFilterUnit(g,g2,Condition(function PrivateFilter))
endfunction
//cut off, i dont care about the rest right now
scope Stupidity initializer Init
globals
private unit Caster
endglobals
public function Filt takes nothing returns nothing
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster))
endfunction
private function Init takes nothing returns nothing
set Caster = //....Some Unit Stuff
//...Some Group Stuff
call GroupEnum...(.......,Filter(function Filt))
endfunction
endscope
private function Match takes nothing returns boolean
return IsUnitAliveBJ(GetFilterUnit())
endfunction
call GroupEnum(Group2, ..., ..., ..., Filter(function Match))
globals
group g2 = CreateGroup()
endglobals
function Ostrich takes nothing returns nothing
if GetWidgetLife(GetEnumUnit()) > .405 then
call GroupAddUnit(g2,GetEnumUnit())
endif
endfunction
function ILikePotatos takes nothing returns nothing
local group g = CreateGroup()
ForGroup(g,function Ostrich)
endfunction
yes frozenhelfir, at least the idea is correct but it would make my coding easier just to have a custom function that does it all rather than pasting a bunch of those and modifying them to work with the triggers, (as you may have guessed, i use filtering almost everywhere but the way i was doing it was..)
library UnitAliveFilter
globals
private group g2 = CreateGroup()
endglobals
function UnitAlive takes group g returns group
local unit u
call GroupClear(g2) //not sure if this is the exact naming of it, this is freehand if you couldn't tell by lack of indent <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetWidgetLife(u) > .405 then
call GroupAddUnit(g2,u)
endif
call GroupRemoveUnit(g,u)
endloop
set u = null
return g2
endfunction
endlibrary
call UnitAlive(g1)
function GroupRunFilter takes group g, boolexpr filter returns group
local group g1 = CreateGroup()
local group g2 = CreateGroup()
local integer i = 0
local unit u = null
call GroupEnumUnitsInRect(g1, bj_mapInitialPlayableArea, filter)
call GroupAddGroup(g, g2)
loop
set u = FirstOfGroup(g2)
exitwhen u == null
if IsUnitInGroup(u, g1) == false then
call GroupRemoveUnit(g)
endif
call GroupRemoveUnit(u, g2)
endloop
return g
endfunction
How about:JASS:function GroupRunFilter takes group g, boolexpr filter returns group local group g1 = CreateGroup() local group g2 = CreateGroup() local integer i = 0 local unit u = null call GroupEnumUnitsInRect(g1, bj_mapInitialPlayableArea, filter) call GroupAddGroup(g, g2) loop set u = FirstOfGroup(g2) exitwhen u == null if IsUnitInGroup(u, g1) == false then call GroupRemoveUnit(g) endif call GroupRemoveUnit(u, g2) endloop return g endfunction
Something like that?