Ok, bare with me now. I am trying to write an AI function for one of the maps im making, I have had way to much trouble with desyncs and memory leaks using GUI so i have decided to convert all the problemed areas into jass to avoid this. One part of the trigger i am rewriting involves ordering a unit to attack another unit, which was defined by a variable. Here is the variable defining function
That is one giant mess and i do not want to have anything to do with that. From what i have learned so far, is the gui editor does conditions pretty poorly and inefficient. So now my question is can i combine all those into one with a function like this?
Or is that invalid? is there an easier way to pick any unit at random that is either 1 of 3 different units?
-
Find target
- Events
- Conditions
-
Actions
- Set Kingstar = (Random unit from (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to A.P.C) or (((Unit-type of (Matching unit)) Equal to Getaway Car) or ((Unit-type of (Matching unit)) Equal to Runner)))))
JASS:
function Trig_Find_target_Func001002001002001 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'hmtt' )
endfunction
function Trig_Find_target_Func001002001002002001 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'h000' )
endfunction
function Trig_Find_target_Func001002001002002002 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'uC01' )
endfunction
function Trig_Find_target_Func001002001002002 takes nothing returns boolean
return GetBooleanOr( Trig_Find_target_Func001002001002002001(), Trig_Find_target_Func001002001002002002() )
endfunction
function Trig_Find_target_Func001002001002 takes nothing returns boolean
return GetBooleanOr( Trig_Find_target_Func001002001002001(), Trig_Find_target_Func001002001002002() )
endfunction
function Trig_Find_target_Actions takes nothing returns nothing
set udg_Kingstar = GroupPickRandomUnit(GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Find_target_Func001002001002)))
endfunction
//===========================================================================
function InitTrig_Find_target takes nothing returns nothing
set gg_trg_Find_target = CreateTrigger( )
call TriggerAddAction( gg_trg_Find_target, function Trig_Find_target_Actions )
endfunction
That is one giant mess and i do not want to have anything to do with that. From what i have learned so far, is the gui editor does conditions pretty poorly and inefficient. So now my question is can i combine all those into one with a function like this?
JASS:
return ( GetUnitTypeId(GetFilterUnit()) == 'hmtt' or 'h000' or 'uC01')
Or is that invalid? is there an easier way to pick any unit at random that is either 1 of 3 different units?