HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

TriggerRegisterUnitInRange description?

06-29-2004, 07:44 PM#1
anctan
Can anyone tell me what boolean expressions I can use with this event type?
The parameters are trigger whichTrigger, unit whichUnit, real range, boolexpr filter. Can I use an expression that checks if unit coming within range is a hero?
06-29-2004, 07:56 PM#2
Vexorian
A boolexpr is not a boolean expression, it is a Condition handle,

function ReturnTrue takes nothing returns boolean
return true
endfunction

Condition(function ReturnTrue)
Is a boolexpr
06-29-2004, 08:39 PM#3
anctan
How do I create the condition for this TriggerRegisterUnitInRange that checks if a unit coming within range is a hero (there is also TriggerRegisterUnitInRangeSimple that doesn't take a boolexpr and it is simply GUI Event - Unit Within Range)? Will

call TriggerRegisterUnitInRange( gg_trg_In_Range2, 300.00, udg_Myunit, ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) work?
06-29-2004, 08:53 PM#4
AIAndy
No, as Lord Vexorian said, that filter code needs to be in a separate function. Like filters in GroupEnum... or conditions in triggers.
06-30-2004, 06:43 AM#5
anctan
Here is a script code:

Code:
function Trig_RangeJ_Conditions takes nothing returns boolean
    if ( not ( IsUnitInGroup(GetTriggerUnit(), udg_ScoutGroup) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_RangeJ_Cond2 takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
       return false
    endif
    return true
endfunction

function Trig_RangeJ_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_145" )
endfunction

//===========================================================================
function InitTrig_RangeJ takes nothing returns nothing
    set gg_trg_RangeJ = CreateTrigger(  )
    call TriggerRegisterUnitInRange( gg_trg_RangeJ, 300.00, udg_Jaina, Condition( function Trig_RangeJ_Cond2 ) )
    call TriggerAddCondition( gg_trg_RangeJ, Condition( function Trig_RangeJ_Conditions ) )
    call TriggerAddAction( gg_trg_RangeJ, function Trig_RangeJ_Actions )
endfunction

Will this work? If not, can anyone give me an example of a correct use of TriggerRegisterUnitInRange?
06-30-2004, 11:29 AM#6
AIAndy
It is likely that GetTriggerUnit is not the right event response here. And it may be that you do not need a Condition but a Filter.
06-30-2004, 01:47 PM#7
anctan
The problem is that I don't understand what a filter or a boolexpr is. When I look at this "TriggerRegisterUnitInRange" native (if it, actually, is a native) I see that it takes whichTrigger, unit whichUnit, real range, boolexpr filter. It's OK with the first three parameters, I understand them; but what do I do about boolexpr? This will most probably be my first attempt at any JASS scripting. I read "boolexpr" as some kind of condition which makes the trigger fire only when it evaluates to true. But I don't know how to add conditions / filters. Maybe you could give me an example with a native that takes a boolexpr like this one?
07-01-2004, 01:51 PM#8
Cubasis
Boolexpr is a type.

Filters and Conditions are also a type. They are derived from Boolexpr. And you can't create boolexpr's, but you can create filters and conditions.

To create a Filter or a Condition, you use the two simple natives:

Filter( code )
Condition( code )

Where code is something like this: function <name>

These functions then return a filter/condition object that you use. Notice that then, to use Boolexpr's, you need to have the condition/filter in a function of it's own.

And yes, Boolexpr's do exactly what you think, I'm not sure about any difference between Conditions and Filters, except, you normally use filters with Events and Unit Group functions, and conditions with Conditions (no shit).

So then you'd just do something like this:

call TriggerRegisterUnitInRange( gg_trg_RangeJ, 300.00, udg_Jaina, Filter( function IsHero ) )

Where IsHero is a function that returns true if the triggering unit is a hero, or false if it's not.

Examples of other functions are... TriggerAddCondition, and most of the Group functions.

The reason the Simple function doesn't take a boolexpr, is that it's a ugly blizzard.j interfacing function, that simply references the native, and....loses this (filter) functionality.

~Cubasis
07-02-2004, 08:04 PM#9
Starcraftfreak
Quote:
Originally Posted by AIAndy
It is likely that GetTriggerUnit is not the right event response here. And it may be that you do not need a Condition but a Filter.
To access the unit that is currently passed through the filter you have to call GetFilterUnit() (instead of GetTriggerUnit in your case).

@Cubasis:
I didn't even know the "Filter(code)" function. I always use "Condition(code)" for that purpose. Since a boolexpr is supposed to be the same in both cases there may be no difference between the two. The only thing I wonder about then is that both exist.