local groups not correct

C

crazedcougar

Guest
local groups not correct [solved]

Code:
function takes_food_bool takes nothing returns boolean
    if  ( (GetWidgetLife(GetFilterUnit()) > 0) and (GetUnitFoodUsed(GetFilterUnit()) > 0 )) then
        return true
    else
        return false
    endif
endfunction


function Trig_Untitled_Trigger_001_Func001002 takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetEnumUnit()) )
endfunction

function Trig_vex_Actions takes nothing returns nothing
   local boolexpr b = Condition(function takes_food_bool)
   local group redArmy = GetUnitsOfPlayerMatching(udg_playerC[1], b)
   local group blueArmy = GetUnitsOfPlayerMatching(udg_playerC[2], b) 

   call ForGroupBJ( redArmy, function Trig_Untitled_Trigger_001_Func001002 )
   call ForGroupBJ( blueArmy, function Trig_Untitled_Trigger_001_Func001002 )
endfunction
Hopefully you can see the problem after reading that, but heres the issue:
I give both players perfectly identical armies. I know this.

The variable redArmy only contains alive, food using, units.
The variable blueArmy contains every unit owned by udg_playerC[2]!

:nuts:

Note: Trig_vex_Actions has been pruned to only show the relevent bit. If you want to see all, I will post that.

EDIT: solved! It turns out that GetUnitsOfPlayerMatching destroys the boolxpr when its done.
 

corvusHaunt

New Member
Reaction score
96
Code:
(GetWidgetLife(GetFilterUnit()) > 0)

Just so you know, the cut off for a unit to be dead is actually .405, meaning you could be getting dead units. Plus, you might use
Code:
GetUnitState(GetFilterUnit(),ConvertUnitState(0)) > .405
instead, because the engine still has to type check to see if the widget matches the value, in this case a unit. You skip this by using GetUnitState(), because you can only use a unit for the parameter (the game won't have to check this because the editor will). Of course, the difference is really negligible.
 
General chit-chat
Help Users

      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