• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Matching Utils v.2.a

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
A Library to be able to faster call some Filters and to not have the same long lines ever and ever again.

Now featuring

GroupType-
  • Unit
  • Hero
  • Structure
  • Moveable
  • Flying
  • Ground
  • Mechanical
  • Ancient
  • Undead
  • Tauren
-Match


Every Categorie consists of 3 functions:
  • GroupType<one of Categories>Match
    catches all Units of that Categorie not being Immune
  • GroupType<one of Categories>ImmuneMatch
    catches all Units of that Categorie being Immune
  • GroupType<one of Categories>AllMatch
    catches all Units of that Categorie ,also Immune ones

so now to call this you have always 3 possibilities:

I take Unit as example:
JASS:
return GroupTypeUnitMatch()
return GroupTypeUnitImmuneMatch()
return GroupTypeUnitAllMatch()




Credits to maskedpoptart for IsUnitDead



JASS:
scope Spell initializer Init

globals
    private constant integer Spell_Id
    private boolexpr Con
    private unit Temp
endglobals

private function Match takes nothing returns nothing
    return IsUnitEnemy(GetFilterUnit() , GetOwningPlayer(Temp)) and GroupTypeHeroMatch()
endfunction

private function Conditions takes nothing returns boolean
    local unit u
    local group g

    if GetSpellAbiliyId() == Spell_Id then
    set u = GetTriggerUnit()u
    set g = CreateGroup() //NewGroup() if GroupUtils
    
    set Temp = u
    call GroupEnumUnitsInRange(g , x , y ,AOE , Con)

    //finish now your group is filled with the EnemyHeros 
   //do rest stuff here....
    endif
    
return false
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    set Con = Condition(function Match)
    //the usual rest : Add Condition ... Init Variables
endfunction
endscope



v.1.0 Initial Release
v.2.a Enormous Update featuring loads of new content


See Code here:

JASS:
//**************Matching  Utils *************************
//*                                                                                                    *
//*                                         v.2.a                                                   *
//*                                                                                                    *
//*                                by Saia_Djinn                                             *
//*                                                                                                    *
//*                                                                                                    *
//*                 Contains the most usual FilterFunctions                  *
//*                                                                                                    *
//*             Credits: maskedpoptart for IsUnitDead()                     *
//****************************************************

//                                                          USAGE

//              An Example shows best how to use this:

//      function Match takes nothing returns boolean
//           return IsUnitAlly( GetFilterUnit() , GetOwningPlayer(Temp)) and GroupUnitMatch()
//      endfunction

//  This would send a true for all allied units not being immune or a structure in the Filter

//Only thing you should most times call before this in a Match function is:

// IsUnitAlly() or IsUnitEnemy() or nothing if you want friendly fire

//for sure you can also call other function before this just simplifies some

//  Contains some functions to simplify Catching units in a Filter and to don't have to type it everytime again
//  Credits should be given


library MatchingUtils

function IsUnitDead takes unit u returns boolean // by maskedpoptart
      return IsUnitType(u, UNIT_TYPE_DEAD) or GetUnitTypeId(u) == 0
endfunction



function GroupTypeUnitMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO ) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeUnitImmuneMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO ) and IsUnitDead(GetFilterUnit()) ) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)
endfunction

function GroupTypeUnitAllMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO ) and IsUnitDead(GetFilterUnit()) ) == false 
endfunction



function GroupTypeHeroMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO )  and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeHeroImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO )  and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeHeroAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO ) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeStructureMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) and IsUnitDead(GetFilterUnit()) ) == false
endfunction

function GroupTypeStructureImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_STRUCTURE) and IsUnitType(GetFilterUnit() , UNIT_TYPE_MAGIC_IMMUNE) and IsUnitDead(GetFilterUnit())  == false
endfunction

function GroupTypeStructureAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_STRUCTURE) and IsUnitDead(GetFilterUnit())  == false
endfunction



function GroupTypeMovableMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeMovableImmuneMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitDead(GetFilterUnit()) ) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)
endfunction

function GroupTypeMovableAllMatch takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) and IsUnitDead(GetFilterUnit()) ) == false 
endfunction



function GroupTypeFlyingMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_FLYING) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeFlyingImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_FLYING) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeFlyingAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_FLYING) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeGroundMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_GROUND) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeGroundImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_GROUND) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeGroundAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_GROUND) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeMechanicalMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_MECHANICAL) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeMechanicalImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_MECHANICAL) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeMechanicalAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_MECHANICAL) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeAncientMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_ANCIENT) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeAncientImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_ANCIENT) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeAncientAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_ANCIENT) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeUndeadMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_UNDEAD) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeUndeadImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_UNDEAD) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeUndeadAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_UNDEAD) and IsUnitDead(GetFilterUnit()) == false 
endfunction



function GroupTypeTaurenMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_TAUREN) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) ) == false 
endfunction

function GroupTypeTaurenImmuneMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_TAUREN) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)   and IsUnitDead(GetFilterUnit()) == false 
endfunction

function GroupTypeTaurenAllMatch takes nothing returns boolean
    return IsUnitType(GetFilterUnit() , UNIT_TYPE_TAUREN) and IsUnitDead(GetFilterUnit()) == false 
endfunction

endlibrary


I attached also the Map where this is in but there is no show of usage as everything is threated here and you can't show a system that Helps Coding.

Maybe this could be posted in Submissions but i think it's well here too.

If you like this you must not download the Map just copy the Script in a empty trigger called MatchingUtils and use it.

Saia_Djinn

Keywords:
Saia_Djinn , Utils , Matching , System , Helpful , Filter
Contents

Noch eine WARCRAFT-III-Karte (Map)

Reviews
17:31, 9th Nov 2009 TriggerHappy187: A bunch of BJ's and a demo map which does nothing.

Moderator

M

Moderator

17:31, 9th Nov 2009
TriggerHappy187:

A bunch of BJ's and a demo map which does nothing.
 
Yes, -JonNny pointed out a good thing.
There should be a lot more matching conditions and alot of more functionality in this library.

For example, you could add an function that creates unitgroups automaticly with a filter you choose when you say GroupCreateRange(x, y, range, filtercond) to something like GroupCreateRangeLiving.
 
Level 8
Joined
Feb 15, 2009
Messages
463
Yeah that's right Ana but with something like Create functions this would be a hard piece coz some guys use GroupUtils some not and Creating Groups then /or taking New always the deal
For sure you can require GroupUtils but then it looses Portability and this would be useless for global groups then.

There could be more functions but i think i got the most used ones in there and it's v.1.0 so adding new ones would'nt be a big deal

Furthermore this is nothing new for experienced Jassers but is a GUI spell something new for them ? I think not

This is mostly pointed to amateur/novice Jassers still on the way to point things out for them.For sure they can write a own , but why not save time and take this and port it to the things you need?(e.g. add new functions)

If it's not rejected i will surely add some more functions to this to cover a broader palette of different Filtertypes
 
Level 11
Joined
Apr 29, 2007
Messages
826
Well both static ifs and that library thingie are kind of new, yes.
static ifs can only be used together with constant booleans. JassHelper will compile only the part which is true. Example:
JASS:
    constant boolean SHOW_MSG = false

    function whatever takes nothing returns nothing
        static if SHOW_MSG then
            call BJDebugMsg("Message!")
        endif
    endfunction
So JassHelper would delete all the contents there. If you set it to true, there will just be the BJDebugMsg call.

That LIBRARY_NAME thing is quite easy. If there is a library named like that, it is true, else, it's false. Means if you got GroupUtils, it's true. So you can easily put a different code in there if the user has GroupUtils.
JASS:
    function bla takes nothing returns nothing
        local group g
        static if LIBRARY_GroupUtils then
            set g = NewGroup() //or whatever that GroupUtils function is called
        else
            set g = CreateGroup()
        endif
    endfunction
 
Top