HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Advanced Filter System

11-09-2006, 09:57 PM#1
PandaMine
Zoom (requires log in)
Advanced Filter System is a system that allows you to customize your filters before you use them. Instead of having to make a seperate function for each different filter to use with AFS you set some options before you use your Condition (filter)
Changelog
v1.20 Added conditional functions for if a filtered unit is in range of a point
Added extra Remove Option Functions
Added conditional functions for Unit State (i.e. if a unit has less then/less then or equal to/equal to/greater then or equal to/greater then a certain amount of max/current health/mana
Check the official changelog for more information
v1.11 Fixed a very stupid bug with ClearFilter, it now works properly
v1.10 Just some minor changes for the code

Features
- Allows you to use Exception and Acceptance Functions for Unit Types, Races and Players
- Also has FilterAlliance and FilterVisible/Non-Visible
- Can use tokenized strings as these datatypes are constant integer

As an example of how the system works, you would od something like this

Collapse JASS:
set dummyvariable = FilterAddExceptionUnitType(UNIT_TYPE_HERO) + FilterAlliance(1)
//Use Your Filter Here with UseAFS as a Conditional Function
call ClearFilter()

This will filter out all units that are heroes and any friendly units

Credits
- Give credit when you use it in a public map
- The Functions Readme uses the same Template as the Caster System made by Vexorian
- The tokenize scripts code was taken from Vexorians Caster System
Attached Images
File type: jpgPrism_by_digitalgecko.jpg (3.3 KB)
Attached Files
File type: w3xAdvanced Filter System v1.20.w3x (30.1 KB)
11-09-2006, 10:03 PM#2
Taur
I havent looked at the map but I dont understand what exactly this system does, maybe post some screenshots?
11-09-2006, 10:08 PM#3
PandaMine
Well you do really need to look at the map but anyways here is a clear explanation

When you want to use filters (i.e. boolexpr filter when setting a group) you would use a filter something like this
Collapse JASS:
function FilterEnemy takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),GetTriggerPlayer())
endfunction

However when you want more options (i.e. Filter All Enemy Units, Only Include flying units owned by player 3 etc), intead of having to make a different function for each type of Filter this system allows you to set the a filter before you call it.

Some people call filters conditions, they are the exact same thing but Filters are only used with groups
11-10-2006, 04:54 AM#4
Jazradel
Can't you use 'and' for that?
11-10-2006, 11:21 AM#5
blu_da_noob
'unittype' and 'race' both extend handle, you don't need seperate return buggers for them, just use H2I.
Your ClearFilter function does nothing atm.
Instead of storing a boolean 'r' and checking it each time, just return false if any of the conditions is false.

Other than that, I'm debating the usefulness of this. Mm.
11-13-2006, 01:13 AM#6
PandaMine
Changed it so it uses H2I. Clear filter doesnt do anything in the test map because only one filter is being used, it cleans out the array which must be done. Changed it so it returns r if the condition is false

The system may be more useful on some maps than others as I mentioned in the into
11-14-2006, 04:35 AM#7
Jazradel
I still don't understand what this does.

What's wrong with using and?
Collapse JASS:
function AndTestC takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true and GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) > 0
endfunction

function AndTestA takes nothing returns nothing
    local unit u = GetEnumUnit()
endfunction

function Trig_And_Test_Actions takes nothing returns nothing
    call ForGroup( GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function AndTestC)), function AndTestA )
endfunction
And if you use the loop method you don't need filters at all.
11-14-2006, 01:50 PM#8
Chuckle_Brother
ForGroup is actually faster than iterating with a loop, Vex proved that a while back.
11-14-2006, 10:03 PM#9
PandaMine
Quote:
Originally Posted by Jazradel
I still don't understand what this does.

What's wrong with using and?
Collapse JASS:
function AndTestC takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true and GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) > 0
endfunction

function AndTestA takes nothing returns nothing
    local unit u = GetEnumUnit()
endfunction

function Trig_And_Test_Actions takes nothing returns nothing
    call ForGroup( GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function AndTestC)), function AndTestA )
endfunction
Not that you should use ForGroup when you can use the loop method.

The point of this system is not where you have simple Filters that have 1 or 2 conditions (such as using the and operator as you have shown) in which in the introduction to the system I have specifically stated. It is when you have more complicated combinations and possibilities, i.e. filter out all units that belong to a player that is a hero, undead and ranged that is invisible to a certain player. Not only that but the main point of the system is you do not have to create a seperate function for each different type of Filter.

This system is similar to damage options in Vex's Caster System, but instead of damage options this system just filter's out groups. In later versions there will be more options such as if unit is in a group or belongs to a specific force.

The system is definitly not as useless as you may think it is, i am currently a programmer for a map called RoW and it makes coding a hell of a lot faster and a lot less code
11-15-2006, 03:40 AM#10
Jazradel
Oh okay now I get it. I wouldn't use this personally but if your doing a lot of work with filters I can see how it would be useful.

I know Vexorian proved ForGroup was faster but I don't like having to pass variables to it with globals, the gamecache, etc.
11-15-2006, 05:58 AM#11
blu_da_noob
Your ClearFilter function is bugged. It will currently do nothing because your loop exit condition has the sign going the wrong way.
11-16-2006, 10:45 PM#12
PandaMine
Quote:
Originally Posted by blu_da_noob
Your ClearFilter function is bugged. It will currently do nothing because your loop exit condition has the sign going the wrong way.

Eh woops, ill fix that right away
11-17-2006, 04:47 AM#13
PandaMine
Updated and is now fixed
11-21-2006, 01:49 PM#14
blu_da_noob
You don't need to double post that kind of stuff >.>

It's useful enough, so... approved.

Oh, eh. Forgot this needs a picture. Please add one soon.
11-22-2006, 12:53 PM#15
ArchWorm
Eh, why that idea didn't come in my head? -_-
Ty, for the sys. +rep.