Bool Expressions In detail

eXirrah

New Member
Reaction score
51
Can someone explain to me how Boolean Expressions work.

Seems like I got problems with them cause sometimes they work and sometimes
they don't

For example:
JASS:
function Trig_Revive_Zombies_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer i = GetRandomInt(1,20)
    call SetUnitAbilityLevel(u,'z000',i)
    call msg(0,GetUnitName(u) + " Reincarnation Level " + I2S(GetUnitAbilityLevel(u,'z000')) + " should be " + I2S(i))
endfunction

function IsTriggerUnitZombie takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == 'n000'
endfunction
//===========================================================================
function InitTrig_Revive_Zombies takes nothing returns nothing
    set gg_trg_Revive_Zombies = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEvent(gg_trg_Revive_Zombies,Player(11),EVENT_PLAYER_UNIT_DEATH,Condition(function IsTriggerUnitZombie))
    call TriggerAddAction( gg_trg_Revive_Zombies, function Trig_Revive_Zombies_Actions )
endfunction


This doesn't work....

Question that I have:
1. When using with TriggerRegister.... function what do I have to use GetTriggerUnit(), GetFilterUnit .....
2. Can I store the boolexpr in variable and then use it(my point is would it be calculated when the variable is created and not when the event starts)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
1. When using with TriggerRegister.... function what do I have to use GetTriggerUnit(), GetFilterUnit .....
GetTriggerUnit() is available in unit death event.

2. Can I store the boolexpr in variable and then use it(my point is would it be calculated when the variable is created and not when the event starts)
You can. Use Condition(whichCode) to store it!
 

ZugZugZealot

New Member
Reaction score
33
You'd use "[ljass]GetFilterUnit()[/ljass]" for boolean expressions. Though the unit that's passed as "FilterUnit" tends to vary. If I remember right, [ljass]GetFilterUnit()[/ljass] for the [ljass]EVENT_PLAYER_UNIT_ATTACKED[/ljass] event, [ljass]GetFilterUnit()[/ljass] passes the attacker instead of the triggering unit, which I prefer it does that instead for trying to make "Unit Attacks" oriented triggers.

Here's a good way to test which unit [ljass]GetFilterUnit()[/ljass] is based on the event you use...
JASS:
library GetFilterTest initializer Init
    globals
        private boolexpr myFilter
    endglobals

    private function BXPR takes nothing returns boolean
        call RemoveUnit(GetFilterUnit())
    endfunction

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        set myFilter = Condition(function BXPR)
        call TriggerRegisterPlayerUnitEvent( t, whichPlayer, whichEvent, myFilter ) //Supply your own player and EVENT_PLAYER_UNIT_...
    endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top