• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Condition Help

Status
Not open for further replies.
Level 5
Joined
Feb 22, 2013
Messages
161
JASS:
function BlueEntered takes nothing returns boolean
    return ( GetEnteringUnit() == udg_Paladin )
endfunction

function PurpleEntered takes nothing returns boolean
    return ( GetEnteringUnit() == udg_Warrior )
endfunction

function YellowEntered takes nothing returns boolean
    return ( GetEnteringUnit() == udg_Mage )
endfunction

function LightBlueEntered takes nothing returns boolean
    return ( GetEnteringUnit() == udg_Priest )
endfunction

function BlueIsThere takes nothing returns boolean
    return ( GetRectMinX(gg_rct_Ambush_Trigger) <= GetUnitX(udg_Paladin)) and (GetUnitX(udg_Paladin) <= GetRectMaxX(gg_rct_Ambush_Trigger)) and (GetRectMinY(gg_rct_Ambush_Trigger) <= GetUnitY(udg_Paladin)) and (GetUnitY(udg_Paladin) <= GetRectMaxY(gg_rct_Ambush_Trigger))
endfunction

function PurpleIsThere takes nothing returns boolean
    return ( GetRectMinX(gg_rct_Ambush_Trigger) <= GetUnitX(udg_Warrior)) and (GetUnitX(udg_Warrior) <= GetRectMaxX(gg_rct_Ambush_Trigger)) and (GetRectMinY(gg_rct_Ambush_Trigger) <= GetUnitY(udg_Warrior)) and (GetUnitY(udg_Warrior) <= GetRectMaxY(gg_rct_Ambush_Trigger))
endfunction

function YellowIsThere takes nothing returns boolean
    return ( GetRectMinX(gg_rct_Ambush_Trigger) <= GetUnitX(udg_Mage)) and (GetUnitX(udg_Mage) <= GetRectMaxX(gg_rct_Ambush_Trigger)) and (GetRectMinY(gg_rct_Ambush_Trigger) <= GetUnitY(udg_Mage)) and (GetUnitY(udg_Mage) <= GetRectMaxY(gg_rct_Ambush_Trigger))
endfunction

function LightBlueIsThere takes nothing returns boolean
    return ( GetRectMinX(gg_rct_Ambush_Trigger) <= GetUnitX(udg_Priest)) and (GetUnitX(udg_Priest) <= GetRectMaxX(gg_rct_Ambush_Trigger)) and (GetRectMinY(gg_rct_Ambush_Trigger) <= GetUnitY(udg_Priest)) and (GetUnitY(udg_Priest) <= GetRectMaxY(gg_rct_Ambush_Trigger))
endfunction

function Ambush_Trigger_Conditions takes nothing returns boolean
    if ( not BlueEntered() or PurpleEntered() or YellowEntered() or LightBlueEntered() ) then
        return false
    endif
    return true
endfunction

function Ambush_Trigger_Actions takes nothing returns nothing
    if ( BlueIsThere() and PurpleIsThere() and YellowIsThere() and LightBlueIsThere() ) then
        call DoNothing()
    else
        if ( IsPlayerInForce(GetLocalPlayer(), udg_UserGroup) ) then
            call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, "All heroes must be within the area to proceed.")
        endif
    endif
endfunction

//===========================================================================
function InitTrig_Ambush_Trigger takes nothing returns nothing
    local region rectRegion = CreateRegion()
    
    set gg_trg_Ambush_Trigger = CreateTrigger(  )
    call TriggerAddCondition(gg_trg_Ambush_Trigger, Condition(function Ambush_Trigger_Conditions))
    call TriggerAddAction( gg_trg_Ambush_Trigger, function Ambush_Trigger_Actions )
    call RegionAddRect(rectRegion, gg_rct_Ambush_Trigger)
    call TriggerRegisterEnterRegion(gg_trg_Ambush_Trigger, rectRegion, null)
endfunction

Now the problem is, is that in the Ambush_Trigger_Conditions, do the ors work? Because in-game however, blue will enter the region fine and activate the game text message in the actions, but any other player wont activate the message action in actions... Help is much appreciated :)
 
Level 4
Joined
May 25, 2009
Messages
100
I think the problem is that the "not" in your condition just for the BlueEntered(), but it should be for all of them (just add bracets)
or you just remove the "not" and the returns and then you get the function Doomlord just posted
 
Level 5
Joined
Feb 22, 2013
Messages
161
I think the problem is that the "not" in your condition just for the BlueEntered(), but it should be for all of them (just add bracets)
or you just remove the "not" and the returns and then you get the function Doomlord just posted

So adding the brackets before the 'not' and after the ors before 'then' worked. Thank you guys :thumbs_up:
 
Status
Not open for further replies.
Top